mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
Add a special case for /31 networks to openvpn_get_interface_ip() (another instance of #2529).
This commit is contained in:
parent
15fa1eb0d4
commit
7c833ea3d6
@ -1485,9 +1485,21 @@ function openvpn_create_dirs()
|
||||
|
||||
function openvpn_get_interface_ip($ip, $mask)
|
||||
{
|
||||
$baselong = ip2long32($ip) & ip2long($mask);
|
||||
$ip1 = long2ip32($baselong + 1);
|
||||
$ip2 = long2ip32($baselong + 2);
|
||||
$masklong = ip2long($mask);
|
||||
$baselong = ip2long32($ip) & $masklong;
|
||||
|
||||
// Special case for /31 networks which lack network and broadcast addresses.
|
||||
// As per RFC3021, both addresses should be treated as host addresses.
|
||||
if ($masklong == 0xfffffffe)
|
||||
{
|
||||
$ip1 = long2ip32($baselong);
|
||||
$ip2 = long2ip32($baselong + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ip1 = long2ip32($baselong + 1);
|
||||
$ip2 = long2ip32($baselong + 2);
|
||||
}
|
||||
return array($ip1, $ip2);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user