Project

General

Profile

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