$entry1) { if ((int)$ipv === 1) { $ip_version = 'ipv4'; } elseif ((int)$ipv === 2) { $ip_version = 'ipv6'; } else { // other types unknown continue; } foreach ($entry1 as $ip_snmp => $entry) { list($len, $ip_snmp) = explode('.', $ip_snmp, 2); $ip_address = $ip_version === 'ipv6' ? snmp2ipv6($ip_snmp) : $ip_snmp; if ($entry['lldpLocManAddrIfSubtype'] === 'ifIndex') { $ifIndex = $entry['lldpLocManAddrIfId']; } elseif ($port_id = get_port_id_by_ifDescr($device['device_id'], $entry['lldpLocManAddrIfId'])) { $port = get_port_by_id_cache($port_id); $ifIndex = $port['ifIndex']; } else { continue; } $data = [ 'ifIndex' => $ifIndex, 'ip' => $ip_address ]; discover_add_ip_address($device, $mib, $data); } } unset($ifIndex, $ip_address, $ip_snmp, $entry1, $oid_data); } // EOF