Project

General

Profile

Download (33.3 KB) Statistics
| Branch: | Tag: | Revision:
1 e2cd32df Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	interfaces_wan.php
5 c3b3cd36 Scott Ullrich
        Copyright (C) 2004 Scott Ullrich
6
	All rights reserved.
7 b1c525ee Scott Ullrich
8 c3b3cd36 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
9 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11 e2cd32df Scott Ullrich
12 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14 e2cd32df Scott Ullrich
15 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17 e2cd32df Scott Ullrich
18 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21 e2cd32df Scott Ullrich
22 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33
34
require("guiconfig.inc");
35
36
$wancfg = &$config['interfaces']['wan'];
37 8bb29531 Scott Ullrich
$optcfg = &$config['interfaces']['wan'];
38 5b237745 Scott Ullrich
39
$pconfig['username'] = $config['pppoe']['username'];
40
$pconfig['password'] = $config['pppoe']['password'];
41
$pconfig['provider'] = $config['pppoe']['provider'];
42 a23d7248 Scott Ullrich
$pconfig['pppoe_dialondemand'] = isset($config['pppoe']['ondemand']);
43 5b237745 Scott Ullrich
$pconfig['pppoe_idletimeout'] = $config['pppoe']['timeout'];
44
45
$pconfig['pptp_username'] = $config['pptp']['username'];
46
$pconfig['pptp_password'] = $config['pptp']['password'];
47
$pconfig['pptp_local'] = $config['pptp']['local'];
48
$pconfig['pptp_subnet'] = $config['pptp']['subnet'];
49
$pconfig['pptp_remote'] = $config['pptp']['remote'];
50 a23d7248 Scott Ullrich
$pconfig['pptp_dialondemand'] = isset($config['pptp']['ondemand']);
51 5b237745 Scott Ullrich
$pconfig['pptp_idletimeout'] = $config['pptp']['timeout'];
52
53 c1ec2c2f Scott Ullrich
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
54
55 5b237745 Scott Ullrich
$pconfig['bigpond_username'] = $config['bigpond']['username'];
56
$pconfig['bigpond_password'] = $config['bigpond']['password'];
57
$pconfig['bigpond_authserver'] = $config['bigpond']['authserver'];
58
$pconfig['bigpond_authdomain'] = $config['bigpond']['authdomain'];
59
$pconfig['bigpond_minheartbeatinterval'] = $config['bigpond']['minheartbeatinterval'];
60
61
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
62
63
if ($wancfg['ipaddr'] == "dhcp") {
64
	$pconfig['type'] = "DHCP";
65
} else if ($wancfg['ipaddr'] == "pppoe") {
66
	$pconfig['type'] = "PPPoE";
67
} else if ($wancfg['ipaddr'] == "pptp") {
68
	$pconfig['type'] = "PPTP";
69
} else if ($wancfg['ipaddr'] == "bigpond") {
70
	$pconfig['type'] = "BigPond";
71
} else {
72
	$pconfig['type'] = "Static";
73
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
74
	$pconfig['subnet'] = $wancfg['subnet'];
75 588a183b Scott Ullrich
	$pconfig['gateway'] = $config['interfaces']['wan']['gateway'];
76 a23d7248 Scott Ullrich
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
77 5b237745 Scott Ullrich
}
78
79
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
80 ff1955ee Bill Marquette
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
81 5b237745 Scott Ullrich
$pconfig['spoofmac'] = $wancfg['spoofmac'];
82
$pconfig['mtu'] = $wancfg['mtu'];
83
84
/* Wireless interface? */
85 b7f01f59 Bill Marquette
if (isset($wancfg['wireless'])) {
86 5b237745 Scott Ullrich
	require("interfaces_wlan.inc");
87
	wireless_config_init();
88
}
89
90
if ($_POST) {
91
92
	unset($input_errors);
93
	$pconfig = $_POST;
94
95 ee968e4f Scott Ullrich
	if($_POST['gateway'] and $pconfig['gateway'] <> $_POST['gateway']) {
96 6fc5bf35 Scott Ullrich
		/* enumerate slbd gateways and make sure we are not creating a route loop */
97
		if(is_array($config['load_balancer']['lbpool'])) {
98
			foreach($config['load_balancer']['lbpool'] as $lbpool) {
99
				if($lbpool['type'] == "gateway") {
100
				    foreach ((array) $lbpool['servers'] as $server) {
101
			            $svr = split("\|", $server);
102 8bddc5b7 Scott Ullrich
			            if($svr[1] == $pconfig['gateway'])  {
103
			            		$_POST['gateway']  = $pconfig['gateway'];
104 de42a08e Scott Ullrich
			            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the load balancer pools.";
105 8bddc5b7 Scott Ullrich
			            }
106 6fc5bf35 Scott Ullrich
					}
107
				}
108 8bddc5b7 Scott Ullrich
			}
109
			foreach($config['filter']['rule'] as $rule) {
110
				if($rule['gateway'] == $pconfig['gateway']) {
111
	            		$_POST['gateway']  = $pconfig['gateway'];
112
	            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the filter rules via policy based routing.";
113
				}
114
			}
115 6fc5bf35 Scott Ullrich
		}
116
	}
117
118 5b237745 Scott Ullrich
	/* input validation */
119
	if ($_POST['type'] == "Static") {
120
		$reqdfields = explode(" ", "ipaddr subnet gateway");
121
		$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
122
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
123
	} else if ($_POST['type'] == "PPPoE") {
124
		if ($_POST['pppoe_dialondemand']) {
125
			$reqdfields = explode(" ", "username password pppoe_dialondemand pppoe_idletimeout");
126
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
127
		} else {
128
			$reqdfields = explode(" ", "username password");
129
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
130
		}
131
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
132
	} else if ($_POST['type'] == "PPTP") {
133
		if ($_POST['pptp_dialondemand']) {
134
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
135
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
136
		} else {
137
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
138
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
139
		}
140
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
141
	} else if ($_POST['type'] == "BigPond") {
142
		$reqdfields = explode(" ", "bigpond_username bigpond_password");
143
		$reqdfieldsn = explode(",", "BigPond username,BigPond password");
144
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
145
	}
146 e2cd32df Scott Ullrich
147 4f3401e0 Bill Marquette
        /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
148
        $_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
149
150 5b237745 Scott Ullrich
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
151
		$input_errors[] = "A valid IP address must be specified.";
152
	}
