Project

General

Profile

Download (5.5 KB) Statistics
| Branch: | Tag: | Revision:
1 cae1695e Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 c5d81585 Renato Botelho
 * interfaces_vlan.php
4 191cb31d Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 81299b5c Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * All rights reserved.
8 d42b970e Stephen Beaver
 *
9 c5d81585 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 b12ea3fb Renato Botelho
 * 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 d42b970e Stephen Beaver
 *
17 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
18 d42b970e Stephen Beaver
 *
19 b12ea3fb Renato Botelho
 * 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 d42b970e Stephen Beaver
 */
25 5b237745 Scott Ullrich
26 6b07c15a Matthew Grooms
##|+PRIV
27
##|*IDENT=page-interfaces-vlan
28 5230f468 jim-p
##|*NAME=Interfaces: VLAN
29 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
30
##|*MATCH=interfaces_vlan.php*
31
##|-PRIV
32
33 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
34 5b237745 Scott Ullrich
35 2af86dda Phil Davis
if (!is_array($config['vlans']['vlan'])) {
36 5b237745 Scott Ullrich
	$config['vlans']['vlan'] = array();
37 2af86dda Phil Davis
}
38 5b237745 Scott Ullrich
39
$a_vlans = &$config['vlans']['vlan'] ;
40
41
function vlan_inuse($num) {
42 c059940b Erik Fonnesbeck
	global $config, $a_vlans;
43 5b237745 Scott Ullrich
44 fbb45bb0 Ermal Luçi
	$iflist = get_configured_interface_list(false, true);
45
	foreach ($iflist as $if) {
46 2af86dda Phil Davis
		if ($config['interfaces'][$if]['if'] == $a_vlans[$num]['vlanif']) {
47 5b237745 Scott Ullrich
			return true;
48 2af86dda Phil Davis
		}
49 5b237745 Scott Ullrich
	}
50 cae1695e Scott Ullrich
51 5b237745 Scott Ullrich
	return false;
52
}
53
54 4f7fb8a6 heper
if ($_POST['act'] == "del") {
55
	if (!isset($_POST['id'])) {
56 465f17a3 Thane Gill
		$input_errors[] = gettext("Wrong parameters supplied");
57 4f7fb8a6 heper
	} else if (empty($a_vlans[$_POST['id']])) {
58 465f17a3 Thane Gill
		$input_errors[] = gettext("Wrong index supplied");
59 5b237745 Scott Ullrich
	/* check if still in use */
60 4f7fb8a6 heper
	} else if (vlan_inuse($_POST['id'])) {
61 f76baeb3 Rafael Lucas
		$input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface.");
62 5b237745 Scott Ullrich
	} else {
63 4f7fb8a6 heper
		if (does_interface_exist($a_vlans[$_POST['id']]['vlanif'])) {
64
			pfSense_interface_destroy($a_vlans[$_POST['id']]['vlanif']);
65 2af86dda Phil Davis
		}
66 4f7fb8a6 heper
		unset($a_vlans[$_POST['id']]);
67 cae1695e Scott Ullrich
68 5b237745 Scott Ullrich
		write_config();
69 de068d0b Scott Ullrich
70 5b237745 Scott Ullrich
		header("Location: interfaces_vlan.php");
71
		exit;
72
	}
73
}
74
75 7f43ca88 Scott Ullrich
76 26b4bef8 k-paulius
$pgtitle = array(gettext("Interfaces"), gettext("VLANs"));
77 b32dd0a6 jim-p
$shortcut_section = "interfaces";
78 465f17a3 Thane Gill
include('head.inc');
79
80
if ($input_errors) print_input_errors($input_errors);
81
82
$tab_array = array();
83 26b4bef8 k-paulius
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
84 69ddae89 sbeaver
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
85
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
86
$tab_array[] = array(gettext("VLANs"), true, "interfaces_vlan.php");
87
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
88
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
89 26b4bef8 k-paulius
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
90
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
91 69ddae89 sbeaver
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
92 26b4bef8 k-paulius
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
93 465f17a3 Thane Gill
display_top_tabs($tab_array);
94 e78276d8 sbeaver
95
?>
96 4f7fb8a6 heper
<form action="interfaces_vlan.php" method="post">
97
	<input id="act" type="hidden" name="act" value="" />
98
	<input id="id" type="hidden" name="id" value=""/>
99
100 060ed238 Stephen Beaver
	<div class="panel panel-default">
