Project

General

Profile

Download (6.5 KB) Statistics
| Branch: | Tag: | Revision:
1 de4a1c84 Colin Fleming
<?php
2 b991e3b5 Ermal Lu?i
/* $Id$ */
3 b9043cdc Stephen Beaver
/* ====================================================================
4
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
5
 *
6
 *	Redistribution and use in source and binary forms, with or without modification,
7
 *	are permitted provided that the following conditions are met:
8
 *
9
 *	1. Redistributions of source code must retain the above copyright notice,
10
 *		this list of conditions and the following disclaimer.
11
 *
12
 *	2. Redistributions in binary form must reproduce the above copyright
13
 *		notice, this list of conditions and the following disclaimer in
14
 *		the documentation and/or other materials provided with the
15
 *		distribution.
16
 *
17
 *	3. All advertising materials mentioning features or use of this software
18
 *		must display the following acknowledgment:
19
 *		"This product includes software developed by the pfSense Project
20
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
21
 *
22
 *	4. The names "pfSense" and "pfSense Project" must not be used to
23
 *		 endorse or promote products derived from this software without
24
 *		 prior written permission. For written permission, please contact
25
 *		 coreteam@pfsense.org.
26
 *
27
 *	5. Products derived from this software may not be called "pfSense"
28
 *		nor may "pfSense" appear in their names without prior written
29
 *		permission of the Electric Sheep Fencing, LLC.
30
 *
31
 *	6. Redistributions of any form whatsoever must retain the following
32
 *		acknowledgment:
33
 *
34
 *	"This product includes software developed by the pfSense Project
35
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
36
 *
37
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
38
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
41
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
49
 *
50
 *	====================================================================
51
 *
52
 */
53 7ac5a4cb Scott Ullrich
/*
54 62f8244b Renato Botelho
	pfSense_BUILDER_BINARIES:	/usr/sbin/ngctl
55 b104d092 sbeaver
	pfSense_MODULE: interfaces
56 7ac5a4cb Scott Ullrich
*/
57 b991e3b5 Ermal Lu?i
58
##|+PRIV
59
##|*IDENT=page-interfaces-qinq
60
##|*NAME=Interfaces: QinQ page
61
##|*DESCR=Allow access to the 'Interfaces: QinQ' page.
62
##|*MATCH=interfaces_qinq.php*
63
##|-PRIV
64
65
require("guiconfig.inc");
66 347ec09e Carlos Eduardo Ramos
require_once("functions.inc");
67 b991e3b5 Ermal Lu?i
68 2af86dda Phil Davis
if (!is_array($config['qinqs']['qinqentry'])) {
69 b991e3b5 Ermal Lu?i
	$config['qinqs']['qinqentry'] = array();
70 2af86dda Phil Davis
}
71 b991e3b5 Ermal Lu?i
72
$a_qinqs = &$config['qinqs']['qinqentry'];
73
74
function qinq_inuse($num) {
75 c059940b Erik Fonnesbeck
	global $config, $a_qinqs;
76 b991e3b5 Ermal Lu?i
77
	$iflist = get_configured_interface_list(false, true);
78
	foreach ($iflist as $if) {
79 2af86dda Phil Davis
		if ($config['interfaces'][$if]['if'] == $a_qinqs[$num]['qinqif']) {
80 b991e3b5 Ermal Lu?i
			return true;
81 2af86dda Phil Davis
		}
82 b991e3b5 Ermal Lu?i
	}
83
84
	return false;
85
}
86
87
if ($_GET['act'] == "del") {
88 eea7eb99 Renato Botelho
	$id = $_GET['id'];
89
90 b991e3b5 Ermal Lu?i
	/* check if still in use */
91 eea7eb99 Renato Botelho
	if (qinq_inuse($id)) {
92 a11b9585 Rafael Lucas
		$input_errors[] = gettext("This QinQ cannot be deleted because it is still being used as an interface.");
93 eea7eb99 Renato Botelho
	} elseif (empty($a_qinqs[$id]['vlanif']) || !does_interface_exist($a_qinqs[$id]['vlanif'])) {
94
		$input_errors[] = gettext("QinQ interface does not exist");
95 b991e3b5 Ermal Lu?i
	} else {
96
		$qinq =& $a_qinqs[$id];
97
98
		$delmembers = explode(" ", $qinq['members']);
99 62f8244b Renato Botelho
		if (count($delmembers) > 0) {
100 2af86dda Phil Davis
			foreach ($delmembers as $tag) {
101 4400ad66 Ermal Lu?i
				mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}h{$tag}:");
102 2af86dda Phil Davis
			}
103 62f8244b Renato Botelho
		}
104 4400ad66 Ermal Lu?i
		mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}qinq:");
