1
|
<?php
|
2
|
/*
|
3
|
* interfaces_vlan.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
10
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11
|
* All rights reserved.
|
12
|
*
|
13
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
14
|
* you may not use this file except in compliance with the License.
|
15
|
* You may obtain a copy of the License at
|
16
|
*
|
17
|
* http://www.apache.org/licenses/LICENSE-2.0
|
18
|
*
|
19
|
* Unless required by applicable law or agreed to in writing, software
|
20
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
21
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
22
|
* See the License for the specific language governing permissions and
|
23
|
* limitations under the License.
|
24
|
*/
|
25
|
|
26
|
##|+PRIV
|
27
|
##|*IDENT=page-interfaces-vlan
|
28
|
##|*NAME=Interfaces: VLAN
|
29
|
##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
|
30
|
##|*MATCH=interfaces_vlan_new_prof.php*
|
31
|
##|-PRIV
|
32
|
|
33
|
require_once("guiconfig.inc");
|
34
|
require_once("interfaces_fast.inc");
|
35
|
|
36
|
global $profile;
|
37
|
|
38
|
if (!is_array($config['vlans'])) {
|
39
|
$config['vlans'] = array();
|
40
|
}
|
41
|
|
42
|
if (!is_array($config['vlans']['vlan'])) {
|
43
|
$config['vlans']['vlan'] = array();
|
44
|
}
|
45
|
|
46
|
$a_vlans = &$config['vlans']['vlan'] ;
|
47
|
|
48
|
if ($_POST['act'] == "del") {
|
49
|
if (!isset($_POST['id'])) {
|
50
|
$input_errors[] = gettext("Wrong parameters supplied");
|
51
|
} else if (empty($a_vlans[$_POST['id']])) {
|
52
|
$input_errors[] = gettext("Wrong index supplied");
|
53
|
/* check if still in use */
|
54
|
} else if (vlan_inuse($a_vlans[$_POST['id']])) {
|
55
|
$input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface.");
|
56
|
} else {
|
57
|
if (does_interface_exist($a_vlans[$_POST['id']]['vlanif'])) {
|
58
|
pfSense_interface_destroy($a_vlans[$_POST['id']]['vlanif']);
|
59
|
}
|
60
|
unset($a_vlans[$_POST['id']]);
|
61
|
|
62
|
write_config();
|
63
|
|
64
|
header("Location: interfaces_vlan.php");
|
65
|
exit;
|
66
|
}
|
67
|
}
|
68
|
|
69
|
|
70
|
$pgtitle = array(gettext("Interfaces"), gettext("VLANs"));
|
71
|
$shortcut_section = "interfaces";
|
72
|
include('head.inc');
|
73
|
|
74
|
if ($input_errors) print_input_errors($input_errors);
|
75
|
|
76
|
$tab_array = array();
|
77
|
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
|
78
|
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
|
79
|
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
|
80
|
$tab_array[] = array(gettext("VLANs"), true, "interfaces_vlan.php");
|
81
|
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
|
82
|
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
|
83
|
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
|
84
|
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
|
85
|
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
|
86
|
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
|
87
|
display_top_tabs($tab_array);
|
88
|
|
89
|
?>
|
90
|
<form action="interfaces_vlan.php" method="post">
|
91
|
<input id="act" type="hidden" name="act" value="" />
|
92
|
<input id="id" type="hidden" name="id" value=""/>
|
93
|
|
94
|
<div class="panel panel-default">
|
95
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('VLAN Interfaces')?></h2></div>
|
96
|
<div class="panel-body">
|
97
|
<div class="table-responsive">
|
98
|
<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
|
99
|
<thead>
|
100
|
<tr>
|
101
|
<th><?=gettext('Interface');?></th>
|
102
|
<th><?=gettext('VLAN tag');?></th>
|
103
|
<th><?=gettext('Priority');?></th>
|
104
|
<th><?=gettext('Description');?></th>
|
105
|
<th><?=gettext('Actions');?></th>
|
106
|
</tr>
|
107
|
</thead>
|
108
|
<tbody>
|
109
|
<?php
|
110
|
$i = 0;
|
111
|
$gettext_array = array('edit'=>gettext('Edit VLAN'),'del'=>gettext('Delete VLAN'));
|
112
|
$ifaces = convert_real_interface_to_friendly_interface_name_fast(array());
|
113
|
foreach ($a_vlans as $vlan) {
|
114
|
?>
|
115
|
<tr>
|
116
|
<td>
|
117
|
<?php
|
118
|
printf("%s", htmlspecialchars($vlan['if']));
|
119
|
if (isset($ifaces[$vlan['if']]) && strlen($ifaces[$vlan['if']]) > 0)
|
120
|
printf(" (%s)", htmlspecialchars($ifaces[$vlan['if']]));
|
121
|
?>
|
122
|
</td>
|
123
|
<td><?=htmlspecialchars($vlan['tag']);?></td>
|
124
|
<td><?=htmlspecialchars($vlan['pcp']);?></td>
|
125
|
<td><?=htmlspecialchars($vlan['descr']);?></td>
|
126
|
<td>
|
127
|
<a class="fa fa-pencil" title="<?=$gettext_array['edit']?>" role="button" href="interfaces_vlan_edit.php?id=<?=$i?>" ></a>
|
128
|
<a class="fa fa-trash no-confirm" title="<?=$gettext_array['del']?>" role="button" id="del-<?=$i?>"></a>
|
129
|
</td>
|
130
|
</tr>
|
131
|
<?php
|
132
|
$i++;
|
133
|
}
|
134
|
?>
|
135
|
</tbody>
|
136
|
</table>
|
137
|
</div>
|
138
|
</div>
|
139
|
</div>
|
140
|
|
141
|
<nav class="action-buttons">
|
142
|
<a class="btn btn-success btn-sm" role="button" href="interfaces_vlan_edit.php">
|
143
|
<i class="fa fa-plus icon-embed-btn"></i>
|
144
|
<?=gettext('Add'); ?>
|
145
|
</a>
|
146
|
</nav>
|
147
|
|
148
|
</form>
|
149
|
|
150
|
<div class="infoblock">
|
151
|
<?php print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q '.
|
152
|
'VLAN tagging properly. %1$sOn cards that do not explicitly support it, VLAN '.
|
153
|
'tagging will still work, but the reduced MTU may cause problems.%1$sSee the '.
|
154
|
'%2$s handbook for information on supported cards.'), '<br />', $g['product_name']), 'info', false); ?>
|
155
|
</div>
|
156
|
|
157
|
<?php
|
158
|
$delmsg = gettext("Are you sure you want to delete this VLAN?");
|
159
|
?>
|
160
|
|
161
|
<script type="text/javascript">
|
162
|
//<![CDATA[
|
163
|
events.push(function() {
|
164
|
// Select 'delete button' clicks, extract the id, set the hidden input values and submit
|
165
|
$('[id^=del-]').click(function(event) {
|
166
|
if (confirm("<?=$delmsg?>")) {
|
167
|
$('#act').val('del');
|
168
|
$('#id').val(this.id.replace("del-", ""));
|
169
|
$(this).parents('form').submit();
|
170
|
}
|
171
|
});
|
172
|
|
173
|
});
|
174
|
//]]>
|
175
|
</script>
|
176
|
<?php
|
177
|
include("foot.inc");
|