Project

General

Profile

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