Project

General

Profile

Download (5.41 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-2019 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
require_once("interfaces_fast.inc");
35

    
36
global $profile;
37

    
38
init_config_arr(array('vlans', 'vlan'));
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
	$gettext_array = array('edit'=>gettext('Edit VLAN'),'del'=>gettext('Delete VLAN'));
105
	$ifaces = convert_real_interface_to_friendly_interface_name_fast(array());
106
	foreach ($a_vlans as $vlan) {
107
?>
108
						<tr>
109
							<td>
110
<?php
111
	printf("%s", htmlspecialchars($vlan['if']));
112
	if (isset($ifaces[$vlan['if']]) && strlen($ifaces[$vlan['if']]) > 0)
113
		printf(" (%s)", htmlspecialchars($ifaces[$vlan['if']]));
114
?>
115
							</td>
116
							<td><?=htmlspecialchars($vlan['tag']);?></td>
117
							<td><?=htmlspecialchars($vlan['pcp']);?></td>
118
							<td><?=htmlspecialchars($vlan['descr']);?></td>
119
							<td>
120
								<a class="fa fa-pencil"	title="<?=$gettext_array['edit']?>"	role="button" href="interfaces_vlan_edit.php?id=<?=$i?>" ></a>
121
								<a class="fa fa-trash no-confirm"	title="<?=$gettext_array['del']?>"	role="button" id="del-<?=$i?>"></a>
122
							</td>
123
						</tr>
124
<?php
125
			$i++;
126
	}
127
?>
128
					</tbody>
129
				</table>
130
			</div>
131
		</div>
132
	</div>
133

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

    
141
</form>
142

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

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

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

    
166
});
167
//]]>
168
</script>
169
<?php
170
include("foot.inc");
(88-88/235)