Project

General

Profile

Download (7.25 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php
2 7f5b4824 Scott Ullrich
<?php
3 b46bfcf5 Bill Marquette
/* $Id$ */
4 5b237745 Scott Ullrich
/*
5
	interfaces_lan.php
6
	part of m0n0wall (http://m0n0.ch/wall)
7 7f5b4824 Scott Ullrich
8 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10 7f5b4824 Scott Ullrich
11 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13 7f5b4824 Scott Ullrich
14 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16 7f5b4824 Scott Ullrich
17 5b237745 Scott Ullrich
	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 7f5b4824 Scott Ullrich
21 5b237745 Scott Ullrich
	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
$lancfg = &$config['interfaces']['lan'];
36 e95c754f Bill Marquette
$pconfig['ipaddr'] = $lancfg['ipaddr'];
37
$pconfig['subnet'] = $lancfg['subnet'];
38 5b237745 Scott Ullrich
39 e95c754f Bill Marquette
$pconfig['bandwidth'] = $lancfg['bandwidth'];
40
$pconfig['bandwidthtype'] = $lancfg['bandwidthtype'];
41 03b92764 Scott Ullrich
42 5b237745 Scott Ullrich
/* Wireless interface? */
43 b7f01f59 Bill Marquette
if (isset($lancfg['wireless'])) {
44 5b237745 Scott Ullrich
	require("interfaces_wlan.inc");
45
	wireless_config_init();
46
}
47
48
if ($_POST) {
49
50
	unset($input_errors);
51
	$pconfig = $_POST;
52 52442f57 Bill Marquette
	$changedesc = "LAN Interface: ";
53 5b237745 Scott Ullrich
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 b7f01f59 Bill Marquette
	if (isset($lancfg['wireless'])) {
69 5b237745 Scott Ullrich
		$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 52442f57 Bill Marquette
		if (($lancfg['ipaddr'] != $_POST['ipaddr']) || ($lancfg['subnet'] != $_POST['subnet'])) {
77 79f8694f Bill Marquette
			update_if_changed("IP Address", &$lancfg['ipaddr'], $_POST['ipaddr']);
78
			update_if_changed("subnet", &$lancfg['subnet'], $_POST['subnet']);
79 52442f57 Bill Marquette
80
			/* We'll need to reboot after this */
81
			touch($d_sysrebootreqd_path);
82
		}
83
84 001fdeea Scott Ullrich
		if($_POST['bandwidth'] <> "" and $_POST['bandwidthtype'] <> "") {
85
			update_if_changed("bandwidth", &$lancfg['bandwidth'], $_POST['bandwidth']);
86
			update_if_changed("bandwidth type", &$lancfg['bandwidthtype'], $_POST['bandwidthtype']);
87
		} else {
88
			unset($lancfg['bandwidth']);
89
			unset($lancfg['bandwidthtype']);
90
		}
91 7f5b4824 Scott Ullrich
92 5b237745 Scott Ullrich
		$dhcpd_was_enabled = 0;
93
		if (isset($config['dhcpd']['enable'])) {
94
			unset($config['dhcpd']['enable']);
95
			$dhcpd_was_enabled = 1;
96 7247e494 Bill Marquette
			$changedesc .= " DHCP disabled";
97 5b237745 Scott Ullrich
		}
98 7f5b4824 Scott Ullrich
99 52442f57 Bill Marquette
		write_config($changedesc);
100 7f5b4824 Scott Ullrich
101 5b237745 Scott Ullrich
		$savemsg = get_std_save_message(0);
102 1f8caa36 Scott Ullrich
		
103
		/* setup carp interfaces */
104
		interfaces_carp_configure();
105
	
106
		/* bring up carp interfaces */
107
		interfaces_carp_bringup();	
108 7f5b4824 Scott Ullrich
109 5b237745 Scott Ullrich
		if ($dhcpd_was_enabled)
110
			$savemsg .= "<br>Note that the DHCP server has been disabled.<br>Please review its configuration " .
111
				"and enable it again prior to rebooting.";
112
	}
113
}
114 222b5299 Scott Ullrich
115 b9e255dd Bill Marquette
116 7f43ca88 Scott Ullrich
$pgtitle = "Interfaces: LAN";
117
include("head.inc");
118
119
?>
120 b9e255dd Bill Marquette
<script type="text/javascript" language="javascript" src="ip_helper.js">
121
</script>
122
123 5b237745 Scott Ullrich
<script language="JavaScript">
124
<!--
125
function ipaddr_change() {
126 6846116e Scott Ullrich
	document.iform.subnet.value = gen_bits_lan(document.iform.ipaddr.value);
127 5b237745 Scott Ullrich
}
128
// -->
129
</script>
130 b9e255dd Bill Marquette
131 5b237745 Scott Ullrich
132
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
133
<?php include("fbegin.inc"); ?>
134 931066a8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
135 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
136
<?php if ($savemsg) print_info_box($savemsg); ?>
137
            <form action="interfaces_lan.php" method="post" name="iform" id="iform">
138
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
139 7f5b4824 Scott Ullrich
                <tr>
140 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">IP address</td>
141 7f5b4824 Scott Ullrich
                  <td width="78%" class="vtable">
142 5b237745 Scott Ullrich
                    <input name="ipaddr" type="text" class="formfld" id="hostname" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" onchange="ipaddr_change()">
143 7f5b4824 Scott Ullrich
                    /
144 5b237745 Scott Ullrich
                    <select name="subnet" class="formfld" id="subnet">
145 21ab1cde Scott Ullrich
					<?php
146
					for ($i = 32; $i > 0; $i--) {
147
						if($i <> 31) {
148
							echo "<option value=\"{$i}\" ";
149
							if ($i == $pconfig['subnet']) echo "selected";
150
							echo ">" . $i . "</option>";
151
						}
152
					}
153
					?>
154 5b237745 Scott Ullrich
                    </select></td>
155
                </tr>
156
				<?php /* Wireless interface? */
157 b7f01f59 Bill Marquette
				if (isset($lancfg['wireless']))
158 5b237745 Scott Ullrich
					wireless_config_print();
159
				?>
160 73c38fa2 Scott Ullrich
161
                <tr>
162
                  <td colspan="2" valign="top" height="16"></td>
163
                </tr>
164
165
                <tr>
166
                  <td colspan="2" valign="top" class="vnsepcell">Bandwidth Management (Traffic Shaping)</td>
167
                </tr>
168 7f5b4824 Scott Ullrich
                <tr>
169
                  <td valign="top" class="vncell">Interface Bandwidth Speed</td>
170
                  <td class="vtable"> <input name="bandwidth" type="text" class="formfld" id="bandwidth" size="30" value="<?=htmlspecialchars($pconfig['bandwidth']);?>">
171
			<select name="bandwidthtype">
172
				<option value="<?=htmlspecialchars($pconfig['bandwidthtype']);?>"><?=htmlspecialchars($pconfig['bandwidthtype']);?></option>
173
				<option value="b">bit/s</option>
174
				<option value="Kb">Kilobit/s</option>
175
				<option value="Mb">Megabit/s</option>
176
				<option value="Gb">Gigabit/s</option>
177 d09c8936 Scott Ullrich
				<option value=""></option>
178 7f5b4824 Scott Ullrich
			</select>
179
			<br> The bandwidth setting will define the speed of the interface for traffic shaping.
180
		  </td>
181
                </tr>
182
                <tr>
183 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
184 7f5b4824 Scott Ullrich
                  <td width="78%">
185
                    <input name="Submit" type="submit" class="formbtn" value="Save">
186 5b237745 Scott Ullrich
                  </td>
187
                </tr>
188 7f5b4824 Scott Ullrich
                <tr>
189 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
190
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Warning:<br>
191 0390c50a Bill Marquette
                    </strong></span>after you click &quot;Save&quot;, you will need
192
                    reboot your firewall for changes to take effect if you changed the
193
                    IP address or subnet of this interface. You may also
194 7f5b4824 Scott Ullrich
                    have to do one or more of the following steps before you can
195
                    access your firewall again:
196 5b237745 Scott Ullrich
                    <ul>
197
                      <li>change the IP address of your computer</li>
198
                      <li>renew its DHCP lease</li>
199
                      <li>access the webGUI with the new IP address</li>
200
                    </ul>
201
                    </span></td>
202
                </tr>
203
              </table>
204
</form>
205
<?php include("fend.inc"); ?>
206
</body>
207
</html>