Project

General

Profile

Download (131 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
$old_wancfg['realif'] = get_real_interface($if);
90
$old_ppps = $a_ppps;
91
// Populate page descr if it does not exist.
92
if ($if == "wan" && !$wancfg['descr'])
93
	$wancfg['descr'] = "WAN";
94
else if ($if == "lan" && !$wancfg['descr'])
95
	$wancfg['descr'] = "LAN";
96

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

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

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

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

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

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

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

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

    
256
// print_r($pconfig);
257

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

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

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

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

    
358
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
359
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
360
			foreach ($toapplylist as $ifapply => $ifcfgo) {
361
				if (isset($config['interfaces'][$ifapply]['enable'])) {
362
					interface_bring_down($ifapply, false, $ifcfgo);
363
					interface_configure($ifapply, true);
364
				} else
365
					interface_bring_down($ifapply, true, $ifcfgo);
366
			}
367
		}
368
		/* restart snmp so that it binds to correct address */
369
		services_snmpd_configure();
370

    
371
		/* sync filter configuration */
372
		setup_gateways_monitor();
373

    
374
		clear_subsystem_dirty('interfaces');
375

    
376
		filter_configure();
377

    
378
		enable_rrd_graphing();
379

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

    
405
	unset($input_errors);
406
	$pconfig = $_POST;
407
	if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
408
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
409
	else
410
		$pconfig['track6-prefix-id'] = 0;
411
	conf_mount_rw();
412

    
413
	/* filter out spaces from descriptions  */
414
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
415

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

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

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

    
550

    
551
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
552
	$staticroutes = get_staticroutes(true);
553
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
554
	if ($_POST['ipaddr']) {
555
		if (!is_ipaddrv4($_POST['ipaddr']))
556
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
557
		else {
558
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
559
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
560

    
561
			foreach ($staticroutes as $route_subnet) {
562
				list($network, $subnet) = explode("/", $route_subnet);
563
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
564
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
565
					break;
566
				}
567
				unset($network, $subnet);
568
			}
569
		}
570
	}
571
	if ($_POST['ipaddrv6']) {
572
		if (!is_ipaddrv6($_POST['ipaddrv6']))
573
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
574
		else {
575
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
576
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
577

    
578
			foreach ($staticroutes as $route_subnet) {
579
				list($network, $subnet) = explode("/", $route_subnet);
580
				if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
581
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
582
					break;
583
				}
584
				unset($network, $subnet);
585
			}
586
		}
587
	}
588
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
589
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
590
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
591
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
592
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address'])))
593
		$input_errors[] = gettext("A valid alias IP address must be specified.");
594
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
595
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
596
	if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom']))
597
		$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
598
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
599
		$match = false;
600
		foreach($a_gateways as $gateway) {
601
			if(in_array($_POST['gateway'], $gateway)) {
602
				$match = true;
603
			}
604
		}
605
		foreach($a_gateways as $gateway) {
606
			if(in_array($_POST['gatewayv6'], $gateway)) {
607
				$match = true;
608
			}
609
		}
610
		if(!$match) {
611
			$input_errors[] = gettext("A valid gateway must be specified.");
612
		}
613
	}
614
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
615
		$input_errors[] = gettext("The service name contains invalid characters.");
616
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
617
		$input_errors[] = gettext("The idle timeout value must be an integer.");
618
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
619
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
620
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
621
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
622
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
623
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
624
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
625
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
626
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local'])))
627
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
628
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
629
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
630
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
631
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
632
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
633
		$input_errors[] = gettext("The idle timeout value must be an integer.");
634
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
635
		$input_errors[] = gettext("A valid MAC address must be specified.");
636
	if ($_POST['mtu']) {
637
		if ($_POST['mtu'] < 576 || $_POST['mtu'] > 9000)
638
			$input_errors[] = gettext("The MTU must be greater than 576 bytes.");
639

    
640
		if (stristr($wancfg['if'], "_vlan")) {
641
			$realhwif_array = get_parent_interface($wancfg['if']);
642
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
643
			$parent_realhwif = $realhwif_array[0];
644
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
645
			if (!empty($parent_if) && isset($config['interfaces'][$parent_if]['mtu'])) {
646
				$parent_mtu = $config['interfaces'][$parent_if]['mtu'];
647

    
648
				if ($_POST['mtu'] > $parent_mtu)
649
					$input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface.");
650
			}
651
		} else {
652
			foreach ($config['interfaces'] as $idx => $ifdata) {
653
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
654
					continue;
655

    
656
				$realhwif_array = get_parent_interface($ifdata['if']);
657
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
658
				$parent_realhwif = $realhwif_array[0];
659

    
660
				if ($parent_realhwif != $wancfg['if'])
661
					continue;
662

    
663
				if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu'])
664
					$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a bigger value"), $ifdata['descr']);
665
			}
666
		}
667
	}
668
	if ($_POST['mss'] && ($_POST['mss'] < 576))
669
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
670
	/* Wireless interface? */
671
	if (isset($wancfg['wireless'])) {
672
		$reqdfields = array("mode");
673
		$reqdfieldsn = array(gettext("Mode"));
674
		if ($_POST['mode'] == 'hostap') {
675
			$reqdfields[] = "ssid";
676
			$reqdfieldsn[] = gettext("SSID");
677
		}
678
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
679
		check_wireless_mode();
680
		/* loop through keys and enforce size */
681
		for ($i = 1; $i <= 4; $i++) {
682
			if ($_POST['key' . $i]) {
683
				/* 64 bit */
684
				if (strlen($_POST['key' . $i]) == 5)
685
					continue;
686
				if (strlen($_POST['key' . $i]) == 10) {
687
					/* hex key */
688
					if (stristr($_POST['key' . $i], "0x") == false) {
689
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
690
					}
691
					continue;
692
				}
693
				if (strlen($_POST['key' . $i]) == 12) {
694
					/* hex key */
695
					if(stristr($_POST['key' . $i], "0x") == false) {
696
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
697
					}
698
					continue;
699
				}
700
				/* 128 bit */
701
				if (strlen($_POST['key' . $i]) == 13)
702
					continue;
703
				if (strlen($_POST['key' . $i]) == 26) {
704
					/* hex key */
705
					if (stristr($_POST['key' . $i], "0x") == false)
706
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
707
					continue;
708
				}
709
				if(strlen($_POST['key' . $i]) == 28)
710
					continue;
711
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
712
				break;
713
			}
714
		}
715

    
716
		if ($_POST['passphrase']) {
717
			$passlen = strlen($_POST['passphrase']);
718
			if ($passlen < 8 || $passlen > 63)
719
				$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
720
		}
721
	}
722
	if (!$input_errors) {
723
		if ($wancfg['ipaddr'] != $_POST['type']) {
724
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
725
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
726
				unset($a_ppps[$pppid]);
727
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
728
				$pid = find_dhcp6c_process($wancfg['if']);
729
				if($pid)
730
					posix_kill($pid, SIGTERM);
731
			} else if ($wancfg['ipaddr'] == "dhcp") {
732
				$pid = find_dhclient_process($wancfg['if']);
733
				if($pid)
734
					posix_kill($pid, SIGTERM);
735
			}
736

    
737
		}
738
		$ppp = array();
739
		if ($wancfg['ipaddr'] != "ppp")
740
			unset($wancfg['ipaddr']);
741
		if ($wancfg['ipaddrv6'] != "ppp")
