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(a)ipfire.org>
---
Makefile.am | 2 +-
src/functions/functions.ip | 2 +-
src/functions/functions.route | 8 ++++----
test/functions/ip/ip_is_network | 27 ---------------------------
test/functions/ip/ip_net_is_valid | 27 +++++++++++++++++++++++++++
5 files changed, 33 insertions(+), 33 deletions(-)
delete mode 100755 test/functions/ip/ip_is_network
create mode 100755 test/functions/ip/ip_net_is_valid
diff --git a/Makefile.am b/Makefile.am
index acf5a71..7a28bb1 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 97750e3..ec108ac 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 1b6369e..86328a0 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_is_network
deleted file mode 100755
index 9e9a546..0000000
--- a/test/functions/ip/ip_is_network
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-
-. ${functions}
-
-. ${testdir}/constants.sh
-
-failed=0
-
-for network in ${VALID_NETWORKS[@]}; do
- if ip_is_network ${network}; then
- echo "OK: network: ${network} is valid"
- else
- echo "ERROR: network ${network} is invalid"
- failed=1
- fi
-done
-
-for network in ${INVALID_NETWORKS[@]}; do
- if ! ip_is_network ${network}; then
- echo "OK: network: ${network} is invalid"
- else
- echo "ERROR: network: ${network} is valid"
- failed=1
- fi
-done
-
-exit ${failed}
diff --git a/test/functions/ip/ip_net_is_valid b/test/functions/ip/ip_net_is_valid
new file mode 100755
index 0000000..4db59e8
--- /dev/null
+++ b/test/functions/ip/ip_net_is_valid
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+. ${functions}
+
+. ${testdir}/constants.sh
+
+failed=0
+
+for network in ${VALID_NETWORKS[@]}; do
+ if ip_net_is_valid ${network}; then
+ echo "OK: network: ${network} is valid"
+ else
+ echo "ERROR: network ${network} is invalid"
+ failed=1
+ fi
+done
+
+for network in ${INVALID_NETWORKS[@]}; do
+ if ! ip_net_is_valid ${network}; then
+ echo "OK: network: ${network} is invalid"
+ else
+ echo "ERROR: network: ${network} is valid"
+ failed=1
+ fi
+done
+
+exit ${failed}
--
2.6.3