Project

General

Profile

Download (183 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces.php
5
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6
	Copyright (C) 2004-2008 Scott Ullrich
7
	Copyright (C) 2006 Daniel S. Haischt.
8
	Copyright (C) 2008-2010 Ermal Luçi
9
	All rights reserved.
10

    
11
	originally part of m0n0wall (http://m0n0.ch/wall)
12
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
	All rights reserved.
14

    
15
	Redistribution and use in source and binary forms, with or without
16
	modification, are permitted provided that the following conditions are met:
17

    
18
	1. Redistributions of source code must retain the above copyright notice,
19
	   this list of conditions and the following disclaimer.
20

    
21
	2. Redistributions in binary form must reproduce the above copyright
22
	   notice, this list of conditions and the following disclaimer in the
23
	   documentation and/or other materials provided with the distribution.
24

    
25
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
26
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
29
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
	POSSIBILITY OF SUCH DAMAGE.
35
*/
36
/*
37
	pfSense_BUILDER_BINARIES:	/usr/sbin/arp
38
	pfSense_MODULE:	interfaces
39
*/
40

    
41
##|+PRIV
42
##|*IDENT=page-interfaces
43
##|*NAME=Interfaces: WAN page
44
##|*DESCR=Allow access to the 'Interfaces' page.
45
##|*MATCH=interfaces.php*
46
##|-PRIV
47

    
48
require_once("guiconfig.inc");
49
require_once("ipsec.inc");
50
require_once("functions.inc");
51
require_once("captiveportal.inc");
52
require_once("filter.inc");
53
require_once("shaper.inc");
54
require_once("rrd.inc");
55
require_once("vpn.inc");
56
require_once("xmlparse_attr.inc");
57

    
58
if (isset($_POST['referer'])) {
59
	$referer = $_POST['referer'];
60
} else {
61
	$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces.php');
62
}
63

    
64
// Get configured interface list
65
$ifdescrs = get_configured_interface_with_descr(false, true);
66

    
67
$if = "wan";
68
if ($_REQUEST['if']) {
69
	$if = $_REQUEST['if'];
70
}
71

    
72
if (empty($ifdescrs[$if])) {
73
	header("Location: interfaces.php");
74
	exit;
75
}
76

    
77
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
78
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
79
define("CRON_DAILY_PATTERN", "0 0 * * *");
80
define("CRON_HOURLY_PATTERN", "0 * * * *");
81

    
82
if (!is_array($pconfig)) {
83
	$pconfig = array();
84
}
85

    
86
if (!is_array($config['ppps'])) {
87
	$config['ppps'] = array();
88
}
89
if (!is_array($config['ppps']['ppp'])) {
90
	$config['ppps']['ppp'] = array();
91
}
92
$a_ppps = &$config['ppps']['ppp'];
93

    
94
function remove_bad_chars($string) {
95
	return preg_replace('/[^a-z_0-9]/i', '', $string);
96
}
97

    
98
if (!is_array($config['gateways']['gateway_item'])) {
99
	$config['gateways']['gateway_item'] = array();
100
}
101
$a_gateways = &$config['gateways']['gateway_item'];
102

    
103
$wancfg = &$config['interfaces'][$if];
104
$old_wancfg = $wancfg;
105
$old_wancfg['realif'] = get_real_interface($if);
106
$old_ppps = $a_ppps;
107
// Populate page descr if it does not exist.
108
if ($if == "wan" && !$wancfg['descr']) {
109
	$wancfg['descr'] = "WAN";
110
} else if ($if == "lan" && !$wancfg['descr']) {
111
	$wancfg['descr'] = "LAN";
112
}
113

    
114
/* NOTE: The code here is used to set the $pppid for the curious */
115
foreach ($a_ppps as $pppid => $ppp) {
116
	if ($wancfg['if'] == $ppp['if']) {
117
		break;
118
	}
119
}
120

    
121
$type_disabled = (substr($wancfg['if'], 0, 3) == 'gre') ? 'disabled="disabled"' : '';
122

    
123
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
124
	$pconfig['pppid'] = $pppid;
125
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
126
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
127
	if ($a_ppps[$pppid]['type'] == "ppp") {
128
		$pconfig['ppp_username'] = $a_ppps[$pppid]['username'];
129
		$pconfig['ppp_password'] = base64_decode($a_ppps[$pppid]['password']);
130

    
131
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
132
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
133
	} else if ($a_ppps[$pppid]['type'] == "pppoe") {
134
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
135
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
136
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
137
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
138
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
139

    
140
		/* ================================================ */
141
		/* = force a connection reset at a specific time? = */
142
		/* ================================================ */
143

    
144
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
145
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
146
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
147
			if ($itemhash) {
148
				$cronitem = $itemhash['ITEM'];
149
			}
150
			if (isset($cronitem)) {
151
				$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
152
			} else {
153
				$resetTime = NULL;
154
			}
155
			//log_error("ResetTime:".$resetTime);
156
			if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
157
				if ($cronitem) {
158
					$pconfig['pppoe_pr_custom'] = true;
159
					$pconfig['pppoe_resetminute'] = $cronitem['minute'];
160
					$pconfig['pppoe_resethour'] = $cronitem['hour'];
161
					if ($cronitem['mday'] <> "*" && $cronitem['month'] <> "*") {
162
						$pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y");
163
					}
164
				}
165
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
166
				$pconfig['pppoe_pr_preset'] = true;
167
				switch ($resetTime) {
168
					case CRON_MONTHLY_PATTERN:
169
						$pconfig['pppoe_monthly'] = true;
170
						break;
171
					case CRON_WEEKLY_PATTERN:
172
						$pconfig['pppoe_weekly'] = true;
173
						break;
174
					case CRON_DAILY_PATTERN:
175
						$pconfig['pppoe_daily'] = true;
176
						break;
177
					case CRON_HOURLY_PATTERN:
178
						$pconfig['pppoe_hourly'] = true;
179
						break;
180
				}
181
			}
182
		} // End force pppoe reset at specific time
183
		// End if type == pppoe
184
	} else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp") {
185
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
186
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
187
		$pconfig['pptp_local'] = explode(",", $a_ppps[$pppid]['localip']);
188
		$pconfig['pptp_subnet'] = explode(",", $a_ppps[$pppid]['subnet']);
189
		$pconfig['pptp_remote'] = explode(",", $a_ppps[$pppid]['gateway']);
190
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
191
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
192
	}
193
} else {
194
	$pconfig['ptpid'] = interfaces_ptpid_next();
195
	$pppid = count($a_ppps);
196
}
197
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
198
$pconfig['alias-address'] = $wancfg['alias-address'];
199
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
200
$pconfig['dhcprejectfrom'] = $wancfg['dhcprejectfrom'];
201

    
202
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
203
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
204
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
205
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
206
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
207
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
208

    
209
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
210

    
211
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
212
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
213
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
214
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
215

    
216
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
217
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
218
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
219

    
220
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
221
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
222
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
223
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
224

    
225
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
226
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
227
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
228
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
229
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
230

    
231
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
232
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
233
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
234
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
235
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
236

    
237
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
238
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
239

    
240
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
241
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
242
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
243
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
244

    
245
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
246
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
247
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
248
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
249
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
250

    
251
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
252
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
253
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
254

    
255
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
256
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
257
$pconfig['enable'] = isset($wancfg['enable']);
258

    
259
if (is_array($config['aliases']['alias'])) {
260
	foreach ($config['aliases']['alias'] as $alias) {
261
		if ($alias['name'] == $wancfg['descr']) {
262
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $wancfg['descr']);
263
		}
264
	}
265
}
266

    
267
switch ($wancfg['ipaddr']) {
268
	case "dhcp":
269
		$pconfig['type'] = "dhcp";
270
		break;
271
	case "pppoe":
272
	case "pptp":
273
	case "l2tp":
274
	case "ppp":
275
		$pconfig['type'] = $wancfg['ipaddr'];
276
		break;
277
	default:
278
		if (is_ipaddrv4($wancfg['ipaddr'])) {
279
			$pconfig['type'] = "staticv4";
280
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
281
			$pconfig['subnet'] = $wancfg['subnet'];
282
			$pconfig['gateway'] = $wancfg['gateway'];
283
		} else {
284
			$pconfig['type'] = "none";
285
		}
286
		break;
287
}
288

    
289
switch ($wancfg['ipaddrv6']) {
290
	case "slaac":
291
		$pconfig['type6'] = "slaac";
292
		break;
293
	case "dhcp6":
294
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
295
		if (!isset($wancfg['dhcp6-ia-pd-len'])) {
296
			$wancfg['dhcp6-ia-pd-len'] = "none";
297
		}
298
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
299
		$pconfig['dhcp6-ia-pd-send-hint'] = isset($wancfg['dhcp6-ia-pd-send-hint']);
300
		$pconfig['type6'] = "dhcp6";
301
		$pconfig['dhcp6prefixonly'] = isset($wancfg['dhcp6prefixonly']);
302
		$pconfig['dhcp6usev4iface'] = isset($wancfg['dhcp6usev4iface']);
303
		break;
304
	case "6to4":
305
		$pconfig['type6'] = "6to4";
306
		break;
307
	case "track6":
308
		$pconfig['type6'] = "track6";
309
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
310
		if ($wancfg['track6-prefix-id'] == "") {
311
			$pconfig['track6-prefix-id'] = 0;
312
		} else {
313
			$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
314
		}
315
		$pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
316
		break;
317
	case "6rd":
318
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
319
		if ($wancfg['prefix-6rd-v4plen'] == "") {
320
			$wancfg['prefix-6rd-v4plen'] = "0";
321
		}
322
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
323
		$pconfig['type6'] = "6rd";
324
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
325
		break;
326
	default:
327
		if (is_ipaddrv6($wancfg['ipaddrv6'])) {
328
			$pconfig['type6'] = "staticv6";
329
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
330
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
331
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
332
		} else {
333
			$pconfig['type6'] = "none";
334
		}
335
		break;
336
}
337

    
338
// print_r($pconfig);
339

    
340
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
341
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
342
$pconfig['spoofmac'] = $wancfg['spoofmac'];
343
$pconfig['mtu'] = $wancfg['mtu'];
344
$pconfig['mss'] = $wancfg['mss'];
345

    
346
/* Wireless interface? */
347
if (isset($wancfg['wireless'])) {
348
	/* Sync first to be sure it displays the actual settings that will be used */
349
	interface_sync_wireless_clones($wancfg, false);
350
	/* Get wireless modes */
351
	$wlanif = get_real_interface($if);
352
	if (!does_interface_exist($wlanif)) {
353
		interface_wireless_clone($wlanif, $wancfg);
354
	}
355
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
356
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
357
	$wl_modes = get_wireless_modes($if);
358
	$wl_chaninfo = get_wireless_channel_info($if);
359
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
360
	$wl_sysctl = get_sysctl(
361
		array(
362
			"{$wl_sysctl_prefix}.diversity",
363
			"{$wl_sysctl_prefix}.txantenna",
364
			"{$wl_sysctl_prefix}.rxantenna",
365
			"{$wl_sysctl_prefix}.slottime",
366
			"{$wl_sysctl_prefix}.acktimeout",
367
			"{$wl_sysctl_prefix}.ctstimeout"));
368
	$wl_regdomain_xml_attr = array();
369
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
370
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
371
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
372
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
373
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
374
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
375
	$pconfig['standard'] = $wancfg['wireless']['standard'];
376
	$pconfig['mode'] = $wancfg['wireless']['mode'];
377
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
378
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
379
	$pconfig['channel'] = $wancfg['wireless']['channel'];
380
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
381
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
382
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
383
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
384
	$pconfig['distance'] = $wancfg['wireless']['distance'];
385
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
386
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
387
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
388
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
389
	if (isset($wancfg['wireless']['puren']['enable'])) {
390
		$pconfig['puremode'] = '11n';
391
	} else if (isset($wancfg['wireless']['pureg']['enable'])) {
392
		$pconfig['puremode'] = '11g';
393
	} else {
394
		$pconfig['puremode'] = 'any';
395
	}
396
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
397
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
398
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
399
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
400
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
401
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
402
	$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
403
	$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
404
	$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
405
	if (is_array($wancfg['wireless']['wpa'])) {
406
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
407
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
408
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
409
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
410
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
411
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
412
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
413
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
414
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
415
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
416
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
417
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
418
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
419
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
420
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
421
	}
422
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
423
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
424
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
425
		$i = 1;
426
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
427
			$pconfig['key' . $i] = $wepkey['value'];
428
			if (isset($wepkey['txkey'])) {
429
				$pconfig['txkey'] = $i;
430
			}
431
			$i++;
432
		}
433
		if (!isset($wepkey['txkey'])) {
434
			$pconfig['txkey'] = 1;
435
		}
436
	}
437
}
438

    
439
if ($_POST['apply']) {
440
	unset($input_errors);
441
	if (!is_subsystem_dirty('interfaces')) {
442
		$input_errors[] = gettext("You have already applied your settings!");
443
	} else {
444
		unlink_if_exists("{$g['tmp_path']}/config.cache");
445
		clear_subsystem_dirty('interfaces');
446

    
447
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
448
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
449
			foreach ($toapplylist as $ifapply => $ifcfgo) {
450
				if (isset($config['interfaces'][$ifapply]['enable'])) {
451
					interface_bring_down($ifapply, false, $ifcfgo);
452
					interface_configure($ifapply, true);
453
				} else {
454
					interface_bring_down($ifapply, true, $ifcfgo);
455
					if (isset($config['dhcpd'][$ifapply]['enable']) ||
456
					    isset($config['dhcpdv6'][$ifapply]['enable'])) {
457
						services_dhcpd_configure();
458
					}
459
				}
460
			}
461
		}
462
		/* restart snmp so that it binds to correct address */
463
		services_snmpd_configure();
464

    
465
		/* sync filter configuration */
466
		setup_gateways_monitor();
467

    
468
		clear_subsystem_dirty('interfaces');
469

    
470
		filter_configure();
471

    
472
		enable_rrd_graphing();
473

    
474
		if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0)) {
475
			clear_subsystem_dirty('staticroutes');
476
		}
477
	}
478
	@unlink("{$g['tmp_path']}/.interfaces.apply");
479
	header("Location: interfaces.php?if={$if}");
480
	exit;
481
} else if ($_POST && $_POST['enable'] != "yes") {
482
	unset($wancfg['enable']);
483
	if (isset($wancfg['wireless'])) {
484
		interface_sync_wireless_clones($wancfg, false);
485
	}
486
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
487
	mark_subsystem_dirty('interfaces');
488
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
489
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
490
	} else {
491
		$toapplylist = array();
492
	}
493
	$toapplylist[$if]['ifcfg'] = $wancfg;
494
	$toapplylist[$if]['ppps'] = $a_ppps;
495
	/* we need to be able remove IP aliases for IPv6 */
496
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
497
	header("Location: interfaces.php?if={$if}");
498
	exit;
499
} else if ($_POST) {
500

    
501
	unset($input_errors);
502
	$pconfig = $_POST;
503

    
504
	if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
505
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
506
	} else {
507
		$pconfig['track6-prefix-id'] = 0;
508
	}
509
	conf_mount_rw();
510

    
511
	/* filter out spaces from descriptions */
512
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
513

    
514
	/* okay first of all, cause we are just hiding the PPPoE HTML
515
	 * fields related to PPPoE resets, we are going to unset $_POST
516
	 * vars, if the reset feature should not be used. Otherwise the
517
	 * data validation procedure below, may trigger a false error
518
	 * message.
519
	 */
520
	if (empty($_POST['pppoe-reset-type'])) {
521
		unset($_POST['pppoe_pr_type']);
522
		unset($_POST['pppoe_resethour']);
523
		unset($_POST['pppoe_resetminute']);
524
		unset($_POST['pppoe_resetdate']);
525
		unset($_POST['pppoe_pr_preset_val']);
526
	}
527
	/* description unique? */
528
	foreach ($ifdescrs as $ifent => $ifdescr) {
529
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
530
			$input_errors[] = gettext("An interface with the specified description already exists.");
531
			break;
532
		}
533
	}
534
	if (is_numeric($_POST['descr'])) {
535
		$input_errors[] = gettext("The interface description cannot contain only numbers.");
536
	}
537
	/* input validation */
538
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (!preg_match("/^staticv4/", $_POST['type']))) {
539
		$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.");
540
	}
541
	if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (!preg_match("/^staticv6/", $_POST['type6']))) {
542
		$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.");
543
	}
544

    
545
	switch (strtolower($_POST['type'])) {
546
		case "staticv4":
547
			$reqdfields = explode(" ", "ipaddr subnet gateway");
548
			$reqdfieldsn = array(gettext("IPv4 address"), gettext("Subnet bit count"), gettext("Gateway"));
549
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
550
			break;
551
		case "none":
552
			if (is_array($config['virtualip']['vip'])) {
553
				foreach ($config['virtualip']['vip'] as $vip) {
554
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if) {
555
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
556
					}
557
				}
558
			}
559
			break;
560
		case "ppp":
561
			$reqdfields = explode(" ", "port phone");
