From: Jonatan Schlag Date: Fri, 2 Jun 2017 09:46:53 +0000 (+0200) Subject: ip: rename ip_is_network to ip_net_is_valid X-Git-Tag: 009~233 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b0958b26165c9b3d19068db4c54584632bacb45;p=network.git ip: rename ip_is_network to ip_net_is_valid We rename this function to state clear what the function is actually doing. The function checks if a network is valid and not if something is a network or not. Fixes: 11357 Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index acf5a718..7a28bb14 100644 --- a/Makefile.am +++ b/Makefile.am @@ -445,7 +445,7 @@ TESTS = \ test/load-library \ test/functions/ip/ip_detect_protocol \ test/functions/ip/ip_get_prefix \ - test/functions/ip/ip_is_network \ + test/functions/ip/ip_net_is_valid \ test/functions/ip/ip_is_valid \ test/functions/ip/ip_network_is_subnet_of \ test/functions/ip/ip_prefix_is_valid \ diff --git a/src/functions/functions.ip b/src/functions/functions.ip index 97750e36..ec108ac9 100644 --- a/src/functions/functions.ip +++ b/src/functions/functions.ip @@ -79,7 +79,7 @@ ip_is_valid() { return ${EXIT_FALSE} } -ip_is_network() { +ip_net_is_valid() { local network=${1} assert isset network diff --git a/src/functions/functions.route b/src/functions/functions.route index 1b6369ef..86328a0c 100644 --- a/src/functions/functions.route +++ b/src/functions/functions.route @@ -56,7 +56,7 @@ route_add() { assert isset network - if ! ip_is_network ${network} && ! ip_is_valid ${network}; then + if ! ip_net_is_valid ${network} && ! ip_is_valid ${network}; then error "The given network is invalid: ${network}" return ${EXIT_ERROR} fi @@ -154,7 +154,7 @@ route_remove() { for _network in $@; do # Validate input - if ! ip_is_network ${_network} && ! ip_is_valid ${_network}; then + if ! ip_net_is_valid ${_network} && ! ip_is_valid ${_network}; then error "Invalid IP address or network: ${_network}" error=${EXIT_ERROR} continue @@ -296,7 +296,7 @@ route_parse_line() { isset network || return ${EXIT_ERROR} # Is network or IP valid? - if ! ip_is_network ${network} && ! ip_is_valid ${network}; then + if ! ip_net_is_valid ${network} && ! ip_is_valid ${network}; then error "The given network is invalid: ${network}" return ${EXIT_ERROR} fi @@ -408,7 +408,7 @@ route_entry_add() { assert isset network - if ! ip_is_network ${network} && ! ip_is_valid ${network}; then + if ! ip_net_is_valid ${network} && ! ip_is_valid ${network}; then error "The given network is invalid: ${network}" return ${EXIT_ERROR} fi diff --git a/test/functions/ip/ip_is_network b/test/functions/ip/ip_net_is_valid similarity index 83% rename from test/functions/ip/ip_is_network rename to test/functions/ip/ip_net_is_valid index 9e9a546f..4db59e86 100755 --- a/test/functions/ip/ip_is_network +++ b/test/functions/ip/ip_net_is_valid @@ -7,7 +7,7 @@ failed=0 for network in ${VALID_NETWORKS[@]}; do - if ip_is_network ${network}; then + if ip_net_is_valid ${network}; then echo "OK: network: ${network} is valid" else echo "ERROR: network ${network} is invalid" @@ -16,7 +16,7 @@ for network in ${VALID_NETWORKS[@]}; do done for network in ${INVALID_NETWORKS[@]}; do - if ! ip_is_network ${network}; then + if ! ip_net_is_valid ${network}; then echo "OK: network: ${network} is invalid" else echo "ERROR: network: ${network} is valid"