1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
7f5b4824
|
Scott Ullrich
|
<?php
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
interfaces_lan.php
|
5 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
6 |
7f5b4824
|
Scott Ullrich
|
|
7 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
|
|
All rights reserved.
|
9 |
7f5b4824
|
Scott Ullrich
|
|
10 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
7f5b4824
|
Scott Ullrich
|
|
13 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
7f5b4824
|
Scott Ullrich
|
|
16 |
5b237745
|
Scott Ullrich
|
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 |
7f5b4824
|
Scott Ullrich
|
|
20 |
5b237745
|
Scott Ullrich
|
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 |
|
|
$lancfg = &$config['interfaces']['lan'];
|
35 |
|
|
$optcfg = &$config['interfaces']['lan'];
|
36 |
|
|
$pconfig['ipaddr'] = $config['interfaces']['lan']['ipaddr'];
|
37 |
|
|
$pconfig['subnet'] = $config['interfaces']['lan']['subnet'];
|
38 |
|
|
|
39 |
03b92764
|
Scott Ullrich
|
$pconfig['bandwidth'] = $config['interfaces']['lan']['bandwidth'];
|
40 |
|
|
$pconfig['bandwidthtype'] = $config['interfaces']['lan']['bandwidthtype'];
|
41 |
73c38fa2
|
Scott Ullrich
|
$pconfig['schedulertype'] = $config['interfaces']['lan']['schedulertype'];
|
42 |
03b92764
|
Scott Ullrich
|
|
43 |
5b237745
|
Scott Ullrich
|
/* Wireless interface? */
|
44 |
|
|
if (isset($optcfg['wireless'])) {
|
45 |
|
|
require("interfaces_wlan.inc");
|
46 |
|
|
wireless_config_init();
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
if ($_POST) {
|
50 |
|
|
|
51 |
|
|
unset($input_errors);
|
52 |
|
|
$pconfig = $_POST;
|
53 |
|
|
|
54 |
|
|
/* input validation */
|
55 |
|
|
$reqdfields = explode(" ", "ipaddr subnet");
|
56 |
|
|
$reqdfieldsn = explode(",", "IP address,Subnet bit count");
|
57 |
7f5b4824
|
Scott Ullrich
|
|
58 |
5b237745
|
Scott Ullrich
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
59 |
7f5b4824
|
Scott Ullrich
|
|
60 |
5b237745
|
Scott Ullrich
|
if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
|
61 |
|
|
$input_errors[] = "A valid IP address must be specified.";
|
62 |
|
|
}
|
63 |
|
|
if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
|
64 |
|
|
$input_errors[] = "A valid subnet bit count must be specified.";
|
65 |
|
|
}
|
66 |
7f5b4824
|
Scott Ullrich
|
|
67 |
5b237745
|
Scott Ullrich
|
/* Wireless interface? */
|
68 |
|
|
if (isset($optcfg['wireless'])) {
|
69 |
|
|
$wi_input_errors = wireless_config_post();
|
70 |
|
|
if ($wi_input_errors) {
|
71 |
|
|
$input_errors = array_merge($input_errors, $wi_input_errors);
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
if (!$input_errors) {
|
76 |
|
|
$config['interfaces']['lan']['ipaddr'] = $_POST['ipaddr'];
|
77 |
|
|
$config['interfaces']['lan']['subnet'] = $_POST['subnet'];
|
78 |
7f5b4824
|
Scott Ullrich
|
$config['interfaces']['lan']['bandwidth'] = $_POST['bandwidth'];
|
79 |
|
|
$config['interfaces']['lan']['bandwidthtype'] = $_POST['bandwidthtype'];
|
80 |
73c38fa2
|
Scott Ullrich
|
$config['interfaces']['lan']['schedulertype'] = $_POST['schedulertype'];
|
81 |
7f5b4824
|
Scott Ullrich
|
|
82 |
5b237745
|
Scott Ullrich
|
$dhcpd_was_enabled = 0;
|
83 |
|
|
if (isset($config['dhcpd']['enable'])) {
|
84 |
|
|
unset($config['dhcpd']['enable']);
|
85 |
|
|
$dhcpd_was_enabled = 1;
|
86 |
|
|
}
|
87 |
7f5b4824
|
Scott Ullrich
|
|
88 |
5b237745
|
Scott Ullrich
|
write_config();
|
89 |
|
|
touch($d_sysrebootreqd_path);
|
90 |
7f5b4824
|
Scott Ullrich
|
|
91 |
5b237745
|
Scott Ullrich
|
$savemsg = get_std_save_message(0);
|
92 |
7f5b4824
|
Scott Ullrich
|
|
93 |
5b237745
|
Scott Ullrich
|
if ($dhcpd_was_enabled)
|
94 |
|
|
$savemsg .= "<br>Note that the DHCP server has been disabled.<br>Please review its configuration " .
|
95 |
|
|
"and enable it again prior to rebooting.";
|
96 |
|
|
}
|
97 |
|
|
}
|
98 |
73c38fa2
|
Scott Ullrich
|
$schedulertype = $config['interfaces']['lan']['schedulertype'];
|
99 |
5b237745
|
Scott Ullrich
|
?>
|
100 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
101 |
|
|
<html>
|
102 |
|
|
<head>
|
103 |
|
|
<title><?=gentitle("Interfaces: LAN");?></title>
|
104 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
105 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
106 |
|
|
<script language="JavaScript">
|
107 |
|
|
<!--
|
108 |
|
|
function gen_bits(ipaddr) {
|
109 |
|
|
if (ipaddr.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) != -1) {
|
110 |
|
|
var adr = ipaddr.split(/\./);
|
111 |
|
|
if (adr[0] > 255 || adr[1] > 255 || adr[2] > 255 || adr[3] > 255)
|
112 |
|
|
return "";
|
113 |
|
|
if (adr[0] == 0 && adr[1] == 0 && adr[2] == 0 && adr[3] == 0)
|
114 |
|
|
return "";
|
115 |
7f5b4824
|
Scott Ullrich
|
|
116 |
5b237745
|
Scott Ullrich
|
if (adr[0] <= 127)
|
117 |
|
|
return "8";
|
118 |
|
|
else if (adr[0] <= 191)
|
119 |
|
|
return "16";
|
120 |
|
|
else
|
121 |
|
|
return "24";
|
122 |
|
|
}
|
123 |
|
|
else
|
124 |
|
|
return "";
|
125 |
|
|
}
|
126 |
|
|
function ipaddr_change() {
|
127 |
|
|
document.iform.subnet.value = gen_bits(document.iform.ipaddr.value);
|
128 |
|
|
}
|
129 |
|
|
// -->
|
130 |
|
|
</script>
|
131 |
|
|
</head>
|
132 |
|
|
|
133 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
134 |
|
|
<?php include("fbegin.inc"); ?>
|
135 |
|
|
<p class="pgtitle">Interfaces: LAN</p>
|
136 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
137 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
138 |
|
|
<form action="interfaces_lan.php" method="post" name="iform" id="iform">
|
139 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
140 |
7f5b4824
|
Scott Ullrich
|
<tr>
|
141 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">IP address</td>
|
142 |
7f5b4824
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
143 |
5b237745
|
Scott Ullrich
|
<input name="ipaddr" type="text" class="formfld" id="hostname" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" onchange="ipaddr_change()">
|
144 |
7f5b4824
|
Scott Ullrich
|
/
|
145 |
5b237745
|
Scott Ullrich
|
<select name="subnet" class="formfld" id="subnet">
|
146 |
40dd6441
|
Scott Ullrich
|
<?php for ($i = 32; $i > 0; $i--): ?>
|
147 |
5b237745
|
Scott Ullrich
|
<option value="<?=$i;?>" <?php if ($i == $pconfig['subnet']) echo "selected"; ?>>
|
148 |
|
|
<?=$i;?>
|
149 |
|
|
</option>
|
150 |
|
|
<?php endfor; ?>
|
151 |
|
|
</select></td>
|
152 |
|
|
</tr>
|
153 |
|
|
<?php /* Wireless interface? */
|
154 |
|
|
if (isset($optcfg['wireless']))
|
155 |
|
|
wireless_config_print();
|
156 |
|
|
?>
|
157 |
73c38fa2
|
Scott Ullrich
|
|
158 |
|
|
<tr>
|
159 |
|
|
<td colspan="2" valign="top" height="16"></td>
|
160 |
|
|
</tr>
|
161 |
|
|
|
162 |
|
|
<tr>
|
163 |
|
|
<td colspan="2" valign="top" class="vnsepcell">Bandwidth Management (Traffic Shaping)</td>
|
164 |
|
|
</tr>
|
165 |
|
|
<tr>
|
166 |
|
|
<td width="22%" valign="top" class="vncell"><b>Scheduler</b> </td>
|
167 |
|
|
<td width="78%" class="vtable">
|
168 |
|
|
<select id="schedulertype" name="schedulertype">
|
169 |
|
|
<?php
|
170 |
|
|
if($schedulertype == 'priq')
|
171 |
|
|
echo "<option value=\"priq\">Priority based queueing</option>";
|
172 |
|
|
if($schedulertype == 'cbq')
|
173 |
|
|
echo "<option value=\"cbq\">Class based queueing</option>";
|
174 |
|
|
if($schedulertype == 'hfsc')
|
175 |
|
|
echo "<option value=\"hfsc\">Hierarchical Fair Service Curve queueing</option>";
|
176 |
|
|
?>
|
177 |
|
|
<option value="priq">Priority based queueing</option>
|
178 |
|
|
<option value="cbq">Class based queueing</option>
|
179 |
|
|
<option value="hfsc">Hierarchical Fair Service Curve queueing</option>
|
180 |
|
|
</select>
|
181 |
|
|
<br> <span class="vexpl">Select which type of queueing you would like to use
|
182 |
|
|
</span></td>
|
183 |
|
|
</tr>
|
184 |
7f5b4824
|
Scott Ullrich
|
<tr>
|
185 |
|
|
<td valign="top" class="vncell">Interface Bandwidth Speed</td>
|
186 |
|
|
<td class="vtable"> <input name="bandwidth" type="text" class="formfld" id="bandwidth" size="30" value="<?=htmlspecialchars($pconfig['bandwidth']);?>">
|
187 |
|
|
<select name="bandwidthtype">
|
188 |
|
|
<option value="<?=htmlspecialchars($pconfig['bandwidthtype']);?>"><?=htmlspecialchars($pconfig['bandwidthtype']);?></option>
|
189 |
|
|
<option value="b">bit/s</option>
|
190 |
|
|
<option value="Kb">Kilobit/s</option>
|
191 |
|
|
<option value="Mb">Megabit/s</option>
|
192 |
|
|
<option value="Gb">Gigabit/s</option>
|
193 |
|
|
</select>
|
194 |
|
|
<br> The bandwidth setting will define the speed of the interface for traffic shaping.
|
195 |
|
|
</td>
|
196 |
|
|
</tr>
|
197 |
|
|
<tr>
|
198 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top"> </td>
|
199 |
7f5b4824
|
Scott Ullrich
|
<td width="78%">
|
200 |
|
|
<input name="Submit" type="submit" class="formbtn" value="Save">
|
201 |
5b237745
|
Scott Ullrich
|
</td>
|
202 |
|
|
</tr>
|
203 |
7f5b4824
|
Scott Ullrich
|
<tr>
|
204 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top"> </td>
|
205 |
|
|
<td width="78%"><span class="vexpl"><span class="red"><strong>Warning:<br>
|
206 |
7f5b4824
|
Scott Ullrich
|
</strong></span>after you click "Save", you must
|
207 |
|
|
reboot your firewall for changes to take effect. You may also
|
208 |
|
|
have to do one or more of the following steps before you can
|
209 |
|
|
access your firewall again:
|
210 |
5b237745
|
Scott Ullrich
|
<ul>
|
211 |
|
|
<li>change the IP address of your computer</li>
|
212 |
|
|
<li>renew its DHCP lease</li>
|
213 |
|
|
<li>access the webGUI with the new IP address</li>
|
214 |
|
|
</ul>
|
215 |
|
|
</span></td>
|
216 |
|
|
</tr>
|
217 |
|
|
</table>
|
218 |
|
|
</form>
|
219 |
|
|
<?php include("fend.inc"); ?>
|
220 |
|
|
</body>
|
221 |
|
|
</html>
|