Esempio n. 1
0
function addIPv6Prefix()
{
    assertStringArg('range');
    assertStringArg('name', TRUE);
    $taglist = genericAssertion('taglist', 'array0');
    global $sic;
    $vlan_ck = empty($sic['vlan_ck']) ? NULL : genericAssertion('vlan_ck', 'uint-vlan1');
    $net_id = createIPv6Prefix($_REQUEST['range'], $sic['name'], isCheckSet('is_connected'), $taglist, $vlan_ck);
    showSuccess('IP network ' . mkA($_REQUEST['range'], 'ipv6net', $net_id) . ' has been created');
}
function snmpgeneric_opcreate()
{
    $object_id = $_REQUEST['object_id'];
    $attr = getAttrValues($object_id);
    //	sg_var_dump_html($_REQUEST);
    //	sg_var_dump_html($attr);
    /* commitUpdateAttrValue ($object_id, $attr_id, $new_value); */
    if (isset($_POST['updateattr'])) {
        foreach ($_POST['updateattr'] as $attr_id => $value) {
            //	if(empty($attr[$attr_id]['value']))
            if (!empty($value)) {
                commitUpdateAttrValue($object_id, $attr_id, $value);
                showSuccess("Attribute " . $attr[$attr_id]['name'] . " set to {$value}");
            }
        }
        unset($attr_id);
        unset($value);
    }
    /* updateattr */
    /* create ports */
    if (isset($_POST['portcreate'])) {
        foreach ($_POST['portcreate'] as $if => $value) {
            $ifName = isset($_POST['ifName'][$if]) ? trim($_POST['ifName'][$if]) : '';
            $ifPhysAddress = isset($_POST['ifPhysAddress'][$if]) ? trim($_POST['ifPhysAddress'][$if]) : '';
            $ifAlias = isset($_POST['ifAlias'][$if]) ? trim($_POST['ifAlias'][$if]) : '';
            $ifDescr = isset($_POST['ifDescr'][$if]) ? trim($_POST['ifDescr'][$if]) : '';
            //$visible_label = (empty($ifAlias) ? '' : $ifAlias.'; ').$ifDescr;
            $visible_label = $ifAlias;
            if (empty($ifName)) {
                showError('Port without ifName ' . $_POST['porttypeid'][$if] . ', ' . $visible_label . ', ' . $ifPhysAddress);
            } else {
                commitAddPort($object_id, $ifName, $_POST['porttypeid'][$if], $visible_label, $ifPhysAddress);
                showSuccess('Port created ' . $ifName . ', ' . $_POST['porttypeid'][$if] . ', ' . $visible_label . ', ' . $ifPhysAddress);
            }
        }
        unset($if);
        unset($value);
    }
    /* portcreate */
    /* net create */
    if (isset($_POST['netcreate'])) {
        foreach ($_POST['netcreate'] as $id => $addrtype) {
            $range = $_POST['netprefix'][$id];
            $name = $_POST['netname'][$id];
            $is_reserved = isset($_POST['netreserve'][$id]);
            if ($addrtype == 'ipv4' || $addrtype == 'ipv4z') {
                createIPv4Prefix($range, $name, $is_reserved);
            } else {
                createIPv6Prefix($range, $name, $is_reserved);
            }
            showSuccess("{$range} {$name} created");
        }
        unset($id);
        unset($addrtype);
    }
    /* netcreate */
    /* allocate ipv6 adresses */
    if (isset($_POST['ipv6addrcreate'])) {
        foreach ($_POST['ipv6addrcreate'] as $ipaddr => $if) {
            bindIPv6ToObject(ip6_parse($ipaddr), $object_id, $_POST['ifName'][$if], 1);
            /* connected */
            showSuccess("{$ipaddr} allocated");
        }
        unset($ipaddr);
        unset($if);
    }
    /* allocate ip adresses */
    if (isset($_POST['ipaddrcreate'])) {
        foreach ($_POST['ipaddrcreate'] as $ipaddr => $if) {
            bindIPToObject(ip_parse($ipaddr), $object_id, $_POST['ifName'][$if], 1);
            /* connected */
            showSuccess("{$ipaddr} allocated");
        }
        unset($ipaddr);
        unset($if);
    }
    /* ipaddrecreate */
    /* update label */
    if (isset($_POST['updatelabel'])) {
        foreach ($_POST['updatelabel'] as $if => $port_id) {
            $ifAlias = isset($_POST['ifAlias'][$if]) ? trim($_POST['ifAlias'][$if]) : '';
            sg_commitUpdatePortLabel($object_id, $port_id, $ifAlias);
            $ifName = isset($_POST['ifName'][$if]) ? trim($_POST['ifName'][$if]) : '';
            showSuccess("label updated on {$ifName} to {$ifAlias}");
        }
        unset($if);
        unset($port_id);
    }
    /* updatemac */
    /* update mac addresses only */
    if (isset($_POST['updatemac'])) {
        foreach ($_POST['updatemac'] as $if => $port_id) {
            $ifPhysAddress = isset($_POST['ifPhysAddress'][$if]) ? trim($_POST['ifPhysAddress'][$if]) : '';
            sg_commitUpdatePortl2address($object_id, $port_id, $ifPhysAddress);
            $ifName = isset($_POST['ifName'][$if]) ? trim($_POST['ifName'][$if]) : '';
            showSuccess("l2address updated on {$ifName} to {$ifPhysAddress}");
        }
        unset($if);
        unset($port_id);
    }
    /* updatemac */
    /* update port type */
    if (isset($_POST['updateporttype'])) {
        foreach ($_POST['updateporttype'] as $if => $port_id) {
            $porttypeid = isset($_POST['porttypeid'][$if]) ? trim($_POST['porttypeid'][$if]) : '';
            sg_commitUpdatePortType($object_id, $port_id, $porttypeid);
            $ifName = isset($_POST['ifName'][$if]) ? trim($_POST['ifName'][$if]) : '';
            showSuccess("port type updated on {$ifName}");
        }
        unset($if);
        unset($port_id);
    }
    /* updateporttype */
}
function addIPv6Prefix()
{
    assertStringArg('range');
    assertStringArg('name', TRUE);
    $taglist = genericAssertion('taglist', 'array0');
    global $sic;
    $vlan_ck = empty($sic['vlan_ck']) ? NULL : genericAssertion('vlan_ck', 'uint-vlan1');
    $net_id = createIPv6Prefix($_REQUEST['range'], $sic['name'], isCheckSet('is_connected'), $taglist);
    $net_cell = spotEntity('ipv6net', $net_id);
    if (isset($vlan_ck)) {
        if (considerConfiguredConstraint($net_cell, 'VLANIPV4NET_LISTSRC')) {
            commitSupplementVLANIPv6($vlan_ck, $net_id);
        } else {
            showError("VLAN binding to network " . mkCellA($net_cell) . " is restricted in config");
        }
    }
    showSuccess('IP network ' . mkA($_REQUEST['range'], 'ipv6net', $net_id) . ' has been created');
}
Esempio n. 4
0
function addIPv6Prefix()
{
    assertStringArg('range');
    assertStringArg('name', TRUE);
    $taglist = isset($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array();
    global $sic;
    $vlan_ck = empty($sic['vlan_ck']) ? NULL : $sic['vlan_ck'];
    $net_id = createIPv6Prefix($_REQUEST['range'], $sic['name'], isCheckSet('is_connected'), $taglist, $vlan_ck);
    showSuccess('IP network <a href="' . makeHref(array('page' => 'ipv6net', 'tab' => 'default', 'id' => $net_id)) . '">' . $_REQUEST['range'] . '</a> has been created');
}