Project

General

Profile

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