153
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
154
		$input_errors[] = "A valid subnet bit count must be specified.";
155
	}
156
	if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
157
		$input_errors[] = "A valid gateway must be specified.";
158
	}
159 a23d7248 Scott Ullrich
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
160
		$input_errors[] = "A valid point-to-point IP address must be specified.";
161
	}
162 5b237745 Scott Ullrich
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
163
		$input_errors[] = "The service name contains invalid characters.";
164
	}
165 a23d7248 Scott Ullrich
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
166 5b237745 Scott Ullrich
		$input_errors[] = "The idle timeout value must be an integer.";
167
	}
168
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) {
169
		$input_errors[] = "A valid PPTP local IP address must be specified.";
170
	}
171
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) {
172
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
173
	}
174
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) {
175
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
176
	}
177 a23d7248 Scott Ullrich
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
178 5b237745 Scott Ullrich
		$input_errors[] = "The idle timeout value must be an integer.";
179
	}
180
	if (($_POST['bigpond_authserver'] && !is_domain($_POST['bigpond_authserver']))) {
181
		$input_errors[] = "The authentication server name contains invalid characters.";
182
	}
183
	if (($_POST['bigpond_authdomain'] && !is_domain($_POST['bigpond_authdomain']))) {
184
		$input_errors[] = "The authentication domain name contains invalid characters.";
185
	}
186
	if ($_POST['bigpond_minheartbeatinterval'] && !is_numericint($_POST['bigpond_minheartbeatinterval'])) {
187
		$input_errors[] = "The minimum heartbeat interval must be an integer.";
188
	}
189
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
190
		$input_errors[] = "A valid MAC address must be specified.";
191
	}
192
	if ($_POST['mtu'] && (($_POST['mtu'] < 576) || ($_POST['mtu'] > 1500))) {
193
		$input_errors[] = "The MTU must be between 576 and 1500 bytes.";
194
	}
195 e2cd32df Scott Ullrich
196 5b237745 Scott Ullrich
	/* Wireless interface? */
197 b7f01f59 Bill Marquette
	if (isset($wancfg['wireless'])) {
198 5b237745 Scott Ullrich
		$wi_input_errors = wireless_config_post();
199
		if ($wi_input_errors) {
200
			$input_errors = array_merge($input_errors, $wi_input_errors);
201
		}
202
	}
