Project

General

Profile

Download (8.36 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	interfaces_lan.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
$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
$pconfig['bandwidth'] = $config['interfaces']['lan']['bandwidth'];
40
$pconfig['bandwidthtype'] = $config['interfaces']['lan']['bandwidthtype'];
41
$pconfig['schedulertype'] = $config['interfaces']['lan']['schedulertype'];
42

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

    
58
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
59

    
60
	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

    
67
	/* 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
		$config['interfaces']['lan']['bandwidth'] = $_POST['bandwidth'];
79
		$config['interfaces']['lan']['bandwidthtype'] = $_POST['bandwidthtype'];
80
		$config['interfaces']['lan']['schedulertype'] = $_POST['schedulertype'];
81

    
82
		$dhcpd_was_enabled = 0;
83
		if (isset($config['dhcpd']['enable'])) {
84
			unset($config['dhcpd']['enable']);
85
			$dhcpd_was_enabled = 1;
86
		}
87

    
88
		write_config();
89
		touch($d_sysrebootreqd_path);
90

    
91
		$savemsg = get_std_save_message(0);
92

    
93
		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
$schedulertype = $config['interfaces']['lan']['schedulertype'];
99
?>
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

    
116
		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
                <tr>
141
                  <td width="22%" valign="top" class="vncellreq">IP address</td>
142
                  <td width="78%" class="vtable">
143
                    <input name="ipaddr" type="text" class="formfld" id="hostname" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" onchange="ipaddr_change()">
144
                    /
145
                    <select name="subnet" class="formfld" id="subnet">
146
                      <?php for ($i = 32; $i > 0; $i--): ?>
147
                      <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

    
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
                <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
                  <td width="22%" valign="top">&nbsp;</td>
199
                  <td width="78%">
200
                    <input name="Submit" type="submit" class="formbtn" value="Save">
201
                  </td>
202
                </tr>
203
                <tr>
204
                  <td width="22%" valign="top">&nbsp;</td>
205
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Warning:<br>
206
                    </strong></span>after you click &quot;Save&quot;, 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
                    <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>
(42-42/90)