From mboxrd@z Thu Jan  1 00:00:00 1970
From: Jonatan Schlag <jonatan.schlag@ipfire.org>
To: network@lists.ipfire.org
Subject: [network] [PATCH] ip: rename ip_is_network to ip_net_is_valid
Date: Fri, 02 Jun 2017 11:46:53 +0200
Message-ID: <1496396813-7949-1-git-send-email-jonatan.schlag@ipfire.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============0577513027087666129=="
List-Id: <network.lists.ipfire.org>

--===============0577513027087666129==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

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 o=
r 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 =3D \
 	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}
 }
=20
-ip_is_network() {
+ip_net_is_valid() {
 	local network=3D${1}
 	assert isset network
=20
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() {
=20
 	assert isset network
=20
-	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() {
=20
 	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=3D${EXIT_ERROR}
 			continue
@@ -296,7 +296,7 @@ route_parse_line() {
 	isset network || return ${EXIT_ERROR}
=20
 	# 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() {
=20
 	assert isset network
=20
-	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=3D0
-
-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=3D1
-	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=3D1
-	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=3D0
+
+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=3D1
+	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=3D1
+	fi
+done
+
+exit ${failed}
--=20
2.6.3


--===============0577513027087666129==--