Project

General

Profile

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