Project

General

Profile

Download (7.2 KB) Statistics
| Branch: | Tag: | Revision:
1 cae1695e Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3
	interfaces_vlan.php
4
*/
5 d42b970e Stephen Beaver
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7 191cb31d Stephen Beaver
 *
8 cb41dd63 Renato Botelho
 *	Some or all of this file is based on the m0n0wall project which is
9
 *	Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
10 d42b970e Stephen Beaver
 *
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 5b237745 Scott Ullrich
59 6b07c15a Matthew Grooms
##|+PRIV
60
##|*IDENT=page-interfaces-vlan
61 5230f468 jim-p
##|*NAME=Interfaces: VLAN
62 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
63
##|*MATCH=interfaces_vlan.php*
64
##|-PRIV
65
66 5b237745 Scott Ullrich
require("guiconfig.inc");
67
68 2af86dda Phil Davis
if (!is_array($config['vlans']['vlan'])) {
69 5b237745 Scott Ullrich
	$config['vlans']['vlan'] = array();
70 2af86dda Phil Davis
}
71 5b237745 Scott Ullrich
72
$a_vlans = &$config['vlans']['vlan'] ;
73
74
function vlan_inuse($num) {
75 c059940b Erik Fonnesbeck
	global $config, $a_vlans;
76 5b237745 Scott Ullrich
77 fbb45bb0 Ermal Luçi
	$iflist = get_configured_interface_list(false, true);
78
	foreach ($iflist as $if) {
79 2af86dda Phil Davis
		if ($config['interfaces'][$if]['if'] == $a_vlans[$num]['vlanif']) {
80 5b237745 Scott Ullrich
			return true;
81 2af86dda Phil Davis
		}
82 5b237745 Scott Ullrich
	}
83 cae1695e Scott Ullrich
84 5b237745 Scott Ullrich
	return false;
85
}
86
87 4f7fb8a6 heper
if ($_POST['act'] == "del") {
88
	if (!isset($_POST['id'])) {
89 465f17a3 Thane Gill
		$input_errors[] = gettext("Wrong parameters supplied");
90 4f7fb8a6 heper
	} else if (empty($a_vlans[$_POST['id']])) {
91 465f17a3 Thane Gill
		$input_errors[] = gettext("Wrong index supplied");
92 5b237745 Scott Ullrich
	/* check if still in use */
93 4f7fb8a6 heper
	} else if (vlan_inuse($_POST['id'])) {
94 f76baeb3 Rafael Lucas
		$input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface.");
95 5b237745 Scott Ullrich
	} else {
96 4f7fb8a6 heper
		if (does_interface_exist($a_vlans[$_POST['id']]['vlanif'])) {
97
			pfSense_interface_destroy($a_vlans[$_POST['id']]['vlanif']);
98 2af86dda Phil Davis
		}
99 4f7fb8a6 heper
		unset($a_vlans[$_POST['id']]);
100 cae1695e Scott Ullrich
101 5b237745 Scott Ullrich
		write_config();
102 de068d0b Scott Ullrich
103 5b237745 Scott Ullrich
		header("Location: interfaces_vlan.php");
104
		exit;
105
	}
106
}
107
108 7f43ca88 Scott Ullrich
109 26b4bef8 k-paulius
$pgtitle = array(gettext("Interfaces"), gettext("VLANs"));
110 b32dd0a6 jim-p
$shortcut_section = "interfaces";
111 465f17a3 Thane Gill
include('head.inc');
112
113
if ($input_errors) print_input_errors($input_errors);
114
115
$tab_array = array();
116 26b4bef8 k-paulius
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
117 69ddae89 sbeaver
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
118
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
119
$tab_array[] = array(gettext("VLANs"), true, "interfaces_vlan.php");
120
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
121
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
122 26b4bef8 k-paulius
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
123
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
124 69ddae89 sbeaver
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
125 26b4bef8 k-paulius
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
126 465f17a3 Thane Gill
display_top_tabs($tab_array);
127 e78276d8 sbeaver
128
?>
129 4f7fb8a6 heper
<form action="interfaces_vlan.php" method="post">
130
	<input id="act" type="hidden" name="act" value="" />
131
	<input id="id" type="hidden" name="id" value=""/>
