Project

General

Profile

Download (10.9 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/* $Id$ */
4
/*
5
	interfaces_lan.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
$lancfg = &$config['interfaces']['lan'];
36
$optcfg = &$config['interfaces']['lan'];
37

    
38
$pconfig['ipaddr'] = $lancfg['ipaddr'];
39
$pconfig['subnet'] = $lancfg['subnet'];
40
$pconfig['bridge'] = $lancfg['bridge'];
41
$pconfig['bandwidth'] = $lancfg['bandwidth'];
42
$pconfig['bandwidthtype'] = $lancfg['bandwidthtype'];
43

    
44
$pconfig['disableftpproxy'] = isset($lancfg['disableftpproxy']);
45

    
46
/* Wireless interface? */
47
if (isset($lancfg['wireless'])) {
48
	require("interfaces_wlan.inc");
49
	wireless_config_init();
50
}
51

    
52
if ($_POST) {
53

    
54
	if ($_POST['bridge']) {
55
		/* double bridging? */
56
		for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
57
			if ($i != $index) {
58
				if ($config['interfaces']['opt' . $i]['bridge'] == $_POST['bridge']) {
59
					//$input_errors[] = "Optional interface {$i} " .
60
					//	"({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " .
61
					//	"the specified interface.";
62
				} else if ($config['interfaces']['opt' . $i]['bridge'] == "opt{$index}") {
63
					//$input_errors[] = "Optional interface {$i} " .
64
					//	"({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " .
65
					//	"this interface.";
66
				}
67
			}
68
		}
69
		if ($config['interfaces'][$_POST['bridge']]['bridge']) {
70
			//$input_errors[] = "The specified interface is already bridged to " .
71
			//	"another interface.";
72
		}
73
		/* captive portal on? */
74
		if (isset($config['captiveportal']['enable'])) {
75
			//$input_errors[] = "Interfaces cannot be bridged while the captive portal is enabled.";
76
		}
77
	}
78

    
79
	unset($input_errors);
80
	$pconfig = $_POST;
81
	$changedesc = "LAN Interface: ";
82

    
83
	/* input validation */
84
	$reqdfields = explode(" ", "ipaddr subnet");
85
	$reqdfieldsn = explode(",", "IP address,Subnet bit count");
86
	
87
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
88

    
89

    
90
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
91
		$input_errors[] = "A valid IP address must be specified.";
92
	}
93
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
94
		$input_errors[] = "A valid subnet bit count must be specified.";
95
	}
96
	if($_POST['bandwidth'] <> "" && !is_numeric($_POST['bandwidth'])) {
97
		$input_errors[] = "A valid bandwidth value is required 1-999999.";
98
	}
99

    
100
	/* Wireless interface? */
101
	if (isset($lancfg['wireless'])) {
102
		$wi_input_errors = wireless_config_post();
103
		if ($wi_input_errors) {
104
			$input_errors = array_merge($input_errors, $wi_input_errors);
105
		}
106
	}
107

    
108
	if (!$input_errors) {
109
		
110
		unset($lancfg['disableftpproxy']);
111
		
112
		/* per interface pftpx helper */
113
		if($_POST['disableftpproxy'] == "yes") {
114
			$lancfg['disableftpproxy'] = true;
115
			system_start_ftp_helpers();
116
		} else {			
117
			system_start_ftp_helpers();
118
		}			
119
		
120
		$bridge = discover_bridge($lancfg['if'], filter_translate_type_to_real_interface($lancfg['bridge']));
121
		if($bridge <> "-1") {
122
			destroy_bridge($bridge);
123
		}
124

    
125
		$lancfg['bridge'] = $_POST['bridge'];
126
		
127
		if (($lancfg['ipaddr'] != $_POST['ipaddr']) || ($lancfg['subnet'] != $_POST['subnet'])) {
128
			update_if_changed("IP Address", &$lancfg['ipaddr'], $_POST['ipaddr']);
129
			update_if_changed("subnet", &$lancfg['subnet'], $_POST['subnet']);
130
		}
131

    
132
		if($_POST['bandwidth'] <> "" and $_POST['bandwidthtype'] <> "") {
133
			update_if_changed("bandwidth", &$lancfg['bandwidth'], $_POST['bandwidth']);
134
			update_if_changed("bandwidth type", &$lancfg['bandwidthtype'], $_POST['bandwidthtype']);
135
		} else {
136
			unset($lancfg['bandwidth']);
137
			unset($lancfg['bandwidthtype']);
138
		}
139

    
140
		write_config($changedesc);
141

    
142
		touch($d_landirty_path);
143

    
144
		if ($_POST['apply'] <> "") {
145
			unlink($d_landirty_path);
146
			$savemsg = "The changes have been applied.  You may need to correct the web browsers ip address.";
147
		}
148

    
149
	}
150
}
151

    
152

    
153
$pgtitle = "Interfaces: LAN";
154
include("head.inc");
155

    
156
?>
157

    
158
<script language="JavaScript">
159
<!--
160
function enable_change(enable_over) {
161
	return;
162
	var endis;
163
	endis = !((document.iform.bridge.selectedIndex == 0) || enable_over);
164
	document.iform.ipaddr.disabled = endis;
165
	document.iform.subnet.disabled = endis;
166
}
167
// -->
168
</script>
169

    
170

    
171
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
172
<form action="interfaces_lan.php" method="post" name="iform" id="iform">
173
<?php include("fbegin.inc"); ?>
174
<p class="pgtitle"><?=$pgtitle?></p>
175
<?php if ($input_errors) print_input_errors($input_errors); ?>
176
<?php if (file_exists($d_landirty_path)): ?><p>
177
<?php print_info_box_np("The LAN configuration has been changed.<p>You must apply the changes in order for them to take effect.<p>Don't forget to adjust the DHCP Server range if needed before applying.");?><br>
178
<?php endif; ?>
179
<?php if ($savemsg) print_info_box_np($savemsg); ?>
180
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
181
		<tr>
