Project

General

Profile

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

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

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

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

    
17
	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

    
21
	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

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

    
53
	return false;
54
}
55

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

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

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

    
80
		write_config();
81
		touch($d_sysrebootreqd_path);
82
		header("Location: interfaces_vlan.php");
83
		exit;
84
	}
85
}
86

    
87

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

    
91
?>
92

    
93
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
94
<?php include("fbegin.inc"); ?>
95
<p class="pgtitle"><?=$pgtitle?></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
<table width="100%" border="0" cellpadding="0" cellspacing="0">
99
  <tr><td>
100
<?php
101
	$tab_array = array();
102
	$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
103
	$tab_array[1] = array("VLANs", true, "interfaces_vlan.php");
104
	display_top_tabs($tab_array);
105
?>
106
  </td></tr>
107
  <tr>
108
    <td>
109
	<div id="mainarea">
110
	<table class="tabcont" 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
                <tr>
133
                  <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
				  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
				  </td>
142
				<td class="list">&nbsp;</td>
143
				</tr>
144
              </table>
145
	      </div>
146
	</td>
147
	</tr>
148
</table>
149
<?php include("fend.inc"); ?>
150
</body>
151
</html>
(60-60/133)