101 70dc5cd6 Phil Davis
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('VLAN Interfaces')?></h2></div>
102 060ed238 Stephen Beaver
		<div class="panel-body">
103
			<div class="table-responsive">
104 1c10ce97 PiBa-NL
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
105 060ed238 Stephen Beaver
					<thead>
106
						<tr>
107
							<th><?=gettext('Interface');?></th>
108
							<th><?=gettext('VLAN tag');?></th>
109
							<th><?=gettext('Priority');?></th>
110
							<th><?=gettext('Description');?></th>
111 70dc5cd6 Phil Davis
							<th><?=gettext('Actions');?></th>
112 060ed238 Stephen Beaver
						</tr>
113
					</thead>
114
					<tbody>
115 e78276d8 sbeaver
<?php
116
	$i = 0;
117
	foreach ($a_vlans as $vlan) {
118 c8b8ff69 Scott Ullrich
?>
119 060ed238 Stephen Beaver
						<tr>
120 9fcc7581 Luiz Otavio O Souza
							<td>
121
<?php
122
	printf("%s", htmlspecialchars($vlan['if']));
123
	$iface = convert_real_interface_to_friendly_interface_name($vlan['if']);
124
	if (isset($iface) && strlen($iface) > 0)
125
		printf(" (%s)", htmlspecialchars($iface));
126
?>
127
							</td>
128 060ed238 Stephen Beaver
							<td><?=htmlspecialchars($vlan['tag']);?></td>
129
							<td><?=htmlspecialchars($vlan['pcp']);?></td>
130
							<td><?=htmlspecialchars($vlan['descr']);?></td>
131
							<td>
132 4401107f Steve Beaver
								<a class="fa fa-pencil"	title="<?=gettext('Edit VLAN')?>"	role="button" href="interfaces_vlan_edit.php?id=<?=$i?>" ></a>
133 4a03ae0a Steve Beaver
								<a class="fa fa-trash no-confirm"	title="<?=gettext('Delete VLAN')?>"	role="button" id="del-<?=$i?>"></a>
134 060ed238 Stephen Beaver
							</td>
135
						</tr>
136 968865fa heper
<?php
137 4f7fb8a6 heper
			$i++;
138 e78276d8 sbeaver
	}
139
?>
140 060ed238 Stephen Beaver
					</tbody>
141
				</table>
142
			</div>
143
		</div>
144 4f7fb8a6 heper
	</div>
145 060ed238 Stephen Beaver
146
	<nav class="action-buttons">
147 4401107f Steve Beaver
		<a class="btn btn-success btn-sm" role="button" href="interfaces_vlan_edit.php">
148 060ed238 Stephen Beaver
			<i class="fa fa-plus icon-embed-btn"></i>
149
			<?=gettext('Add'); ?>
150
		</a>
151
	</nav>
152
153 4f7fb8a6 heper
</form>
154
155 35681930 Stephen Beaver
<div class="infoblock">
156 f6aebbcc NewEraCracker
	<?php print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q '.
157 7ae1b34f Phil Davis
		'VLAN tagging properly. %1$sOn cards that do not explicitly support it, VLAN '.
158
		'tagging will still work, but the reduced MTU may cause problems.%1$sSee the '.
159
		'%2$s handbook for information on supported cards.'), '<br />', $g['product_name']), 'info', false); ?>
160 2ec8f0ba Stephen Beaver
</div>
161 38fe6f07 Steve Beaver
162
<?php
163
	$delmsg = gettext("Are you sure you want to delete this VLAN?");
164
?>
165
166 8fd9052f Colin Fleming
<script type="text/javascript">
167 4f7fb8a6 heper
//<![CDATA[
168 aa82505e Phil Davis
events.push(function() {
169 4f7fb8a6 heper
	// Select 'delete button' clicks, extract the id, set the hidden input values and submit
170
	$('[id^=del-]').click(function(event) {
171 38fe6f07 Steve Beaver
		if (confirm("<?=$delmsg?>")) {
172
			$('#act').val('del');
173
			$('#id').val(this.id.replace("del-", ""));
174
			$(this).parents('form').submit();
175
		}
176 4f7fb8a6 heper
	});
177 38fe6f07 Steve Beaver
178 4f7fb8a6 heper
});
179
//]]>
180
</script>
181 e78276d8 sbeaver
<?php
182 a41fd4a7 Sjon Hortensius
include("foot.inc");