Project

General

Profile

Download (76.3 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces.php
5
	Copyright (C) 2004-2008 Scott Ullrich
6
	Copyright (C) 2006 Daniel S. Haischt.
7
	Copyright (C) 2008 Ermal Lu?i
8
	All rights reserved.
9

    
10
	originally part of m0n0wall (http://m0n0.ch/wall)
11
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13

    
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16

    
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19

    
20
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23

    
24
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35
/*
36
	pfSense_BUILDER_BINARIES:	/usr/sbin/arp
37
	pfSense_MODULE:	interfaces
38
*/
39

    
40
##|+PRIV
41
##|*IDENT=page-interfaces
42
##|*NAME=Interfaces: WAN page
43
##|*DESCR=Allow access to the 'Interfaces' page.
44
##|*MATCH=interfaces.php*
45
##|-PRIV
46

    
47
require("guiconfig.inc");
48
require("ipsec.inc");
49
require("functions.inc");
50
require("captiveportal.inc");
51
require("filter.inc");
52
require("shaper.inc");
53
require("rrd.inc");
54
require("vpn.inc");
55
require('regdomain.inc');
56

    
57
if ($_REQUEST['if']) {
58
	$if = $_REQUEST['if'];
59
} else {
60
	$if = "wan";
61
}
62

    
63
define("CRON_PPPOE_CMD_FILE", "/conf/pppoe{$if}restart");
64
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
65
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
66
define("CRON_DAILY_PATTERN", "0 0 * * *");
67
define("CRON_HOURLY_PATTERN", "0 * * * *");
68

    
69
function getMPDCRONSettings() {
70
	global $config;
71
	if (is_array($config['cron']['item'])) {
72
		for ($i = 0; $i < count($config['cron']['item']); $i++) {
73
			$item = $config['cron']['item'][$i];
74
			if (strpos($item['command'], CRON_PPPOE_CMD_FILE) !== false) {
75
				return array("ID" => $i, "ITEM" => $item);
76
			}
77
		}
78
	}
79
	return NULL;
80
}
81

    
82
function getMPDResetTimeFromConfig() {
83
	$itemhash = getMPDCRONSettings();
84
	$cronitem = $itemhash['ITEM'];
85
	if (isset($cronitem)) {
86
		return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
87
	} else {
88
		return NULL;
89
	}
90
}
91

    
92
function remove_bad_chars($string) {
93
	return preg_replace('/[^a-z|_|0-9]/i','',$string);
94
}
95

    
96
if (!is_array($config['gateways']['gateway_item']))
97
	$config['gateways']['gateway_item'] = array();
98

    
99
$a_gateways = &$config['gateways']['gateway_item'];
100

    
101
$wancfg = &$config['interfaces'][$if];
102

    
103
$pconfig['pppoe_username'] = $wancfg['pppoe_username'];
104
$pconfig['pppoe_password'] = $wancfg['pppoe_password'];
105
$pconfig['provider'] = $wancfg['provider'];
106
$pconfig['pppoe_dialondemand'] = isset($wancfg['ondemand']);
107
$pconfig['pppoe_idletimeout'] = $wancfg['timeout'];
108

    
109
/* ================================================ */
110
/* = force a connection reset at a specific time? = */
111
/* ================================================ */
112

    
113
if (isset($wancfg['pppoe']['pppoe-reset-type'])) {
114
	$resetTime = getMPDResetTimeFromConfig();  
115
	$pconfig['pppoe_preset'] = true;
116
	if ($wancfg['pppoe']['pppoe-reset-type'] == "custom") {
117
		$resetTime_a = split(" ", $resetTime);
118
		$pconfig['pppoe_pr_custom'] = true;
119
		$pconfig['pppoe_resetminute'] = $resetTime_a[0];
120
		$pconfig['pppoe_resethour'] = $resetTime_a[1];
121
		/*  just initialize $pconfig['pppoe_resetdate'] if the
122
		 *  coresponding item contains appropriate numeric values.
123
		 */
124
		if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*") 
125
			$pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
126
	} else if ($wancfg['pppoe']['pppoe-reset-type'] == "preset") {
127
		$pconfig['pppoe_pr_preset'] = true;
128
		switch ($resetTime) {
129
			case CRON_MONTHLY_PATTERN:
130
				$pconfig['pppoe_monthly'] = true;
131
				break;
132
			case CRON_WEEKLY_PATTERN:
133
				$pconfig['pppoe_weekly'] = true;
134
				break;
135
			case CRON_DAILY_PATTERN:
136
				$pconfig['pppoe_daily'] = true;
137
				break;
138
			case CRON_HOURLY_PATTERN:
139
				$pconfig['pppoe_hourly'] = true;
140
				break;
141
		}
142
	}
143
}
144

    
145
$pconfig['pptp_username'] = $wancfg['pptp_username'];
146
$pconfig['pptp_password'] = $wancfg['pptp_password'];
147
$pconfig['pptp_local'] = $wancfg['local'];
148
$pconfig['pptp_subnet'] = $wancfg['subnet'];
149
$pconfig['pptp_remote'] = $wancfg['remote'];
150
$pconfig['pptp_dialondemand'] = isset($wancfg['ondemand']);
151
$pconfig['pptp_idletimeout'] = $wancfg['timeout'];
152

    
153
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
154
$pconfig['alias-address'] = $wancfg['alias-address'];
155
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
156

    
157
// Populate page descr if it does not exist.
158
if($if == "wan" && !$wancfg['descr']) {
159
	$wancfg['descr'] = "WAN";
160
} else if ($if == "lan" && !$wancfg['descr']) {
161
	$wancfg['descr'] = "LAN";
162
}
163
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
164

    
165
if ($if == "wan" || $if == "lan")
166
	$pconfig['enable'] = true;
167
else
168
	$pconfig['enable'] = isset($wancfg['enable']);
169

    
170
if (is_array($config['aliases']['alias'])) {
171
	foreach($config['aliases']['alias'] as $alias) {
172
		if($alias['name'] == $wancfg['descr']) {
173
			$input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists.");
174
		}
175
	}
176
}
177

    
178
switch($wancfg['ipaddr']) {
179
	case "dhcp":
180
		$pconfig['type'] = "dhcp";
181
		break;
182
	case "carpdev-dhcp":
183
		$pconfig['type'] = "carpdev-dhcp";
184
		$pconfig['ipaddr'] = "";
185
		break;
186
	case "pppoe":
187
		$pconfig['type'] = "pppoe";
188
		break;
189
	case "pptp":
190
		$pconfig['type'] = "pptp";
191
		break;
192
	default:
193
		if(is_ipaddr($wancfg['ipaddr'])) {
194
			$pconfig['type'] = "static";
195
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
196
			$pconfig['subnet'] = $wancfg['subnet'];
197
			$pconfig['gateway'] = $wancfg['gateway'];
198
			$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
199
		} else {
200
			$pconfig['type'] = "none";
201
		}
202
		break;
203
}
204

    
205
// Handle PPP type interfaces
206
if($wancfg['serialport']) 
207
	$pconfig['type'] = "none";
208

    
209
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
210
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
211
$pconfig['spoofmac'] = $wancfg['spoofmac'];
212
$pconfig['mtu'] = $wancfg['mtu'];
213

    
214
/* Wireless interface? */
215
if (isset($wancfg['wireless'])) {
216
	/* Get wireless modes */
217
	$wlanif = get_real_interface($if);
218
	if (!does_interface_exist($wlanif))
219
		interface_wireless_clone($wlanif, $wancfg);
220
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
221
	$wl_modes = get_wireless_modes($if);
222
	$wl_regdomains = parse_xml_regdomain();
223
	$pconfig['standard'] = $wancfg['wireless']['standard'];
224
	$pconfig['mode'] = $wancfg['wireless']['mode'];
225
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
226
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
227
	$pconfig['channel'] = $wancfg['wireless']['channel'];
228
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
229
	$pconfig['distance'] = $wancfg['wireless']['distance'];
230
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
231
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
232
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
233
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
234
	if (isset($wancfg['wireless']['puren']['enable']))
235
		$pconfig['puremode'] = '11n';
236
	else if (isset($wancfg['wireless']['pureg']['enable']))
237
		$pconfig['puremode'] = '11g';
238
	else
239
		$pconfig['puremode'] = 'any';
240
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
241
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
242
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
243
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
244
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
245
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
246
	if (is_array($wancfg['wireless']['wpa'])) {
247
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
248
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
249
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
250
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
251
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
252
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
253
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
254
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
255
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
256
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
257
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
258
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
259
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
260
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
261
	}
262
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
263
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
264
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
265
		$i = 1;
266
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
267
			$pconfig['key' . $i] = $wepkey['value'];
268
			if (isset($wepkey['txkey']))
269
				$pconfig['txkey'] = $i;
270
			$i++;
271
		}
272
		if (!isset($wepkey['txkey']))
273
			$pconfig['txkey'] = 1;
274
	}
275
}
276

    
277
if ($_POST['apply']) {
278
	unset($input_errors);
279
	if (!is_subsystem_dirty('interfaces'))
280
		$intput_errors[] = "You have already applied your settings!";
281
	else {	
282
		unlink_if_exists("{$g['tmp_path']}/config.cache");
283
		clear_subsystem_dirty('interfaces');
284
		if ($pconfig['enable'])
285
			interface_configure($if, true);
286
		else
287
			interface_bring_down($if);
288
		
289
		/* restart snmp so that it binds to correct address */		
290
		services_snmpd_configure();		
291
		if ($if == "lan") 		
292
			$savemsg = "The changes have been applied.  You may need to correct your web browser's IP address.";
293

    
294
		/* sync filter configuration */
295
		setup_gateways_monitor();
296

    
297
		clear_subsystem_dirty('staticroutes');
298
		
299
		filter_configure();
300
		
301
		enable_rrd_graphing();
302
	}
303
	header("Location: interfaces.php?if={$if}");
304
	exit;
305
} else
306

    
307
if ($_POST && $_POST['enable'] != "yes") {
308
	unset($wancfg['enable']);
309
	if (isset($wancfg['wireless'])) {
310
		interface_sync_wireless_clones($wancfg, false);
311
	}
312
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
313
	mark_subsystem_dirty('interfaces');
314
	header("Location: interfaces.php?if={$if}");
315
	exit;
316
} else
317

    
318
if ($_POST) {
319
	unset($input_errors);
320
	$pconfig = $_POST;
321
	conf_mount_rw();
322
	/* filter out spaces from descriptions  */
323
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
324
	/* okay first of all, cause we are just hiding the PPPoE HTML
325
	 * fields releated to PPPoE resets, we are going to unset $_POST
326
	 * vars, if the reset feature should not be used. Otherwise the
327
	 * data validation procedure below, may trigger a false error
328
	 * message.
329
	 */
330
	if (empty($_POST['pppoe_preset'])) {
331
		unset($_POST['pppoe_pr_type']);                
332
		unset($_POST['pppoe_resethour']);
333
		unset($_POST['pppoe_resetminute']);
334
		unset($_POST['pppoe_resetdate']);
335
		unset($_POST['pppoe_pr_preset_val']);
336
	}
337
	/* optional interface if list */
338
	$iflist = get_configured_interface_with_descr();
339
	/* description unique? */
340
	foreach ($iflist as $ifent => $ifdescr) {
341
		if ($if != $ifent && $ifdescr == $_POST['descr'])
342
			$input_errors[] = "An interface with the specified description already exists.";
343
	}
344
	/* input validation */
345
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && $_POST['type'] != "static")
346
		$input_errors[] = "The DHCP Server is active on this interface and it can be used only with a static IP configuration. Please disable the DHCP Server service on this interface first, then change the interface configuration.";