742
			unset($wancfg['ipaddrv6']);
743
		unset($wancfg['subnet']);
744
		unset($wancfg['gateway']);
745
		unset($wancfg['subnetv6']);
746
		unset($wancfg['gatewayv6']);
747
		unset($wancfg['dhcphostname']);
748
		unset($wancfg['dhcprejectfrom']);
749
		unset($wancfg['dhcp6-duid']);
750
		unset($wancfg['dhcp6-ia-pd-len']);
751
		unset($wancfg['dhcp6prefixonly']);
752
		unset($wancfg['dhcp6usev4iface']);
753
		unset($wancfg['track6-interface']);
754
		unset($wancfg['track6-prefix-id']);
755
		unset($wancfg['prefix-6rd']);
756
		unset($wancfg['prefix-6rd-v4plen']);
757
		unset($wancfg['gateway-6rd']);
758
		unset($wancfg['pppoe_password']);
759
		unset($wancfg['pptp_username']);
760
		unset($wancfg['pptp_password']);
761
		unset($wancfg['provider']);
762
		unset($wancfg['ondemand']);
763
		unset($wancfg['timeout']);
764
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
765
			unset($wancfg['pppoe']['pppoe-reset-type']);
766
		unset($wancfg['local']);
767

    
768
		unset($wancfg['remote']);
769
		unset($a_ppps[$pppid]['apn']);
770
		unset($a_ppps[$pppid]['phone']);
771
		unset($a_ppps[$pppid]['localip']);
772
		unset($a_ppps[$pppid]['subnet']);
773
		unset($a_ppps[$pppid]['gateway']);
774
		unset($a_ppps[$pppid]['pppoe-reset-type']);
775
		unset($a_ppps[$pppid]['provider']);
776

    
777
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
778
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
779

    
780
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
781
		switch($_POST['type']) {
782
			case "staticv4":
783
				$wancfg['ipaddr'] = $_POST['ipaddr'];
784
				$wancfg['subnet'] = $_POST['subnet'];
785
				if ($_POST['gateway'] != "none") {
786
					$wancfg['gateway'] = $_POST['gateway'];
787
				}
788
				break;
789
			case "dhcp":
790
				$wancfg['ipaddr'] = "dhcp";
791
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
792
				$wancfg['alias-address'] = $_POST['alias-address'];
793
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
794
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
795
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
796
				if($gateway_item) {
797
					$a_gateways[] = $gateway_item;
798
				}
799
				break;
800
			case "ppp":
801
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
802
				$a_ppps[$pppid]['type'] = $_POST['type'];
803
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
804
				$a_ppps[$pppid]['ports'] = $_POST['port'];
805
				$a_ppps[$pppid]['username'] = $_POST['username'];
806
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
807
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
808
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
809
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
810
				$wancfg['ipaddr'] = $_POST['type'];
811
				unset($a_ppps[$pppid]['ondemand']);
812
				unset($a_ppps[$pppid]['idletimeout']);
813
				break;
814

    
815
			case "pppoe":
816
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
817
				$a_ppps[$pppid]['type'] = $_POST['type'];
818
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
819
				if (isset($_POST['ppp_port']))
820
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
821
				else
822
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
823
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
824
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
825
				if (!empty($_POST['provider']))
826
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
827
				else
828
					$a_ppps[$pppid]['provider'] = true;
829
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
830
				if (!empty($_POST['pppoe_idletimeout']))
831
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
832
				else
833
					unset($a_ppps[$pppid]['idletimeout']);
834

    
835
				if (!empty($_POST['pppoe-reset-type']))
836
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
837
				else
838
					unset($a_ppps[$pppid]['pppoe-reset-type']);
839
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
840
				$wancfg['ipaddr'] = $_POST['type'];
841
				if($gateway_item) {
842
					$a_gateways[] = $gateway_item;
843
				}
844

    
845
				break;
846
			case "pptp":
847
			case "l2tp":
848
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
849
				$a_ppps[$pppid]['type'] = $_POST['type'];
850
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
851
				if (isset($_POST['ppp_port']))
852
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
853
				else
854
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
855
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
856
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
857
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
858
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
859
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
860
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
861
				if (!empty($_POST['pptp_idletimeout']))
862
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
863
				else
864
					unset($a_ppps[$pppid]['idletimeout']);
865
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
866
				$wancfg['ipaddr'] = $_POST['type'];
867
				if($gateway_item) {
868
					$a_gateways[] = $gateway_item;
869
				}
870
				break;
871
			case "none":
872
				break;
873
		}
874
		switch($_POST['type6']) {
875
			case "staticv6":
876
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
877
				$wancfg['subnetv6'] = $_POST['subnetv6'];
878
				if ($_POST['gatewayv6'] != "none") {
879
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
880
				}
881
				break;
882
			case "slaac":
883
				$wancfg['ipaddrv6'] = "slaac";
884
				break;
885
			case "dhcp6":
886
				$wancfg['ipaddrv6'] = "dhcp6";
887
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
888
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
889
				if($_POST['dhcp6prefixonly'] == "yes")
890
					$wancfg['dhcp6prefixonly'] = true;
891
				if($_POST['dhcp6usev4iface'] == "yes")
892
					$wancfg['dhcp6usev4iface'] = true;
893
				if($gateway_item) {
894
					$a_gateways[] = $gateway_item;
895
				}
896
				break;
897
			case "6rd":
898
				$wancfg['ipaddrv6'] = "6rd";
899
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
900
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
901
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
902
				if($gateway_item) {
903
					$a_gateways[] = $gateway_item;
904
				}
905
				break;
906
			case "6to4":
907
				$wancfg['ipaddrv6'] = "6to4";
908
				break;
909
			case "track6":
910
				$wancfg['ipaddrv6'] = "track6";
911
				$wancfg['track6-interface'] = $_POST['track6-interface'];
912
				if ($_POST['track6-prefix-id--hex'] === "")
913
					$wancfg['track6-prefix-id'] = 0;
914
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
915
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
916
				else
917
					$wancfg['track6-prefix-id'] = 0;
918
				break;
919
			case "none":
920
				break;
921
		}
922
		handle_pppoe_reset($_POST);
923

    
924
		if($_POST['blockpriv'] == "yes") {
925
			$wancfg['blockpriv'] = true;
926
		} else {
927
			unset($wancfg['blockpriv']);
928
		}
929
		if($_POST['blockbogons'] == "yes") {
930
			$wancfg['blockbogons'] = true;
931
		} else {
932
			unset($wancfg['blockbogons']);
933
		}
934
		$wancfg['spoofmac'] = $_POST['spoofmac'];
935
		if (empty($_POST['mtu'])) {
936
			unset($wancfg['mtu']);
937
		} else {
938
			$wancfg['mtu'] = $_POST['mtu'];
939
		}
940
		if (empty($_POST['mss'])) {
941
			unset($wancfg['mss']);
942
		} else {
943
			$wancfg['mss'] = $_POST['mss'];
944
		}
945
		if (empty($_POST['mediaopt'])) {
946
			unset($wancfg['media']);
947
			unset($wancfg['mediaopt']);
948
		} else {
949
			$mediaopts = explode(' ', $_POST['mediaopt']);
950
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
951
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
952
			else { unset($wancfg['mediaopt']); }
953
		}
954
		if (isset($wancfg['wireless'])) {
955
			handle_wireless_post();
956
		}
957

    
958
		conf_mount_ro();
959
		write_config();
