function renderPortsReport()
{
    $tmp = array();
    foreach (getPortIIFOptions() as $iif_id => $iif_name) {
        if (count(getPortIIFStats($iif_id))) {
            $tmp[] = array('title' => $iif_name, 'type' => 'meters', 'func' => 'getPortIIFStats', 'args' => $iif_id);
        }
    }
    renderReports($tmp);
}
        $regex = $attr['regex'];
        $raw_value = $snmp->get($oid);
        if (isset($attr['replacement'])) {
            $replace = $attr['replacement'];
        } else {
            $replace = '\\1';
        }
        $value = preg_replace($regex, $replace, $raw_value);
        /* return array of attr_id => attr_value) */
        $attr['value'] = $value;
    }
    // else Warning ??
}
/* snmpgeneric_pf_regex */
/* -------------------------------------------------- */
$sg_portiifoptions = getPortIIFOptions();
$sg_portiifoptions[-1] = 'sfp';
/* generic sfp */
$sg_portoifoptions = getPortOIFOptions();
/* -------------------------------------------------- */
/* -------------------------------------------------- */
function snmpgeneric_tabhandler($object_id)
{
    //	sg_var_dump_html($_POST);
    if (isset($_POST['asnewobject']) && $_POST['asnewobject'] == "1") {
        $newobject_name = $_POST['object_name'];
        $newobject_label = $_POST['object_label'];
        $newobject_type_id = $_POST['object_type_id'];
        $newobject_asset_no = $_POST['object_asset_no'];
        if (sg_checkObjectNameUniqueness($newobject_name, $newobject_type_id)) {
            $object_id = commitAddObject($newobject_name, $newobject_label, $newobject_type_id, $newobject_asset_no);
Esempio n. 3
0
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>&nbsp;</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();
}
Esempio n. 4
0
 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>';
 }
Esempio n. 5
0
function genericAssertion($argname, $argtype)
{
    global $sic;
    switch ($argtype) {
        case 'string':
            assertStringArg($argname);
            break;
        case 'string0':
            assertStringArg($argname, TRUE);
            break;
        case 'uint':
            assertUIntArg($argname);
            break;
        case 'uint-uint':
            assertStringArg($argname);
            if (1 != preg_match('/^[1-9][0-9]*-[1-9][0-9]*$/', $_REQUEST[$argname])) {
                throw new InvalidRequestArgException($argname, $_REQUEST[$argname], 'illegal format');
            }
            break;
        case 'uint0':
            assertUIntArg($argname, TRUE);
            break;
        case 'inet':
            assertIPArg($argname);
            break;
        case 'inet4':
            assertIPv4Arg($argname);
            break;
        case 'inet6':
            assertIPv6Arg($argname);
            break;
        case 'l2address':
            assertStringArg($argname);
        case 'l2address0':
            assertStringArg($argname, TRUE);
            try {
                l2addressForDatabase($sic[$argname]);
            } catch (InvalidArgException $e) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'malformed MAC/WWN address');
            }
            break;
        case 'tag':
            assertStringArg($argname);
            if (!validTagName($sic[$argname])) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Invalid tag name');
            }
            break;
        case 'pcre':
            assertPCREArg($argname);
            break;
        case 'json':
            assertStringArg($argname);
            if (NULL === json_decode($sic[$argname], TRUE)) {
                throw new InvalidRequestArgException($argname, '(omitted)', 'Invalid JSON code received from client');
            }
            break;
        case 'array':
            if (!array_key_exists($argname, $_REQUEST)) {
                throw new InvalidRequestArgException($argname, '(missing argument)');
            }
            if (!is_array($_REQUEST[$argname])) {
                throw new InvalidRequestArgException($argname, '(omitted)', 'argument is not an array');
            }
            break;
        case 'enum/attr_type':
            assertStringArg($argname);
            if (!in_array($sic[$argname], array('uint', 'float', 'string', 'dict', 'date'))) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'enum/vlan_type':
            assertStringArg($argname);
            // "Alien" type is not valid until the logic is fixed to implement it in full.
            if (!in_array($sic[$argname], array('ondemand', 'compulsory'))) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'enum/wdmstd':
            assertStringArg($argname);
            global $wdm_packs;
            if (!array_key_exists($sic[$argname], $wdm_packs)) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'enum/ipproto':
            assertStringArg($argname);
            global $vs_proto;
            if (!array_key_exists($sic[$argname], $vs_proto)) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'enum/alloc_type':
            assertStringArg($argname);
            if (!in_array($sic[$argname], array('regular', 'shared', 'virtual', 'router'))) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'enum/dqcode':
            assertStringArg($argname);
            global $dqtitle;
            if (!array_key_exists($sic[$argname], $dqtitle)) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'iif':
            if (!array_key_exists($sic[$argname], getPortIIFOptions())) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'vlan':
        case 'vlan1':
            genericAssertion($argname, 'uint');
            if ($argtype == 'vlan' and $sic[$argname] == VLAN_DFL_ID) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'default VLAN cannot be changed');
            }
            if ($sic[$argname] > VLAN_MAX_ID or $sic[$argname] < VLAN_MIN_ID) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'out of valid range');
            }
            break;
        case 'rackcode/expr':
            genericAssertion($argname, 'string0');
            if ($sic[$argname] == '') {
                return;
            }
            $parse = spotPayload($sic[$argname], 'SYNT_EXPR');
            if ($parse['result'] != 'ACK') {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'RackCode parsing error');
            }
            break;
        default:
            throw new InvalidArgException('argtype', $argtype);
            // comes not from user's input
    }
}