Project

General

Profile

Download (5.72 KB) Statistics
| Branch: | Tag: | Revision:
1 de4a1c84 Colin Fleming
<?php
2 919d91f9 Phil Davis
/*
3 c5d81585 Renato Botelho
 * interfaces_qinq.php
4 b9043cdc Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8 a68f7a3d Luiz Otavio O Souza
 * Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
9 c5d81585 Renato Botelho
 * All rights reserved.
10 b9043cdc Stephen Beaver
 *
11 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14 b9043cdc Stephen Beaver
 *
15 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
16 b9043cdc Stephen Beaver
 *
17 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22 b9043cdc Stephen Beaver
 */
23 b991e3b5 Ermal Lu?i
24
##|+PRIV
25
##|*IDENT=page-interfaces-qinq
26 5230f468 jim-p
##|*NAME=Interfaces: QinQ
27 b991e3b5 Ermal Lu?i
##|*DESCR=Allow access to the 'Interfaces: QinQ' page.
28
##|*MATCH=interfaces_qinq.php*
29
##|-PRIV
30
31 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
32 347ec09e Carlos Eduardo Ramos
require_once("functions.inc");
33 b991e3b5 Ermal Lu?i
34 63d6bb4f Marcos Mendoza
config_init_path('qinqs/qinqentry');
35 b991e3b5 Ermal Lu?i
36 87b458b5 Steve Beaver
if ($_POST['act'] == "del") {
37 4cd7b4b4 Marcos Mendoza
	$id = is_numericint($_POST['id']) ? $_POST['id'] : null;
38 eea7eb99 Renato Botelho
39 68ed2891 jim-p
	/*
40
	 * Check user privileges to test if the user is allowed to make changes.
41
	 * Otherwise users can end up in an inconsistent state where some changes are
42
	 * performed and others denied. See https://redmine.pfsense.org/issues/15318
43
	 */
44
	phpsession_begin();
45
	$guiuser = getUserEntry($_SESSION['Username']);
46
	$read_only = (is_array($guiuser) && userHasPrivilege($guiuser, "user-config-readonly"));
47
	phpsession_end();
48
49
	if ($read_only) {
50
		$input_errors = array(gettext("Insufficient privileges to make the requested change (read only)."));
51
	}
52
53 63d6bb4f Marcos Mendoza
	$this_qinq_config = config_get_path("qinqs/qinqentry/{$id}");
54 b991e3b5 Ermal Lu?i
	/* check if still in use */
55 63d6bb4f Marcos Mendoza
	if ((config_get_path('qinqs/qinqentry') !== null) && vlan_inuse($this_qinq_config)) {
56 a11b9585 Rafael Lucas
		$input_errors[] = gettext("This QinQ cannot be deleted because it is still being used as an interface.");
57 63d6bb4f Marcos Mendoza
	} elseif (empty($this_qinq_config['vlanif']) || !does_interface_exist($this_qinq_config['vlanif'])) {
58 eea7eb99 Renato Botelho
		$input_errors[] = gettext("QinQ interface does not exist");
59 b991e3b5 Ermal Lu?i
	} else {
60 63d6bb4f Marcos Mendoza
		$delmembers = explode(" ", $this_qinq_config['members']);
61 0793de1a Luiz Souza
		foreach ($delmembers as $tag) {
62 63d6bb4f Marcos Mendoza
			if (qinq_inuse($this_qinq_config, $tag)) {
63 0793de1a Luiz Souza
				$input_errors[] = gettext("This QinQ cannot be deleted because one of it tags is still being used as an interface.");
64
				break;
65 2af86dda Phil Davis
			}
66 62f8244b Renato Botelho
		}
67 0793de1a Luiz Souza
	}
68
69
	if (empty($input_errors)) {
70 63d6bb4f Marcos Mendoza
		$delmembers = explode(" ", $this_qinq_config['members']);
71 0793de1a Luiz Souza
		foreach ($delmembers as $tag) {
72 63d6bb4f Marcos Mendoza
			exec("/sbin/ifconfig {$this_qinq_config['vlanif']}.{$tag} destroy");
73 0793de1a Luiz Souza
		}
74 63d6bb4f Marcos Mendoza
		pfSense_interface_destroy($this_qinq_config['vlanif']);
75
		config_del_path("qinqs/qinqentry/{$id}");
76 b991e3b5 Ermal Lu?i
77 e85ae672 Renato Botelho do Couto
		write_config("QinQ interface deleted");
78 b991e3b5 Ermal Lu?i
79
		header("Location: interfaces_qinq.php");
80
		exit;
81
	}
82
}
83
84 26b4bef8 k-paulius
$pgtitle = array(gettext("Interfaces"), gettext("QinQs"));
85 b32dd0a6 jim-p
$shortcut_section = "interfaces";
86 b991e3b5 Ermal Lu?i
include("head.inc");
87
88 aa82505e Phil Davis
if ($input_errors) {
89 ff846cb9 Sjon Hortensius
	print_input_errors($input_errors);
90 aa82505e Phil Davis
}
91 ff846cb9 Sjon Hortensius
92 b104d092 sbeaver
$tab_array = array();
93 26b4bef8 k-paulius
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
94 ff846cb9 Sjon Hortensius
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
95
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
96
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
97
$tab_array[] = array(gettext("QinQs"), true, "interfaces_qinq.php");
98
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
99 26b4bef8 k-paulius
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
100
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
101 ff846cb9 Sjon Hortensius
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
102 26b4bef8 k-paulius
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
103 b104d092 sbeaver
display_top_tabs($tab_array);
104
105 b991e3b5 Ermal Lu?i
?>
106 060ed238 Stephen Beaver
<div class="panel panel-default">
107 70dc5cd6 Phil Davis
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('QinQ Interfaces')?></h2></div>
108 060ed238 Stephen Beaver
	<div class="panel-body">
