Project

General

Profile

Download (5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * interfaces_qinq.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
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21

    
22
##|+PRIV
23
##|*IDENT=page-interfaces-qinq
24
##|*NAME=Interfaces: QinQ
25
##|*DESCR=Allow access to the 'Interfaces: QinQ' page.
26
##|*MATCH=interfaces_qinq.php*
27
##|-PRIV
28

    
29
require_once("guiconfig.inc");
30
require_once("functions.inc");
31

    
32
if (!is_array($config['qinqs']['qinqentry'])) {
33
	$config['qinqs']['qinqentry'] = array();
34
}
35

    
36
$a_qinqs = &$config['qinqs']['qinqentry'];
37

    
38
function qinq_inuse($num) {
39
	global $config, $a_qinqs;
40

    
41
	$iflist = get_configured_interface_list(false, true);
42
	foreach ($iflist as $if) {
43
		if ($config['interfaces'][$if]['if'] == $a_qinqs[$num]['qinqif']) {
44
			return true;
45
		}
46
	}
47

    
48
	return false;
49
}
50

    
51
if ($_GET['act'] == "del") {
52
	$id = $_GET['id'];
53

    
54
	/* check if still in use */
55
	if (qinq_inuse($id)) {
56
		$input_errors[] = gettext("This QinQ cannot be deleted because it is still being used as an interface.");
57
	} elseif (empty($a_qinqs[$id]['vlanif']) || !does_interface_exist($a_qinqs[$id]['vlanif'])) {
58
		$input_errors[] = gettext("QinQ interface does not exist");
59
	} else {
60
		$qinq =& $a_qinqs[$id];
61

    
62
		$delmembers = explode(" ", $qinq['members']);
63
		if (count($delmembers) > 0) {
64
			foreach ($delmembers as $tag) {
65
				mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}h{$tag}:");
66
			}
67
		}
68
		mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}qinq:");
69
		mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}:");
70
		pfSense_interface_destroy($qinq['vlanif']);
71
		unset($a_qinqs[$id]);
72

    
73
		write_config();
74

    
75
		header("Location: interfaces_qinq.php");
76
		exit;
77
	}
78
}
79

    
80
$pgtitle = array(gettext("Interfaces"), gettext("QinQs"));
81
$shortcut_section = "interfaces";
82
include("head.inc");
83

    
84
if ($input_errors) {
85
	print_input_errors($input_errors);
86
}
87

    
88
$tab_array = array();
89
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
90
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
91
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
92
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
93
$tab_array[] = array(gettext("QinQs"), true, "interfaces_qinq.php");
94
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
95
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
96
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
97
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
98
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
99
display_top_tabs($tab_array);
100

    
101
?>
102
<div class="panel panel-default">
103
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('QinQ Interfaces')?></h2></div>
104
	<div class="panel-body">
105
		<div class="table-responsive">
106
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
107
				<thead>
108
					<tr>
109
						<th><?=gettext("Interface"); ?></th>
110
						<th><?=gettext("Tag");?></th>
111
						<th><?=gettext("QinQ members"); ?></th>
112
						<th><?=gettext("Description"); ?></th>
113
						<th><?=gettext("Actions"); ?></th>
114
					</tr>
115
				</thead>
116
				<tbody>
117
<?php foreach ($a_qinqs as $i => $qinq):?>
118
					<tr>
119
						<td>
120
							<?=htmlspecialchars($qinq['if'])?>
121
						</td>
122
						<td>
123
							<?=htmlspecialchars($qinq['tag'])?>
124
						</td>
125
						<td>
126
<?php if (strlen($qinq['members']) > 20):?>
127
							<?=substr(htmlspecialchars($qinq['members']), 0, 20)?>&hellip;
128
<?php else:?>
129
							<?=htmlspecialchars($qinq['members'])?>
130
<?php endif; ?>
131
						</td>
132
						<td>
133
							<?=htmlspecialchars($qinq['descr'])?>&nbsp;
134
						</td>
135
						<td>
136
							<a class="fa fa-pencil"	title="<?=gettext('Edit Q-in-Q interface')?>"	href="interfaces_qinq_edit.php?id=<?=$i?>"></a>
137
							<a class="fa fa-trash"	title="<?=gettext('Delete Q-in-Q interface')?>"	href="interfaces_qinq.php?act=del&amp;id=<?=$i?>"></a>
138
						</td>
139
					</tr>
140
<?php
141
endforeach;
142
?>
143
				</tbody>
144
			</table>
145
		</div>
146
	</div>
147
</div>
148

    
149
<nav class="action-buttons">
150
	<a href="interfaces_qinq_edit.php" class="btn btn-success btn-sm">
151
		<i class="fa fa-plus icon-embed-btn"></i>
152
		<?=gettext("Add")?>
153
	</a>
154
</nav>
155

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

    
162
<?php
163
include("foot.inc");
(81-81/225)