203
204
	if (!$input_errors) {
205 e2cd32df Scott Ullrich
206 9a6757a1 Scott Ullrich
		$bridge = discover_bridge($wancfg['if'], filter_translate_type_to_real_interface($wancfg['bridge']));
207 0d429e43 Scott Ullrich
		if($bridge <> "-1") {
208 1665e79c Scott Ullrich
			destroy_bridge($bridge);
209 91e8aab2 Scott Ullrich
		}
210 b1c525ee Scott Ullrich
211 5b237745 Scott Ullrich
		unset($wancfg['ipaddr']);
212
		unset($wancfg['subnet']);
213 588a183b Scott Ullrich
		unset($config['interfaces']['wan']['gateway']);
214 a23d7248 Scott Ullrich
		unset($wancfg['pointtopoint']);
215 5b237745 Scott Ullrich
		unset($wancfg['dhcphostname']);
216
		unset($config['pppoe']['username']);
217
		unset($config['pppoe']['password']);
218
		unset($config['pppoe']['provider']);
219
		unset($config['pppoe']['ondemand']);
220
		unset($config['pppoe']['timeout']);
221
		unset($config['pptp']['username']);
222
		unset($config['pptp']['password']);
223
		unset($config['pptp']['local']);
224
		unset($config['pptp']['subnet']);
225
		unset($config['pptp']['remote']);
226
		unset($config['pptp']['ondemand']);
227
		unset($config['pptp']['timeout']);
228
		unset($config['bigpond']['username']);
229
		unset($config['bigpond']['password']);
230
		unset($config['bigpond']['authserver']);
231
		unset($config['bigpond']['authdomain']);
232
		unset($config['bigpond']['minheartbeatinterval']);
233 c1ec2c2f Scott Ullrich
		unset($wancfg['disableftpproxy']);
234 b1c525ee Scott Ullrich
235 c1ec2c2f Scott Ullrich
		/* per interface pftpx helper */
236
		if($_POST['disableftpproxy'] == "yes") {
237
			$wancfg['disableftpproxy'] = true;
238
			system_start_ftp_helpers();
239 b1c525ee Scott Ullrich
		} else {
240 c1ec2c2f Scott Ullrich
			system_start_ftp_helpers();
241
		}
242 e2cd32df Scott Ullrich
243 5b237745 Scott Ullrich
		if ($_POST['type'] == "Static") {
244
			$wancfg['ipaddr'] = $_POST['ipaddr'];
245
			$wancfg['subnet'] = $_POST['subnet'];
246 588a183b Scott Ullrich
			$config['interfaces']['wan']['gateway'] = $_POST['gateway'];
247 a23d7248 Scott Ullrich
			if (isset($wancfg['ispointtopoint']))
248
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
249 5b237745 Scott Ullrich
		} else if ($_POST['type'] == "DHCP") {
250
			$wancfg['ipaddr'] = "dhcp";
251
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
252
		} else if ($_POST['type'] == "PPPoE") {
253
			$wancfg['ipaddr'] = "pppoe";
254
			$config['pppoe']['username'] = $_POST['username'];
255
			$config['pppoe']['password'] = $_POST['password'];
256
			$config['pppoe']['provider'] = $_POST['provider'];
257 a23d7248 Scott Ullrich
			$config['pppoe']['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
258 5b237745 Scott Ullrich
			$config['pppoe']['timeout'] = $_POST['pppoe_idletimeout'];
259
		} else if ($_POST['type'] == "PPTP") {
260
			$wancfg['ipaddr'] = "pptp";
261
			$config['pptp']['username'] = $_POST['pptp_username'];
262
			$config['pptp']['password'] = $_POST['pptp_password'];
263
			$config['pptp']['local'] = $_POST['pptp_local'];
264
			$config['pptp']['subnet'] = $_POST['pptp_subnet'];
265
			$config['pptp']['remote'] = $_POST['pptp_remote'];
266 a23d7248 Scott Ullrich
			$config['pptp']['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
267 5b237745 Scott Ullrich
			$config['pptp']['timeout'] = $_POST['pptp_idletimeout'];
268
		} else if ($_POST['type'] == "BigPond") {
269
			$wancfg['ipaddr'] = "bigpond";
270
			$config['bigpond']['username'] = $_POST['bigpond_username'];
271
			$config['bigpond']['password'] = $_POST['bigpond_password'];
272
			$config['bigpond']['authserver'] = $_POST['bigpond_authserver'];
273
			$config['bigpond']['authdomain'] = $_POST['bigpond_authdomain'];
274
			$config['bigpond']['minheartbeatinterval'] = $_POST['bigpond_minheartbeatinterval'];
275
		}
276 e2cd32df Scott Ullrich
277 90ebf755 Scott Ullrich
		if($_POST['blockpriv'] == "yes")
278
			$wancfg['blockpriv'] = true;
279
		else
280 42a58cb9 Scott Ullrich
			unset($wancfg['blockpriv']);
281 b1c525ee Scott Ullrich
282 90ebf755 Scott Ullrich
		if($_POST['blockbogons'] == "yes")
283
			$wancfg['blockbogons'] = true;
284
		else
285
			unset($wancfg['blockbogons']);
286 b1c525ee Scott Ullrich
287 5b237745 Scott Ullrich
		$wancfg['spoofmac'] = $_POST['spoofmac'];
288
		$wancfg['mtu'] = $_POST['mtu'];
289 e2cd32df Scott Ullrich
290 5b237745 Scott Ullrich
		write_config();
291 e2cd32df Scott Ullrich
292 5b237745 Scott Ullrich
		$retval = 0;
293 11a4b1a0 Scott Ullrich
294 824edb6c Scott Ullrich
		$savemsg = get_std_save_message($retval);
295 5b237745 Scott Ullrich
	}
296
}
297 7f43ca88 Scott Ullrich
298
$pgtitle = "Interfaces: WAN";
299
include("head.inc");
300
301 5b237745 Scott Ullrich
?>
302 7f43ca88 Scott Ullrich
303 5b237745 Scott Ullrich
<script language="JavaScript">
304
<!--
305
function enable_change(enable_change) {
306
	if (document.iform.pppoe_dialondemand.checked || enable_change) {
307
		document.iform.pppoe_idletimeout.disabled = 0;
308
	} else {
309
		document.iform.pppoe_idletimeout.disabled = 1;
310
	}
311
}
312
313
function enable_change_pptp(enable_change_pptp) {
314
	if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
315
		document.iform.pptp_idletimeout.disabled = 0;
316
		document.iform.pptp_local.disabled = 0;
317
		document.iform.pptp_remote.disabled = 0;
318
	} else {
319
		document.iform.pptp_idletimeout.disabled = 1;
320
	}
321
}
322
323
function type_change(enable_change,enable_change_pptp) {
324
	switch (document.iform.type.selectedIndex) {
325
		case 0:
326
			document.iform.username.disabled = 1;
327
			document.iform.password.disabled = 1;
328
			document.iform.provider.disabled = 1;
329
			document.iform.pppoe_dialondemand.disabled = 1;
330
			document.iform.pppoe_idletimeout.disabled = 1;
331
			document.iform.ipaddr.disabled = 0;
332
			document.iform.subnet.disabled = 0;
333
			document.iform.gateway.disabled = 0;
334
			document.iform.pptp_username.disabled = 1;
335
			document.iform.pptp_password.disabled = 1;
336
			document.iform.pptp_local.disabled = 1;
337
			document.iform.pptp_subnet.disabled = 1;
338
			document.iform.pptp_remote.disabled = 1;
339
			document.iform.pptp_dialondemand.disabled = 1;
340
			document.iform.pptp_idletimeout.disabled = 1;
341
			document.iform.bigpond_username.disabled = 1;
342
			document.iform.bigpond_password.disabled = 1;
343
			document.iform.bigpond_authserver.disabled = 1;
344
			document.iform.bigpond_authdomain.disabled = 1;
345
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
346
			document.iform.dhcphostname.disabled = 1;
347
			break;
348
		case 1:
349
			document.iform.username.disabled = 1;
350
			document.iform.password.disabled = 1;
351
			document.iform.provider.disabled = 1;
352
			document.iform.pppoe_dialondemand.disabled = 1;
353
			document.iform.pppoe_idletimeout.disabled = 1;
354
			document.iform.ipaddr.disabled = 1;
355
			document.iform.subnet.disabled = 1;
356
			document.iform.gateway.disabled = 1;
357
			document.iform.pptp_username.disabled = 1;
358
			document.iform.pptp_password.disabled = 1;
359
			document.iform.pptp_local.disabled = 1;
360
			document.iform.pptp_subnet.disabled = 1;
361
			document.iform.pptp_remote.disabled = 1;
362
			document.iform.pptp_dialondemand.disabled = 1;
363
			document.iform.pptp_idletimeout.disabled = 1;
364
			document.iform.bigpond_username.disabled = 1;
365
			document.iform.bigpond_password.disabled = 1;
366
			document.iform.bigpond_authserver.disabled = 1;
367
			document.iform.bigpond_authdomain.disabled = 1;
368
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
369
			document.iform.dhcphostname.disabled = 0;
370
			break;
371
		case 2:
372
			document.iform.username.disabled = 0;
373
			document.iform.password.disabled = 0;
374
			document.iform.provider.disabled = 0;
375
			document.iform.pppoe_dialondemand.disabled = 0;
376
			if (document.iform.pppoe_dialondemand.checked || enable_change) {
377
				document.iform.pppoe_idletimeout.disabled = 0;
378
			} else {
379
				document.iform.pppoe_idletimeout.disabled = 1;
380
			}
381
			document.iform.ipaddr.disabled = 1;
382
			document.iform.subnet.disabled = 1;
383
			document.iform.gateway.disabled = 1;
384
			document.iform.pptp_username.disabled = 1;
385
			document.iform.pptp_password.disabled = 1;
386
			document.iform.pptp_local.disabled = 1;
387
			document.iform.pptp_subnet.disabled = 1;
388
			document.iform.pptp_remote.disabled = 1;
389
			document.iform.pptp_dialondemand.disabled = 1;
390
			document.iform.pptp_idletimeout.disabled = 1;
391
			document.iform.bigpond_username.disabled = 1;
392
			document.iform.bigpond_password.disabled = 1;
393
			document.iform.bigpond_authserver.disabled = 1;
394
			document.iform.bigpond_authdomain.disabled = 1;
395
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
396
			document.iform.dhcphostname.disabled = 1;
397
			break;
398
		case 3:
399
			document.iform.username.disabled = 1;
400
			document.iform.password.disabled = 1;
401
			document.iform.provider.disabled = 1;
402
			document.iform.pppoe_dialondemand.disabled = 1;
403
			document.iform.pppoe_idletimeout.disabled = 1;
404
			document.iform.ipaddr.disabled = 1;
405
			document.iform.subnet.disabled = 1;
406
			document.iform.gateway.disabled = 1;
407
			document.iform.pptp_username.disabled = 0;
408
			document.iform.pptp_password.disabled = 0;
409
			document.iform.pptp_local.disabled = 0;
410
			document.iform.pptp_subnet.disabled = 0;
411
			document.iform.pptp_remote.disabled = 0;
412
			document.iform.pptp_dialondemand.disabled = 0;
413
			if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
414
				document.iform.pptp_idletimeout.disabled = 0;
415
			} else {
416
				document.iform.pptp_idletimeout.disabled = 1;
417
			}
418
			document.iform.bigpond_username.disabled = 1;
419
			document.iform.bigpond_password.disabled = 1;
420
			document.iform.bigpond_authserver.disabled = 1;
421
			document.iform.bigpond_authdomain.disabled = 1;
422
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
423
			document.iform.dhcphostname.disabled = 1;
424
			break;
425
		case 4:
426
			document.iform.username.disabled = 1;
427
			document.iform.password.disabled = 1;
428
			document.iform.provider.disabled = 1;
429
			document.iform.pppoe_dialondemand.disabled = 1;
430
			document.iform.pppoe_idletimeout.disabled = 1;
431
			document.iform.ipaddr.disabled = 1;
432
			document.iform.subnet.disabled = 1;
433
			document.iform.gateway.disabled = 1;
434
			document.iform.pptp_username.disabled = 1;
435
			document.iform.pptp_password.disabled = 1;
436
			document.iform.pptp_local.disabled = 1;
437
			document.iform.pptp_subnet.disabled = 1;
438
			document.iform.pptp_remote.disabled = 1;
439
			document.iform.pptp_dialondemand.disabled = 1;
440
			document.iform.pptp_idletimeout.disabled = 1;
441
			document.iform.bigpond_username.disabled = 0;
442
			document.iform.bigpond_password.disabled = 0;
443
			document.iform.bigpond_authserver.disabled = 0;
444
			document.iform.bigpond_authdomain.disabled = 0;
445
			document.iform.bigpond_minheartbeatinterval.disabled = 0;
446
			document.iform.dhcphostname.disabled = 1;
447
			break;
448
	}
