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>
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 \
return ${EXIT_FALSE}
}
-ip_is_network() {
+ip_net_is_valid() {
local network=${1}
assert isset network
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
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
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
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
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"
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"