mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Backport simplify subnet_size()
Original pull request to master was #3007
This commit is contained in:
parent
c9d6b915da
commit
f24e175eeb
@ -838,12 +838,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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user