449
}
450
//-->
451
</script>
452
453
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
454
<?php include("fbegin.inc"); ?>
455 931066a8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
456 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
457
<?php if ($savemsg) print_info_box($savemsg); ?>
458
            <form action="interfaces_wan.php" method="post" name="iform" id="iform">
459
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
460 e2cd32df Scott Ullrich
                <tr>
461 8fdc8744 Bill Marquette
                  <td colspan="2" valign="top" class="listtopic">General configuration</td>
462
                </tr>
463
                <tr>
464
                  <td valign="middle" class="vncell"><strong>Type</strong></td>
465
                  <td class="vtable"> <select name="type" class="formfld" id="type" onchange="type_change()">
466 5b237745 Scott Ullrich
                      <?php $opts = split(" ", "Static DHCP PPPoE PPTP BigPond");
467
				foreach ($opts as $opt): ?>
468 e2cd32df Scott Ullrich
                      <option <?php if ($opt == $pconfig['type']) echo "selected";?>>
469 5b237745 Scott Ullrich
                      <?=htmlspecialchars($opt);?>
470
                      </option>
471
                      <?php endforeach; ?>
472
                    </select></td>
473
                </tr>
474 e2cd32df Scott Ullrich
                <tr>
475 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MAC address</td>
476 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="spoofmac" type="text" class="formfld" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
477 1e694bee Scott Ullrich
		    <?php