347

    
348
	switch($_POST['type']) {
349
		case "static":
350
			$reqdfields = explode(" ", "ipaddr subnet gateway");
351
			$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
352
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
353
			break;
354
		case "PPPoE":
355
			if ($_POST['pppoe_dialondemand']) {
356
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
357
				$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
358
			} else {
359
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
360
				$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
361
			}
362
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
363
			break;
364
		case "PPTP":
365
			if ($_POST['pptp_dialondemand']) {
366
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
367
				$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
368
			} else {
369
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
370
				$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
371
			}
372
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
373
			break;
374
	}
375

    
376
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
377
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
378
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) 
379
		$input_errors[] = "A valid IP address must be specified.";
380
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) 
381
		$input_errors[] = "A valid subnet bit count must be specified.";
382
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) 
383
		$input_errors[] = "A valid alias IP address must be specified.";
384
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) 
385
		$input_errors[] = "A valid alias subnet bit count must be specified.";
386
	if ($_POST['gateway'] != "none") {
387
		$match = false;
388
		foreach($a_gateways as $gateway) {
389
			if(in_array($_POST['gateway'], $gateway)) {
390
				$match = true;
391
			}
392
		}
393
		if(!$match) {
394
			$input_errors[] = "A valid gateway must be specified.";
395
		}
396
	}
397
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) 
398
		$input_errors[] = "A valid point-to-point IP address must be specified.";
399
	if (($_POST['provider'] && !is_domain($_POST['provider']))) 
400
		$input_errors[] = "The service name contains invalid characters.";
401
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) 
402
		$input_errors[] = "The idle timeout value must be an integer.";
403
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
404
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) 
405
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
406
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
407
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) 
408
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
409
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) 
410
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
411
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) 
412
		$input_errors[] = "A valid PPTP local IP address must be specified.";
413
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) 
414
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
415
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) 
416
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
417
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) 
418
		$input_errors[] = "The idle timeout value must be an integer.";
419
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) 
420
		$input_errors[] = "A valid MAC address must be specified.";
421
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) 
422
		$input_errors[] = "The MTU must be greater than 576 bytes.";
423
	/* Wireless interface? */
424
	if (isset($wancfg['wireless'])) {
425
		$reqdfields = explode(" ", "mode ssid");
426
		$reqdfieldsn = explode(",", "Mode,SSID");
427
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
428
		check_wireless_mode();
429
		/* loop through keys and enforce size */
430
		for ($i = 1; $i <= 4; $i++) {
431
			if ($_POST['key' . $i]) {
432
				/* 64 bit */
433
				if (strlen($_POST['key' . $i]) == 5)
434
					continue;
435
				if (strlen($_POST['key' . $i]) == 10) {
436
					/* hex key */
437
					if (stristr($_POST['key' . $i], "0x") == false) {
438
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
439
					}
440
					continue;
441
				}
442
				if (strlen($_POST['key' . $i]) == 12) {
443
					/* hex key */
444
					if(stristr($_POST['key' . $i], "0x") == false) {
445
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
446
					}
447
					continue;
448
				}
449
				/* 128 bit */
450
				if (strlen($_POST['key' . $i]) == 13)
451
					continue;
452
				if (strlen($_POST['key' . $i]) == 26) {
453
					/* hex key */
454
					if (stristr($_POST['key' . $i], "0x") == false)
455
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
456
					continue;
457
				}
458
				if(strlen($_POST['key' . $i]) == 28)
459
					continue;
460
				$input_errors[] =  "Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.";
461
				break;
462
			}
463
		}
464

    
465
		if ($_POST['passphrase']) {
466
                	$passlen = strlen($_POST['passphrase']);
467
                	if ($passlen < 8 || $passlen > 64)
468
                        	$input_errors[] = "The length of the passphrase should be between 8 and 63 characters.";
469
		}
470
	}
