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
	else if ($a_ppps[$pppid]['type'] == "pppoe") {
113
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
114
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
115
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
116
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
117
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
118

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

    
123
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
124
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
125
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
126
			if ($itemhash)
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
				if ($cronitem) {
136
					$pconfig['pppoe_pr_custom'] = true;
137
					$pconfig['pppoe_resetminute'] = $cronitem['minute'];
138
					$pconfig['pppoe_resethour'] = $cronitem['hour'];
139
					if ($cronitem['mday'] <> "*" && $cronitem['month'] <> "*")
140
						$pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y");
141
				}
142
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
143
				$pconfig['pppoe_pr_preset'] = true;
144
				switch ($resetTime) {
145
					case CRON_MONTHLY_PATTERN:
146
						$pconfig['pppoe_monthly'] = true;
147
						break;
148
					case CRON_WEEKLY_PATTERN:
149
						$pconfig['pppoe_weekly'] = true;
150
						break;
151
					case CRON_DAILY_PATTERN:
152
						$pconfig['pppoe_daily'] = true;
153
						break;
154
					case CRON_HOURLY_PATTERN:
155
						$pconfig['pppoe_hourly'] = true;
156
						break;
157
				}
158
			}
159
		}// End force pppoe reset at specific time
160
	}// End if type == pppoe
161
	else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp"){
162
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
163
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
164
		$pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']);
165
		$pconfig['pptp_subnet'] = explode(",",$a_ppps[$pppid]['subnet']);
166
		$pconfig['pptp_remote'] = explode(",",$a_ppps[$pppid]['gateway']);
167
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
168
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
169
	}
170
} else {
171
	$pconfig['ptpid'] = interfaces_ptpid_next();
172
	$pppid = count($a_ppps);
173
}
174
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
175
$pconfig['alias-address'] = $wancfg['alias-address'];
176
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
177
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
178
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
179
$pconfig['enable'] = isset($wancfg['enable']);
180

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

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

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

    
253
// print_r($pconfig);
254

    
255
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
256
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
257
$pconfig['spoofmac'] = $wancfg['spoofmac'];
258
$pconfig['mtu'] = $wancfg['mtu'];
259
$pconfig['mss'] = $wancfg['mss'];
260

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

    
344
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
345
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
346

    
347
if ($_POST['apply']) {
348
	unset($input_errors);
349
	if (!is_subsystem_dirty('interfaces'))
350
		$intput_errors[] = gettext("You have already applied your settings!");
351
	else {
352
		unlink_if_exists("{$g['tmp_path']}/config.cache");
353
		clear_subsystem_dirty('interfaces');
354

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

    
368
					interface_bring_down($ifapply);
369
				}
370
			}
371
		}
372
		/* restart snmp so that it binds to correct address */
373
		services_snmpd_configure();
374

    
375
		/* sync filter configuration */
376
		setup_gateways_monitor();
377

    
378
		clear_subsystem_dirty('staticroutes');
379

    
380
		filter_configure();
381

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

    
408
	unset($input_errors);
409
	$pconfig = $_POST;
410
	if ($pconfig['track6-prefix-id--hex'] === "") {
411
		$pconfig['track6-prefix-id'] = "none";
412
	} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
413
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
414
	} else {
415
		$pconfig['track6-prefix-id'] = "none";
416
	}
417
	conf_mount_rw();
418

    
419
	/* filter out spaces from descriptions  */
420
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
421

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

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

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

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

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

    
715
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
716
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
717

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

    
752
			case "pppoe":
753
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
754
				$a_ppps[$pppid]['type'] = $_POST['type'];
755
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
756
				if (isset($_POST['ppp_port']))
757
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
758
				else
759
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
760
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
761
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
762
				if (!empty($_POST['provider']))
763
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
764
				else
765
					$a_ppps[$pppid]['provider'] = true;
766
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
767
				if (!empty($_POST['idletimeout']))
768
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
769
				else
770
					unset($a_ppps[$pppid]['idletimeout']);
771

    
772
				if (!empty($_POST['pppoe-reset-type']))
773
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
774
				else
775
					unset($a_ppps[$pppid]['pppoe-reset-type']);
776
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
777
				$wancfg['ipaddr'] = $_POST['type'];
778
				if($gateway_item) {
779
					$a_gateways[] = $gateway_item;
780
				}
781

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

    
858
		if($_POST['blockpriv'] == "yes") {
859
			$wancfg['blockpriv'] = true;
860
		} else {
861
			unset($wancfg['blockpriv']);
862
		}
863
		if($_POST['blockbogons'] == "yes") {
864
			$wancfg['blockbogons'] = true;
865
		} else {
866
			unset($wancfg['blockbogons']);
867
		}
868
		$wancfg['spoofmac'] = $_POST['spoofmac'];
869
		if (empty($_POST['mtu'])) {
870
			unset($wancfg['mtu']);
871
		} else {
872
			$wancfg['mtu'] = $_POST['mtu'];
873
		}
874
		if (empty($_POST['mss'])) {
875
			unset($wancfg['mss']);
876
		} else {
877
			$wancfg['mss'] = $_POST['mss'];
878
		}
879
		if (empty($_POST['mediaopt'])) {
880
			unset($wancfg['media']);
881
			unset($wancfg['mediaopt']);
882
		} else {
883
			$mediaopts = explode(' ', $_POST['mediaopt']);	
884
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
885
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
886
			else { unset($wancfg['mediaopt']); }
887
		}
888
		if (isset($wancfg['wireless'])) {
889
			handle_wireless_post();
890
		}
891

    
892
		conf_mount_ro();
893
		write_config();
