Project

General

Profile

Download (7.21 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
##|+PRIV
60
##|*IDENT=page-interfaces-vlan
61
##|*NAME=Interfaces: VLAN
62
##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
63
##|*MATCH=interfaces_vlan.php*
64
##|-PRIV
65

    
66
require_once("guiconfig.inc");
67

    
68
if (!is_array($config['vlans']['vlan'])) {
69
	$config['vlans']['vlan'] = array();
70
}
71

    
72
$a_vlans = &$config['vlans']['vlan'] ;
73

    
74
function vlan_inuse($num) {
75
	global $config, $a_vlans;
76

    
77
	$iflist = get_configured_interface_list(false, true);
78
	foreach ($iflist as $if) {
79
		if ($config['interfaces'][$if]['if'] == $a_vlans[$num]['vlanif']) {
80
			return true;
81
		}
82
	}
83

    
84
	return false;
85
}
86

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

    
101
		write_config();
102

    
103
		header("Location: interfaces_vlan.php");
104
		exit;
105
	}
106
}
107

    
108

    
109
$pgtitle = array(gettext("Interfaces"), gettext("VLANs"));
110
$shortcut_section = "interfaces";
111
include('head.inc');
112

    
113
if ($input_errors) print_input_errors($input_errors);
114

    
115
$tab_array = array();
116
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
117
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
118
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
119
$tab_array[] = array(gettext("VLANs"), true, "interfaces_vlan.php");
120
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
121
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
122
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
123
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
124
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
125
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
126
display_top_tabs($tab_array);
127

    
128
?>
129
<form action="interfaces_vlan.php" method="post">
130
	<input id="act" type="hidden" name="act" value="" />
131
	<input id="id" type="hidden" name="id" value=""/>
132

    
133
	<div class="panel panel-default">
134
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('VLAN Interfaces')?></h2></div>
135
		<div class="panel-body">
136
			<div class="table-responsive">
137
				<table class="table table-striped table-hover table-condensed">
138
					<thead>
139
						<tr>
140
							<th><?=gettext('Interface');?></th>
141
							<th><?=gettext('VLAN tag');?></th>
142
							<th><?=gettext('Priority');?></th>
143
							<th><?=gettext('Description');?></th>
144
							<th><?=gettext('Actions');?></th>
145
						</tr>
146
					</thead>
147
					<tbody>
148
<?php
149
	$i = 0;
150
	foreach ($a_vlans as $vlan) {
151
?>
152
						<tr>
153
							<td>
154
<?php
155
	printf("%s", htmlspecialchars($vlan['if']));
156
	$iface = convert_real_interface_to_friendly_interface_name($vlan['if']);
157
	if (isset($iface) && strlen($iface) > 0)
158
		printf(" (%s)", htmlspecialchars($iface));
159
?>
160
							</td>
161
							<td><?=htmlspecialchars($vlan['tag']);?></td>
162
							<td><?=htmlspecialchars($vlan['pcp']);?></td>
163
							<td><?=htmlspecialchars($vlan['descr']);?></td>
164
							<td>
165
								<a class="fa fa-pencil"	title="<?=gettext('Edit VLAN')?>"	role="button" href="interfaces_vlan_edit.php?id=<?=$i?>"></a>
166
<!--						<a class="btn btn-danger btn-xs" role="button" href="interfaces_vlan.php?act=del&amp;id=<?=$i?>"><?=gettext('Delete')?></a></td> -->
167
								<a class="fa fa-trash"	title="<?=gettext('Delete VLAN')?>"	role="button" id="del-<?=$i?>"></a>
168
							</td>
169
						</tr>
170
<?php
171
			$i++;
172
	}
173
?>
174
					</tbody>
175
				</table>
176
			</div>
177
		</div>
178
	</div>
179

    
180
	<nav class="action-buttons">
181
		<a class="btn btn-success btn-sm" role="button" href="interfaces_vlan_edit.php">
182
			<i class="fa fa-plus icon-embed-btn"></i>
183
			<?=gettext('Add'); ?>
184
		</a>
185
	</nav>
186

    
187
</form>
188

    
189
<div class="infoblock">
190
	<?php print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q '.
191
		'VLAN tagging properly. <br />On cards that do not explicitly support it, VLAN '.
192
		'tagging will still work, but the reduced MTU may cause problems.<br />See the '.
193
		'%s handbook for information on supported cards.'), $g['product_name']), 'info', false); ?>
194
</div>
195
<script type="text/javascript">
196
//<![CDATA[
197
events.push(function() {
198
	// Select 'delete button' clicks, extract the id, set the hidden input values and submit
199
	$('[id^=del-]').click(function(event) {
200
		$('#act').val('del');
201
		$('#id').val(this.id.replace("del-", ""));
202
		$(this).parents('form').submit();
203
	});
204
});
205
//]]>
206
</script>
207
<?php
208
include("foot.inc");
(85-85/225)