471
	if (!$input_errors) {
472
		unset($wancfg['ipaddr']);
473
		unset($wancfg['subnet']);
474
		unset($wancfg['gateway']);
475
		unset($wancfg['pointtopoint']);
476
		unset($wancfg['dhcphostname']);
477
		unset($wancfg['pppoe_username']);
478
		unset($wancfg['pppoe_password']);
479
		unset($wancfg['pptp_username']);
480
		unset($wancfg['pptp_password']);
481
		unset($wancfg['provider']);
482
		unset($wancfg['ondemand']);
483
		unset($wancfg['timeout']);
484
		if ($wancfg['pppoe']['pppoe-reset-type'])
485
			unset($wancfg['pppoe']['pppoe-reset-type']);
486
		unset($wancfg['local']);
487
		unset($wancfg['subnet']);
488
		unset($wancfg['remote']);
489

    
490
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
491
		if ($if == "wan" || $if == "lan") {
492
			$wancfg['enable'] = true;
493
		} else {
494
			$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
495
		}
496

    
497
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
498
		 * log messages from appearing. They can also manually add these items */
499
		/* 1st added gateway gets a default bit */
500
		$gateway_item = array();
501
		if(empty($a_gateways)) {
502
			$gateway_item['defaultgw'] = "true";
503
		} else {
504
			/* check for duplicates */
505
			$skip = false;
506
			foreach($a_gateways as $item) {
507
				if(($item['interface'] == "$if") && ($item['gateway'] == "dynamic")) {
508
					$skip = true;
509
				}
510
			}
511
			if($skip == false) {
512
				$gateway_item['gateway'] = "dynamic";
513
				$gateway_item['descr'] = "Interface {$if} dynamic gateway";
514
				$gateway_item['name'] = "GW_" . strtoupper($if);
515
				$gateway_item['interface'] = "{$if}";
516
			} else {
517
				unset($gateway_item);
518
			}
519
		}
520

    
521
		switch($_POST['type']) {
522
			case "static":
523
				$wancfg['ipaddr'] = $_POST['ipaddr'];
524
				$wancfg['subnet'] = $_POST['subnet'];
525
				if ($_POST['gateway'] != "none") {
526
					$wancfg['gateway'] = $_POST['gateway'];
527
				}
528
				if (isset($wancfg['ispointtopoint'])) {
529
					$wancfg['pointtopoint'] = $_POST['pointtopoint'];
530
				}
531
				break;
532
			case "dhcp":
533
				$wancfg['ipaddr'] = "dhcp";
534
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
535
				$wancfg['alias-address'] = $_POST['alias-address'];
536
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
537
				if($gateway_item) {
538
					$a_gateways[] = $gateway_item;
539
				}
540
				break;
541
			case "carpdev-dhcp":
542
				$wancfg['ipaddr'] = "carpdev-dhcp";
543
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
544
				$wancfg['alias-address'] = $_POST['alias-address'];
545
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
546
				if($gateway_item) {
547
					$a_gateways[] = $gateway_item;
548
				}
549
				break;
550
			case "pppoe":
551
				$wancfg['ipaddr'] = "pppoe";
552
				$wancfg['pppoe_username'] = $_POST['pppoe_username'];
553
				$wancfg['pppoe_password'] = $_POST['pppoe_password'];
554
				$wancfg['provider'] = $_POST['provider'];
555
				$wancfg['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
556
				$wancfg['timeout'] = $_POST['pppoe_idletimeout'];
557
				if($gateway_item) {
558
					$a_gateways[] = $gateway_item;
559
				}
560
				break;
561
			case "pptp":
562
				$wancfg['ipaddr'] = "pptp";
563
				$wancfg['pptp_username'] = $_POST['pptp_username'];
564
				$wancfg['pptp_password'] = $_POST['pptp_password'];
565
				$wancfg['local'] = $_POST['pptp_local'];
566
				$wancfg['subnet'] = $_POST['pptp_subnet'];
567
				$wancfg['remote'] = $_POST['pptp_remote'];
568
				$wancfg['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
569
				$wancfg['timeout'] = $_POST['pptp_idletimeout'];
570
				if($gateway_item) {
571
					$a_gateways[] = $gateway_item;
572
				}
573
				break;
574
		}
575
		handle_pppoe_reset();
576
		/* reset cron items if necessary */
577
		if (empty($_POST['pppoe_preset'])) {
578
			/* test whether a cron item exists and unset() it if necessary */
579
			$itemhash = getMPDCRONSettings();
580
			$item = $itemhash['ITEM'];
581
			if (isset($item))
582
				unset($config['cron']['item'][$itemhash['ID']]); 
583
		}
584
		if($_POST['blockpriv'] == "yes") {
585
			$wancfg['blockpriv'] = true;
586
		} else {
587
			unset($wancfg['blockpriv']);
588
		}
589
		if($_POST['blockbogons'] == "yes") {
590
			$wancfg['blockbogons'] = true;
591
		} else {
592
			unset($wancfg['blockbogons']);
593
		}
594
		$wancfg['spoofmac'] = $_POST['spoofmac'];
595
		if (empty($_POST['mtu'])) {
596
			unset($wancfg['mtu']);
597
		} else {
598
			$wancfg['mtu'] = $_POST['mtu'];
599
		}
600
		if (isset($wancfg['wireless'])) {
601
			handle_wireless_post();
602
		}
603
		write_config();
604
		mark_subsystem_dirty('interfaces');
605
		/* regenerate cron settings/crontab file */
606
		configure_cron();
607
		conf_mount_ro();
608
		header("Location: interfaces.php?if={$if}");
609
		exit;
610
	}
611
} // end if($_POST) 
612

    
613
function handle_pppoe_reset() {
614
	global $_POST, $config, $g, $wancfg, $if;
615
	/* perform a periodic reset? */
616
	if(!isset($_POST['pppoe_preset'])) {
617
		setup_pppoe_reset_file($if, false);		
618
		return;
619
	}
620
	if (!is_array($config['cron']['item'])) 
621
		$config['cron']['item'] = array(); 
622
	$itemhash = getMPDCRONSettings();
623
	$item = $itemhash['ITEM'];
624
	if (empty($item)) 
625
		$item = array();
626
	if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] == "custom") {
627
		$wancfg['pppoe']['pppoe-reset-type'] = "custom";
628
		$pconfig['pppoe_pr_custom'] = true;
629
		$item['minute'] = $_POST['pppoe_resetminute'];
630
		$item['hour'] = $_POST['pppoe_resethour'];
631
		if (isset($_POST['pppoe_resetdate']) && $_POST['pppoe_resetdate'] <> "" && strlen($_POST['pppoe_resetdate']) == 10) {
632
			$date = explode("/", $_POST['pppoe_resetdate']);
633
			$item['mday'] = $date[1];
634
			$item['month'] = $date[0];
635
		} else {
636
			$item['mday'] = "*";
637
			$item['month'] = "*";
638
		}
639
		$item['wday'] = "*";
640
		$item['who'] = "root";
641
		$item['command'] = CRON_PPPOE_CMD_FILE;
642
	} else if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] = "preset") {
643
		$wancfg['pppoe']['pppoe-reset-type'] = "preset";
644
		$pconfig['pppoe_pr_preset'] = true;
645
		switch ($_POST['pppoe_pr_preset_val']) {
646
			case "monthly":
647
				$item['minute'] = "0";
648
				$item['hour'] = "0";
649
				$item['mday'] = "1";
650
				$item['month'] = "*";
651
				$item['wday'] = "*";
652
				$item['who'] = "root";
653
				$item['command'] = CRON_PPPOE_CMD_FILE;
654
				break;
655
	        	case "weekly":
656
				$item['minute'] = "0";
657
				$item['hour'] = "0";
658
				$item['mday'] = "*";
659
				$item['month'] = "*";
660
				$item['wday'] = "0";
661
				$item['who'] = "root";
662
				$item['command'] = CRON_PPPOE_CMD_FILE;
663
				break;
664
			case "daily":
665
				$item['minute'] = "0";
666
				$item['hour'] = "0";
667
				$item['mday'] = "*";
668
				$item['month'] = "*";
669
				$item['wday'] = "*";
670
				$item['who'] = "root";
671
				$item['command'] = CRON_PPPOE_CMD_FILE;
672
				break;
673
			case "hourly":
674
				$item['minute'] = "0";
675
				$item['hour'] = "*";
676
				$item['mday'] = "*";
677
				$item['month'] = "*";
678
				$item['wday'] = "*";
679
				$item['who'] = "root";
680
				$item['command'] = CRON_PPPOE_CMD_FILE;
681
				break;
682
		} // end switch
683
	} // end if
684
	if (isset($itemhash['ID'])) 
685
		$config['cron']['item'][$itemhash['ID']] = $item;
686
	else 
687
		$config['cron']['item'][] = $item;
688
	/* finally install the pppoerestart file */
689
	if (isset($_POST['pppoe_preset'])) {
690
		setup_pppoe_reset_file($if, true);
691
		$wancfg['pppoe_reset'] = true;
692
		$wancfg['pppoe_preset'] = true;
693
		sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
694
	} else {
695
		unset($wancfg['pppoe_reset']);
696
		unset($wancfg['pppoe_preset']);		
697
		setup_pppoe_reset_file($if, false);	
698
	}
699
}
700

    
701
function handle_wireless_post() {
702
	global $_POST, $config, $g, $wancfg, $if, $wl_regdomains;
703
	if (!is_array($wancfg['wireless']))
704
		$wancfg['wireless'] = array();
705
	$wancfg['wireless']['standard'] = $_POST['standard'];
706
	$wancfg['wireless']['mode'] = $_POST['mode'];
707
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
708
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
709
	$wancfg['wireless']['channel'] = $_POST['channel'];
710
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
711
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
712
	$wancfg['wireless']['distance'] = $_POST['distance'];
713
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
714
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
715
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
716
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
717
		foreach($wl_regdomains['country-codes']['country'] as $wl_country) {
718
			if ($wancfg['wireless']['regcountry'] == $wl_country['attributes']['ID']) {
719
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['attributes']['REF'];
720
				break;
721
			}
722
		}
723
	}
724
	if (!is_array($wancfg['wireless']['wpa']))
725
		$wancfg['wireless']['wpa'] = array();
726
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
727
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
728
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
729
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
730
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
731
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
732
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
733
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
734
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
735
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
736
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
737
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
738
	if ($_POST['hidessid_enable'] == "yes")
739
		$wancfg['wireless']['hidessid']['enable'] = true;
740
	else if (isset($wancfg['wireless']['hidessid']['enable']))
741
		unset($wancfg['wireless']['hidessid']['enable']);
742
	if ($_POST['mac_acl_enable'] == "yes")
743
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
744
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
745
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
746
	if ($_POST['ieee8021x'] == "yes")
747
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
748
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
749
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
750
	if ($_POST['wpa_strict_rekey'] == "yes")
751
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
752
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
753
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
754
	if ($_POST['debug_mode'] == "yes")
755
		$wancfg['wireless']['wpa']['debug_mode'] = true;
756
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
757
		sunset($wancfg['wireless']['wpa']['debug_mode']);
758
	if ($_POST['wpa_enable'] == "yes")
