Project

General

Profile

Download (125 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-2010 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_once("guiconfig.inc");
48
require_once("ipsec.inc");
49
require_once("functions.inc");
50
require_once("captiveportal.inc");
51
require_once("filter.inc");
52
require_once("shaper.inc");
53
require_once("rrd.inc");
54
require_once("vpn.inc");
55
require_once("xmlparse_attr.inc");
56

    
57
// Get configured interface list
58
$ifdescrs = get_configured_interface_with_descr(false, true);
59

    
60
$if = "wan";
61
if ($_REQUEST['if'])
62
	$if = $_REQUEST['if'];
63

    
64
if (empty($ifdescrs[$if])) {
65
	Header("Location: interfaces.php");
66
	exit;
67
}
68

    
69
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
70
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
71
define("CRON_DAILY_PATTERN", "0 0 * * *");
72
define("CRON_HOURLY_PATTERN", "0 * * * *");
73

    
74
if (!is_array($config['ppps']['ppp']))
75
	$config['ppps']['ppp'] = array();
76

    
77
$a_ppps = &$config['ppps']['ppp'];
78

    
79
function remove_bad_chars($string) {
80
	return preg_replace('/[^a-z_0-9]/i','',$string);
81
}
82

    
83
if (!is_array($config['gateways']['gateway_item']))
84
	$config['gateways']['gateway_item'] = array();
85
$a_gateways = &$config['gateways']['gateway_item'];
86

    
87
$wancfg = &$config['interfaces'][$if];
88
$old_wancfg = $wancfg;
89
// Populate page descr if it does not exist.
90
if ($if == "wan" && !$wancfg['descr'])
91
	$wancfg['descr'] = "WAN";
92
else if ($if == "lan" && !$wancfg['descr'])
93
	$wancfg['descr'] = "LAN";
94

    
95

    
96
foreach ($a_ppps as $pppid => $ppp) {
97
	if ($wancfg['if'] == $ppp['if'])
98
		break;
99
}
100

    
101
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
102
	$pconfig['pppid'] = $pppid;
103
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
104
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
105
	if ($a_ppps[$pppid]['type'] == "ppp"){
106
		$pconfig['username'] = $a_ppps[$pppid]['username'];
107
		$pconfig['password'] = base64_decode($a_ppps[$pppid]['password']);
108

    
109
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
110
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
111
	}
112

    
113
	if ($a_ppps[$pppid]['type'] == "pppoe"){
114
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
115
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
116
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
117
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
118
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
119

    
120
		/* ================================================ */
121
		/* = force a connection reset at a specific time? = */
122
		/* ================================================ */
123

    
124
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
125
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
126
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
127
			$cronitem = $itemhash['ITEM'];
128
			if (isset($cronitem)) {
129
				$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
130
			} else {
131
				$resetTime = NULL;
132
			}
133
			log_error("ResetTime:".$resetTime);
134
			if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
135
				$resetTime_a = explode(" ", $resetTime);
136
				$pconfig['pppoe_pr_custom'] = true;
137
				$pconfig['pppoe_resetminute'] = $resetTime_a[0];
138
				$pconfig['pppoe_resethour'] = $resetTime_a[1];
139
				/*  just initialize $pconfig['pppoe_resetdate'] if the
140
				 *  coresponding item contains appropriate numeric values.
141
				 */
142
				if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*")
143
					$pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
144
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
145
				$pconfig['pppoe_pr_preset'] = true;
146
				switch ($resetTime) {
147
					case CRON_MONTHLY_PATTERN:
148
						$pconfig['pppoe_monthly'] = true;
149
						break;
150
					case CRON_WEEKLY_PATTERN:
151
						$pconfig['pppoe_weekly'] = true;
152
						break;
153
					case CRON_DAILY_PATTERN:
154
						$pconfig['pppoe_daily'] = true;
155
						break;
156
					case CRON_HOURLY_PATTERN:
157
						$pconfig['pppoe_hourly'] = true;
158
						break;
159
				}
160
			}
161
		}// End force pppoe reset at specific time
162
	}// End if type == pppoe
163
	else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp"){
164
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
165
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
166
		$pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']);
167
		$pconfig['pptp_subnet'] = explode(",",$a_ppps[$pppid]['subnet']);
168
		$pconfig['pptp_remote'] = explode(",",$a_ppps[$pppid]['gateway']);
169
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
170
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
171
	}
172
} else {
173
	$pconfig['ptpid'] = interfaces_ptpid_next();
174
	$pppid = count($a_ppps);
175
}
176
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
177
$pconfig['alias-address'] = $wancfg['alias-address'];
178
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
179
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
180
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
181
$pconfig['enable'] = isset($wancfg['enable']);
182

    
183
if (is_array($config['aliases']['alias'])) {
184
	foreach($config['aliases']['alias'] as $alias) {
185
		if($alias['name'] == $wancfg['descr']) {
186
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']);
187
		}
188
	}
189
}
190

    
191
switch($wancfg['ipaddr']) {
192
	case "dhcp":
193
		$pconfig['type'] = "dhcp";
194
		break;
195
	case "carpdev-dhcp":
196
		$pconfig['ipaddr'] = "";
197
		break;
198
	case "pppoe":
199
	case "pptp":
200
	case "l2tp":
201
	case "ppp":
202
		$pconfig['type'] = $wancfg['ipaddr'];
203
		break;
204
	default:
205
		if(is_ipaddr($wancfg['ipaddr'])) {
206
			$pconfig['type'] = "staticv4";
207
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
208
			$pconfig['subnet'] = $wancfg['subnet'];
209
			$pconfig['gateway'] = $wancfg['gateway'];
210
		} else
211
			$pconfig['type'] = "none";
212
		break;
213
}
214

    
215
switch($wancfg['ipaddrv6']) {
216
	case "slaac":
217
		$pconfig['type6'] = "slaac";
218
		break;
219
	case "dhcp6":
220
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
221
		if($wancfg['dhcp6-ia-pd-len'] == "")
222
			$wancfg['dhcp6-ia-pd-len'] = "none";
223
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
224
		$pconfig['type6'] = "dhcp6";
225
		break;
226
	case "6to4":
227
		$pconfig['type6'] = "6to4";
228
		break;
229
	case "track6":
230
		$pconfig['type6'] = "track6";
231
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
232
		$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
233
		if ($wancfg['track6-prefix-id'] == "" || $wancfg['track6-prefix-id'] == "none") {
234
			$pconfig['track6-prefix-id--hex'] = "";
235
		} else {
236
			$pconfig['track6-prefix-id--hex'] = sprintf("%x", $wancfg['track6-prefix-id']);
237
		}
238
		break;
239
	case "6rd":
240
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
241
		if($wancfg['prefix-6rd-v4plen'] == "")
242
			$wancfg['prefix-6rd-v4plen'] = "0";
243
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
244
		$pconfig['type6'] = "6rd";
245
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
246
		break;
247
	default:
248
		if(is_ipaddr($wancfg['ipaddrv6'])) {
249
			$pconfig['type6'] = "staticv6";
250
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
251
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
252
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
253
		} else
254
			$pconfig['type6'] = "none";
255
		break;
256
}
257

    
258
// print_r($pconfig);
259

    
260
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
261
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
262
$pconfig['spoofmac'] = $wancfg['spoofmac'];
263
$pconfig['mtu'] = $wancfg['mtu'];
264
$pconfig['mss'] = $wancfg['mss'];
265

    
266
/* Wireless interface? */
267
if (isset($wancfg['wireless'])) {
268
	/* Sync first to be sure it displays the actual settings that will be used */
269
	interface_sync_wireless_clones($wancfg, false);
270
	/* Get wireless modes */
271
	$wlanif = get_real_interface($if);
272
	if (!does_interface_exist($wlanif))
273
		interface_wireless_clone($wlanif, $wancfg);
274
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
275
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
276
	$wl_modes = get_wireless_modes($if);
277
	$wl_chaninfo = get_wireless_channel_info($if);
278
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
279
	$wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna",
280
	                              "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout"));
281
	$wl_regdomain_xml_attr = array();
282
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
283
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
284
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
285
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
286
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
287
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
288
	$pconfig['standard'] = $wancfg['wireless']['standard'];
289
	$pconfig['mode'] = $wancfg['wireless']['mode'];
290
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
291
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
292
	$pconfig['channel'] = $wancfg['wireless']['channel'];
293
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
294
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
295
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
296
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
297
	$pconfig['distance'] = $wancfg['wireless']['distance'];
298
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
299
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
300
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
301
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
302
	if (isset($wancfg['wireless']['puren']['enable']))
303
		$pconfig['puremode'] = '11n';
304
	else if (isset($wancfg['wireless']['pureg']['enable']))
305
		$pconfig['puremode'] = '11g';
306
	else
307
		$pconfig['puremode'] = 'any';
308
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
309
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
310
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
311
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
312
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
313
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
314
	$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
315
	$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
316
	$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
317
	if (is_array($wancfg['wireless']['wpa'])) {
318
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
319
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
320
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
321
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
322
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
323
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
324
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
325
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
326
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
327
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
328
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
329
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
330
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
331
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
332
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
333
	}
334
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
335
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
336
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
337
		$i = 1;
338
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
339
			$pconfig['key' . $i] = $wepkey['value'];
340
			if (isset($wepkey['txkey']))
341
				$pconfig['txkey'] = $i;
342
			$i++;
343
		}
344
		if (!isset($wepkey['txkey']))
345
			$pconfig['txkey'] = 1;
346
	}
347
}
348

    
349
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
350
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
351

    
352
if ($_POST['apply']) {
353
	unset($input_errors);
354
	if (!is_subsystem_dirty('interfaces'))
355
		$intput_errors[] = gettext("You have already applied your settings!");
356
	else {
357
		unlink_if_exists("{$g['tmp_path']}/config.cache");
358
		clear_subsystem_dirty('interfaces');
359

    
360
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
361
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
362
			foreach ($toapplylist as $ifapply => $values) {
363
				if (isset($config['interfaces'][$ifapply]['enable'])) {
364
					/* check if any old addresses need purging */
365
					if(is_ipaddrv6($values['ipaddrv6'])) {
366
						$realif = get_real_interface("$ifapply");
367
						log_error("removing old v6 address {$values['ipaddrv6']} on {$realif}");
368
						mwexec("/sbin/ifconfig {$realif} inet6 {$values['ipaddrv6']} -alias");
369
					}
370
					interface_reconfigure($ifapply, true);
371
				} else {
372

    
373
					interface_bring_down($ifapply);
374
				}
375
			}
376
		}
377
		/* restart snmp so that it binds to correct address */
378
		services_snmpd_configure();
379

    
380
		/* sync filter configuration */
381
		setup_gateways_monitor();
382

    
383
		clear_subsystem_dirty('staticroutes');
384

    
385
		filter_configure();
386

    
387
		enable_rrd_graphing();
388
	}
