Project

General

Profile

Download (6.46 KB) Statistics
| Branch: | Tag: | Revision:
1 b991e3b5 Ermal Lu?i
<?php
2
/* $Id$ */
3
/*
4
	interfaces_qinq.php
5 4b653c44 Ermal Lu?i
	Copyright (C) 2009 Ermal Luçi
6 b991e3b5 Ermal Lu?i
	All rights reserved.
7
8
	Redistribution and use in source and binary forms, with or without
9
	modification, 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 the
16
	   documentation and/or other materials provided with the distribution.
17
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29 7ac5a4cb Scott Ullrich
/*
30 62f8244b Renato Botelho
	pfSense_BUILDER_BINARIES:	/usr/sbin/ngctl
31 7ac5a4cb Scott Ullrich
	pfSense_MODULE:	interfaces
32
*/
33 b991e3b5 Ermal Lu?i
34
##|+PRIV
35
##|*IDENT=page-interfaces-qinq
36
##|*NAME=Interfaces: QinQ page
37
##|*DESCR=Allow access to the 'Interfaces: QinQ' page.
38
##|*MATCH=interfaces_qinq.php*
39
##|-PRIV
40
41
require("guiconfig.inc");
42 347ec09e Carlos Eduardo Ramos
require_once("functions.inc");
43 b991e3b5 Ermal Lu?i
44
if (!is_array($config['qinqs']['qinqentry']))
45
	$config['qinqs']['qinqentry'] = array();
46
47
$a_qinqs = &$config['qinqs']['qinqentry'];
48
49
function qinq_inuse($num) {
50 c059940b Erik Fonnesbeck
	global $config, $a_qinqs;
51 b991e3b5 Ermal Lu?i
52
	$iflist = get_configured_interface_list(false, true);
53
	foreach ($iflist as $if) {
54
		if ($config['interfaces'][$if]['if'] == $a_qinqs[$num]['qinqif'])
55
			return true;
56
	}
57
58
	return false;
59
}
60
61
if ($_GET['act'] == "del") {
62 eea7eb99 Renato Botelho
	$id = $_GET['id'];
63
64 b991e3b5 Ermal Lu?i
	/* check if still in use */
65 eea7eb99 Renato Botelho
	if (qinq_inuse($id)) {
66 a11b9585 Rafael Lucas
		$input_errors[] = gettext("This QinQ cannot be deleted because it is still being used as an interface.");
67 eea7eb99 Renato Botelho
	} elseif (empty($a_qinqs[$id]['vlanif']) || !does_interface_exist($a_qinqs[$id]['vlanif'])) {
68
		$input_errors[] = gettext("QinQ interface does not exist");
69 b991e3b5 Ermal Lu?i
	} else {
70
		$qinq =& $a_qinqs[$id];
71
72
		$delmembers = explode(" ", $qinq['members']);
73 62f8244b Renato Botelho
		if (count($delmembers) > 0) {
74 b991e3b5 Ermal Lu?i
			foreach ($delmembers as $tag)
75 4400ad66 Ermal Lu?i
				mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}h{$tag}:");
76 62f8244b Renato Botelho
		}
77 4400ad66 Ermal Lu?i
		mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}qinq:");
78
		mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}:");
79 9cf46050 Ermal
		mwexec("/sbin/ifconfig {$qinq['vlanif']} destroy");
80 b991e3b5 Ermal Lu?i
		unset($a_qinqs[$id]);
81
82
		write_config();
83
84
		header("Location: interfaces_qinq.php");
85
		exit;
86
	}
87
}
88
89 a11b9585 Rafael Lucas
$pgtitle = array(gettext("Interfaces"),gettext("QinQ"));
90 b32dd0a6 jim-p
$shortcut_section = "interfaces";
91 b991e3b5 Ermal Lu?i
include("head.inc");
92
93
?>
94
95
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
96
<?php include("fbegin.inc"); ?>
97
<?php if ($input_errors) print_input_errors($input_errors); ?>
98
<table width="100%" border="0" cellpadding="0" cellspacing="0">
99
  <tr><td>
100
<?php
101
	$tab_array = array();
