Project

General

Profile

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