Project

General

Profile

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