389
	@unlink("{$g['tmp_path']}/.interfaces.apply");
390
	header("Location: interfaces.php?if={$if}");
391
	exit;
392
} else if ($_POST && $_POST['enable'] != "yes") {
393
	unset($wancfg['enable']);
394
	if (isset($wancfg['wireless']))
395
		interface_sync_wireless_clones($wancfg, false);
396
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
397
	mark_subsystem_dirty('interfaces');
398
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
399
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
400
	} else {
401
		$toapplylist = array();
402
	}
403
	$toapplylist[$if] = array();
404
	/* we need to be able remove IP aliases for IPv6 */
405
	if(($old_wancfg['ipaddrv6'] != $wancfg['ipaddrv6']) && (is_ipaddrv6($old_wancfg['ipaddrv6']))) {
406
		$toapplylist[$if]['ipaddrv6'] = "{$old_wancfg['ipaddrv6']}";
407
	}
408
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
409
	header("Location: interfaces.php?if={$if}");
410
	exit;
411
} else if ($_POST) {
412

    
413
	unset($input_errors);
414
	$pconfig = $_POST;
415
	if ($pconfig['track6-prefix-id--hex'] === "") {
416
		$pconfig['track6-prefix-id'] = "none";
417
	} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
418
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
419
	} else {
420
		$pconfig['track6-prefix-id'] = "none";
421
	}
422
	conf_mount_rw();
423

    
424
	/* filter out spaces from descriptions  */
425
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
426

    
427
	/* okay first of all, cause we are just hiding the PPPoE HTML
428
	 * fields releated to PPPoE resets, we are going to unset $_POST
429
	 * vars, if the reset feature should not be used. Otherwise the
430
	 * data validation procedure below, may trigger a false error
431
	 * message.
432
	 */
433
	if (empty($_POST['pppoe-reset-type'])) {
434
		unset($_POST['pppoe_pr_type']);
435
		unset($_POST['pppoe_resethour']);
436
		unset($_POST['pppoe_resetminute']);
437
		unset($_POST['pppoe_resetdate']);
438
		unset($_POST['pppoe_pr_preset_val']);
439
	}
440
	/* description unique? */
441
	foreach ($ifdescrs as $ifent => $ifdescr) {
442
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
443
			$input_errors[] = gettext("An interface with the specified description already exists.");
444
			break;
445
		}
446
	}
447
	/* input validation */
448
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
449
		$input_errors[] = gettext("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.");
450
	if (isset($config['dhcpd6']) && isset($config['dhcpd6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
451
		$input_errors[] = gettext("The DHCP6 Server is active on this interface and it can be used only with a static IPv6 configuration. Please disable the DHCPv6 Server service on this interface first, then change the interface configuration.");
452

    
453
	switch(strtolower($_POST['type'])) {
454
		case "staticv4":
455
			$reqdfields = explode(" ", "ipaddr subnet gateway");
456
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
457
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
458
			break;
459
		case "none":
460
			if(is_array($config['virtualip']['vip'])) {
461
				foreach ($config['virtualip']['vip'] as $vip) {
462
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if)
463
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
464
				}
465
			}
466
		case "dhcp":
467
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
468
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
469
			break;
470
		case "ppp":
471
			$reqdfields = explode(" ", "port phone");
472
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
473
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
474
			break;
475
		case "pppoe":
476
			if ($_POST['pppoe_dialondemand']) {
477
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
478
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
479
			} else {
480
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
481
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
482
			}
483
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
484
			break;
485
		case "pptp":
486
			if ($_POST['pptp_dialondemand']) {
487
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
488
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
489
			} else {
490
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
491
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
492
			}
493
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
494
			break;
495
		case "l2tp":
496
			if ($_POST['pptp_dialondemand']) {
497
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
498
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
499
			} else {
500
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
501
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
502
			}
503
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
504
			break;
505
	}
506
	switch(strtolower($_POST['type6'])) {
507
		case "staticv6":
508
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
509
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
510
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
511
			break;
512
		case "none":
513
			if(is_array($config['virtualip']['vip'])) {
514
				foreach ($config['virtualip']['vip'] as $vip) {
515
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if)
516
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
517
				}
518
			}
519
		case "dhcp6":
520
			if (in_array($wancfg['ipaddrv6'], array()))
521
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
522
			break;
523
		case "6rd":
524
			foreach ($ifdescrs as $ifent => $ifdescr) {
525
				if ($if != $ifent && (($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6']) || ($config[interfaces][$ifent]['ipaddrv6'] == "6to4")) ) {
526
					$input_errors[] = sprintf(gettext("You can only have one interface configured as %s or 6to4."),$_POST['type6']);
527
					break;
528
				}
529
			}
530
			if (in_array($wancfg['ipaddrv6'], array()))
531
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
532
			break;
533
		case "6to4":
534
			foreach ($ifdescrs as $ifent => $ifdescr) {
535
				if ($if != $ifent && (($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6']) || ($config[interfaces][$ifent]['ipaddrv6'] == "6rd")) ) {
536
					$input_errors[] = sprintf(gettext("You can only have one interface configured as %s or 6rd."),$_POST['type6']);
537
					break;
538
				}
539
			}
540
			if (in_array($wancfg['ipaddrv6'], array()))
541
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
542
			break;
543
		case "track6":
544
			/* needs to check if $track6-prefix-id is used on another interface */
545
			if (in_array($wancfg['ipaddrv6'], array()))
546
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
547

    
548
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
549
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
550
			} else {
551
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
552
				if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
553
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
554
				}
555
			}
556
			break;
557
	}
558

    
559
	
560
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
561
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
562
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr'])))
563
		$input_errors[] = gettext("A valid IPv4 address must be specified.");
564
	if (($_POST['ipaddrv6'] && !is_ipaddr($_POST['ipaddrv6'])))
565
		$input_errors[] = gettext("A valid IPv6 address must be specified.");
566
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
567
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
568
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
569
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
570
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address'])))
571
		$input_errors[] = gettext("A valid alias IP address must be specified.");
572
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
573
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
574
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
575
		$match = false;
576
		foreach($a_gateways as $gateway) {
577
			if(in_array($_POST['gateway'], $gateway)) {
578
				$match = true;
579
			}
580
		}
581
		foreach($a_gateways as $gateway) {
582
			if(in_array($_POST['gatewayv6'], $gateway)) {
583
				$match = true;
584
			}
585
		}
586
		if(!$match) {
587
			$input_errors[] = gettext("A valid gateway must be specified.");
588
		}
589
	}
590
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
591
		$input_errors[] = gettext("The service name contains invalid characters.");
592
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
593
		$input_errors[] = gettext("The idle timeout value must be an integer.");
594
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
595
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
596
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
597
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
598
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
599
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
600
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
601
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
602
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local'])))
603
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
604
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
605
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
606
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
607
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
608
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
609
		$input_errors[] = gettext("The idle timeout value must be an integer.");
610
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
611
		$input_errors[] = gettext("A valid MAC address must be specified.");
612
	if ($_POST['mtu'] && ($_POST['mtu'] < 576))
613
		$input_errors[] = gettext("The MTU must be greater than 576 bytes.");
614
	if ($_POST['mss'] && ($_POST['mss'] < 576))
615
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
616
	/* Wireless interface? */
617
	if (isset($wancfg['wireless'])) {
618
		$reqdfields = array("mode");
619
		$reqdfieldsn = array(gettext("Mode"));
620
		if ($_POST['mode'] == 'hostap') {
621
			$reqdfields[] = "ssid";
622
			$reqdfieldsn[] = gettext("SSID");
623
		}
624
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
625
		check_wireless_mode();
626
		/* loop through keys and enforce size */
627
		for ($i = 1; $i <= 4; $i++) {
628
			if ($_POST['key' . $i]) {
629
				/* 64 bit */
630
				if (strlen($_POST['key' . $i]) == 5)
631
					continue;
632
				if (strlen($_POST['key' . $i]) == 10) {
633
					/* hex key */
634
					if (stristr($_POST['key' . $i], "0x") == false) {
635
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
636
					}
637
					continue;
638
				}
639
				if (strlen($_POST['key' . $i]) == 12) {
640
					/* hex key */
641
					if(stristr($_POST['key' . $i], "0x") == false) {
642
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
643
					}
644
					continue;
645
				}
646
				/* 128 bit */
647
				if (strlen($_POST['key' . $i]) == 13)
648
					continue;
649
				if (strlen($_POST['key' . $i]) == 26) {
650
					/* hex key */
651
					if (stristr($_POST['key' . $i], "0x") == false)
652
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
653
					continue;
654
				}
655
				if(strlen($_POST['key' . $i]) == 28)
656
					continue;
657
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
658
				break;
659
			}
660
		}
661

    
662
		if ($_POST['passphrase']) {
663
                	$passlen = strlen($_POST['passphrase']);
664
                	if ($passlen < 8 || $passlen > 64)
665
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
666
		}
667
	}
668
	if (!$input_errors) {
669
		if ($wancfg['ipaddr'] != $_POST['type']) {
670
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
671
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
672
				unset($a_ppps[$pppid]);
673
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
674
				$pid = find_dhcp6c_process($wancfg['if']);
675
				if($pid)
676
					posix_kill($pid, SIGTERM);
677
			} else if ($wancfg['ipaddr'] == "dhcp") {
678
				$pid = find_dhclient_process($wancfg['if']);
679
				if($pid)
680
					posix_kill($pid, SIGTERM);
681
			}
682
				
683
		}
684
		$ppp = array();
685
		if ($wancfg['ipaddr'] != "ppp")
686
			unset($wancfg['ipaddr']);
687
		if ($wancfg['ipaddrv6'] != "ppp")
688
			unset($wancfg['ipaddrv6']);
689
		unset($wancfg['subnet']);
690
		unset($wancfg['gateway']);
691
		unset($wancfg['subnetv6']);
692
		unset($wancfg['gatewayv6']);
693
		unset($wancfg['dhcphostname']);
694
		unset($wancfg['dhcp6-duid']);
695
		unset($wancfg['dhcp6-ia-pd-len']);
696
		unset($wancfg['track6-interface']);
697
		unset($wancfg['track6-prefix-id']);		
698
		unset($wancfg['prefix-6rd']);
699
		unset($wancfg['prefix-6rd-v4plen']);
700
		unset($wancfg['gateway-6rd']);
701
		unset($wancfg['pppoe_password']);
702
		unset($wancfg['pptp_username']);
703
		unset($wancfg['pptp_password']);
704
		unset($wancfg['provider']);
705
		unset($wancfg['ondemand']);
706
		unset($wancfg['timeout']);
707
		if (isset($wancfg['pppoe']['pppoe-reset-type']))
708
			unset($wancfg['pppoe']['pppoe-reset-type']);
709
		unset($wancfg['local']);
710
		
711
		unset($wancfg['remote']);
712
		unset($a_ppps[$pppid]['apn']);
713
		unset($a_ppps[$pppid]['phone']);
714
		unset($a_ppps[$pppid]['localip']);
715
		unset($a_ppps[$pppid]['subnet']);
716
		unset($a_ppps[$pppid]['gateway']);
717
		unset($a_ppps[$pppid]['pppoe-reset-type']);
718
		unset($a_ppps[$pppid]['provider']);
719

    
720
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
721
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
722

    
723
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
724
		switch($_POST['type']) {
725
			case "staticv4":
726
				$wancfg['ipaddr'] = $_POST['ipaddr'];
727
				$wancfg['subnet'] = $_POST['subnet'];
728
				if ($_POST['gateway'] != "none") {
729
					$wancfg['gateway'] = $_POST['gateway'];
730
				}
731
				break;
732
			case "dhcp":
733
				$wancfg['ipaddr'] = "dhcp";
734
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
735
				$wancfg['alias-address'] = $_POST['alias-address'];
736
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
737
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
738
				if($gateway_item) {
739
					$a_gateways[] = $gateway_item;
740
				}
741
				break;
742
			case "carpdev-dhcp":
743
				$wancfg['ipaddr'] = "carpdev-dhcp";
744
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
745
				$wancfg['alias-address'] = $_POST['alias-address'];
746
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
747
				if($gateway_item) {
748
					$a_gateways[] = $gateway_item;
749
				}
750
				break;
751
			case "ppp":
752
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
753
				$a_ppps[$pppid]['type'] = $_POST['type'];
754
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
755
				$a_ppps[$pppid]['ports'] = $_POST['port'];
756
				$a_ppps[$pppid]['username'] = $_POST['username'];
757
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
758
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
759
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
760
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
761
				$wancfg['ipaddr'] = $_POST['type'];
762
				unset($a_ppps[$pppid]['ondemand']);
763
				unset($a_ppps[$pppid]['idletimeout']);
764
				break;
765

    
766
			case "pppoe":
767
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
768
				$a_ppps[$pppid]['type'] = $_POST['type'];
769
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
770
				if (isset($_POST['ppp_port']))
771
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
772
				else
773
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
774
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
775
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
776
				if (!empty($_POST['provider']))
777
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
778
				else
779
					$a_ppps[$pppid]['provider'] = true;
780
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
781
				if (!empty($_POST['idletimeout']))
782
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
783
				else
784
					unset($a_ppps[$pppid]['idletimeout']);
785

    
786
				if (!empty($_POST['pppoe-reset-type']))
787
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
788
				else
789
					unset($a_ppps[$pppid]['pppoe-reset-type']);
790
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
791
				$wancfg['ipaddr'] = $_POST['type'];
792
				if($gateway_item) {
793
					$a_gateways[] = $gateway_item;
794
				}
795

    
796
				break;
797
			case "pptp":
798
			case "l2tp":
799
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
800
				$a_ppps[$pppid]['type'] = $_POST['type'];
801
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
802
				if (isset($_POST['ppp_port']))
803
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
804
				else
805
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
806
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
807
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
808
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
809
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
810
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
811
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
812
				if (!empty($_POST['idletimeout']))
813
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
814
				else
815
					unset($a_ppps[$pppid]['idletimeout']);
816
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
817
				$wancfg['ipaddr'] = $_POST['type'];
818
				if($gateway_item) {
819
					$a_gateways[] = $gateway_item;
820
				}
821
				break;
822
			case "none":
823
				break;
824
		}
825
		switch($_POST['type6']) {
826
			case "staticv6":
827
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
828
				$wancfg['subnetv6'] = $_POST['subnetv6'];
829
				if ($_POST['gatewayv6'] != "none") {
830
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
831
				}
832
				break;
833
			case "slaac":
834
				$wancfg['ipaddrv6'] = "slaac";
835
				break;
836
			case "dhcp6":
837
				$wancfg['ipaddrv6'] = "dhcp6";
838
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
839
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
840
				if($gateway_item) {
841
					$a_gateways[] = $gateway_item;
842
				}
843
				break;
844
			case "6rd":
845
				$wancfg['ipaddrv6'] = "6rd";
846
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
847
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
848
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
849
				if($gateway_item) {
850
					$a_gateways[] = $gateway_item;
851
				}
852
				break;
853
			case "6to4":
854
				$wancfg['ipaddrv6'] = "6to4";
855
				break;
856
			case "track6":
857
				$wancfg['ipaddrv6'] = "track6";
858
				$wancfg['track6-interface'] = $_POST['track6-interface'];
859
				if ($_POST['track6-prefix-id--hex'] === "") {
860
					$wancfg['track6-prefix-id'] = "none";
861
				} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
862
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
863
				} else {
864
					$wancfg['track6-prefix-id'] = "none";
865
				}
866
				break;
867
			case "none":
868
				break;
869
		}
870
		handle_pppoe_reset($_POST);
871

    
872
		if($_POST['blockpriv'] == "yes") {
873
			$wancfg['blockpriv'] = true;
874
		} else {
875
			unset($wancfg['blockpriv']);
876
		}
877
		if($_POST['blockbogons'] == "yes") {
878
			$wancfg['blockbogons'] = true;
879
		} else {
880
			unset($wancfg['blockbogons']);
881
		}
882
		$wancfg['spoofmac'] = $_POST['spoofmac'];
883
		if (empty($_POST['mtu'])) {
884
			unset($wancfg['mtu']);
885
		} else {
886
			$wancfg['mtu'] = $_POST['mtu'];
887
		}
888
		if (empty($_POST['mss'])) {
889
			unset($wancfg['mss']);
890
		} else {
891
			$wancfg['mss'] = $_POST['mss'];
892
		}
893
		if (empty($_POST['mediaopt'])) {
894
			unset($wancfg['media']);
895
			unset($wancfg['mediaopt']);
896
		} else {
897
			$mediaopts = explode(' ', $_POST['mediaopt']);	
898
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
899
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
900
			else { unset($wancfg['mediaopt']); }
901
		}
902
		if (isset($wancfg['wireless'])) {
903
			handle_wireless_post();
904
		}
905

    
906
		conf_mount_ro();
907
		write_config();
908

    
909
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
910
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
911
		} else {
912
			$toapplylist = array();
913
		}
