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-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * originally based on m0n0wall (http://m0n0.ch/wall)
12
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
 * All rights reserved.
14
 *
15
 * Licensed under the Apache License, Version 2.0 (the "License");
16
 * you may not use this file except in compliance with the License.
17
 * You may obtain a copy of the License at
18
 *
19
 * http://www.apache.org/licenses/LICENSE-2.0
20
 *
21
 * Unless required by applicable law or agreed to in writing, software
22
 * distributed under the License is distributed on an "AS IS" BASIS,
23
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
 * See the License for the specific language governing permissions and
25
 * limitations under the License.
26
 */
27

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

    
35
require_once("guiconfig.inc");
36
require_once("interfaces_fast.inc");
37

    
38
global $profile;
39

    
40
init_config_arr(array('vlans', 'vlan'));
41
$a_vlans = &$config['vlans']['vlan'];
42

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

    
57
		write_config();
58

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

    
64

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

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

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

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

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

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

    
143
</form>
144

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

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

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

    
168
});
169
//]]>
170
</script>
171
<?php
172
include("foot.inc");
(88-88/227)