132
133 060ed238 Stephen Beaver
	<div class="panel panel-default">
134 70dc5cd6 Phil Davis
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('VLAN Interfaces')?></h2></div>
135 060ed238 Stephen Beaver
		<div class="panel-body">
136
			<div class="table-responsive">
137
				<table class="table table-striped table-hover table-condensed">
138
					<thead>
139
						<tr>
140
							<th><?=gettext('Interface');?></th>
141
							<th><?=gettext('VLAN tag');?></th>
142
							<th><?=gettext('Priority');?></th>
143
							<th><?=gettext('Description');?></th>
144 70dc5cd6 Phil Davis
							<th><?=gettext('Actions');?></th>
145 060ed238 Stephen Beaver
						</tr>
146
					</thead>
147
					<tbody>
148 e78276d8 sbeaver
<?php
149
	$i = 0;
150
	foreach ($a_vlans as $vlan) {
151 c8b8ff69 Scott Ullrich
?>
152 060ed238 Stephen Beaver
						<tr>
153 9fcc7581 Luiz Otavio O Souza
							<td>
154
<?php
155
	printf("%s", htmlspecialchars($vlan['if']));
156
	$iface = convert_real_interface_to_friendly_interface_name($vlan['if']);
157
	if (isset($iface) && strlen($iface) > 0)
158
		printf(" (%s)", htmlspecialchars($iface));
159
?>
160
							</td>
161 060ed238 Stephen Beaver
							<td><?=htmlspecialchars($vlan['tag']);?></td>
162
							<td><?=htmlspecialchars($vlan['pcp']);?></td>
163
							<td><?=htmlspecialchars($vlan['descr']);?></td>
164
							<td>
165
								<a class="fa fa-pencil"	title="<?=gettext('Edit VLAN')?>"	role="button" href="interfaces_vlan_edit.php?id=<?=$i?>"></a>
166 968865fa heper
<!--						<a class="btn btn-danger btn-xs" role="button" href="interfaces_vlan.php?act=del&amp;id=<?=$i?>"><?=gettext('Delete')?></a></td> -->
167 060ed238 Stephen Beaver
								<a class="fa fa-trash"	title="<?=gettext('Delete VLAN')?>"	role="button" id="del-<?=$i?>"></a>
168
							</td>
169
						</tr>
170 968865fa heper
<?php
171 4f7fb8a6 heper
			$i++;
172 e78276d8 sbeaver
	}
173
?>
174 060ed238 Stephen Beaver
					</tbody>
175
				</table>
176
			</div>
177
		</div>
178 4f7fb8a6 heper
	</div>
179 060ed238 Stephen Beaver
180
	<nav class="action-buttons">
181
		<a class="btn btn-success btn-sm" role="button" href="interfaces_vlan_edit.php">
182
			<i class="fa fa-plus icon-embed-btn"></i>
183
			<?=gettext('Add'); ?>
184
		</a>
185
	</nav>
186
187 4f7fb8a6 heper
</form>
188
189 35681930 Stephen Beaver
<div class="infoblock">
190 f6aebbcc NewEraCracker
	<?php print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q '.
191 2ec8f0ba Stephen Beaver
		'VLAN tagging properly. <br />On cards that do not explicitly support it, VLAN '.
192
		'tagging will still work, but the reduced MTU may cause problems.<br />See the '.
193 f6aebbcc NewEraCracker
		'%s handbook for information on supported cards.'), $g['product_name']), 'info', false); ?>
194 2ec8f0ba Stephen Beaver
</div>
195 8fd9052f Colin Fleming
<script type="text/javascript">
196 4f7fb8a6 heper
//<![CDATA[
197 aa82505e Phil Davis
events.push(function() {
198 4f7fb8a6 heper
	// Select 'delete button' clicks, extract the id, set the hidden input values and submit
199
	$('[id^=del-]').click(function(event) {
200 cbe639a8 Stephen Beaver
		$('#act').val('del');
201
		$('#id').val(this.id.replace("del-", ""));
202
		$(this).parents('form').submit();
203 4f7fb8a6 heper
	});
204
});
205
//]]>
206
</script>
207 e78276d8 sbeaver
<?php
208 a41fd4a7 Sjon Hortensius
include("foot.inc");