Project

General

Profile

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

    
58
##|+PRIV
59
##|*IDENT=page-interfaces-vlan
60
##|*NAME=Interfaces: VLAN
61
##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
62
##|*MATCH=interfaces_vlan.php*
63
##|-PRIV
64

    
65
require_once("guiconfig.inc");
66

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

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

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

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

    
83
	return false;
84
}
85

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

    
100
		write_config();
101

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

    
107

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

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

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

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

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

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

    
186
</form>
187

    
188
<div class="infoblock">
189
	<?php print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q '.
190
		'VLAN tagging properly. <br />On cards that do not explicitly support it, VLAN '.
191
		'tagging will still work, but the reduced MTU may cause problems.<br />See the '.
192
		'%s handbook for information on supported cards.'), $g['product_name']), 'info', false); ?>
193
</div>
194

    
195
<?php
196
	$delmsg = gettext("Are you sure you want to delete this VLAN?");
197
?>
198

    
199
<script type="text/javascript">
200
//<![CDATA[
201
events.push(function() {
202
	// Select 'delete button' clicks, extract the id, set the hidden input values and submit
203
	$('[id^=del-]').click(function(event) {
204
		if (confirm("<?=$delmsg?>")) {
205
			$('#act').val('del');
206
			$('#id').val(this.id.replace("del-", ""));
207
			$(this).parents('form').submit();
208
		}
209
	});
210

    
211
});
212
//]]>
213
</script>
214
<?php
215
include("foot.inc");
(87-87/230)