diff options
author | Warren Baker <warren@decoy.co.za> | 2011-09-29 01:26:57 +0200 |
---|---|---|
committer | Warren Baker <warren@decoy.co.za> | 2011-09-29 01:26:57 +0200 |
commit | fdb9c1dbb63b93ed0230e66a79559cbdd3cb7943 (patch) | |
tree | a2e64f971ad6ccfa4860224266c999add4bea616 /etc/inc/util.inc | |
parent | 433e98427c6f66e3170b125c2541896cc073ff0e (diff) | |
download | pfsense-fdb9c1dbb63b93ed0230e66a79559cbdd3cb7943.zip pfsense-fdb9c1dbb63b93ed0230e66a79559cbdd3cb7943.tar.gz |
Add is_subnetv6 for checking of IPv6 subnets
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r-- | etc/inc/util.inc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 0222e5c..b065868 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -509,7 +509,7 @@ function is_subnet($subnet) { list($hp,$np) = explode('/', $subnet); - if (!is_ipaddr($hp)) + if (!is_ipaddrv4($hp)) return false; if (!is_numeric($np) || ($np < 1) || ($np > 32)) @@ -518,6 +518,23 @@ function is_subnet($subnet) { return true; } +/* returns true if $subnet is a valid IPv6 subnet in CIDR format */ +function is_subnetv6($subnet) { + if (!is_string($subnet)) + return false; + + list($hp,$np) = explode('/', $subnet); + + if (!is_ipaddrv6($hp)) + return false; + + if (!is_numeric($np) || ($np < 1) || ($np > 128)) + return false; + + return true; +} + + /* returns true if $subnet is a valid subnet in CIDR format or an alias thereof */ function is_subnetoralias($subnet) { global $aliastable; |