$entry) { if ($entry['sysSelfIpUnitId'] != '0') { continue; } // Skip all except self Unit addresses $ifName = $entry['sysSelfIpVlanName']; if (isset($ports_ifDescr[$ifName])) { $ifIndex = $ports_ifDescr[$ifName]['ifIndex']; $ip_version = $entry['sysSelfIpAddrType']; $ip_address = hex2ip($entry['sysSelfIpAddr']); $ip_mask = hex2ip($entry['sysSelfIpNetmask']); if ($ip_version == 'ipv4') { $ip_mask_fix = explode('.', $ip_mask); if (empty($ip_mask) || count($ip_mask_fix) != 4) { $ip_mask = '255.255.255.255'; } } else { // IPv6 - not tested $prefix = 0; $m = str_split($ip_mask); foreach ($m as $c) { if ($c == ":") { continue; } if ($c == "0") { break; } $bin = base_convert($c, 16, 2); $bin = trim($bin, "0"); $prefix += strlen($bin); } } /* $ip_data[$ip_version][$ifIndex][$ip_address] = array('ifIndex' => $ifIndex, 'ip' => $ip_address, 'mask' => $ip_mask, 'prefix' => $prefix); */ $data = [ 'ifIndex' => $ifIndex, 'ip' => $ip_address, 'mask' => $ip_mask, 'prefix' => $prefix ]; discover_add_ip_address($device, $mib, $data); } unset($ifName, $ifIndex, $ip_version, $ip_address, $ip_mask, $prefix); } //} unset($ports_ifDescr, $ifIndex, $ip_address, $ip_mask_fix, $oid_data, $flags); // EOF