960

    
961
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
962
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
963
		} else {
964
			$toapplylist = array();
965
		}
966
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
967
		$toapplylist[$if]['ppps'] = $old_ppps;
968
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
969

    
970
		mark_subsystem_dirty('interfaces');
971

    
972
		/* regenerate cron settings/crontab file */
973
		configure_cron();
974

    
975
		header("Location: interfaces.php?if={$if}");
976
		exit;
977
	}
978

    
979
} // end if($_POST)
980

    
981
function handle_wireless_post() {
982
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
983
	if (!is_array($wancfg['wireless']))
984
		$wancfg['wireless'] = array();
985
	$wancfg['wireless']['standard'] = $_POST['standard'];
986
	$wancfg['wireless']['mode'] = $_POST['mode'];
987
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
988
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
989
	$wancfg['wireless']['channel'] = $_POST['channel'];
990
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
991
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
992
	$wancfg['wireless']['distance'] = $_POST['distance'];
993
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
994
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
995
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
996
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
997
		foreach($wl_countries_attr as $wl_country) {
998
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
999
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1000
				break;
1001
			}
1002
		}
1003
	}
1004
	if (!is_array($wancfg['wireless']['wpa']))
1005
		$wancfg['wireless']['wpa'] = array();
1006
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1007
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1008
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1009
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1010
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1011
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1012
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1013
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1014
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1015
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1016
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1017
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1018
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1019
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1020
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1021

    
1022
	if ($_POST['persistcommonwireless'] == "yes") {
1023
		if (!is_array($config['wireless']))
1024
			$config['wireless'] = array();
1025
		if (!is_array($config['wireless']['interfaces']))
1026
			$config['wireless']['interfaces'] = array();
1027
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
1028
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1029
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
1030
		unset($config['wireless']['interfaces'][$wlanbaseif]);
1031
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
1032
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1033
	else if (isset($wancfg['wireless']['diversity']))
1034
		unset($wancfg['wireless']['diversity']);
1035
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
1036
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1037
	else if (isset($wancfg['wireless']['txantenna']))
1038
		unset($wancfg['wireless']['txantenna']);
1039
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
1040
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1041
	else if (isset($wancfg['wireless']['rxantenna']))
1042
		unset($wancfg['wireless']['rxantenna']);
1043
	if ($_POST['hidessid_enable'] == "yes")
1044
		$wancfg['wireless']['hidessid']['enable'] = true;
1045
	else if (isset($wancfg['wireless']['hidessid']['enable']))
1046
		unset($wancfg['wireless']['hidessid']['enable']);
1047
	if ($_POST['mac_acl_enable'] == "yes")
1048
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1049
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
1050
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1051
	if ($_POST['rsn_preauth'] == "yes")
1052
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1053
	else
1054
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1055
	if ($_POST['ieee8021x'] == "yes")
1056
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1057
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
1058
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1059
	if ($_POST['wpa_strict_rekey'] == "yes")
1060
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1061
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
1062
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1063
	if ($_POST['debug_mode'] == "yes")
1064
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1065
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
1066
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1067
	if ($_POST['wpa_enable'] == "yes")
1068
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1069
	else if (isset($wancfg['wireless']['wpa']['enable']))
1070
		unset($wancfg['wireless']['wpa']['enable']);
1071
	if ($_POST['wep_enable'] == "yes") {
1072
		if (!is_array($wancfg['wireless']['wep']))
1073
			$wancfg['wireless']['wep'] = array();
1074
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1075
	} else if (isset($wancfg['wireless']['wep']))
1076
		unset($wancfg['wireless']['wep']);
1077
	if ($_POST['wme_enable'] == "yes") {
1078
		if (!is_array($wancfg['wireless']['wme']))
1079
			$wancfg['wireless']['wme'] = array();
1080
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1081
	} else if (isset($wancfg['wireless']['wme']['enable']))
1082
		unset($wancfg['wireless']['wme']['enable']);
1083
	if ($_POST['puremode'] == "11g") {
1084
		if (!is_array($wancfg['wireless']['pureg']))
1085
			$wancfg['wireless']['pureg'] = array();
1086
		$wancfg['wireless']['pureg']['enable'] = true;
1087
	} else if ($_POST['puremode'] == "11n") {
1088
		if (!is_array($wancfg['wireless']['puren']))
1089
			$wancfg['wireless']['puren'] = array();
1090
		$wancfg['wireless']['puren']['enable'] = true;
1091
	} else {
1092
		if (isset($wancfg['wireless']['pureg']))
1093
			unset($wancfg['wireless']['pureg']);
1094
		if (isset($wancfg['wireless']['puren']))
1095
			unset($wancfg['wireless']['puren']);
1096
	}
1097
	if ($_POST['apbridge_enable'] == "yes") {
1098
		if (!is_array($wancfg['wireless']['apbridge']))
1099
			$wancfg['wireless']['apbridge'] = array();
1100
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1101
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1102
		unset($wancfg['wireless']['apbridge']['enable']);
1103
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1104
		if (!is_array($wancfg['wireless']['turbo']))
1105
			$wancfg['wireless']['turbo'] = array();
1106
		$wancfg['wireless']['turbo']['enable'] = true;
1107
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1108
		unset($wancfg['wireless']['turbo']['enable']);
1109
	$wancfg['wireless']['wep']['key'] = array();
1110
	for ($i = 1; $i <= 4; $i++) {
1111
		if ($_POST['key' . $i]) {
1112
			$newkey = array();
1113
			$newkey['value'] = $_POST['key' . $i];
1114
			if ($_POST['txkey'] == $i)
1115
				$newkey['txkey'] = true;
1116
			$wancfg['wireless']['wep']['key'][] = $newkey;
1117
		}
1118
	}
1119
	interface_sync_wireless_clones($wancfg, true);
1120
}
1121

    
1122
function check_wireless_mode() {
1123
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1124

    
1125
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1126
		return;
1127

    
1128
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1129
		$clone_count = 1;
1130
	else
1131
		$clone_count = 0;
1132
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1133
		foreach ($config['wireless']['clone'] as $clone) {
1134
			if ($clone['if'] == $wlanbaseif)
1135
				$clone_count++;
1136
		}
1137
	}
1138
	if ($clone_count > 1) {
1139
		$old_wireless_mode = $wancfg['wireless']['mode'];
1140
		$wancfg['wireless']['mode'] = $_POST['mode'];
1141
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1142
			$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']]);
1143
		} else {
1144
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1145
		}
1146
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1147
	}
1148
}
1149

    
1150
// Find all possible media options for the interface
1151
$mediaopts_list = array();
1152
$intrealname = $config['interfaces'][$if]['if'];
1153
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1154
foreach ($mediaopts as $mediaopt){
1155
	preg_match("/media (.*)/", $mediaopt, $matches);
1156
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1157
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1158
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1159
	}else{
1160
		// there is only media like "media 1000baseT"
1161
		array_push($mediaopts_list, $matches[1]);
1162
	}
