function snmpgeneric_list($object_id) { global $sg_create_noconnector_ports, $sg_known_sysObjectIDs, $sg_portoifoptions, $sg_ifType_ignore; if (isset($_POST['snmpconfig'])) { $snmpconfig = $_POST; } else { showError("Missing SNMP Config"); return; } // sg_var_dump_html($snmpconfig); echo '<body onload="document.getElementById(\'createbutton\').focus();">'; addJS('function setchecked(classname) { var boxes = document.getElementsByClassName(classname); var value = document.getElementById(classname).checked; for(i=0;i<boxes.length;i++) { if(boxes[i].disabled == false) boxes[i].checked=value; } };', TRUE); $object = spotEntity('object', $object_id); $object['attr'] = getAttrValues($object_id); $snmpdev = new mySNMP($snmpconfig['version'], $snmpconfig['host'], $snmpconfig['community']); if ($snmpconfig['version'] == "v3") { $snmpdev->setSecurity($snmpconfig['sec_level'], $snmpconfig['auth_protocol'], $snmpconfig['auth_passphrase'], $snmpconfig['priv_protocol'], $snmpconfig['priv_passphrase']); } $snmpdev->init(); if ($snmpdev->getErrno()) { showError($snmpdev->getError()); return; } /* SNMP connect successfull */ showSuccess("SNMP " . $snmpconfig['version'] . " connect to {$snmpconfig['host']} successfull"); echo '<form name=CreatePorts method=post action=' . $_SERVER['REQUEST_URI'] . '&module=redirect&op=create>'; echo "<strong>System Informations</strong>"; echo "<table>"; // echo "<tr><th>OID</th><th>Value</th></tr>"; $systemoids = array('sysDescr', 'sysObjectID', 'sysUpTime', 'sysContact', 'sysName', 'sysLocation'); foreach ($systemoids as $shortoid) { $value = $snmpdev->{$shortoid}; if ($shortoid == 'sysUpTime') { /* in hundredths of a second */ $secs = (int) ($value / 100); $days = (int) ($secs / (60 * 60 * 24)); $secs -= $days * 60 * 60 * 24; $hours = (int) ($secs / (60 * 60)); $secs -= $hours * 60 * 60; $mins = (int) ($secs / 60); $secs -= $mins * 60; $value = "{$value} ({$days} {$hours}:{$mins}:{$secs})"; } echo "<tr><td title=\"" . $snmpdev->lastgetoid . "\" align=\"right\">{$shortoid}: </td><td>{$value}</td></tr>"; } unset($shortoid); echo "</table>"; /* sysObjectID Attributes and Ports */ $sysObjectID['object'] =& $object; /* get sysObjectID */ $sysObjectID['raw_value'] = $snmpdev->sysObjectID; //$sysObjectID['raw_value'] = 'NET-SNMP-MIB::netSnmpAgentOIDs.10'; $sysObjectID['value'] = preg_replace('/^.*enterprises\\.([\\.[:digit:]]+)$/', '\\1', $sysObjectID['raw_value']); /* try snmptranslate to numeric */ if (preg_match('/[^\\.0-9]+/', $sysObjectID['value'])) { $numeric_value = $snmpdev->translatetonumeric($sysObjectID['value']); if (!empty($numeric_value)) { showSuccess("sysObjectID: " . $sysObjectID['value'] . " translated to {$numeric_value}"); $sysObjectID['value'] = preg_replace('/^.1.3.6.1.4.1.([\\.[:digit:]]+)$/', '\\1', $numeric_value); } } /* array_merge doesn't work with numeric keys !! */ $sysObjectID['attr'] = array(); $sysObjectID['port'] = array(); $sysobjid = $sysObjectID['value']; $count = 1; while ($count) { if (isset($sg_known_sysObjectIDs[$sysobjid])) { $sysObjectID = $sysObjectID + $sg_known_sysObjectIDs[$sysobjid]; if (isset($sg_known_sysObjectIDs[$sysobjid]['attr'])) { $sysObjectID['attr'] = $sysObjectID['attr'] + $sg_known_sysObjectIDs[$sysobjid]['attr']; } if (isset($sg_known_sysObjectIDs[$sysobjid]['port'])) { $sysObjectID['port'] = $sysObjectID['port'] + $sg_known_sysObjectIDs[$sysobjid]['port']; } if (isset($sg_known_sysObjectIDs[$sysobjid]['text'])) { showSuccess("found sysObjectID ({$sysobjid}) " . $sg_known_sysObjectIDs[$sysobjid]['text']); } } $sysobjid = preg_replace('/\\.[[:digit:]]+$/', '', $sysobjid, 1, $count); /* add default sysobjectid */ if ($count == 0 && $sysobjid != 'default') { $sysobjid = 'default'; $count = 1; } } $sysObjectID['vendor_number'] = $sysobjid; /* device pf */ if (isset($sysObjectID['pf'])) { foreach ($sysObjectID['pf'] as $function) { if (function_exists($function)) { /* call device pf */ $function($snmpdev, $sysObjectID, NULL); } else { showWarning("Missing processor function " . $function . " for device {$sysobjid}"); } } } /* sort attributes maintain numeric keys */ ksort($sysObjectID['attr']); /* DEBUG */ //sg_var_dump_html($sysObjectID['attr'], "Before processing"); /* needs PHP >= 5 foreach call by reference */ /* php 5.1.6 doesn't seem to work */ //foreach($sysObjectID['attr'] as $attr_id => &$attr) foreach ($sysObjectID['attr'] as $attr_id => $value) { $attr =& $sysObjectID['attr'][$attr_id]; if (isset($object['attr'][$attr_id])) { if (array_key_exists('key', $object['attr'][$attr_id])) { $attr['key'] = $object['attr'][$attr_id]['key']; } switch (TRUE) { case isset($attr['pf']): if (function_exists($attr['pf'])) { $attr['pf']($snmpdev, $sysObjectID, $attr_id); } else { showWarning("Missing processor function " . $attr['pf'] . " for attribute {$attr_id}"); } break; case isset($attr['oid']): $attrvalue = $snmpdev->get($attr['oid']); if (isset($attr['regex'])) { $regex = $attr['regex']; if (isset($attr['replacement'])) { $replacement = $attr['replacement']; $attrvalue = preg_replace($regex, $replacement, $attrvalue); } else { if (!preg_match($regex, $attrvalue)) { if (!isset($attr['uncheck'])) { $attr['uncheck'] = "regex doesn't match"; } } else { unset($attr['uncheck']); } } } $attr['value'] = $attrvalue; break; case isset($attr['value']): break; default: showError("Error handling attribute id: {$attr_id}"); } } else { showWarning("Object has no attribute id: {$attr_id}"); unset($sysObjectID['attr'][$attr_id]); } } unset($attr_id); /* sort again in case there where attribs added ,maintain numeric keys */ ksort($sysObjectID['attr']); /* print attributes */ echo '<br>Attributes<br><table>'; echo '<tr><th><input type="checkbox" id="attribute" checked="checked" onclick="setchecked(this.id)"></td>'; echo '<th>Name</th><th>Current Value</th><th>new value</th></tr>'; /* DEBUG */ //sg_var_dump_html($sysObjectID['attr'], "After processing"); foreach ($sysObjectID['attr'] as $attr_id => &$attr) { $attr['id'] = $attr_id; if (isset($object['attr'][$attr_id]) && isset($attr['value'])) { if ($attr['value'] == $object['attr'][$attr_id]['value']) { $attr['uncheck'] = 'Current = new value'; } if (isset($attr['key']) && isset($object['attr'][$attr_id]['key'])) { if ($attr['key'] == $object['attr'][$attr_id]['key']) { $attr['uncheck'] = 'Current = new key'; } } $value = $attr['value']; $val_key = isset($object['attr'][$attr_id]['key']) ? ' (' . $object['attr'][$attr_id]['key'] . ')' : ''; $comment = ''; if (isset($attr['comment'])) { if (!empty($attr['comment'])) { $comment = $attr['comment']; } } if (isset($attr['uncheck'])) { $checked = ''; $comment .= ', ' . $attr['uncheck']; } else { $checked = ' checked="checked"'; } $updateattrcheckbox = '<b style="background-color:#00ff00">' . '<input style="background-color:#00ff00" class="attribute" type="checkbox" name="updateattr[' . $attr_id . ']" value="' . $value . '"' . $checked . '></b>'; $comment = trim($comment, ', '); echo "<tr><td>{$updateattrcheckbox}</td><td title=\"id: {$attr_id}\">" . $object['attr'][$attr_id]['name'] . '</td><td style="background-color:#d8d8d8">' . $object['attr'][$attr_id]['value'] . $val_key . '</td><td>' . $value . '</td>' . '<td style="color:#888888">' . $comment . '</td></tr>'; } } unset($attr_id); echo '</table>'; $object['breed'] = sg_detectDeviceBreedByObject($sysObjectID); if (!empty($object['breed'])) { echo "Found Breed: " . $object['breed'] . "<br>"; } /* ports */ /* get ports */ amplifyCell($object); /* set array key to lowercase port name */ foreach ($object['ports'] as $key => $values) { $object['ports'][strtolower(shortenIfName($values['name'], $object['breed']))] = $values; unset($object['ports'][$key]); } $newporttypeoptions = getNewPortTypeOptions(); // sg_var_dump_html($sysObjectID['port']); if (!empty($sysObjectID['port'])) { echo '<br>Vendor / Device specific ports<br>'; echo '<table><tr><th><input type="checkbox" id="moreport" checked="checked" onclick="setchecked(this.id)"></th><th>ifName</th><th>porttypeid</th></tr>'; foreach ($sysObjectID['port'] as $name => $port) { if (array_key_exists(strtolower($name), $object['ports'])) { $disableport = TRUE; } else { $disableport = FALSE; } $comment = ''; if (isset($port['comment'])) { if (!empty($port['comment'])) { $comment = $port['comment']; } } if (isset($port['uncheck'])) { $checked = ''; $comment .= ', ' . $port['uncheck']; } else { $checked = ' checked="checked"'; } $portcreatecheckbox = '<b style="background-color:' . ($disableport ? '#ff0000' : '#00ff00') . '"><input style="background-color:' . ($disableport ? '#ff0000' : '#00ff00') . '" class="moreport" type="checkbox" name="portcreate[' . $name . ']" value="' . $name . '"' . ($disableport ? ' disabled="disbaled"' : $checked) . '></b>'; $formfield = '<input type="hidden" name="ifName[' . $name . ']" value="' . $name . '">'; echo "<tr>{$formfield}<td>{$portcreatecheckbox}</td><td>{$name}</td>"; if (isset($port['disabled'])) { $disabledselect = array('disabled' => "disabled"); } else { $disabledselect = array(); } foreach ($port as $key => $value) { if ($key == 'uncheck' || $key == 'comment') { continue; } /* TODO iif_name */ if ($key == 'porttypeid') { $displayvalue = getNiftySelect($newporttypeoptions, array('name' => "porttypeid[{$name}]") + $disabledselect, $value); } else { $displayvalue = $value; } $formfield = '<input type="hidden" name="' . $key . '[' . $name . ']" value="' . $value . '">'; echo "{$formfield}<td>{$displayvalue}</td>"; } $comment = trim($comment, ', '); echo "<td style=\"color:#888888\">{$comment}</td></tr>"; } unset($name); unset($port); echo '</table>'; } /* snmp ports */ $ifsnmp = new ifSNMP($snmpdev); // needed for shortenIfName() $ifsnmp->object_breed = $object['breed']; /* ip spaces */ $ipspace = NULL; foreach ($ifsnmp->ipaddress as $ifindex => $ipaddresses) { foreach ($ipaddresses as $ipaddr => $value) { $addrtype = $value['addrtype']; $netaddr = $value['net']; $maskbits = $value['maskbits']; $netid = NULL; $linklocal = FALSE; //echo "<br> - DEBUG: ipspace $ipaddr - $netaddr - $addrtype - $maskbits<br>"; /* check for ip space */ switch ($addrtype) { case 'ipv4': case 'ipv4z': if ($maskbits == 32) { $netid = 'host'; } else { $netid = getIPv4AddressNetworkId(ip_parse($ipaddr)); } break; case 'ipv6': if (ip_checkparse($ipaddr) === false) { /* format ipaddr for ip6_parse */ $ipaddr = preg_replace('/((..):(..))/', '\\2\\3', $ipaddr); $ipaddr = preg_replace('/%.*$/', '', $ipaddr); } if (ip_checkparse($ipaddr) === false) { continue 2; } // 2 because of switch $ip6_bin = ip6_parse($ipaddr); $ip6_addr = ip_format($ip6_bin); $netid = getIPv6AddressNetworkId($ip6_bin); $node = constructIPRange($ip6_bin, $maskbits); $netaddr = $node['ip']; $linklocal = substr($ip6_addr, 0, 5) == "fe80:"; //echo "<br> - DEBUG: ipspace $ipaddr - $addrtype - $maskbits - $netaddr - >$linklocal<<br>"; break; case 'ipv6z': /* link local */ $netid = 'ignore'; break; default: } if (empty($netid) && $netaddr != '::1' && $netaddr != '127.0.0.1' && $netaddr != '127.0.0.0' && $netaddr != '0.0.0.0' && !$linklocal) { $netaddr .= "/{$maskbits}"; $ipspace[$netaddr] = array('addrtype' => $addrtype, 'checked' => $maskbits > 0 ? true : false); } } unset($ipaddr); unset($value); unset($addrtype); } unset($ifindex); unset($ipaddresses); /* print ip spaces table */ if (!empty($ipspace)) { echo '<br><br>Create IP Spaces'; echo '<table><tr><th><input type="checkbox" id="ipspace" onclick="setchecked(this.id)" checked=\\"checked\\"></th>'; echo '<th>Type</th><th>prefix</th><th>name</th><th width=150 title="reserve network and router addresses">reserve network / router addresses</th></tr>'; $i = 1; foreach ($ipspace as $prefix => $ipspace) { $netcreatecheckbox = '<b style="background-color:#00ff00">' . '<input class="ipspace" style="background-color:#00ff00" type="checkbox" name="netcreate[' . $i . ']" value="' . $ipspace['addrtype'] . '"' . ($ipspace['checked'] ? ' checked=\\"checked\\"' : '') . '></b>'; $netprefixfield = '<input type="text" size=50 name="netprefix[' . $i . ']" value="' . $prefix . '">'; $netnamefield = '<input type="text" name="netname[' . $i . ']">'; $netreservecheckbox = '<input type="checkbox" name="netreserve[' . $i . ']" checked="checked">'; echo "<tr><td>{$netcreatecheckbox}</td><td style=\"color:#888888\">{$ipspace['addrtype']}</td><td>{$netprefixfield}</td><td>{$netnamefield}</td><td>{$netreservecheckbox}</td></tr>"; $i++; } unset($prefix); unset($addrtype); unset($i); echo '</table>'; } echo "<br><br>ifNumber: " . $ifsnmp->ifNumber . "<br>indexcount: " . $ifsnmp->indexcount . "<br><table><tbody valign=\"top\">"; $portcompat = getPortInterfaceCompat(); $ipnets = array(); $ifsnmp->printifInfoTableHeader("<th>add ip</th><th>add port</th><th>upd label</th><th title=\"update mac\">upd mac</th><td>upd port type</th><th>porttypeid</th><th>comment</th></tr>"); echo '<tr><td colspan="11"></td> <td><input type="checkbox" id="ipaddr" onclick="setchecked(this.id);" checked="checked">IPv4<br> <input type="checkbox" id="ipv6addr" onclick="setchecked(this.id);" checked="checked">IPv6</td> <td><input type="checkbox" id="ports" onclick="setchecked(this.id)"></td> <td><input type="checkbox" id="label" onclick="setchecked(this.id);" checked="checked"></td> <td><input type="checkbox" id="mac" onclick="setchecked(this.id);" checked="checked"></td> <td><input type="checkbox" id="porttype" onclick="setchecked(this.id);"></td></tr>'; foreach ($ifsnmp as $if) { $createport = TRUE; $disableport = FALSE; $ignoreport = FALSE; $port_info = NULL; $updatelabel = false; $updateporttype = false; $updatemaccheckbox = ''; $hrefs = array(); $comment = ""; if (trim($ifsnmp->ifName($if)) == '') { $comment .= "no ifName"; $createport = FALSE; } else { if (array_key_exists($ifsnmp->ifName($if), $object['ports'])) { $port_info =& $object['ports'][$ifsnmp->ifName($if)]; $comment .= "Name exists"; /* ifalias change */ if ($port_info['label'] != $ifsnmp->ifAlias($if)) { $updatelabel = true; } $createport = FALSE; $disableport = TRUE; } } if ($ifsnmp->ifPhysAddress($if) != '') { $ifPhysAddress = $ifsnmp->ifPhysAddress($if); $l2port = sg_checkL2Address($ifPhysAddress); if (!empty($l2port)) { $l2object_id = key($l2port); $porthref = makeHref(array('page' => 'object', 'tab' => 'ports', 'object_id' => $l2object_id, 'hl_port_id' => $l2port[$l2object_id])); $comment .= ", L2Address exists"; $hrefs['ifPhysAddress'] = $porthref; $createport = FALSE; // $disableport = TRUE; $updatemaccheckbox = ''; } $disablemac = true; if ($disableport) { if ($port_info !== NULL) { if (str_replace(':', '', $port_info['l2address']) != $ifPhysAddress) { $disablemac = false; } else { $disablemac = true; } } } else { /* port create always updates mac */ $updatemaccheckbox = '<b style="background-color:#00ff00">' . '<input style="background-color:' . '#00ff00" type="checkbox"' . ' checked="checked"' . ' disabled=\\"disabled\\"></b>'; } if (!$disablemac) { $updatemaccheckbox = '<b style="background-color:' . ($disablemac ? '#ff0000' : '#00ff00') . '">' . '<input class="mac" style="background-color:' . ($disablemac ? '#ff0000' : '#00ff00') . '" type="checkbox" name="updatemac[' . $if . ']" value="' . $object['ports'][$ifsnmp->ifName($if)]['id'] . '" checked="checked"' . ($disablemac ? ' disabled=\\"disabled\\"' : '') . '></b>'; } } $porttypeid = guessRToif_id($ifsnmp->ifType($if), $ifsnmp->ifDescr($if)); if (in_array($ifsnmp->ifType($if), $sg_ifType_ignore)) { $comment .= ", ignore if type"; $createport = FALSE; $ignoreport = TRUE; } else { if ($port_info) { $ptid = $port_info['iif_id'] . "-" . $port_info['oif_id']; if ($porttypeid != $ptid) { $comment .= ", Update Type {$ptid} -> {$porttypeid}"; $updateporttype = true; } } } /* ignore ports without an Connector */ if (!$sg_create_noconnector_ports && $ifsnmp->ifConnectorPresent($if) == 2) { $comment .= ", no Connector"; $createport = FALSE; } /* Allocate IPs ipv4 and ipv6 */ $ipaddresses = $ifsnmp->ipaddress($if); if (!empty($ipaddresses)) { $ipaddrcell = '<table>'; foreach ($ipaddresses as $ipaddr => $value) { $createipaddr = FALSE; $disableipaddr = FALSE; $ipaddrhref = ''; $linklocal = FALSE; $addrtype = $value['addrtype']; $maskbits = $value['maskbits']; $bcast = $value['bcast']; //echo "<br> - DEBUG: ip $ipaddr - $addrtype - $maskbits - $bcast<br>"; switch ($addrtype) { case 'ipv4z': case 'ipv4': if ($maskbits == 32) { $bcast = "host"; } $inputname = 'ip'; break; case 'ipv6z': $disableipaddr = TRUE; case 'ipv6': $inputname = 'ipv6'; if (ip_checkparse($ipaddr) === false) { /* format ipaddr for ip6_parse */ $ipaddr = preg_replace('/((..):(..))/', '\\2\\3', $ipaddr); $ipaddr = preg_replace('/%.*$/', '', $ipaddr); } if (ip_checkparse($ipaddr) === false) { continue 2; } // 2 because of switch /* ip_parse throws exception on parse errors */ $ip6_bin = ip_parse($ipaddr); $ipaddr = ip_format($ip6_bin); $node = constructIPRange($ip6_bin, $maskbits); $linklocal = $node['ip'] == 'fe80::'; $createipaddr = FALSE; break; } //switch $address = getIPAddress(ip_parse($ipaddr)); /* only if ip not already allocated */ if (empty($address['allocs'])) { if (!$ignoreport) { $createipaddr = TRUE; } } else { $disableipaddr = TRUE; $ipobject_id = $address['allocs'][0]['object_id']; $ipaddrhref = makeHref(array('page' => 'object', 'object_id' => $ipobject_id, 'hl_ipv4_addr' => $ipaddr)); } /* reserved addresses */ if ($address['reserved'] == 'yes') { $comment .= ', ' . $address['ip'] . ' reserved ' . $address['name']; $createipaddr = FALSE; // $disableipaddr = TRUE; } if ($ipaddr == '127.0.0.1' || $ipaddr == '0.0.0.0' || $ipaddr == '::1' || $ipaddr == '::' || $linklocal) { $createipaddr = FALSE; $disableipaddr = TRUE; } if ($ipaddr === $bcast) { $comment .= ", {$ipaddr} broadcast"; $createipaddr = FALSE; $disableipaddr = TRUE; } if (!$disableipaddr) { $ipaddrcheckbox = '<b style="background-color:' . ($disableipaddr ? '#ff0000' : '#00ff00') . '"><input class="' . $inputname . 'addr" style="background-color:' . ($disableipaddr ? '#ff0000' : '#00ff00') . '" type="checkbox" name="' . $inputname . 'addrcreate[' . $ipaddr . ']" value="' . $if . '"' . ($disableipaddr ? ' disabled="disabled"' : '') . ($createipaddr ? ' checked="checked"' : '') . '></b>'; } else { $ipaddrcheckbox = ''; } $ipaddrcell .= "<tr><td>{$ipaddrcheckbox}</td>"; if (!empty($ipaddrhref)) { $ipaddrcell .= "<td><a href={$ipaddrhref}>{$ipaddr}/{$maskbits}</a></td></tr>"; } else { $ipaddrcell .= "<td>{$ipaddr}/{$maskbits}</td></tr>"; } } // foreach unset($ipaddr); unset($value); $ipaddrcell .= '</table>'; // if(!empty($ipaddresses)) } else { $ipaddrcreatecheckbox = ''; $ipaddrcell = ''; } /* checkboxes for add port and add ip */ /* FireFox needs <b style=..>, IE and Opera work with <td style=..> */ if (!$disableport) { $portcreatecheckbox = '<b style="background-color:' . ($disableport ? '#ff0000' : '#00ff00') . '"><input class="ports" style="background-color:' . ($disableport ? '#ff0000' : '#00ff00') . '" type="checkbox" name="portcreate[' . $if . ']" value="' . $if . '"' . ($disableport ? ' disabled="disbaled"' : '') . ($createport ? ' checked="checked"' : '') . '></b>'; } else { $portcreatecheckbox = ''; } /* port type id */ /* add port type to newporttypeoptions if missing */ if (strpos(serialize($newporttypeoptions), $porttypeid) === FALSE) { $portids = explode('-', $porttypeid); $oif_name = $sg_portoifoptions[$portids[1]]; $newporttypeoptions['auto'] = array($porttypeid => "*{$oif_name}"); } $selectoptions = array('name' => "porttypeid[{$if}]"); if ($disableport && !$updateporttype) { $selectoptions['disabled'] = "disabled"; } $updateporttypecheckbox = ""; if ($updateporttype) { $updateporttypecheckbox = '<b style="background-color:#00ff00;">' . '<input class="porttype" style="background-color:#00ff00;" type="checkbox" name="updateporttype[' . $if . ']" value="' . $port_info['id'] . '"></b>'; } $porttypeidselect = getNiftySelect($newporttypeoptions, $selectoptions, $porttypeid); $updatelabelcheckbox = ""; if ($updatelabel) { $updatelabelcheckbox = '<b style="background-color:#00ff00;">' . '<input class="label" style="background-color:#00ff00;" type="checkbox" name="updatelabel[' . $if . ']" value="' . $port_info['id'] . ($updatelabel ? '" checked="checked"' : '') . '></b>'; } $comment = trim($comment, ', '); $ifsnmp->printifInfoTableRow($if, "<td>{$ipaddrcell}</td><td>{$portcreatecheckbox}</td><td>{$updatelabelcheckbox}</td><td>{$updatemaccheckbox}</td><td>{$updateporttypecheckbox}</td><td>{$porttypeidselect}</td><td nowrap=\"nowrap\">{$comment}</td>", $hrefs); } unset($if); /* preserve snmpconfig */ foreach ($_POST as $key => $value) { echo '<input type=hidden name=' . $key . ' value=' . $value . ' />'; } unset($key); unset($value); echo '<tr><td colspan=15 align="right"><p><input id="createbutton" type=submit value="Create Ports and IPs" onclick="return confirm(\'Create selected items?\')"></p></td></tr></tbody></table></form>'; }
function checkPIC($port_type_id) { // cache PortInterfaceCompat static $compat_array = NULL; if (!isset($compat_array)) { $compat_array = array(); foreach (getPortInterfaceCompat() as $record) { $key = $record['iif_id'] . '-' . $record['oif_id']; $compat_array[$key] = 1; } } if (preg_match('/^(?:(\\d+)-)?(\\d+)$/', $port_type_id, $m)) { $iif_id = $m[1]; $oif_id = $m[2]; if (empty($iif_id)) { $iif_id = 1; $port_type_id = $iif_id . '-' . $port_type_id; } if (!array_key_exists($port_type_id, $compat_array)) { commitSupplementPIC($iif_id, $oif_id); $compat_array[$port_type_id] = 1; } } }
function renderIIFOIFCompatEditor() { function printNewitemTR() { printOpFormIntro('add'); echo '<tr><th class=tdleft>'; printImageHREF('add', 'add pair', TRUE); echo '</th><th class=tdleft>'; printSelect(getPortIIFOptions(), array('name' => 'iif_id')); echo '</th><th class=tdleft>'; printSelect(readChapter(CHAP_PORTTYPE), array('name' => 'oif_id')); echo '</th></tr></form>'; } startPortlet('WDM standard by interface'); $iif = getPortIIFOptions(); global $nextorder, $wdm_packs; $order = 'odd'; echo '<table border=0 align=center cellspacing=0 cellpadding=5>'; foreach ($wdm_packs as $codename => $packinfo) { echo "<tr><th> </th><th colspan=2>{$packinfo['title']}</th></tr>"; foreach ($packinfo['iif_ids'] as $iif_id) { echo "<tr class=row_{$order}><th class=tdleft>" . $iif[$iif_id] . '</th><td><a href="'; echo makeHrefProcess(array('op' => 'addPack', 'standard' => $codename, 'iif_id' => $iif_id)); echo '">' . getImageHREF('add') . '</a></td><td><a href="'; echo makeHrefProcess(array('op' => 'delPack', 'standard' => $codename, 'iif_id' => $iif_id)); echo '">' . getImageHREF('delete') . '</a></td></tr>'; $order = $nextorder[$order]; } } echo '</table>'; finishPortlet(); startPortlet('interface by interface'); global $nextorder; $last_iif_id = 0; $order = 'even'; echo '<br><table class=cooltable align=center border=0 cellpadding=5 cellspacing=0>'; echo '<tr><th> </th><th class=tdleft>inner interface</th><th class=tdleft>outer interface</th></tr>'; if (getConfigVar('ADDNEW_AT_TOP') == 'yes') { printNewitemTR(); } foreach (getPortInterfaceCompat() as $record) { if ($last_iif_id != $record['iif_id']) { $order = $nextorder[$order]; $last_iif_id = $record['iif_id']; } echo "<tr class=row_{$order}><td>"; echo '<a href="' . makeHrefProcess(array('op' => 'del', 'iif_id' => $record['iif_id'], 'oif_id' => $record['oif_id'])) . '">'; printImageHREF('delete', 'remove pair'); echo "</a></td><td class=tdleft>{$record['iif_name']}</td><td class=tdleft>{$record['oif_name']}</td></tr>"; } if (getConfigVar('ADDNEW_AT_TOP') != 'yes') { printNewitemTR(); } echo '</table>'; finishPortlet(); }
function renderIIFOIFCompatEditor() { startPortlet('WDM standard by interface'); $iif = getPortIIFOptions(); global $nextorder, $wdm_packs; $order = 'odd'; echo '<table border=0 align=center cellspacing=0 cellpadding=5>'; foreach ($wdm_packs as $codename => $packinfo) { echo "<tr><th> </th><th colspan=2>{$packinfo['title']}</th></tr>"; foreach ($packinfo['iif_ids'] as $iif_id) { echo "<tr class=row_{$order}><th class=tdleft>" . $iif[$iif_id] . '</th><td>'; echo getOpLink(array('op' => 'addPack', 'standard' => $codename, 'iif_id' => $iif_id), '', 'add'); echo '</td><td>'; echo getOpLink(array('op' => 'delPack', 'standard' => $codename, 'iif_id' => $iif_id), '', 'delete'); echo '</td></tr>'; $order = $nextorder[$order]; } } echo '</table>'; finishPortlet(); startPortlet('interface by interface'); renderTwoColumnCompatTableEditor(getPortInterfaceCompat(), array('header' => 'inner interface', 'key' => 'iif_id', 'value' => 'iif_name', 'width' => 16, 'options' => getPortIIFOptions()), array('header' => 'outer interface', 'key' => 'oif_id', 'value' => 'oif_name', 'width' => 48, 'options' => getPortOIFOptions())); finishPortlet(); }
function getNewPortTypeOptions() { $ret = array(); $prefs = getPortListPrefs(); foreach (getPortInterfaceCompat() as $row) { if ($row['iif_id'] == $prefs['iif_pick']) { $optgroup = $row['iif_name']; } elseif (array_key_exists($row['iif_id'], $prefs['oif_picks']) and $prefs['oif_picks'][$row['iif_id']] == $row['oif_id']) { $optgroup = 'other'; } else { continue; } if (!array_key_exists($optgroup, $ret)) { $ret[$optgroup] = array(); } $ret[$optgroup][$row['iif_id'] . '-' . $row['oif_id']] = $row['oif_name']; } return $ret; }