562
			$reqdfieldsn = array(gettext("Modem Port"), gettext("Phone Number"));
563
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
564
			break;
565
		case "pppoe":
566
			if ($_POST['pppoe_dialondemand']) {
567
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
568
				$reqdfieldsn = array(gettext("PPPoE username"), gettext("PPPoE password"), gettext("Dial on demand"), gettext("Idle timeout value"));
569
			} else {
570
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
571
				$reqdfieldsn = array(gettext("PPPoE username"), gettext("PPPoE password"));
572
			}
573
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
574
			break;
575
		case "pptp":
576
			if ($_POST['pptp_dialondemand']) {
577
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
578
				$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"));
579
			} else {
580
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
581
				$reqdfieldsn = array(gettext("PPTP username"), gettext("PPTP password"), gettext("PPTP local IP address"), gettext("PPTP subnet"), gettext("PPTP remote IP address"));
582
			}
583
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
584
			break;
585
		case "l2tp":
586
			if ($_POST['pptp_dialondemand']) {
587
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
588
				$reqdfieldsn = array(gettext("L2TP username"), gettext("L2TP password"), gettext("L2TP remote IP address"), gettext("Dial on demand"), gettext("Idle timeout value"));
589
			} else {
590
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
591
				$reqdfieldsn = array(gettext("L2TP username"), gettext("L2TP password"), gettext("L2TP remote IP address"));
592
			}
593
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
594
			break;
595
	}
596
	switch (strtolower($_POST['type6'])) {
597
		case "staticv6":
598
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
599
			$reqdfieldsn = array(gettext("IPv6 address"), gettext("Subnet bit count"), gettext("Gateway"));
600
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
601
			break;
602
		case "none":
603
			if (is_array($config['virtualip']['vip'])) {
604
				foreach ($config['virtualip']['vip'] as $vip) {
605
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if) {
606
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
607
					}
608
				}
609
			}
610
			break;
611
		case "dhcp6":
612
			if (in_array($wancfg['ipaddrv6'], array())) {
613
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."), $_POST['type6']);
614
			}
615
			if ($_POST['dhcp6-ia-pd-send-hint'] && strtolower($_POST['dhcp6-ia-pd-len']) == 'none') {
616
				$input_errors[] = gettext('DHCPv6 Prefix Delegation size must be provided when Send IPv6 prefix hint flag is checked');
617
			}
618
			break;
619
		case "6rd":
620
			foreach ($ifdescrs as $ifent => $ifdescr) {
621
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
622
					if ($config[interfaces][$ifent]['prefix-6rd'] == $_POST['prefix-6rd']) {
623
						$input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix.");
624
						break;
625
					}
626
				}
627
			}
628
			if (in_array($wancfg['ipaddrv6'], array())) {
629
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."), $_POST['type6']);
630
			}
631
			break;
632
		case "6to4":
633
			foreach ($ifdescrs as $ifent => $ifdescr) {
634
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
635
					$input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."), $_POST['type6']);
636
					break;
637
				}
638
			}
639
			if (in_array($wancfg['ipaddrv6'], array())) {
640
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."), $_POST['type6']);
641
			}
642
			break;
643
		case "track6":
644
			/* needs to check if $track6-prefix-id is used on another interface */
645
			if (in_array($wancfg['ipaddrv6'], array())) {
646
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."), $_POST['type6']);
647
			}
648

    
649
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
650
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
651
			} else {
652
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
653
				if ($track6_prefix_id < 0 || $track6_prefix_id > $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) {
654
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.") .
655
						" ({$_POST['track6-interface']}) - (0) - (" . sprintf('%x', $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) . ")";
656
				} else {
657
					foreach ($ifdescrs as $ifent => $ifdescr) {
658
						if ($if == $ifent) {
659
							continue;
660
						}
661
						if ($config['interfaces'][$ifent]['ipaddrv6'] == 'track6' &&
662
						    $config['interfaces'][$ifent]['track6-interface'] == $_POST['track6-interface'] &&
663
						    $config['interfaces'][$ifent]['track6-prefix-id'] == $track6_prefix_id) {
664
							$input_errors[] = sprintf(gettext("This track6 prefix ID is already being used in %s."), $ifdescr);
665
						}
666
					}
667
				}
668
			}
669
			break;
670
	}
671

    
672
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
673
	$staticroutes = get_staticroutes(true);
674
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
675
	if ($_POST['ipaddr']) {
676
		if (!is_ipaddrv4($_POST['ipaddr'])) {
677
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
678
		} else {
679
			$where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddr'], $if, true, true, $_POST['subnet']);
680
			if (count($where_ipaddr_configured)) {
681
				$subnet_conflict_text = sprintf(gettext("IPv4 address %s is being used by or overlaps with:"), $_POST['ipaddr'] . "/" . $_POST['subnet']);
682
				foreach ($where_ipaddr_configured as $subnet_conflict) {
683
					$subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
684
				}
685
				$input_errors[] = $subnet_conflict_text;
686
			}
687

    
688
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
689
			if ($_POST['subnet'] < 31) {
690
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
691
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
692
				} else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet'])) {
693
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
694
				}
695
			}
696

    
697
			foreach ($staticroutes as $route_subnet) {
698
				list($network, $subnet) = explode("/", $route_subnet);
699
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
700
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
701
					break;
702
				}
703
				unset($network, $subnet);
704
			}
705
		}
706
	}
707
	if ($_POST['ipaddrv6']) {
708
		if (!is_ipaddrv6($_POST['ipaddrv6'])) {
709
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
710
		} else {
711
			$where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddrv6'], $if, true, true, $_POST['subnetv6']);
712
			if (count($where_ipaddr_configured)) {
713
				$subnet_conflict_text = sprintf(gettext("IPv6 address %s is being used by or overlaps with:"), $_POST['ipaddrv6'] . "/" . $_POST['subnetv6']);
714
				foreach ($where_ipaddr_configured as $subnet_conflict) {
715
					$subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
716
				}
717
				$input_errors[] = $subnet_conflict_text;
718
			}
719

    
720
			foreach ($staticroutes as $route_subnet) {
721
				list($network, $subnet) = explode("/", $route_subnet);
722
				if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
723
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
724
					break;
725
				}
726
				unset($network, $subnet);
727
			}
728
		}
729
	}
730
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
731
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
732
	}
733
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6']))) {
734
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
735
	}
736
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address']))) {
737
		$input_errors[] = gettext("A valid alias IP address must be specified.");
738
	}
739
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
740
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
741
	}
742
	if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom'])) {
743
		$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
744
	}
745
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
746
		$match = false;
747
		foreach ($a_gateways as $gateway) {
748
			if (in_array($_POST['gateway'], $gateway)) {
749
				$match = true;
750
			}
751
		}
752
		foreach ($a_gateways as $gateway) {
753
			if (in_array($_POST['gatewayv6'], $gateway)) {
754
				$match = true;
755
			}
756
		}
757
		if (!$match) {
758
			$input_errors[] = gettext("A valid gateway must be specified.");
759
		}
760
	}
761
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
762
		$input_errors[] = gettext("The service name contains invalid characters.");
763
	}
764
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
765
		$input_errors[] = gettext("The idle timeout value must be an integer.");
766
	}
767
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
768
	    $_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) {
769
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
770
	}
771
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
772
	    $_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) {
773
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
774
	}
775
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
776
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
777
	}
778
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local']))) {
779
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
780
	}
781
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) {
782
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
783
	}
784
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface]))) {
785
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
786
	}
787
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
788
		$input_errors[] = gettext("The idle timeout value must be an integer.");
789
	}
790
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
791
		$input_errors[] = gettext("A valid MAC address must be specified.");
792
	}
793
	if ($_POST['mtu']) {
794
		if (!is_numericint($_POST['mtu'])) {
795
			$input_errors[] = "MTU must be an integer.";
796
		}
797
		if (substr($wancfg['if'], 0, 3) == 'gif') {
798
			$min_mtu = 1280;
799
			$max_mtu = 8192;
800
		} else {
801
			$min_mtu = 576;
802
			$max_mtu = 9000;
803
		}
804

    
805
		if ($_POST['mtu'] < $min_mtu || $_POST['mtu'] > $max_mtu) {
806
			$input_errors[] = sprintf(gettext("The MTU must be between %d and %d bytes."), $min_mtu, $max_mtu);
807
		}
808

    
809
		unset($min_mtu, $max_mtu);
810

    
811
		if (stristr($wancfg['if'], "_vlan")) {
812
			$realhwif_array = get_parent_interface($wancfg['if']);
813
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
814
			$parent_realhwif = $realhwif_array[0];
815
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
816
			if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
817
				if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu'])) {
818
					$input_errors[] = gettext("The MTU of a VLAN cannot be greater than that of its parent interface.");
819
				}
820
			}
821
		} else {
822
			foreach ($config['interfaces'] as $idx => $ifdata) {
823
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if'])) {
824
					continue;
825
				}
826

    
827
				$realhwif_array = get_parent_interface($ifdata['if']);
828
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
829
				$parent_realhwif = $realhwif_array[0];
830

    
831
				if ($parent_realhwif != $wancfg['if']) {
832
					continue;
833
				}
834

    
835
				if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu']) {
836
					$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a larger value"), $ifdata['descr']);
837
				}
838
			}
839
		}
840
	}
841
	if ($_POST['mss'] <> '') {
842
		if (!is_numericint($_POST['mss']) || ($_POST['mss'] < 576 || $_POST['mss'] > 65535)) {
843
			$input_errors[] = gettext("The MSS must be an integer between 576 and 65535 bytes.");
844
		}
845
	}
846
	/* Wireless interface? */
847
	if (isset($wancfg['wireless'])) {
848
		$reqdfields = array("mode");
849
		$reqdfieldsn = array(gettext("Mode"));
850
		if ($_POST['mode'] == 'hostap') {
851
			$reqdfields[] = "ssid";
852
			$reqdfieldsn[] = gettext("SSID");
853
			if (isset($_POST['channel']) && $_POST['channel'] == "0") {
854
				// auto channel with hostap is broken, prevent this for now.
855
				$input_errors[] = gettext("A specific channel, not auto, must be selected for Access Point mode.");
856
			}
857
		}
858
		if (stristr($_POST['standard'], '11n')) {
859
			if (!($_POST['wme_enable'])) {
860
				$input_errors[] = gettext("802.11n standards require enabling WME.");
861
			}
862
		}
863
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
864
		check_wireless_mode();
865
		if (isset($_POST['wpa_group_rekey']) && (!is_numericint($_POST['wpa_group_rekey']) || $_POST['wpa_group_rekey'] < 1 || $_POST['wpa_group_rekey'] > 9999)) {
866
			$input_errors[] = gettext("Key Rotation must be an integer between 1 and 9999.");
867
		}
868
		if (isset($_POST['wpa_gmk_rekey']) && (!is_numericint($_POST['wpa_gmk_rekey']) || $_POST['wpa_gmk_rekey'] < 1 || $_POST['wpa_gmk_rekey'] > 9999)) {
869
			$input_errors[] = gettext("Master Key Regeneration must be an integer between 1 and 9999.");
870
		}
871
		if (isset($_POST['wpa_group_rekey']) && isset($_POST['wpa_gmk_rekey'])) {
872
			if ($_POST['wpa_group_rekey'] > $_POST['wpa_gmk_rekey']) {
873
				$input_errors[] = gettext("Master Key Regeneration must be greater than Key Rotation.");
874
			}
875
		}
876
		if (!empty($_POST['auth_server_addr'])) {
877
			if (!is_domain($_POST['auth_server_addr']) && !is_ipaddr($_POST['auth_server_addr'])) {
878
				$input_errors[] = gettext("802.1X Authentication Server must be an IP or hostname.");
879
			}
880
		}
881
		if (!empty($_POST['auth_server_addr2'])) {
882
			if (!is_domain($_POST['auth_server_addr2']) && !is_ipaddr($_POST['auth_server_addr2'])) {
883
				$input_errors[] = gettext("Secondary 802.1X Authentication Server must be an IP or hostname.");
884
			}
885
		}
886
		if (!empty($_POST['auth_server_port'])) {
887
			if (!is_port($_POST['auth_server_port'])) {
888
				$input_errors[] = gettext("802.1X Authentication Server Port must be a valid port number (1-65535).");
889
			}
890
		}
891
		if (!empty($_POST['auth_server_port2'])) {
892
			if (!is_port($_POST['auth_server_port2'])) {
893
				$input_errors[] = gettext("Secondary 802.1X Authentication Server Port must be a valid port number (1-65535).");
894
			}
895
		}
896
		if (isset($_POST['channel']) && !is_numericint($_POST['channel'])) {
897
			if (!is_numericint($_POST['channel'])) {
898
				$input_errors[] = gettext("Invalid channel specified.");
899
			} else {
900
				if ($_POST['channel'] > 255 || $_POST['channel'] < 0) {
901
					$input_errors[] = gettext("Channel must be between 0-255.");
902
				}
903
			}
904
		}
905
		if (!empty($_POST['distance']) && !is_numericint($_POST['distance'])) {
906
			$input_errors[] = gettext("Distance must be an integer.");
907
		}
908
		if (isset($_POST['standard']) && (stristr($_POST['standard'], '11na') || stristr($_POST['standard'], '11a'))) {
909
			if ($_POST['channel'] != 0 && $_POST['channel'] < 15) {
910
				$input_errors[] = gettext("Channel selected is not valid for 802.11a or 802.11na.");
911
			}
912
		}
913
		if (isset($_POST['standard']) && ($_POST['standard'] == "11b" || $_POST['standard'] == "11g")) {
914
			if ($_POST['channel'] > 14) {
915
				$input_errors[] = gettext("Channel selected is not valid for 802.11b or 802.11g.");
916
			}
917
		}
918
		if (!empty($_POST['protmode']) && !in_array($_POST['protmode'], array("off", "cts", "rtscts"))) {
919
			$input_errors[] = gettext("Invalid option chosen for OFDM Protection Mode");
920
		}
921
		/* loop through keys and enforce size */
922
		for ($i = 1; $i <= 4; $i++) {
923
			if ($_POST['key' . $i]) {
924
				/* 64 bit */
925
				if (strlen($_POST['key' . $i]) == 5) {
926
					continue;
927
				}
928
				if (strlen($_POST['key' . $i]) == 10) {
929
					/* hex key */
930
					if (stristr($_POST['key' . $i], "0x") == false) {
931
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
932
					}
933
					continue;
934
				}
935
				if (strlen($_POST['key' . $i]) == 12) {
936
					/* hex key */
937
					if (stristr($_POST['key' . $i], "0x") == false) {
938
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
939
					}
940
					continue;
941
				}
942
				/* 128 bit */
943
				if (strlen($_POST['key' . $i]) == 13) {
944
					continue;
945
				}
946
				if (strlen($_POST['key' . $i]) == 26) {
947
					/* hex key */
948
					if (stristr($_POST['key' . $i], "0x") == false) {
949
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
950
					}
951
					continue;
952
				}
953
				if (strlen($_POST['key' . $i]) == 28) {
954
					continue;
955
				}
956
				$input_errors[] = gettext("Invalid WEP key. Enter a valid 40, 64, 104 or 128 bit WEP key.");
957
				break;
958
			}
959
		}
960

    
961
		if ($_POST['passphrase']) {
962
			$passlen = strlen($_POST['passphrase']);
963
			if ($passlen < 8 || $passlen > 63) {
964
				$input_errors[] = gettext("The WPA passphrase must be between 8 and 63 characters long.");
965
			}
966
		}
967
		if ($_POST['wpa_enable'] == "yes") {
968
			if (empty($_POST['passphrase']) && stristr($_POST['wpa_key_mgmt'], "WPA-PSK")) {
969
				$input_errors[] = gettext("A WPA Passphrase must be specified when WPA PSK is enabled.");
970
			}
971
		}
972
	}
973
	if (!$input_errors) {
974
		if ($wancfg['ipaddr'] != $_POST['type']) {
975
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
976
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
977
				unset($a_ppps[$pppid]);
978
			} else if ($wancfg['ipaddr'] == "dhcp") {
979
				kill_dhclient_process($wancfg['if']);
980
			}
981
			if ($wancfg['ipaddrv6'] == "dhcp6") {
982
				$pid = find_dhcp6c_process($wancfg['if']);
983
				if ($pid) {
984
					posix_kill($pid, SIGTERM);
985
				}
986
			}
987
		}
988
		$ppp = array();
989
		if ($wancfg['ipaddr'] != "ppp") {
990
			unset($wancfg['ipaddr']);
991
		}
992
		if ($wancfg['ipaddrv6'] != "ppp") {
993
			unset($wancfg['ipaddrv6']);
994
		}
995
		unset($wancfg['subnet']);
996
		unset($wancfg['gateway']);
997
		unset($wancfg['subnetv6']);
998
		unset($wancfg['gatewayv6']);
999
		unset($wancfg['dhcphostname']);
1000
		unset($wancfg['dhcprejectfrom']);
1001
		unset($wancfg['dhcp6-duid']);
1002
		unset($wancfg['dhcp6-ia-pd-len']);