894

    
895
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
896
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
897
		} else {
898
			$toapplylist = array();
899
		}
900
		$toapplylist[$if] = array();
901
		/* we need to be able remove IP aliases for IPv6 */
902
		if(($old_wancfg['ipaddrv6'] != $wancfg['ipaddrv6']) && (is_ipaddrv6($old_wancfg['ipaddrv6']))) {
903
			$toapplylist[$if]['ipaddrv6'] = $old_wancfg['ipaddrv6'];
904
		}
905
		
906
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
907

    
908
		mark_subsystem_dirty('interfaces');
909

    
910
		/* regenerate cron settings/crontab file */
911
		configure_cron();
912

    
913
		header("Location: interfaces.php?if={$if}");
914
		exit;
915
	}
916

    
917
} // end if($_POST)
918

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

    
1060
function check_wireless_mode() {
1061
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1062

    
1063
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1064
		return;
1065

    
1066
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1067
		$clone_count = 1;
1068
	else
1069
		$clone_count = 0;
1070
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1071
		foreach ($config['wireless']['clone'] as $clone) {
1072
			if ($clone['if'] == $wlanbaseif)
1073
				$clone_count++;
1074
		}
1075
	}
1076
	if ($clone_count > 1) {
1077
		$old_wireless_mode = $wancfg['wireless']['mode'];
1078
		$wancfg['wireless']['mode'] = $_POST['mode'];
1079
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1080
			$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']]);
1081
		} else {
1082
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1083
		}
1084
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1085
	}
1086
}
1087

    
1088
// Find all possible media options for the interface
1089
$mediaopts_list = array();
1090
$intrealname = $config['interfaces'][$if]['if'];
1091
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1092
foreach ($mediaopts as $mediaopt){
1093
	preg_match("/media (.*)/", $mediaopt, $matches);
1094
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1095
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1096
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1097
	}else{
1098
		// there is only media like "media 1000baseT"
1099
		array_push($mediaopts_list, $matches[1]);
1100
	}
1101
}
1102

    
1103
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1104
$shortcut_section = "interfaces";
1105

    
1106
$closehead = false;
1107
include("head.inc");
1108
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1109
$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"));
1110

    
1111
?>
1112

    
1113
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
1114
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1115
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1116
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1117
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1118

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

    
1188
	function show_allcfg(obj) {
1189
		if (obj.checked)
1190
			jQuery('#allcfg').show();
1191
		else
1192
			jQuery('#allcfg').hide();
1193
	}
1194

    
1195
	function show_reset_settings(reset_type) {
1196
		if (reset_type == 'preset') {
1197
			jQuery('#pppoepresetwrap').show();
1198
			jQuery('#pppoecustomwrap').hide();
1199
		}
1200
		else if (reset_type == 'custom') {
1201
			jQuery('#pppoecustomwrap').show();
1202
			jQuery('#pppoepresetwrap').hide();
1203
		} else {
1204
			jQuery('#pppoecustomwrap').hide();
1205
			jQuery('#pppoepresetwrap').hide();
1206
		}
1207
	}
1208
	function show_mon_config() {
1209
		jQuery("#showmonbox").html('');
1210
		jQuery('#showmon').css('display','block');
1211
	}
1212

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

    
1240
	function providers_list() {
1241
		jQuery('#provider').children().remove();
1242
		jQuery('#providerplan').children().remove();
1243
		jQuery.ajax("getserviceproviders.php",{
1244
			type: 'post',
1245
			data: {country : jQuery('#country').val()},
1246
			success: function(response) {
1247
				var responseTextArr = response.split("\n");
1248
				responseTextArr.sort();
1249
				responseTextArr.each( function(value) {
1250
					var option = new Element('option');
1251
					option.text = value;
1252
					option.value = value;
1253
					jQuery('#provider').append(option);
1254
				});
1255
			}
1256
		});
1257
		jQuery('#trprovider').css("display","table-row");
1258
		jQuery('#trproviderplan').css("display","none");
1259
	}
1260

    
1261
	function providerplan_list() {
1262
		jQuery('#providerplan').children().remove();
1263
		jQuery('#providerplan').append( new Element('option') );
1264
		jQuery.ajax("getserviceproviders.php",{
1265
			type: 'post',
1266
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1267
			success: function(response) {
1268
				var responseTextArr = response.split("\n");
1269
				responseTextArr.sort();
1270
				responseTextArr.each( function(value) {
1271
					if(value != "") {
1272
						providerplan = value.split(":");
1273

    
1274
						var option = new Element('option');
1275
						option.text = providerplan[0] + " - " + providerplan[1];
1276
						option.value = providerplan[1];
1277
						jQuery('#providerplan').append(option);
1278
					}
1279
				});
1280
			}
1281
		});
1282
		jQuery('#trproviderplan').css("display","table-row");
1283
	}
1284

    
1285
	function prefill_provider() {
1286
		jQuery.ajax("getserviceproviders.php",{
1287
			type: 'post',
1288
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1289
			success: function(data,textStatus,response) {
1290
				var xmldoc = response.responseXML;
1291
				var provider = xmldoc.getElementsByTagName('connection')[0];
1292
				jQuery('#username').val('');
1293
				jQuery('#password').val('');
1294
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1295
					jQuery('#phone').val('#777');
1296
					jQuery('#apn').val('');
1297
				} else {
1298
					jQuery('#phone').val('*99#');
1299
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1300
				}
1301
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1302
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1303
				jQuery('#username').val(username);
1304
				jQuery('#password').val(password);
1305
			}
1306
		});
1307
	}
1308

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

    
1537

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

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

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

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