Beispiel #1
0
function getAccessPortControlCode($req_port_name, $vdom, $port_name, $port, &$nports)
{
    static $permissions_cache = array();
    // don't render a form for access ports, when a trunk port is zoomed
    if ($req_port_name != '') {
        return ' ';
    }
    if (array_key_exists($port['native'], $vdom['vlanlist']) and $vdom['vlanlist'][$port['native']]['vlan_type'] == 'alien') {
        return formatVLANAsLabel($vdom['vlanlist'][$port['native']]);
    }
    static $vlanpermissions = array();
    if (!array_key_exists($port['native'], $vlanpermissions)) {
        $vlanpermissions[$port['native']] = array();
        foreach (array_keys($vdom['vlanlist']) as $to) {
            $from_key = 'from_' . $port['native'];
            $to_key = 'to_' . $to;
            if (isset($permissions_cache[$from_key])) {
                $allowed_from = $permissions_cache[$from_key];
            } else {
                $allowed_from = $permissions_cache[$from_key] = permitted(NULL, NULL, 'save8021QConfig', array(array('tag' => '$fromvlan_' . $port['native']), array('tag' => '$vlan_' . $port['native'])));
            }
            if ($allowed_from) {
                if (isset($permissions_cache[$to_key])) {
                    $allowed_to = $permissions_cache[$to_key];
                } else {
                    $allowed_to = $permissions_cache[$to_key] = permitted(NULL, NULL, 'save8021QConfig', array(array('tag' => '$tovlan_' . $to), array('tag' => '$vlan_' . $to)));
                }
                if ($allowed_to) {
                    $vlanpermissions[$port['native']][] = $to;
                }
            }
        }
    }
    $ret = "<input type=hidden name=pn_{$nports} value={$port_name}>";
    $ret .= "<input type=hidden name=pm_{$nports} value=access>";
    $options = array();
    // Offer only options that are listed in domain and fit into VST.
    // Never offer immune VLANs regardless of VST filter for this port.
    // Also exclude current VLAN from the options, unless current port
    // mode is "trunk" (in this case it should be possible to set VST-
    // approved mode without changing native VLAN ID).
    foreach ($vdom['vlanlist'] as $vlan_id => $vlan_info) {
        if (($vlan_id != $port['native'] or $port['mode'] == 'trunk') and $vlan_info['vlan_type'] != 'alien' and in_array($vlan_id, $vlanpermissions[$port['native']]) and matchVLANFilter($vlan_id, $port['wrt_vlans'])) {
            $options[$vlan_id] = formatVLANAsOption($vlan_info);
        }
    }
    ksort($options);
    $options['same'] = '-- no change --';
    $ret .= getSelect($options, array('name' => "pnv_{$nports}"), 'same');
    $nports++;
    return $ret;
}
Beispiel #2
0
function produceDownlinkPort($domain_vlanlist, $portname, $order, $uplink_order)
{
    $new_order = array($portname => $order[$portname]);
    $new_order[$portname]['mode'] = 'trunk';
    $new_order[$portname]['allowed'] = array();
    $new_order[$portname]['native'] = 0;
    foreach ($uplink_order['allowed'] as $vlan_id) {
        if (matchVLANFilter($vlan_id, $new_order[$portname]['wrt_vlans'])) {
            $new_order[$portname]['allowed'][] = $vlan_id;
        }
    }
    return filter8021QChangeRequests($domain_vlanlist, $order, $new_order);
}