]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/functions/functions.route
hostapd: Dump config file in debug mode
[people/ms/network.git] / src / functions / functions.route
index 6a2c1fa5a695366e84cae4a513d9ca29ced00ee4..e6ea2441ef0a69c10dda0a10c7808eab7912425d 100644 (file)
@@ -23,7 +23,7 @@
 #
 
 cli_route() {
-       if cli_help_requested $@; then
+       if cli_help_requested "$@"; then
                cli_show_man network-route
                exit ${EXIT_OK}
        fi
@@ -33,7 +33,7 @@ cli_route() {
 
        case "${action}" in
                static)
-                       cli_route_static $@
+                       cli_route_static "$@"
                        ;;
                *)
                        error "Unrecognized action: ${action}"
@@ -47,7 +47,7 @@ cli_route() {
 }
 
 cli_route_static() {
-       if cli_help_requested $@; then
+       if cli_help_requested "$@"; then
                cli_show_man network-route-static
                exit ${EXIT_OK}
        fi
@@ -58,20 +58,20 @@ cli_route_static() {
        case "${action}" in
                # Add a new route.
                add)
-                       route_add $@
+                       route_add "$@"
                        ;;
                # Remove an existing route.
                remove)
-                       route_remove $@
+                       route_remove "$@"
                        ;;
                # List all routes.
                list)
-                       route_list $@
+                       route_list "$@"
                        return ${EXIT_OK}
                        ;;
                # Reload all routes
                reload)
-                       route_apply $@
+                       route_apply "$@"
                        ;;
                *)
                        error "Unrecognized action: ${action}"
@@ -93,7 +93,7 @@ route_add() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --gateway=*)
-                               gateway=$(cli_get_val ${1})
+                               gateway=$(cli_get_val "${1}")
                                ;;
                        --unreachable)
                                unreachable="true"
@@ -105,7 +105,7 @@ route_add() {
                                blackhole="true"
                                ;;
                        --mtu=*)
-                               mtu=$(cli_get_val ${1})
+                               mtu=$(cli_get_val "${1}")
                                ;;
                        *)
                                if isset network; then
@@ -217,7 +217,7 @@ route_remove() {
        local _network
        local error=${EXIT_OK}
 
-       for _network in $@; do
+       for _network in "$@"; do
                # Validate input
                if ! ip_net_is_valid ${_network} && ! ip_is_valid ${_network}; then
                        error "Invalid IP address or network: ${_network}"
@@ -260,7 +260,7 @@ route_list() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --protocol=*)
-                               protocol=$(cli_get_val ${1})
+                               protocol=$(cli_get_val "${1}")
                                ;;
                        *)
                                warning "Unrecognized argument: ${1}"
@@ -335,25 +335,25 @@ route_parse_line() {
        while read arg; do
                case "${arg}" in
                        network=*)
-                               network=$(cli_get_val ${arg})
+                               network=$(cli_get_val "${arg}")
                                ;;
                        gateway=*)
-                               gateway=$(cli_get_val ${arg})
+                               gateway=$(cli_get_val "${arg}")
                                ;;
                        unreachable=*)
-                               unreachable=$(cli_get_val ${arg})
+                               unreachable=$(cli_get_val "${arg}")
                                ;;
                        prohibit=*)
-                               prohibit=$(cli_get_val ${arg})
+                               prohibit=$(cli_get_val "${arg}")
                                ;;
                        blackhole=*)
-                               blackhole=$(cli_get_val ${arg})
+                               blackhole=$(cli_get_val "${arg}")
                                ;;
                        mtu=*)
-                               mtu=$(cli_get_val ${arg})
+                               mtu=$(cli_get_val "${arg}")
                                ;;
                esac
-       done <<< "$(args $@)"
+       done <<< "$(args "$@")"
 
        ### Check if all values are correctly set.
 
@@ -393,41 +393,11 @@ route_parse_line() {
 }
 
 route_apply() {
-       local table="static"
-       local type
+       # Re-generate BIRD configuration
+       bird_generate_config
 
-       log DEBUG "Applying static routes..."
-
-       # Flush the routing table.
-       route_table_flush ${table}
-
-       local ${NETWORK_CONFIG_ROUTES_PARAMS}
-       local line
-       while read line; do
-               route_parse_line ${line}
-               [ $? -eq ${EXIT_OK} ] || continue
-
-               type="unicast"
-               local arg
-               for arg in unreachable prohibit blackhole; do
-                       if enabled ${arg}; then
-                               type="${arg}"
-                               break
-                       fi
-               done
-
-               # Add the route.
-               route_entry_add ${network} --table="static" --proto="static" \
-                       --type="${type}" --gateway="${gateway}" --mtu="${mtu}"
-               local ret=$?
-
-               if [ ${ret} -ne ${EXIT_OK} ]; then
-                       log WARNING "Could not set route '${network}'."
-               fi
-       done < ${NETWORK_CONFIG_ROUTES}
-
-       # Create a lookup rule for the static routing table.
-       route_rule_add --lookup="static" --priority=1000
+       # Reload the daemon
+       bird_reload
 }
 
 route_entry_add() {
@@ -443,19 +413,19 @@ route_entry_add() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --gateway=*)
-                               gateway=$(cli_get_val ${1})
+                               gateway=$(cli_get_val "${1}")
                                ;;
                        --table=*)
-                               table=$(cli_get_val ${1})
+                               table=$(cli_get_val "${1}")
                                ;;
                        --type=*)
-                               type=$(cli_get_val ${1})
+                               type=$(cli_get_val "${1}")
                                ;;
                        --proto=*)
-                               proto=$(cli_get_val ${1})
+                               proto=$(cli_get_val "${1}")
                                ;;
                        --mtu=*)
-                               mtu=$(cli_get_val ${1})
+                               mtu=$(cli_get_val "${1}")
                                ;;
                        *)
                                if isset network; then
@@ -574,7 +544,7 @@ route_table_flush() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --protocol=*)
-                               protocol=$(cli_get_val ${1})
+                               protocol=$(cli_get_val "${1}")
                                ;;
                        *)
                                table="${1}"
@@ -621,7 +591,7 @@ route_table_exists() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --id=*)
-                               _id=$(cli_get_val ${1})
+                               _id=$(cli_get_val "${1}")
                                ;;
                        *)
                                _table=${1}
@@ -653,13 +623,13 @@ route_rule_add() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --lookup=*)
-                               lookup=$(cli_get_val ${1})
+                               lookup=$(cli_get_val "${1}")
                                ;;
                        --priority=*)
-                               priority=$(cli_get_val ${1})
+                               priority=$(cli_get_val "${1}")
                                ;;
                        --protocol=*)
-                               protocols=$(cli_get_val ${1})
+                               protocols=$(cli_get_val "${1}")
 
                                assert isoneof protocols ${IP_SUPPORTED_PROTOCOLS}
                                ;;
@@ -717,16 +687,16 @@ route_rule_exists() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --from=*)
-                               from=$(cli_get_val ${1})
+                               from=$(cli_get_val "${1}")
                                ;;
                        --lookup=*)
-                               lookup=$(cli_get_val ${1})
+                               lookup=$(cli_get_val "${1}")
                                ;;
                        --priority=*)
-                               prio=$(cli_get_val ${1})
+                               prio=$(cli_get_val "${1}")
                                ;;
                        --protocol=*)
-                               proto=$(cli_get_val ${1})
+                               proto=$(cli_get_val "${1}")
                                ;;
                        *)
                                warning "Unrecognized argument: ${1}"