if (in_array($subnet->sectionId, $permitted_sections)) { $permitted_devices_mac[] = $d; } } } // if none set die if (!isset($permitted_devices_arp)) { $Result->show("danger", _("No devices for SNMP ARP query available"), true); } if (!isset($permitted_devices_mac)) { $Result->show("danger", _("No devices for SNMP MAC address query available"), true); } // first we need ARP table to fetchIP <> MAC mappings foreach ($permitted_devices_arp as $d) { // init $Snmp->set_snmp_device($d); // fetch arp table try { $res = $Snmp->get_query("get_arp_table"); // remove those not in subnet if (sizeof($res) > 0) { // save for debug $debug[$d->hostname]["get_arp_table"] = $res; // check foreach ($res as $kr => $r) { // if is inside subnet if ($Subnets->is_subnet_inside_subnet($r['ip'] . "/32", $Subnets->transform_address($subnet->subnet, "dotted") . "/" . $subnet->mask) === false) { } elseif (in_array($r['ip'], $subnet_ip_addresses)) { } else { $found_arp[] = $r; }
$device = $Tools->fetch_object("devices", "id", str_replace("device-", "", $k)); if ($device !== false) { $scan_devices[] = $device; } } } // if none set die if (!isset($scan_devices)) { $Result->show("danger", _("No devices for SNMP VRF query available"), true); } // init result array $new_vrfs = array(); // ok, we have devices, connect to each device and do query foreach ($scan_devices as $d) { // init $Snmp->set_snmp_device($d); // fetch arp table try { $res = $Snmp->get_query("get_vrf_table"); // remove those not in subnet if (sizeof($res) > 0) { // save for debug $debug[$d->hostname]["get_vrf_table"] = $res; // loop and save foreach ($res as $k => $r) { if (!array_key_exists($k, $new_vrfs) && !array_key_exists($k, $ex_vrfs)) { $new_vrfs[$k] = $r; } } } } catch (Exception $e) {
# init snmp class $Snmp = new phpipamSNMP(); # set queries foreach ($_POST as $k => $p) { if (strpos($k, "query-") !== false) { if ($p == "on") { $queries[] = substr($k, 6); } } } # fake as device queries $device->snmp_queries = implode(";", $queries); # open connection if (isset($queries)) { // set device $Snmp->set_snmp_device($device); // loop foreach ($queries as $query) { try { // overrides for MAC table query - we need to test with some vlan number, so we need vlan first if ($query == "get_mac_table") { $Snmp->get_query("get_vlan_table"); if (is_array($Snmp->last_result)) { foreach ($Snmp->last_result as $k => $r) { if (is_numeric($k)) { // ok, we have vlan, set query $Snmp->set_snmp_device($device, $k); try { $Snmp->get_query($query); $vlan_set = true; break;