Project

General

Profile

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