1003
		unset($wancfg['dhcp6-ia-pd-send-hint']);
1004
		unset($wancfg['dhcp6prefixonly']);
1005
		unset($wancfg['dhcp6usev4iface']);
1006
		unset($wancfg['track6-interface']);
1007
		unset($wancfg['track6-prefix-id']);
1008
		unset($wancfg['prefix-6rd']);
1009
		unset($wancfg['prefix-6rd-v4plen']);
1010
		unset($wancfg['gateway-6rd']);
1011

    
1012
		unset($wancfg['adv_dhcp_pt_timeout']);
1013
		unset($wancfg['adv_dhcp_pt_retry']);
1014
		unset($wancfg['adv_dhcp_pt_select_timeout']);
1015
		unset($wancfg['adv_dhcp_pt_reboot']);
1016
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
1017
		unset($wancfg['adv_dhcp_pt_initial_interval']);
1018

    
1019
		unset($wancfg['adv_dhcp_pt_values']);
1020

    
1021
		unset($wancfg['adv_dhcp_send_options']);
1022
		unset($wancfg['adv_dhcp_request_options']);
1023
		unset($wancfg['adv_dhcp_required_options']);
1024
		unset($wancfg['adv_dhcp_option_modifiers']);
1025

    
1026
		unset($wancfg['adv_dhcp_config_advanced']);
1027
		unset($wancfg['adv_dhcp_config_file_override']);
1028
		unset($wancfg['adv_dhcp_config_file_override_path']);
1029

    
1030
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
1031
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
1032
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
1033
		unset($wancfg['adv_dhcp6_interface_statement_script']);
1034

    
1035
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
1036
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
1037
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
1038
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
1039
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
1040

    
1041
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
1042
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
1043
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
1044
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
1045
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
1046

    
1047
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
1048
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
1049

    
1050
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
1051
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
1052
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
1053
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
1054

    
1055
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
1056
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
1057
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
1058
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
1059
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
1060

    
1061
		unset($wancfg['adv_dhcp6_config_advanced']);
1062
		unset($wancfg['adv_dhcp6_config_file_override']);
1063
		unset($wancfg['adv_dhcp6_config_file_override_path']);
1064

    
1065
		unset($wancfg['pppoe_password']);
1066
		unset($wancfg['pptp_username']);
1067
		unset($wancfg['pptp_password']);
1068
		unset($wancfg['provider']);
1069
		unset($wancfg['ondemand']);
1070
		unset($wancfg['timeout']);
1071
		if (empty($wancfg['pppoe']['pppoe-reset-type'])) {
1072
			unset($wancfg['pppoe']['pppoe-reset-type']);
1073
		}
1074
		unset($wancfg['local']);
1075

    
1076
		unset($wancfg['remote']);
1077
		if (is_array($a_ppps[$pppid]) && in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
1078
			if ($wancfg['ipaddr'] != 'ppp') {
1079
				unset($a_ppps[$pppid]['apn']);
1080
				unset($a_ppps[$pppid]['phone']);
1081
				unset($a_ppps[$pppid]['provider']);
1082
				unset($a_ppps[$pppid]['ondemand']);
1083
			}
1084
			if (in_array($wancfg['ipaddr'], array("pppoe", "pptp", "l2tp"))) {
1085
				unset($a_ppps[$pppid]['localip']);
1086
				unset($a_ppps[$pppid]['subnet']);
1087
				unset($a_ppps[$pppid]['gateway']);
1088
			}
1089
			if ($wancfg['ipaddr'] != 'pppoe') {
1090
				unset($a_ppps[$pppid]['pppoe-reset-type']);
1091
			}
1092
			if ($wancfg['type'] != $_POST['type']) {
1093
				unset($a_ppps[$pppid]['idletimeout']);
1094
			}
1095
		}
1096

    
1097
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
1098
		$wancfg['enable'] = $_POST['enable'] == "yes" ? true : false;
1099

    
1100
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
1101
		switch ($_POST['type']) {
1102
			case "staticv4":
1103
				$wancfg['ipaddr'] = $_POST['ipaddr'];
1104
				$wancfg['subnet'] = $_POST['subnet'];
1105
				if ($_POST['gateway'] != "none") {
1106
					$wancfg['gateway'] = $_POST['gateway'];
1107
				}
1108
				break;
1109
			case "dhcp":
1110
				$wancfg['ipaddr'] = "dhcp";
1111
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
1112
				$wancfg['alias-address'] = $_POST['alias-address'];
1113
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
1114
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
1115

    
1116
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
1117
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
1118
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
1119
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
1120
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
1121
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
1122

    
1123
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
1124

    
1125
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
1126
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
1127
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
1128
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
1129

    
1130
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
1131
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
1132
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
1133

    
1134
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
1135
				if ($gateway_item) {
1136
					$a_gateways[] = $gateway_item;
1137
				}
1138
				break;
1139
			case "ppp":
1140
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1141
				$a_ppps[$pppid]['type'] = $_POST['type'];
1142
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1143
				$a_ppps[$pppid]['ports'] = $_POST['port'];
1144
				$a_ppps[$pppid]['username'] = $_POST['ppp_username'];
1145
				$a_ppps[$pppid]['password'] = base64_encode($_POST['ppp_password']);
1146
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
1147
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
1148
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
1149
				$wancfg['ipaddr'] = $_POST['type'];
1150
				break;
1151

    
1152
			case "pppoe":
1153
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1154
				$a_ppps[$pppid]['type'] = $_POST['type'];
1155
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1156
				if (isset($_POST['ppp_port'])) {
1157
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1158
				} else {
1159
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1160
				}
1161
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
1162
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
1163
				if (!empty($_POST['provider'])) {
1164
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
1165
				} else {
1166
					$a_ppps[$pppid]['provider'] = true;
1167
				}
1168
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
1169
				if (!empty($_POST['pppoe_idletimeout'])) {
1170
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
1171
				} else {
1172
					unset($a_ppps[$pppid]['idletimeout']);
1173
				}
1174

    
1175
				if (!empty($_POST['pppoe-reset-type'])) {
1176
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
1177
				} else {
1178
					unset($a_ppps[$pppid]['pppoe-reset-type']);
1179
				}
1180
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1181
				$wancfg['ipaddr'] = $_POST['type'];
1182
				if ($gateway_item) {
1183
					$a_gateways[] = $gateway_item;
1184
				}
1185

    
1186
				break;
1187
			case "pptp":
1188
			case "l2tp":
1189
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1190
				$a_ppps[$pppid]['type'] = $_POST['type'];
1191
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1192
				if (isset($_POST['ppp_port'])) {
1193
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1194
				} else {
1195
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1196
				}
1197
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
1198
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
1199
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
1200
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
1201
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
1202
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
1203
				if (!empty($_POST['pptp_idletimeout'])) {
1204
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
1205
				} else {
1206
					unset($a_ppps[$pppid]['idletimeout']);
1207
				}
1208
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1209
				$wancfg['ipaddr'] = $_POST['type'];
1210
				if ($gateway_item) {
1211
					$a_gateways[] = $gateway_item;
1212
				}
1213
				break;
1214
			case "none":
1215
				break;
1216
		}
1217
		switch ($_POST['type6']) {
1218
			case "staticv6":
1219
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
1220
				$wancfg['subnetv6'] = $_POST['subnetv6'];
1221
				if ($_POST['gatewayv6'] != "none") {
1222
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
1223
				}
1224
				break;
1225
			case "slaac":
1226
				$wancfg['ipaddrv6'] = "slaac";
1227
				break;
1228
			case "dhcp6":
1229
				$wancfg['ipaddrv6'] = "dhcp6";
1230
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
1231
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
1232
				if ($_POST['dhcp6-ia-pd-send-hint'] == "yes") {
1233
					$wancfg['dhcp6-ia-pd-send-hint'] = true;
1234
				}
1235
				if ($_POST['dhcp6prefixonly'] == "yes") {
1236
					$wancfg['dhcp6prefixonly'] = true;
1237
				}
1238
				if ($_POST['dhcp6usev4iface'] == "yes") {
1239
					$wancfg['dhcp6usev4iface'] = true;
1240
				}
1241

    
1242
				if (!empty($_POST['adv_dhcp6_interface_statement_send_options'])) {
1243
					$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1244
				}
1245
				if (!empty($_POST['adv_dhcp6_interface_statement_request_options'])) {
1246
					$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1247
				}
1248
				if (isset($_POST['adv_dhcp6_interface_statement_information_only_enable'])) {
1249
					$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1250
				}
1251
				if (!empty($_POST['adv_dhcp6_interface_statement_script'])) {
1252
					$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1253
				}
1254

    
1255
				if (isset($_POST['adv_dhcp6_id_assoc_statement_address_enable'])) {
1256
					$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1257
				}
1258
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address'])) {
1259
					$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1260
				}
1261
				if (is_numericint($_POST['adv_dhcp6_id_assoc_statement_address_id'])) {
1262
					$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1263
				}
1264
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_pltime'])) {
1265
					$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1266
				}
1267
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_vltime'])) {
1268
					$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1269
				}
1270

    
1271
				if (isset($_POST['adv_dhcp6_id_assoc_statement_prefix_enable'])) {
1272
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1273
				}
1274
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix'])) {
1275
					$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1276
				}
1277
				if (is_numericint($_POST['adv_dhcp6_id_assoc_statement_prefix_id'])) {
1278
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1279
				}
1280
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'])) {
1281
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1282
				}
1283
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'])) {
1284
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1285
				}
1286

    
1287
				if (is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_id'])) {
1288
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1289
				}
1290
				if (is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_len'])) {
1291
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1292
				}
1293

    
1294
				if (!empty($_POST['adv_dhcp6_authentication_statement_authname'])) {
1295
					$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1296
				}
1297
				if (!empty($_POST['adv_dhcp6_authentication_statement_protocol'])) {
1298
					$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1299
				}
1300
				if (!empty($_POST['adv_dhcp6_authentication_statement_algorithm'])) {
1301
					$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1302
				}
1303
				if (!empty($_POST['adv_dhcp6_authentication_statement_rdm'])) {
1304
					$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1305
				}
1306

    
1307
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyname'])) {
1308
					$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1309
				}
1310
				if (!empty($_POST['adv_dhcp6_key_info_statement_realm'])) {
1311
					$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1312
				}
1313
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyid'])) {
1314
					$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1315
				}
1316
				if (!empty($_POST['adv_dhcp6_key_info_statement_secret'])) {
1317
					$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1318
				}
1319
				if (!empty($_POST['adv_dhcp6_key_info_statement_expire'])) {
1320
					$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1321
				}
1322

    
1323
				if (!empty($_POST['adv_dhcp6_config_advanced'])) {
1324
					$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1325
				}
1326
				if (!empty($_POST['adv_dhcp6_config_file_override'])) {
1327
					$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1328
				}
1329
				if (!empty($_POST['adv_dhcp6_config_file_override_path'])) {
1330
					$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1331
				}
1332

    
1333
				if ($gateway_item) {
1334
					$a_gateways[] = $gateway_item;
1335
				}
1336
				break;
1337
			case "6rd":
1338
				$wancfg['ipaddrv6'] = "6rd";
1339
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1340
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1341
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1342
				if ($gateway_item) {
1343
					$a_gateways[] = $gateway_item;
1344
				}
1345
				break;
1346
			case "6to4":
1347
				$wancfg['ipaddrv6'] = "6to4";
1348
				break;
1349
			case "track6":
1350
				$wancfg['ipaddrv6'] = "track6";
1351
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1352
				if ($_POST['track6-prefix-id--hex'] === "") {
1353
					$wancfg['track6-prefix-id'] = 0;
1354
				} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
1355
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1356
				} else {
1357
					$wancfg['track6-prefix-id'] = 0;
1358
				}
1359
				break;
1360
			case "none":
1361
				break;
1362
		}
1363
		handle_pppoe_reset($_POST);
1364

    
1365
		if ($_POST['blockpriv'] == "yes") {
1366
			$wancfg['blockpriv'] = true;
1367
		} else {
1368
			unset($wancfg['blockpriv']);
1369
		}
1370
		if ($_POST['blockbogons'] == "yes") {
1371
			$wancfg['blockbogons'] = true;
1372
		} else {
1373
			unset($wancfg['blockbogons']);
1374
		}
1375
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1376
		if (empty($_POST['mtu'])) {
1377
			unset($wancfg['mtu']);
1378
		} else {
1379
			$wancfg['mtu'] = $_POST['mtu'];
1380
		}
1381
		if (empty($_POST['mss'])) {
1382
			unset($wancfg['mss']);
1383
		} else {
1384
			$wancfg['mss'] = $_POST['mss'];
1385
		}
1386
		if (empty($_POST['mediaopt'])) {
1387
			unset($wancfg['media']);
1388
			unset($wancfg['mediaopt']);
1389
		} else {
1390
			$mediaopts = explode(' ', $_POST['mediaopt']);
1391
			if ($mediaopts[0] != '') {
1392
				$wancfg['media'] = $mediaopts[0];
1393
			}
1394
			if ($mediaopts[1] != '') {
1395
				$wancfg['mediaopt'] = $mediaopts[1];
1396
			} else {
1397
				unset($wancfg['mediaopt']);
1398
			}
1399
		}
1400
		if (isset($wancfg['wireless'])) {
1401
			handle_wireless_post();
1402
		}
1403

    
1404
		conf_mount_ro();
1405
		write_config();
1406

    
1407
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1408
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1409
		} else {
1410
			$toapplylist = array();
1411
		}
1412
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1413
		$toapplylist[$if]['ppps'] = $old_ppps;
1414
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1415

    
1416
		mark_subsystem_dirty('interfaces');
1417

    
1418
		/* regenerate cron settings/crontab file */
1419
		configure_cron();
1420

    
1421
		header("Location: interfaces.php?if={$if}");
1422
		exit;
1423
	}
1424

    
1425
} // end if ($_POST)
1426

    
1427
function handle_wireless_post() {
1428
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1429
	if (!is_array($wancfg['wireless'])) {
1430
		$wancfg['wireless'] = array();
1431
	}
1432
	$wancfg['wireless']['standard'] = $_POST['standard'];
1433
	$wancfg['wireless']['mode'] = $_POST['mode'];
1434
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1435
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1436
	$wancfg['wireless']['channel'] = $_POST['channel'];
1437
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1438
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1439
	$wancfg['wireless']['distance'] = $_POST['distance'];
1440
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1441
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1442
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1443
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1444
		foreach ($wl_countries_attr as $wl_country) {
1445
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1446
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1447
				break;
1448
			}
1449
		}
1450
	}
1451
	if (!is_array($wancfg['wireless']['wpa'])) {
1452
		$wancfg['wireless']['wpa'] = array();
1453
	}
1454
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1455
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1456
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1457
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1458
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1459
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1460
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1461
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1462
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1463
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1464
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1465
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1466
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1467
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1468
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1469

    
1470
	if ($_POST['persistcommonwireless'] == "yes") {
1471
		if (!is_array($config['wireless'])) {
1472
			$config['wireless'] = array();
1473
		}
1474
		if (!is_array($config['wireless']['interfaces'])) {
1475
			$config['wireless']['interfaces'] = array();
1476
		}
1477
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif])) {
1478
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1479
		}
1480
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif])) {
1481
		unset($config['wireless']['interfaces'][$wlanbaseif]);
1482
	}
1483
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity'])) {
1484
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1485
	} else if (isset($wancfg['wireless']['diversity'])) {
1486
		unset($wancfg['wireless']['diversity']);
1487
	}
1488
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna'])) {
1489
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1490
	} else if (isset($wancfg['wireless']['txantenna'])) {
1491
		unset($wancfg['wireless']['txantenna']);
1492
	}
1493
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna'])) {
1494
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1495
	} else if (isset($wancfg['wireless']['rxantenna'])) {
1496
		unset($wancfg['wireless']['rxantenna']);
1497
	}
1498
	if ($_POST['hidessid_enable'] == "yes") {
1499
		$wancfg['wireless']['hidessid']['enable'] = true;
1500
	} else if (isset($wancfg['wireless']['hidessid']['enable'])) {
1501
		unset($wancfg['wireless']['hidessid']['enable']);
1502
	}
1503
	if ($_POST['mac_acl_enable'] == "yes") {
1504
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1505
	} else if (isset($wancfg['wireless']['wpa']['mac_acl_enable'])) {
1506
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1507
	}
1508
	if ($_POST['rsn_preauth'] == "yes") {
1509
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1510
	} else {
1511
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1512
	}
1513
	if ($_POST['ieee8021x'] == "yes") {
1514
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1515
	} else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable'])) {
1516
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1517
	}
1518
	if ($_POST['wpa_strict_rekey'] == "yes") {
1519
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1520
	} else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey'])) {
1521
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1522
	}	
1523
	if ($_POST['debug_mode'] == "yes") {
1524
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1525
	} else if (isset($wancfg['wireless']['wpa']['debug_mode'])) {
1526
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1527
	}
