Project

General

Profile

Download (6.78 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	interfaces_vlan.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *
8
 *	Some or all of this file is based on the m0n0wall project which is
9
 *	Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
10
 *
11
 *	Redistribution and use in source and binary forms, with or without modification,
12
 *	are permitted provided that the following conditions are met:
13
 *
14
 *	1. Redistributions of source code must retain the above copyright notice,
15
 *		this list of conditions and the following disclaimer.
16
 *
17
 *	2. Redistributions in binary form must reproduce the above copyright
18
 *		notice, this list of conditions and the following disclaimer in
19
 *		the documentation and/or other materials provided with the
20
 *		distribution.
21
 *
22
 *	3. All advertising materials mentioning features or use of this software
23
 *		must display the following acknowledgment:
24
 *		"This product includes software developed by the pfSense Project
25
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
26
 *
27
 *	4. The names "pfSense" and "pfSense Project" must not be used to
28
 *		 endorse or promote products derived from this software without
29
 *		 prior written permission. For written permission, please contact
30
 *		 coreteam@pfsense.org.
31
 *
32
 *	5. Products derived from this software may not be called "pfSense"
33
 *		nor may "pfSense" appear in their names without prior written
34
 *		permission of the Electric Sheep Fencing, LLC.
35
 *
36
 *	6. Redistributions of any form whatsoever must retain the following
37
 *		acknowledgment:
38
 *
39
 *	"This product includes software developed by the pfSense Project
40
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
41
 *
42
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
43
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
46
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
54
 *
55
 *	====================================================================
56
 *
57
 */
58
/*
59
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
60
	pfSense_MODULE: interfaces
61
*/
62

    
63
##|+PRIV
64
##|*IDENT=page-interfaces-vlan
65
##|*NAME=Interfaces: VLAN page
66
##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
67
##|*MATCH=interfaces_vlan.php*
68
##|-PRIV
69

    
70
require("guiconfig.inc");
71

    
72
if (!is_array($config['vlans']['vlan'])) {
73
	$config['vlans']['vlan'] = array();
74
}
75

    
76
$a_vlans = &$config['vlans']['vlan'] ;
77

    
78
function vlan_inuse($num) {
79
	global $config, $a_vlans;
80

    
81
	$iflist = get_configured_interface_list(false, true);
82
	foreach ($iflist as $if) {
83
		if ($config['interfaces'][$if]['if'] == $a_vlans[$num]['vlanif']) {
84
			return true;
85
		}
86
	}
87

    
88
	return false;
89
}
90

    
91
if ($_POST['act'] == "del") {
92
	if (!isset($_POST['id'])) {
93
		$input_errors[] = gettext("Wrong parameters supplied");
94
	} else if (empty($a_vlans[$_POST['id']])) {
95
		$input_errors[] = gettext("Wrong index supplied");
96
	/* check if still in use */
97
	} else if (vlan_inuse($_POST['id'])) {
98
		$input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface.");
99
	} else {
100
		if (does_interface_exist($a_vlans[$_POST['id']]['vlanif'])) {
101
			pfSense_interface_destroy($a_vlans[$_POST['id']]['vlanif']);
102
		}
103
		unset($a_vlans[$_POST['id']]);
104

    
105
		write_config();
106

    
107
		header("Location: interfaces_vlan.php");
108
		exit;
109
	}
110
}
111

    
112

    
113
$pgtitle = array(gettext("Interfaces"), gettext("VLAN"));
114
$shortcut_section = "interfaces";
115
include('head.inc');
116

    
117
if ($input_errors) print_input_errors($input_errors);
118

    
119
$tab_array = array();
120
$tab_array[] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
121
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
122
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
123
$tab_array[] = array(gettext("VLANs"), true, "interfaces_vlan.php");
124
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
125
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
126
$tab_array[] = array(gettext("GRE"), false, "interfaces_gre.php");
127
$tab_array[] = array(gettext("GIF"), false, "interfaces_gif.php");
128
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
129
$tab_array[] = array(gettext("LAGG"), false, "interfaces_lagg.php");
130
display_top_tabs($tab_array);
131

    
132
?>
133
<form action="interfaces_vlan.php" method="post">
134
	<input id="act" type="hidden" name="act" value="" />
135
	<input id="id" type="hidden" name="id" value=""/>
136

    
137
	<div class="table-responsive">
138
		<table class="table table-striped table-hover table-condensed">
139
			<thead>
140
				<tr>
141
					<th><?=gettext('Interface');?></th>
142
					<th><?=gettext('VLAN tag');?></th>
143
					<th><?=gettext('Description');?></th>
144
				</tr>
145
			</thead>
146
<?php
147
	$i = 0;
148
	foreach ($a_vlans as $vlan) {
149
?>
150
				<tr>
151
					<td><?=htmlspecialchars($vlan['if']);?></td>
152
					<td><?=htmlspecialchars($vlan['tag']);?></td>
153
					<td><?=htmlspecialchars($vlan['descr']);?></td>
154
					<td>
155
						<a class="fa fa-pencil"	title="<?=gettext('Edit VLAN')?>"	role="button" href="interfaces_vlan_edit.php?id=<?=$i?>"></a>
156
<!--						<a class="btn btn-danger btn-xs" role="button" href="interfaces_vlan.php?act=del&amp;id=<?=$i?>"><?=gettext('Delete')?></a></td> -->
157
						<a class="fa fa-trash"	title="<?=gettext('Delete VLAN')?>"	role="button" id="del-<?=$i?>"></a>
158
					</td>
159
				</tr>
160
<?php
161
			$i++;
162
	}
163
?>
164
		</table>
165
		<nav class="action-buttons">
166
			<a class="btn btn-success btn-sm" role="button" href="interfaces_vlan_edit.php">
167
				<i class="fa fa-plus icon-embed-btn"></i>
168
				<?=gettext('Add'); ?>
169
			</a>
170
		</nav>
171
	</div>
172
</form>
173

    
174
<div id="infoblock">
175
	<?=print_info_box(sprintf(gettext('NOTE: Not all drivers/NICs support 802.1Q '.
176
		'VLAN tagging properly. <br />On cards that do not explicitly support it, VLAN '.
177
		'tagging will still work, but the reduced MTU may cause problems.<br />See the '.
178
		'%s handbook for information on supported cards.'),$g['product_name']), info)?>
179
</div>
180
<script>
181
//<![CDATA[
182
events.push(function(){
183
	// Select 'delete button' clicks, extract the id, set the hidden input values and submit
184
	$('[id^=del-]').click(function(event) {
185
		if(confirm('<?=gettext("Are you sure you want to delete this VLAN?")?>')) {
186
			$('#act').val('del');
187
			$('#id').val(this.id.replace("del-", ""));
188
			$(this).parents('form').submit();
189
		}
190
	});
191
});
192
//]]>
193
</script>
194
<?php
195
include("foot.inc");
(99-99/235)