Project

General

Profile

Download (5.27 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
if ($_POST['act'] == "del") {
42
	if (!isset($_POST['id'])) {
43
		$input_errors[] = gettext("Wrong parameters supplied");
44
	} else if (empty($a_vlans[$_POST['id']])) {
45
		$input_errors[] = gettext("Wrong index supplied");
46
	/* check if still in use */
47
	} else if (vlan_inuse($a_vlans[$_POST['id']])) {
48
		$input_errors[] = gettext("This VLAN cannot be deleted because it is still being used as an interface.");
49
	} else {
50
		if (does_interface_exist($a_vlans[$_POST['id']]['vlanif'])) {
51
			pfSense_interface_destroy($a_vlans[$_POST['id']]['vlanif']);
52
		}
53
		unset($a_vlans[$_POST['id']]);
54

    
55
		write_config();
56

    
57
		header("Location: interfaces_vlan.php");
58
		exit;
59
	}
60
}
61

    
62

    
63
$pgtitle = array(gettext("Interfaces"), gettext("VLANs"));
64
$shortcut_section = "interfaces";
65
include('head.inc');
66

    
67
if ($input_errors) print_input_errors($input_errors);
68

    
69
$tab_array = array();
70
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
71
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
72
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
73
$tab_array[] = array(gettext("VLANs"), true, "interfaces_vlan.php");
74
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
75
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
76
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
77
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
78
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
79
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
80
display_top_tabs($tab_array);
81

    
82
?>
83
<form action="interfaces_vlan.php" method="post">
84
	<input id="act" type="hidden" name="act" value="" />
85
	<input id="id" type="hidden" name="id" value=""/>
86

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

    
133
	<nav class="action-buttons">
134
		<a class="btn btn-success btn-sm" role="button" href="interfaces_vlan_edit.php">
135
			<i class="fa fa-plus icon-embed-btn"></i>
136
			<?=gettext('Add'); ?>
137
		</a>
138
	</nav>
139

    
140
</form>
141

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

    
149
<?php
150
	$delmsg = gettext("Are you sure you want to delete this VLAN?");
151
?>
152

    
153
<script type="text/javascript">
154
//<![CDATA[
155
events.push(function() {
156
	// Select 'delete button' clicks, extract the id, set the hidden input values and submit
157
	$('[id^=del-]').click(function(event) {
158
		if (confirm("<?=$delmsg?>")) {
159
			$('#act').val('del');
160
			$('#id').val(this.id.replace("del-", ""));
161
			$(this).parents('form').submit();
162
		}
163
	});
164

    
165
});
166
//]]>
167
</script>
168
<?php
169
include("foot.inc");
(87-87/231)