1528
	if ($_POST['wpa_enable'] == "yes") {
1529
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1530
	} else if (isset($wancfg['wireless']['wpa']['enable'])) {
1531
		unset($wancfg['wireless']['wpa']['enable']);
1532
	}
1533
	if ($_POST['wep_enable'] == "yes") {
1534
		if (!is_array($wancfg['wireless']['wep'])) {
1535
			$wancfg['wireless']['wep'] = array();
1536
		}
1537
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1538
	} else if (isset($wancfg['wireless']['wep'])) {
1539
		unset($wancfg['wireless']['wep']);
1540
	}
1541
	if ($_POST['wme_enable'] == "yes") {
1542
		if (!is_array($wancfg['wireless']['wme'])) {
1543
			$wancfg['wireless']['wme'] = array();
1544
		}
1545
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1546
	} else if (isset($wancfg['wireless']['wme']['enable'])) {
1547
		unset($wancfg['wireless']['wme']['enable']);
1548
	}
1549
	if ($_POST['puremode'] == "11g") {
1550
		if (!is_array($wancfg['wireless']['pureg'])) {
1551
			$wancfg['wireless']['pureg'] = array();
1552
		}
1553
		$wancfg['wireless']['pureg']['enable'] = true;
1554
	} else if ($_POST['puremode'] == "11n") {
1555
		if (!is_array($wancfg['wireless']['puren'])) {
1556
			$wancfg['wireless']['puren'] = array();
1557
		}
1558
		$wancfg['wireless']['puren']['enable'] = true;
1559
	} else {
1560
		if (isset($wancfg['wireless']['pureg'])) {
1561
			unset($wancfg['wireless']['pureg']);
1562
		}
1563
		if (isset($wancfg['wireless']['puren'])) {
1564
			unset($wancfg['wireless']['puren']);
1565
		}
1566
	}
1567
	if ($_POST['apbridge_enable'] == "yes") {
1568
		if (!is_array($wancfg['wireless']['apbridge'])) {
1569
			$wancfg['wireless']['apbridge'] = array();
1570
		}
1571
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1572
	} else if (isset($wancfg['wireless']['apbridge']['enable'])) {
1573
		unset($wancfg['wireless']['apbridge']['enable']);
1574
	}
1575
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1576
		if (!is_array($wancfg['wireless']['turbo'])) {
1577
			$wancfg['wireless']['turbo'] = array();
1578
		}
1579
		$wancfg['wireless']['turbo']['enable'] = true;
1580
	} else if (isset($wancfg['wireless']['turbo']['enable'])) {
1581
		unset($wancfg['wireless']['turbo']['enable']);
1582
	}
1583
	$wancfg['wireless']['wep']['key'] = array();
1584
	for ($i = 1; $i <= 4; $i++) {
1585
		if ($_POST['key' . $i]) {
1586
			$newkey = array();
1587
			$newkey['value'] = $_POST['key' . $i];
1588
			if ($_POST['txkey'] == $i) {
1589
				$newkey['txkey'] = true;
1590
			}
1591
			$wancfg['wireless']['wep']['key'][] = $newkey;
1592
		}
1593
	}
1594
	interface_sync_wireless_clones($wancfg, true);
1595
}
1596

    
1597
function check_wireless_mode() {
1598
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1599

    
1600
	if ($wancfg['wireless']['mode'] == $_POST['mode']) {
1601
		return;
1602
	}
1603

    
1604
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif))) {
1605
		$clone_count = 1;
1606
	} else {
1607
		$clone_count = 0;
1608
	}
1609
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1610
		foreach ($config['wireless']['clone'] as $clone) {
1611
			if ($clone['if'] == $wlanbaseif) {
1612
				$clone_count++;
1613
			}
1614
		}
1615
	}
1616
	if ($clone_count > 1) {
1617
		$old_wireless_mode = $wancfg['wireless']['mode'];
1618
		$wancfg['wireless']['mode'] = $_POST['mode'];
1619
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1620
			$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']]);
1621
		} else {
1622
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1623
		}
1624
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1625
	}
1626
}
1627

    
1628
// Find all possible media options for the interface
1629
$mediaopts_list = array();
1630
$intrealname = $config['interfaces'][$if]['if'];
1631
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1632
foreach ($mediaopts as $mediaopt) {
1633
	preg_match("/media (.*)/", $mediaopt, $matches);
1634
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)) {
1635
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1636
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1637
	} else {
1638
		// there is only media like "media 1000baseT"
1639
		array_push($mediaopts_list, $matches[1]);
1640
	}
1641
}
1642

    
1643
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1644
$shortcut_section = "interfaces";
1645

    
1646
$closehead = false;
1647
include("head.inc");
1648
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1649
$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"));
1650

    
1651
?>
1652

    
1653
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1654
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1655
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1656
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1657

    
1658
<script type="text/javascript">
1659
//<![CDATA[
1660
	function updateType(t) {
1661
		switch (t) {
1662
			case "none": {
1663
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1664
				break;
1665
			}
1666
			case "staticv4": {
1667
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1668
				break;
1669
			}
1670
			case "dhcp": {
1671
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1672
				break;
1673
			}
1674
			case "ppp": {
1675
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1676
				country_list();
1677
				break;
1678
			}
1679
			case "pppoe": {
1680
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1681
				break;
1682
			}
1683
			case "l2tp":
1684
			case "pptp": {
1685
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1686
				jQuery('#pptp').show();
1687
				break;
1688
			}
1689
		}
1690
		if (t != "l2tp" && t != "pptp") {
1691
			jQuery('#'+t).show();
1692
		}
1693
	}
1694
	function updateTypeSix(t) {
1695
		if (!isNaN(t[0])) t = '_' + t;
1696
		switch (t) {
1697
			case "none": {
1698
				jQuery('#staticv6, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
1699
				break;
1700
			}
1701
			case "staticv6": {
1702
				jQuery('#none, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
1703
				break;
1704
			}
1705
			case "slaac": {
1706
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #dhcp6').hide();
1707
				break;
1708
			}
1709
			case "dhcp6": {
1710
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #slaac').hide();
1711
				break;
1712
			}
1713
			case "_6rd": {
1714
				jQuery('#none, #dhcp6, #staticv6, #_6to4, #track6, #slaac').hide();
1715
				break;
1716
			}
1717
			case "_6to4": {
1718
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #track6, #slaac').hide();
1719
				break;
1720
			}
1721
			case "track6": {
1722
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #_6to4, #slaac').hide();
1723
				update_track6_prefix();
1724
				break;
1725
			}
1726
		}
1727
		if (t != "l2tp" && t != "pptp") {
1728
			jQuery('#'+t).show();
1729
		}
1730
	}
1731

    
1732
	function show_allcfg(obj) {
1733
		if (obj.checked) {
1734
			jQuery('#allcfg').show();
1735
		} else {
1736
			jQuery('#allcfg').hide();
1737
		}
1738
	}
1739

    
1740
	function show_reset_settings(reset_type) {
1741
		if (reset_type == 'preset') {
1742
			jQuery('#pppoepresetwrap').show();
1743
			jQuery('#pppoecustomwrap').hide();
1744
		} else if (reset_type == 'custom') {
1745
			jQuery('#pppoecustomwrap').show();
1746
			jQuery('#pppoepresetwrap').hide();
1747
		} else {
1748
			jQuery('#pppoecustomwrap').hide();
1749
			jQuery('#pppoepresetwrap').hide();
1750
		}
1751
	}
1752

    
1753
	function show_mon_config() {
1754
		jQuery("#showmonbox").html('');
1755
		jQuery('#showmon').css('display', 'block');
1756
	}
1757

    
1758
	function openwindow(url) {
1759
		var oWin = window.open(url, "pfSensePop", "width=620,height=400,top=150,left=150");
1760
		if (oWin == null || typeof(oWin) == "undefined") {
1761
			return false;
1762
		} else {
1763
			return true;
1764
		}
1765
	}
1766

    
1767
	function country_list() {
1768
		jQuery('#country').children().remove();
1769
		jQuery('#provider_list').children().remove();
1770
		jQuery('#providerplan').children().remove();
1771
		jQuery.ajax("getserviceproviders.php",{
1772
			success: function(response) {
1773
				var responseTextArr = response.split("\n");
1774
				responseTextArr.sort();
1775
				responseTextArr.each( function(value) {
1776
					var option = new Element('option');
1777
					country = value.split(":");
1778
					option.text = country[0];
1779
					option.value = country[1];
1780
					jQuery('#country').append(option);
1781
				});
1782
			}
1783
		});
1784
		jQuery('#trcountry').css('display', "table-row");
1785
	}
1786

    
1787
	function providers_list() {
1788
		jQuery('#provider_list').children().remove();
1789
		jQuery('#providerplan').children().remove();
1790
		jQuery.ajax("getserviceproviders.php",{
1791
			type: 'post',
1792
			data: {country : jQuery('#country').val()},
1793
			success: function(response) {
1794
				var responseTextArr = response.split("\n");
1795
				responseTextArr.sort();
1796
				responseTextArr.each( function(value) {
1797
					var option = new Element('option');
1798
					option.text = value;
1799
					option.value = value;
1800
					jQuery('#provider_list').append(option);
1801
				});
1802
			}
1803
		});
1804
		jQuery('#trprovider').css("display", "table-row");
1805
		jQuery('#trproviderplan').css("display", "none");
1806
	}
1807

    
1808
	function providerplan_list() {
1809
		jQuery('#providerplan').children().remove();
1810
		jQuery('#providerplan').append( new Element('option') );
1811
		jQuery.ajax("getserviceproviders.php",{
1812
			type: 'post',
1813
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val()},
1814
			success: function(response) {
1815
				var responseTextArr = response.split("\n");
1816
				responseTextArr.sort();
1817
				responseTextArr.each( function(value) {
1818
					if (value != "") {
1819
						providerplan = value.split(":");
1820

    
1821
						var option = new Element('option');
1822
						option.text = providerplan[0] + " - " + providerplan[1];
1823
						option.value = providerplan[1];
1824
						jQuery('#providerplan').append(option);
1825
					}
1826
				});
1827
			}
1828
		});
1829
		jQuery('#trproviderplan').css("display", "table-row");
1830
	}
1831

    
1832
	function prefill_provider() {
1833
		jQuery.ajax("getserviceproviders.php",{
1834
			type: 'post',
1835
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val(), plan : jQuery('#providerplan').val()},
1836
			success: function(data, textStatus, response) {
1837
				var xmldoc = response.responseXML;
1838
				var provider = xmldoc.getElementsByTagName('connection')[0];
1839
				jQuery('#ppp_username').val('');
1840
				jQuery('#ppp_password').val('');
1841
				if (provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1842
					jQuery('#phone').val('#777');
1843
					jQuery('#apn').val('');
1844
				} else {
1845
					jQuery('#phone').val('*99#');
1846
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1847
				}
1848
				ppp_username = provider.getElementsByTagName('ppp_username')[0].firstChild.data;
1849
				ppp_password = provider.getElementsByTagName('ppp_password')[0].firstChild.data;
1850
				jQuery('#ppp_username').val(ppp_username);
1851
				jQuery('#ppp_password').val(ppp_password);
1852
			}
1853
		});
1854
	}
1855

    
1856
	function update_track6_prefix() {
1857
		var iface = jQuery("#track6-interface").val();
1858
		if (iface == null) {
1859
			return;
1860
		}
1861
		var track6_prefix_ids = jQuery('#ipv6-num-prefix-ids-' + iface).val();
1862
		if (track6_prefix_ids == null) {
1863
			return;
1864
		}
1865
		track6_prefix_ids = parseInt(track6_prefix_ids).toString(16);
1866
		jQuery('#track6-prefix-id-range').html('(<b>hexadecimal</b> from 0 to ' + track6_prefix_ids + ')');
1867
	}
1868

    
1869
//]]>
1870
</script>
1871
</head>
1872
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1873
	<?php include("fbegin.inc"); ?>
1874
	<form action="interfaces.php" method="post" name="iform" id="iform">
1875
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1876
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1877
		<?php print_info_box_np(sprintf(gettext("The %s configuration has been changed."), $wancfg['descr']) . "</p><p>" . gettext("You must apply the changes in order for them to take effect.") . "</p><p>" . gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?></p><br />
1878
		<?php endif; ?>
1879
		<?php if ($savemsg) print_info_box($savemsg); ?>
1880
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces">
1881
			<tr>
1882
				<td id="mainarea">
1883
					<div class="tabcont">
1884
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
1885
						<tr>
1886
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1887
						</tr>
1888
						<tr>
1889
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1890
							<td width="78%" class="vtable">
1891
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked=\"checked\""; ?> onclick="show_allcfg(this);" />
1892
								<strong><?=gettext("Enable Interface"); ?></strong>
1893
							</td>
1894
						</tr>
1895
					</table>
1896
					<div style="display:none;" id="allcfg">
1897
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="allcfg">
1898
						<tr>
1899
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1900
							<td width="78%" class="vtable">
1901
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>" />
1902
								<br /><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1903
							</td>
1904
						</tr>
1905
						<tr>
1906
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1907
							<td class="vtable">
1908
								<select name="type" onchange="updateType(this.value);" <?php echo $type_disabled; ?> class="formselect" id="type">
1909
								<?php
1910
									foreach ($types4 as $key => $opt) {
1911
										echo "<option onclick=\"updateType('{$key}');\"";
1912
										if ($key == $pconfig['type']) {
1913
											echo " selected=\"selected\"";
1914
										}
1915
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1916
										echo "</option>";
1917
									}
1918
								?>
1919
								</select>
1920
							</td>
1921
						</tr>
1922
						<tr>
1923
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1924
							<td class="vtable">
1925
								<select name="type6" onchange="updateTypeSix(this.value);" <?php echo $type_disabled; ?> class="formselect" id="type6">
1926
								<?php
1927
									foreach ($types6 as $key => $opt) {
1928
										echo "<option onclick=\"updateTypeSix('{$key}');\"";
1929
										if ($key == $pconfig['type6']) {
1930
											echo " selected=\"selected\"";
1931
										}
1932
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1933
										echo "</option>";
1934
									}
1935
								?>
1936
								</select>
1937
							</td>
1938
						</tr>
1939
						<tr>
1940
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1941
							<td class="vtable">
1942
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>" />
1943
								<br />
1944
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1945
								"address of this interface"); ?><br />
1946
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1947
								"or leave blank"); ?>
1948
							</td>
1949
						</tr>
1950
						<tr>
1951
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1952
							<td class="vtable">
1953
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>" />
1954
								<br />
1955
								<?php
1956
									print gettext("If you leave this field blank, the adapter's default MTU will " .
1957
									"be used. This is typically 1500 bytes but can vary in some circumstances.");
1958
								?>
1959
							</td>
1960
						</tr>
1961
						<tr>
1962
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1963
							<td class="vtable">
1964
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>" />
1965
								<br />
1966
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1967
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1968
								"header size) will be in effect."); ?>
1969
							</td>
1970
						</tr>
1971
						<?php
1972
						if (count($mediaopts_list) > 0) {
1973
							$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1974
							echo "<tr>";
1975
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1976
							echo '<td class="vtable">';
1977
							echo '<div id="showadvmediabox"';
1978
							if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') {
1979
								echo " style='display:none'>";
1980
							} else {
1981
								echo '>';
1982
							}
1983
							echo '<input type="button" onclick="show_advanced_media()" value="' . gettext("Advanced") . '" /> - ' . gettext("Show advanced option");
1984
							echo "</div>";
1985
							echo '<div id="showmediaadv" ';
1986
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') {
1987
								echo "style='display:none'>";
1988
							} else {
1989
								echo '>';
1990
							}
1991
							echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1992
							print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1993
							print "<option value=\"\">------- Media Supported by this interface -------</option>";
1994
							foreach ($mediaopts_list as $mediaopt) {
1995
								if ($mediaopt != rtrim($mediaopt_from_config)) {
1996
									print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1997
								} else {
1998
									print "<option value=\"$mediaopt\" selected=\"selected\">" . gettext("$mediaopt") . "</option>";
1999
								}
2000
							}
2001
							echo '</select><br />';
2002
							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.");
2003
							echo '</div>';
2004
							echo '</td>';
2005
							echo '</tr>';
2006
						}
2007
						?>
2008
						<tr>
2009
							<td colspan="2" valign="top" height="16"></td>
2010
						</tr>
2011
						<tr style="display:none;" id="none">
2012
							<td style="display:none;"></td>
2013
						</tr>
2014
						<tr style="display:none;" id="staticv4">
2015
							<td colspan="2" style="padding:0px;">
2016
								<a name="gatewaysection"></a>
2017
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv4">
2018
									<tr>
2019
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
2020
									</tr>
2021
									<tr>
2022
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
2023
										<td width="78%" class="vtable">
2024
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" />
2025
											/
2026
											<select name="subnet" class="formselect" id="subnet">
2027
												<?php
2028
												for ($i = 32; $i > 0; $i--) {
2029
													echo "<option value=\"{$i}\" ";
2030
													if ($i == $pconfig['subnet']) {
2031
														echo "selected=\"selected\"";
2032
													}
2033
													echo ">" . $i . "</option>";
2034
												}
2035
												?>