914
		$toapplylist[$if] = array();
915
		/* we need to be able remove IP aliases for IPv6 */
916
		if(($old_wancfg['ipaddrv6'] != $wancfg['ipaddrv6']) && (is_ipaddrv6($old_wancfg['ipaddrv6']))) {
917
			$toapplylist[$if]['ipaddrv6'] = $old_wancfg['ipaddrv6'];
918
		}
919
		
920
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
921

    
922
		mark_subsystem_dirty('interfaces');
923

    
924
		/* regenerate cron settings/crontab file */
925
		configure_cron();
926

    
927
		header("Location: interfaces.php?if={$if}");
928
		exit;
929
	}
930

    
931
} // end if($_POST)
932

    
933
function handle_wireless_post() {
934
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
935
	if (!is_array($wancfg['wireless']))
936
		$wancfg['wireless'] = array();
937
	$wancfg['wireless']['standard'] = $_POST['standard'];
938
	$wancfg['wireless']['mode'] = $_POST['mode'];
939
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
940
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
941
	$wancfg['wireless']['channel'] = $_POST['channel'];
942
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
943
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
944
	$wancfg['wireless']['distance'] = $_POST['distance'];
945
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
946
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
947
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
948
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
949
		foreach($wl_countries_attr as $wl_country) {
950
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
951
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
952
				break;
953
			}
954
		}
955
	}
956
	if (!is_array($wancfg['wireless']['wpa']))
957
		$wancfg['wireless']['wpa'] = array();
958
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
959
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
960
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
961
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
962
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
963
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
964
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
965
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
966
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
967
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
968
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
969
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
970
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
971
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
972
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
973
	
974
	if ($_POST['persistcommonwireless'] == "yes") {
975
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
976
			$config['wireless']['interfaces'][$wlanbaseif] = array();
977
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
978
		unset($config['wireless']['interfaces'][$wlanbaseif]);
979
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
980
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
981
	else if (isset($wancfg['wireless']['diversity']))
982
		unset($wancfg['wireless']['diversity']);
983
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
984
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
985
	else if (isset($wancfg['wireless']['txantenna']))
986
		unset($wancfg['wireless']['txantenna']);
987
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
988
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
989
	else if (isset($wancfg['wireless']['rxantenna']))
990
		unset($wancfg['wireless']['rxantenna']);
991
	if ($_POST['hidessid_enable'] == "yes")
992
		$wancfg['wireless']['hidessid']['enable'] = true;
993
	else if (isset($wancfg['wireless']['hidessid']['enable']))
994
		unset($wancfg['wireless']['hidessid']['enable']);
995
	if ($_POST['mac_acl_enable'] == "yes")
996
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
997
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
998
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
999
	if ($_POST['rsn_preauth'] == "yes")
1000
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1001
	else
1002
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1003
	if ($_POST['ieee8021x'] == "yes")
1004
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1005
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
1006
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1007
	if ($_POST['wpa_strict_rekey'] == "yes")
1008
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1009
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
1010
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1011
	if ($_POST['debug_mode'] == "yes")
1012
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1013
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
1014
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1015
	if ($_POST['wpa_enable'] == "yes")
1016
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1017
	else if (isset($wancfg['wireless']['wpa']['enable']))
1018
		unset($wancfg['wireless']['wpa']['enable']);
1019
	if ($_POST['wep_enable'] == "yes") {
1020
		if (!is_array($wancfg['wireless']['wep']))
1021
			$wancfg['wireless']['wep'] = array();
1022
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1023
	} else if (isset($wancfg['wireless']['wep']))
1024
		unset($wancfg['wireless']['wep']);
1025
	if ($_POST['wme_enable'] == "yes") {
1026
		if (!is_array($wancfg['wireless']['wme']))
1027
			$wancfg['wireless']['wme'] = array();
1028
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1029
	} else if (isset($wancfg['wireless']['wme']['enable']))
1030
		unset($wancfg['wireless']['wme']['enable']);
1031
	if ($_POST['puremode'] == "11g") {
1032
		if (!is_array($wancfg['wireless']['pureg']))
1033
			$wancfg['wireless']['pureg'] = array();
1034
		$wancfg['wireless']['pureg']['enable'] = true;
1035
	} else if ($_POST['puremode'] == "11n") {
1036
		if (!is_array($wancfg['wireless']['puren']))
1037
			$wancfg['wireless']['puren'] = array();
1038
		$wancfg['wireless']['puren']['enable'] = true;
1039
	} else {
1040
		if (isset($wancfg['wireless']['pureg']))
1041
			unset($wancfg['wireless']['pureg']);
1042
		if (isset($wancfg['wireless']['puren']))
1043
			unset($wancfg['wireless']['puren']);
1044
	}
1045
	if ($_POST['apbridge_enable'] == "yes") {
1046
		if (!is_array($wancfg['wireless']['apbridge']))
1047
			$wancfg['wireless']['apbridge'] = array();
1048
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1049
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1050
		unset($wancfg['wireless']['apbridge']['enable']);
1051
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1052
		if (!is_array($wancfg['wireless']['turbo']))
1053
			$wancfg['wireless']['turbo'] = array();
1054
		$wancfg['wireless']['turbo']['enable'] = true;
1055
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1056
		unset($wancfg['wireless']['turbo']['enable']);
1057
	$wancfg['wireless']['wep']['key'] = array();
1058
	for ($i = 1; $i <= 4; $i++) {
1059
		if ($_POST['key' . $i]) {
1060
			$newkey = array();
1061
			$newkey['value'] = $_POST['key' . $i];
1062
			if ($_POST['txkey'] == $i)
1063
				$newkey['txkey'] = true;
1064
			$wancfg['wireless']['wep']['key'][] = $newkey;
1065
		}
1066
	}
1067
	interface_sync_wireless_clones($wancfg, true);
1068
}
1069

    
1070
function check_wireless_mode() {
1071
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1072

    
1073
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1074
		return;
1075

    
1076
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1077
		$clone_count = 1;
1078
	else
1079
		$clone_count = 0;
1080
	if (is_array($config['wireless']['clone'])) {
1081
		foreach ($config['wireless']['clone'] as $clone) {
1082
			if ($clone['if'] == $wlanbaseif)
1083
				$clone_count++;
1084
		}
1085
	}
1086
	if ($clone_count > 1) {
1087
		$old_wireless_mode = $wancfg['wireless']['mode'];
1088
		$wancfg['wireless']['mode'] = $_POST['mode'];
1089
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1090
			$input_errors[] = sprintf(gettext("Unable to change mode to %s.  You may already have the maximum number of wireless clones supported in this mode."), $wlan_modes[$wancfg['wireless']['mode']]);
1091
		} else {
1092
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1093
		}
1094
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1095
	}
1096
}
1097

    
1098
// Find all possible media options for the interface
1099
$mediaopts_list = array();
1100
$intrealname = $config['interfaces'][$if]['if'];
1101
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1102
foreach ($mediaopts as $mediaopt){
1103
	preg_match("/media (.*)/", $mediaopt, $matches);
1104
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1105
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1106
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1107
	}else{
1108
		// there is only media like "media 1000baseT"
1109
		array_push($mediaopts_list, $matches[1]);
1110
	}
