diff options
author | stilez <stilez@users.noreply.github.com> | 2016-06-17 05:12:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-17 05:12:51 +0100 |
commit | 0987677ac58ba5e22c9d26f4d1af509b3010a5d6 (patch) | |
tree | 09a916c88b4b70f8a55a03124fd1aa0eea54ace2 | |
parent | 9c40391966dbd9c69d2bfbfbf042d3277adb145d (diff) | |
download | pfsense-0987677ac58ba5e22c9d26f4d1af509b3010a5d6.zip pfsense-0987677ac58ba5e22c9d26f4d1af509b3010a5d6.tar.gz |
simplify subnet_size()
is_ipaddr() returns the type of IP if valid. Use this to simplify the function
-rw-r--r-- | src/etc/inc/util.inc | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index 171483e..fe4a3d4 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -839,12 +839,9 @@ function is_subnetoralias($subnet) { Returns 0 for bad data or if cannot represent size as an INT when $exact is set. */ function subnet_size($subnet, $exact=false) { $parts = explode("/", $subnet); - if (count($parts) == 2) { - if (is_ipaddrv4($parts[0])) { - return subnet_size_by_netmask(4, $parts[1], $exact); - } elseif (is_ipaddrv6($parts[0])) { - return subnet_size_by_netmask(6, $parts[1], $exact); - } + $iptype = is_ipaddr($parts[0]); + if (count($parts) == 2 && $iptype) { + return subnet_size_by_netmask($iptype, $parts[1], $exact); } return 0; } |