Project

General

Profile

Download (4.74 KB) Statistics
| Branch: | Tag: | Revision:
1 cae1695e Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	interfaces_vlan.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 cae1695e Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9 5b237745 Scott Ullrich
	All rights reserved.
10 cae1695e Scott Ullrich
11 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13 cae1695e Scott Ullrich
14 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16 cae1695e Scott Ullrich
17 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20 cae1695e Scott Ullrich
21 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32 7ac5a4cb Scott Ullrich
/*
33
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
34 e78276d8 sbeaver
	pfSense_MODULE: interfaces
35 7ac5a4cb Scott Ullrich
*/
36 5b237745 Scott Ullrich
37 6b07c15a Matthew Grooms
##|+PRIV
38
##|*IDENT=page-interfaces-vlan
39
##|*NAME=Interfaces: VLAN page
40
##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
41
##|*MATCH=interfaces_vlan.php*
42
##|-PRIV
43
44 5b237745 Scott Ullrich
require("guiconfig.inc");
45
46 2af86dda Phil Davis
if (!is_array($config['vlans']['vlan'])) {
47 5b237745 Scott Ullrich
	$config['vlans']['vlan'] = array();
48 2af86dda Phil Davis
}
49 5b237745 Scott Ullrich
50
$a_vlans = &$config['vlans']['vlan'] ;
51
52
function vlan_inuse($num) {
53 c059940b Erik Fonnesbeck
	global $config, $a_vlans;
54 5b237745 Scott Ullrich
55 fbb45bb0 Ermal Luçi
	$iflist = get_configured_interface_list(false, true);
56
	foreach ($iflist as $if) {
57 2af86dda Phil Davis
		if ($config['interfaces'][$if]['if'] == $a_vlans[$num]['vlanif']) {
58 5b237745 Scott Ullrich
			return true;
59 2af86dda Phil Davis
		}
60 5b237745 Scott Ullrich
	}
61 cae1695e Scott Ullrich
62 5b237745 Scott Ullrich
	return false;
63
}
64
65
if ($_GET['act'] == "del") {
66 2af86dda Phil Davis
	if (!isset($_GET['id'])) {
67 465f17a3 Thane Gill
		$input_errors[] = gettext("Wrong parameters supplied");
68 2af86dda Phil Davis
	} else if (empty($a_vlans[$_GET['id']])) {
69 465f17a3 Thane Gill
		$input_errors[] = gettext("Wrong index supplied");
70 5b237745 Scott Ullrich
	/* check if still in use */
71 2af86dda Phil Davis
	} else if (vlan_inuse($_GET['id'])) {
72 f76baeb3 Rafael Lucas
		$input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface.");
73 5b237745 Scott Ullrich
	} else {
74 2af86dda Phil Davis
		if (does_interface_exist($a_vlans[$_GET['id']]['vlanif'])) {
75 36b7f215 Renato Botelho
			pfSense_interface_destroy($a_vlans[$_GET['id']]['vlanif']);
76 2af86dda Phil Davis
		}
77 5b237745 Scott Ullrich
		unset($a_vlans[$_GET['id']]);
78 cae1695e Scott Ullrich
79 5b237745 Scott Ullrich
		write_config();
80 de068d0b Scott Ullrich
81 5b237745 Scott Ullrich
		header("Location: interfaces_vlan.php");
82
		exit;
83
	}
84
}
85
86 7f43ca88 Scott Ullrich
87 6c07db48 Phil Davis
$pgtitle = array(gettext("Interfaces"), gettext("VLAN"));
88 b32dd0a6 jim-p
$shortcut_section = "interfaces";
89 465f17a3 Thane Gill
include('head.inc');
90
91
if ($input_errors) print_input_errors($input_errors);
92
93
$tab_array = array();
94 69ddae89 sbeaver
$tab_array[] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
95
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
96
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
97
$tab_array[] = array(gettext("VLANs"), true, "interfaces_vlan.php");
98
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
99
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
100
$tab_array[] = array(gettext("GRE"), false, "interfaces_gre.php");
101
$tab_array[] = array(gettext("GIF"), false, "interfaces_gif.php");
102
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
103
$tab_array[] = array(gettext("LAGG"), false, "interfaces_lagg.php");
104 465f17a3 Thane Gill
display_top_tabs($tab_array);
105 e78276d8 sbeaver
106
print_info_box(sprintf(gettext('NOTE: Not all drivers/NICs support 802.1Q '.
107
		'VLAN tagging properly. <br />On cards that do not explicitly support it, VLAN '.
108
		'tagging will still work, but the reduced MTU may cause problems.<br />See the '.
109
		'%s handbook for information on supported cards.'),$g['product_name']));
110
?>
111
<div class="table-responsive">
112
	<table class="table">
113
		<tr>
114
			<th><?=gettext('Interface');?></th>
115
			<th><?=gettext('VLAN tag');?></th>
116
			<th><?=gettext('Description');?></th>
117
		</tr>
118
<?php
119
	$i = 0;
120
	foreach ($a_vlans as $vlan) {
121 c8b8ff69 Scott Ullrich
?>
122 e78276d8 sbeaver
		<tr>
123
			<td><?=htmlspecialchars($vlan['if']);?></td>
124
			<td><?=htmlspecialchars($vlan['tag']);?></td>
125
			<td><?=htmlspecialchars($vlan['descr']);?></td>
126
			<td>
127
				<a class="btn btn-primary btn-xs" role="button" href="interfaces_vlan_edit.php?id=<?=$i?>"><?=gettext('Edit')?></a>
128
				<a class="btn btn-danger btn-xs" role="button" href="interfaces_vlan.php?act=del&amp;id=<?=$i?>"><?=gettext('Delete')?></a></td>
129
			</td>
130
		</tr>
131
		<?php
132
			$i++;
133
	}
134
?>
135
	</table>
136 69ddae89 sbeaver
	<nav class="action-buttons">
137
		<a class="btn btn-success" role="button" href="interfaces_vlan_edit.php"><?=gettext('Add VLAN'); ?></a>
138
	</nav>
139 e78276d8 sbeaver
</div>
140
<?php
141 a41fd4a7 Sjon Hortensius
include("foot.inc");