1163
}
1164

    
1165
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1166
$shortcut_section = "interfaces";
1167

    
1168
$closehead = false;
1169
include("head.inc");
1170
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1171
$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"));
1172

    
1173
?>
1174

    
1175
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1176
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1177
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1178
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1179

    
1180
<script type="text/javascript">
1181
	function updateType(t) {
1182
		switch(t) {
1183
			case "none": {
1184
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1185
				break;
1186
			}
1187
			case "staticv4": {
1188
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1189
				break;
1190
			}
1191
			case "dhcp": {
1192
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1193
				break;
1194
			}
1195
			case "ppp": {
1196
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1197
				country_list();
1198
				break;
1199
			}
1200
			case "pppoe": {
1201
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1202
				break;
1203
			}
1204
			case "l2tp":
1205
			case "pptp": {
1206
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1207
				jQuery('#pptp').show();
1208
				break;
1209
			}
1210
		}
1211
		if (t != "l2tp" && t != "pptp")
1212
			jQuery('#'+t).show();
1213
	}
1214
	function updateTypeSix(t) {
1215
		switch(t) {
1216
			case "none": {
1217
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1218
				break;
1219
			}
1220
			case "staticv6": {
1221
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1222
				break;
1223
			}
1224
			case "slaac": {
1225
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1226
				break;
1227
			}
1228
			case "dhcp6": {
1229
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1230
				break;
1231
			}
1232
			case "6rd": {
1233
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1234
				break;
1235
			}
1236
			case "6to4": {
1237
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1238
				break;
1239
			}
1240
			case "track6": {
1241
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1242
				break;
1243
			}
1244
		}
1245
		if (t != "l2tp" && t != "pptp")
1246
			jQuery('#'+t).show();
1247
	}
1248

    
1249
	function show_allcfg(obj) {
1250
		if (obj.checked)
1251
			jQuery('#allcfg').show();
1252
		else
1253
			jQuery('#allcfg').hide();
1254
	}
1255

    
1256
	function show_reset_settings(reset_type) {
1257
		if (reset_type == 'preset') {
1258
			jQuery('#pppoepresetwrap').show();
1259
			jQuery('#pppoecustomwrap').hide();
1260
		}
1261
		else if (reset_type == 'custom') {
1262
			jQuery('#pppoecustomwrap').show();
1263
			jQuery('#pppoepresetwrap').hide();
1264
		} else {
1265
			jQuery('#pppoecustomwrap').hide();
1266
			jQuery('#pppoepresetwrap').hide();
1267
		}
1268
	}
1269
	function show_mon_config() {
1270
		jQuery("#showmonbox").html('');
1271
		jQuery('#showmon').css('display','block');
1272
	}
1273

    
1274
	function openwindow(url) {
1275
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1276
		if (oWin==null || typeof(oWin)=="undefined")
1277
			return false;
1278
		else
1279
			return true;
1280
	}
1281
	function country_list() {
1282
		jQuery('#country').children().remove();
1283
		jQuery('#provider').children().remove();
1284
		jQuery('#providerplan').children().remove();
1285
		jQuery.ajax("getserviceproviders.php",{
1286
			success: function(response) {
1287
				var responseTextArr = response.split("\n");
1288
				responseTextArr.sort();
1289
				responseTextArr.each( function(value) {
1290
					var option = new Element('option');
1291
					country = value.split(":");
1292
					option.text = country[0];
1293
					option.value = country[1];
1294
					jQuery('#country').append(option);
1295
				});
1296
			}
1297
		});
1298
		jQuery('#trcountry').css('display',"table-row");
1299
	}
1300

    
1301
	function providers_list() {
1302
		jQuery('#provider').children().remove();
1303
		jQuery('#providerplan').children().remove();
1304
		jQuery.ajax("getserviceproviders.php",{
1305
			type: 'post',
1306
			data: {country : jQuery('#country').val()},
1307
			success: function(response) {
1308
				var responseTextArr = response.split("\n");
1309
				responseTextArr.sort();
1310
				responseTextArr.each( function(value) {
1311
					var option = new Element('option');
1312
					option.text = value;
1313
					option.value = value;
1314
					jQuery('#provider').append(option);
1315
				});
1316
			}
1317
		});
1318
		jQuery('#trprovider').css("display","table-row");
1319
		jQuery('#trproviderplan').css("display","none");
1320
	}
1321

    
1322
	function providerplan_list() {
1323
		jQuery('#providerplan').children().remove();
1324
		jQuery('#providerplan').append( new Element('option') );
1325
		jQuery.ajax("getserviceproviders.php",{
1326
			type: 'post',
1327
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1328
			success: function(response) {
1329
				var responseTextArr = response.split("\n");
1330
				responseTextArr.sort();
1331
				responseTextArr.each( function(value) {
1332
					if(value != "") {
1333
						providerplan = value.split(":");
1334

    
1335
						var option = new Element('option');
1336
						option.text = providerplan[0] + " - " + providerplan[1];
1337
						option.value = providerplan[1];
1338
						jQuery('#providerplan').append(option);
1339
					}
1340
				});
1341
			}
1342
		});
1343
		jQuery('#trproviderplan').css("display","table-row");
1344
	}
1345

    
1346
	function prefill_provider() {
1347
		jQuery.ajax("getserviceproviders.php",{
1348
			type: 'post',
1349
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1350
			success: function(data,textStatus,response) {
1351
				var xmldoc = response.responseXML;
1352
				var provider = xmldoc.getElementsByTagName('connection')[0];
1353
				jQuery('#username').val('');
1354
				jQuery('#password').val('');
1355
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1356
					jQuery('#phone').val('#777');
1357
					jQuery('#apn').val('');
1358
				} else {
1359
					jQuery('#phone').val('*99#');
1360
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1361
				}
1362
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1363
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1364
				jQuery('#username').val(username);
1365
				jQuery('#password').val(password);
1366
			}
1367
		});
1368
	}
1369

    
1370
</script>
1371
</head>
1372
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1373
	<?php include("fbegin.inc"); ?>
1374
	<form action="interfaces.php" method="post" name="iform" id="iform">
1375
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1376
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1377
		<?php print_info_box_np(sprintf(gettext("The %s configuration has been changed."),$wancfg['descr'])."</p><p>".gettext("You must apply the changes in order for them to take effect.")."</p><p>".gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?></p><br />
1378
		<?php endif; ?>
1379
		<?php if ($savemsg) print_info_box($savemsg); ?>
1380
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces">
1381
			<tr>
1382
				<td id="mainarea">
1383
					<div class="tabcont">
1384
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
1385
						<tr>
1386
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1387
						</tr>
1388
						<tr>
1389
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1390
							<td width="78%" class="vtable">
1391
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked=\"checked\""; ?> onclick="show_allcfg(this);" />
1392
							<strong><?=gettext("Enable Interface"); ?></strong>
1393
							</td>
1394
						</tr>
1395
					</table>
1396
					<div style="display:none;" name="allcfg" id="allcfg">
1397
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="allcfg">
1398
						<tr>
1399
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1400
							<td width="78%" class="vtable">
1401
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>" />
1402
								<br/><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1403
							</td>
1404
						</tr>
1405
						<tr>
1406
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1407
							<td class="vtable">
1408
								<select name="type" onchange="updateType(this.value);" class="formselect" id="type">
1409
								<?php
1410
									foreach ($types4 as $key => $opt) {
1411
										echo "<option onclick=\"updateType('{$key}');\"";
1412
										if ($key == $pconfig['type'])
1413
											echo " selected=\"selected\"";
1414
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1415
										echo "</option>";
1416
									}
1417
								?>
1418
								</select>
1419
							</td>
1420
						</tr>
1421
						<tr>
1422
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1423
							<td class="vtable">
1424
								<select name="type6" onchange="updateTypeSix(this.value);" class="formselect" id="type6">
1425
								<?php
1426
									foreach ($types6 as $key => $opt) {
1427
										echo "<option onclick=\"updateTypeSix('{$key}');\"";
1428
										if ($key == $pconfig['type6'])
1429
											echo " selected=\"selected\"";
1430
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1431
										echo "</option>";
1432
									}
1433
								?>
1434
								</select>
1435
							</td>
1436
						</tr>
1437
						<tr>
1438
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1439
							<td class="vtable">
1440
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>" />
1441
								<?php
1442
									$ip = getenv('REMOTE_ADDR');
1443
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1444
									$mac = str_replace("\n","",$mac);
1445
									if($mac):
1446
								?>
1447
									<a onclick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1448
								<?php endif; ?>
1449
								<br/>
1450
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1451
								"address of this interface"); ?><br/>