759
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
760
	else if (isset($wancfg['wireless']['wpa']['enable']))
761
		unset($wancfg['wireless']['wpa']['enable']);
762
	if ($_POST['wep_enable'] == "yes") {
763
		if (!is_array($wancfg['wireless']['wep']))
764
			$wancfg['wireless']['wep'] = array();
765
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
766
	} else if (isset($wancfg['wireless']['wep']))
767
		unset($wancfg['wireless']['wep']);
768
	if ($_POST['wme_enable'] == "yes") {
769
		if (!is_array($wancfg['wireless']['wme']))
770
			$wancfg['wireless']['wme'] = array();
771
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
772
	} else if (isset($wancfg['wireless']['wme']['enable']))
773
		unset($wancfg['wireless']['wme']['enable']);
774
	if ($_POST['puremode'] == "11g") {
775
		if (!is_array($wancfg['wireless']['pureg']))
776
			$wancfg['wireless']['pureg'] = array();
777
		$wancfg['wireless']['pureg']['enable'] = true;
778
	} else if ($_POST['puremode'] == "11n") {
779
		if (!is_array($wancfg['wireless']['puren']))
780
			$wancfg['wireless']['puren'] = array();
781
		$wancfg['wireless']['puren']['enable'] = true;
782
	} else {
783
		if (isset($wancfg['wireless']['pureg']))
784
			unset($wancfg['wireless']['pureg']);
785
		if (isset($wancfg['wireless']['puren']))
786
			unset($wancfg['wireless']['puren']);
787
	}
788
	if ($_POST['apbridge_enable'] == "yes") {
789
		if (!is_array($wancfg['wireless']['apbridge']))
790
			$wancfg['wireless']['apbridge'] = array();
791
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
792
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
793
		unset($wancfg['wireless']['apbridge']['enable']);
794
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
795
		if (!is_array($wancfg['wireless']['turbo']))
796
			$wancfg['wireless']['turbo'] = array();
797
		$wancfg['wireless']['turbo']['enable'] = true;
798
	} else if (isset($wancfg['wireless']['turbo']['enable']))
799
		unset($wancfg['wireless']['turbo']['enable']);
800
	$wancfg['wireless']['wep']['key'] = array();
801
	for ($i = 1; $i <= 4; $i++) {
802
		if ($_POST['key' . $i]) {
803
			$newkey = array();
804
			$newkey['value'] = $_POST['key' . $i];
805
			if ($_POST['txkey'] == $i)
806
				$newkey['txkey'] = true;
807
			$wancfg['wireless']['wep']['key'][] = $newkey;
808
		}
809
	}
810
	interface_sync_wireless_clones($wancfg, true);
811
}
812

    
813
function check_wireless_mode() {
814
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
815

    
816
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
817
		return;
818

    
819
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
820
		$clone_count = 1;
821
	else
822
		$clone_count = 0;
823
	if (is_array($config['wireless']['clone'])) {
824
		foreach ($config['wireless']['clone'] as $clone) {
825
			if ($clone['if'] == $wlanbaseif)
826
				$clone_count++;
827
		}
828
	}
829
	if ($clone_count > 1) {
830
		$old_wireless_mode = $wancfg['wireless']['mode'];
831
		$wancfg['wireless']['mode'] = $_POST['mode'];
832
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
833
			$input_errors[] = "Unable to change mode to {$wlan_modes[$wancfg['wireless']['mode']]}.  You may already have the maximum number of wireless clones supported in this mode.";
834
		} else {
835
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
836
		}
837
		$wancfg['wireless']['mode'] = $old_wireless_mode;
838
	}
839
}
840

    
841
$pgtitle = array("Interfaces", $pconfig['descr']);
842
$closehead = false;
843
include("head.inc");
844
$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
845

    
846
?>
847

    
848
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
849
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
850
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
851
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
852

    
853
<script type="text/javascript">
854
	function updateType(t){
855
		switch(t) {
856
	<?php
857
		/* OK, so this is sick using php to generate javascript, but it needed to be done */
858
		foreach ($types as $key => $val) {
859
			echo "case \"{$key}\": {\n";
860
			$t = $types;
861
			foreach ($t as $k => $v) {
862
				if ($k != $key) {
863
					echo "$('{$k}').hide();\n";
864
				}
865
			}
866
			echo "}\n";
867
		}
868
	?>
869
		}
870
		$(t).show();
871
	}
872

    
873
	function show_allcfg(obj) {
874
		if (obj.checked)
875
			$('allcfg').show();
876
		else
877
			$('allcfg').hide();
878
	}
879
	
880
	function show_periodic_reset(obj) {
881
		if (obj.checked)
882
			$('presetwrap').show();
883
		else
884
			$('presetwrap').hide();
885
	}
886

    
887
	function show_mon_config() {
888
		document.getElementById("showmonbox").innerHTML='';
889
		aodiv = document.getElementById('showmon');
890
		aodiv.style.display = "block";
891
	}
892

    
893
	function openwindow(url) {
894
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
895
		if (oWin==null || typeof(oWin)=="undefined") 
896
			return false;
897
		else 
898
			return true;
899
	}
900
</script>
901
</head>
902
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
903
	<?php include("fbegin.inc"); ?>
904
	<form action="interfaces.php" method="post" name="iform" id="iform">
905
		<?php if ($input_errors) print_input_errors($input_errors); ?>
906
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
907
		<?php print_info_box_np(gettext("The {$wancfg['descr']} configuration has been changed.<p>You must apply the changes in order for them to take effect.<p>Don't forget to adjust the DHCP Server range if needed before applying."));?><br />
908
		<?php endif; ?>
909
		<?php if ($savemsg) print_info_box($savemsg); ?>
910
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
911
		<tr>
912
                                <td id="mainarea">
913
                                        <div class="tabcont">
914
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
915
		<tr>
916
			<td colspan="2" valign="top" class="listtopic">General configuration</td>
917
		</tr>
918
		<?php if ($if != "wan" && $if != "lan"): ?>
919
		<tr>
920
			<td width="22%" valign="top" class="vncell">Enable</td>
921
			<td width="78%" class="vtable">
922
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
923
			<strong>Enable Interface</strong>
924
			</td>
925
		</tr>
926
		<?php else: ?>
927
		<input name="enable" type="hidden" value="yes">
928
		<?php endif; ?>
929
		</table>
930
		<div style="display:none;" name="allcfg" id="allcfg">
931
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
932
			<tr>
933
				<td width="22%" valign="top" class="vncell">Description</td>
934
				<td width="78%" class="vtable">
935
					<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
936
					<br><span class="vexpl">Enter a description (name) for the interface here.</span>
937
				</td>
938
			</tr>
939
		<?
940
		 if(!$wancfg['serialport']):
941
		?>
942
			<tr>
943
				<td valign="middle" class="vncell"><strong>Type</strong></td>
944
				<td class="vtable"> 
945
					<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
946
					<?php 
947
						foreach ($types as $key => $opt) { 
948
							echo "<option onClick=\"updateType('{$key}');\"";
949
							if ($key == $pconfig['type']) 
950
								echo " selected";
951
							echo " value=\"{$key}\" >" . htmlspecialchars($opt);
952
							echo "</option>";
953
					    } 
954
					?>
955
					</select>
956
				</td>
957
			</tr>
958
			<?php endif; ?>
959
			<tr>
960
				<td valign="top" class="vncell">MAC address</td>
961
				<td class="vtable">
962
					<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
963
				    <?php
964
						$ip = getenv('REMOTE_ADDR');
965
						$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
966
						$mac = str_replace("\n","",$mac);
967
						if($mac):
968
					?>
969
						<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Insert my local MAC address</a>
970
					<?php endif; ?>
971
					<br>
972
					This field can be used to modify (&quot;spoof&quot;) the MAC
973
					address of the WAN interface<br>
974
					(may be required with some cable connections)<br>
975
					Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
976
					or leave blank
977
				</td>
978
			</tr>
979
			<tr>
980
				<td valign="top" class="vncell">MTU</td>
981
				<td class="vtable"> 
982
					<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
983
					<br>
984
					If you enter a value in this field, then MSS clamping for
985
					TCP connections to the value entered above minus 40 (TCP/IP
986
					header size) will be in effect. If you leave this field blank,
987
					an MTU of 1500 bytes will be assumed.
988
				</td>
989
			</tr>
990
			<tr>
991
				<td colspan="2" valign="top" height="16"></td>
992
			</tr>			
993
			<tr style="display:none;" name="none" id="none">
994
			</tr>
995
			<tr style="display:none;" name="static" id="static">
996
				<td colspan="2" style="padding:0px;">
997
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
998
						<tr>
999
							<td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
1000
						</tr>
1001
						<tr>
1002
							<td width="22%" valign="top" class="vncellreq">IP address</td>
1003
							<td width="78%" class="vtable"> 
1004
								<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1005
								/
1006
								<select name="subnet" class="formselect" id="subnet">