1111
}
1112

    
1113
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1114
$statusurl = "status_interfaces.php";
1115

    
1116
$closehead = false;
1117
include("head.inc");
1118
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP") /* , "carpdev-dhcp" => "CarpDev"*/);
1119
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "slaac" => gettext("SLAAC"), "6rd" => gettext("6rd Tunnel"), "6to4" => gettext("6to4 Tunnel"), "track6" => gettext("Track Interface"));
1120

    
1121
?>
1122

    
1123
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
1124
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1125
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1126
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1127
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1128

    
1129
<script type="text/javascript">
1130
	function updateType(t) {
1131
		switch(t) {
1132
			case "none": {
1133
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1134
				break;
1135
			}
1136
			case "staticv4": {
1137
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1138
				break;
1139
			}
1140
			case "dhcp": {
1141
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1142
				break;
1143
			}
1144
			case "ppp": {
1145
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1146
				country_list();
1147
				break;
1148
			}
1149
			case "pppoe": {
1150
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1151
				break;
1152
			}
1153
			case "l2tp":
1154
			case "pptp": {
1155
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1156
				jQuery('#pptp').show();
1157
				break;
1158
			}
1159
		}
1160
		if (t != "l2tp" && t != "pptp")
1161
			jQuery('#'+t).show();
1162
	}
1163
	function updateTypeSix(t) {
1164
		switch(t) {
1165
			case "none": {
1166
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1167
				break;
1168
			}
1169
			case "staticv6": {
1170
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1171
				break;
1172
			}
1173
			case "slaac": {
1174
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1175
				break;
1176
			}
1177
			case "dhcp6": {
1178
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1179
				break;
1180
			}
1181
			case "6rd": {
1182
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1183
				break;
1184
			}
1185
			case "6to4": {
1186
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1187
				break;
1188
			}
1189
			case "track6": {
1190
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1191
				break;
1192
			}
1193
		}
1194
		if (t != "l2tp" && t != "pptp")
1195
			jQuery('#'+t).show();
1196
	}
1197

    
1198
	function show_allcfg(obj) {
1199
		if (obj.checked)
1200
			jQuery('#allcfg').show();
1201
		else
1202
			jQuery('#allcfg').hide();
1203
	}
1204

    
1205
	function show_reset_settings(reset_type) {
1206
		if (reset_type == 'preset') {
1207
			jQuery('#pppoepresetwrap').show();
1208
			jQuery('#pppoecustomwrap').hide();
1209
		}
1210
		else if (reset_type == 'custom') {
1211
			jQuery('#pppoecustomwrap').show();
1212
			jQuery('#pppoepresetwrap').hide();
1213
		} else {
1214
			jQuery('#pppoecustomwrap').hide();
1215
			jQuery('#pppoepresetwrap').hide();
1216
		}
1217
	}
1218
	function show_mon_config() {
1219
		jQuery("#showmonbox").html('');
1220
		jQuery('#showmon').css('display','block');
1221
	}
1222

    
1223
	function openwindow(url) {
1224
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1225
		if (oWin==null || typeof(oWin)=="undefined")
1226
			return false;
1227
		else
1228
			return true;
1229
	}
1230
	function country_list() {
1231
		jQuery('#country').children().remove();
1232
		jQuery('#provider').children().remove();
1233
		jQuery('#providerplan').children().remove();
1234
		jQuery.ajax("getserviceproviders.php",{
1235
			success: function(response) {
1236
				var responseTextArr = response.split("\n");
1237
				responseTextArr.sort();
1238
				responseTextArr.each( function(value) {
1239
					var option = new Element('option');
1240
					country = value.split(":");
1241
					option.text = country[0];
1242
					option.value = country[1];
1243
					jQuery('#country').append(option);
1244
				});
1245
			}
1246
		});
1247
		jQuery('#trcountry').css('display',"table-row");
1248
	}
1249

    
1250
	function providers_list() {
1251
		jQuery('#provider').children().remove();
1252
		jQuery('#providerplan').children().remove();
1253
		jQuery.ajax("getserviceproviders.php",{
1254
			type: 'post',
1255
			data: {country : jQuery('#country').val()},
1256
			success: function(response) {
1257
				var responseTextArr = response.split("\n");
1258
				responseTextArr.sort();
1259
				responseTextArr.each( function(value) {
1260
					var option = new Element('option');
1261
					option.text = value;
1262
					option.value = value;
1263
					jQuery('#provider').append(option);
1264
				});
1265
			}
1266
		});
1267
		jQuery('#trprovider').css("display","table-row");
1268
		jQuery('#trproviderplan').css("display","none");
1269
	}
1270

    
1271
	function providerplan_list() {
1272
		jQuery('#providerplan').children().remove();
1273
		jQuery('#providerplan').append( new Element('option') );
1274
		jQuery.ajax("getserviceproviders.php",{
1275
			type: 'post',
1276
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1277
			success: function(response) {
1278
				var responseTextArr = response.split("\n");
1279
				responseTextArr.sort();
1280
				responseTextArr.each( function(value) {
1281
					if(value != "") {
1282
						providerplan = value.split(":");
1283

    
1284
						var option = new Element('option');
1285
						option.text = providerplan[0] + " - " + providerplan[1];
1286
						option.value = providerplan[1];
1287
						jQuery('#providerplan').append(option);
1288
					}
1289
				});
1290
			}
1291
		});
1292
		jQuery('#trproviderplan').css("display","table-row");
1293
	}
1294

    
1295
	function prefill_provider() {
1296
		jQuery.ajax("getserviceproviders.php",{
1297
			type: 'post',
1298
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1299
			success: function(data,textStatus,response) {
1300
				var xmldoc = response.responseXML;
1301
				var provider = xmldoc.getElementsByTagName('connection')[0];
1302
				jQuery('#username').val('');
1303
				jQuery('#password').val('');
1304
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1305
					jQuery('#phone').val('#777');
1306
					jQuery('#apn').val('');
1307
				} else {
1308
					jQuery('#phone').val('*99#');
1309
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1310
				}
1311
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1312
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1313
				jQuery('#username').val(username);
1314
				jQuery('#password').val(password);
1315
			}
1316
		});
1317
	}
1318

    
1319
</script>
1320
</head>
1321
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1322
	<?php include("fbegin.inc"); ?>
1323
	<form action="interfaces.php" method="post" name="iform" id="iform">
1324
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1325
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1326
		<?php print_info_box_np(sprintf(gettext("The %s configuration has been changed."),$wancfg['descr'])."<p>".gettext("You must apply the changes in order for them to take effect.")."<p>".gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?><br />
1327
		<?php endif; ?>
1328
		<?php if ($savemsg) print_info_box($savemsg); ?>
1329
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1330
			<tr>
1331
				<td id="mainarea">
1332
					<div class="tabcont">
1333
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1334
						<tr>
1335
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1336
						</tr>
1337
						<tr>
1338
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1339
							<td width="78%" class="vtable">
1340
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1341
							<strong><?=gettext("Enable Interface"); ?></strong>
1342
							</td>
1343
						</tr>
1344
					</table>
1345
					<div style="display:none;" name="allcfg" id="allcfg">
1346
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1347
						<tr>
1348
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1349
							<td width="78%" class="vtable">
1350
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1351
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1352
							</td>
1353
						</tr>
1354
						<tr>
1355
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1356
							<td class="vtable">
1357
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1358
								<?php
1359
									foreach ($types4 as $key => $opt) {
1360
										echo "<option onClick=\"updateType('{$key}');\"";
1361
										if ($key == $pconfig['type'])
1362
											echo " selected";
1363
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1364
										echo "</option>";
1365
									}
1366
								?>
1367
								</select>
1368
							</td>
1369
						</tr>
1370
						<tr>
1371
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1372
							<td class="vtable">
1373
								<select name="type6" onChange="updateTypeSix(this.value);" class="formselect" id="type6">
1374
								<?php
1375
									foreach ($types6 as $key => $opt) {
1376
										echo "<option onClick=\"updateTypeSix('{$key}');\"";
1377
										if ($key == $pconfig['type6'])
1378
											echo " selected";
1379
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1380
										echo "</option>";
1381
									}
1382
								?>
1383
								</select>
1384
							</td>
1385
						</tr>
1386
						<tr>
1387
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1388
							<td class="vtable">
1389
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1390
								<?php
1391
									$ip = getenv('REMOTE_ADDR');
1392
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1393
									$mac = str_replace("\n","",$mac);
1394
									if($mac):
1395
								?>
1396
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1397
								<?php endif; ?>
1398
								<br>
1399
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1400
								"address of this interface"); ?><br>