109
		<div class="table-responsive">
110 1c10ce97 PiBa-NL
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
111 060ed238 Stephen Beaver
				<thead>
112
					<tr>
113 70dc5cd6 Phil Davis
						<th><?=gettext("Interface"); ?></th>
114 edb85ffd Renato Botelho
						<th><?=gettext("Tag");?></th>
115 70dc5cd6 Phil Davis
						<th><?=gettext("QinQ members"); ?></th>
116
						<th><?=gettext("Description"); ?></th>
117
						<th><?=gettext("Actions"); ?></th>
118 060ed238 Stephen Beaver
					</tr>
119
				</thead>
120
				<tbody>
121 4b9165e5 Marcos Mendoza
<?php foreach (config_get_path('qinqs/qinqentry', []) as $i => $qinq):?>
122 060ed238 Stephen Beaver
					<tr>
123
						<td>
124
							<?=htmlspecialchars($qinq['if'])?>
125
						</td>
126
						<td>
127
							<?=htmlspecialchars($qinq['tag'])?>
128
						</td>
129
						<td>
130 ff846cb9 Sjon Hortensius
<?php if (strlen($qinq['members']) > 20):?>
131 060ed238 Stephen Beaver
							<?=substr(htmlspecialchars($qinq['members']), 0, 20)?>&hellip;
132 ff846cb9 Sjon Hortensius
<?php else:?>
133 060ed238 Stephen Beaver
							<?=htmlspecialchars($qinq['members'])?>
134 ff846cb9 Sjon Hortensius
<?php endif; ?>
135 060ed238 Stephen Beaver
						</td>
136
						<td>
137
							<?=htmlspecialchars($qinq['descr'])?>&nbsp;
138
						</td>
139
						<td>
140 e0cb987c Marcos Mendoza
							<a class="fa-solid fa-pencil"	title="<?=gettext('Edit Q-in-Q interface')?>"	href="interfaces_qinq_edit.php?id=<?=$i?>"></a>
141 c1d304b3 Marcos Mendoza
							<a class="fa-solid fa-trash-can"	title="<?=gettext('Delete Q-in-Q interface')?>"	href="interfaces_qinq.php?act=del&amp;id=<?=$i?>" usepost></a>
142 060ed238 Stephen Beaver
						</td>
143
					</tr>
144 b104d092 sbeaver
<?php
145 c72237ee Sjon Hortensius
endforeach;
146 b104d092 sbeaver
?>
147 060ed238 Stephen Beaver
				</tbody>
148
			</table>
149
		</div>
150
	</div>
151 b104d092 sbeaver
</div>
152 ff846cb9 Sjon Hortensius
153 c10cb196 Stephen Beaver
<nav class="action-buttons">
154 4401107f Steve Beaver
	<a href="interfaces_qinq_edit.php" class="btn btn-success btn-sm">
155 e0cb987c Marcos Mendoza
		<i class="fa-solid fa-plus icon-embed-btn"></i>
156 ff846cb9 Sjon Hortensius
		<?=gettext("Add")?>
157
	</a>
158
</nav>
159 2ec8f0ba Stephen Beaver
160 35681930 Stephen Beaver
<div class="infoblock">
161 7ae1b34f Phil Davis
	<?php print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q QinQ tagging properly. %1$sOn cards that do not explicitly support it, ' .
162
		'QinQ tagging will still work, but the reduced MTU may cause problems.%1$s' .
163 2568e151 Christian McDonald
		'See the %2$s handbook for information on supported cards.'), '<br />', g_get('product_label')), 'info', false); ?>
164 2ec8f0ba Stephen Beaver
</div>
165
166 b104d092 sbeaver
<?php
167 de4a1c84 Colin Fleming
include("foot.inc");