478
			$ip = getenv('REMOTE_ADDR');
479
			$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
480
			$mac = str_replace("\n","",$mac);
481
		    ?>
482 b1c525ee Scott Ullrich
		    <a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Copy my MAC address</a>
483 1e694bee Scott Ullrich
		    <br>
484 e2cd32df Scott Ullrich
                    This field can be used to modify (&quot;spoof&quot;) the MAC
485 5b237745 Scott Ullrich
                    address of the WAN interface<br>
486
                    (may be required with some cable connections)<br>
487 e2cd32df Scott Ullrich
                    Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
488 5b237745 Scott Ullrich
                    or leave blank</td>
489
                </tr>
490 e2cd32df Scott Ullrich
                <tr>
491 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MTU</td>
492 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="mtu" type="text" class="formfld" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
493 5b237745 Scott Ullrich
                    <br>
494 e2cd32df Scott Ullrich
                    If you enter a value in this field, then MSS clamping for
495
                    TCP connections to the value entered above minus 40 (TCP/IP
496
                    header size) will be in effect. If you leave this field blank,
497
                    an MTU of 1492 bytes for PPPoE and 1500 bytes for all other
498 5b237745 Scott Ullrich
                    connection types will be assumed.</td>
499
                </tr>
500 e2cd32df Scott Ullrich
                <tr>