1401
								<?=gettext("(may be required with some cable connections)"); ?><br>
1402
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1403
								"or leave blank"); ?>
1404
							</td>
1405
						</tr>
1406
						<tr>
1407
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1408
							<td class="vtable">
1409
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1410
								<br>
1411
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1412
								"be used. This is typically 1500 bytes but can vary in some circumstances."); ?>
1413
							</td>
1414
						</tr>
1415
						<tr>
1416
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1417
							<td class="vtable">
1418
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1419
								<br>
1420
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1421
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1422
								"header size) will be in effect."); ?>
1423
							</td>
1424
						</tr>
1425
						<?php 
1426
						if (count($mediaopts_list) > 0){
1427
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1428
						echo "<tr>";
1429
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1430
							echo '<td class="vtable">';
1431
                                			echo '<div id="showadvmediabox"';
1432
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1433
								else echo '>';
1434
								echo '<input type="button" onClick="show_advanced_media()" value="' . gettext("Advanced") . '"></input> - ' . gettext("Show advanced option");
1435
							echo "</div>";
1436
							echo '<div id="showmediaadv" ';
1437
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1438
							else echo '>';
1439
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1440
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1441
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1442
								foreach($mediaopts_list as $mediaopt){
1443
									if ($mediaopt != rtrim($mediaopt_from_config)){
1444
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1445
									} else {
1446
										print "<option value=\"$mediaopt\" selected>" . gettext("$mediaopt") . "</option>";
1447
									}
1448
								}
1449
								echo '</select><br>';
1450
								echo gettext("Here you can explicitly set speed and duplex mode for this interface. WARNING: You MUST leave this set to autoselect (automatically negotiate speed) unless the port this interface connects to has its speed and duplex forced.");
1451
						echo '</div>';
1452
							echo '</td>';
1453
						echo '</tr>';
1454
						}
1455
						?>
1456
						<tr>
1457
							<td colspan="2" valign="top" height="16"></td>
1458
						</tr>
1459
						<tr style="display:none;" name="none" id="none">
1460
						</tr>
1461
						<tr style="display:none;" name="staticv4" id="staticv4">
1462
							<td colspan="2" style="padding:0px;">
1463
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1464
									<tr>
1465
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1466
									</tr>
1467
									<tr>
1468
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1469
										<td width="78%" class="vtable">
1470
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1471
											/
1472
											<select name="subnet" class="formselect" id="subnet">
1473
												<?php
1474
												for ($i = 32; $i > 0; $i--) {
1475
													if($i <> 31) {
1476
														echo "<option value=\"{$i}\" ";
1477
														if ($i == $pconfig['subnet']) echo "selected";
1478
														echo ">" . $i . "</option>";
1479
													}
1480
												}
1481
												?>
1482
											</select>
1483
										</td>
1484
									</tr>
1485
									<tr>
1486
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1487
										<td width="78%" class="vtable">
1488
											<select name="gateway" class="formselect" id="gateway">
1489
												<option value="none" selected><?=gettext("None"); ?></option>
1490
													<?php
1491
													if(count($a_gateways) > 0) {
1492
														foreach ($a_gateways as $gateway) {
1493
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1494
													?>
1495
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1496
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1497
															</option>
1498
													<?php
1499
															}
1500
														}
1501
													}
1502
													?>
1503
											</select>
1504
											- or  <strong><a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a></strong>
1505
											<br/>
1506
											<div id='addgwbox'>
1507
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1508
											</div>
1509
											<div id='notebox'>
1510
											</div>
1511
											<div id="status">
1512
											</div>
1513
											<div style="display:none" id="addgateway" name="addgateway">
1514
												<p>
1515
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1516
													<tr>
1517
														<td>
1518
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1519
																<tr><td>&nbsp;</td>
1520
																<tr>
1521
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1522
																</tr>
1523
																<tr><td>&nbsp;</td>
1524
																<?php
1525
																if($if == "wan" || $if == "WAN")
1526
																	$checked = " CHECKED";
1527
																?>
1528
																<tr>
1529
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1530
																</tr>
1531
																<tr>
1532
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1533
																</tr>
1534
																<tr>
1535
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1536
																</tr>
1537
																<tr>
1538
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1539
																</tr>
1540
																<tr><td>&nbsp;</td>
1541
																<tr>
1542
																	<td>&nbsp;</td>
1543
																	<td>
1544
																		<center>
1545
																			<div id='savebuttondiv'>
1546

    
1547

    
1548
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1549
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1550
																			</div>
1551
																		</center>
1552
																	</td>
1553
																</tr>
1554
																<tr><td>&nbsp;</td></tr>
1555
															</table>
1556
														</td>
1557
													</tr>
1558
												</table>
1559
												<p/>
1560
											</div>
1561
										</td>
1562
									</tr>
1563
								</table>
1564
							</td>
1565
						</tr>
1566
						<tr style="display:none;" name="staticv6" id="staticv6">
1567
							<td colspan="2" style="padding:0px;">
1568
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1569
									<tr>
1570
										<td colspan="2" valign="top">&nbsp;</td>
1571
									</tr>
1572
									<tr>
1573
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1574
									</tr>
1575
									<tr>
1576
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1577
										<td width="78%" class="vtable">
1578
											<input name="ipaddrv6" type="text" class="formfld unknown ipv4v6" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>">
1579
											/
1580
											<select name="subnetv6" class="formselect ipv4v6" id="subnetv6">
1581
												<?php
1582
												for ($i = 128; $i > 0; $i--) {
1583
													if($i <> 127) {
1584
														echo "<option value=\"{$i}\" ";
1585
														if ($i == $pconfig['subnetv6']) echo "selected";
1586
														echo ">" . $i . "</option>";
1587
													}
1588
												}
1589
												?>
1590
											</select>
1591
										</td>
1592
									</tr>
1593
									<tr>
1594
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1595
										<td width="78%" class="vtable">
1596
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1597
												<option value="none" selected><?=gettext("None"); ?></option>
1598
													<?php
1599
													if(count($a_gateways) > 0) {
1600
														foreach ($a_gateways as $gateway) {
1601
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1602
													?>
1603
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>>
1604
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1605
															</option>
1606
													<?php
1607
															}
1608
														}
1609
													}
1610
													?>
1611
											</select>
1612
											- or <strong><a OnClick="show_add_gateway_v6();" href="#"><?=gettext("add a new one."); ?></a></strong>
1613
											<br/>
1614
											<div id='addgwboxv6'>
1615
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1616
											</div>
1617
											<div id='noteboxv6'>
1618
											</div>
1619
											<div id="statusv6">
1620
											</div>
1621
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1622
												<p>
1623
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1624
													<tr>
1625
														<td>
1626
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1627
																<tr><td>&nbsp;</td>
1628
																<tr>
1629
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1630
																</tr>
1631
																<tr><td>&nbsp;</td>
1632
																<?php
1633
																if($if == "wan" || $if == "WAN")
1634
																	$checked = " CHECKED";
1635
																?>
1636
																<tr>
1637
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td>
1638
																</tr>
1639
																<tr>
1640
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>"></td>
1641
																</tr>
1642
																<tr>
1643
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayipv6" name="gatewayipv6"></td>
1644
																</tr>
1645
																<tr>
1646
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescrv6" name="gatewaydescrv6"></td>
1647
																</tr>
1648
																<tr><td>&nbsp;</td>
1649
																<tr>
1650
																	<td>&nbsp;</td>
1651
																	<td>
1652
																		<center>
1653
																			<div id='savebuttondivv6'>
1654
																				<input id="gwsavev6" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave_v6();'>
1655
																				<input id="gwcancelv6" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway_v6();'>
1656
																			</div>
1657
																		</center>
1658
																	</td>
1659
																</tr>
1660
																<tr><td>&nbsp;</td></tr>
1661
															</table>
1662
														</td>
1663
													</tr>
1664
												</table>
1665
												<p/>
1666
											</div>
1667
										</td>
1668
									</tr>
1669
								</table>
1670
							</td>
1671
						</tr>
1672
						<tr style="display:none;" name="dhcp" id="dhcp">
1673
							<td colspan="2" style="padding: 0px;">
1674
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1675
									<tr>
1676
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1677
									</tr>
1678
									<!-- Uncomment to expose DHCP+ in GUI
1679
									<tr>
1680
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1681
										<td width="78%" class="vtable">
1682
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked"; ?> >
1683
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1684
										<br/>
1685
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1686
										</td>
1687
									</tr>
1688
									-->
1689
									<tr>
1690
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1691
										<td width="78%" class="vtable">
1692
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1693
											<br>
1694
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1695
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1696
											"this (for client identification)."); ?>
1697
										</td>
1698
									</tr>
1699
									<tr>
1700
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1701
										<td width="78%" class="vtable">
1702
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1703
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1704
												<?php
1705
												for ($i = 32; $i > 0; $i--) {
1706
													if($i <> 31) {
1707
														echo "<option value=\"{$i}\" ";
1708
														if ($i == $pconfig['alias-subnet']) echo "selected";
1709
														echo ">" . $i . "</option>";
1710
													}
1711
												}
1712
												?>
1713
											</select>
1714
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1715
											"DHCP client."); ?>
1716
										</td>
1717
									</tr>
1718
								</table>
1719
							</td>
1720
						</tr>
1721
						<tr style="display:none;" name="dhcp6" id="dhcp6">
1722
							<td colspan="2" style="padding: 0px;">
1723
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1724
									<tr>
1725
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration"); ?></td>
1726
									</tr>
1727
									<!--- Leave commented out for now
1728
									<tr>
1729
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1730
										<td width="78%" class="vtable">
1731
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>">
1732
											<br>
1733
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1734
											"when requesting a DHCPv6 lease."); ?><br />
1735
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1736
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
1737
												}
1738
												printf(gettext("The current DUID is: '%s'"),$current_duid);
1739
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
1740
											?>
1741
										</td>
1742
									</tr>
1743
									-->
1744
									<tr>
1745
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1746
										<td width="78%" class="vtable">
1747
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
1748
												<?php
1749
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1750
												foreach($sizes as $bits => $length) {
1751
													echo "<option value=\"{$bits}\" ";
1752
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected";
1753
													echo ">" . $length . "</option>";
1754
												}
1755
												?>
1756
											</select>
1757
											<br>
1758
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
1759
										</td>
1760
									</tr>
1761
								</table>
1762
							</td>
1763
						</tr>
1764
						<tr style="display:none;" name="6rd" id="6rd">
1765
							<td colspan="2" style="padding: 0px;">
1766
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1767
									<tr>