102 a11b9585 Rafael Lucas
	$tab_array[0] = array(gettext("Interface assignments"), false, "interfaces_assign.php");
103
	$tab_array[1] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
104
	$tab_array[2] = array(gettext("Wireless"), false, "interfaces_wireless.php");
105
	$tab_array[3] = array(gettext("VLANs"), false, "interfaces_vlan.php");
106
	$tab_array[4] = array(gettext("QinQs"), true, "interfaces_qinq.php");
107
	$tab_array[5] = array(gettext("PPPs"), false, "interfaces_ppps.php");
108
	$tab_array[6] = array(gettext("GRE"), false, "interfaces_gre.php");
109
	$tab_array[7] = array(gettext("GIF"), false, "interfaces_gif.php");
110
	$tab_array[8] = array(gettext("Bridges"), false, "interfaces_bridge.php");
111
	$tab_array[9] = array(gettext("LAGG"), false, "interfaces_lagg.php");
112 b991e3b5 Ermal Lu?i
	display_top_tabs($tab_array);
113
?>
114
  </td></tr>
115
  <tr>
116
    <td>
117
	<div id="mainarea">
118
	<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
119
                <tr>
120 a11b9585 Rafael Lucas
                  <td width="15%" class="listhdrr"><?=gettext("Interface");?></td>
121
                  <td width="10%" class="listhdrr"><?=gettext("Tag");?></td>
122
                  <td width="20%" class="listhdrr"><?=gettext("QinQ members");?></td>
123
                  <td width="45%" class="listhdr"><?=gettext("Description");?></td>
124 b991e3b5 Ermal Lu?i
                  <td width="10%" class="list"></td>
125
				</tr>
126
			  <?php $i = 0; foreach ($a_qinqs as $qinq): ?>
127 fd22be34 Ermal Lu?i
                <tr  ondblclick="document.location='interfaces_qinq_edit.php?id=<?=$i;?>'">
128 b991e3b5 Ermal Lu?i
                  <td class="listlr">
129
					<?=htmlspecialchars($qinq['if']);?>
130
                  </td>
131
		  <td class="listlr">
132
					<?=htmlspecialchars($qinq['tag']);?>
133
		  </td>
134
                  <td class="listr">
135 a5adbd09 Ermal Lu?i
					<?php
136
					if (strlen($qinq['members']) > 20)
137 4400ad66 Ermal Lu?i
						echo substr(htmlspecialchars($qinq['members']), 0, 20) . "...";
138 a5adbd09 Ermal Lu?i
					else
139
						echo htmlspecialchars($qinq['members']);
140
					?>
141 b991e3b5 Ermal Lu?i
                  </td>
142
                  <td class="listbg">
143
                    <?=htmlspecialchars($qinq['descr']);?>&nbsp;
144
                  </td>
145
                  <td valign="middle" nowrap class="list"> <a href="interfaces_qinq_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
146 5daab314 Vinicius Coque
                     &nbsp;<a href="interfaces_qinq.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this QinQ?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
147 b991e3b5 Ermal Lu?i
				</tr>
148
			  <?php $i++; endforeach; ?>
149
                <tr>
150
                  <td class="list" colspan="4">&nbsp;</td>
151
                  <td class="list"> <a href="interfaces_qinq_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
152
				</tr>
153
				<tr>
154 abc16ee6 jim-p
				<td colspan="4" class="list"><p class="vexpl"><span class="red"><strong>
155 ad157b4c Vinicius Coque
				  <?=gettext("Note:");?><br>
156 b991e3b5 Ermal Lu?i
				  </strong></span>
157 1b42d9b6 Vinicius Coque
				  <?php printf(gettext("Not all drivers/NICs support 802.1Q QinQ tagging properly. On cards that do not explicitly support it, QinQ tagging will still work, but the reduced MTU may cause problems. See the %s handbook for information on supported cards."), $g['product_name']);?></p>
158 b991e3b5 Ermal Lu?i
				  </td>
159
				<td class="list">&nbsp;</td>
160
				</tr>
161
              </table>
162
	      </div>
163
	</td>
164
	</tr>
165
</table>
166
<?php include("fend.inc"); ?>
167
</body>
168
</html>