Project

General

Profile

Download (5.63 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces_vlan.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

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

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

    
16
	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

    
20
	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

    
47
	for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
48
		if ($config['interfaces']['opt' . $i]['if'] == "vlan{$num}")
49
			return true;
50
	}
51

    
52
	return false;
53
}
54

    
55
function renumber_vlan($if, $delvlan) {
56
	if (!preg_match("/^vlan/", $if))
57
		return $if;
58

    
59
	$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

    
73
		/* 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

    
79
		write_config();
80

    
81
		interfaces_vlan_configure();
82

    
83
		header("Location: interfaces_vlan.php");
84
		exit;
85
	}
86
}
87

    
88

    
89
$pgtitle = "Interfaces: VLAN";
90
include("head.inc");
91

    
92
?>
93

    
94
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
95
<?php include("fbegin.inc"); ?>
96
<p class="pgtitle"><?=$pgtitle?></p>
97
<?php if ($input_errors) print_input_errors($input_errors); ?>
98
<?php if (file_exists("/tmp/vlanchanged")) { 
99
	print_info_box("VLAN configuration has changed.  WARNING: You may need to <a href='reboot.php'>reboot</a> for
100
		the changes to take effect.");
101
	mwexec("/bin/rm /tmp/vlanchanged");
102
}
103
?>
104
<table width="100%" border="0" cellpadding="0" cellspacing="0">
105
  <tr><td>
106
<?php
107
	$tab_array = array();
108
	$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
109
	$tab_array[1] = array("VLANs", true, "interfaces_vlan.php");
110
	display_top_tabs($tab_array);
111
?>
112
  </td></tr>
113
  <tr>
114
    <td>
115
	<div id="mainarea">
116
	<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
117
                <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
		    <font color="white">
133
                    <?=htmlspecialchars($vlan['descr']);?>&nbsp;
134
		    </font>
135
                  </td>
136
                  <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
				</tr>
139
			  <?php $i++; endforeach; ?>
140
                <tr>
141
                  <td class="list" colspan="3">&nbsp;</td>
142
                  <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
				</tr>
144
				<tr>
145
				<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
146
				  Note:<br>
147
				  </strong></span>
148
				  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 <?=$g['product_name']?> handbook for information on supported cards. </p>
149
				  </td>
150
				<td class="list">&nbsp;</td>
151
				</tr>
152
              </table>
153
	      </div>
154
	</td>
155
	</tr>
156
</table>
157
<?php include("fend.inc"); ?>
158
</body>
159
</html>
(75-75/175)