Project

General

Profile

Download (5.34 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces_vlan_edit.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
$portlist = get_interface_list();
40

    
41
$id = $_GET['id'];
42
if (isset($_POST['id']))
43
	$id = $_POST['id'];
44

    
45
if (isset($id) && $a_vlans[$id]) {
46
	$pconfig['if'] = $a_vlans[$id]['if'];
47
	$pconfig['tag'] = $a_vlans[$id]['tag'];
48
	$pconfig['descr'] = $a_vlans[$id]['descr'];
49
}
50

    
51
if ($_POST) {
52

    
53
	unset($input_errors);
54
	$pconfig = $_POST;
55

    
56
	/* input validation */
57
	$reqdfields = explode(" ", "if tag");
58
	$reqdfieldsn = explode(",", "Parent interface,VLAN tag");
59

    
60
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
61

    
62
	if ($_POST['tag'] && (!is_numericint($_POST['tag']) || ($_POST['tag'] < '1') || ($_POST['tag'] > '4094'))) {
63
		$input_errors[] = "The VLAN tag must be an integer between 1 and 4094.";
64
	}
65

    
66
	foreach ($a_vlans as $vlan) {
67
		if (isset($id) && ($a_vlans[$id]) && ($a_vlans[$id] === $vlan))
68
			continue;
69

    
70
		if (($vlan['if'] == $_POST['if']) && ($vlan['tag'] == $_POST['tag'])) {
71
			$input_errors[] = "A VLAN with the tag {$vlan['tag']} is already defined on this interface.";
72
			break;
73
		}
74
	}
75

    
76
	if (!$input_errors) {
77
		$vlan = array();
78
		$vlan['if'] = $_POST['if'];
79
		$vlan['tag'] = $_POST['tag'];
80
		$vlan['descr'] = $_POST['descr'];
81

    
82
		if (isset($id) && $a_vlans[$id])
83
			$a_vlans[$id] = $vlan;
84
		else
85
			$a_vlans[] = $vlan;
86

    
87
		write_config();
88

    
89
		interfaces_vlan_configure();
90
		interfaces_lan_configure();
91
		interfaces_wan_configure();
92
		interfaces_optional_configure();
93

    
94
		header("Location: interfaces_vlan.php");
95
		exit;
96
	}
97
}
98

    
99
$pgtitle = "Firewall: VLAN: Edit";
100
include("head.inc");
101

    
102
?>
103

    
104
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
105
<?php include("fbegin.inc"); ?>
106
<p class="pgtitle"><?=$pgtitle?></p>
107
<?php if ($input_errors) print_input_errors($input_errors); ?>
108
            <form action="interfaces_vlan_edit.php" method="post" name="iform" id="iform">
109
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
110
				<tr>
111
                  <td width="22%" valign="top" class="vncellreq">Parent interface</td>
112
                  <td width="78%" class="vtable">
113
                    <select name="if" class="formfld">
114
                      <?php
115
					  foreach ($portlist as $ifn => $ifinfo)
116
						if (is_jumbo_capable($ifn)) {
117
							echo "<option value=\"{$ifn}\"";
118
							if ($ifn == $pconfig['if'])
119
								echo "selected";
120
							echo ">";
121
                      				        echo htmlspecialchars($ifn . " (" . $ifinfo['mac'] . ")");
122
                      					echo "</option>";
123
						}
124
		      ?>
125
                    </select>
126
			<br/>
127
			<span class="vexpl">Only VLAN capable interfaces will be shown.</span></td>
128
                </tr>
129
				<tr>
130
                  <td valign="top" class="vncellreq">VLAN tag </td>
131
                  <td class="vtable">
132
                    <input name="tag" type="text" class="formfld" id="tag" size="6" value="<?=htmlspecialchars($pconfig['tag']);?>">
133
                    <br>
134
                    <span class="vexpl">802.1Q VLAN tag (between 1 and 4094) </span></td>
135
			    </tr>
136
				<tr>
137
                  <td width="22%" valign="top" class="vncell">Description</td>
138
                  <td width="78%" class="vtable">
139
                    <input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
140
                    <br> <span class="vexpl">You may enter a description here
141
                    for your reference (not parsed).</span></td>
142
                </tr>
143
                <tr>
144
                  <td width="22%" valign="top">&nbsp;</td>
145
                  <td width="78%">
146
                    <input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" value="Cancel" onclick="history.back()">
147
                    <?php if (isset($id) && $a_vlans[$id]): ?>
148
                    <input name="id" type="hidden" value="<?=$id;?>">
149
                    <?php endif; ?>
150
                  </td>
151
                </tr>
152
              </table>
153
</form>
154
<?php include("fend.inc"); ?>
155
</body>
156
</html>
(74-74/175)