501 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
502
                </tr>
503 e2cd32df Scott Ullrich
                <tr>
504 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
505 5b237745 Scott Ullrich
                </tr>
506 e2cd32df Scott Ullrich
                <tr>
507 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">IP address</td>
508
                  <td class="vtable"> <input name="ipaddr" type="text" class="formfld" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
509 e2cd32df Scott Ullrich
                    /
510 5b237745 Scott Ullrich
                    <select name="subnet" class="formfld" id="subnet">
511 fa3b333d Scott Ullrich
			<?php
512
			for ($i = 32; $i > 0; $i--) {
513
				if($i <> 31) {
514
					echo "<option value=\"{$i}\" ";
515
					if ($i == $pconfig['subnet']) echo "selected";
516
					echo ">" . $i . "</option>";
517
				}
518
			}
519
			?>
520 5b237745 Scott Ullrich
                    </select></td>
521 a23d7248 Scott Ullrich
                </tr><?php if (isset($wancfg['ispointtopoint'])): ?>
522 7f5b4824 Scott Ullrich
                <tr>
523 a23d7248 Scott Ullrich
                  <td valign="top" class="vncellreq">Point-to-point IP address </td>
524
                  <td class="vtable">
525
                    <input name="pointtopoint" type="text" class="formfld" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
526
                  </td>
527
                </tr><?php endif; ?>
528 e2cd32df Scott Ullrich
                <tr>
529 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Gateway</td>
530 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="gateway" type="text" class="formfld" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>">
531 5b237745 Scott Ullrich
                  </td>
532
                </tr>
533 e2cd32df Scott Ullrich
                <tr>
534 73c38fa2 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
535
                </tr>
536 e2cd32df Scott Ullrich
                <tr>
537 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
538 5b237745 Scott Ullrich
                </tr>
539 e2cd32df Scott Ullrich
                <tr>
540 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Hostname</td>
541
                  <td class="vtable"> <input name="dhcphostname" type="text" class="formfld" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
542
                    <br>
543 e2cd32df Scott Ullrich
                    The value in this field is sent as the DHCP client identifier
544
                    and hostname when requesting a DHCP lease. Some ISPs may require
545 5b237745 Scott Ullrich
                    this (for client identification).</td>
546
                </tr>
547 e2cd32df Scott Ullrich
                <tr>
548 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
549
                </tr>
550 e2cd32df Scott Ullrich
                <tr>
551 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
552 5b237745 Scott Ullrich
                </tr>
553 e2cd32df Scott Ullrich
                <tr>
554 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
555 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="username" type="text" class="formfld" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
556 5b237745 Scott Ullrich
                  </td>
557
                </tr>
558 e2cd32df Scott Ullrich
                <tr>
559 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
560 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="password" type="text" class="formfld" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
561 5b237745 Scott Ullrich
                  </td>
562
                </tr>
563 e2cd32df Scott Ullrich
                <tr>
564 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Service name</td>
565 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="provider" type="text" class="formfld" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
566
                    <br> <span class="vexpl">Hint: this field can usually be left
567 5b237745 Scott Ullrich
                    empty</span></td>
568
                </tr>
569 e2cd32df Scott Ullrich
                <tr>
570 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Dial on demand</td>
571 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?> onClick="enable_change(false)" >
572 5b237745 Scott Ullrich
                    <strong>Enable Dial-On-Demand mode</strong><br>
573
		    This option causes the interface to operate in dial-on-demand mode, allowing you to have a <i>virtual full time</i> connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected.</td>
574
                </tr>
575
                <tr>