1007
									<?php
1008
									for ($i = 32; $i > 0; $i--) {
1009
										if($i <> 31) {
1010
											echo "<option value=\"{$i}\" ";
1011
											if ($i == $pconfig['subnet']) echo "selected";
1012
											echo ">" . $i . "</option>";
1013
										}
1014
									}
1015
									?>
1016
								</select>
1017
							</td>
1018
						</tr>
1019
						<?php if (isset($wancfg['ispointtopoint'])): ?>
1020
							<tr>
1021
								<td width="22%" valign="top" class="vncellreq">Point-to-point IP address </td>
1022
								<td width"78%" class="vtable">
1023
									<input name="pointtopoint" type="text" class="formfld unknown" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
1024
								</td>
1025
							</tr>
1026
						<?php endif; ?>
1027
						<tr>
1028
							<td width="22%" valign="top" class="vncellreq">Gateway</td>
1029
							<td width="78%" class="vtable">
1030
								<select name="gateway" class="formselect" id="gateway">
1031
									<option value="none" selected>None</option>
1032
										<?php
1033
										if(count($a_gateways) > 0) {
1034
											foreach ($a_gateways as $gateway) {
1035
												if($gateway['interface'] == $if) {
1036
										?>
1037
												<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1038
													<?=htmlspecialchars($gateway['name']);?>
1039
												</option>
1040
										<?php
1041
												}
1042
											}
1043
										}
1044
										?>
1045
								</select>
1046
								<br/>
1047
								<div id='addgwbox'>
1048
									If this interface is an Internet connection, select an existing Gateway from the list or <a OnClick="show_add_gateway();" href="#">add a new one</a>.
1049
								</div>
1050
								<div id='notebox'>
1051
								</div>
1052
								<div id="status">
1053
								</div>								
1054
								<div style="display:none" id="addgateway" name="addgateway">
1055
									<p> 
1056
									<table border="1" style="background:#990000; border-style: none none none none; width:225px;"><tr><td>
1057
										<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1058
											<tr><td>&nbsp;</td>
1059
											<tr>
1060
												<td colspan="2"><center><b><font color="white">Add new gateway:</b></center></td>
1061
											</tr>
1062
											<tr><td>&nbsp;</td>
1063
											<?php
1064
											if($if == "wan" || $if == "WAN")
1065
												$checked = " CHECKED";
1066
											?>
1067
											<tr>
1068
												<td width="45%" align="right"><font color="white">Default  gateway:</td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1069
											</tr>												
1070
											<tr>
1071
												<td align="right"><font color="white">Gateway Name:</td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1072
											</tr>
1073
											<tr>
1074
												<td align="right"><font color="white">Gateway IP:</td><td><input id="gatewayip" name="gatewayip"></td>
1075
											</tr>
1076
											<tr>
1077
												<td align="right"><font color="white">Description:</td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1078
											</tr>
1079
											<tr><td>&nbsp;</td>
1080
											<tr>
1081
												<td colspan="2">
1082
													<center>
1083
														<div id='savebuttondiv'>
1084
															<input type="hidden" name="addrtype" id="addrtype" value="IPv4" />
1085
															<input id="gwsave" type="Button" value="Save Gateway" onClick='hide_add_gatewaysave();'> 
1086
															<input id="gwcancel" type="Button" value="Cancel" onClick='hide_add_gateway();'>
1087
														</div>
1088
													</center>
1089
												</td>
1090
											</tr>
1091
											<tr><td>&nbsp;</td>
1092
										</table>
1093
										</td></tr></table>
1094
									<p/>
1095
								</div>
1096
							</td>
1097
						</tr>
1098
					</table>
1099
				</td>
1100
				</tr>
1101
				<tr style="display:none;" name="dhcp" id="dhcp">
1102
					<td colspan="2" style="padding: 0px;">
1103
						<table width="100%" border="0" cellpadding="6" cellspacing="0">
1104
							<tr>
1105
								<td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
1106
							</tr>
1107
							<tr>
1108
								<td width="22%" valign="top" class="vncell">Hostname</td>
1109
								<td width="78%" class="vtable">
1110
									<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1111
									<br>
1112
									The value in this field is sent as the DHCP client identifier
1113
									and hostname when requesting a DHCP lease. Some ISPs may require
1114
									this (for client identification).
1115
								</td>
1116
							</tr>
1117
							<tr>
1118
								<td width="22%" valign="top" class="vncell">Alias IP address</td>
1119
								<td width="78%" class="vtable"> 
1120
									<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1121
									<select name="alias-subnet" class="formselect" id="alias-subnet">
1122
										<?php
1123
										for ($i = 32; $i > 0; $i--) {
1124
											if($i <> 31) {
1125
												echo "<option value=\"{$i}\" ";
1126
												if ($i == $pconfig['alias-subnet']) echo "selected";
1127
												echo ">" . $i . "</option>";
1128
											}
1129
										}
1130
										?>
1131
									</select>
1132
									The value in this field is used as a fixed alias IP address by the
1133
									DHCP client.
1134
								</td>
1135
							</tr>
1136
						</table>
1137
					</td>
1138
				</tr>
1139
				<tr style="display:none;" name="pppoe" id="pppoe">
1140
					<td colspan="2" style="padding:0px;">
1141
						<table width="100%" border="0" cellpadding="6" cellspacing="0">
1142
							<tr>
1143
								<td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
1144
							</tr>
1145
							<tr>
1146
								<td width="22%" valign="top" class="vncellreq">Username</td>
1147
								<td width="78%" class="vtable">
1148
										<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1149
								</td>
1150
							</tr>
1151
							<tr>
1152
								<td width="22%" valign="top" class="vncellreq">Password</td>
1153
								<td width="78%" class="vtable">
1154
									<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1155
								</td>
1156
							</tr>
1157
							<tr>
1158
								<td width="22%" valign="top" class="vncell">Service name</td>
1159
								<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1160
									<br> <span class="vexpl">Hint: this field can usually be left empty</span>
1161
								</td>
1162
							</tr>
1163
							<tr>
1164
								<td width="22%" valign="top" class="vncell">Dial on demand</td>
1165
								<td width="78%" class="vtable">
1166
									<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1167
									<strong>Enable Dial-On-Demand mode</strong><br>
1168
		    						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.
1169
								</td>
1170
							</tr>
1171
							<tr>
1172
								<td width="22%" valign="top" class="vncell">Idle timeout</td>
1173
								<td width="78%" class="vtable">
1174
									<input name="pppoe_idletimeout" type="text" class="formfld unknown" 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.
1175
								</td>
1176
							</tr>
1177
							<tr>
1178
								<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1179
								<td width="78%" class="vtable">
1180
									<input name="pppoe_preset" type="checkbox" id="pppoe_preset" value="yes" <?php if ($pconfig['pppoe_preset']) echo "checked=\"checked\""; ?> onclick="show_periodic_reset(this);" />
1181
										<?= gettext("enable periodic PPPoE resets"); ?>
1182
										<br />
1183
										<?php if ($pconfig['pppoe_preset']): ?>
1184
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1185
											<?php else: ?>
1186
												<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" style="display: none;">
1187
												<?php endif; ?>
1188
												<tr>
1189
													<td align="left" valign="top">
1190
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1191
															<input name="pppoe_pr_type" type="radio" id="pppoe_pr_custom" value="custom" <?php if ($pconfig['pppoe_pr_custom']) echo "checked=\"checked\""; ?> onclick="if (this.checked) { Effect.Appear('pppoecustomwrap', { duration: 0.0 }); Effect.Fade('pppoepresetwrap', { duration: 0.0 }); }" /> 
1192
																<?= gettext("provide a custom reset time"); ?>
1193
																<br />
1194
																<input name="pppoe_pr_type" type="radio" id="pppoe_pr_preset" value="preset" <?php if ($pconfig['pppoe_pr_preset']) echo "checked=\"checked\""; ?> onclick="if (this.checked) { Effect.Appear('pppoepresetwrap', { duration: 0.0 }); Effect.Fade('pppoecustomwrap', { duration: 0.0 }); }" /> 
1195
																	<?= gettext("select reset time from a preset"); ?>
1196
																</p>
1197
																<?php if ($pconfig['pppoe_pr_custom']): ?>
1198
																	<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
1199
																	<?php else: ?>
1200
																		<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
1201
																		<?php endif; ?>
1202
																		<input type="text" name="pppoe_resethour" class="fd_incremental_inp_range_0_23 fd_increment_1 fd_classname_dec_buttonDec fd_classname_inc_buttonInc" maxlength="2" id="pppoe_resethour" value="<?= $pconfig['pppoe_resethour']; ?>" size="3" /> 
1203
																		<?= gettext("hour (0-23)"); ?><br />
1204
																		<input type="text" name="pppoe_resetminute" class="fd_incremental_inp_range_0_59 fd_increment_1 fd_classname_dec_buttonDec fd_classname_inc_buttonInc" maxlength="2" id="pppoe_resetminute" value="<?= $pconfig['pppoe_resetminute']; ?>" size="3" /> 
