]> git.ipfire.org Git - network.git/commitdiff
ip: rename ip_is_network to ip_net_is_valid
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Fri, 2 Jun 2017 09:46:53 +0000 (11:46 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 7 Jun 2017 16:32:17 +0000 (18:32 +0200)
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 <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/functions/functions.ip
src/functions/functions.route
test/functions/ip/ip_net_is_valid [moved from test/functions/ip/ip_is_network with 83% similarity]

index acf5a718f3b25265f1a291169ca04ceb2256220b..7a28bb14fbb9bf9c7d7206748702bdf8b99791dc 100644 (file)
@@ -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 \
index 97750e36b2fc6c980c703458c8d9f79df3eff587..ec108ac9000624852bc112c34cef4ab0a6cdd411 100644 (file)
@@ -79,7 +79,7 @@ ip_is_valid() {
        return ${EXIT_FALSE}
 }
 
-ip_is_network() {
+ip_net_is_valid() {
        local network=${1}
        assert isset network
 
index 1b6369efbbee15466481b6684ee49221753d247f..86328a0c01db8c34db9665a768461ad1bd4e0a90 100644 (file)
@@ -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
similarity index 83%
rename from test/functions/ip/ip_is_network
rename to test/functions/ip/ip_net_is_valid
index 9e9a546f66b515dab85ee860e4b65d52e3046e3f..4db59e860a36267dc7155cd704df2e914f38136e 100755 (executable)
@@ -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"