576
                  <td valign="top" class="vncell">Idle timeout</td>
577
                  <td class="vtable">
578 fa3b333d Scott Ullrich
                    <input name="pppoe_idletimeout" type="text" class="formfld" id="pppoe_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pppoe_idletimeout']);?>"> seconds<br>If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature.</td>
579 5b237745 Scott Ullrich
                </tr>
580 e2cd32df Scott Ullrich
                <tr>
581 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
582
                </tr>
583 e2cd32df Scott Ullrich
                <tr>
584 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
585 5b237745 Scott Ullrich
                </tr>
586 e2cd32df Scott Ullrich
                <tr>
587 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
588 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pptp_username" type="text" class="formfld" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
589 5b237745 Scott Ullrich
                  </td>
590
                </tr>
591 e2cd32df Scott Ullrich
                <tr>
592 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
593 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pptp_password" type="text" class="formfld" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
594 5b237745 Scott Ullrich
                  </td>
595
                </tr>
596 e2cd32df Scott Ullrich
                <tr>
597 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">Local IP address</td>
598
                  <td class="vtable"> <input name="pptp_local" type="text" class="formfld" id="pptp_local" size="20" value="<?=htmlspecialchars($pconfig['pptp_local']);?>">
599 e2cd32df Scott Ullrich
                    /
600 5b237745 Scott Ullrich
                    <select name="pptp_subnet" class="formfld" id="pptp_subnet">
601 a23d7248 Scott Ullrich
                      <?php for ($i = 31; $i > 0; $i--): ?>
602 e2cd32df Scott Ullrich
                      <option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet']) echo "selected"; ?>>
603 5b237745 Scott Ullrich
                      <?=$i;?>
604
                      </option>
605
                      <?php endfor; ?>
606
                    </select></td>
607
                </tr>
608 e2cd32df Scott Ullrich
                <tr>
609 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">Remote IP address</td>
610 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="pptp_remote" type="text" class="formfld" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote']);?>">
611 5b237745 Scott Ullrich
                  </td>
612
                </tr>
613 e2cd32df Scott Ullrich
                <tr>
614 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Dial on demand</td>
615 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?> onClick="enable_change_pptp(false)" >
616 5b237745 Scott Ullrich
                    <strong>Enable Dial-On-Demand mode</strong><br>
617
		    This option causes the interface to operate in dial-on-demand mode, allowing you to have a <i>virtual full time</i> connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected.</td>
618
                </tr>
619
                <tr>
620
                  <td valign="top" class="vncell">Idle timeout</td>
621
                  <td class="vtable">
622 fa3b333d Scott Ullrich
                    <input name="pptp_idletimeout" type="text" class="formfld" id="pptp_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pptp_idletimeout']);?>"> seconds<br>If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature.</td>
623 5b237745 Scott Ullrich
                </tr>
624 e2cd32df Scott Ullrich
                <tr>
625 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
626
                </tr>
627 e2cd32df Scott Ullrich
                <tr>
628 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">BigPond Cable configuration</td>
629 5b237745 Scott Ullrich
                </tr>
630 e2cd32df Scott Ullrich
                <tr>
631 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
632 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="bigpond_username" type="text" class="formfld" id="bigpond_username" size="20" value="<?=htmlspecialchars($pconfig['bigpond_username']);?>">
633 5b237745 Scott Ullrich
                  </td>
634
                </tr>
635 e2cd32df Scott Ullrich
                <tr>
636 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
637 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="bigpond_password" type="text" class="formfld" id="bigpond_password" size="20" value="<?=htmlspecialchars($pconfig['bigpond_password']);?>">
638 5b237745 Scott Ullrich
                  </td>
639
                </tr>
640 e2cd32df Scott Ullrich
                <tr>
641 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Authentication server</td>
642
                  <td class="vtable"><input name="bigpond_authserver" type="text" class="formfld" id="bigpond_authserver" size="20" value="<?=htmlspecialchars($pconfig['bigpond_authserver']);?>">
643
                    <br>
644
                  <span class="vexpl">If this field is left empty, the default (&quot;dce-server&quot;) is used. </span></td>
645
                </tr>
646 e2cd32df Scott Ullrich
                <tr>
647 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Authentication domain</td>
648
                  <td class="vtable"><input name="bigpond_authdomain" type="text" class="formfld" id="bigpond_authdomain" size="20" value="<?=htmlspecialchars($pconfig['bigpond_authdomain']);?>">
649
                    <br>
650
                  <span class="vexpl">If this field is left empty, the domain name assigned via DHCP will be used.<br>
651
                  <br>
652
                  Note: the BigPond client implicitly sets the &quot;Allow DNS server list to be overridden by DHCP/PPP on WAN&quot; on the System: General setup page.            </span></td>