1768
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
1769
									</tr>
1770
									<tr>
1771
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
1772
										<td width="78%" class="vtable">
1773
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>">
1774
											<br>
1775
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
1776
										</td>
1777
									</tr>
1778
									<tr>
1779
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
1780
										<td width="78%" class="vtable">
1781
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>">
1782
											<br>
1783
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
1784
										</td>
1785
									</tr>
1786
									<tr>
1787
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
1788
										<td width="78%" class="vtable">
1789
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
1790
												<?php
1791
												for ($i = 0; $i < 32; $i++) {
1792
													echo "<option value=\"{$i}\" ";
1793
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected";
1794
													echo ">" . $i . " bits</option>";
1795
												}
1796
												?>
1797
											</select>
1798
											<br>
1799
											<?=gettext("The value in this field is the 6RD IPv4 prefix length. Normally specified by the ISP. A value of 0 means we embed the entire IPv4 address in the 6RD prefix."); ?>
1800
										</td>
1801
									</tr>
1802
								</table>
1803
							</td>
1804
						</tr>
1805
						<tr style="display:none;" name="track6" id="track6">
1806
							<td colspan="2" style="padding: 0px;">
1807
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1808
									<tr>
1809
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
1810
									</tr>
1811
									<tr>
1812
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
1813
										<td width="78%" class="vtable">
1814
										<select name='track6-interface' class='formselect' >
1815
										<?php 
1816
											$interfaces = get_configured_interface_with_descr(false, true);
1817
											$dynv6ifs = array();
1818
											foreach ($interfaces as $iface => $ifacename) {
1819
												switch($config['interfaces'][$iface]['ipaddrv6']) {
1820
													case "6to4":
1821
													case "6rd":
1822
													case "dhcp6":
1823
														$dynv6ifs[$iface] = $ifacename;
1824
														break;
1825
													default:
1826
														continue;
1827
												}
1828
											}
1829
											foreach($dynv6ifs as $iface => $ifacename) {
1830
												echo "<option value=\"{$iface}\"";
1831
												if ($iface == $pconfig['track6-interface'])
1832
													echo " selected";
1833
												echo ">" . htmlspecialchars($ifacename) . "</option>";
1834
											}
1835
										  ?>
1836
										</select> <br>
1837
											<br>
1838
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
1839
										</td>
1840
									</tr>
1841
									<tr>
1842
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
1843
										<td width="78%" class="vtable">
1844
											<?php
1845
												if ($pconfig['track6-prefix-id'] == "none" || $pconfig['track6-prefix-id'] == "") {
1846
													$track6_prefix_id_hex = "";
1847
												} else {
1848
													$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
1849
												}
1850
											?>
1851
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
1852
											<br />
1853
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
1854
											<br />
1855
											<?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, or leave blank."), 0, $ipv6_num_prefix_ids - 1); ?>
1856
										</td>
1857
									</tr>
1858
										</td>
1859
									</tr>
1860
								</table>
1861
							</td>
1862
						</tr>
1863
						<tr style="display:none;" name="ppp" id="ppp">
1864
							<td colspan="2" style="padding: 0px;">
1865
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1866
									<tr>
1867
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1868
									</tr>
1869
									<tr name="ppp_provider" id="ppp_provider">
1870
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1871
										<td width="78%" class="vtable">
1872
											<table border="0" cellpadding="0" cellspacing="0">
1873
												<tr id="trcountry">
1874
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1875
													<td>
1876
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1877
															<option></option>
1878
														</select>
1879
													</td>
1880
												</tr>
1881
												<tr id="trprovider" style="display:none">
1882
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1883
													<td>
1884
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1885
															<option></option>
1886
														</select>
1887
													</td>
1888
												</tr>
1889
												<tr id="trproviderplan" style="display:none">
1890
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1891
													<td>
1892
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1893
															<option></option>
1894
														</select>
1895
													</td>
1896
												</tr>
1897
											</table>
1898
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1899
										</td>
1900
									</tr>
1901
									<tr>
1902
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1903
										<td width="78%" class="vtable">
1904
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1905
										</td>
1906
									</tr>
1907
									<tr>
1908
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1909
										<td width="78%" class="vtable">
1910
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1911
										</td>
1912
									</tr>
1913
									<tr name="phone_num" id="phone_num">
1914
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1915
										<td width="78%" class="vtable">
1916
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1917
										</td>
1918
									</tr>
1919
									<tr name="apn_" id="apn_">
1920
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1921
										<td width="78%" class="vtable">
1922
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1923
										</td>
1924
									</tr>
1925
									<tr name="interface" id="interface" >
1926
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1927
										<td width="78%" class="vtable">
1928
											<select name="port" id="port" class="formselect">
1929
											<?php
1930
												$portlist = glob("/dev/cua*");
1931
												$modems = glob("/dev/modem*");
1932
												$portlist = array_merge($portlist, $modems);
1933
												foreach ($portlist as $port) {
1934
													if(preg_match("/\.(lock|init)$/", $port))
1935
														continue;
1936
													echo "<option value=\"".trim($port)."\"";
1937
													if ($pconfig['port'] == $port)
1938
														echo "selected";
1939
													echo ">{$port}</option>";
1940
												}?>
1941
											</select>
1942
										</td>
1943
									</tr>
1944
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1945
										<?php if (isset($pconfig['pppid'])): ?>
1946
											<td width="78%" class="vtable">
1947
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1948
											<?=gettext("to edit PPP configuration."); ?>
1949
											</td>
1950
										<?php else: ?>
1951
											<td width="78%" class="vtable">
1952
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1953
											<?=gettext("to create a PPP configuration."); ?>
1954
											</td>
1955
										<?php endif; ?>
1956
									</tr>
1957
								</table>
1958
							</td>
1959
						</tr>
1960
						<tr style="display:none;" name="pppoe" id="pppoe">
1961
							<td colspan="2" style="padding:0px;">
1962
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1963
									<tr>
1964
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1965
									</tr>
1966
									<tr>
1967
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1968
										<td width="78%" class="vtable">
1969
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1970
										</td>
1971
									</tr>
1972
									<tr>
1973
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1974
										<td width="78%" class="vtable">
1975
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1976
										</td>
1977
									</tr>
1978
									<tr>
1979
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1980
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1981
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1982
										</td>
1983
									</tr>
1984
									<tr>
1985
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1986
										<td width="78%" class="vtable">
1987
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1988
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1989
											<?=gettext("This option causes the interface to operate in dial-on-demand mode, allowing you to have a "); ?><i><?=gettext("virtual full time"); ?></i> <?=gettext("connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected."); ?>
1990
										</td>
1991
									</tr>
1992
									<tr>
1993
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1994
										<td width="78%" class="vtable">
1995
											<input name="pppoe_idletimeout" type="text" class="formfld unknown" id="pppoe_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pppoe_idletimeout']);?>"> <?=gettext("seconds"); ?><br><?=gettext("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."); ?>
1996
										</td>
1997
									</tr>
1998
									<tr>
1999
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
2000
										<td width="78%" class="vtable">
2001
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
2002
												<tr>
2003
													<td align="left" valign="top">
2004
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
2005
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
2006
															<option value = ""><?=gettext("Disabled"); ?></option>
2007
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
2008
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
2009
														</select> <?=gettext("Select a reset timing type"); ?>
2010
														</p>
2011
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2012
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2013
														<?php else: ?>
2014
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2015
														<?php endif; ?>
2016
														<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" />
2017
														<?=gettext("hour (0-23)"); ?><br />
2018
														<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" />
2019
														<?=gettext("minute (0-59)"); ?><br />
2020
														<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']);?>" />
2021
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2022
														<br />&nbsp;<br />
2023
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2024
														<?=gettext("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."); ?>
2025
														</p>
2026
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2027
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2028
														<?php else: ?>
2029
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2030
														<?php endif; ?>
2031
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2032
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2033
														<br />
2034
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2035
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2036
														<br />
2037
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2038
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2039
														<br />
2040
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2041
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2042
														</p>
2043
													</td>
2044
												</tr>
2045
											</table>
2046
										</td>
2047
									</tr>
2048

    
2049
									<tr>
2050
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2051
										<?php if (isset($pconfig['pppid'])): ?>
2052
											<td width="78%" class="vtable">
2053
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2054
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2055
											</td>
2056
										<?php else: ?>
2057
											<td width="78%" class="vtable">
2058
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2059
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2060
											</td>
2061
										<?php endif; ?>
2062
									</tr>
2063
								</table>
2064
							</td>
2065
						</tr>
2066
						<tr style="display:none;" name="pptp" id="pptp">
2067
							<td colspan="2" style="padding:0px;">
2068
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
2069
									<tr>
2070
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2071
									</tr>
2072
									<tr>
2073
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2074
										<td width="78%" class="vtable">
2075
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
2076
										</td>
2077
									</tr>
2078
									<tr>
2079
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2080
										<td width="78%" class="vtable">
2081
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
2082
										</td>
2083
									</tr>
2084
									<tr>
2085
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2086
										<td width="78%" class="vtable">
2087
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>">
2088
											/
2089
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2090
												<?php for ($i = 31; $i > 0; $i--): ?>
2091
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected"; ?>>
2092
														<?=$i;?></option>
2093
												<?php endfor; ?>
2094
											</select>
2095
										</td>
2096
									</tr>
2097
									<tr>
2098
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2099
										<td width="78%" class="vtable">
2100
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>">
2101
										</td>
2102
									</tr>
2103
									<tr>
2104
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2105
										<td width="78%" class="vtable">
2106
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>>
2107
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
2108
											<?=gettext("This option causes the interface to operate in dial-on-demand mode, allowing you to have a"); ?> <i><?=gettext("virtual full time"); ?></i> <?=gettext("connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected."); ?>
2109
										</td>
2110
									</tr>
2111
									<tr>
2112
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2113
										<td width="78%" class="vtable">
2114
											<input name="pptp_idletimeout" type="text" class="formfld unknown" id="pptp_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pptp_idletimeout']);?>"> <?=gettext("seconds"); ?><br><?=gettext("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."); ?>
2115
										</td>
2116
									</tr>
2117
									<tr>
2118
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2119
										<?php if (isset($pconfig['pppid'])): ?>
2120
											<td width="78%" class="vtable">
2121
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2122
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2123
											</td>
2124
										<?php else: ?>
2125
											<td width="78%" class="vtable">
2126
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2127
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2128
											</td>
2129
										<?php endif; ?>
2130
									</tr>
2131
								</table>
2132
							</td>
2133
						</tr>
2134
						<?php
2135
							/* Wireless interface? */
2136
							if (isset($wancfg['wireless'])):
2137
						?>
2138
						<tr>
2139
							<td colspan="2" valign="top" height="16"></td>
2140
						</tr>
2141
						<tr>
2142
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2143
						</tr>
2144
						<tr>
