Project

General

Profile

Download (9.44 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

    
41
$pconfig['disableftpproxy'] = isset($lancfg['disableftpproxy']);
42

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

    
49
if ($_POST) {
50

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

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

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

    
86
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
87
		$input_errors[] = "A valid IP address must be specified.";
88
	}
89
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
90
		$input_errors[] = "A valid subnet bit count must be specified.";
91
	}
92

    
93
	/* Wireless interface? */
94
	if (isset($lancfg['wireless'])) {
95
		$wi_input_errors = wireless_config_post();
96
		if ($wi_input_errors) {
97
			$input_errors = array_merge($input_errors, $wi_input_errors);
98
		}
99
	}
100

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

    
119
		$lancfg['bridge'] = $_POST['bridge'];
120
		
121
		if (($lancfg['ipaddr'] != $_POST['ipaddr']) || ($lancfg['subnet'] != $_POST['subnet'])) {
122
			update_if_changed("IP Address", &$lancfg['ipaddr'], $_POST['ipaddr']);
123
			update_if_changed("subnet", &$lancfg['subnet'], $_POST['subnet']);
124
		}
125

    
126
		write_config($changedesc);
127

    
128
		touch($d_landirty_path);
129

    
130
		/* restart snmp so that it binds to correct address */
131
		services_snmpd_configure();
132

    
133
		if ($_POST['apply'] <> "") {
134
			
135
			unlink($d_landirty_path);
136
			
137
			$savemsg = "The changes have been applied.  You may need to correct your web browser's IP address.";
138
			
139
		}
140
	}
141
}
142

    
143
$pgtitle = "Interfaces: LAN";
144
include("head.inc");
145

    
146
?>
147

    
148
<script language="JavaScript">
149
<!--
150
function enable_change(enable_over) {
151
	return;
152
	var endis;
153
	endis = !((document.iform.bridge.selectedIndex == 0) || enable_over);
154
	document.iform.ipaddr.disabled = endis;
155
	document.iform.subnet.disabled = endis;
156
}
157
// -->
158
</script>
159

    
160

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

    
228

    
229
                <tr>
230
                  <td colspan="2" valign="top" height="16"></td>
231
                </tr>
232
                <tr>
233
                  <td width="22%" valign="top">&nbsp;</td>
234
                  <td width="78%">
235
                    <input name="Submit" type="submit" class="formbtn" value="Save">
236
                  </td>
237
                </tr>
238
                <tr>
239
                  <td width="22%" valign="top">&nbsp;</td>
240
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Warning:<br>
241
                    </strong></span>after you click &quot;Save&quot;, you will need
242
                    to do one or more of the following steps before you can
243
                    access your firewall again:
244
                    <ul>
245
                      <li>change the IP address of your computer</li>
246
                      <li>renew its DHCP lease</li>
247
                      <li>access the webGUI with the new IP address</li>
248
		      <li>be sure to add <a href="firewall_rules.php">firewall rules</a> to permit traffic through the interface.</li>
249
		      <li>You also need firewall rules for an interface in bridged mode as the firewall acts as a filtering bridge.</li>
250
                    </ul>
251
                    </span></td>
252
                </tr>
253
              </table>
254
</form>
255
<?php include("fend.inc"); ?>
256
</body>
257
</html>
258

    
259
<?php
260

    
261
if ($_POST['apply'] <> "") {
262

    
263
	ob_flush();
264
	flush();
265
	
266
	interfaces_lan_configure();
267
	
268
	reset_carp();
269
	
270
	/* sync filter configuration */
271
	filter_configure();
272

    
273
	/* set up static routes */
274
	system_routing_configure();
275
	
276
	if(file_exists($d_landirty_path))
277
		unlink($d_landirty_path);
278
	
279
}
280

    
281
?>
(74-74/176)