Revision f24e175e
Added by Phil Davis about 9 years ago
src/etc/inc/util.inc | ||
---|---|---|
838 | 838 |
Returns 0 for bad data or if cannot represent size as an INT when $exact is set. */ |
839 | 839 |
function subnet_size($subnet, $exact=false) { |
840 | 840 |
$parts = explode("/", $subnet); |
841 |
if (count($parts) == 2) { |
|
842 |
if (is_ipaddrv4($parts[0])) { |
|
843 |
return subnet_size_by_netmask(4, $parts[1], $exact); |
|
844 |
} elseif (is_ipaddrv6($parts[0])) { |
|
845 |
return subnet_size_by_netmask(6, $parts[1], $exact); |
|
846 |
} |
|
841 |
$iptype = is_ipaddr($parts[0]); |
|
842 |
if (count($parts) == 2 && $iptype) { |
|
843 |
return subnet_size_by_netmask($iptype, $parts[1], $exact); |
|
847 | 844 |
} |
848 | 845 |
return 0; |
849 | 846 |
} |
Also available in: Unified diff
Backport simplify subnet_size()
Original pull request to master was #3007