2145
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2146
							<td class="vtable">
2147
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked";?>>
2148
								<br/><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2149
							</td>
2150
						</tr>
2151
						<tr>
2152
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2153
							<td class="vtable">
2154
							<select name="standard" class="formselect" id="standard">
2155
								<?php
2156
								foreach($wl_modes as $wl_standard => $wl_channels) {
2157
									echo "<option ";
2158
									if ($pconfig['standard'] == "$wl_standard")
2159
										echo "selected ";
2160
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2161
								}
2162
								?>
2163
							</select>
2164
							</td>
2165
						</tr>
2166
						<?php if (isset($wl_modes['11g'])): ?>
2167
						<tr>
2168
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2169
							<td class="vtable">
2170
								<select name="protmode" class="formselect" id="protmode">
2171
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected";?> value="off"><?=gettext("Protection mode off"); ?></option>
2172
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2173
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2174
								</select>
2175
								<br/>
2176
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2177
								<br/>
2178
							</td>
2179
						</tr>
2180
						<?php else: ?>
2181
						<input name="protmode" type="hidden" id="protmode" value="off">
2182
						<?php endif; ?>
2183
						<tr>
2184
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2185
							<td class="vtable">
2186
								<select name="txpower" class="formselect" id="txpower">
2187
									<?
2188
									for($x = 99; $x > 0; $x--) {
2189
										if($pconfig["txpower"] == $x)
2190
											$SELECTED = " SELECTED";
2191
										else
2192
											$SELECTED = "";
2193
										echo "<option {$SELECTED}>{$x}</option>\n";
2194
									}
2195
									?>
2196
								</select><br/>
2197
								<?=gettext("Note: Typically only a few discreet power settings are available and the driver will use the setting closest to the specified value.  Not all adapters support changing the transmit power setting."); ?>
2198
							</td>
2199
						</tr>
2200
						<tr>
2201
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
2202
							<td class="vtable">
2203
								<select name="channel" class="formselect" id="channel">
2204
									<option <?php if ($pconfig['channel'] == 0) echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2205
									<?php
2206
									foreach($wl_modes as $wl_standard => $wl_channels) {
2207
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
2208
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
2209
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
2210
										foreach($wl_channels as $wl_channel) {
2211
											echo "<option ";
2212
											if ($pconfig['channel'] == "$wl_channel") {
2213
												echo "selected ";
2214
											}
2215
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
2216
											if(isset($wl_chaninfo[$wl_channel]))
2217
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
2218
											echo "</option>\n";
2219
										}
2220
									}
2221
									?>
2222
								</select>
2223
								<br/>
2224
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
2225
								<br/>
2226
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
2227
							</td>
2228
						</tr>
2229
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2230
						<tr>
2231
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
2232
							<td class="vtable">
2233
								<table border="0" cellpadding="0" cellspacing="0">
2234
									<tr>
2235
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
2236
										<td>
2237
											<?=gettext("Diversity"); ?><br/>
2238
											<select name="diversity" class="formselect" id="diversity">
