Project

General

Profile

Download (5.62 KB) Statistics
| Branch: | Tag: | Revision:
1 cae1695e Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	interfaces_vlan.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 cae1695e Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 cae1695e Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 cae1695e Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 cae1695e Scott Ullrich
16 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19 cae1695e Scott Ullrich
20 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32
require("guiconfig.inc");
33
34
if (!is_array($config['vlans']['vlan']))
35
	$config['vlans']['vlan'] = array();
36
37
$a_vlans = &$config['vlans']['vlan'] ;
38
39
function vlan_inuse($num) {
40
	global $config, $g;
41
42
	if ($config['interfaces']['lan']['if'] == "vlan{$num}")
43
		return true;
44
	if ($config['interfaces']['wan']['if'] == "vlan{$num}")
45
		return true;
46 cae1695e Scott Ullrich
47 5b237745 Scott Ullrich
	for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
48
		if ($config['interfaces']['opt' . $i]['if'] == "vlan{$num}")
49
			return true;
50
	}
51 cae1695e Scott Ullrich
52 5b237745 Scott Ullrich
	return false;
53
}
54
55
function renumber_vlan($if, $delvlan) {
56
	if (!preg_match("/^vlan/", $if))
57
		return $if;
58 cae1695e Scott Ullrich
59 5b237745 Scott Ullrich
	$vlan = substr($if, 4);
60
	if ($vlan > $delvlan)
61
		return "vlan" . ($vlan - 1);
62
	else
63
		return $if;
64
}
65
66
if ($_GET['act'] == "del") {
67
	/* check if still in use */
68
	if (vlan_inuse($_GET['id'])) {
69
		$input_errors[] = "This VLAN cannot be deleted because it is still being used as an interface.";
70
	} else {
71
		unset($a_vlans[$_GET['id']]);
72 cae1695e Scott Ullrich
73 5b237745 Scott Ullrich
		/* renumber all interfaces that use VLANs */
74
		$config['interfaces']['lan']['if'] = renumber_vlan($config['interfaces']['lan']['if'], $_GET['id']);
75
		$config['interfaces']['wan']['if'] = renumber_vlan($config['interfaces']['wan']['if'], $_GET['id']);
76
		for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++)
77
			$config['interfaces']['opt' . $i]['if'] = renumber_vlan($config['interfaces']['opt' . $i]['if'], $_GET['id']);
78 cae1695e Scott Ullrich
79 5b237745 Scott Ullrich
		write_config();
80 de068d0b Scott Ullrich
81
		interfaces_vlan_configure();
82
83 5b237745 Scott Ullrich
		header("Location: interfaces_vlan.php");
84
		exit;
85
	}
86
}
87
88 7f43ca88 Scott Ullrich
89
$pgtitle = "Interfaces: VLAN";
90
include("head.inc");
91
92 5b237745 Scott Ullrich
?>
93
94
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
95
<?php include("fbegin.inc"); ?>
96 931066a8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
97 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
98 f6f3b7e0 Chris Buechler
<?php if (file_exists("/tmp/vlanchanged")) { 
99
	print_info_box("VLAN configuration has changed.  WARNING: You may need to <a href='system_reboot.php'>reboot</a> for
100
		the changes to take effect.");
101
	mwexec("/bin/rm /tmp/vlanchanged");
102
}
103
?>
104 5b237745 Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">
105
  <tr><td>
106 c8b8ff69 Scott Ullrich
<?php
107
	$tab_array = array();
108 931066a8 Bill Marquette
	$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
109
	$tab_array[1] = array("VLANs", true, "interfaces_vlan.php");
110 c8b8ff69 Scott Ullrich
	display_top_tabs($tab_array);
111
?>
112 5b237745 Scott Ullrich
  </td></tr>
113 cae1695e Scott Ullrich
  <tr>
114 d732f186 Bill Marquette
    <td>
115
	<div id="mainarea">
116
	<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
117 5b237745 Scott Ullrich
                <tr>
118
                  <td width="20%" class="listhdrr">Interface</td>
119
                  <td width="20%" class="listhdrr">VLAN tag</td>
120
                  <td width="50%" class="listhdr">Description</td>
121
                  <td width="10%" class="list"></td>
122
				</tr>
123
			  <?php $i = 0; foreach ($a_vlans as $vlan): ?>
124
                <tr>
125
                  <td class="listlr">
126
					<?=htmlspecialchars($vlan['if']);?>
127
                  </td>
128
                  <td class="listr">
129
					<?=htmlspecialchars($vlan['tag']);?>
130
                  </td>
131
                  <td class="listbg">
132 5faf356d Scott Ullrich
		    <font color="white">
133 5b237745 Scott Ullrich
                    <?=htmlspecialchars($vlan['descr']);?>&nbsp;
134 5faf356d Scott Ullrich
		    </font>
135 5b237745 Scott Ullrich
                  </td>
136 677c0869 Erik Kristensen
                  <td valign="middle" nowrap class="list"> <a href="interfaces_vlan_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
137
                     &nbsp;<a href="interfaces_vlan.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this VLAN?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
138 5b237745 Scott Ullrich
				</tr>
139
			  <?php $i++; endforeach; ?>
140 cae1695e Scott Ullrich
                <tr>
141 5b237745 Scott Ullrich
                  <td class="list" colspan="3">&nbsp;</td>
142 677c0869 Erik Kristensen
                  <td class="list"> <a href="interfaces_vlan_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
143 5b237745 Scott Ullrich
				</tr>
144
				<tr>
145
				<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
146
				  Note:<br>
147
				  </strong></span>
148 cae1695e Scott Ullrich
				  Not all drivers/NICs support 802.1Q VLAN tagging properly. On cards that do not explicitly support it, VLAN tagging will still work, but the reduced MTU may cause problems. See the pfSense handbook for information on supported cards. </p>
149 5b237745 Scott Ullrich
				  </td>
150
				<td class="list">&nbsp;</td>
151
				</tr>
152
              </table>
153 d732f186 Bill Marquette
	      </div>
154
	</td>
155 5b237745 Scott Ullrich
	</tr>
156
</table>
157
<?php include("fend.inc"); ?>
158
</body>
159
</html>