2036
											</select>
2037
										</td>
2038
									</tr>
2039
									<tr>
2040
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Upstream Gateway"); ?></td>
2041
										<td width="78%" class="vtable">
2042
											<select name="gateway" class="formselect" id="gateway">
2043
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
2044
												<?php
2045
												if (count($a_gateways) > 0) {
2046
													foreach ($a_gateways as $gateway) {
2047
														if (($gateway['interface'] == $if) && (is_ipaddrv4($gateway['gateway']))) {
2048
												?>
2049
														<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected=\"selected\""; ?>>
2050
															<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
2051
														</option>
2052
												<?php
2053
														}
2054
													}
2055
												}
2056
												?>
2057
											</select>
2058
											- or  <strong><a onclick="show_add_gateway();" href="#gatewaysection"><?=gettext("add a new one."); ?></a></strong>
2059
											<br />
2060
											<div id='addgwbox'>
2061
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above."); ?><br />
2062
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
2063
											</div>
2064
											<div id='notebox'>
2065
											</div>
2066
											<div id="status">
2067
											</div>
2068
											<div style="display:none" id="addgateway">
2069
												<p>&nbsp;</p>
2070
												<table border="1" class="addgatewaybox" summary="addgateway">
2071
													<tr>
2072
														<td>
2073
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgateway">
2074
																<tr>
2075
																	<td>&nbsp;</td>
2076
																</tr>
2077
																<tr>
2078
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
2079
																</tr>
2080
																<tr>
2081
																	<td>&nbsp;</td>
2082
																</tr>
2083
																<?php
2084
																if ($if == "wan" || $if == "WAN") {
2085
																	$checked = " checked=\"checked\"";
2086
																}
2087
																?>
2088
																<tr>
2089
																	<td width="45%" align="right"><font color="white"><?=gettext("Default gateway:"); ?></font></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?> /></td>
2090
																</tr>
2091
																<tr>
2092
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></font></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>" /></td>
2093
																</tr>
2094
																<tr>
2095
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></font></td><td><input id="gatewayip" name="gatewayip" /></td>
2096
																</tr>
2097
																<tr>
2098
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescr" name="gatewaydescr" /></td>
2099
																</tr>
2100
																<tr>
2101
																	<td>&nbsp;</td>
2102
																</tr>
2103
																<tr>
2104
																	<td colspan="2">
2105
																		<center>
2106
																			<div id='savebuttondiv'>
2107
																				<input id="gwsave" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave();' />
2108
																				<input id="gwcancel" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway();' />
2109
																			</div>
2110
																		</center>
2111
																	</td>
2112
																</tr>
2113
																<tr>
2114
																	<td>&nbsp;</td>
2115
																</tr>
2116
															</table>
2117
														</td>
2118
													</tr>
2119
												</table>
2120
											</div>
2121
										</td>
2122
									</tr>
2123
									<tr>
2124
										<td colspan="2" valign="top" height="16"></td>
2125
									</tr>
2126
								</table>
2127
							</td>
2128
						</tr>
2129
						<tr style="display:none;" id="staticv6">
2130
							<td colspan="2" style="padding:0px;">
2131
								<a name="gatewayv6section"></a>
2132
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv6">
2133
									<tr>
2134
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
2135
									</tr>
2136
									<tr>
2137
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
2138
										<td width="78%" class="vtable">
2139
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>" />
2140
											/
2141
											<select name="subnetv6" class="formselect" id="subnetv6">
2142
												<?php
2143
												for ($i = 128; $i > 0; $i--) {
2144
													echo "<option value=\"{$i}\" ";
2145
													if ($i == $pconfig['subnetv6']) {
2146
														echo "selected=\"selected\"";
2147
													}
2148
													echo ">" . $i . "</option>";
2149
												}
2150
												?>
2151
											</select>
2152
										</td>
2153
									</tr>
2154
									<tr>
2155
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Upstream Gateway"); ?></td>
2156
										<td width="78%" class="vtable">
2157
											<select name="gatewayv6" class="formselect" id="gatewayv6">
2158
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
2159
												<?php
2160
												if (count($a_gateways) > 0) {
2161
													foreach ($a_gateways as $gateway) {
2162
														if (($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
2163
												?>
2164
														<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected=\"selected\""; ?>>
2165
															<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
2166
														</option>
2167
												<?php
2168
														}
2169
													}
2170
												}
2171
												?>
2172
											</select>
2173
											- or <strong><a onclick="show_add_gateway_v6();" href="#gatewayv6section"><?=gettext("add a new one."); ?></a></strong>
2174
											<br />
2175
											<div id='addgwboxv6'>
2176
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above."); ?><br />
2177
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
2178
											</div>
2179
											<div id='noteboxv6'>
2180
											</div>
2181
											<div id="statusv6">
2182
											</div>
2183
											<div style="display:none" id="addgatewayv6">
2184
												<p>&nbsp;</p>
2185
												<table border="1" class="addgatewaybox" summary="addgatewayv6">
2186
													<tr>
2187
														<td>
2188
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgatewayv6">
2189
																<tr>
2190
																	<td>&nbsp;</td>
2191
																</tr>
2192
																<tr>
2193
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
2194
																</tr>
2195
																<tr>
2196
																	<td>&nbsp;</td>
2197
																</tr>
2198
																<?php
2199
																if ($if == "wan" || $if == "WAN") {
2200
																	$checked = " checked=\"checked\"";
2201
																}
2202
																?>
2203
																<tr>
2204
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></font></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?> /></td>
2205
																</tr>
2206
																<tr>
2207
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></font></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>" /></td>
2208
																</tr>
2209
																<tr>
2210
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></font></td><td><input id="gatewayipv6" name="gatewayipv6" /></td>
2211
																</tr>
2212
																<tr>
2213
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescrv6" name="gatewaydescrv6" /></td>
2214
																</tr>
2215
																<tr>
2216
																	<td>&nbsp;</td>
2217
																</tr>
2218
																<tr>
2219
																	<td colspan="2">
2220
																		<center>
2221
																			<div id='savebuttondivv6'>
2222
																				<input id="gwsavev6" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave_v6();' />
2223
																				<input id="gwcancelv6" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway_v6();' />
2224
																			</div>
2225
																		</center>
2226
																	</td>
2227
																</tr>
2228
																<tr>
2229
																	<td>&nbsp;</td>
2230
																</tr>
2231
															</table>
2232
														</td>
2233
													</tr>
2234
												</table>
2235
											</div>
2236
										</td>
2237
									</tr>
2238
									<tr>
2239
										<td colspan="2" valign="top" height="16"></td>
2240
									</tr>
2241
								</table>
2242
							</td>
2243
						</tr>
2244
						<tr style="display:none;" id="dhcp">
2245
							<td colspan="2" style="padding: 0px;">
2246
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp">
2247
									<tr>
2248
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration &nbsp; &nbsp; " .
2249
										' <input name="adv_dhcp_config_advanced" type="checkbox" id="adv_dhcp_config_advanced" value="" onclick="show_adv_dhcp_config(this)" /> ' .
2250
										" Advanced &nbsp; &nbsp; " .
2251
										' <input name="adv_dhcp_config_file_override" type="checkbox" id="adv_dhcp_config_file_override" value="" onclick="show_adv_dhcp_config(this)" /> ' .
2252
										" Config File Override &nbsp; &nbsp; "); ?>
2253
										</td>
2254
									</tr>
2255
									<!-- Uncomment to expose DHCP+ in GUI
2256
									<tr>
2257
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
2258
										<td width="78%" class="vtable">
2259
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked=\"checked\""; ?> />
2260
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
2261
										<br />
2262
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
2263
										</td>
2264
									</tr>
2265
									-->
2266
									<tr style='display:none' id="show_basic_dhcphostname">
2267
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
2268
										<td width="78%" class="vtable">
2269
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>" />
2270
											<br />
2271
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
2272
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
2273
											"this (for client identification)."); ?>
2274
										</td>
2275
									</tr>
2276
									<tr style='display:none' id="show_basic_dhcpalias-address">
2277
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
2278
										<td width="78%" class="vtable">
2279
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>" />
2280
											<select name="alias-subnet" class="formselect" id="alias-subnet">
2281
												<?php
2282
												for ($i = 32; $i > 0; $i--) {
2283
													echo "<option value=\"{$i}\" ";
2284
													if ($i == $pconfig['alias-subnet']) {
2285
														echo "selected=\"selected\"";
2286
													}
2287
													echo ">" . $i . "</option>";
2288
												}
2289
												?>
2290
											</select>
2291
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
2292
											"DHCP client."); ?>
2293
										</td>
2294
									</tr>
2295
									<tr style='display:none' id="show_basic_dhcprejectlease">
2296
										<td width="22%" valign="top" class="vncell"><?=gettext("Reject Leases From"); ?></td>
2297
										<td width="78%" class="vtable">
2298
											<input name="dhcprejectfrom" type="text" class="formfld unknown" id="dhcprejectfrom" size="20" value="<?=htmlspecialchars($pconfig['dhcprejectfrom']);?>" />
2299
											<br />
2300
											<?=gettext("If there is a certain upstream DHCP server that should be ignored, place the IP address or subnet of the DHCP server to be ignored here."); ?>
2301
											<?=gettext("This is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync."); ?>
2302
										</td>
2303
									</tr>
2304

    
2305
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
2306
										<td width="22%" valign="top" class="vncell"><a target="_blank" href="http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#PROTOCOL_TIMING"><?=gettext("Protocol Timing"); ?></a></td>
2307
										<td width="48%" class="vtable">
2308
											Timeout: <input name="adv_dhcp_pt_timeout" type="text" class="formfld unknown" id="adv_dhcp_pt_timeout" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_timeout']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2309
											Retry:   <input name="adv_dhcp_pt_retry"   type="text" class="formfld unknown" id="adv_dhcp_pt_retry"   size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_retry']);?>"   onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2310
											Select Timeout: <input name="adv_dhcp_pt_select_timeout" type="text" class="formfld unknown" id="adv_dhcp_pt_select_timeout" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_select_timeout']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2311

    
2312
											&nbsp; &nbsp; &nbsp; &nbsp;
2313
											Presets: &nbsp;
2314
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	id="customdhcpptdhcpdefaults"	onclick="customdhcpptsetvalues(this, iform);" />FreeBSD Default &nbsp;
2315
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	id="customdhcpptclear" onclick="customdhcpptsetvalues(this, iform);" />Clear
2316

    
2317
											<br />
2318
											Reboot: <input name="adv_dhcp_pt_reboot" type="text" class="formfld unknown" id="adv_dhcp_pt_reboot" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_reboot']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2319
											Backoff Cutoff:   <input name="adv_dhcp_pt_backoff_cutoff"   type="text" class="formfld unknown" id="adv_dhcp_pt_backoff_cutoff"   size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_backoff_cutoff']);?>"   onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2320
											Initial Interval: <input name="adv_dhcp_pt_initial_interval" type="text" class="formfld unknown" id="adv_dhcp_pt_initial_interval" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_initial_interval']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2321

    
2322
											&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
2323
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense" id="customdhcpptpfsensedefaults" onclick="customdhcpptsetvalues(this, iform);" />pfSense Default &nbsp;
2324
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked="checked" id="customdhcpptsavedcfg" onclick="customdhcpptsetvalues(this, iform);" />Saved Cfg
2325

    
2326
											<br />
2327
											<?=gettext("The values in these fields are DHCP protocol timings used when requesting a lease. <br /> "); ?>
2328

    
2329
											<script type="text/javascript">
2330
											//<![CDATA[
2331
												function customdhcpptcheckradiobuton(T, BUTTON) {
2332
													for (var i = 0; i < T.length; i++) {
2333
														T[i].checked = false;
2334
														if (T[i].value == BUTTON) T[i].checked = true;
2335
													}
2336
													T.value = BUTTON;
2337
												}
2338

    
2339
												function customdhcpptsetvalues(T, FORM) {
2340
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
2341
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
2342
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
2343
													if (T.value == "SavedCfg")	customdhcpptsetvaluesnow(T, FORM, "<?=htmlspecialchars($pconfig['adv_dhcp_pt_timeout']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_retry']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_select_timeout']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_reboot']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_backoff_cutoff']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_initial_interval']);?>");
2344
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
2345
												}
2346

    
2347
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
2348
													FORM.adv_dhcp_pt_timeout.value = timeout;
2349
													FORM.adv_dhcp_pt_retry.value = retry;
2350
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2351
													FORM.adv_dhcp_pt_reboot.value = reboot;
2352
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2353
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2354

    
2355
													FORM.adv_dhcp_pt_values.value = T.value;
2356
												}
2357

    
2358
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
2359
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
2360
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
2361
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
2362
											//]]>
2363
											</script>
2364
										</td>
2365
									</tr>
2366

    
2367
									<tr style='display:none' id="show_adv_dhcp_lease_requirements_and_requests">
2368
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Lease Requirements and Requests</a>"); ?></td>
2369
										<td width="78%" class="vtable">
2370
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Send</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2371
											<input name="adv_dhcp_send_options" type="text" class="formfld unknown" id="adv_dhcp_send_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_send_options']);?>" />
2372
											<br />
2373
											<?=gettext("The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2374
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2375
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2376
											"Some ISPs may require certain options be or not be sent. "); ?>
2377
											<hr/>
2378
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Request</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2379
											<input name="adv_dhcp_request_options" type="text" class="formfld unknown" id="adv_dhcp_request_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_request_options']);?>" />
2380
											<br />
2381
											<?=gettext("The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2382
											"Some ISPs may require certain options be or not be requested. "); ?>
2383
											<hr/>
2384
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Require</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2385
											<input name="adv_dhcp_required_options" type="text" class="formfld unknown" id="adv_dhcp_required_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_required_options']);?>" />
2386
											<br />
2387
											<?=gettext("The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]] "); ?>
2388
										</td>
2389
									</tr>
2390

    
2391
									<tr style='display:none' id="show_adv_dhcp_option_modifiers">
2392
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Option</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#OPTION_MODIFIERS\">Modifiers</a>"); ?></td>
2393
										<td width="78%" class="vtable">
2394
											<input name="adv_dhcp_option_modifiers" type="text" class="formfld unknown" id="adv_dhcp_option_modifiers" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_option_modifiers']);?>" />
2395
											<br />
2396
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br /> " .
2397
											"modifiers: (default, supersede, prepend, append)"); ?>
2398
										</td>
2399
									</tr>
2400

    
2401
									<tr style='display:none' id="show_adv_dhcp_config_file_override">
2402
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5\">Configuration File</a> Override"); ?></td>
2403
										<td width="78%" class="vtable">
2404
											<input name="adv_dhcp_config_file_override_path"   type="text" class="formfld unknown" id="adv_dhcp_config_file_override_path" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override_path']);?>" />
2405
											<br />
2406
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2407
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2408
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2409
											"Some ISPs may require certain options be or not be sent. "); ?>
2410
										</td>
2411
									</tr>
2412

    
2413
									<tr>
2414
										<td colspan="2" valign="top" height="16"></td>
2415
									</tr>
2416

    
2417
								</table>
2418

    
2419
								<script type="text/javascript">
2420
								//<![CDATA[
2421
									function show_adv_dhcp_config(T) {
2422

    
2423
										if (T.checked) {
2424
											T.value = "Selected";
2425
										} else {
2426
											T.value = "";
2427
										}
2428

    
2429
										if (document.iform.adv_dhcp_config_file_override.checked) {
2430
											show_hide_adv_dhcp('none', 'none', '');
2431
										} else if (document.iform.adv_dhcp_config_advanced.checked)	{
2432
											show_hide_adv_dhcp('', '', 'none');
2433
										} else {
2434
											show_hide_adv_dhcp('', 'none', 'none');
2435
										}
2436
									}
2437

    
2438
									function show_hide_adv_dhcp(basic, advanced, override) {
2439

    
2440
										document.getElementById("show_basic_dhcphostname").style.display = basic;
2441
										document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2442
										document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2443

    
2444
										document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2445
										document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2446
										document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2447

    
2448
										document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2449
									}
2450

    
2451
									<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2452
									if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") {
2453
										document.iform.adv_dhcp_config_advanced.checked = true;
2454
									}
2455
									show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2456

    
2457
									<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2458
									if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") {
2459
										document.iform.adv_dhcp_config_file_override.checked = true;
2460
									}
2461
									show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2462
								//]]>
2463
								</script>
2464

    
2465
							</td>
2466
						</tr>
2467
						<tr style="display:none;" id="dhcp6">
2468
							<td colspan="2" style="padding: 0px;">
2469
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp6">
2470
									<tr>
2471
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration &nbsp; &nbsp; " .
2472
										' <input name="adv_dhcp6_config_advanced" type="checkbox" id="adv_dhcp6_config_advanced" value="" onclick="show_adv_dhcp6_config(this)" /> ' .
2473
										" Advanced &nbsp; &nbsp; " .
2474
										' <input name="adv_dhcp6_config_file_override" type="checkbox" id="adv_dhcp6_config_file_override" value="" onclick="show_adv_dhcp6_config(this)" /> ' .