1205
																		<?= gettext("minute (0-59)"); ?><br />
1206
																		<input name="pppoe_resetdate" type="text" class="w8em format-m-d-y highlight-days-67" id="pppoe_resetdate" maxlength="10" size="10" value="<?=htmlspecialchars($pconfig['pppoe_resetdate']);?>" /> 
1207
																		<?= gettext("reset at a specific date (mm/dd/yyyy)"); ?>
1208
																		<br />&nbsp;<br />
1209
																		<span class="red"><strong>Note: </strong></span>
1210
																		If you leave the date field empty, the reset will be executed each day at the time you did specify using the minutes and hour field.
1211
																	</p>
1212
																	<?php if ($pconfig['pppoe_pr_preset']): ?>
1213
																		<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
1214
																		<?php else: ?>
1215
																			<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
1216
																			<?php endif; ?>
1217
																			<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> /> 
1218
																			<?= gettext("reset at each month ('0 0 1 * *')"); ?>
1219
																			<br />
1220
																			<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> /> 
1221
																			<?= gettext("reset at each week ('0 0 * * 0')"); ?>
1222
																			<br />
1223
																			<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> /> 
1224
																			<?= gettext("reset at each day ('0 0 * * *')"); ?>
1225
																			<br />
1226
																			<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> /> 
1227
																			<?= gettext("reset at each hour ('0 * * * *')"); ?>
1228
																		</p>
1229
																	</td>
1230
																</tr>
1231
															</table>
1232
														</td>
1233
													</tr>
1234
												</table>
1235
											</td>
1236
										</tr>
1237
										<tr style="display:none;" name="pptp" id="pptp">
1238
											<td colspan="2" style="padding:0px;">
1239
												<table width="100%" border="0" cellpadding="6" cellspacing="0">
1240
													<tr>
1241
														<td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
1242
													</tr>
1243
													<tr>
1244
														<td width="22%" valign="top" class="vncellreq">Username</td>
1245
														<td width="78%" class="vtable">
1246
															<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
1247
														</td>
1248
													</tr>
1249
													<tr>
1250
														<td width="22%" valign="top" class="vncellreq">Password</td>
1251
														<td width="78%" class="vtable">
1252
															<input name="pptp_password" type="text" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
1253
														</td>
1254
													</tr>
1255
													<tr>
1256
														<td width="22%" width="100" valign="top" class="vncellreq">Local IP address</td>
1257
														<td width="78%" class="vtable"> 
1258
															<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local']);?>">
1259
															/
1260
															<select name="pptp_subnet" class="formselect" id="pptp_subnet">
1261
																<?php for ($i = 31; $i > 0; $i--): ?>
1262
																	<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet']) echo "selected"; ?>>
1263
																		<?=$i;?>
1264
																	</option>
1265
																<?php endfor; ?>
1266
															</select>
1267
														</td>
1268
													</tr>
1269
													<tr>
1270
														<td width="22%" width="100" valign="top" class="vncellreq">Remote IP address</td>
1271
														<td width="78%" class="vtable">
1272
															<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote']);?>">
1273
														</td>
1274
													</tr>
1275
													<tr>
1276
														<td width="22%" valign="top" class="vncell">Dial on demand</td>
1277
														<td width="78%" class="vtable">
1278
															<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>>
1279
															<strong>Enable Dial-On-Demand mode</strong><br>
1280
															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.
1281
														</td>
1282
													</tr>
1283
													<tr>
1284
														<td width="22%" valign="top" class="vncell">Idle timeout</td>
1285
														<td width="78%" class="vtable">
1286
															<input name="pptp_idletimeout" type="text" class="formfld unknown" 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.
1287
														</td>
1288
													</tr>
1289
												</table>
1290
											</td>
1291
										</tr>
1292
										<?php
1293
											/* Wireless interface? */
1294
											if (isset($wancfg['wireless'])):
1295
										?>
1296
										<tr>
1297
											<td colspan="2" valign="top" height="16"></td>
1298
										</tr>										
1299
										<tr>
1300
											<td colspan="2" valign="top" class="listtopic">Common wireless configuration - Settings apply to all wireless networks on <?=$wlanbaseif;?>.</td>
1301
										</tr>
1302
										<tr>
1303
											<td valign="top" class="vncellreq">Standard</td>
1304
											<td class="vtable">
1305
											<select name="standard" class="formselect" id="standard">
1306
												<?php
1307
												foreach($wl_modes as $wl_standard => $wl_channels) {
1308
													echo "<option ";
1309
													if ($pconfig['standard'] == "$wl_standard")
1310
														echo "selected ";
1311
													echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
1312
												}
1313
												?>
1314
											</select>
1315
										</td>
1316
									</tr>
1317
									<?php if (isset($wl_modes['11g'])): ?>
1318
									<tr>
1319
										<td valign="top" class="vncellreq">802.11g OFDM Protection Mode</td>
1320
										<td class="vtable">
1321
											<select name="protmode" class="formselect" id="protmode">
1322
												<option <? if ($pconfig['protmode'] == 'off') echo "selected";?> value="off">Protection mode off</option>
1323
												<option <? if ($pconfig['protmode'] == 'cts') echo "selected";?> value="cts">Protection mode CTS to self</option>
1324
												<option <? if ($pconfig['protmode'] == 'rtscts') echo "selected";?> value="rtscts">Protection mode RTS and CTS</option>
1325
											</select>
1326
											<br/>
1327
											For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network.
1328
											<br/>
1329
										</td>
1330
									</tr>
1331
									<?php else: ?>
1332
									<input name="protmode" type="hidden" id="protmode" value="off">
1333
									<?php endif; ?>
1334
										<tr>
1335
											<td valign="top" class="vncellreq">Transmit power</td>
1336
											<td class="vtable">
1337
												<select name="txpower" class="formselect" id="txpower">
1338
													<?
1339
													for($x = 99; $x > 0; $x--) {
1340
														if($pconfig["txpower"] == $x)
1341
															$SELECTED = " SELECTED";
1342
														else
1343
															$SELECTED = "";
1344
														echo "<option {$SELECTED}>{$x}</option>\n";
1345
													}
1346
													?>
1347
												</select><br/>
1348
												Note: Typically only a few discreet power settings are available and the driver will use the setting closest to the specified value.  Not all adaptors support changing the transmit power setting.
1349
											</td>
1350
										</tr>
1351
										<tr>
1352
											<td valign="top" class="vncellreq">Channel</td>
1353
											<td class="vtable">
1354
												<select name="channel" class="formselect" id="channel">
1355
													<option <? if ($pconfig['channel'] == 0) echo "selected"; ?> value="0">Auto</option>
1356
													<?php
1357
													foreach($wl_modes as $wl_standard => $wl_channels) {
1358
														if($wl_standard == "11g") { $wl_standard = "11b/g"; }
1359
														else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
1360
														else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
1361
														foreach($wl_channels as $wl_channel) {
1362
															echo "<option ";
1363
															if ($pconfig['channel'] == "$wl_channel") {
1364
																echo "selected ";
1365
															}
1366
															echo "value=\"$wl_channel\">$wl_standard - $wl_channel</option>\n";
1367
														}
1368
													}
1369
													?>
1370
												</select>
1371
												<br/>
1372
												Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above.
1373
											</td>
1374
										</tr>
1375
										<tr>
1376
											<td valign="top" class="vncell">Distance setting</td>
1377
											<td class="vtable">
1378
												<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>">
1379
												<br/>
1380
												Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client<br/>
1381
												(measured in Meters and works only for Atheros based cards !)
1382
											</td>
1383
										</tr>
1384
										<tr>
1385
											<td valign="top" class="vncell">Regulatory settings</td>
1386
											<td class="vtable">
1387
												Regulatory domain<br/>
1388
												<select name="regdomain" class="formselect" id="regdomain">
1389
													<option <? if (empty($pconfig['regdomain'])) echo "selected"; ?> value="">Default</option>
1390
													<?php
1391
													foreach($wl_regdomains['regulatory-domains']['rd'] as $wl_regdomain) {
1392
														echo "<option ";
1393
														if ($pconfig['regdomain'] == $wl_regdomain['attributes']['ID']) {
1394
															echo "selected ";
1395
														}
1396
														echo "value=\"{$wl_regdomain['attributes']['ID']}\">{$wl_regdomain['name']}</option>\n";
1397
													}
1398
													?>
1399
												</select>
1400
												<br/><br/>
1401
												Country (listed with country code and regulatory domain)<br/>
1402
												<select name="regcountry" class="formselect" id="regcountry">
1403
													<option <? if (empty($pconfig['regcountry'])) echo "selected"; ?> value="">Default</option>
1404
													<?php
