Project

General

Profile

Download (5.45 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
		touch($d_sysrebootreqd_path);
82
		header("Location: interfaces_vlan.php");
83
		exit;
84
	}
85
}
86
87 7f43ca88 Scott Ullrich
88
$pgtitle = "Interfaces: VLAN";
89
include("head.inc");
90
91 5b237745 Scott Ullrich
?>
92
93
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
94
<?php include("fbegin.inc"); ?>
95
<p class="pgtitle">Interfaces: Assign network ports: VLANs</p>
96
<?php if ($input_errors) print_input_errors($input_errors); ?>
97
<?php if (file_exists($d_sysrebootreqd_path)) print_info_box(get_std_save_message(0)); ?>
98 c8b8ff69 Scott Ullrich
<div id="mainarea">
99 5b237745 Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">
100
  <tr><td>
101 c8b8ff69 Scott Ullrich
<?php
102
	$tab_array = array();
103
	$tab_array[0] = array("Interface assignments", true, "interfaces_assign.php");
104
	$tab_array[1] = array("VLANs", false, "interfaces_vlan.php");
105
	display_top_tabs($tab_array);
106
?>
107 5b237745 Scott Ullrich
  </td></tr>
108 cae1695e Scott Ullrich
  <tr>
109 5b237745 Scott Ullrich
    <td class="tabcont">
110
<table width="100%" border="0" cellpadding="0" cellspacing="0">
111
                <tr>
112
                  <td width="20%" class="listhdrr">Interface</td>
113
                  <td width="20%" class="listhdrr">VLAN tag</td>
114
                  <td width="50%" class="listhdr">Description</td>
115
                  <td width="10%" class="list"></td>
116
				</tr>
117
			  <?php $i = 0; foreach ($a_vlans as $vlan): ?>
118
                <tr>
119
                  <td class="listlr">
120
					<?=htmlspecialchars($vlan['if']);?>
121
                  </td>
122
                  <td class="listr">
123
					<?=htmlspecialchars($vlan['tag']);?>
124
                  </td>
125
                  <td class="listbg">
126
                    <?=htmlspecialchars($vlan['descr']);?>&nbsp;
127
                  </td>
128
                  <td valign="middle" nowrap class="list"> <a href="interfaces_vlan_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
129
                     &nbsp;<a href="interfaces_vlan.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this VLAN?')"><img src="x.gif" width="17" height="17" border="0"></a></td>
130
				</tr>
131
			  <?php $i++; endforeach; ?>
132 cae1695e Scott Ullrich
                <tr>
133 5b237745 Scott Ullrich
                  <td class="list" colspan="3">&nbsp;</td>
134
                  <td class="list"> <a href="interfaces_vlan_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
135
				</tr>
136
				<tr>
137
				<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
138
				  Note:<br>
139
				  </strong></span>
140 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>
141 5b237745 Scott Ullrich
				  </td>
142
				<td class="list">&nbsp;</td>
143
				</tr>
144
              </table>
145
			  </td>
146
	</tr>
147
</table>
148 c8b8ff69 Scott Ullrich
</div>
149 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
150 c8b8ff69 Scott Ullrich
151
<script type="text/javascript">
152
NiftyCheck();
153
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
154
</script>
155
156 5b237745 Scott Ullrich
</body>
157
</html>