From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonatan Schlag To: network@lists.ipfire.org Subject: [network] [PATCH 1/4] ipv4: new function ipv4_net_is_valid Date: Sat, 03 Jun 2017 13:25:07 +0200 Message-ID: <1496489110-10134-1-git-send-email-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2605802499419978452==" List-Id: --===============2605802499419978452== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit This function checks if a given network is valid IPv4 network Signed-off-by: Jonatan Schlag --- 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}" -- 2.6.3 --===============2605802499419978452==--