2475
										" Config File Override &nbsp; &nbsp; "); ?>
2476
										</td>
2477
									</tr>
2478
									<!--- Leave commented out for now
2479
									<tr style='display:none' id="basicdhcp6_show_dhcp6_duid">
2480
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
2481
										<td width="78%" class="vtable">
2482
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>" />
2483
											<br />
2484
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
2485
											"when requesting a DHCPv6 lease."); ?><br />
2486
											<?php	if (is_readable("/var/db/dhcp6c_duid")) {
2487
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
2488
												}
2489
												printf(gettext("The current DUID is: '%s'"), $current_duid);
2490
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
2491
											?>
2492
										</td>
2493
									</tr>
2494
									-->
2495
									<tr style='display:none' id="basicdhcp6_use_pppoeinterface">
2496
										<td width="22%" valign="top" class="vncell"><?=gettext("Use IPv4 connectivity as parent interface"); ?></td>
2497
										<td width="78%" class="vtable">
2498
											<input name="dhcp6usev4iface" type="checkbox" id="dhcp6usev4iface" value="yes" <?php if ($pconfig['dhcp6usev4iface'] == true) echo "checked=\"checked\""; ?> />
2499
											<?=gettext("Request a IPv6 prefix/information through the IPv4 connectivity link"); ?>
2500
										</td>
2501
									</tr>
2502
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_only">
2503
										<td width="22%" valign="top" class="vncell"><?=gettext("Request only an IPv6 prefix"); ?></td>
2504
										<td width="78%" class="vtable">
2505
											<input name="dhcp6prefixonly" type="checkbox" id="dhcp6prefixonly" value="yes" <?php if ($pconfig['dhcp6prefixonly'] == true) echo "checked=\"checked\""; ?> />
2506
											<?=gettext("Only request an IPv6 prefix, do not request an IPv6 address"); ?>
2507
										</td>
2508
									</tr>
2509
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_delegation_size">
2510
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
2511
										<td width="78%" class="vtable">
2512
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
2513
												<?php
2514
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 3 => "61",  2 => "62", 1 => "63", 0 => "64");
2515
												foreach ($sizes as $bits => $length) {
2516
													echo "<option value=\"{$bits}\" ";
2517
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) {
2518
														echo "selected=\"selected\"";
2519
													}
2520
													echo ">" . $length . "</option>";
2521
												}
2522
												?>
2523
											</select>
2524
											<br />
2525
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
2526
										</td>
2527
									</tr>
2528
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_send_hint">
2529
										<td width="22%" valign="top" class="vncell"><?=gettext("Send IPv6 prefix hint"); ?></td>
2530
										<td width="78%" class="vtable">
2531
											<input name="dhcp6-ia-pd-send-hint" type="checkbox" id="dhcp6-ia-pd-send-hint" value="yes" <?php if ($pconfig['dhcp6-ia-pd-send-hint'] == true) echo "checked=\"checked\""; ?> />
2532
											<?=gettext("Send an IPv6 prefix hint to indicate the desired prefix size for delegation"); ?>
2533
										</td>
2534
									</tr>
2535

    
2536
									<tr style='display:none' id="show_adv_dhcp6_interface_statement">
2537
										<td width="22%" valign="top" class="vncell">
2538
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+10.1-RELEASE+and+Ports#Interface_statement\">Interface Statement</a>"); ?>
2539
											<br /><br />
2540
											<input name="adv_dhcp6_interface_statement_information_only_enable" type="checkbox" id="adv_dhcp6_interface_statement_information_only_enable" value="" onclick="show_adv_dhcp6_config(this)" />
2541
											<?=gettext("Information Only"); ?>
2542
										</td>
2543
										<td width="78%" class="vtable">
2544
											<?=gettext("Send Options"); ?><br />
2545
											<input name="adv_dhcp6_interface_statement_send_options" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_send_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_send_options']);?>" />
2546
											<br />
2547
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2548
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2549
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2550
											"Some DHCP services may require certain options be or not be sent. "); ?>
2551
											<br />
2552
											<br />
2553
											<?=gettext("Request Options"); ?><br />
2554
											<input name="adv_dhcp6_interface_statement_request_options" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_request_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_request_options']);?>" />
2555
											<br />
2556
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2557
											"Some DHCP services may require certain options be or not be requested. "); ?>
2558
											<br />
2559
											<br />
2560
											<?=gettext("Script"); ?><br />
2561
											<input name="adv_dhcp6_interface_statement_script" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_script" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_script']);?>" />
2562
											<br />
2563
											<?=gettext("The value in this field is the absolute path to a script invoked on certain conditions including when a reply message is received. <br />" .
2564
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2565
										</td>
2566
									</tr>
2567

    
2568
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_statement">
2569
										<td width="22%" valign="top" class="vncell">
2570
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+10.1-RELEASE+and+Ports#Identity_association_statement\">Identity Association Statement</a>"); ?>
2571
										</td>
2572
										<td width="78%" class="vtable">
2573

    
2574
											<input name="adv_dhcp6_id_assoc_statement_address_enable" type="checkbox" id="adv_dhcp6_id_assoc_statement_address_enable" value="" onclick="show_adv_dhcp6_config(this);" />
2575
											<?=gettext("Non-Temporary Address Allocation"); ?>
2576
											<div style='display:none' id="show_adv_dhcp6_id_assoc_statement_address">
2577
											<?=gettext("id-assoc na"); ?>
2578
											<?=gettext("<i>ID</i>"); ?>
2579
											<input name="adv_dhcp6_id_assoc_statement_address_id" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_id']);?>" />
2580
											<br />
2581
											<?=gettext("Address"); ?>
2582
											<?=gettext("<i>ipv6-address</i>"); ?>
2583
											<input name="adv_dhcp6_id_assoc_statement_address" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address" size="34" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address']);?>" />
2584
											<?=gettext("<i>pltime</i>"); ?>
2585
											<input name="adv_dhcp6_id_assoc_statement_address_pltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_pltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_pltime']);?>" />
2586
											<?=gettext("<i>vltime</i>"); ?>
2587
											<input name="adv_dhcp6_id_assoc_statement_address_vltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_vltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_vltime']);?>" />
2588
											</div>
2589
											<hr/>
2590

    
2591
											<input name="adv_dhcp6_id_assoc_statement_prefix_enable" type="checkbox" id="adv_dhcp6_id_assoc_statement_prefix_enable" value="" onclick="show_adv_dhcp6_config(this)" />
2592
											<?=gettext("Prefix Delegation"); ?>
2593
											<div style='display:none' id="show_adv_dhcp6_id_assoc_statement_prefix">
2594
											<?=gettext("id-assoc pd"); ?>
2595
											<?=gettext("<i>ID</i>"); ?>
2596
											<input name="adv_dhcp6_id_assoc_statement_prefix_id" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_id']);?>" />
2597
											<br />
2598
											<?=gettext("Prefix"); ?>
2599
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2600
											<input name="adv_dhcp6_id_assoc_statement_prefix" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix" size="37" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix']);?>" />
2601
											<?=gettext("<i>pltime</i>"); ?>
2602
											<input name="adv_dhcp6_id_assoc_statement_prefix_pltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_pltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime']);?>" />
2603
											<?=gettext("<i>vltime</i>"); ?>
2604
											<input name="adv_dhcp6_id_assoc_statement_prefix_vltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_vltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime']);?>" />
2605
											</div>
2606
										</td>
2607
									</tr>
2608

    
2609
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2610
										<td width="22%" valign="top" class="vncell">
2611
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+10.1-RELEASE+and+Ports#Prefix_interface_statement\">Prefix Interface Statement</a>"); ?>
2612
										</td>
2613
										<td width="78%" class="vtable">
2614
											<?=gettext("Prefix Interface "); ?>
2615
											<?=gettext("<i>sla-id</i>"); ?>
2616
											<input name="adv_dhcp6_prefix_interface_statement_sla_id" type="text" class="formfld unknown" id="adv_dhcp6_prefix_interface_statement_sla_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_prefix_interface_statement_sla_id']);?>" />
2617
											<?=gettext("<i>sla-len</i>"); ?>
2618
											<input name="adv_dhcp6_prefix_interface_statement_sla_len" type="text" class="formfld unknown" id="adv_dhcp6_prefix_interface_statement_sla_len" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_prefix_interface_statement_sla_len']);?>" />
2619
										</td>
2620
									</tr>
2621

    
2622
									<tr style='display:none' id="show_adv_dhcp6_authentication_statement">
2623
										<td width="22%" valign="top" class="vncell">
2624
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+10.1-RELEASE+and+Ports#Authentication_statement\">Authentication Statement</a>"); ?>
2625
										</td>
2626
										<td width="78%" class="vtable">
2627
											<?=gettext("<i>authname</i>"); ?>
2628
											<input name="adv_dhcp6_authentication_statement_authname" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_authname" size="10" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_authname']);?>" />
2629
											<?=gettext("<i>protocol</i>"); ?>
2630
											<input name="adv_dhcp6_authentication_statement_protocol" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_protocol" size="6" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_protocol']);?>" />
2631
											<?=gettext("<i>algorithm</i>"); ?>
2632
											<input name="adv_dhcp6_authentication_statement_algorithm" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_algorithm" size="8" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_algorithm']);?>" />
2633
											<?=gettext("<i>rdm</i>"); ?>
2634
											<input name="adv_dhcp6_authentication_statement_rdm" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_rdm" size="9" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_rdm']);?>" />
2635
										</td>
2636
									</tr>
2637

    
2638
									<tr style='display:none' id="show_adv_dhcp6_key_info_statement">
2639
										<td width="22%" valign="top" class="vncell">
2640
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+10.1-RELEASE+and+Ports#Keyinfo_statement\">Keyinfo Statement</a>"); ?>
2641
										</td>
2642
										<td width="78%" class="vtable">
2643
											<?=gettext("<i>keyname</i>"); ?>
2644
											<input name="adv_dhcp6_key_info_statement_keyname" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_keyname" size="27" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_keyname']);?>" />
2645
											<?=gettext("<i>realm</i>"); ?>
2646
											<input name="adv_dhcp6_key_info_statement_realm" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_realm" size="37" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_realm']);?>" />
2647
											<br />
2648
											<?=gettext("<i>keyid</i>"); ?>
2649
											<input name="adv_dhcp6_key_info_statement_keyid" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_keyid" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_keyid']);?>" />
2650
											<?=gettext("<i>secret</i>"); ?>
2651
											<input name="adv_dhcp6_key_info_statement_secret" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_secret" size="36" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_secret']);?>" />
2652
											<?=gettext("<i>expire</i>"); ?>
2653
											<input name="adv_dhcp6_key_info_statement_expire" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_expire" size="15" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_expire']);?>" />
2654
										</td>
2655
									</tr>
2656

    
2657
									<tr style='display:none' id="show_adv_dhcp6_config_file_override">
2658
										<td width="22%" valign="top" class="vncell">
2659
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+10.1-RELEASE+and+Ports\">Configuration File</a> Override"); ?>
2660
										</td>
2661
										<td width="78%" class="vtable">
2662
											<input name="adv_dhcp6_config_file_override_path"   type="text" class="formfld unknown" id="adv_dhcp6_config_file_override_path" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override_path']);?>" />
2663
											<br />
2664
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2665
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2666
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2667
											"Some ISPs may require certain options be or not be sent. "); ?>
2668
										</td>
2669
									</tr>
2670

    
2671
									<tr>
2672
										<td colspan="2" valign="top" height="16"></td>
2673
									</tr>
2674

    
2675
								</table>
2676

    
2677
								<script type="text/javascript">
2678
								//<![CDATA[
2679
									function show_adv_dhcp6_config(T) {
2680

    
2681
										if (T.checked) {
2682
											T.value = "Selected";
2683
										} else {
2684
											T.value = "";
2685
										}
2686

    
2687
										if (document.iform.adv_dhcp6_config_file_override.checked) {
2688
											show_hide_adv_dhcp6('none', 'none', '');
2689
										} else if (document.iform.adv_dhcp6_config_advanced.checked) {
2690
											show_hide_adv_dhcp6('none', '', 'none');
2691
										} else {
2692
											show_hide_adv_dhcp6('', 'none', 'none');
2693
										}
2694
									}
2695

    
2696
									function show_hide_adv_dhcp6(basic, advanced, override) {
2697

    
2698
										document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2699
										document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2700
										document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2701
										document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2702

    
2703
										document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2704
										document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2705

    
2706
										document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2707
										if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked) {
2708
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2709
										}
2710

    
2711
										document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2712
										document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2713
										if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked) {
2714
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2715
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2716
										}
2717

    
2718
										document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2719
										document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2720

    
2721
										document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2722
									}
2723

    
2724
									<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2725
									if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") {
2726
										document.iform.adv_dhcp6_config_advanced.checked = true;
2727
									}
2728
									show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2729

    
2730
									<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
2731
									if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override']);?>" == "Selected") {
2732
										document.iform.adv_dhcp6_config_file_override.checked = true;
2733
									}
2734
									show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
2735

    
2736
									<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
2737
									if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable']);?>" == "Selected") {
2738
										document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
2739
									}
2740
									show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
2741

    
2742
									<!-- Set the adv_dhcp6_id_assoc_statement_address_enable checkbox from saved config -->
2743
									if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_enable']);?>" == "Selected") {
2744
										document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked = true;
2745
									}
2746
									show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_address_enable);
2747

    
2748
									<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
2749
									if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']);?>" == "Selected") {
2750
										document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
2751
									}
2752
									show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
2753
								//]]>
2754
								</script>
2755

    
2756
							</td>
2757
						</tr>
2758
						<tr style="display:none;" id="_6rd">
2759
							<td colspan="2" style="padding: 0px;">
2760
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="6rd">
2761
									<tr>
2762
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Configuration"); ?></td>
2763
									</tr>
2764
									<tr>
2765
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
2766
										<td width="78%" class="vtable">
2767
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>" />
2768
											<br />
2769
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
2770
										</td>
2771
									</tr>
2772
									<tr>
2773
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
2774
										<td width="78%" class="vtable">
2775
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>" />
2776
											<br />
2777
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
2778
										</td>
2779
									</tr>
2780
									<tr>
2781
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
2782
										<td width="78%" class="vtable">
2783
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
2784
												<?php
2785
												for ($i = 0; $i < 32; $i++) {
2786
													echo "<option value=\"{$i}\" ";
2787
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) {
2788
														echo "selected=\"selected\"";
2789
													}
2790
													echo ">" . $i . " bits</option>";
2791
												}
2792
												?>
2793
											</select>
2794
											<br />
2795
											<?=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."); ?>
2796
										</td>
2797
									</tr>
2798
									<tr>
2799
										<td colspan="2" valign="top" height="16"></td>
2800
									</tr>
2801
								</table>
2802
							</td>
2803
						</tr>
2804
						<tr style="display:none;" id="track6">
2805
							<td colspan="2" style="padding: 0px;">
2806
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="track6">
2807
									<tr>
2808
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
2809
									</tr>
2810
									<tr>
2811
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
2812
										<td width="78%" class="vtable">
2813
											<select name="track6-interface" id='track6-interface' class='formselect' onchange="update_track6_prefix();">
2814
											<?php
2815
												$interfaces = get_configured_interface_with_descr(false, true);
2816
												$dynv6ifs = array();
2817
												foreach ($interfaces as $iface => $ifacename) {
2818
													switch ($config['interfaces'][$iface]['ipaddrv6']) {
2819
														case "6to4":
2820
														case "6rd":
2821
														case "dhcp6":
2822
															$dynv6ifs[$iface] = array(
2823
																'name' => $ifacename,
2824
																'ipv6_num_prefix_ids' => pow(2, calculate_ipv6_delegation_length($iface)) - 1
2825
															);
2826
															break;
2827
														default:
2828
															continue;
2829
													}
2830
												}
2831
												$rowIndex = 0;
2832
												foreach ($dynv6ifs as $iface => $ifacedata) {
2833
													$rowIndex++;
2834
													echo "<option value=\"{$iface}\"";
2835
													if ($iface == $pconfig['track6-interface']) {
2836
														echo " selected=\"selected\"";
2837
													}
2838
													echo ">" . htmlspecialchars($ifacedata['name']) . "</option>";
2839
												}
2840
												if ($rowIndex == 0) {
2841
													echo "<option></option>";
2842
												}
2843
											?>
2844
											</select> <br />
2845
											<?php
2846
												foreach ($dynv6ifs as $iface => $ifacedata) {
2847
													echo "<input type=\"hidden\" name=\"ipv6-num-prefix-ids-{$iface}\" id=\"ipv6-num-prefix-ids-{$iface}\" value=\"{$ifacedata['ipv6_num_prefix_ids']}\">\n";
2848
												}
2849
											?>
2850
											<br />
2851
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
2852
										</td>
2853
									</tr>
2854
									<tr>
2855
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
2856
										<td width="78%" class="vtable">
2857
											<?php
2858
												if ($pconfig['track6-prefix-id'] == "") {
2859
													$pconfig['track6-prefix-id'] = 0;
2860
												}
