Project

General

Profile

Download (5.29 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces_qinq.php
5
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6
	Copyright (C) 2009 Ermal Luçi
7
	All rights reserved.
8

    
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11

    
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14

    
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18

    
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30
/*
31
	pfSense_BUILDER_BINARIES:	/usr/sbin/ngctl
32
	pfSense_MODULE: interfaces
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-interfaces-qinq
37
##|*NAME=Interfaces: QinQ page
38
##|*DESCR=Allow access to the 'Interfaces: QinQ' page.
39
##|*MATCH=interfaces_qinq.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43
require_once("functions.inc");
44

    
45
if (!is_array($config['qinqs']['qinqentry'])) {
46
	$config['qinqs']['qinqentry'] = array();
47
}
48

    
49
$a_qinqs = &$config['qinqs']['qinqentry'];
50

    
51
function qinq_inuse($num) {
52
	global $config, $a_qinqs;
53

    
54
	$iflist = get_configured_interface_list(false, true);
55
	foreach ($iflist as $if) {
56
		if ($config['interfaces'][$if]['if'] == $a_qinqs[$num]['qinqif']) {
57
			return true;
58
		}
59
	}
60

    
61
	return false;
62
}
63

    
64
if ($_GET['act'] == "del") {
65
	$id = $_GET['id'];
66

    
67
	/* check if still in use */
68
	if (qinq_inuse($id)) {
69
		$input_errors[] = gettext("This QinQ cannot be deleted because it is still being used as an interface.");
70
	} elseif (empty($a_qinqs[$id]['vlanif']) || !does_interface_exist($a_qinqs[$id]['vlanif'])) {
71
		$input_errors[] = gettext("QinQ interface does not exist");
72
	} else {
73
		$qinq =& $a_qinqs[$id];
74

    
75
		$delmembers = explode(" ", $qinq['members']);
76
		if (count($delmembers) > 0) {
77
			foreach ($delmembers as $tag) {
78
				mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}h{$tag}:");
79
			}
80
		}
81
		mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}qinq:");
82
		mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}:");
83
		mwexec("/sbin/ifconfig {$qinq['vlanif']} destroy");
84
		unset($a_qinqs[$id]);
85

    
86
		write_config();
87

    
88
		header("Location: interfaces_qinq.php");
89
		exit;
90
	}
91
}
92

    
93
$pgtitle = array(gettext("Interfaces"), gettext("QinQ"));
94
$shortcut_section = "interfaces";
95
include("head.inc");
96

    
97
if ($input_errors)
98
	print_input_errors($input_errors);
99

    
100
$tab_array = array();
101
$tab_array[] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
102
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
103
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
104
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
105
$tab_array[] = array(gettext("QinQs"), true, "interfaces_qinq.php");
106
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
107
$tab_array[] = array(gettext("GRE"), false, "interfaces_gre.php");
108
$tab_array[] = array(gettext("GIF"), false, "interfaces_gif.php");
109
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
110
$tab_array[] = array(gettext("LAGG"), false, "interfaces_lagg.php");
111
display_top_tabs($tab_array);
112

    
113
print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q QinQ tagging properly. <br />On cards that do not explicitly support it, ' .
114
							   'QinQ tagging will still work, but the reduced MTU may cause problems.<br />' .
115
							   'See the %s handbook for information on supported cards.'), $g['product_name']));
116

    
117
?>
118
<div class="table-responsive">
119
	<table class="table table-striped table-hover table-condensed">
120
		<thead>
121
			<tr>
122
			  <th><?=gettext("Interface"); ?></th>
123
			  <th><?=gettext("Tag");?></td>
124
			  <th><?=gettext("QinQ members"); ?></th>
125
			  <th><?=gettext("Description"); ?></th>
126
			  <th></th>
127
			</tr>
128
		</thead>
129
		<tbody>
130
<?php foreach ($a_qinqs as $i => $qinq):?>
131
			<tr>
132
				<td>
133
					<?=htmlspecialchars($qinq['if'])?>
134
				</td>
135
				<td>
136
					<?=htmlspecialchars($qinq['tag'])?>
137
				</td>
138
				<td>
139
<?php if (strlen($qinq['members']) > 20):?>
140
					<?=substr(htmlspecialchars($qinq['members']), 0, 20)?>&hellip;
141
<?php else:?>
142
					<?=htmlspecialchars($qinq['members'])?>
143
<?php endif; ?>
144
				</td>
145
				<td>
146
					<?=htmlspecialchars($qinq['descr'])?>&nbsp;
147
				</td>
148
				<td>
149
					<a href="interfaces_qinq_edit.php?id=<?=$i?>" class="btn btn-default btn-xs"><?=gettext("Edit")?></a>
150
					<a href="interfaces_qinq.php?act=del&amp;id=<?=$i?>" class="btn btn-danger btn-xs"><?=gettext("Delete")?></a>
151
				</td>
152
			</tr>
153
<?php
154
endforeach;
155
?>
156
		</tbody>
157
	</table>
158
</div>
159

    
160
<nav class="action-buttons">
161
	<a href="interfaces_qinq_edit.php" class="btn btn-success">
162
		<?=gettext("Add")?>
163
	</a>
164
</nav>
165
<?php
166
include("foot.inc");
(97-97/235)