Project

General

Profile

Download (10.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
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

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

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

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

    
51
if ($_POST) {
52

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

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

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

    
88

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

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

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

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

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

    
139
		write_config($changedesc);
140

    
141
		touch($d_landirty_path);
142

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

    
148
	}
149
}
150

    
151

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

    
155
?>
156

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

    
169

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

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

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

    
288
<?php
289

    
290
if ($_POST['apply'] <> "") {
291

    
292
	touch("/tmp/reload_interfaces");
293
	if(file_exists($d_landirty_path))
294
	unlink($d_landirty_path);
295
	
296
}
297

    
298
?>
(61-61/155)