2861
												$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
2862
											?>
2863
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
2864
											<span id="track6-prefix-id-range"></span>
2865
											<input type="hidden" id="track6-prefix-id-max" value="0"></input>
2866
											<br />
2867
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix ID. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
2868
											<br />
2869
											<?= gettext("default value is 0."); ?>
2870
										</td>
2871
									</tr>
2872
									<tr>
2873
										<td colspan="2" valign="top" height="16"></td>
2874
									</tr>
2875
								</table>
2876
							</td>
2877
						</tr>
2878
						<tr style="display:none;" id="ppp">
2879
							<td colspan="2" style="padding: 0px;">
2880
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="ppp">
2881
									<tr>
2882
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
2883
									</tr>
2884
									<tr id="ppp_provider">
2885
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
2886
										<td width="78%" class="vtable">
2887
											<table border="0" cellpadding="0" cellspacing="0" summary="service provider">
2888
												<tr id="trcountry">
2889
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
2890
													<td>
2891
														<select class="formselect" name="country" id="country" onchange="providers_list()">
2892
															<option></option>
2893
														</select>
2894
													</td>
2895
												</tr>
2896
												<tr id="trprovider" style="display:none">
2897
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
2898
													<td>
2899
														<select class="formselect" name="provider_list" id="provider_list" onchange="providerplan_list()">
2900
															<option></option>
2901
														</select>
2902
													</td>
2903
												</tr>
2904
												<tr id="trproviderplan" style="display:none">
2905
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
2906
													<td>
2907
														<select class="formselect" name="providerplan" id="providerplan" onchange="prefill_provider()">
2908
															<option></option>
2909
														</select>
2910
													</td>
2911
												</tr>
2912
											</table>
2913
											<br /><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
2914
										</td>
2915
									</tr>
2916
									<tr>
2917
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
2918
										<td width="78%" class="vtable">
2919
											<input name="ppp_username" type="text" class="formfld user" id="ppp_username" size="20" value="<?=htmlspecialchars($pconfig['ppp_username']);?>" />
2920
										</td>
2921
									</tr>
2922
									<tr>
2923
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
2924
										<td width="78%" class="vtable">
2925
											<input name="ppp_password" type="password" class="formfld pwd" id="ppp_password" size="20" value="<?=htmlspecialchars($pconfig['ppp_password']);?>" />
2926
										</td>
2927
									</tr>
2928
									<tr id="phone_num">
2929
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
2930
										<td width="78%" class="vtable">
2931
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>" />
2932
										</td>
2933
									</tr>
2934
									<tr id="apn_">
2935
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
2936
										<td width="78%" class="vtable">
2937
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>" />
2938
										</td>
2939
									</tr>
2940
									<tr id="interface" >
2941
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
2942
										<td width="78%" class="vtable">
2943
											<select name="port" id="port" class="formselect">
2944
											<?php
2945
												$portlist = glob("/dev/cua*");
2946
												$modems = glob("/dev/modem*");
2947
												$portlist = array_merge($portlist, $modems);
2948
												$rowIndex = 0;
2949
												foreach ($portlist as $port) {
2950
													if (preg_match("/\.(lock|init)$/", $port)) {
2951
														continue;
2952
													}
2953
													$rowIndex++;
2954
													echo "<option value=\"".trim($port)."\"";
2955
													if ($pconfig['port'] == $port) {
2956
														echo " selected=\"selected\"";
2957
													}
2958
													echo ">{$port}</option>";
2959
												}
2960
												if ($rowIndex == 0) {
2961
													echo "<option></option>";
2962
												}
2963
											?>
2964
											</select>
2965
										</td>
2966
									</tr>
2967
									<tr>
2968
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
2969
										<?php if (isset($pconfig['pppid'])): ?>
2970
											<td width="78%" class="vtable">
2971
												<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2972
												<?=gettext("to edit PPP configuration."); ?>
2973
											</td>
2974
										<?php else: ?>
2975
											<td width="78%" class="vtable">
2976
												<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2977
												<?=gettext("to create a PPP configuration."); ?>
2978
											</td>
2979
										<?php endif; ?>
2980
									</tr>
2981
									<tr>
2982
										<td colspan="2" valign="top" height="16"></td>
2983
									</tr>
2984
								</table>
2985
							</td>
2986
						</tr>
2987
						<tr style="display:none;" id="pppoe">
2988
							<td colspan="2" style="padding:0px;">
2989
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pppoe">
2990
									<tr>
2991
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
2992
									</tr>
2993
									<tr>
2994
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2995
										<td width="78%" class="vtable">
2996
											<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>" />
2997
										</td>
2998
									</tr>
2999
									<tr>
3000
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
3001
										<td width="78%" class="vtable">
3002
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>" />
3003
										</td>
3004
									</tr>
3005
									<tr>
3006
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
3007
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>" />
3008
											<br /> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
3009
										</td>
3010
									</tr>
3011
									<tr>
3012
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
3013
										<td width="78%" class="vtable">
3014
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked=\"checked\""; ?> />
3015
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
3016
											<?=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."); ?>
3017
										</td>
3018
									</tr>
3019
									<tr>
3020
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
3021
										<td width="78%" class="vtable">
3022
											<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."); ?>
3023
										</td>
3024
									</tr>
3025
									<tr>
3026
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
3027
										<td width="78%" class="vtable">
3028
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" summary="periodic reset">
3029
												<tr>
3030
													<td align="left" valign="top">
3031
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
3032
														<select style="vertical-align:top" id="reset_type" name="pppoe-reset-type" class="formselect" onchange="show_reset_settings(this.value);">
3033
															<option value=""><?=gettext("Disabled"); ?></option>
3034
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected=\"selected\""; ?>><?=gettext("Custom"); ?></option>
3035
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected=\"selected\""; ?>><?=gettext("Pre-Set"); ?></option>
3036
														</select> <?=gettext("Select a reset timing type"); ?>
3037
														</p>
3038
														<?php if ($pconfig['pppoe_pr_custom']): ?>
3039
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
3040
														<?php else: ?>
3041
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
3042
														<?php endif; ?>
3043
														<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="<?= htmlspecialchars($pconfig['pppoe_resethour']); ?>" size="3" />
3044
														<?=gettext("hour (0-23)"); ?><br />
3045
														<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="<?= htmlspecialchars($pconfig['pppoe_resetminute']); ?>" size="3" />
3046
														<?=gettext("minute (0-59)"); ?><br />
3047
														<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']);?>" />
3048
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
3049
														<br />&nbsp;<br />
3050
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
3051
														<?=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."); ?>
3052
														</p>
3053
														<?php if ($pconfig['pppoe_pr_preset']): ?>
3054
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
3055
														<?php else: ?>
3056
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
3057
														<?php endif; ?>
3058
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
3059
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
3060
														<br />
3061
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
3062
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
3063
														<br />
3064
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
3065
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
3066
														<br />
3067
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
3068
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
3069
														</p>
3070
													</td>
3071
												</tr>
3072
											</table>
3073
										</td>
3074
									</tr>
3075

    
3076
									<tr>
3077
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
3078
										<?php if (isset($pconfig['pppid'])): ?>
3079
											<td width="78%" class="vtable">
3080
												<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
3081
												<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
3082
											</td>
3083
										<?php else: ?>
3084
											<td width="78%" class="vtable">
3085
												<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
3086
												<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
3087
											</td>
3088
										<?php endif; ?>
3089
									</tr>
3090
									<tr>
3091
										<td colspan="2" valign="top" height="16"></td>
3092
									</tr>
3093
								</table>
3094
							</td>
3095
						</tr>
3096
						<tr style="display:none;" id="pptp">
3097
							<td colspan="2" style="padding:0px;">
3098
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pptp">
3099
									<tr>
3100
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
3101
									</tr>
3102
									<tr>
3103
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
3104
										<td width="78%" class="vtable">
3105
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>" />
3106
										</td>
3107
									</tr>
3108
									<tr>
3109
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
3110
										<td width="78%" class="vtable">
3111
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>" />
3112
										</td>
3113
									</tr>
3114
									<tr>
3115
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
3116
										<td width="78%" class="vtable">
3117
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20" value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>" />
3118
											/
3119
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
3120
												<?php for ($i = 31; $i > 0; $i--): ?>
3121
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected=\"selected\""; ?>>
3122
														<?=$i;?>
3123
													</option>
3124
												<?php endfor; ?>
3125
											</select>
3126
										</td>
3127
									</tr>
3128
									<tr>
3129
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
3130
										<td width="78%" class="vtable">
3131
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>" />
3132
										</td>
3133
									</tr>
3134
									<tr>
3135
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
3136
										<td width="78%" class="vtable">
3137
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked=\"checked\""; ?> />
3138
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
3139
											<?=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."); ?>
3140
										</td>
3141
									</tr>
3142
									<tr>
3143
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
3144
										<td width="78%" class="vtable">
3145
											<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."); ?>
3146
										</td>
3147
									</tr>
3148
									<tr>
3149
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
3150
										<?php if (isset($pconfig['pppid'])): ?>
3151
											<td width="78%" class="vtable">
3152
												<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
3153
												<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
3154
											</td>
3155
										<?php else: ?>
3156
											<td width="78%" class="vtable">
3157
												<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
3158
												<?=gettext("for advanced PPTP and L2TP configuration options");?>.
3159
											</td>
3160
										<?php endif; ?>
3161
									</tr>
3162
									<tr>
3163
										<td colspan="2" valign="top" height="16"></td>
3164
									</tr>
3165
								</table>
3166
							</td>
3167
						</tr>
3168
						<?php
3169
							/* Wireless interface? */
3170
							if (isset($wancfg['wireless'])):
3171
						?>
3172
						<tr>
3173
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
3174
						</tr>
3175
						<tr>
3176
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
3177
							<td class="vtable">
3178
								<input name="persistcommonwireless" type="checkbox" value="yes" class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked=\"checked\"";?> />
3179
								<br /><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
3180
							</td>
3181
						</tr>
3182
						<tr>
3183
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
3184
							<td class="vtable">
3185
							<select name="standard" class="formselect" id="standard">
3186
								<?php
3187
								$rowIndex = 0;
3188
								echo "<option ";
3189
								if ($pconfig['standard'] == "auto") {
3190
									echo "selected=\"selected\" ";
3191
								}
3192
								echo "value=\"auto\">auto</option>\n";
3193
								foreach ($wl_modes as $wl_standard => $wl_channels) {
3194
									$rowIndex++;
3195
									echo "<option ";
3196
									if ($pconfig['standard'] == "$wl_standard") {
3197
										echo "selected=\"selected\" ";
3198
									}
3199
									if ($pconfig['standard'] == "") {
3200
										if ($wl_standard == "11ng") {
3201
											echo "selected=\"selected\" ";
3202
										}
3203
									}
3204
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
3205
								}
3206
								if ($rowIndex == 0) {
3207
									echo "<option></option>";
3208
								}
3209
								?>
3210
							</select>
3211
							</td>
3212
						</tr>
3213
						<?php if (isset($wl_modes['11g'])): ?>
3214
						<tr>
3215
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
3216
							<td class="vtable">
3217
								<select name="protmode" class="formselect" id="protmode">
3218
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected=\"selected\"";?> value="off"><?=gettext("Protection mode off"); ?></option>
3219
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected=\"selected\"";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
3220
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected=\"selected\"";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
3221
								</select>
3222
								<br />
3223
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
3224
								<br />
3225
							</td>
3226
						</tr>
3227
						<?php else: ?>
3228
						<input name="protmode" type="hidden" id="protmode" value="off" />
3229
						<?php endif; ?>
3230
						<?php /* txpower is disabled because of issues with it.
3231
						<tr>
3232
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
3233
							<td class="vtable">
3234
								<select name="txpower" class="formselect" id="txpower">
3235
									<?
3236
									for ($x = 99; $x > 0; $x--) {
3237
										if ($pconfig["txpower"] == $x) {
3238
											$SELECTED = " selected=\"selected\"";
3239
										} else {
3240
											$SELECTED = "";
3241
										}
3242
										echo "<option {$SELECTED}>{$x}</option>\n";
3243
									}
3244
									?>
3245
								</select><br />
3246
								<?=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."); ?>
3247
							</td>
3248
						</tr>*/
3249
						?>
3250
						<tr>
3251
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
3252
							<td class="vtable">
3253
								<select name="channel" class="formselect" id="channel">
3254
									<option <?php if ($pconfig['channel'] == 0) echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
3255
									<?php
3256
									foreach ($wl_modes as $wl_standard => $wl_channels) {
3257
										if ($wl_standard == "11g") {
3258
											$wl_standard = "11b/g";
3259
										} else if ($wl_standard == "11ng") {
3260
											$wl_standard = "11b/g/n";
3261
										} else if ($wl_standard == "11na") {
3262
											$wl_standard = "11a/n";
3263
										}
3264
										foreach ($wl_channels as $wl_channel) {
3265
											echo "<option ";
3266
											if ($pconfig['channel'] == "$wl_channel") {
3267
												echo "selected=\"selected\" ";
3268
											}
3269
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
3270
											if (isset($wl_chaninfo[$wl_channel])) {
3271
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
3272
											}
3273
											echo "</option>\n";
3274
										}
3275
									}
3276
									?>
3277
								</select>
3278
								<br />
3279
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
3280
								<br />
3281
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
3282
							</td>
3283
						</tr>
3284
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
3285
						<tr>
3286
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
3287
							<td class="vtable">
3288
								<table border="0" cellpadding="0" cellspacing="0" summary="antenna settings">
3289
									<tr>
3290
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
3291
										<td>
3292
											<?=gettext("Diversity"); ?><br />
3293
											<select name="diversity" class="formselect" id="diversity">