1452
								<?=gettext("(may be required with some cable connections)"); ?><br/>
1453
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1454
								"or leave blank"); ?>
1455
							</td>
1456
						</tr>
1457
						<tr>
1458
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1459
							<td class="vtable">
1460
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>" />
1461
								<br/>
1462
								<?php
1463
									print gettext("If you leave this field blank, the adapter's default MTU will " .
1464
									"be used. This is typically 1500 bytes but can vary in some circumstances.");
1465
								?>
1466
							</td>
1467
						</tr>
1468
						<tr>
1469
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1470
							<td class="vtable">
1471
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>" />
1472
								<br/>
1473
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1474
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1475
								"header size) will be in effect."); ?>
1476
							</td>
1477
						</tr>
1478
						<?php
1479
						if (count($mediaopts_list) > 0){
1480
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1481
						echo "<tr>";
1482
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1483
							echo '<td class="vtable">';
1484
							echo '<div id="showadvmediabox"';
1485
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1486
								else echo '>';
1487
								echo '<input type="button" onclick="show_advanced_media()" value="' . gettext("Advanced") . '" /> - ' . gettext("Show advanced option");
1488
							echo "</div>";
1489
							echo '<div id="showmediaadv" ';
1490
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1491
							else echo '>';
1492
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1493
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1494
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1495
								foreach($mediaopts_list as $mediaopt){
1496
									if ($mediaopt != rtrim($mediaopt_from_config)){
1497
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1498
									} else {
1499
										print "<option value=\"$mediaopt\" selected=\"selected\">" . gettext("$mediaopt") . "</option>";
1500
									}
1501
								}
1502
								echo '</select><br/>';
1503
								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.");
1504
						echo '</div>';
1505
							echo '</td>';
1506
						echo '</tr>';
1507
						}
1508
						?>
1509
						<tr>
1510
							<td colspan="2" valign="top" height="16"></td>
1511
						</tr>
1512
						<tr style="display:none;" name="none" id="none"><td style="display:none;"></td></tr>
1513
						<tr style="display:none;" name="staticv4" id="staticv4">
1514
							<td colspan="2" style="padding:0px;">
1515
								<a name="gatewaysection"></a>
1516
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv4">
1517
									<tr>
1518
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1519
									</tr>
1520
									<tr>
1521
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1522
										<td width="78%" class="vtable">
1523
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" />
1524
											/
1525
											<select name="subnet" class="formselect" id="subnet">
1526
												<?php
1527
												for ($i = 32; $i > 0; $i--) {
1528
													if($i <> 31) {
1529
														echo "<option value=\"{$i}\" ";
1530
														if ($i == $pconfig['subnet']) echo "selected=\"selected\"";
1531
														echo ">" . $i . "</option>";
1532
													}
1533
												}
1534
												?>
1535
											</select>
1536
										</td>
1537
									</tr>
1538
									<tr>
1539
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1540
										<td width="78%" class="vtable">
1541
											<select name="gateway" class="formselect" id="gateway">
1542
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1543
													<?php
1544
													if(count($a_gateways) > 0) {
1545
														foreach ($a_gateways as $gateway) {
1546
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1547
													?>
1548
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected=\"selected\""; ?>>
1549
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1550
															</option>
1551
													<?php
1552
															}
1553
														}
1554
													}
1555
													?>
1556
											</select>
1557
											- or  <strong><a onclick="show_add_gateway();" href="#gatewaysection"><?=gettext("add a new one."); ?></a></strong>
1558
											<br/>
1559
											<div id='addgwbox'>
1560
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1561
											</div>
1562
											<div id='notebox'>
1563
											</div>
1564
											<div id="status">
1565
											</div>
1566
											<div style="display:none" id="addgateway" name="addgateway">
1567
												<p>&nbsp;</p>
1568
												<table border="1" class="addgatewaybox" summary="addgateway">
1569
													<tr>
1570
														<td>
1571
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgateway">
1572
																<tr><td>&nbsp;</td></tr>
1573
																<tr>
1574
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1575
																</tr>
1576
																<tr><td>&nbsp;</td></tr>
1577
																<?php
1578
																if($if == "wan" || $if == "WAN")
1579
																	$checked = " checked=\"checked\"";
1580
																?>
1581
																<tr>
1582
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></font></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?> /></td>
1583
																</tr>
1584
																<tr>
1585
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></font></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>" /></td>
1586
																</tr>
1587
																<tr>
1588
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></font></td><td><input id="gatewayip" name="gatewayip" /></td>
1589
																</tr>
1590
																<tr>
1591
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescr" name="gatewaydescr" /></td>
1592
																</tr>
1593
																<tr><td>&nbsp;</td></tr>
1594
																<tr>
1595
																	<td colspan="2">
1596
																		<center>
1597
																			<div id='savebuttondiv'>
1598
																				<input id="gwsave" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave();' />
1599
																				<input id="gwcancel" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway();' />
1600
																			</div>
1601
																		</center>
1602
																	</td>
1603
																</tr>
1604
																<tr><td>&nbsp;</td></tr>
1605
															</table>
1606
														</td>
1607
													</tr>
1608
												</table>
1609
											</div>
1610
										</td>
1611
									</tr>
1612
									<tr>
1613
										<td colspan="2" valign="top" height="16"></td>
1614
									</tr>
1615
								</table>
1616
							</td>
1617
						</tr>
1618
						<tr style="display:none;" name="staticv6" id="staticv6">
1619
							<td colspan="2" style="padding:0px;">
1620
								<a name="gatewayv6section"></a>
1621
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv6">
1622
									<tr>
1623
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1624
									</tr>
1625
									<tr>
1626
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1627
										<td width="78%" class="vtable">
1628
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>" />
1629
											/
1630
											<select name="subnetv6" class="formselect" id="subnetv6">
1631
												<?php
1632
												for ($i = 128; $i > 0; $i--) {
1633
													if($i <> 127) {
1634
														echo "<option value=\"{$i}\" ";
1635
														if ($i == $pconfig['subnetv6']) echo "selected=\"selected\"";
1636
														echo ">" . $i . "</option>";
1637
													}
1638
												}
1639
												?>
1640
											</select>
1641
										</td>
1642
									</tr>
1643
									<tr>
1644
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1645
										<td width="78%" class="vtable">
1646
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1647
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1648
													<?php
1649
													if(count($a_gateways) > 0) {
1650
														foreach ($a_gateways as $gateway) {
1651
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1652
													?>
1653
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected=\"selected\""; ?>>
1654
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1655
															</option>
1656
													<?php
1657
															}
1658
														}
1659
													}
1660
													?>
1661
											</select>
