Project

General

Profile

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