1 |
cae1695e
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
interfaces_vlan.php
|
5 |
|
|
*/
|
6 |
d42b970e
|
Stephen Beaver
|
/* ====================================================================
|
7 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
8 |
|
|
* Copyright (c) 2004, 2005 Scott Ullrich
|
9 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>
|
10 |
|
|
*
|
11 |
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
12 |
|
|
* are permitted provided that the following conditions are met:
|
13 |
|
|
*
|
14 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
* this list of conditions and the following disclaimer.
|
16 |
|
|
*
|
17 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
* notice, this list of conditions and the following disclaimer in
|
19 |
|
|
* the documentation and/or other materials provided with the
|
20 |
|
|
* distribution.
|
21 |
|
|
*
|
22 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
23 |
|
|
* must display the following acknowledgment:
|
24 |
|
|
* "This product includes software developed by the pfSense Project
|
25 |
|
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
26 |
|
|
*
|
27 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
28 |
|
|
* endorse or promote products derived from this software without
|
29 |
|
|
* prior written permission. For written permission, please contact
|
30 |
|
|
* coreteam@pfsense.org.
|
31 |
|
|
*
|
32 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
33 |
|
|
* nor may "pfSense" appear in their names without prior written
|
34 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
35 |
|
|
*
|
36 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
37 |
|
|
* acknowledgment:
|
38 |
|
|
*
|
39 |
|
|
* "This product includes software developed by the pfSense Project
|
40 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
41 |
|
|
*
|
42 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
43 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
44 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
45 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
46 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
47 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
48 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
49 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
50 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
51 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
52 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
53 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
54 |
|
|
*
|
55 |
|
|
* ====================================================================
|
56 |
|
|
*
|
57 |
|
|
*/
|
58 |
7ac5a4cb
|
Scott Ullrich
|
/*
|
59 |
|
|
pfSense_BUILDER_BINARIES: /sbin/ifconfig
|
60 |
e78276d8
|
sbeaver
|
pfSense_MODULE: interfaces
|
61 |
7ac5a4cb
|
Scott Ullrich
|
*/
|
62 |
5b237745
|
Scott Ullrich
|
|
63 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
64 |
|
|
##|*IDENT=page-interfaces-vlan
|
65 |
|
|
##|*NAME=Interfaces: VLAN page
|
66 |
|
|
##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
|
67 |
|
|
##|*MATCH=interfaces_vlan.php*
|
68 |
|
|
##|-PRIV
|
69 |
|
|
|
70 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
71 |
|
|
|
72 |
2af86dda
|
Phil Davis
|
if (!is_array($config['vlans']['vlan'])) {
|
73 |
5b237745
|
Scott Ullrich
|
$config['vlans']['vlan'] = array();
|
74 |
2af86dda
|
Phil Davis
|
}
|
75 |
5b237745
|
Scott Ullrich
|
|
76 |
|
|
$a_vlans = &$config['vlans']['vlan'] ;
|
77 |
|
|
|
78 |
|
|
function vlan_inuse($num) {
|
79 |
c059940b
|
Erik Fonnesbeck
|
global $config, $a_vlans;
|
80 |
5b237745
|
Scott Ullrich
|
|
81 |
fbb45bb0
|
Ermal Luçi
|
$iflist = get_configured_interface_list(false, true);
|
82 |
|
|
foreach ($iflist as $if) {
|
83 |
2af86dda
|
Phil Davis
|
if ($config['interfaces'][$if]['if'] == $a_vlans[$num]['vlanif']) {
|
84 |
5b237745
|
Scott Ullrich
|
return true;
|
85 |
2af86dda
|
Phil Davis
|
}
|
86 |
5b237745
|
Scott Ullrich
|
}
|
87 |
cae1695e
|
Scott Ullrich
|
|
88 |
5b237745
|
Scott Ullrich
|
return false;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
d42b970e
|
Stephen Beaver
|
if ($_POST['act'] == "del") {
|
92 |
|
|
if (!isset($_POST['id'])) {
|
93 |
465f17a3
|
Thane Gill
|
$input_errors[] = gettext("Wrong parameters supplied");
|
94 |
d42b970e
|
Stephen Beaver
|
} else if (empty($a_vlans[$_POST['id']])) {
|
95 |
465f17a3
|
Thane Gill
|
$input_errors[] = gettext("Wrong index supplied");
|
96 |
5b237745
|
Scott Ullrich
|
/* check if still in use */
|
97 |
d42b970e
|
Stephen Beaver
|
} else if (vlan_inuse($_POST['id'])) {
|
98 |
f76baeb3
|
Rafael Lucas
|
$input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface.");
|
99 |
5b237745
|
Scott Ullrich
|
} else {
|
100 |
d42b970e
|
Stephen Beaver
|
if (does_interface_exist($a_vlans[$_POST['id']]['vlanif'])) {
|
101 |
|
|
pfSense_interface_destroy($a_vlans[$_POST['id']]['vlanif']);
|
102 |
2af86dda
|
Phil Davis
|
}
|
103 |
d42b970e
|
Stephen Beaver
|
unset($a_vlans[$_POST['id']]);
|
104 |
cae1695e
|
Scott Ullrich
|
|
105 |
5b237745
|
Scott Ullrich
|
write_config();
|
106 |
de068d0b
|
Scott Ullrich
|
|
107 |
5b237745
|
Scott Ullrich
|
header("Location: interfaces_vlan.php");
|
108 |
|
|
exit;
|
109 |
|
|
}
|
110 |
|
|
}
|
111 |
|
|
|
112 |
7f43ca88
|
Scott Ullrich
|
|
113 |
6c07db48
|
Phil Davis
|
$pgtitle = array(gettext("Interfaces"), gettext("VLAN"));
|
114 |
b32dd0a6
|
jim-p
|
$shortcut_section = "interfaces";
|
115 |
465f17a3
|
Thane Gill
|
include('head.inc');
|
116 |
|
|
|
117 |
|
|
if ($input_errors) print_input_errors($input_errors);
|
118 |
|
|
|
119 |
|
|
$tab_array = array();
|
120 |
69ddae89
|
sbeaver
|
$tab_array[] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
|
121 |
|
|
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
|
122 |
|
|
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
|
123 |
|
|
$tab_array[] = array(gettext("VLANs"), true, "interfaces_vlan.php");
|
124 |
|
|
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
|
125 |
|
|
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
|
126 |
|
|
$tab_array[] = array(gettext("GRE"), false, "interfaces_gre.php");
|
127 |
|
|
$tab_array[] = array(gettext("GIF"), false, "interfaces_gif.php");
|
128 |
|
|
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
|
129 |
|
|
$tab_array[] = array(gettext("LAGG"), false, "interfaces_lagg.php");
|
130 |
465f17a3
|
Thane Gill
|
display_top_tabs($tab_array);
|
131 |
e78276d8
|
sbeaver
|
|
132 |
|
|
print_info_box(sprintf(gettext('NOTE: Not all drivers/NICs support 802.1Q '.
|
133 |
|
|
'VLAN tagging properly. <br />On cards that do not explicitly support it, VLAN '.
|
134 |
|
|
'tagging will still work, but the reduced MTU may cause problems.<br />See the '.
|
135 |
|
|
'%s handbook for information on supported cards.'),$g['product_name']));
|
136 |
|
|
?>
|
137 |
d42b970e
|
Stephen Beaver
|
<form action="interfaces_vlan.php" method="post">
|
138 |
|
|
<input id="act" type="hidden" name="act" value="" />
|
139 |
|
|
<input id="id" type="hidden" name="id" value=""/>
|
140 |
|
|
|
141 |
|
|
<div class="table-responsive">
|
142 |
|
|
<table class="table table-striped table-hover table-condensed">
|
143 |
|
|
<tr>
|
144 |
|
|
<th><?=gettext('Interface');?></th>
|
145 |
|
|
<th><?=gettext('VLAN tag');?></th>
|
146 |
|
|
<th><?=gettext('Description');?></th>
|
147 |
|
|
</tr>
|
148 |
e78276d8
|
sbeaver
|
<?php
|
149 |
|
|
$i = 0;
|
150 |
|
|
foreach ($a_vlans as $vlan) {
|
151 |
c8b8ff69
|
Scott Ullrich
|
?>
|
152 |
d42b970e
|
Stephen Beaver
|
<tr>
|
153 |
|
|
<td><?=htmlspecialchars($vlan['if']);?></td>
|
154 |
|
|
<td><?=htmlspecialchars($vlan['tag']);?></td>
|
155 |
|
|
<td><?=htmlspecialchars($vlan['descr']);?></td>
|
156 |
|
|
<td>
|
157 |
|
|
<a class="btn btn-primary btn-xs" role="button" href="interfaces_vlan_edit.php?id=<?=$i?>"><?=gettext('Edit')?></a>
|
158 |
|
|
<!-- <a class="btn btn-danger btn-xs" role="button" href="interfaces_vlan.php?act=del&id=<?=$i?>"><?=gettext('Delete')?></a></td> -->
|
159 |
|
|
<a class="btn btn-danger btn-xs" role="button" id="del-<?=$i?>"><?=gettext('Delete')?></a></td>
|
160 |
|
|
</td>
|
161 |
|
|
</tr>
|
162 |
e78276d8
|
sbeaver
|
<?php
|
163 |
|
|
$i++;
|
164 |
|
|
}
|
165 |
|
|
?>
|
166 |
d42b970e
|
Stephen Beaver
|
</table>
|
167 |
|
|
<nav class="action-buttons">
|
168 |
|
|
<a class="btn btn-success" role="button" href="interfaces_vlan_edit.php"><?=gettext('Add VLAN'); ?></a>
|
169 |
|
|
</nav>
|
170 |
|
|
</div>
|
171 |
|
|
</form>
|
172 |
|
|
|
173 |
|
|
<script>
|
174 |
|
|
//<![CDATA[
|
175 |
|
|
events.push(function(){
|
176 |
|
|
// Select 'delete button' clicks, extract the id, set the hidden input values and submit
|
177 |
|
|
$('[id^=del-]').click(function(event) {
|
178 |
|
|
$('#act').val('del');
|
179 |
|
|
$('#id').val(this.id.replace("del-", ""));
|
180 |
|
|
$(this).parents('form').submit();
|
181 |
|
|
});
|
182 |
|
|
});
|
183 |
|
|
//]]>
|
184 |
|
|
</script>
|
185 |
e78276d8
|
sbeaver
|
<?php
|
186 |
a41fd4a7
|
Sjon Hortensius
|
include("foot.inc");
|