1662
											- or <strong><a onclick="show_add_gateway_v6();" href="#gatewayv6section"><?=gettext("add a new one."); ?></a></strong>
1663
											<br/>
1664
											<div id='addgwboxv6'>
1665
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1666
											</div>
1667
											<div id='noteboxv6'>
1668
											</div>
1669
											<div id="statusv6">
1670
											</div>
1671
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1672
												<p>&nbsp;</p>
1673
												<table border="1" class="addgatewaybox" summary="addgatewayv6">
1674
													<tr>
1675
														<td>
1676
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgatewayv6">
1677
																<tr><td>&nbsp;</td></tr>
1678
																<tr>
1679
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1680
																</tr>
1681
																<tr><td>&nbsp;</td></tr>
1682
																<?php
1683
																if($if == "wan" || $if == "WAN")
1684
																	$checked = " checked=\"checked\"";
1685
																?>
1686
																<tr>
1687
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></font></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?> /></td>
1688
																</tr>
1689
																<tr>
1690
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></font></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>" /></td>
1691
																</tr>
1692
																<tr>
1693
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></font></td><td><input id="gatewayipv6" name="gatewayipv6" /></td>
1694
																</tr>
1695
																<tr>
1696
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescrv6" name="gatewaydescrv6" /></td>
1697
																</tr>
1698
																<tr><td>&nbsp;</td></tr>
1699
																<tr>
1700
																	<td colspan="2">
1701
																		<center>
1702
																			<div id='savebuttondivv6'>
1703
																				<input id="gwsavev6" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave_v6();' />
1704
																				<input id="gwcancelv6" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway_v6();' />
1705
																			</div>
1706
																		</center>
1707
																	</td>
1708
																</tr>
1709
																<tr><td>&nbsp;</td></tr>
1710
															</table>
1711
														</td>
1712
													</tr>
1713
												</table>
1714
											</div>
1715
										</td>
1716
									</tr>
1717
									<tr>
1718
										<td colspan="2" valign="top" height="16"></td>
1719
									</tr>
1720
								</table>
1721
							</td>
1722
						</tr>
1723
						<tr style="display:none;" name="dhcp" id="dhcp">
1724
							<td colspan="2" style="padding: 0px;">
1725
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp">
1726
									<tr>
1727
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1728
									</tr>
1729
									<!-- Uncomment to expose DHCP+ in GUI
1730
									<tr>
1731
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1732
										<td width="78%" class="vtable">
1733
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked=\"checked\""; ?> />
1734
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1735
										<br/>
1736
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1737
										</td>
1738
									</tr>
1739
									-->
1740
									<tr>
1741
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1742
										<td width="78%" class="vtable">
1743
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>" />
1744
											<br/>
1745
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1746
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1747
											"this (for client identification)."); ?>
1748
										</td>
1749
									</tr>
1750
									<tr>
1751
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1752
										<td width="78%" class="vtable">
1753
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>" />
1754
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1755
												<?php
1756
												for ($i = 32; $i > 0; $i--) {
1757
													if($i <> 31) {
1758
														echo "<option value=\"{$i}\" ";
1759
														if ($i == $pconfig['alias-subnet']) echo "selected=\"selected\"";
1760
														echo ">" . $i . "</option>";
1761
													}
1762
												}
1763
												?>
1764
											</select>
1765
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1766
											"DHCP client."); ?>
1767
										</td>
1768
									</tr>
1769
									<tr>
1770
										<td width="22%" valign="top" class="vncell"><?=gettext("Reject Leases From"); ?></td>
1771
										<td width="78%" class="vtable">
1772
											<input name="dhcprejectfrom" type="text" class="formfld unknown" id="dhcprejectfrom" size="20" value="<?=htmlspecialchars($pconfig['dhcprejectfrom']);?>" />
1773
											<br/>
1774
											<?=gettext("If there is a certain upstream DHCP server that should be ignored, place the IP address or subnet of the DHCP server to be ignored here."); ?>
1775
											<?=gettext("This is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync."); ?>
1776
										</td>
1777
									</tr>
1778
									<tr>
1779
										<td colspan="2" valign="top" height="16"></td>
1780
									</tr>
1781
								</table>
1782
							</td>
1783
						</tr>
1784
						<tr style="display:none;" name="dhcp6" id="dhcp6">
1785
							<td colspan="2" style="padding: 0px;">
1786
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp6">
1787
									<tr>
1788
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration"); ?></td>
1789
									</tr>
1790
									<!--- Leave commented out for now
1791
									<tr>
1792
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1793
										<td width="78%" class="vtable">
1794
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>" />
1795
											<br/>
1796
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1797
											"when requesting a DHCPv6 lease."); ?><br />
1798
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1799
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
1800
												}
1801
												printf(gettext("The current DUID is: '%s'"),$current_duid);
1802
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
1803
											?>
1804
										</td>
1805
									</tr>
1806
									-->
1807
									<tr>
1808
										<td width="22%" valign="top" class="vncell"><?=gettext("Use IPv4 connectivity as parent interface"); ?></td>
1809
										<td width="78%" class="vtable">
1810
											<input name="dhcp6usev4iface" type="checkbox" id="dhcp6usev4iface" value="yes" <?php if ($pconfig['dhcp6usev4iface'] == true) echo "checked=\"checked\""; ?> />
1811
											<?=gettext("Request a IPv6 prefix/information through the IPv4 connectivity link"); ?>
1812
										</td>
1813
									</tr>
1814
									<tr>
1815
										<td width="22%" valign="top" class="vncell"><?=gettext("Request only a IPv6 prefix"); ?></td>
1816
										<td width="78%" class="vtable">
1817
											<input name="dhcp6prefixonly" type="checkbox" id="dhcp6prefixonly" value="yes" <?php if ($pconfig['dhcp6prefixonly'] == true) echo "checked=\"checked\""; ?> />
1818
											<?=gettext("Only request a IPv6 prefix, do not request a IPv6 address"); ?>
1819
										</td>
1820
									</tr>
1821
									<tr>
1822
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1823
										<td width="78%" class="vtable">
1824
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
1825
												<?php
1826
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1827
												foreach($sizes as $bits => $length) {
1828
													echo "<option value=\"{$bits}\" ";
1829
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected=\"selected\"";
1830
													echo ">" . $length . "</option>";
1831
												}
1832
												?>
1833
											</select>
1834
											<br/>
1835
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
1836
										</td>
1837
									</tr>
1838
									<tr>
1839
										<td colspan="2" valign="top" height="16"></td>
1840
									</tr>
1841
								</table>
1842
							</td>
1843
						</tr>
1844
						<tr style="display:none;" name="6rd" id="6rd">
1845
							<td colspan="2" style="padding: 0px;">
1846
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="6rd">
1847
									<tr>
1848
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
1849
									</tr>
1850
									<tr>
1851
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
1852
										<td width="78%" class="vtable">
1853
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>" />
1854
											<br/>
1855
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
1856
										</td>
1857
									</tr>
1858
									<tr>
1859
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
1860
										<td width="78%" class="vtable">
1861
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>" />
1862
											<br/>
1863
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
1864
										</td>
1865
									</tr>
1866
									<tr>
1867
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
1868
										<td width="78%" class="vtable">
1869
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
1870
												<?php
1871
												for ($i = 0; $i < 32; $i++) {
1872
													echo "<option value=\"{$i}\" ";
1873
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected=\"selected\"";
1874
													echo ">" . $i . " bits</option>";
1875
												}