653
                </tr>
654
                <tr>
655
                  <td valign="top" class="vncell">Min. heartbeat interval</td>
656
                  <td class="vtable">
657 fa3b333d Scott Ullrich
                    <input name="bigpond_minheartbeatinterval" type="text" class="formfld" id="bigpond_minheartbeatinterval" size="8" value="<?=htmlspecialchars($pconfig['bigpond_minheartbeatinterval']);?>">seconds<br>Setting this to a sensible value (e.g. 60 seconds) can protect against DoS attacks. </td>
658 5b237745 Scott Ullrich
                </tr>
659 da56c4d7 Scott Ullrich
                <tr>
660
                  <td colspan="2" valign="top" height="16"></td>
661
                </tr>
662
                <tr>
663
                  <td colspan="2" valign="top" class="listtopic">FTP Helper</td>
664 b1c525ee Scott Ullrich
                </tr>
665 da56c4d7 Scott Ullrich
		<tr>
666
			<td width="22%" valign="top" class="vncell">FTP Helper</td>
667
			<td width="78%" class="vtable">
668 0135299b Scott Ullrich
				<input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if ($pconfig['disableftpproxy']) echo "checked"; ?> onclick="enable_change(false)" />
669 da56c4d7 Scott Ullrich
				<strong>Disable the userland FTP-Proxy application</strong>
670
				<br />
671
			</td>
672
		</tr>
673 fa3b333d Scott Ullrich
		        <?php
674
				/* Wireless interface? */
675 b7f01f59 Bill Marquette
				if (isset($wancfg['wireless']))
676 5b237745 Scott Ullrich
					wireless_config_print();
677 fa3b333d Scott Ullrich
			?>
678 e2cd32df Scott Ullrich
                <tr>
679 5b237745 Scott Ullrich
                  <td height="16" colspan="2" valign="top"></td>
680
                </tr>
681 e2cd32df Scott Ullrich
                <tr>
682 5b237745 Scott Ullrich
                  <td valign="middle">&nbsp;</td>
683 d9eeccbd Scott Ullrich
                  <td class="vtable"><a name="rfc1918"></a> <input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
684 5b237745 Scott Ullrich
                    <strong>Block private networks</strong><br>
685 e2cd32df Scott Ullrich
                    When set, this option blocks traffic from IP addresses that
686 5b237745 Scott Ullrich
                    are reserved for private<br>
687 e2cd32df Scott Ullrich
                    networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as
688 5b237745 Scott Ullrich
                    well as loopback addresses<br>
689 e2cd32df Scott Ullrich
                    (127/8). You should generally leave this option turned on,
690 5b237745 Scott Ullrich
                    unless your WAN network<br>
691
                    lies in such a private address space, too.</td>
692
                </tr>
693 ff1955ee Bill Marquette
                <tr>
694
                  <td valign="middle">&nbsp;</td>
695
                  <td class="vtable"> <input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
696
                    <strong>Block bogon networks</strong><br>
697
                    When set, this option blocks traffic from IP addresses that
698
                    are reserved (but not RFC 1918) or not yet assigned by IANA.<br>
699
                    Bogons are prefixes that should never appear in the Internet routing table, and obviously should not appear as the source address in any packets you receive.</td>
700 c1ec2c2f Scott Ullrich
		</tr>
701 b1c525ee Scott Ullrich
702 e2cd32df Scott Ullrich
                <tr>
703 5b237745 Scott Ullrich
                  <td width="100" valign="top">&nbsp;</td>
704 e2cd32df Scott Ullrich
                  <td> &nbsp;<br> <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change_pptp(true)&&enable_change(true)">
705 5b237745 Scott Ullrich
                  </td>
706
                </tr>
707
              </table>
708
</form>
709
<script language="JavaScript">
710
<!--
711
type_change();
712
//-->
713
</script>
714
<?php include("fend.inc"); ?>
715
</body>
716
</html>
717 e4e8c30f Scott Ullrich
718
719
<?php
720
721
if ($_POST) {
722
723
	if (!$input_errors) {
724 b1c525ee Scott Ullrich
725
		unlink_if_exists("{$g['tmp_path']}/config.cache");
726
727 2e70a096 Scott Ullrich
		ob_flush();
728
		flush();
729 b1c525ee Scott Ullrich
		sleep(1);
730
731 e4e8c30f Scott Ullrich
		interfaces_wan_configure();
732 b1c525ee Scott Ullrich
733 610b1136 Scott Ullrich
		reset_carp();
734 b1c525ee Scott Ullrich
735 e4e8c30f Scott Ullrich
		/* sync filter configuration */
736
		filter_configure();
737
	}
738
}
739
740
?>