Project

General

Profile

Download (127 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['dhcp_plus'] = isset($wancfg['dhcp_plus']);
179
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
180
$pconfig['enable'] = isset($wancfg['enable']);
181

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

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

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

    
254
// print_r($pconfig);
255

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

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

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

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

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

    
369
		/* sync filter configuration */
370
		setup_gateways_monitor();
371

    
372
		clear_subsystem_dirty('interfaces');
373

    
374
		filter_configure();
375

    
376
		enable_rrd_graphing();
377

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

    
403
	unset($input_errors);
404
	$pconfig = $_POST;
405
	if ($pconfig['track6-prefix-id--hex'] === "") {
406
		$pconfig['track6-prefix-id'] = "none";
407
	} else 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'] = "none";
411
	}
412
	conf_mount_rw();
413

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

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

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

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

    
551

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
953
		conf_mount_ro();
954
		write_config();
955

    
956
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
957
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
958
		} else {
959
			$toapplylist = array();
960
		}
961
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
962
		$toapplylist[$if]['ppps'] = $old_ppps;
963
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
964

    
965
		mark_subsystem_dirty('interfaces');
966

    
967
		/* regenerate cron settings/crontab file */
968
		configure_cron();
969

    
970
		header("Location: interfaces.php?if={$if}");
971
		exit;
972
	}
973

    
974
} // end if($_POST)
975

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

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

    
1117
function check_wireless_mode() {
1118
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1119

    
1120
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1121
		return;
1122

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

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

    
1160
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1161
$shortcut_section = "interfaces";
1162

    
1163
$closehead = false;
1164
include("head.inc");
1165
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1166
$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"));
1167

    
1168
?>
1169

    
1170
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1171
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1172
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1173
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1174

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

    
1244
	function show_allcfg(obj) {
1245
		if (obj.checked)
1246
			jQuery('#allcfg').show();
1247
		else
1248
			jQuery('#allcfg').hide();
1249
	}
1250

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

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

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

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

    
1330
						var option = new Element('option');
1331
						option.text = providerplan[0] + " - " + providerplan[1];
1332
						option.value = providerplan[1];
1333
						jQuery('#providerplan').append(option);
1334
					}
1335
				});
1336
			}
1337
		});
1338
		jQuery('#trproviderplan').css("display","table-row");
1339
	}
1340

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

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

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

    
2704
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2705
						<tr>
2706
							<td width="22%" valign="top">
2707
								&nbsp;
2708
							</td>
2709
							<td width="78%">
2710
								<br/>
2711
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2712
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2713
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2714
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2715
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2716
								<?php endif; ?>
2717
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2718
							</td>
2719
						</tr>
2720
					</table>
2721
				</td>
2722
			</tr>
2723
		</table>
2724
		<!--
2725
		</div>
2726
		</td></tr>
2727
		</table>
2728
		-->
2729
	</form>
2730
	<script type="text/javascript">
2731
		var gatewayip;
2732
		var name;
2733
		var gatewayipv6;
2734
		var namev6;
2735
		function show_add_gateway() {
2736
			document.getElementById("addgateway").style.display = '';
2737
			document.getElementById("addgwbox").style.display = 'none';
2738
			document.getElementById("gateway").style.display = 'none';
2739
			document.getElementById("save").style.display = 'none';
2740
			document.getElementById("cancel").style.display = 'none';
2741
			document.getElementById("gwsave").style.display = '';
2742
			document.getElementById("gwcancel").style.display = '';
2743
			jQuery('#notebox').html("");
2744
		}
2745
		function show_add_gateway_v6() {
2746
			document.getElementById("addgatewayv6").style.display = '';
2747
			document.getElementById("addgwboxv6").style.display = 'none';
2748
			document.getElementById("gatewayv6").style.display = 'none';
2749
			document.getElementById("save").style.display = 'none';
2750
			document.getElementById("cancel").style.display = 'none';
2751
			document.getElementById("gwsave").style.display = '';
2752
			document.getElementById("gwcancel").style.display = '';
2753
			jQuery('#noteboxv6').html("");
2754
		}
2755
		function hide_add_gateway() {
2756
			document.getElementById("addgateway").style.display = 'none';
2757
			document.getElementById("addgwbox").style.display = '';
2758
			document.getElementById("gateway").style.display = '';
2759
			document.getElementById("save").style.display = '';
2760
			document.getElementById("cancel").style.display = '';
2761
			document.getElementById("gwsave").style.display = '';
2762
			document.getElementById("gwcancel").style.display = '';
2763
			jQuery('#status').html('');
2764
		}
2765
		function hide_add_gateway_v6() {
2766
			document.getElementById("addgatewayv6").style.display = 'none';
2767
			document.getElementById("addgwboxv6").style.display = '';
2768
			document.getElementById("gatewayv6").style.display = '';
2769
			document.getElementById("save").style.display = '';
2770
			document.getElementById("cancel").style.display = '';
2771
			document.getElementById("gwsave").style.display = '';
2772
			document.getElementById("gwcancel").style.display = '';
2773
			jQuery('#statusv6').html('');
2774
		}
2775
		function hide_add_gatewaysave() {
2776
			document.getElementById("addgateway").style.display = 'none';
2777
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2778
			var iface = jQuery('#if').val();
2779
			name = jQuery('#name').val();
2780
			var descr = jQuery('#gatewaydescr').val();
2781
			gatewayip = jQuery('#gatewayip').val();
2782

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