Feature #4133 » pf_pcp_git.diff
| /pfsense/gitrepo/pfSenseGITREPO/etc/inc/config.inc 2014-12-20 13:20:39.000000000 +0100 | ||
|---|---|---|
|
$timezone = "Etc/UTC";
|
||
|
date_default_timezone_set("$timezone");
|
||
|
/* compatibility with older configs using vlan "tags" */
|
||
|
if (($config['version'] < 11) && (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
|
||
|
foreach ($config['vlans']['vlan'] as &$vlan) {
|
||
|
if (empty($vlan['vid']) && !empty($vlan['tag'])) {
|
||
|
$vlan['vid'] = $vlan['tag'];
|
||
|
unset($vlan['tag']);
|
||
|
}
|
||
|
}
|
||
|
if($config_parsed == true) {
|
||
|
/* process packager manager custom rules */
|
||
|
if(is_dir("/usr/local/pkg/parse_config")) {
|
||
| /pfsense/gitrepo/pfSenseGITREPO/etc/inc/interfaces.inc 2014-12-13 15:11:56.000000000 +0100 | ||
|---|---|---|
|
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
|
||
|
foreach ($config['vlans']['vlan'] as $vlan) {
|
||
|
if (empty($vlan['vlanif']))
|
||
|
$vlan['vlanif'] = "{$vlan['if']}_vlan{$vlan['tag']}";
|
||
|
$vlan['vlanif'] = "{$vlan['if']}_vlan{$vlan['vid']}";
|
||
|
if (!empty($realif) && $realif != $vlan['vlanif'])
|
||
|
continue;
|
||
| ... | ... | |
|
return;
|
||
|
}
|
||
|
$if = $vlan['if'];
|
||
|
$vlanif = empty($vlan['vlanif']) ? "{$if}_vlan{$vlan['tag']}" : $vlan['vlanif'];
|
||
|
$tag = $vlan['tag'];
|
||
|
if (empty($if)) {
|
||
|
log_error(gettext("interface_vlan_configure called with if undefined."));
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$vlanif = empty($vlan['vlanif']) ? "{$if}_vlan{$vlan['vid']}" : $vlan['vlanif'];
|
||
|
$vid = $vlan['vid'];
|
||
|
$pcp = empty($vlan['pcp']) ? 0 : $vlan['pcp']; /* Apply "Best Effort" if not set */
|
||
|
/* make sure the parent interface is up */
|
||
|
interfaces_bring_up($if);
|
||
| ... | ... | |
|
pfSense_ngctl_name("{$tmpvlanif}:", $vlanif);
|
||
|
}
|
||
|
pfSense_vlan_create($vlanif, $if, $tag);
|
||
|
pfSense_vlan_create($vlanif, $if, $vid, $pcp);
|
||
|
interfaces_bring_up($vlanif);
|
||
| ... | ... | |
|
}
|
||
|
$qinqif = $vlan['if'];
|
||
|
$tag = $vlan['tag'];
|
||
|
$tag = $vlan['vid'];
|
||
|
if(empty($qinqif)) {
|
||
|
log_error(sprintf(gettext("interface_qinq_configure called with if undefined.%s"), "\n"));
|
||
|
return;
|
||
| ... | ... | |
|
if ($action == "update") {
|
||
|
interfaces_bring_up($int);
|
||
|
} else
|
||
|
$ifaces[$vlan['tag']] = $vlan;
|
||
|
$ifaces[$vlan['vid']] = $vlan;
|
||
|
}
|
||
|
}
|
||
|
if (!empty($ifaces))
|
||
| /pfsense/gitrepo/pfSenseGITREPO/usr/local/www/interfaces_assign.php 2014-12-13 15:06:55.000000000 +0100 | ||
|---|---|---|
|
function interface_assign_description($portinfo, $portname) {
|
||
|
global $ovpn_descrs;
|
||
|
if ($portinfo['isvlan']) {
|
||
|
$descr = sprintf(gettext('VLAN %1$s on %2$s'),$portinfo['tag'],$portinfo['if']);
|
||
|
$descr = sprintf(gettext('VLAN %1$s on %2$s'),$portinfo['vid'],$portinfo['if']);
|
||
|
if ($portinfo['descr'])
|
||
|
$descr .= " (" . $portinfo['descr'] . ")";
|
||
|
} elseif ($portinfo['iswlclone']) {
|
||
| ... | ... | |
|
if (is_array($config['vlans']['vlan'])) {
|
||
|
foreach ($config['vlans']['vlan'] as $vlan) {
|
||
|
if (does_interface_exist($vlan['if']) == false)
|
||
|
$input_errors[] = "Vlan parent interface {$vlan['if']} does not exist anymore so vlan id {$vlan['tag']} cannot be created please fix the issue before continuing.";
|
||
|
$input_errors[] = "Vlan parent interface {$vlan['if']} does not exist anymore so vlan id {$vlan['vid']} cannot be created please fix the issue before continuing.";
|
||
|
}
|
||
|
}
|
||
| /pfsense/gitrepo/pfSenseGITREPO/usr/local/www/interfaces_vlan.php 2014-12-13 15:06:55.000000000 +0100 | ||
|---|---|---|
|
<div id="mainarea">
|
||
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
|
||
|
<tr>
|
||
|
<td width="20%" class="listhdrr"><?=gettext("Interface");?></td>
|
||
|
<td width="20%" class="listhdrr"><?=gettext("VLAN tag");?></td>
|
||
|
<td width="16%" class="listhdrr"><?=gettext("Interface");?></td>
|
||
|
<td width="12%" class="listhdrr"><?=gettext("VLAN");?></td>
|
||
|
<td width="12%" class="listhdrr"><?=gettext("Priority");?></td>
|
||
|
<td width="50%" class="listhdr"><?=gettext("Description");?></td>
|
||
|
<td width="10%" class="list"></td>
|
||
|
</tr>
|
||
| ... | ... | |
|
<?=htmlspecialchars($vlan['if']);?>
|
||
|
</td>
|
||
|
<td class="listr">
|
||
|
<?=htmlspecialchars($vlan['tag']);?>
|
||
|
<?=htmlspecialchars($vlan['vid']);?>
|
||
|
</td>
|
||
|
<td class="listr">
|
||
|
<?=htmlspecialchars($vlan['pcp']);?>
|
||
|
</td>
|
||
|
<td class="listbg">
|
||
|
<?=htmlspecialchars($vlan['descr']);?>
|
||
|
</td>
|
||
| /pfsense/gitrepo/pfSenseGITREPO/usr/local/www/interfaces_vlan_edit.php 2014-12-13 15:06:55.000000000 +0100 | ||
|---|---|---|
|
if (isset($id) && $a_vlans[$id]) {
|
||
|
$pconfig['if'] = $a_vlans[$id]['if'];
|
||
|
$pconfig['vlanif'] = $a_vlans[$id]['vlanif'];
|
||
|
$pconfig['tag'] = $a_vlans[$id]['tag'];
|
||
|
$pconfig['vid'] = $a_vlans[$id]['vid'];
|
||
|
$pconfig['pcp'] = $a_vlans[$id]['pcp'];
|
||
|
$pconfig['descr'] = $a_vlans[$id]['descr'];
|
||
|
}
|
||
| ... | ... | |
|
$pconfig = $_POST;
|
||
|
/* input validation */
|
||
|
$reqdfields = explode(" ", "if tag");
|
||
|
$reqdfieldsn = array(gettext("Parent interface"),gettext("VLAN tag"));
|
||
|
$reqdfields = explode(" ", "if vid");
|
||
|
$reqdfieldsn = array(gettext("Parent interface"),gettext("VLAN"));
|
||
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
||
|
if ($_POST['tag'] && (!is_numericint($_POST['tag']) || ($_POST['tag'] < '1') || ($_POST['tag'] > '4094'))) {
|
||
|
$input_errors[] = gettext("The VLAN tag must be an integer between 1 and 4094.");
|
||
|
if ($_POST['vid'] && (!is_numericint($_POST['vid']) || ($_POST['vid'] < '1') || ($_POST['vid'] > '4094'))) {
|
||
|
$input_errors[] = gettext("The VLAN ID must be an integer between 1 and 4094.");
|
||
|
}
|
||
|
if ($_POST['pcp'] && (!is_numericint($_POST['pcp']) || ($_POST['pcp'] < '0') || ($_POST['pcp'] > '7'))) {
|
||
|
$input_errors[] = gettext("The VLAN Priority must be an integer between 0 and 7.");
|
||
|
}
|
||
|
if (!does_interface_exist($_POST['if']))
|
||
|
$input_errors[] = gettext("Interface supplied as parent is invalid");
|
||
|
if (isset($id)) {
|
||
|
if ($_POST['tag'] && $_POST['tag'] != $a_vlans[$id]['tag']) {
|
||
|
if (!empty($a_vlans[$id]['vlanif']) && convert_real_interface_to_friendly_interface_name($a_vlans[$id]['vlanif']) != NULL)
|
||
|
$input_errors[] = gettext("Interface is assigned and you cannot change the VLAN tag while assigned.");
|
||
|
}
|
||
|
if ($_POST['vid'] && $_POST['vid'] != $a_vlans[$id]['vid']) {
|
||
|
if (!empty($a_vlans[$id]['vlanif']) && convert_real_interface_to_friendly_interface_name($a_vlans[$id]['vlanif']) != NULL)
|
||
|
$input_errors[] = gettext("Interface is assigned and you cannot change the VLAN id while assigned.");
|
||
|
}
|
||
|
}
|
||
|
foreach ($a_vlans as $vlan) {
|
||
|
if (isset($id) && ($a_vlans[$id]) && ($a_vlans[$id] === $vlan))
|
||
|
continue;
|
||
|
if (($vlan['if'] == $_POST['if']) && ($vlan['tag'] == $_POST['tag'])) {
|
||
|
$input_errors[] = sprintf(gettext("A VLAN with the tag %s is already defined on this interface."),$vlan['tag']);
|
||
|
if (($vlan['if'] == $_POST['if']) && ($vlan['vid'] == $_POST['vid'])) {
|
||
|
$input_errors[] = sprintf(gettext("A VLAN with id %s is already defined on this interface."),$vlan['vid']);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (is_array($config['qinqs']['qinqentry'])) {
|
||
|
foreach ($config['qinqs']['qinqentry'] as $qinq)
|
||
|
if ($qinq['tag'] == $_POST['tag'] && $qinq['if'] == $_POST['if'])
|
||
|
$input_errors[] = gettext("A QinQ VLAN exists with this tag please remove it to use this tag with.");
|
||
|
if ($qinq['tag'] == $_POST['vid'] && $qinq['if'] == $_POST['if'])
|
||
|
$input_errors[] = gettext("A QinQ VLAN exists with this id please remove it to use this id with.");
|
||
|
}
|
||
|
if (!$input_errors) {
|
||
|
if (isset($id) && $a_vlans[$id]) {
|
||
|
if (($a_vlans[$id]['if'] != $_POST['if']) || ($a_vlans[$id]['tag'] != $_POST['tag'])) {
|
||
|
if (($a_vlans[$id]['if'] != $_POST['if']) || ($a_vlans[$id]['vid'] != $_POST['vid'])) {
|
||
|
if (!empty($a_vlans[$id]['vlanif'])) {
|
||
|
$confif = convert_real_interface_to_friendly_interface_name($vlan['vlanif']);
|
||
|
// Destroy previous vlan
|
||
|
pfSense_interface_destroy($a_vlans[$id]['vlanif']);
|
||
|
} else {
|
||
|
pfSense_interface_destroy("{$a_vlans[$id]['if']}_vlan{$a_vlans[$id]['tag']}");
|
||
|
$confif = convert_real_interface_to_friendly_interface_name("{$a_vlans[$id]['if']}_vlan{$a_vlans[$id]['tag']}");
|
||
|
pfSense_interface_destroy("{$a_vlans[$id]['if']}_vlan{$a_vlans[$id]['vid']}");
|
||
|
$confif = convert_real_interface_to_friendly_interface_name("{$a_vlans[$id]['if']}_vlan{$a_vlans[$id]['vid']}");
|
||
|
}
|
||
|
if ($confif <> "")
|
||
|
$config['interfaces'][$confif]['if'] = "{$_POST['if']}_vlan{$_POST['tag']}";
|
||
|
$config['interfaces'][$confif]['if'] = "{$_POST['if']}_vlan{$_POST['vid']}";
|
||
|
}
|
||
|
}
|
||
|
$vlan = array();
|
||
|
$vlan['if'] = $_POST['if'];
|
||
|
$vlan['tag'] = $_POST['tag'];
|
||
|
$vlan['descr'] = $_POST['descr'];
|
||
|
$vlan['vlanif'] = "{$_POST['if']}_vlan{$_POST['tag']}";
|
||
|
$vlan['vid'] = $_POST['vid'];
|
||
|
if ($_POST['pcp'] != '')
|
||
|
$vlan['pcp'] = $_POST['pcp']; /* Leave PCP unset if not required */
|
||
|
$vlan['descr'] = $_POST['descr'];
|
||
|
$vlan['vlanif'] = "{$_POST['if']}_vlan{$_POST['vid']}";
|
||
|
$vlan['vlanif'] = interface_vlan_configure($vlan);
|
||
|
if ($vlan['vlanif'] == "" || !stristr($vlan['vlanif'], "vlan"))
|
||
| ... | ... | |
|
<span class="vexpl"><?=gettext("Only VLAN capable interfaces will be shown.");?></span></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td valign="top" class="vncellreq"><?=gettext("VLAN tag ");?></td>
|
||
|
<td valign="top" class="vncellreq"><?=gettext("VLAN id ");?></td>
|
||
|
<td class="vtable">
|
||
|
<input name="tag" type="text" class="formfld unknown" id="tag" size="6" value="<?=htmlspecialchars($pconfig['tag']);?>" />
|
||
|
<input name="vid" type="text" class="formfld unknown" id="vid" size="6" value="<?=htmlspecialchars($pconfig['vid']);?>" />
|
||
|
<br />
|
||
|
<span class="vexpl"><?=gettext("802.1Q VLAN tag (between 1 and 4094) ");?></span></td>
|
||
|
<span class="vexpl"><?=gettext("802.1Q VLAN vid (between 1 and 4094) ");?></span></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td valign="top" class="vncell"><?=gettext("VLAN Priority ");?></td>
|
||
|
<td class="vtable">
|
||
|
<input name="pcp" type="text" class="formfld unknown" id="pcp" size="4" value="<?=htmlspecialchars($pconfig['pcp']);?>" />
|
||
|
<br/>
|
||
|
<span class="vexpl"><?=gettext("802.1Q VLAN pcp (between 0 and 7, default 0) ");?></span></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
|
||
|
<td width="78%" class="vtable">
|
||
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
|
||