3294
												<option <?php if (!isset($pconfig['diversity'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3295
												<option <?php if ($pconfig['diversity'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Off"); ?></option>
3296
												<option <?php if ($pconfig['diversity'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("On"); ?></option>
3297
											</select>
3298
										</td>
3299
										<td>&nbsp;&nbsp;</td>
3300
										<?php endif; ?>
3301
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
3302
										<td>
3303
											<?=gettext("Transmit antenna"); ?><br />
3304
											<select name="txantenna" class="formselect" id="txantenna">
3305
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3306
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
3307
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
3308
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
3309
											</select>
3310
										</td>
3311
										<td>&nbsp;&nbsp;</td>
3312
										<?php endif; ?>
3313
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
3314
										<td>
3315
											<?=gettext("Receive antenna"); ?><br />
3316
											<select name="rxantenna" class="formselect" id="rxantenna">
3317
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3318
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
3319
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
3320
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
3321
											</select>
3322
										</td>
3323
										<?php endif; ?>
3324
									</tr>
3325
								</table>
3326
								<br />
3327
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
3328
							</td>
3329
						</tr>
3330
						<?php endif; ?>
3331
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
3332
						<tr>
3333
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
3334
							<td class="vtable">
3335
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>" />
3336
								<br />
3337
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br />
3338
								<?=gettext("(measured in meters)"); ?>
3339
							</td>
3340
						</tr>
3341
						<?php endif; ?>
3342
						<tr>
3343
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
3344
							<td class="vtable">
3345
								<?=gettext("Regulatory domain"); ?><br />
3346
								<select name="regdomain" class="formselect" id="regdomain">
3347
									<option <?php if (empty($pconfig['regdomain'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3348
									<?php
3349
									foreach ($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
3350
										echo "<option ";
3351
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
3352
											echo "selected=\"selected\" ";
3353
										}
3354
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
3355
									}
3356
									?>
3357
								</select>
3358
								<br />
3359
								<?=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."); ?>
3360
								<br /><br />
3361
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br />
3362
								<select name="regcountry" class="formselect" id="regcountry">
3363
									<option <?php if (empty($pconfig['regcountry'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3364
									<?php
3365
									foreach ($wl_countries as $wl_country_key => $wl_country) {
3366
										echo "<option ";
3367
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
3368
											echo "selected=\"selected\" ";
3369
										}
3370
										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";
3371
									}
3372
									?>
3373
								</select>
3374
								<br />
3375
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
3376
								<br /><br />
3377
								<?=gettext("Location"); ?><br />
3378
								<select name="reglocation" class="formselect" id="reglocation">
3379
									<option <?php if (empty($pconfig['reglocation'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3380
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected=\"selected\""; ?> value="indoor"><?=gettext("Indoor"); ?></option>
3381
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected=\"selected\""; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
3382
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected=\"selected\""; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
3383
								</select>
3384
								<br /><br />
3385
								<?=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."); ?>
3386
								<br />
3387
								<?=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."); ?>
3388
							</td>
3389
						</tr>
3390
						<tr>
3391
							<td colspan="2" valign="top" height="16"></td>
3392
						</tr>
3393
						<tr>
3394
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
3395
						</tr>
3396
						<tr>
3397
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
3398
							<td class="vtable">
3399
								<select name="mode" class="formselect" id="mode">
3400
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected=\"selected\"";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
3401
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected=\"selected\"";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
3402
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected=\"selected\"";?> value="hostap"><?=gettext("Access Point"); ?></option>
3403
								</select>
3404
							</td>
3405
						</tr>
3406
						<tr>
3407
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
3408
							<td class="vtable">
3409
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>" />
3410
								<br />
3411
								<?=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"); ?>
3412
							</td>
3413
						</tr>
3414
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
3415
						<tr>
3416
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
3417
							<td class="vtable">
3418
								<select name="puremode" class="formselect" id="puremode">
3419
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected=\"selected\"";?> value="any"><?=gettext("Any"); ?></option>
3420
									<?php if (isset($wl_modes['11g'])): ?>
3421
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected=\"selected\"";?> value="11g"><?=gettext("802.11g"); ?></option>
3422
									<?php endif; ?>
3423
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected=\"selected\"";?> value="11n"><?=gettext("802.11n"); ?></option>
3424
								</select>
3425
								<br />
3426
								<?=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)."); ?>
3427
							</td>
3428
						</tr>
3429
						<?php elseif (isset($wl_modes['11g'])): ?>
3430
						<tr>
3431
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
3432
							<td class="vtable">
3433
								<input name="puremode" type="checkbox" value="11g" class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked=\"checked\"";?> />
3434
								<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)."); ?>
3435
							</td>
3436
						</tr>
3437
						<?php endif; ?>
3438
						<tr>
3439
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
3440
							<td class="vtable">
3441
								<input name="apbridge_enable" type="checkbox" value="yes" class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked=\"checked\"";?> />
3442
								<br />
3443
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
3444
								<br />
3445
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
3446
							</td>
3447
						</tr>
3448
						<tr>
3449
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
3450
							<td class="vtable">
3451
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked=\"checked\"";?> />
3452
								<br /><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
3453
							</td>
3454
						</tr>
3455
						<tr>
3456
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
3457
							<td class="vtable">
3458
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked=\"checked\"";?> />
3459
								<br />
3460
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
3461
								<br />
3462
								<?=gettext("(this might create problems for some clients)."); ?>
3463
							</td>
3464
						</tr>
3465
						<tr>
3466
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
3467
							<td class="vtable">
3468
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked=\"checked\""; ?> />
3469
								<strong><?=gettext("Enable WEP"); ?></strong>
3470
								<table border="0" cellspacing="0" cellpadding="0" summary="wep">
3471
									<tr>
3472
										<td>&nbsp;</td>
3473
										<td>&nbsp;</td>
3474
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
3475
									</tr>
3476
									<tr>
3477
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
3478
										<td>
3479
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>" />
3480
										</td>
3481
										<td align="center">
3482
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked=\"checked\"";?> />
3483
										</td>
3484
									</tr>
3485
									<tr>
3486
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
3487
										<td>
3488
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>" />
3489
										</td>
3490
										<td align="center">
3491
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked=\"checked\"";?> />
3492
										</td>
3493
									</tr>
3494
									<tr>
3495
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
3496
										<td>
3497
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>" />
3498
										</td>
3499
										<td align="center">
3500
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked=\"checked\"";?> />
3501
										</td>
3502
									</tr>
3503
									<tr>
3504
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
3505
										<td>
3506
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>" />
3507
										</td>
3508
										<td align="center">
3509
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked=\"checked\"";?> />
3510
										</td>
3511
									</tr>
3512
								</table>
3513
								<br />
3514
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br />
3515
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
3516
							</td>
3517
						</tr>
3518
						<tr>
3519
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
3520
							<td class="vtable">
3521
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked=\"checked\""; ?> />
3522
								<strong><?=gettext("Enable WPA"); ?></strong>
3523
								<br /><br />
3524
								<table border="0" cellspacing="0" cellpadding="0" summary="wpa">
3525
									<tr>
3526
										<td>&nbsp;</td>
3527
										<td>&nbsp;<?=gettext("WPA Pre-Shared Key"); ?>&nbsp;</td>
3528
									</tr>
3529
									<tr>
3530
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
3531
										<td>
3532
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>" />
3533
										</td>
3534
									</tr>
3535
								</table>
3536
								<br /><?=gettext("WPA Passphrase must be between 8 and 63 characters long."); ?>
3537
							</td>
3538
						</tr>
3539
						<tr>
3540
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
3541
							<td class="vtable">
3542
								<select name="wpa_mode" class="formselect" id="wpa_mode">
3543
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("WPA"); ?></option>
3544
									<option <?php if ($pconfig['wpa_mode'] == '2' || !isset($pconfig['wpa_mode'])) echo "selected=\"selected\"";?> value="2"><?=gettext("WPA2"); ?></option>
3545
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3546
								</select>
3547
							</td>
3548
						</tr>
3549
						<tr>
3550
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
3551
							<td class="vtable">
3552
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
3553
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected=\"selected\"";?> value="WPA-PSK"><?=gettext("Pre-Shared Key"); ?></option>
3554
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected=\"selected\"";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
3555
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected=\"selected\"";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
3556
								</select>
3557
							</td>
3558
						</tr>
3559
						<tr>
3560
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
3561
							<td class="vtable">
3562
								<select name="auth_algs" class="formselect" id="auth_algs">
3563
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("Open System Authentication"); ?></option>
3564
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
3565
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3566
								</select>
3567
								<br /><?=gettext("Note: Shared Key Authentication requires WEP."); ?><br />
3568
							</td>
3569
						</tr>
3570
						<tr>
3571
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
3572
							<td class="vtable">
3573
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
3574
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected=\"selected\"";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
3575
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP' || !isset($pconfig['wpa_pairwise'])) echo "selected=\"selected\"";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
3576
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected=\"selected\"";?> value="TKIP"><?=gettext("TKIP"); ?></option>
3577
								</select>
3578
							</td>
3579
						</tr>
3580
						<tr>
3581
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
3582
							<td class="vtable">
3583
								<input name="wpa_group_rekey" type="text" class="formfld unknown" id="wpa_group_rekey" size="30" value="<?php echo htmlspecialchars($pconfig['wpa_group_rekey']) ? $pconfig['wpa_group_rekey'] : "60";?>" />
3584
								<br /><?=gettext("Specified in seconds. Allowed values are 1-9999. Must be shorter than Master Key Regeneration time."); ?>
3585
							</td>
3586
						</tr>
3587
						<tr>
3588
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
3589
							<td class="vtable">
3590
								<input name="wpa_gmk_rekey" type="text" class="formfld" id="wpa_gmk_rekey" size="30" value="<?php echo htmlspecialchars($pconfig['wpa_gmk_rekey']) ? $pconfig['wpa_gmk_rekey'] : "3600";?>" />
3591
								<br /><?=gettext("Specified in seconds. Allowed values are 1-9999. Must be longer than Key Rotation time."); ?>
3592
							</td>
3593
						</tr>
3594
						<tr>
3595
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
3596
							<td class="vtable">
3597
								<input name="wpa_strict_rekey" type="checkbox" value="yes" class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked=\"checked\""; ?> />
3598
								<br /><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
3599
							</td>
3600
						</tr>
3601
						<tr>
3602
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
3603
							<td class="vtable">
3604
								<input name="ieee8021x" type="checkbox" value="yes" class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked=\"checked\"";?> />
3605
								<br /><?=gettext("Setting this option will enable 802.1X authentication."); ?>
3606
								<br /><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
3607
							</td>
3608
						</tr>
3609
						<tr>
3610
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
3611
							<td class="vtable">
3612
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>" />
3613
								<br /><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3614
							</td>
3615
						</tr>
3616
						<tr>
3617
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
3618
							<td class="vtable">
3619
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>" />
3620
								<br /><?=gettext("Leave blank for the default port 1812."); ?>
3621
							</td>
3622
						</tr>
3623
						<tr>
3624
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
3625
							<td class="vtable">
3626
								<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']);?>" />
3627
								<br />
3628
							</td>
3629
						</tr>
3630
						<tr>
3631
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
3632
							<td class="vtable">
3633
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>" />
3634
								<br /><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3635
							</td>
3636
						</tr>
3637
						<tr>
3638
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
3639
							<td class="vtable">
3640
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>" />
3641
								<br /><?=gettext("Leave blank for the default port 1812."); ?>
3642
							</td>
3643
						</tr>
3644
						<tr>
3645
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
3646
							<td class="vtable">
3647
								<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']);?>" />
3648
								<br />
3649
							</td>
3650
						</tr>
3651
						<tr>
3652
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
3653
							<td class="vtable">
3654
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <?php if ($pconfig['rsn_preauth']) echo "checked=\"checked\""; ?> />
3655
								<br />
3656
							</td>
3657
						</tr>
3658
						<tr>
3659
							<td colspan="2" valign="top" height="16"></td>
3660
						</tr>
3661
						<?php endif; ?>
3662
						<tr>
3663
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
3664
						</tr>
3665
						<tr>
3666
							<td valign="middle" class="vncell">&nbsp;</td>
3667
							<td class="vtable">
3668
								<a name="rfc1918"></a>
3669
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked=\"checked\""; ?> />
3670
								<strong><?=gettext("Block private networks"); ?></strong><br />
3671
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3672
								"for private networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
3673
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
3674
								"leave this option turned on, unless your WAN network lies in such " .
3675
								"a private address space, too."); ?>
3676
							</td>
3677
						</tr>
3678
						<tr>
3679
							<td valign="middle" class="vncell">&nbsp;</td>
3680
							<td class="vtable">
3681
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked=\"checked\""; ?> />
3682
								<strong><?=gettext("Block bogon networks"); ?></strong><br />
3683
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3684
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
3685
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
3686
								"and obviously should not appear as the source address in any packets you receive."); ?>
3687
								<br /><br />
3688
								<?=gettext("Note: The update frequency can be changed under System->Advanced Firewall/NAT settings.")?>
3689
							</td>
3690
						</tr>
3691
					</table> <!-- End "allcfg" table -->
3692
					</div> <!-- End "allcfg" div -->
3693

    
3694
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
3695
						<tr>
3696
							<td width="22%" valign="top">
3697
								&nbsp;
3698
							</td>
3699
							<td width="78%">
3700
								<br />
3701
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
3702
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
3703
								<input name="referer" type="hidden" value="<?=$referer;?>" />
3704
								<input name="if" type="hidden" id="if" value="<?=htmlspecialchars($if);?>" />
3705
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
3706
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>" />
3707
								<?php endif; ?>
3708
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>" />
3709
							</td>
3710
						</tr>
3711
					</table>
3712
					</div>
3713
				</td>
3714
			</tr>
3715
		</table>
3716
	</form>
3717
	<script type="text/javascript">
3718
	//<![CDATA[
3719
		var gatewayip;
3720
		var name;
3721
		var gatewayipv6;
3722
		var namev6;
3723
		function show_add_gateway() {
3724
			document.getElementById("addgateway").style.display = '';
3725
			document.getElementById("addgwbox").style.display = 'none';
3726
			document.getElementById("gateway").style.display = 'none';
3727
			document.getElementById("save").style.display = 'none';
3728
			document.getElementById("cancel").style.display = 'none';
3729
			document.getElementById("gwsave").style.display = '';
3730
			document.getElementById("gwcancel").style.display = '';
3731
			jQuery('#notebox').html("");
3732
		}
3733
		function show_add_gateway_v6() {
3734
			document.getElementById("addgatewayv6").style.display = '';
3735
			document.getElementById("addgwboxv6").style.display = 'none';
3736
			document.getElementById("gatewayv6").style.display = 'none';
3737
			document.getElementById("save").style.display = 'none';
3738
			document.getElementById("cancel").style.display = 'none';
3739
			document.getElementById("gwsave").style.display = '';
3740
			document.getElementById("gwcancel").style.display = '';
3741
			jQuery('#noteboxv6').html("");
3742
		}
3743
		function hide_add_gateway() {
3744
			document.getElementById("addgateway").style.display = 'none';
3745
			document.getElementById("addgwbox").style.display = '';
3746
			document.getElementById("gateway").style.display = '';
3747
			document.getElementById("save").style.display = '';
3748
			document.getElementById("cancel").style.display = '';
3749
			document.getElementById("gwsave").style.display = '';
3750
			document.getElementById("gwcancel").style.display = '';
3751
			jQuery('#status').html('');
3752
		}
3753
		function hide_add_gateway_v6() {
3754
			document.getElementById("addgatewayv6").style.display = 'none';
3755
			document.getElementById("addgwboxv6").style.display = '';
3756
			document.getElementById("gatewayv6").style.display = '';
3757
			document.getElementById("save").style.display = '';
3758
			document.getElementById("cancel").style.display = '';
3759
			document.getElementById("gwsave").style.display = '';
3760
			document.getElementById("gwcancel").style.display = '';
3761
			jQuery('#statusv6').html('');
3762
		}
3763
		function hide_add_gatewaysave() {
3764
			document.getElementById("addgateway").style.display = 'none';
3765
			jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3766
			var iface = jQuery('#if').val();
3767
			name = jQuery('#name').val();
3768
			var descr = jQuery('#gatewaydescr').val();
3769
			gatewayip = jQuery('#gatewayip').val();
3770

    
3771
			var defaultgw = '';
3772
			if (jQuery('#defaultgw').is(':checked')) {
3773
				defaultgw = '&defaultgw=on';
3774
			}
3775
			var url = "system_gateways_edit.php";
3776
			var pars = 'isAjax=true&ipprotocol=inet' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3777
			jQuery.ajax(
3778
				url,
3779
				{
3780
					type: 'post',
3781
					data: pars,
3782
					error: report_failure,
3783
					success: save_callback
3784
				});
3785
		}
3786
		function hide_add_gatewaysave_v6() {
3787
			document.getElementById("addgatewayv6").style.display = 'none';
3788
			jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3789
			var iface = jQuery('#if').val();
3790
			name = jQuery('#namev6').val();
3791
			var descr = jQuery('#gatewaydescrv6').val();
3792
			gatewayip = jQuery('#gatewayipv6').val();
3793
			var defaultgw = '';
3794
			if (jQuery('#defaultgwv6').is(':checked')) {
3795
				defaultgw = '&defaultgw=on';
3796
			}
3797
			var url_v6 = "system_gateways_edit.php";
3798
			var pars_v6 = 'isAjax=true&ipprotocol=inet6' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3799
			jQuery.ajax(
3800
				url_v6,
3801
				{
3802
					type: 'post',
3803
					data: pars_v6,
3804
					error: report_failure_v6,
3805
					success: save_callback_v6
3806
				});
3807
		}
3808
		function addOption(selectbox, text, value)
3809
		{
3810
			var optn = document.createElement("OPTION");
3811
			optn.text = text;
3812
			optn.value = value;
3813
			selectbox.append(optn);
3814
			selectbox.prop('selectedIndex', selectbox.children().length - 1);
3815
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3816
		}
3817
		function addOption_v6(selectbox, text, value)
3818
		{
3819
			var optn = document.createElement("OPTION");
3820
			optn.text = text;
3821
			optn.value = value;
3822
			selectbox.append(optn);
3823
			selectbox.prop('selectedIndex', selectbox.children().length - 1);
3824
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3825
		}
3826
		function report_failure(request, textStatus, errorThrown) {
3827
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3828
				alert(request.responseText);
3829
			} else {
3830
				alert("Sorry, we could not create your IPv4 gateway at this time.");
3831
			}
3832
			hide_add_gateway();
3833
		}
3834
		function report_failure_v6(request, textStatus, errorThrown) {
3835
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3836
				alert(request.responseText);
3837
			} else {
3838
				alert("Sorry, we could not create your IPv6 gateway at this time.");
3839
			}
3840
			hide_add_gateway_v6();
3841
		}
3842
		function save_callback(response) {
3843
			if (response) {
3844
				document.getElementById("addgateway").style.display = 'none';
3845
				hide_add_gateway();
3846
				var gwtext = escape(name) + " - " + gatewayip;
3847
				addOption(jQuery('#gateway'), gwtext, name);
3848
				// Auto submit form?
3849
				//document.iform.submit();
3850
				//jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader /">');
3851
			} else {
3852
				report_failure();
3853
			}
3854
		}
3855
		function show_advanced_media() {
3856
			document.getElementById("showadvmediabox").innerHTML='';
3857
			aodiv = document.getElementById('showmediaadv');
3858
			aodiv.style.display = "block";
3859
		}
3860
		function save_callback_v6(response_v6) {
3861
			if (response_v6) {
3862
				document.getElementById("addgatewayv6").style.display = 'none';
3863
				hide_add_gateway_v6();
3864
				var gwtext_v6 = escape(name) + " - " + gatewayip;
3865
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
3866
				// Auto submit form?
3867
				//document.iform.submit();
3868
				//jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" />');
3869
			} else {
3870
				report_failure_v6();
3871
			}
3872
		}
3873
		<?php
3874
		echo "show_allcfg(document.iform.enable);";
3875
		echo "updateType('{$pconfig['type']}');\n";
3876
		echo "updateTypeSix('{$pconfig['type6']}');\n";
3877
		?>
3878
	//]]>
3879
	</script>
3880
	<?php include("fend.inc"); ?>
3881
	</body>
3882
</html>
(95-95/252)