182
                  <td colspan="2" valign="top" class="listtopic">IP configuration</td>
183
		</tr>	      
184
		<tr>
185
                  <td width="22%" valign="top" class="vncellreq">Bridge with</td>
186
                  <td width="78%" class="vtable">
187
			<select name="bridge" class="formfld" id="bridge" onChange="enable_change(false)">
188
				  	<option <?php if (!$pconfig['bridge']) echo "selected";?> value="">none</option>
189
                      <?php $opts = array('wan' => "WAN");
190
					  	for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
191
							if ($i != $index)
192
								$opts['opt' . $i] = "Optional " . $i . " (" .
193
									$config['interfaces']['opt' . $i]['descr'] . ")";
194
						}
195
					foreach ($opts as $opt => $optname): ?>
196
                      <option <?php if ($opt == $pconfig['bridge']) echo "selected";?> value="<?=htmlspecialchars($opt);?>">
197
                      <?=htmlspecialchars($optname);?>
198
                      </option>
199
                      <?php endforeach; ?>
200
                    </select> </td>
201
		</tr>	      
202
                <tr>
203
                  <td width="22%" valign="top" class="vncellreq">IP address</td>
204
                  <td width="78%" class="vtable">
205
                    <input name="ipaddr" type="text" class="formfld" id="hostname" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" onchange="ipaddr_change()">
206
                    /
207
                    <select name="subnet" class="formfld" id="subnet">
208
					<?php
209
					for ($i = 32; $i > 0; $i--) {
210
						if($i <> 31) {
211
							echo "<option value=\"{$i}\" ";
212
							if ($i == $pconfig['subnet']) echo "selected";
213
							echo ">" . $i . "</option>";
214
						}
215
					}
216
					?>
217
                    </select></td>
218
                </tr>
219
                <tr>
220
                  <td colspan="2" valign="top" height="16"></td>
221
                </tr>
222
                <tr>
223
                  <td colspan="2" valign="top" class="listtopic">FTP Helper</td>
224
                </tr>		
225
		<tr>
226
			<td width="22%" valign="top" class="vncell">FTP Helper</td>
227
			<td width="78%" class="vtable">
228
				<input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if ($pconfig['disableftpproxy']) echo "checked"; ?> onclick="enable_change(false)" />
229
				<strong>Disable the userland FTP-Proxy application</strong>
230
				<br />
231
			</td>
232
		</tr>			
233
				<?php /* Wireless interface? */
234
				if (isset($lancfg['wireless']))
235
					wireless_config_print();
236
				?>
237

    
238
                <tr>
239
                  <td colspan="2" valign="top" height="16"></td>
240
                </tr>
241

    
242
                <tr>
243
                  <td colspan="2" valign="top" class="vnsepcell">Bandwidth Management (Traffic Shaping)</td>
244
                </tr>
245
                <tr>
246
                  <td valign="top" class="vncell">Interface Bandwidth Speed</td>
247
                  <td class="vtable"> <input name="bandwidth" type="text" class="formfld" id="bandwidth" size="30" value="<?=htmlspecialchars($pconfig['bandwidth']);?>">
248
			<select name="bandwidthtype">
249
				<option value="<?=htmlspecialchars($pconfig['bandwidthtype']);?>"><?=htmlspecialchars($pconfig['bandwidthtype']);?></option>
250
				<option value="b">bit/s</option>
251
				<option value="Kb">Kilobit/s</option>
252
				<option value="Mb">Megabit/s</option>
253
				<option value="Gb">Gigabit/s</option>
254
				<option value=""></option>
255
			</select>
256
			<br> The bandwidth setting will define the speed of the interface for traffic shaping.  Do not enter your "Internet" bandwidth here, only the physical speed!
257
		  </td>
258
                </tr>
259
                <tr>
260
                  <td colspan="2" valign="top" height="16"></td>
261
                </tr>
262
                <tr>
263
                  <td colspan="2" valign="top" class="listtopic">FTP Helper</td>
264
                </tr>
265
                <tr>
266
                  <td width="22%" valign="top">&nbsp;</td>
267
                  <td width="78%">
268
                    <input name="Submit" type="submit" class="formbtn" value="Save">
269
                  </td>
270
                </tr>
271
                <tr>
272
                  <td width="22%" valign="top">&nbsp;</td>
273
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Warning:<br>
274
                    </strong></span>after you click &quot;Save&quot;, you will need
275
                    to do one or more of the following steps before you can
276
                    access your firewall again:
277
                    <ul>
278
                      <li>change the IP address of your computer</li>
279
                      <li>renew its DHCP lease</li>
280
                      <li>access the webGUI with the new IP address</li>
281
		      <li>be sure to add <a href="firewall_rules.php">firewall rules</a> to permit traffic through the interface.</li>
282
		      <li>You also need firewall rules for an interface in bridged mode as the firewall acts as a filtering bridge.</li>
283
                    </ul>
284
                    </span></td>
285
                </tr>
286
              </table>
287
</form>
288
<?php include("fend.inc"); ?>
289
</body>
290
</html>
291

    
292
<?php
293

    
294
if ($_POST['apply'] <> "") {
295

    
296
	touch("/tmp/reload_interfaces");
297

    
298
	unlink($d_landirty_path);
299
	
300
}
301

    
302
?>
(61-61/153)