1876
												?>
1877
											</select>
1878
											<br/>
1879
											<?=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."); ?>
1880
										</td>
1881
									</tr>
1882
									<tr>
1883
										<td colspan="2" valign="top" height="16"></td>
1884
									</tr>
1885
								</table>
1886
							</td>
1887
						</tr>
1888
						<tr style="display:none;" name="track6" id="track6">
1889
							<td colspan="2" style="padding: 0px;">
1890
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="track6">
1891
									<tr>
1892
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
1893
									</tr>
1894
									<tr>
1895
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
1896
										<td width="78%" class="vtable">
1897
										<select name='track6-interface' class='formselect' >
1898
										<?php
1899
											$interfaces = get_configured_interface_with_descr(false, true);
1900
											$dynv6ifs = array();
1901
											foreach ($interfaces as $iface => $ifacename) {
1902
												switch($config['interfaces'][$iface]['ipaddrv6']) {
1903
													case "6to4":
1904
													case "6rd":
1905
													case "dhcp6":
1906
														$dynv6ifs[$iface] = $ifacename;
1907
														break;
1908
													default:
1909
														continue;
1910
												}
1911
											}
1912
											foreach($dynv6ifs as $iface => $ifacename) {
1913
												echo "<option value=\"{$iface}\"";
1914
												if ($iface == $pconfig['track6-interface'])
1915
													echo " selected=\"selected\"";
1916
												echo ">" . htmlspecialchars($ifacename) . "</option>";
1917
											}
1918
										?>
1919
										</select> <br/>
1920
											<br/>
1921
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
1922
										</td>
1923
									</tr>
1924
									<tr>
1925
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
1926
										<td width="78%" class="vtable">
1927
											<?php
1928
												if ($pconfig['track6-prefix-id'] == "")
1929
													$pconfig['track6-prefix-id'] = 0;
1930
												$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
1931
											?>
1932
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
1933
											<br />
1934
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
1935
											<br />
1936
											<?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, default value is 0."), 0, $ipv6_num_prefix_ids - 1); ?>
1937
										</td>
1938
									</tr>
1939
									<tr>
1940
										<td colspan="2" valign="top" height="16"></td>
1941
									</tr>
1942
								</table>
1943
							</td>
1944
						</tr>
1945
						<tr style="display:none;" name="ppp" id="ppp">
1946
							<td colspan="2" style="padding: 0px;">
1947
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="ppp">
1948
									<tr>
1949
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1950
									</tr>
1951
									<tr name="ppp_provider" id="ppp_provider">
1952
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1953
										<td width="78%" class="vtable">
1954
											<table border="0" cellpadding="0" cellspacing="0" summary="service provider">
1955
												<tr id="trcountry">
1956
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1957
													<td>
1958
														<select class="formselect" name="country" id="country" onchange="providers_list()">
1959
															<option></option>
1960
														</select>
1961
													</td>
1962
												</tr>
1963
												<tr id="trprovider" style="display:none">
1964
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1965
													<td>
1966
														<select class="formselect" name="provider" id="provider" onchange="providerplan_list()">
1967
															<option></option>
1968
														</select>
1969
													</td>
1970
												</tr>
1971
												<tr id="trproviderplan" style="display:none">
1972
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1973
													<td>
1974
														<select class="formselect" name="providerplan" id="providerplan" onchange="prefill_provider()">
1975
															<option></option>
1976
														</select>
1977
													</td>
1978
												</tr>
1979
											</table>
1980
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1981
										</td>
1982
									</tr>
1983
									<tr>
1984
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1985
										<td width="78%" class="vtable">
1986
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>" />
1987
										</td>
1988
									</tr>
1989
									<tr>
1990
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1991
										<td width="78%" class="vtable">
1992
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>" />
1993
										</td>
1994
									</tr>
1995
									<tr name="phone_num" id="phone_num">
1996
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1997
										<td width="78%" class="vtable">
1998
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>" />
1999
										</td>
2000
									</tr>
2001
									<tr name="apn_" id="apn_">
2002
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
2003
										<td width="78%" class="vtable">
2004
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>" />
2005
										</td>
2006
									</tr>
2007
									<tr name="interface" id="interface" >
2008
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
2009
										<td width="78%" class="vtable">
2010
											<select name="port" id="port" class="formselect">
2011
											<?php
2012
												$portlist = glob("/dev/cua*");
2013
												$modems = glob("/dev/modem*");
2014
												$portlist = array_merge($portlist, $modems);
2015
												foreach ($portlist as $port) {
2016
													if(preg_match("/\.(lock|init)$/", $port))
2017
														continue;
2018
													echo "<option value=\"".trim($port)."\"";
2019
													if ($pconfig['port'] == $port)
2020
														echo " selected=\"selected\"";
2021
													echo ">{$port}</option>";
2022
												}?>
2023
											</select>
2024
										</td>
2025
									</tr>
2026
									<tr>
2027
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
2028
										<?php if (isset($pconfig['pppid'])): ?>
2029
											<td width="78%" class="vtable">
2030
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2031
											<?=gettext("to edit PPP configuration."); ?>
2032
											</td>
2033
										<?php else: ?>
2034
											<td width="78%" class="vtable">
2035
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2036
											<?=gettext("to create a PPP configuration."); ?>
2037
											</td>
2038
										<?php endif; ?>
2039
									</tr>
2040
									<tr>
2041
										<td colspan="2" valign="top" height="16"></td>
2042
									</tr>
2043
								</table>
2044
							</td>
2045
						</tr>
2046
						<tr style="display:none;" name="pppoe" id="pppoe">
2047
							<td colspan="2" style="padding:0px;">
2048
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pppoe">
2049
									<tr>
2050
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
2051
									</tr>
2052
									<tr>
2053
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2054
										<td width="78%" class="vtable">
2055
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>" />
2056
										</td>
2057
									</tr>
2058
									<tr>
2059
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2060
										<td width="78%" class="vtable">
2061
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>" />
2062
										</td>
2063
									</tr>
2064
									<tr>
2065
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
2066
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>" />
2067
											<br/> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
2068
										</td>
2069
									</tr>
2070
									<tr>
2071
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2072
										<td width="78%" class="vtable">
2073
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked=\"checked\""; ?> />
2074
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br/>
2075
											<?=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."); ?>
2076
										</td>
2077
									</tr>
2078
									<tr>
2079
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2080
										<td width="78%" class="vtable">
2081
											<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."); ?>
2082
										</td>
2083
									</tr>
2084
									<tr>
2085
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
2086
										<td width="78%" class="vtable">
2087
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" summary="periodic reset">
2088
												<tr>
2089
													<td align="left" valign="top">
2090
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
2091
														<select style="vertical-align:top" id="reset_type" name="pppoe-reset-type" class="formselect" onchange="show_reset_settings(this.value);">
2092
															<option value=""><?=gettext("Disabled"); ?></option>
2093
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected=\"selected\""; ?>><?=gettext("Custom"); ?></option>
2094
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected=\"selected\""; ?>><?=gettext("Pre-Set"); ?></option>
2095
														</select> <?=gettext("Select a reset timing type"); ?>
2096
														</p>
2097
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2098
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2099
														<?php else: ?>
2100
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2101
														<?php endif; ?>
2102
														<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" />
2103
														<?=gettext("hour (0-23)"); ?><br />
2104
														<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" />
2105
														<?=gettext("minute (0-59)"); ?><br />
