This function checks if a given network is valid IPv4 network
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.ipv4 | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/src/functions/functions.ipv4 b/src/functions/functions.ipv4 index f63c2b7..e893f5e 100644 --- a/src/functions/functions.ipv4 +++ b/src/functions/functions.ipv4 @@ -51,6 +51,15 @@ ipv4_prefix_is_valid() { return ${EXIT_TRUE} }
+ipv4_net_is_valid() { + local net="${1}" + + local prefix="$(ip_get_prefix "${net}")" + local addr="$(ip_split_prefix "${net}")" + + ipv4_prefix_is_valid "${prefix}" && ipv4_is_valid "${addr}" +} + ipv4_netmask_is_valid() { local netmask="${1}"