Project

General

Profile

Download (5.46 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_new_prof.php*
31
##|-PRIV
32

    
33
require_once("guiconfig.inc");
34
require_once("interfaces_fast.inc");
35

    
36
global $profile;
37

    
38
if (!is_array($config['vlans']['vlan'])) {
39
	$config['vlans']['vlan'] = array();
40
}
41

    
42
$a_vlans = &$config['vlans']['vlan'] ;
43

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

    
58
		write_config();
59

    
60
		header("Location: interfaces_vlan.php");
61
		exit;
62
	}
63
}
64

    
65

    
66
$pgtitle = array(gettext("Interfaces"), gettext("VLANs"));
67
$shortcut_section = "interfaces";
68
include('head.inc');
69

    
70
if ($input_errors) print_input_errors($input_errors);
71

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

    
85
?>
86
<form action="interfaces_vlan.php" method="post">
87
	<input id="act" type="hidden" name="act" value="" />
88
	<input id="id" type="hidden" name="id" value=""/>
89

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

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

    
144
</form>
145

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

    
153
<?php
154
	$delmsg = gettext("Are you sure you want to delete this VLAN?");
155
?>
156

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

    
169
});
170
//]]>
171
</script>
172
<?php
173
include("foot.inc");
(87-87/232)