2106
														<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']);?>" />
2107
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2108
														<br />&nbsp;<br />
2109
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2110
														<?=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."); ?>
2111
														</p>
2112
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2113
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2114
														<?php else: ?>
2115
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2116
														<?php endif; ?>
2117
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2118
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2119
														<br />
2120
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2121
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2122
														<br />
2123
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2124
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2125
														<br />
2126
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2127
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2128
														</p>
2129
													</td>
2130
												</tr>
2131
											</table>
2132
										</td>
2133
									</tr>
2134

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

    
2728
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
2729
						<tr>
2730
							<td width="22%" valign="top">
2731
								&nbsp;
2732
							</td>
2733
							<td width="78%">
2734
								<br/>
2735
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
2736
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
2737
								<input name="if" type="hidden" id="if" value="<?=$if;?>" />
2738
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2739
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>" />
2740
								<?php endif; ?>
2741
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>" />
2742
							</td>
2743
						</tr>
2744
					</table>
2745
					</div>
2746
				</td>
2747
			</tr>
2748
		</table>
2749
	</form>
2750
	<script type="text/javascript">
2751
	//<![CDATA[
2752
		var gatewayip;
2753
		var name;
2754
		var gatewayipv6;
2755
		var namev6;
2756
		function show_add_gateway() {
2757
			document.getElementById("addgateway").style.display = '';
2758
			document.getElementById("addgwbox").style.display = 'none';
2759
			document.getElementById("gateway").style.display = 'none';
2760
			document.getElementById("save").style.display = 'none';
2761
			document.getElementById("cancel").style.display = 'none';
2762
			document.getElementById("gwsave").style.display = '';
2763
			document.getElementById("gwcancel").style.display = '';
2764
			jQuery('#notebox').html("");
2765
		}
2766
		function show_add_gateway_v6() {
2767
			document.getElementById("addgatewayv6").style.display = '';
2768
			document.getElementById("addgwboxv6").style.display = 'none';
2769
			document.getElementById("gatewayv6").style.display = 'none';
2770
			document.getElementById("save").style.display = 'none';
2771
			document.getElementById("cancel").style.display = 'none';
2772
			document.getElementById("gwsave").style.display = '';
2773
			document.getElementById("gwcancel").style.display = '';
2774
			jQuery('#noteboxv6').html("");
2775
		}
2776
		function hide_add_gateway() {
2777
			document.getElementById("addgateway").style.display = 'none';
2778
			document.getElementById("addgwbox").style.display = '';
2779
			document.getElementById("gateway").style.display = '';
2780
			document.getElementById("save").style.display = '';
2781
			document.getElementById("cancel").style.display = '';
2782
			document.getElementById("gwsave").style.display = '';
2783
			document.getElementById("gwcancel").style.display = '';
2784
			jQuery('#status').html('');
2785
		}
2786
		function hide_add_gateway_v6() {
2787
			document.getElementById("addgatewayv6").style.display = 'none';
2788
			document.getElementById("addgwboxv6").style.display = '';
2789
			document.getElementById("gatewayv6").style.display = '';
2790
			document.getElementById("save").style.display = '';
2791
			document.getElementById("cancel").style.display = '';
2792
			document.getElementById("gwsave").style.display = '';
2793
			document.getElementById("gwcancel").style.display = '';
2794
			jQuery('#statusv6').html('');
2795
		}
2796
		function hide_add_gatewaysave() {
2797
			document.getElementById("addgateway").style.display = 'none';
2798
			jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
2799
			var iface = jQuery('#if').val();
2800
			name = jQuery('#name').val();
2801
			var descr = jQuery('#gatewaydescr').val();
2802
			gatewayip = jQuery('#gatewayip').val();
2803

    
2804
			var defaultgw = jQuery('#defaultgw').val();
2805
			var url = "system_gateways_edit.php";
2806
			var pars = 'isAjax=true&ipprotocol=inet&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2807
			jQuery.ajax(
2808
				url,
2809
				{
2810
					type: 'post',
2811
					data: pars,
2812
					error: report_failure,
2813
					success: save_callback
2814
				});
2815
		}
2816
		function hide_add_gatewaysave_v6() {
2817
			document.getElementById("addgatewayv6").style.display = 'none';
2818
			jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
2819
			var iface = jQuery('#if').val();
2820
			name = jQuery('#namev6').val();
2821
			var descr = jQuery('#gatewaydescrv6').val();
2822
			gatewayip = jQuery('#gatewayipv6').val();
2823
			var defaultgw = jQuery('#defaultgwv6').val();
2824
			var url_v6 = "system_gateways_edit.php";
2825
			var pars_v6 = 'isAjax=true&ipprotocol=inet6&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2826
			jQuery.ajax(
2827
				url_v6,
2828
				{
2829
					type: 'post',
2830
					data: pars_v6,
2831
					error: report_failure_v6,
2832
					success: save_callback_v6
2833
				});
2834
		}
2835
		function addOption(selectbox,text,value)
2836
		{
2837
			var optn = document.createElement("OPTION");
2838
			optn.text = text;
2839
			optn.value = value;
2840
			selectbox.append(optn);
2841
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2842
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
2843
		}
2844
		function addOption_v6(selectbox,text,value)
2845
		{
2846
			var optn = document.createElement("OPTION");
2847
			optn.text = text;
2848
			optn.value = value;
2849
			selectbox.append(optn);
2850
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2851
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
2852
		}
2853
		function report_failure(request, textStatus, errorThrown) {
2854
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2855
				alert(request.responseText);
2856
			} else {
2857
				alert("Sorry, we could not create your IPv4 gateway at this time.");
2858
			}
2859
			hide_add_gateway();
2860
		}
2861
		function report_failure_v6(request, textStatus, errorThrown) {
2862
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2863
				alert(request.responseText);
2864
			} else {
2865
				alert("Sorry, we could not create your IPv6 gateway at this time.");
2866
			}
2867
			hide_add_gateway_v6();
2868
		}
2869
		function save_callback(response) {
2870
			if(response) {
2871
				document.getElementById("addgateway").style.display = 'none';
2872
				hide_add_gateway();
2873
				var gwtext = escape(name) + " - " + gatewayip;
2874
				addOption(jQuery('#gateway'), gwtext, name);
2875
				// Auto submit form?
2876
				//document.iform.submit();
2877
				//jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader /">');
2878
			} else {
2879
				report_failure();
2880
			}
2881
		}
2882
		function show_advanced_media() {
2883
			document.getElementById("showadvmediabox").innerHTML='';
2884
			aodiv = document.getElementById('showmediaadv');
2885
			aodiv.style.display = "block";
2886
		}
2887
		function save_callback_v6(response_v6) {
2888
			if(response_v6) {
2889
				document.getElementById("addgatewayv6").style.display = 'none';
2890
				hide_add_gateway_v6();
2891
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2892
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
2893
				// Auto submit form?
2894
				//document.iform.submit();
2895
				//jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" />');
2896
			} else {
2897
				report_failure_v6();
2898
			}
2899
		}
2900
		<?php
2901
		echo "show_allcfg(document.iform.enable);";
2902
		echo "updateType('{$pconfig['type']}');\n";
2903
		echo "updateTypeSix('{$pconfig['type6']}');\n";
2904
		?>
2905
	//]]>
2906
	</script>
2907
	<?php include("fend.inc"); ?>
2908
	</body>
2909
</html>
(93-93/246)