1405
													foreach($wl_regdomains['country-codes']['country'] as $wl_country) {
1406
														echo "<option ";
1407
														if ($pconfig['regcountry'] == $wl_country['attributes']['ID']) {
1408
															echo "selected ";
1409
														}
1410
														echo "value=\"{$wl_country['attributes']['ID']}\">{$wl_country['name']} -- ({$wl_country['attributes']['ID']}, " . strtoupper($wl_country['rd'][0]['attributes']['REF']) . ")</option>\n";
1411
													}
1412
													?>
1413
												</select>
1414
												<br/>
1415
												Note: Any country setting other than "Default" will override the regulatory domain setting.
1416
												<br/><br/>
1417
												Location<br/>
1418
												<select name="reglocation" class="formselect" id="reglocation">
1419
													<option <? if ($pconfig['reglocation'] == 'indoor') echo "selected"; ?> value="indoor">Indoor</option>
1420
													<option <? if ($pconfig['reglocation'] == 'outdoor') echo "selected"; ?> value="outdoor">Outdoor</option>
1421
													<option <? if ($pconfig['reglocation'] == 'anywhere') echo "selected"; ?> value="anywhere">Anywhere</option>
1422
												</select>
1423
												<br/><br/>
1424
												These settings may affect which channels are available and the maximum transmit power allowed on those channels.  Using the correct settings to comply with local regulatory requirements is recommended.
1425
												<br/>
1426
												Note: All wireless networks on this interface will be temporarily brought down when changing regulatory settings.  Some of the regulatory domains or country codes may not be allowed by some cards.  These settings may not be able to add additional channels that are not already supported.
1427
											</td>
1428
										</tr>
1429
										<tr>
1430
											<td colspan="2" valign="top" height="16"></td>
1431
										</tr>										
1432
										<tr>
1433
											<td colspan="2" valign="top" class="listtopic">Wireless configuration</td>
1434
										</tr>
1435
									<tr>
1436
										<td valign="top" class="vncellreq">Mode</td>
1437
										<td class="vtable">
1438
											<select name="mode" class="formselect" id="mode">
1439
												<option <? if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss">Infrastructure (BSS)</option>
1440
												<option <? if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc">Ad-hoc (IBSS)</option>
1441
												<option <? if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap">Access Point</option>
1442
											</select>
1443
										</td>
1444
									</tr>
1445
									<tr>
1446
										<td valign="top" class="vncellreq">SSID</td>
1447
										<td class="vtable">
1448
											<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>">
1449
										</td>
1450
                					</tr>
1451
									<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
1452
									<tr>
1453
										<td valign="top" class="vncell">Minimum wireless standard</td>
1454
										<td class="vtable">
1455
											<select name="puremode" class="formselect" id="puremode">
1456
												<option <? if ($pconfig['puremode'] == 'any') echo "selected";?> value="any">Any</option>
1457
												<?php if (isset($wl_modes['11g'])): ?>
1458
												<option <? if ($pconfig['puremode'] == '11g') echo "selected";?> value="11g">802.11g</option>
1459
												<?php endif; ?>
1460
												<option <? if ($pconfig['puremode'] == '11n') echo "selected";?> value="11n">802.11n</option>
1461
											</select>
1462
											<br/>
1463
											When operating as an access point, allow only stations capable of the selected wireless standard to associate (stations not capable are not permitted to associate).
1464
										</td>
1465
									</tr>
1466
									<?php elseif (isset($wl_modes['11g'])): ?>
1467
									<tr>
1468
										<td valign="top" class="vncell">802.11g only</td>
1469
										<td class="vtable">
1470
											<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <? if ($pconfig['puremode'] == '11g') echo "checked";?>>
1471
											<br/>When operating as an access point in 802.11g mode, allow only 11g-capable stations to associate (11b-only stations are not permitted to associate).
1472
										</td>
1473
									</tr>
1474
									<?php endif; ?>
1475
									<tr>
1476
										<td valign="top" class="vncell">Allow intra-BSS communication</td>
1477
										<td class="vtable">
1478
											<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <? if ($pconfig['apbridge_enable']) echo "checked";?>>
1479
											<br/>
1480
											When operating as an access point, enable this if you want to pass packets between wireless clients directly.
1481
											<br/>
1482
											Disabling the internal bridging is useful when traffic is to be processed with packet filtering.
1483
										</td>
1484
									</tr>
1485
									<tr>
1486
										<td valign="top" class="vncell">Enable WME</td>
1487
										<td class="vtable">
1488
											<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <? if ($pconfig['wme_enable']) echo "checked";?>>
1489
											<br/>Setting this option will force the card to use WME (wireless QoS).
1490
										</td>
1491
									</tr>
1492
									<tr>
1493
										<td valign="top" class="vncell">Enable Hide SSID</td>
1494
										<td class="vtable">
1495
											<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <? if ($pconfig['hidessid_enable']) echo "checked";?>>
1496
											<br/>
1497
											Setting this option will force the card to NOT broadcast its SSID
1498
											<br/>
1499
											(this might create problems for some clients). </td>
1500
										</tr>
1501
										<tr>
1502
											<td valign="top" class="vncell">WEP</td>
1503
											<td class="vtable"> 
1504
												<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <? if ($pconfig['wep_enable']) echo "checked"; ?>>
1505
												<strong>Enable WEP</strong>
1506
												<table border="0" cellspacing="0" cellpadding="0">
1507
													<tr>
1508
														<td>&nbsp;</td>
1509
														<td>&nbsp;</td>
1510
														<td>&nbsp;TX key&nbsp;</td>
1511
													</tr>
1512
													<tr>
1513
														<td>Key 1:&nbsp;&nbsp;</td>
1514
														<td>
1515
															<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>">
1516
														</td>
1517
														<td align="center">
1518
															<input name="txkey" type="radio" value="1" <? if ($pconfig['txkey'] == 1) echo "checked";?>>
1519
														</td>
1520
													</tr>
1521
													<tr>
1522
														<td>Key 2:&nbsp;&nbsp;</td>
1523
														<td>
1524
															<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>">
1525
														</td>
1526
														<td align="center">
1527
															<input name="txkey" type="radio" value="2" <? if ($pconfig['txkey'] == 2) echo "checked";?>>
1528
														</td>
1529
													</tr>
1530
													<tr>
1531
														<td>Key 3:&nbsp;&nbsp;</td>
1532
														<td>
1533
															<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>">
1534
														</td>
1535
														<td align="center">
1536
															<input name="txkey" type="radio" value="3" <? if ($pconfig['txkey'] == 3) echo "checked";?>>
1537
														</td>
1538
													</tr>
1539
													<tr>
1540
														<td>Key 4:&nbsp;&nbsp;</td>
1541
														<td>
1542
															<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>">
1543
														</td>
1544
														<td align="center">
1545
															<input name="txkey" type="radio" value="4" <? if ($pconfig['txkey'] == 4) echo "checked";?>>
1546
														</td>
1547
													</tr>
1548
												</table>
1549
												<br/>
1550
												40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'.<br/>
1551
												104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'.
1552
											</td>
1553
										</tr>
1554
										<tr>
1555
											<td valign="top" class="vncell">WPA</td>
1556
											<td class="vtable">
1557
												<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <? if ($pconfig['wpa_enable']) echo "checked"; ?>>
1558
												<strong>Enable WPA</strong>
1559
												<br/><br/>
1560
												<table border="0" cellspacing="0" cellpadding="0">
1561
													<tr>
1562
														<td>&nbsp;</td>
1563
														<td>&nbsp;WPA Pre Shared Key&nbsp;</td>
1564
													</tr>
1565
													<tr>
1566
														<td>PSK:&nbsp;&nbsp;</td>
1567
														<td>
1568
															<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>">
1569
														</td>
1570
													</tr>
1571
												</table>
1572
												<br/>Passphrase must be from 8 to 63 characters.
1573
											</td>
1574
										</tr>
1575
										<tr>
1576
											<td valign="top" class="vncell">WPA Mode</td>
1577
											<td class="vtable">
1578
												<select name="wpa_mode" class="formselect" id="wpa_mode">
1579
													<option <? if ($pconfig['wpa_mode'] == '1') echo "selected";?> value="1">WPA</option>
1580
													<option <? if ($pconfig['wpa_mode'] == '2') echo "selected";?> value="2">WPA2</option>
1581
													<option <? if ($pconfig['wpa_mode'] == '3') echo "selected";?> value="3">Both</option>
1582
												</select>
1583
											</td>
1584
										</tr>
1585
										<tr>
1586
											<td valign="top" class="vncell">WPA Key Management Mode</td>
1587
											<td class="vtable"> 
1588
												<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
1589
													<option <? if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected";?> value="WPA-PSK">Pre Shared Key</option>
1590
													<option <? if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected";?> value="WPA-EAP">Extensible Authentication Protocol</option>
1591
													<option <? if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected";?> value="WPA-PSK WPA-EAP">Both</option>
1592
 												</select>
1593
											</td>
1594
										</tr>
