From: Jonatan Schlag Date: Sat, 3 Jun 2017 11:25:08 +0000 (+0200) Subject: ip: restructure ip_net_is_valid X-Git-Tag: 009~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2bd71e40901a45300dfeb06ba7073017e2d9634;p=network.git ip: restructure ip_net_is_valid Insted of checking the network manually we now just calö ipv4_net_is_valid or ipv6_net_is_valid Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.ip b/src/functions/functions.ip index ec108ac9..5a821141 100644 --- a/src/functions/functions.ip +++ b/src/functions/functions.ip @@ -83,23 +83,14 @@ ip_net_is_valid() { local network=${1} assert isset network - # Get the address part. - local address=$(ip_split_prefix ${network}) - isset address || return ${EXIT_FALSE} - - # Get the prefix. - local prefix=$(ip_get_prefix ${network}) - isset prefix || return ${EXIT_FALSE} - - # Detect the protocol (if this fails, the - # address part is invalid) - local proto=$(ip_detect_protocol ${address}) - isset proto || return ${EXIT_FALSE} - - # Check if the prefix is correct. - ip_prefix_is_valid ${proto} ${prefix} || return ${EXIT_FALSE} + local protocol + for protocol in ${IP_SUPPORTED_PROTOCOLS}; do + if ${protocol}_net_is_valid "${network}"; then + return ${EXIT_TRUE} + fi + done - return ${EXIT_TRUE} + return ${EXIT_FALSE} } ip_prefix_is_valid() {