Commit cc1007ad authored by djGrrr's avatar djGrrr Committed by Franco Fichtner

make the ipv4 subnet matching code work like the ipv6 code, fixes bug in...

make the ipv4 subnet matching code work like the ipv6 code, fixes bug in subnet matching on tun interfaces

(cherry picked from commit 07d2354a)
(cherry picked from commit b3bad8d2)
parent c2819c16
......@@ -246,8 +246,15 @@ function legacy_interfaces_details($intf = null)
$result[$current_interface]["macaddr"] = $line_parts[1];
} elseif (strpos($line, "\tinet ") !== false) {
// IPv4 information
$mask = substr_count(base_convert(hexdec($line_parts[3]), 10, 2), '1');
unset($mask);
for ($i = 0; $i < count($line_parts) - 1; ++$i) {
if ($line_parts[$i] == 'netmask') {
$mask = substr_count(base_convert(hexdec($line_parts[($i + 1)]), 10, 2), '1');
}
}
if (isset($mask)) {
$result[$current_interface]["ipv4"][] = array("ipaddr" => $line_parts[1], "subnetbits" => $mask);
}
} elseif (strpos($line, "\tinet6 ") !== false) {
// IPv6 information
$addr = strtok($line_parts[1], '%');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment