Project

General

Profile

Download (75.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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
164
$pconfig['enable'] = isset($wancfg['enable']);
165

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

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

    
203
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
204
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
205
$pconfig['spoofmac'] = $wancfg['spoofmac'];
206
$pconfig['mtu'] = $wancfg['mtu'];
207

    
208
/* Wireless interface? */
209
if (isset($wancfg['wireless'])) {
210
	/* Get wireless modes */
211
	$wlanif = get_real_interface($if);
212
	if (!does_interface_exist($wlanif))
213
		interface_wireless_clone($wlanif, $wancfg);
214
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
215
	$wl_modes = get_wireless_modes($if);
216
	$wl_chaninfo = get_wireless_channel_info($if);
217
	$wl_regdomain_xml_attr = array();
218
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
219
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
220
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
221
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
222
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
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['provider'] && !is_domain($_POST['provider']))) 
398
		$input_errors[] = "The service name contains invalid characters.";
399
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) 
400
		$input_errors[] = "The idle timeout value must be an integer.";
401
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
402
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) 
403
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
404
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
405
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) 
406
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
407
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) 
408
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
409
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) 
410
		$input_errors[] = "A valid PPTP local IP address must be specified.";
411
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) 
412
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
413
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) 
414
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
415
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) 
416
		$input_errors[] = "The idle timeout value must be an integer.";
417
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) 
418
		$input_errors[] = "A valid MAC address must be specified.";
419
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) 
420
		$input_errors[] = "The MTU must be greater than 576 bytes.";
421
	/* Wireless interface? */
422
	if (isset($wancfg['wireless'])) {
423
		$reqdfields = explode(" ", "mode ssid");
424
		$reqdfieldsn = explode(",", "Mode,SSID");
425
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
426
		check_wireless_mode();
427
		/* loop through keys and enforce size */
428
		for ($i = 1; $i <= 4; $i++) {
429
			if ($_POST['key' . $i]) {
430
				/* 64 bit */
431
				if (strlen($_POST['key' . $i]) == 5)
432
					continue;
433
				if (strlen($_POST['key' . $i]) == 10) {
434
					/* hex key */
435
					if (stristr($_POST['key' . $i], "0x") == false) {
436
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
437
					}
438
					continue;
439
				}
440
				if (strlen($_POST['key' . $i]) == 12) {
441
					/* hex key */
442
					if(stristr($_POST['key' . $i], "0x") == false) {
443
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
444
					}
445
					continue;
446
				}
447
				/* 128 bit */
448
				if (strlen($_POST['key' . $i]) == 13)
449
					continue;
450
				if (strlen($_POST['key' . $i]) == 26) {
451
					/* hex key */
452
					if (stristr($_POST['key' . $i], "0x") == false)
453
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
454
					continue;
455
				}
456
				if(strlen($_POST['key' . $i]) == 28)
457
					continue;
458
				$input_errors[] =  "Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.";
459
				break;
460
			}
461
		}
462

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

    
488
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
489
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
490

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

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

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

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

    
802
function check_wireless_mode() {
803
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
804

    
805
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
806
		return;
807

    
808
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
809
		$clone_count = 1;
810
	else
811
		$clone_count = 0;
812
	if (is_array($config['wireless']['clone'])) {
813
		foreach ($config['wireless']['clone'] as $clone) {
814
			if ($clone['if'] == $wlanbaseif)
815
				$clone_count++;
816
		}
817
	}
818
	if ($clone_count > 1) {
819
		$old_wireless_mode = $wancfg['wireless']['mode'];
820
		$wancfg['wireless']['mode'] = $_POST['mode'];
821
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
822
			$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.";
823
		} else {
824
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
825
		}
826
		$wancfg['wireless']['mode'] = $old_wireless_mode;
827
	}
828
}
829

    
830
$pgtitle = array("Interfaces", $pconfig['descr']);
831
$closehead = false;
832
include("head.inc");
833
$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
834

    
835
?>
836

    
837
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
838
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
839
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
840
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
841

    
842
<script type="text/javascript">
843
	function updateType(t){
844
		switch(t) {
845
	<?php
846
		/* OK, so this is sick using php to generate javascript, but it needed to be done */
847
		foreach ($types as $key => $val) {
848
			echo "case \"{$key}\": {\n";
849
			$t = $types;
850
			foreach ($t as $k => $v) {
851
				if ($k != $key) {
852
					echo "$('{$k}').hide();\n";
853
				}
854
			}
855
			echo "}\n";
856
		}
857
	?>
858
		}
859
		$(t).show();
860
	}
861

    
862
	function show_allcfg(obj) {
863
		if (obj.checked)
864
			$('allcfg').show();
865
		else
866
			$('allcfg').hide();
867
	}
868
	
869
	function show_periodic_reset(obj) {
870
		if (obj.checked)
871
			$('presetwrap').show();
872
		else
873
			$('presetwrap').hide();
874
	}
875

    
876
	function show_mon_config() {
877
		document.getElementById("showmonbox").innerHTML='';
878
		aodiv = document.getElementById('showmon');
879
		aodiv.style.display = "block";
880
	}
881

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