2239
												<option <?php if (!isset($pconfig['diversity'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2240
												<option <?php if ($pconfig['diversity'] === '0') echo "selected"; ?> value="0"><?=gettext("Off"); ?></option>
2241
												<option <?php if ($pconfig['diversity'] === '1') echo "selected"; ?> value="1"><?=gettext("On"); ?></option>
2242
											</select>
2243
										</td>
2244
										<td>&nbsp;&nbsp</td>
2245
										<?php endif; ?>
2246
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
2247
										<td>
2248
											<?=gettext("Transmit antenna"); ?><br/>
2249
											<select name="txantenna" class="formselect" id="txantenna">
2250
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2251
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2252
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
2253
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
2254
											</select>
2255
										</td>
2256
										<td>&nbsp;&nbsp</td>
2257
										<?php endif; ?>
2258
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2259
										<td>
2260
											<?=gettext("Receive antenna"); ?><br/>
2261
											<select name="rxantenna" class="formselect" id="rxantenna">
2262
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2263
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2264
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
2265
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
2266
											</select>
2267
										</td>
2268
										<?php endif; ?>
2269
									</tr>
2270
								</table>
2271
								<br/>
2272
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
2273
							</td>
2274
						</tr>
2275
						<?php endif; ?>
2276
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
2277
						<tr>
2278
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
2279
							<td class="vtable">
2280
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>">
2281
								<br/>
2282
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br/>
2283
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
2284
							</td>
2285
						</tr>
2286
						<?php endif; ?>
2287
						<tr>
2288
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
2289
							<td class="vtable">
2290
								<?=gettext("Regulatory domain"); ?><br/>
2291
								<select name="regdomain" class="formselect" id="regdomain">
2292
									<option <?php if (empty($pconfig['regdomain'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2293
									<?php
2294
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
2295
										echo "<option ";
2296
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
2297
											echo "selected ";
2298
										}
2299
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
2300
									}
2301
									?>
2302
								</select>
2303
								<br/>
2304
								<?=gettext("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."); ?>
2305
								<br/><br/>
2306
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br/>
2307
								<select name="regcountry" class="formselect" id="regcountry">
2308
									<option <?php if (empty($pconfig['regcountry'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2309
									<?php
2310
									foreach($wl_countries as $wl_country_key => $wl_country) {
2311
										echo "<option ";
2312
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
2313
											echo "selected ";
2314
										}
2315
										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";
2316
									}
2317
									?>
2318
								</select>
2319
								<br/>
2320
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
2321
								<br/><br/>
2322
								<?=gettext("Location"); ?><br/>
2323
								<select name="reglocation" class="formselect" id="reglocation">
2324
									<option <?php if (empty($pconfig['reglocation'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2325
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected"; ?> value="indoor"><?=gettext("Indoor"); ?></option>
2326
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected"; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
2327
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected"; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
2328
								</select>
2329
								<br/><br/>
2330
								<?=gettext("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."); ?>
2331
								<br/>
2332
								<?=gettext("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."); ?>
2333
							</td>
2334
						</tr>
2335
						<tr>
2336
							<td colspan="2" valign="top" height="16"></td>
2337
						</tr>
2338
						<tr>
2339
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
2340
						</tr>
2341
						<tr>
2342
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
2343
							<td class="vtable">
2344
								<select name="mode" class="formselect" id="mode">
2345
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
2346
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
2347
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap"><?=gettext("Access Point"); ?></option>
2348
								</select>
2349
							</td>
2350
						</tr>
2351
						<tr>
2352
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
2353
							<td class="vtable">
2354
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>">
2355
								<br/>
2356
								<?=gettext("Note: Only required in Access Point mode. If left blank in Ad-hoc or Infrastructure mode, this interface will connect to any available SSID"); ?>
2357
							</td>
2358
						</tr>
2359
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
2360
						<tr>
2361
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
2362
							<td class="vtable">
2363
								<select name="puremode" class="formselect" id="puremode">
2364
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected";?> value="any"><?=gettext("Any"); ?></option>
2365
									<?php if (isset($wl_modes['11g'])): ?>
2366
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected";?> value="11g"><?=gettext("802.11g"); ?></option>
2367
									<?php endif; ?>
2368
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected";?> value="11n"><?=gettext("802.11n"); ?></option>
2369
								</select>
2370
								<br/>
2371
								<?=gettext("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)."); ?>
2372
							</td>
2373
						</tr>
2374
						<?php elseif (isset($wl_modes['11g'])): ?>
2375
						<tr>
2376
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
2377
							<td class="vtable">
2378
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked";?>>
2379
								<br/><?=gettext("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)."); ?>
2380
							</td>
2381
						</tr>
2382
						<?php endif; ?>
2383
						<tr>
2384
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
2385
							<td class="vtable">
2386
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked";?>>
2387
								<br/>
2388
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
2389
								<br/>
2390
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
2391
							</td>
2392
						</tr>
2393
						<tr>
2394
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
2395
							<td class="vtable">
2396
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked";?>>
2397
								<br/><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
2398
							</td>
2399
						</tr>
2400
						<tr>
2401
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
2402
							<td class="vtable">
2403
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked";?>>
2404
								<br/>
2405
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
2406
								<br/>
2407
								<?=gettext("(this might create problems for some clients)."); ?>
2408
							</td>
2409
						</tr>
2410
						<tr>
2411
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
2412
							<td class="vtable">
2413
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked"; ?>>
2414
								<strong><?=gettext("Enable WEP"); ?></strong>
2415
								<table border="0" cellspacing="0" cellpadding="0">
2416
									<tr>
2417
										<td>&nbsp;</td>
2418
										<td>&nbsp;</td>
2419
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
2420
									</tr>
2421
									<tr>
2422
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
2423
										<td>
2424
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>">
2425
										</td>
2426
										<td align="center">
2427
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked";?>>
2428
										</td>
2429
									</tr>
2430
									<tr>
2431
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
2432
										<td>
2433
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>">
2434
										</td>
2435
										<td align="center">
2436
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked";?>>
2437
										</td>
2438
									</tr>
2439
									<tr>
2440
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
2441
										<td>
2442
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>">
2443
										</td>
2444
										<td align="center">
2445
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked";?>>
2446
										</td>
2447
									</tr>
2448
									<tr>
2449
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
2450
										<td>
2451
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>">
2452
										</td>
2453
										<td align="center">
2454
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked";?>>
2455
										</td>
2456
									</tr>
2457
								</table>
2458
								<br/>
2459
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br/>
2460
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
2461
							</td>
2462
						</tr>
2463
						<tr>
2464
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
2465
							<td class="vtable">
2466
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked"; ?>>
2467
								<strong><?=gettext("Enable WPA"); ?></strong>
2468
								<br/><br/>
2469
								<table border="0" cellspacing="0" cellpadding="0">
2470
									<tr>
2471
										<td>&nbsp;</td>
2472
										<td>&nbsp;<?=gettext("WPA Pre Shared Key"); ?>&nbsp;</td>
2473
									</tr>
2474
									<tr>
2475
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
2476
										<td>
2477
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>">
2478
										</td>
2479
									</tr>
2480
								</table>
2481
								<br/><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
2482
							</td>
2483
						</tr>
2484
						<tr>
2485
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
2486
							<td class="vtable">
2487
								<select name="wpa_mode" class="formselect" id="wpa_mode">
2488
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected";?> value="1"><?=gettext("WPA"); ?></option>
2489
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected";?> value="2"><?=gettext("WPA2"); ?></option>
2490
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2491
								</select>
2492
							</td>
2493
						</tr>
2494
						<tr>
2495
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
2496
							<td class="vtable">
2497
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
2498
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected";?> value="WPA-PSK"><?=gettext("Pre Shared Key"); ?></option>
2499
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
2500
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
2501
								</select>
2502
							</td>
2503
						</tr>
2504
						<tr>
2505
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
2506
							<td class="vtable">
2507
								<select name="auth_algs" class="formselect" id="auth_algs">
2508
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected";?> value="1"><?=gettext("Open System Authentication"); ?></option>
2509
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
2510
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2511
								</select>
2512
								<br/><?=gettext("Note: Shared Key Authentication requires WEP."); ?></br>
2513
							</td>
2514
						</tr>
2515
						<tr>
2516
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
2517
							<td class="vtable">
2518
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
2519
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
2520
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
2521
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected";?> value="TKIP"><?=gettext("TKIP"); ?></option>
2522
								</select>
2523
							</td>
2524
						</tr>
2525
						<tr>
2526
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
2527
							<td class="vtable">
2528
								<input name="wpa_group_rekey" type="text" class="formfld unknown" id="wpa_group_rekey" size="30" value="<?php echo $pconfig['wpa_group_rekey'] ? $pconfig['wpa_group_rekey'] : "60";?>">
2529
								<br/><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
2530
							</td>
2531
						</tr>
2532
						<tr>
2533
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
2534
							<td class="vtable">
2535
								<input name="wpa_gmk_rekey" type="text" class="formfld" id="wpa_gmk_rekey" size="30" value="<?php echo $pconfig['wpa_gmk_rekey'] ? $pconfig['wpa_gmk_rekey'] : "3600";?>">
2536
								<br/><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
2537
							</td>
2538
						</tr>
2539
						<tr>
2540
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
2541
							<td class="vtable">
2542
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked"; ?>>
2543
								<br/><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
2544
							</td>
2545
						</tr>
2546
						<tr>
2547
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
2548
							<td class="vtable">
2549
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked";?>>
2550
								<br/><?=gettext("Setting this option will enable 802.1x authentication."); ?>
2551
								<br/><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
2552
							</td>
2553
						</tr>
2554
						<tr>
2555
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
2556
							<td class="vtable">
2557
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>">
2558
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2559
							</td>
2560
						</tr>
2561
						<tr>
2562
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
2563
							<td class="vtable">
2564
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>">
2565
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2566
							</td>
2567
						</tr>
2568
						<tr>
2569
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
2570
							<td class="vtable">
2571
								<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']);?>">
2572
								<br/>
2573
							</td>
2574
						</tr>
2575
						<tr>
2576
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
2577
							<td class="vtable">
2578
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>">
2579
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2580
							</td>
2581
						</tr>
2582
						<tr>
2583
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
2584
							<td class="vtable">
2585
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>">
2586
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2587
							</td>
2588
						</tr>
2589
						<tr>
2590
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
2591
							<td class="vtable">
2592
								<input name="auth_server_shared_secret2" id="auth_server_shared_secret2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_shared_secret2']);?>">
2593
								<br/>
2594
							</td>
2595
						</tr>
2596
						<tr>
2597
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
2598
							<td class="vtable">
2599
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <? if ($pconfig['rsn_preauth']) echo "checked"; ?>>
2600
								<br/>
2601
							</td>
2602
						</tr>
2603
						<?php endif; ?>
2604
						<tr>
2605
							<td colspan="2" valign="top" height="16"></td>
2606
						</tr>
2607
						<tr>
2608
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
2609
						</tr>
2610
						<tr>
2611
							<td valign="middle" class="vncell">&nbsp;</td>
2612
							<td class="vtable">
2613
								<a name="rfc1918"></a>
2614
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
2615
								<strong><?=gettext("Block private networks"); ?></strong><br>
2616
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2617
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
2618
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
2619
								"leave this option turned on, unless your WAN network lies in such " .
2620
								"a private address space, too."); ?>
2621
							</td>
2622
						</tr>
2623
						<tr>
2624
							<td valign="middle" class="vncell">&nbsp;</td>
2625
							<td class="vtable">
2626
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
2627
								<strong><?=gettext("Block bogon networks"); ?></strong><br>
2628
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2629
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
2630
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
2631
								"and obviously should not appear as the source address in any packets you receive."); ?>
2632
							</td>
2633
						</tr>
2634
					</table> <!-- End "allcfg" table -->
2635
					</div> <!-- End "allcfg" div -->
2636

    
2637
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2638
						<tr>
2639
							<td width="22%" valign="top">
2640
								&nbsp;
2641
							</td>
2642
							<td width="78%">
2643
								<br/>
2644
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2645
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2646
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2647
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2648
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2649
								<?php endif; ?>
2650
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2651
							</td>
2652
						</tr>
2653
					</table>
2654
				</td>
2655
			</tr>
2656
		</table>
2657
		<!--
2658
		</div>
2659
		</td></tr>
2660
		</table>
2661
		-->
2662
	</form>
2663
	<script type="text/javascript">
2664
		var gatewayip;
2665
		var name;
2666
		var gatewayipv6;
2667
		var namev6;
2668
		function show_add_gateway() {
2669
			document.getElementById("addgateway").style.display = '';
2670
			document.getElementById("addgwbox").style.display = 'none';
2671
			document.getElementById("gateway").style.display = 'none';
2672
			document.getElementById("save").style.display = 'none';
2673
			document.getElementById("cancel").style.display = 'none';
2674
			document.getElementById("gwsave").style.display = '';
2675
			document.getElementById("gwcancel").style.display = '';
2676
			jQuery('#notebox').html("");
2677
		}
2678
		function show_add_gateway_v6() {
2679
			document.getElementById("addgatewayv6").style.display = '';
2680
			document.getElementById("addgwboxv6").style.display = 'none';
2681
			document.getElementById("gatewayv6").style.display = 'none';
2682
			document.getElementById("save").style.display = 'none';
2683
			document.getElementById("cancel").style.display = 'none';
2684
			document.getElementById("gwsave").style.display = '';
2685
			document.getElementById("gwcancel").style.display = '';
2686
			jQuery('#noteboxv6').html("");
2687
		}
2688
		function hide_add_gateway() {
2689
			document.getElementById("addgateway").style.display = 'none';
2690
			document.getElementById("addgwbox").style.display = '';
2691
			document.getElementById("gateway").style.display = '';
2692
			document.getElementById("save").style.display = '';
2693
			document.getElementById("cancel").style.display = '';
2694
			document.getElementById("gwsave").style.display = '';
2695
			document.getElementById("gwcancel").style.display = '';
2696
		}
2697
		function hide_add_gateway_v6() {
2698
			document.getElementById("addgatewayv6").style.display = 'none';
2699
			document.getElementById("addgwboxv6").style.display = '';
2700
			document.getElementById("gatewayv6").style.display = '';
2701
			document.getElementById("save").style.display = '';
2702
			document.getElementById("cancel").style.display = '';
2703
			document.getElementById("gwsave").style.display = '';
2704
			document.getElementById("gwcancel").style.display = '';
2705
		}
2706
		function hide_add_gatewaysave() {
2707
			document.getElementById("addgateway").style.display = 'none';
2708
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2709
			var iface = jQuery('#if').val();
2710
			name = jQuery('#name').val();
2711
			var descr = jQuery('#gatewaydescr').val();
2712
			gatewayip = jQuery('#gatewayip').val();
2713

    
2714
			var defaultgw = jQuery('#defaultgw').val();
2715
			var url = "system_gateways_edit.php";
2716
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2717
			jQuery.ajax(
2718
				url,
2719
				{
2720
					type: 'post',
2721
					data: pars,
2722
					error: report_failure,
2723
					complete: save_callback
2724
				});
2725
		}
2726
		function hide_add_gatewaysave_v6() {
2727
			document.getElementById("addgatewayv6").style.display = 'none';
2728
			jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2729
			var iface = jQuery('#if').val();
2730
			name = jQuery('#namev6').val();
2731
			var descr = jQuery('#gatewaydescrv6').val();
2732
			gatewayip = jQuery('#gatewayipv6').val();
2733
			var defaultgw = jQuery('#defaultgwv6').val();
2734
			var url_v6 = "system_gateways_edit.php";
2735
			var pars_v6 = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2736
			jQuery.ajax(
2737
				url_v6,
2738
				{
2739
					type: 'post',
2740
					data: pars_v6,
2741
					error: report_failure_v6,
2742
					complete: save_callback_v6
2743
				});
2744
		}
2745
		function addOption(selectbox,text,value)
2746
		{
2747
			var optn = document.createElement("OPTION");
2748
			optn.text = text;
2749
			optn.value = value;
2750
			selectbox.append(optn);
2751
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2752
			jQuery('#notebox').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2753
		}
2754
		function addOption_v6(selectbox,text,value)
2755
		{
2756
			var optn = document.createElement("OPTION");
2757
			optn.text = text;
2758
			optn.value = value;
2759
			selectbox.append(optn);
2760
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2761
			jQuery('#noteboxv6').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2762
		}
2763
		function report_failure(request, textStatus, errorThrown) {
2764
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2765
				alert(request.responseText);
2766
			} else {
2767
				alert("Sorry, we could not create your IPv4 gateway at this time.");
2768
			}
2769
			hide_add_gateway();
2770
		}
2771
		function report_failure_v6(request, textStatus, errorThrown) {
2772
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2773
				alert(request.responseText);
2774
			} else {
2775
				alert("Sorry, we could not create your IPv6 gateway at this time.");
2776
			}
2777
			hide_add_gateway_v6();
2778
		}
2779
		function save_callback(transport) {
2780
			var response = transport.responseText;
2781
			if(response) {
2782
				document.getElementById("addgateway").style.display = 'none';
2783
				hide_add_gateway();
2784
				jQuery('#status').html('');
2785
				var gwtext = escape(name) + " - " + gatewayip;
2786
				addOption(jQuery('#gateway'), gwtext, name);
2787
				// Auto submit form?
2788
				//document.iform.submit();
2789
				//jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif">');
2790
			} else {
2791
				report_failure();
2792
			}
2793
		}
2794
		function show_advanced_media() {
2795
			document.getElementById("showadvmediabox").innerHTML='';
2796
			aodiv = document.getElementById('showmediaadv');
2797
			aodiv.style.display = "block";
2798
		}
2799
		function save_callback_v6(transport) {
2800
			var response_v6 = transport.responseText;
2801
			if(response_v6) {
2802
				document.getElementById("addgatewayv6").style.display = 'none';
2803
				hide_add_gateway_v6();
2804
				jQuery('#statusv6').html('');
2805
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2806
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
2807
				// Auto submit form?
2808
				//document.iform.submit();
2809
				//jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif">');
2810
			} else {
2811
				report_failure_v6();
2812
			}
2813
		}
2814
		<?php
2815
		echo "show_allcfg(document.iform.enable);";
2816
		echo "updateType('{$pconfig['type']}');\n";
2817
		echo "updateTypeSix('{$pconfig['type6']}');\n";
2818
		?>
2819
	</script>
2820
	<?php include("fend.inc"); ?>
2821
	</body>
2822
</html>
(92-92/248)