1595
										<tr>
1596
											<td valign="top" class="vncell">Authentication</td>
1597
											<td class="vtable">
1598
												<select name="auth_algs" class="formselect" id="auth_algs">
1599
													<option <? if ($pconfig['auth_algs'] == '1') echo "selected";?> value="1">Open System Authentication</option>
1600
													<option <? if ($pconfig['auth_algs'] == '2') echo "selected";?> value="2">Shared Key Authentication</option>
1601
													<option <? if ($pconfig['auth_algs'] == '3') echo "selected";?> value="3">Both</option>
1602
												</select>
1603
												<br/>Note: Shared Key Authentication requires WEP.</br>
1604
											</td>
1605
										</tr>
1606
										<tr>
1607
											<td valign="top" class="vncell">WPA Pairwise</td>
1608
											<td class="vtable">
1609
												<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
1610
													<option <? if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected";?> value="CCMP TKIP">Both</option>
1611
													<option <? if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected";?> value="CCMP">AES (recommended)</option>
1612
													<option <? if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected";?> value="TKIP">TKIP</option>
1613
												</select>
1614
											</td>
1615
										</tr>
1616
										<tr>
1617
											<td valign="top" class="vncell">Key Rotation</td>
1618
											<td class="vtable">
1619
												<input name="wpa_group_rekey" type="text" class="formfld unknown" id="wpa_group_rekey" size="30" value="<? echo $pconfig['wpa_group_rekey'] ? $pconfig['wpa_group_rekey'] : "60";?>">
1620
												<br/>Allowed values are 1-9999 but should not be longer than Master Key Regeneration time.
1621
											</td>
1622
										</tr>
1623
										<tr>
1624
											<td valign="top" class="vncell">Master Key Regeneration</td>
1625
											<td class="vtable">
1626
												<input name="wpa_gmk_rekey" type="text" class="formfld" id="wpa_gmk_rekey" size="30" value="<? echo $pconfig['wpa_gmk_rekey'] ? $pconfig['wpa_gmk_rekey'] : "3600";?>">
1627
												<br/>Allowed values are 1-9999 but should not be shorter than Key Rotation time.
1628
											</td>
1629
										</tr>
1630
										<tr>
1631
											<td valign="top" class="vncell">Strict Key Regeneration</td>
1632
											<td class="vtable">
1633
												<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <? if ($pconfig['wpa_strict_rekey']) echo "checked"; ?>>
1634
												<br/>Setting this option will force the AP to rekey whenever a client disassociates.
1635
											</td>
1636
										</tr>
1637
										<tr>
1638
											<td valign="top" class="vncell">Enable IEEE802.1X Authentication</td>
1639
											<td class="vtable">
1640
												<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <? if ($pconfig['ieee8021x']) echo "checked";?>>
1641
												<br/>Setting this option will enable 802.1x authentication.
1642
											</td>
1643
										</tr>
1644
										<tr>
1645
											<td valign="top" class="vncell">802.1X Authentication Server IP Address</td>
1646
											<td class="vtable">
1647
												<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>">
1648
												<br/>Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)
1649
											</td>
1650
										</tr>
1651
										<tr>
1652
											<td valign="top" class="vncell">802.1X Authentication Server Port</td>
1653
											<td class="vtable">
1654
												<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>">
1655
												<br/>Leave blank for the default 1812 port.
1656
											</td>
1657
										</tr>
1658
										<tr>
1659
											<td valign="top" class="vncell">802.1X Authentication Server Shared Secret</td>
1660
											<td class="vtable">
1661
												<input name="auth_server_shared_secret" id="auth_server_shared_secret" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_shared_secret']);?>">
1662
												<br/>
1663
											</td>
1664
										</tr>
1665
									<? endif; ?>
1666
									<tr>
1667
										<td colspan="2" valign="top" height="16"></td>
1668
									</tr>
1669
									<tr>
1670
										<td colspan="2" valign="top" class="listtopic">Private networks</td>
1671
									</tr>
1672
									<tr>
1673
										<td valign="middle" class="vncell">&nbsp;</td>
1674
										<td class="vtable">
1675
											<a name="rfc1918"></a> 
1676
											<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
1677
											<strong>Block private networks</strong><br>
1678
											When set, this option blocks traffic from IP addresses that are reserved 
1679
											for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as 
1680
											well as loopback addresses (127/8).&nbsp;&nbsp; You should generally
1681
											leave this option turned on, unless your WAN network lies in such 
1682
											a private address space, too. 
1683
										</td>
1684
									</tr>
1685
									<tr>
1686
										<td valign="middle" class="vncell">&nbsp;</td>
1687
										<td class="vtable"> 
1688
											<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
1689
											<strong>Block bogon networks</strong><br>
1690
											When set, this option blocks traffic from IP addresses that are reserved 
1691
											(but not RFC 1918) or not yet assigned by IANA.&nbsp;&nbsp;
1692
											Bogons are prefixes that should never appear in the Internet routing table, 
1693
											and obviously should not appear as the source address in any packets you receive.
1694
										</td>
1695
									</tr>
1696
								</tr>
1697
				</table>
1698
				</div>
1699
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
1700
								<tr>
1701
									<td width="100" valign="top">
1702
										&nbsp;
1703
									</td>
1704
									<td>
1705
										<br/>
1706
										<input id="save" name="Submit" type="submit" class="formbtn" value="Save"> 
1707
										<input id="cancel" type="button" class="formbtn" value="Cancel" onclick="history.back()">
1708
										<input name="if" type="hidden" id="if" value="<?=$if;?>">
1709
									</td>
1710
								</tr>
1711
							</table>
1712
						</td>
1713
					</table>
1714
					</div>
1715
					</td></tr>
1716
					</table>
1717
				</form>
1718
				<script type="text/javascript">
1719
					var gatewayip;
1720
					var name;
1721
					function show_add_gateway() {
1722
						document.getElementById("addgateway").style.display = '';
1723
						document.getElementById("addgwbox").style.display = 'none';
1724
						document.getElementById("gateway").style.display = 'none';
1725
						document.getElementById("save").style.display = 'none';
1726
						document.getElementById("cancel").style.display = 'none';
1727
						document.getElementById("gwsave").style.display = '';
1728
						document.getElementById("gwcancel").style.display = '';
1729
						$('notebox').innerHTML="";
1730
					}
1731
					function hide_add_gateway() {
1732
						document.getElementById("addgateway").style.display = 'none';
1733
						document.getElementById("addgwbox").style.display = '';	
1734
						document.getElementById("gateway").style.display = '';
1735
						document.getElementById("save").style.display = '';
1736
						document.getElementById("cancel").style.display = '';
1737
						document.getElementById("gwsave").style.display = '';
1738
						document.getElementById("gwcancel").style.display = '';
1739
					}
1740
					function hide_add_gatewaysave() {
1741
						document.getElementById("addgateway").style.display = 'none';
1742
						$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
1743
						var iface = $F('if');
1744
						name = $('name').getValue();
1745
						var descr = $('gatewaydescr').getValue();
1746
						gatewayip = $('gatewayip').getValue();
1747
						addrtype = $('addrtype').getValue();
1748
						var defaultgw = $('defaultgw').getValue();
1749
						var url = "system_gateways_edit.php";
1750
						var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
1751
						var myAjax = new Ajax.Request(
1752
							url,
1753
							{
1754
								method: 'post',
1755
								parameters: pars,
1756
								onFailure: report_failure,
1757
								onComplete: save_callback
1758
							});	
1759
					}
1760
					function addOption(selectbox,text,value)
1761
					{
1762
						var optn = document.createElement("OPTION");
1763
						optn.text = text;
1764
						optn.value = value;
1765
						selectbox.options.add(optn);
1766
						selectbox.selectedIndex = (selectbox.options.length-1);
1767
						$('notebox').innerHTML="<p/><strong>NOTE:</strong> You can manage Gateways <a target='_new' href='system_gateways.php'>here</a>.";
1768
					}				
1769
					function report_failure() {
1770
						alert("Sorry, we could not create your gateway at this time.");
1771
						hide_add_gateway();
1772
					}
1773
					function save_callback(transport) {
1774
						var response = transport.responseText;
1775
						if(response) {
1776
							document.getElementById("addgateway").style.display = 'none';
1777
							hide_add_gateway();
1778
							$('status').innerHTML = '';
1779
							addOption($('gateway'), name, name);
1780
							// Auto submit form?
1781
							//document.iform.submit();
1782
							//$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
1783
						} else {
1784
							report_failure();
1785
						}
1786
					}
1787
					<?php
1788
					if ($if == "wan" || $if == "lan")
1789
						echo "\$('allcfg').show();";
1790
					else
1791
						echo "show_allcfg(document.iform.enable);";
1792
					echo "updateType('{$pconfig['type']}')";
1793
					?>
1794
				</script>
1795
				<?php include("fend.inc"); ?>
1796
		</body>
1797
</html>
(80-80/218)