Project

General

Profile

Download (5.5 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
 * 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
 *
17
 * http://www.apache.org/licenses/LICENSE-2.0
18
 *
19
 * 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
 */
25

    
26
##|+PRIV
27
##|*IDENT=page-interfaces-vlan
28
##|*NAME=Interfaces: VLAN
29
##|*DESCR=Allow access to the 'Interfaces: VLAN' page.
30
##|*MATCH=interfaces_vlan.php*
31
##|-PRIV
32

    
33
require_once("guiconfig.inc");
34

    
35
if (!is_array($config['vlans']['vlan'])) {
36
	$config['vlans']['vlan'] = array();
37
}
38

    
39
$a_vlans = &$config['vlans']['vlan'] ;
40

    
41
function vlan_inuse($num) {
42
	global $config, $a_vlans;
43

    
44
	$iflist = get_configured_interface_list(false, true);
45
	foreach ($iflist as $if) {
46
		if ($config['interfaces'][$if]['if'] == $a_vlans[$num]['vlanif']) {
47
			return true;
48
		}
49
	}
50

    
51
	return false;
52
}
53

    
54
if ($_POST['act'] == "del") {
55
	if (!isset($_POST['id'])) {
56
		$input_errors[] = gettext("Wrong parameters supplied");
57
	} else if (empty($a_vlans[$_POST['id']])) {
58
		$input_errors[] = gettext("Wrong index supplied");
59
	/* check if still in use */
60
	} else if (vlan_inuse($_POST['id'])) {
61
		$input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface.");
62
	} else {
63
		if (does_interface_exist($a_vlans[$_POST['id']]['vlanif'])) {
64
			pfSense_interface_destroy($a_vlans[$_POST['id']]['vlanif']);
65
		}
66
		unset($a_vlans[$_POST['id']]);
67

    
68
		write_config();
69

    
70
		header("Location: interfaces_vlan.php");
71
		exit;
72
	}
73
}
74

    
75

    
76
$pgtitle = array(gettext("Interfaces"), gettext("VLANs"));
77
$shortcut_section = "interfaces";
78
include('head.inc');
79

    
80
if ($input_errors) print_input_errors($input_errors);
81

    
82
$tab_array = array();
83
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
84
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
85
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
86
$tab_array[] = array(gettext("VLANs"), true, "interfaces_vlan.php");
87
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
88
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
89
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
90
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
91
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
92
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
93
display_top_tabs($tab_array);
94

    
95
?>
96
<form action="interfaces_vlan.php" method="post">
97
	<input id="act" type="hidden" name="act" value="" />
98
	<input id="id" type="hidden" name="id" value=""/>
99

    
100
	<div class="panel panel-default">
101
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('VLAN Interfaces')?></h2></div>
102
		<div class="panel-body">
103
			<div class="table-responsive">
104
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
105
					<thead>
106
						<tr>
107
							<th><?=gettext('Interface');?></th>
108
							<th><?=gettext('VLAN tag');?></th>
109
							<th><?=gettext('Priority');?></th>
110
							<th><?=gettext('Description');?></th>
111
							<th><?=gettext('Actions');?></th>
112
						</tr>
113
					</thead>
114
					<tbody>
115
<?php
116
	$i = 0;
117
	foreach ($a_vlans as $vlan) {
118
?>
119
						<tr>
120
							<td>
121
<?php
122
	printf("%s", htmlspecialchars($vlan['if']));
123
	$iface = convert_real_interface_to_friendly_interface_name($vlan['if']);
124
	if (isset($iface) && strlen($iface) > 0)
125
		printf(" (%s)", htmlspecialchars($iface));
126
?>
127
							</td>
128
							<td><?=htmlspecialchars($vlan['tag']);?></td>
129
							<td><?=htmlspecialchars($vlan['pcp']);?></td>
130
							<td><?=htmlspecialchars($vlan['descr']);?></td>
131
							<td>
132
								<a class="fa fa-pencil"	title="<?=gettext('Edit VLAN')?>"	role="button" href="interfaces_vlan_edit.php?id=<?=$i?>" ></a>
133
								<a class="fa fa-trash no-confirm"	title="<?=gettext('Delete VLAN')?>"	role="button" id="del-<?=$i?>"></a>
134
							</td>
135
						</tr>
136
<?php
137
			$i++;
138
	}
139
?>
140
					</tbody>
141
				</table>
142
			</div>
143
		</div>
144
	</div>
145

    
146
	<nav class="action-buttons">
147
		<a class="btn btn-success btn-sm" role="button" href="interfaces_vlan_edit.php">
148
			<i class="fa fa-plus icon-embed-btn"></i>
149
			<?=gettext('Add'); ?>
150
		</a>
151
	</nav>
152

    
153
</form>
154

    
155
<div class="infoblock">
156
	<?php print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q '.
157
		'VLAN tagging properly. %1$sOn cards that do not explicitly support it, VLAN '.
158
		'tagging will still work, but the reduced MTU may cause problems.%1$sSee the '.
159
		'%2$s handbook for information on supported cards.'), '<br />', $g['product_name']), 'info', false); ?>
160
</div>
161

    
162
<?php
163
	$delmsg = gettext("Are you sure you want to delete this VLAN?");
164
?>
165

    
166
<script type="text/javascript">
167
//<![CDATA[
168
events.push(function() {
169
	// Select 'delete button' clicks, extract the id, set the hidden input values and submit
170
	$('[id^=del-]').click(function(event) {
171
		if (confirm("<?=$delmsg?>")) {
172
			$('#act').val('del');
173
			$('#id').val(this.id.replace("del-", ""));
174
			$(this).parents('form').submit();
175
		}
176
	});
177

    
178
});
179
//]]>
180
</script>
181
<?php
182
include("foot.inc");
(81-81/223)