105
		mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}:");
106 9cf46050 Ermal
		mwexec("/sbin/ifconfig {$qinq['vlanif']} destroy");
107 b991e3b5 Ermal Lu?i
		unset($a_qinqs[$id]);
108
109
		write_config();
110
111
		header("Location: interfaces_qinq.php");
112
		exit;
113
	}
114
}
115
116 6c07db48 Phil Davis
$pgtitle = array(gettext("Interfaces"), gettext("QinQ"));
117 b32dd0a6 jim-p
$shortcut_section = "interfaces";
118 b991e3b5 Ermal Lu?i
include("head.inc");
119
120 ff846cb9 Sjon Hortensius
if ($input_errors)
121
	print_input_errors($input_errors);
122
123 b104d092 sbeaver
$tab_array = array();
124 ff846cb9 Sjon Hortensius
$tab_array[] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
125
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
126
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
127
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
128
$tab_array[] = array(gettext("QinQs"), true, "interfaces_qinq.php");
129
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
130
$tab_array[] = array(gettext("GRE"), false, "interfaces_gre.php");
131
$tab_array[] = array(gettext("GIF"), false, "interfaces_gif.php");
132
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
133
$tab_array[] = array(gettext("LAGG"), false, "interfaces_lagg.php");
134 b104d092 sbeaver
display_top_tabs($tab_array);
135
136 b991e3b5 Ermal Lu?i
?>
137 b104d092 sbeaver
<div class="table-responsive">
138
	<table class="table table-striped table-hover table-condensed">
139
		<thead>
140
			<tr>
141
			  <th><?=gettext("Interface"); ?></th>
142
			  <th><?=gettext("Tag");?></td>
143
			  <th><?=gettext("QinQ members"); ?></th>
144
			  <th><?=gettext("Description"); ?></th>
145
			  <th></th>
146
			</tr>
147
		</thead>
148
		<tbody>
149 ff846cb9 Sjon Hortensius
<?php foreach ($a_qinqs as $i => $qinq):?>
150
			<tr>
151 b104d092 sbeaver
				<td>
152
					<?=htmlspecialchars($qinq['if'])?>
153
				</td>
154
				<td>
155
					<?=htmlspecialchars($qinq['tag'])?>
156
				</td>
157
				<td>
158 ff846cb9 Sjon Hortensius
<?php if (strlen($qinq['members']) > 20):?>
159
					<?=substr(htmlspecialchars($qinq['members']), 0, 20)?>&hellip;
160
<?php else:?>
161 b104d092 sbeaver
					<?=htmlspecialchars($qinq['members'])?>
162 ff846cb9 Sjon Hortensius
<?php endif; ?>
163 b104d092 sbeaver
				</td>
164 ff846cb9 Sjon Hortensius
				<td>
165 b104d092 sbeaver
					<?=htmlspecialchars($qinq['descr'])?>&nbsp;
166
				</td>
167
				<td>
168 8d141eec heper
					<a class="fa fa-pencil"	title="<?=gettext('Edit Q-in-Q interface')?>"	href="interfaces_qinq_edit.php?id=<?=$i?>"></a>
169 33f0b0d5 Stephen Beaver
					<a class="fa fa-trash"	title="<?=gettext('Delete Q-in-Q interface')?>"	href="interfaces_qinq.php?act=del&amp;id=<?=$i?>"></a>
170 b104d092 sbeaver
				</td>
171
			</tr>
172
<?php
173 c72237ee Sjon Hortensius
endforeach;
174 b104d092 sbeaver
?>
175
		</tbody>
176
	</table>
177
</div>
178 ff846cb9 Sjon Hortensius
179 c10cb196 Stephen Beaver
<nav class="action-buttons">
180 2ec8f0ba Stephen Beaver
	<a href="interfaces_qinq_edit.php" class="btn btn-success btn-sm">
181 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
182 ff846cb9 Sjon Hortensius
		<?=gettext("Add")?>
183
	</a>
184
</nav>
185 2ec8f0ba Stephen Beaver
186
<div id="infoblock">
187
	<?=print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q QinQ tagging properly. <br />On cards that do not explicitly support it, ' .
188
		'QinQ tagging will still work, but the reduced MTU may cause problems.<br />' .
189
		'See the %s handbook for information on supported cards.'), $g['product_name']), info)?>
190
</div>
191
192 b104d092 sbeaver
<?php
193 de4a1c84 Colin Fleming
include("foot.inc");