mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
bring back subnetv4_expand function used by pfblockerng
This commit is contained in:
parent
e6ddb55ef3
commit
2208be8b2d
@ -877,6 +877,20 @@ function subnet_size_by_netmask($iptype, $bits, $exact=false) {
|
||||
}
|
||||
}
|
||||
|
||||
/* function used by pfblockerng */
|
||||
function subnetv4_expand($subnet) {
|
||||
$result = array();
|
||||
list ($ip, $bits) = explode("/", $subnet);
|
||||
$net = ip2long($ip);
|
||||
$mask = (0xffffffff << (32 - $bits));
|
||||
$net &= $mask;
|
||||
$size = round(exp(log(2) * (32 - $bits)));
|
||||
for ($i = 0; $i < $size; $i += 1) {
|
||||
$result[] = long2ip($net | $i);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* find out whether two IPv4/IPv6 CIDR subnets overlap.
|
||||
Note: CIDR overlap implies one is identical or included so largest sn will be the same */
|
||||
function check_subnets_overlap($subnet1, $bits1, $subnet2, $bits2) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user