Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
180
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
181
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
182
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
183
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
184
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
185
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
186

    
187
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
188

    
189
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
190
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
191
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
192
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
193

    
194
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
195
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
196
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
197

    
198
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
199
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
200
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
201
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
202

    
203
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
204
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
205
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
206
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
207
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
208

    
209
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
210
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
211
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
212
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
213
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
214

    
215
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
216
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
217

    
218
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
219
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
220
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
221
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
222

    
223
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
224
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
225
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
226
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
227
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
228

    
229
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
230
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
231
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
232

    
233
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
234
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
235
$pconfig['enable'] = isset($wancfg['enable']);
236

    
237
if (is_array($config['aliases']['alias'])) {
238
	foreach($config['aliases']['alias'] as $alias) {
239
		if($alias['name'] == $wancfg['descr']) {
240
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']);
241
		}
242
	}
243
}
244

    
245
switch($wancfg['ipaddr']) {
246
	case "dhcp":
247
		$pconfig['type'] = "dhcp";
248
		break;
249
	case "pppoe":
250
	case "pptp":
251
	case "l2tp":
252
	case "ppp":
253
		$pconfig['type'] = $wancfg['ipaddr'];
254
		break;
255
	default:
256
		if(is_ipaddrv4($wancfg['ipaddr'])) {
257
			$pconfig['type'] = "staticv4";
258
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
259
			$pconfig['subnet'] = $wancfg['subnet'];
260
			$pconfig['gateway'] = $wancfg['gateway'];
261
		} else
262
			$pconfig['type'] = "none";
263
		break;
264
}
265

    
266
switch($wancfg['ipaddrv6']) {
267
	case "slaac":
268
		$pconfig['type6'] = "slaac";
269
		break;
270
	case "dhcp6":
271
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
272
		if(!isset($wancfg['dhcp6-ia-pd-len']))
273
			$wancfg['dhcp6-ia-pd-len'] = "none";
274
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
275
		$pconfig['type6'] = "dhcp6";
276
		break;
277
	case "6to4":
278
		$pconfig['type6'] = "6to4";
279
		break;
280
	case "track6":
281
		$pconfig['type6'] = "track6";
282
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
283
		if ($wancfg['track6-prefix-id'] == "")
284
			$pconfig['track6-prefix-id'] = 0;
285
		else
286
			$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
287
		$pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
288
		break;
289
	case "6rd":
290
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
291
		if($wancfg['prefix-6rd-v4plen'] == "")
292
			$wancfg['prefix-6rd-v4plen'] = "0";
293
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
294
		$pconfig['type6'] = "6rd";
295
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
296
		break;
297
	default:
298
		if(is_ipaddrv6($wancfg['ipaddrv6'])) {
299
			$pconfig['type6'] = "staticv6";
300
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
301
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
302
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
303
		} else
304
			$pconfig['type6'] = "none";
305
		break;
306
}
307

    
308
// print_r($pconfig);
309

    
310
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
311
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
312
$pconfig['spoofmac'] = $wancfg['spoofmac'];
313
$pconfig['mtu'] = $wancfg['mtu'];
314
$pconfig['mss'] = $wancfg['mss'];
315

    
316
/* Wireless interface? */
317
if (isset($wancfg['wireless'])) {
318
	/* Sync first to be sure it displays the actual settings that will be used */
319
	interface_sync_wireless_clones($wancfg, false);
320
	/* Get wireless modes */
321
	$wlanif = get_real_interface($if);
322
	if (!does_interface_exist($wlanif))
323
		interface_wireless_clone($wlanif, $wancfg);
324
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
325
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
326
	$wl_modes = get_wireless_modes($if);
327
	$wl_chaninfo = get_wireless_channel_info($if);
328
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
329
	$wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna",
330
				      "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout"));
331
	$wl_regdomain_xml_attr = array();
332
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
333
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
334
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
335
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
336
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
337
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
338
	$pconfig['standard'] = $wancfg['wireless']['standard'];
339
	$pconfig['mode'] = $wancfg['wireless']['mode'];
340
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
341
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
342
	$pconfig['channel'] = $wancfg['wireless']['channel'];
343
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
344
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
345
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
346
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
347
	$pconfig['distance'] = $wancfg['wireless']['distance'];
348
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
349
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
350
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
351
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
352
	if (isset($wancfg['wireless']['puren']['enable']))
353
		$pconfig['puremode'] = '11n';
354
	else if (isset($wancfg['wireless']['pureg']['enable']))
355
		$pconfig['puremode'] = '11g';
356
	else
357
		$pconfig['puremode'] = 'any';
358
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
359
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
360
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
361
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
362
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
363
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
364
	$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
365
	$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
366
	$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
367
	if (is_array($wancfg['wireless']['wpa'])) {
368
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
369
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
370
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
371
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
372
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
373
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
374
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
375
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
376
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
377
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
378
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
379
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
380
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
381
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
382
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
383
	}
384
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
385
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
386
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
387
		$i = 1;
388
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
389
			$pconfig['key' . $i] = $wepkey['value'];
390
			if (isset($wepkey['txkey']))
391
				$pconfig['txkey'] = $i;
392
			$i++;
393
		}
394
		if (!isset($wepkey['txkey']))
395
			$pconfig['txkey'] = 1;
396
	}
397
}
398

    
399
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
400
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
401

    
402
if ($_POST['apply']) {
403
	unset($input_errors);
404
	if (!is_subsystem_dirty('interfaces'))
405
		$intput_errors[] = gettext("You have already applied your settings!");
406
	else {
407
		unlink_if_exists("{$g['tmp_path']}/config.cache");
408
		clear_subsystem_dirty('interfaces');
409

    
410
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
411
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
412
			foreach ($toapplylist as $ifapply => $ifcfgo) {
413
				if (isset($config['interfaces'][$ifapply]['enable'])) {
414
					interface_bring_down($ifapply, false, $ifcfgo);
415
					interface_configure($ifapply, true);
416
				} else
417
					interface_bring_down($ifapply, true, $ifcfgo);
418
			}
419
		}
420
		/* restart snmp so that it binds to correct address */
421
		services_snmpd_configure();
422

    
423
		/* sync filter configuration */
424
		setup_gateways_monitor();
425

    
426
		clear_subsystem_dirty('interfaces');
427

    
428
		filter_configure();
429

    
430
		enable_rrd_graphing();
431

    
432
		if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0))
433
			clear_subsystem_dirty('staticroutes');
434
	}
435
	@unlink("{$g['tmp_path']}/.interfaces.apply");
436
	header("Location: interfaces.php?if={$if}");
437
	exit;
438
} else if ($_POST && $_POST['enable'] != "yes") {
439
	unset($wancfg['enable']);
440
	if (isset($wancfg['wireless']))
441
		interface_sync_wireless_clones($wancfg, false);
442
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
443
	mark_subsystem_dirty('interfaces');
444
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
445
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
446
	} else {
447
		$toapplylist = array();
448
	}
449
	$toapplylist[$if]['ifcfg'] = $wancfg;
450
	$toapplylist[$if]['ppps'] = $a_ppps;
451
	/* we need to be able remove IP aliases for IPv6 */
452
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
453
	header("Location: interfaces.php?if={$if}");
454
	exit;
455
} else if ($_POST) {
456

    
457
	unset($input_errors);
458
	$pconfig = $_POST;
459
	if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
460
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
461
	else
462
		$pconfig['track6-prefix-id'] = 0;
463
	conf_mount_rw();
464

    
465
	/* filter out spaces from descriptions  */
466
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
467

    
468
	/* okay first of all, cause we are just hiding the PPPoE HTML
469
	 * fields releated to PPPoE resets, we are going to unset $_POST
470
	 * vars, if the reset feature should not be used. Otherwise the
471
	 * data validation procedure below, may trigger a false error
472
	 * message.
473
	 */
474
	if (empty($_POST['pppoe-reset-type'])) {
475
		unset($_POST['pppoe_pr_type']);
476
		unset($_POST['pppoe_resethour']);
477
		unset($_POST['pppoe_resetminute']);
478
		unset($_POST['pppoe_resetdate']);
479
		unset($_POST['pppoe_pr_preset_val']);
480
	}
481
	/* description unique? */
482
	foreach ($ifdescrs as $ifent => $ifdescr) {
483
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
484
			$input_errors[] = gettext("An interface with the specified description already exists.");
485
			break;
486
		}
487
	}
488
	/* input validation */
489
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
490
		$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.");
491
	if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
492
		$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.");
493

    
494
	switch(strtolower($_POST['type'])) {
495
		case "staticv4":
496
			$reqdfields = explode(" ", "ipaddr subnet gateway");
497
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
498
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
499
			break;
500
		case "none":
501
			if(is_array($config['virtualip']['vip'])) {
502
				foreach ($config['virtualip']['vip'] as $vip) {
503
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if)
504
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
505
				}
506
			}
507
		case "dhcp":
508
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
509
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
510
			break;
511
		case "ppp":
512
			$reqdfields = explode(" ", "port phone");
513
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
514
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
515
			break;
516
		case "pppoe":
517
			if ($_POST['pppoe_dialondemand']) {
518
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
519
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
520
			} else {
521
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
522
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
523
			}
524
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
525
			break;
526
		case "pptp":
527
			if ($_POST['pptp_dialondemand']) {
528
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
529
				$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"));
530
			} else {
531
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
532
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
533
			}
534
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
535
			break;
536
		case "l2tp":
537
			if ($_POST['pptp_dialondemand']) {
538
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
539
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
540
			} else {
541
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
542
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
543
			}
544
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
545
			break;
546
	}
547
	switch(strtolower($_POST['type6'])) {
548
		case "staticv6":
549
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
550
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
551
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
552
			break;
553
		case "none":
554
			if(is_array($config['virtualip']['vip'])) {
555
				foreach ($config['virtualip']['vip'] as $vip) {
556
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if)
557
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
558
				}
559
			}
560
		case "dhcp6":
561
			if (in_array($wancfg['ipaddrv6'], array()))
562
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
563
			break;
564
		case "6rd":
565
			foreach ($ifdescrs as $ifent => $ifdescr) {
566
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
567
					if ($config[interfaces][$ifent]['prefix-6rd'] == $_POST['prefix-6rd']) {
568
						$input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix.");
569
						break;
570
					}
571
				}
572
			}
573
			if (in_array($wancfg['ipaddrv6'], array()))
574
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
575
			break;
576
		case "6to4":
577
			foreach ($ifdescrs as $ifent => $ifdescr) {
578
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
579
					$input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."),$_POST['type6']);
580
					break;
581
				}
582
			}
583
			if (in_array($wancfg['ipaddrv6'], array()))
584
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
585
			break;
586
		case "track6":
587
			/* needs to check if $track6-prefix-id is used on another interface */
588
			if (in_array($wancfg['ipaddrv6'], array()))
589
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
590

    
591
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
592
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
593
			} else {
594
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
595
				if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
596
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
597
				}
598
			}
599
			break;
600
	}
601

    
602

    
603
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
604
	$staticroutes = get_staticroutes(true);
605
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
606
	if ($_POST['ipaddr']) {
607
		if (!is_ipaddrv4($_POST['ipaddr']))
608
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
609
		else {
610
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
611
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
612

    
613
			foreach ($staticroutes as $route_subnet) {
614
				list($network, $subnet) = explode("/", $route_subnet);
615
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
616
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
617
					break;
618
				}
619
				unset($network, $subnet);
620
			}
621
		}
622
	}
623
	if ($_POST['ipaddrv6']) {
624
		if (!is_ipaddrv6($_POST['ipaddrv6']))
625
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
626
		else {
627
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
628
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
629

    
630
			foreach ($staticroutes as $route_subnet) {
631
				list($network, $subnet) = explode("/", $route_subnet);
632
				if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
633
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
634
					break;
635
				}
636
				unset($network, $subnet);
637
			}
638
		}
639
	}
640
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
641
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
642
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
643
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
644
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address'])))
645
		$input_errors[] = gettext("A valid alias IP address must be specified.");
646
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
647
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
648
	if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom']))
649
		$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
650
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
651
		$match = false;
652
		foreach($a_gateways as $gateway) {
653
			if(in_array($_POST['gateway'], $gateway)) {
654
				$match = true;
655
			}
656
		}
657
		foreach($a_gateways as $gateway) {
658
			if(in_array($_POST['gatewayv6'], $gateway)) {
659
				$match = true;
660
			}
661
		}
662
		if(!$match) {
663
			$input_errors[] = gettext("A valid gateway must be specified.");
664
		}
665
	}
666
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
667
		$input_errors[] = gettext("The service name contains invalid characters.");
668
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
669
		$input_errors[] = gettext("The idle timeout value must be an integer.");
670
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
671
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
672
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
673
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
674
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
675
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
676
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
677
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
678
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local'])))
679
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
680
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
681
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
682
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
683
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
684
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
685
		$input_errors[] = gettext("The idle timeout value must be an integer.");
686
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
687
		$input_errors[] = gettext("A valid MAC address must be specified.");
688
	if ($_POST['mtu']) {
689
		if ($_POST['mtu'] < 576 || $_POST['mtu'] > 9000)
690
			$input_errors[] = gettext("The MTU must be greater than 576 bytes.");
691

    
692
		if (stristr($wancfg['if'], "_vlan")) {
693
			$realhwif_array = get_parent_interface($wancfg['if']);
694
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
695
			$parent_realhwif = $realhwif_array[0];
696
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
697
			if (!empty($parent_if) && isset($config['interfaces'][$parent_if]['mtu'])) {
698
				$parent_mtu = $config['interfaces'][$parent_if]['mtu'];
699

    
700
				if ($_POST['mtu'] > $parent_mtu)
701
					$input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface.");
702
			}
703
		} else {
704
			foreach ($config['interfaces'] as $idx => $ifdata) {
705
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
706
					continue;
707

    
708
				$realhwif_array = get_parent_interface($ifdata['if']);
709
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
710
				$parent_realhwif = $realhwif_array[0];
711

    
712
				if ($parent_realhwif != $wancfg['if'])
713
					continue;
714

    
715
				if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu'])
716
					$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a bigger value"), $ifdata['descr']);
717
			}
718
		}
719
	}
720
	if ($_POST['mss'] && ($_POST['mss'] < 576))
721
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
722
	/* Wireless interface? */
723
	if (isset($wancfg['wireless'])) {
724
		$reqdfields = array("mode");
725
		$reqdfieldsn = array(gettext("Mode"));
726
		if ($_POST['mode'] == 'hostap') {
727
			$reqdfields[] = "ssid";
728
			$reqdfieldsn[] = gettext("SSID");
729
		}
730
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
731
		check_wireless_mode();
732
		/* loop through keys and enforce size */
733
		for ($i = 1; $i <= 4; $i++) {
734
			if ($_POST['key' . $i]) {
735
				/* 64 bit */
736
				if (strlen($_POST['key' . $i]) == 5)
737
					continue;
738
				if (strlen($_POST['key' . $i]) == 10) {
739
					/* hex key */
740
					if (stristr($_POST['key' . $i], "0x") == false) {
741
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
742
					}
743
					continue;
744
				}
745
				if (strlen($_POST['key' . $i]) == 12) {
746
					/* hex key */
747
					if(stristr($_POST['key' . $i], "0x") == false) {
748
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
749
					}
750
					continue;
751
				}
752
				/* 128 bit */
753
				if (strlen($_POST['key' . $i]) == 13)
754
					continue;
755
				if (strlen($_POST['key' . $i]) == 26) {
756
					/* hex key */
757
					if (stristr($_POST['key' . $i], "0x") == false)
758
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
759
					continue;
760
				}
761
				if(strlen($_POST['key' . $i]) == 28)
762
					continue;
763
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
764
				break;
765
			}
766
		}
767

    
768
		if ($_POST['passphrase']) {
769
			$passlen = strlen($_POST['passphrase']);
770
			if ($passlen < 8 || $passlen > 63)
771
				$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
772
		}
773
	}
774
	if (!$input_errors) {
775
		if ($wancfg['ipaddr'] != $_POST['type']) {
776
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
777
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
778
				unset($a_ppps[$pppid]);
779
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
780
				$pid = find_dhcp6c_process($wancfg['if']);
781
				if($pid)
782
					posix_kill($pid, SIGTERM);
783
			} else if ($wancfg['ipaddr'] == "dhcp") {
784
				$pid = find_dhclient_process($wancfg['if']);
785
				if($pid)
786
					posix_kill($pid, SIGTERM);
787
			}
788

    
789
		}
790
		$ppp = array();
791
		if ($wancfg['ipaddr'] != "ppp")
792
			unset($wancfg['ipaddr']);
793
		if ($wancfg['ipaddrv6'] != "ppp")
794
			unset($wancfg['ipaddrv6']);
795
		unset($wancfg['subnet']);
796
		unset($wancfg['gateway']);
797
		unset($wancfg['subnetv6']);
798
		unset($wancfg['gatewayv6']);
799
		unset($wancfg['dhcphostname']);
800
		unset($wancfg['dhcprejectfrom']);
801
		unset($wancfg['dhcp6-duid']);
802
		unset($wancfg['dhcp6-ia-pd-len']);
803
		unset($wancfg['track6-interface']);
804
		unset($wancfg['track6-prefix-id']);
805
		unset($wancfg['prefix-6rd']);
806
		unset($wancfg['prefix-6rd-v4plen']);
807
		unset($wancfg['gateway-6rd']);
808

    
809
		unset($wancfg['adv_dhcp_pt_timeout']);
810
		unset($wancfg['adv_dhcp_pt_retry']);
811
		unset($wancfg['adv_dhcp_pt_select_timeout']);
812
		unset($wancfg['adv_dhcp_pt_reboot']);
813
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
814
		unset($wancfg['adv_dhcp_pt_initial_interval']);
815

    
816
		unset($wancfg['adv_dhcp_pt_values']);
817

    
818
		unset($wancfg['adv_dhcp_send_options']);
819
		unset($wancfg['adv_dhcp_request_options']);
820
		unset($wancfg['adv_dhcp_required_options']);
821
		unset($wancfg['adv_dhcp_option_modifiers']);
822

    
823
		unset($wancfg['adv_dhcp_config_advanced']);
824
		unset($wancfg['adv_dhcp_config_file_override']);
825
		unset($wancfg['adv_dhcp_config_file_override_path']);
826

    
827
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
828
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
829
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
830
		unset($wancfg['adv_dhcp6_interface_statement_script']);
831

    
832
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
833
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
834
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
835
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
836
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
837

    
838
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
839
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
840
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
841
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
842
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
843

    
844
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
845
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
846

    
847
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
848
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
849
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
850
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
851

    
852
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
853
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
854
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
855
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
856
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
857

    
858
		unset($wancfg['adv_dhcp6_config_advanced']);
859
		unset($wancfg['adv_dhcp6_config_file_override']);
860
		unset($wancfg['adv_dhcp6_config_file_override_path']);
861

    
862
		unset($wancfg['pppoe_password']);
863
		unset($wancfg['pptp_username']);
864
		unset($wancfg['pptp_password']);
865
		unset($wancfg['provider']);
866
		unset($wancfg['ondemand']);
867
		unset($wancfg['timeout']);
868
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
869
			unset($wancfg['pppoe']['pppoe-reset-type']);
870
		unset($wancfg['local']);
871

    
872
		unset($wancfg['remote']);
873
		unset($a_ppps[$pppid]['apn']);
874
		unset($a_ppps[$pppid]['phone']);
875
		unset($a_ppps[$pppid]['localip']);
876
		unset($a_ppps[$pppid]['subnet']);
877
		unset($a_ppps[$pppid]['gateway']);
878
		unset($a_ppps[$pppid]['pppoe-reset-type']);
879
		unset($a_ppps[$pppid]['provider']);
880

    
881
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
882
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
883

    
884
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
885
		switch($_POST['type']) {
886
			case "staticv4":
887
				$wancfg['ipaddr'] = $_POST['ipaddr'];
888
				$wancfg['subnet'] = $_POST['subnet'];
889
				if ($_POST['gateway'] != "none") {
890
					$wancfg['gateway'] = $_POST['gateway'];
891
				}
892
				break;
893
			case "dhcp":
894
				$wancfg['ipaddr'] = "dhcp";
895
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
896
				$wancfg['alias-address'] = $_POST['alias-address'];
897
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
898
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
899

    
900
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
901
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
902
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
903
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
904
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
905
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
906

    
907
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
908

    
909
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
910
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
911
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
912
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
913

    
914
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
915
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
916
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
917

    
918
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
919
				if($gateway_item) {
920
					$a_gateways[] = $gateway_item;
921
				}
922
				break;
923
			case "ppp":
924
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
925
				$a_ppps[$pppid]['type'] = $_POST['type'];
926
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
927
				$a_ppps[$pppid]['ports'] = $_POST['port'];
928
				$a_ppps[$pppid]['username'] = $_POST['username'];
929
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
930
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
931
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
932
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
933
				$wancfg['ipaddr'] = $_POST['type'];
934
				unset($a_ppps[$pppid]['ondemand']);
935
				unset($a_ppps[$pppid]['idletimeout']);
936
				break;
937

    
938
			case "pppoe":
939
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
940
				$a_ppps[$pppid]['type'] = $_POST['type'];
941
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
942
				if (isset($_POST['ppp_port']))
943
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
944
				else
945
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
946
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
947
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
948
				if (!empty($_POST['provider']))
949
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
950
				else
951
					$a_ppps[$pppid]['provider'] = true;
952
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
953
				if (!empty($_POST['pppoe_idletimeout']))
954
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
955
				else
956
					unset($a_ppps[$pppid]['idletimeout']);
957

    
958
				if (!empty($_POST['pppoe-reset-type']))
959
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
960
				else
961
					unset($a_ppps[$pppid]['pppoe-reset-type']);
962
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
963
				$wancfg['ipaddr'] = $_POST['type'];
964
				if($gateway_item) {
965
					$a_gateways[] = $gateway_item;
966
				}
967

    
968
				break;
969
			case "pptp":
970
			case "l2tp":
971
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
972
				$a_ppps[$pppid]['type'] = $_POST['type'];
973
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
974
				if (isset($_POST['ppp_port']))
975
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
976
				else
977
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
978
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
979
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
980
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
981
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
982
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
983
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
984
				if (!empty($_POST['pptp_idletimeout']))
985
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
986
				else
987
					unset($a_ppps[$pppid]['idletimeout']);
988
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
989
				$wancfg['ipaddr'] = $_POST['type'];
990
				if($gateway_item) {
991
					$a_gateways[] = $gateway_item;
992
				}
993
				break;
994
			case "none":
995
				break;
996
		}
997
		switch($_POST['type6']) {
998
			case "staticv6":
999
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
1000
				$wancfg['subnetv6'] = $_POST['subnetv6'];
1001
				if ($_POST['gatewayv6'] != "none") {
1002
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
1003
				}
1004
				break;
1005
			case "slaac":
1006
				$wancfg['ipaddrv6'] = "slaac";
1007
				break;
1008
			case "dhcp6":
1009
				$wancfg['ipaddrv6'] = "dhcp6";
1010
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
1011
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
1012

    
1013
				$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1014
				$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1015
				$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1016
				$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1017

    
1018
				$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1019
				$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1020
				$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1021
				$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1022
				$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1023

    
1024
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1025
				$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1026
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1027
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1028
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1029

    
1030
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1031
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1032

    
1033
				$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1034
				$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1035
				$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1036
				$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1037

    
1038
				$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1039
				$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1040
				$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1041
				$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1042
				$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1043

    
1044
				$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1045
				$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1046
				$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1047

    
1048
				if($gateway_item) {
1049
					$a_gateways[] = $gateway_item;
1050
				}
1051
				break;
1052
			case "6rd":
1053
				$wancfg['ipaddrv6'] = "6rd";
1054
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1055
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1056
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1057
				if($gateway_item) {
1058
					$a_gateways[] = $gateway_item;
1059
				}
1060
				break;
1061
			case "6to4":
1062
				$wancfg['ipaddrv6'] = "6to4";
1063
				break;
1064
			case "track6":
1065
				$wancfg['ipaddrv6'] = "track6";
1066
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1067
				if ($_POST['track6-prefix-id--hex'] === "")
1068
					$wancfg['track6-prefix-id'] = 0;
1069
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
1070
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1071
				else
1072
					$wancfg['track6-prefix-id'] = 0;
1073
				break;
1074
			case "none":
1075
				break;
1076
		}
1077
		handle_pppoe_reset($_POST);
1078

    
1079
		if($_POST['blockpriv'] == "yes") {
1080
			$wancfg['blockpriv'] = true;
1081
		} else {
1082
			unset($wancfg['blockpriv']);
1083
		}
1084
		if($_POST['blockbogons'] == "yes") {
1085
			$wancfg['blockbogons'] = true;
1086
		} else {
1087
			unset($wancfg['blockbogons']);
1088
		}
1089
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1090
		if (empty($_POST['mtu'])) {
1091
			unset($wancfg['mtu']);
1092
		} else {
1093
			$wancfg['mtu'] = $_POST['mtu'];
1094
		}
1095
		if (empty($_POST['mss'])) {
1096
			unset($wancfg['mss']);
1097
		} else {
1098
			$wancfg['mss'] = $_POST['mss'];
1099
		}
1100
		if (empty($_POST['mediaopt'])) {
1101
			unset($wancfg['media']);
1102
			unset($wancfg['mediaopt']);
1103
		} else {
1104
			$mediaopts = explode(' ', $_POST['mediaopt']);
1105
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
1106
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
1107
			else { unset($wancfg['mediaopt']); }
1108
		}
1109
		if (isset($wancfg['wireless'])) {
1110
			handle_wireless_post();
1111
		}
1112

    
1113
		conf_mount_ro();
1114
		write_config();
1115

    
1116
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1117
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1118
		} else {
1119
			$toapplylist = array();
1120
		}
1121
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1122
		$toapplylist[$if]['ppps'] = $old_ppps;
1123
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1124

    
1125
		mark_subsystem_dirty('interfaces');
1126

    
1127
		/* regenerate cron settings/crontab file */
1128
		configure_cron();
1129

    
1130
		header("Location: interfaces.php?if={$if}");
1131
		exit;
1132
	}
1133

    
1134
} // end if($_POST)
1135

    
1136
function handle_wireless_post() {
1137
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1138
	if (!is_array($wancfg['wireless']))
1139
		$wancfg['wireless'] = array();
1140
	$wancfg['wireless']['standard'] = $_POST['standard'];
1141
	$wancfg['wireless']['mode'] = $_POST['mode'];
1142
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1143
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1144
	$wancfg['wireless']['channel'] = $_POST['channel'];
1145
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1146
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1147
	$wancfg['wireless']['distance'] = $_POST['distance'];
1148
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1149
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1150
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1151
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1152
		foreach($wl_countries_attr as $wl_country) {
1153
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1154
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1155
				break;
1156
			}
1157
		}
1158
	}
1159
	if (!is_array($wancfg['wireless']['wpa']))
1160
		$wancfg['wireless']['wpa'] = array();
1161
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1162
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1163
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1164
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1165
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1166
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1167
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1168
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1169
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1170
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1171
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1172
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1173
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1174
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1175
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1176

    
1177
	if ($_POST['persistcommonwireless'] == "yes") {
1178
		if (!is_array($config['wireless']))
1179
			$config['wireless'] = array();
1180
		if (!is_array($config['wireless']['interfaces']))
1181
			$config['wireless']['interfaces'] = array();
1182
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
1183
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1184
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
1185
		unset($config['wireless']['interfaces'][$wlanbaseif]);
1186
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
1187
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1188
	else if (isset($wancfg['wireless']['diversity']))
1189
		unset($wancfg['wireless']['diversity']);
1190
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
1191
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1192
	else if (isset($wancfg['wireless']['txantenna']))
1193
		unset($wancfg['wireless']['txantenna']);
1194
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
1195
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1196
	else if (isset($wancfg['wireless']['rxantenna']))
1197
		unset($wancfg['wireless']['rxantenna']);
1198
	if ($_POST['hidessid_enable'] == "yes")
1199
		$wancfg['wireless']['hidessid']['enable'] = true;
1200
	else if (isset($wancfg['wireless']['hidessid']['enable']))
1201
		unset($wancfg['wireless']['hidessid']['enable']);
1202
	if ($_POST['mac_acl_enable'] == "yes")
1203
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1204
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
1205
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1206
	if ($_POST['rsn_preauth'] == "yes")
1207
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1208
	else
1209
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1210
	if ($_POST['ieee8021x'] == "yes")
1211
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1212
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
1213
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1214
	if ($_POST['wpa_strict_rekey'] == "yes")
1215
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1216
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
1217
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1218
	if ($_POST['debug_mode'] == "yes")
1219
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1220
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
1221
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1222
	if ($_POST['wpa_enable'] == "yes")
1223
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1224
	else if (isset($wancfg['wireless']['wpa']['enable']))
1225
		unset($wancfg['wireless']['wpa']['enable']);
1226
	if ($_POST['wep_enable'] == "yes") {
1227
		if (!is_array($wancfg['wireless']['wep']))
1228
			$wancfg['wireless']['wep'] = array();
1229
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1230
	} else if (isset($wancfg['wireless']['wep']))
1231
		unset($wancfg['wireless']['wep']);
1232
	if ($_POST['wme_enable'] == "yes") {
1233
		if (!is_array($wancfg['wireless']['wme']))
1234
			$wancfg['wireless']['wme'] = array();
1235
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1236
	} else if (isset($wancfg['wireless']['wme']['enable']))
1237
		unset($wancfg['wireless']['wme']['enable']);
1238
	if ($_POST['puremode'] == "11g") {
1239
		if (!is_array($wancfg['wireless']['pureg']))
1240
			$wancfg['wireless']['pureg'] = array();
1241
		$wancfg['wireless']['pureg']['enable'] = true;
1242
	} else if ($_POST['puremode'] == "11n") {
1243
		if (!is_array($wancfg['wireless']['puren']))
1244
			$wancfg['wireless']['puren'] = array();
1245
		$wancfg['wireless']['puren']['enable'] = true;
1246
	} else {
1247
		if (isset($wancfg['wireless']['pureg']))
1248
			unset($wancfg['wireless']['pureg']);
1249
		if (isset($wancfg['wireless']['puren']))
1250
			unset($wancfg['wireless']['puren']);
1251
	}
1252
	if ($_POST['apbridge_enable'] == "yes") {
1253
		if (!is_array($wancfg['wireless']['apbridge']))
1254
			$wancfg['wireless']['apbridge'] = array();
1255
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1256
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1257
		unset($wancfg['wireless']['apbridge']['enable']);
1258
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1259
		if (!is_array($wancfg['wireless']['turbo']))
1260
			$wancfg['wireless']['turbo'] = array();
1261
		$wancfg['wireless']['turbo']['enable'] = true;
1262
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1263
		unset($wancfg['wireless']['turbo']['enable']);
1264
	$wancfg['wireless']['wep']['key'] = array();
1265
	for ($i = 1; $i <= 4; $i++) {
1266
		if ($_POST['key' . $i]) {
1267
			$newkey = array();
1268
			$newkey['value'] = $_POST['key' . $i];
1269
			if ($_POST['txkey'] == $i)
1270
				$newkey['txkey'] = true;
1271
			$wancfg['wireless']['wep']['key'][] = $newkey;
1272
		}
1273
	}
1274
	interface_sync_wireless_clones($wancfg, true);
1275
}
1276

    
1277
function check_wireless_mode() {
1278
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1279

    
1280
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1281
		return;
1282

    
1283
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1284
		$clone_count = 1;
1285
	else
1286
		$clone_count = 0;
1287
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1288
		foreach ($config['wireless']['clone'] as $clone) {
1289
			if ($clone['if'] == $wlanbaseif)
1290
				$clone_count++;
1291
		}
1292
	}
1293
	if ($clone_count > 1) {
1294
		$old_wireless_mode = $wancfg['wireless']['mode'];
1295
		$wancfg['wireless']['mode'] = $_POST['mode'];
1296
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1297
			$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']]);
1298
		} else {
1299
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1300
		}
1301
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1302
	}
1303
}
1304

    
1305
// Find all possible media options for the interface
1306
$mediaopts_list = array();
1307
$intrealname = $config['interfaces'][$if]['if'];
1308
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1309
foreach ($mediaopts as $mediaopt){
1310
	preg_match("/media (.*)/", $mediaopt, $matches);
1311
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1312
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1313
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1314
	}else{
1315
		// there is only media like "media 1000baseT"
1316
		array_push($mediaopts_list, $matches[1]);
1317
	}
1318
}
1319

    
1320
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1321
$shortcut_section = "interfaces";
1322

    
1323
$closehead = false;
1324
include("head.inc");
1325
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1326
$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"));
1327

    
1328
?>
1329

    
1330
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1331
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1332
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1333
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1334

    
1335
<script type="text/javascript">
1336
	function updateType(t) {
1337
		switch(t) {
1338
			case "none": {
1339
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1340
				break;
1341
			}
1342
			case "staticv4": {
1343
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1344
				break;
1345
			}
1346
			case "dhcp": {
1347
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1348
				break;
1349
			}
1350
			case "ppp": {
1351
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1352
				country_list();
1353
				break;
1354
			}
1355
			case "pppoe": {
1356
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1357
				break;
1358
			}
1359
			case "l2tp":
1360
			case "pptp": {
1361
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1362
				jQuery('#pptp').show();
1363
				break;
1364
			}
1365
		}
1366
		if (t != "l2tp" && t != "pptp")
1367
			jQuery('#'+t).show();
1368
	}
1369
	function updateTypeSix(t) {
1370
		switch(t) {
1371
			case "none": {
1372
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1373
				break;
1374
			}
1375
			case "staticv6": {
1376
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1377
				break;
1378
			}
1379
			case "slaac": {
1380
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1381
				break;
1382
			}
1383
			case "dhcp6": {
1384
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1385
				break;
1386
			}
1387
			case "6rd": {
1388
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1389
				break;
1390
			}
1391
			case "6to4": {
1392
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1393
				break;
1394
			}
1395
			case "track6": {
1396
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1397
				break;
1398
			}
1399
		}
1400
		if (t != "l2tp" && t != "pptp")
1401
			jQuery('#'+t).show();
1402
	}
1403

    
1404
	function show_allcfg(obj) {
1405
		if (obj.checked)
1406
			jQuery('#allcfg').show();
1407
		else
1408
			jQuery('#allcfg').hide();
1409
	}
1410

    
1411
	function show_reset_settings(reset_type) {
1412
		if (reset_type == 'preset') {
1413
			jQuery('#pppoepresetwrap').show();
1414
			jQuery('#pppoecustomwrap').hide();
1415
		}
1416
		else if (reset_type == 'custom') {
1417
			jQuery('#pppoecustomwrap').show();
1418
			jQuery('#pppoepresetwrap').hide();
1419
		} else {
1420
			jQuery('#pppoecustomwrap').hide();
1421
			jQuery('#pppoepresetwrap').hide();
1422
		}
1423
	}
1424
	function show_mon_config() {
1425
		jQuery("#showmonbox").html('');
1426
		jQuery('#showmon').css('display','block');
1427
	}
1428

    
1429
	function openwindow(url) {
1430
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1431
		if (oWin==null || typeof(oWin)=="undefined")
1432
			return false;
1433
		else
1434
			return true;
1435
	}
1436
	function country_list() {
1437
		jQuery('#country').children().remove();
1438
		jQuery('#provider').children().remove();
1439
		jQuery('#providerplan').children().remove();
1440
		jQuery.ajax("getserviceproviders.php",{
1441
			success: function(response) {
1442
				var responseTextArr = response.split("\n");
1443
				responseTextArr.sort();
1444
				responseTextArr.each( function(value) {
1445
					var option = new Element('option');
1446
					country = value.split(":");
1447
					option.text = country[0];
1448
					option.value = country[1];
1449
					jQuery('#country').append(option);
1450
				});
1451
			}
1452
		});
1453
		jQuery('#trcountry').css('display',"table-row");
1454
	}
1455

    
1456
	function providers_list() {
1457
		jQuery('#provider').children().remove();
1458
		jQuery('#providerplan').children().remove();
1459
		jQuery.ajax("getserviceproviders.php",{
1460
			type: 'post',
1461
			data: {country : jQuery('#country').val()},
1462
			success: function(response) {
1463
				var responseTextArr = response.split("\n");
1464
				responseTextArr.sort();
1465
				responseTextArr.each( function(value) {
1466
					var option = new Element('option');
1467
					option.text = value;
1468
					option.value = value;
1469
					jQuery('#provider').append(option);
1470
				});
1471
			}
1472
		});
1473
		jQuery('#trprovider').css("display","table-row");
1474
		jQuery('#trproviderplan').css("display","none");
1475
	}
1476

    
1477
	function providerplan_list() {
1478
		jQuery('#providerplan').children().remove();
1479
		jQuery('#providerplan').append( new Element('option') );
1480
		jQuery.ajax("getserviceproviders.php",{
1481
			type: 'post',
1482
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1483
			success: function(response) {
1484
				var responseTextArr = response.split("\n");
1485
				responseTextArr.sort();
1486
				responseTextArr.each( function(value) {
1487
					if(value != "") {
1488
						providerplan = value.split(":");
1489

    
1490
						var option = new Element('option');
1491
						option.text = providerplan[0] + " - " + providerplan[1];
1492
						option.value = providerplan[1];
1493
						jQuery('#providerplan').append(option);
1494
					}
1495
				});
1496
			}
1497
		});
1498
		jQuery('#trproviderplan').css("display","table-row");
1499
	}
1500

    
1501
	function prefill_provider() {
1502
		jQuery.ajax("getserviceproviders.php",{
1503
			type: 'post',
1504
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1505
			success: function(data,textStatus,response) {
1506
				var xmldoc = response.responseXML;
1507
				var provider = xmldoc.getElementsByTagName('connection')[0];
1508
				jQuery('#username').val('');
1509
				jQuery('#password').val('');
1510
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1511
					jQuery('#phone').val('#777');
1512
					jQuery('#apn').val('');
1513
				} else {
1514
					jQuery('#phone').val('*99#');
1515
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1516
				}
1517
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1518
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1519
				jQuery('#username').val(username);
1520
				jQuery('#password').val(password);
1521
			}
1522
		});
1523
	}
1524

    
1525
</script>
1526
</head>
1527
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1528
	<?php include("fbegin.inc"); ?>
1529
	<form action="interfaces.php" method="post" name="iform" id="iform">
1530
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1531
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1532
		<?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 />
1533
		<?php endif; ?>
1534
		<?php if ($savemsg) print_info_box($savemsg); ?>
1535
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces">
1536
			<tr>
1537
				<td id="mainarea">
1538
					<div class="tabcont">
1539
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
1540
						<tr>
1541
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1542
						</tr>
1543
						<tr>
1544
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1545
							<td width="78%" class="vtable">
1546
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked=\"checked\""; ?> onclick="show_allcfg(this);" />
1547
							<strong><?=gettext("Enable Interface"); ?></strong>
1548
							</td>
1549
						</tr>
1550
					</table>
1551
					<div style="display:none;" name="allcfg" id="allcfg">
1552
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="allcfg">
1553
						<tr>
1554
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1555
							<td width="78%" class="vtable">
1556
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>" />
1557
								<br/><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1558
							</td>
1559
						</tr>
1560
						<tr>
1561
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1562
							<td class="vtable">
1563
								<select name="type" onchange="updateType(this.value);" class="formselect" id="type">
1564
								<?php
1565
									foreach ($types4 as $key => $opt) {
1566
										echo "<option onclick=\"updateType('{$key}');\"";
1567
										if ($key == $pconfig['type'])
1568
											echo " selected=\"selected\"";
1569
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1570
										echo "</option>";
1571
									}
1572
								?>
1573
								</select>
1574
							</td>
1575
						</tr>
1576
						<tr>
1577
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1578
							<td class="vtable">
1579
								<select name="type6" onchange="updateTypeSix(this.value);" class="formselect" id="type6">
1580
								<?php
1581
									foreach ($types6 as $key => $opt) {
1582
										echo "<option onclick=\"updateTypeSix('{$key}');\"";
1583
										if ($key == $pconfig['type6'])
1584
											echo " selected=\"selected\"";
1585
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1586
										echo "</option>";
1587
									}
1588
								?>
1589
								</select>
1590
							</td>
1591
						</tr>
1592
						<tr>
1593
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1594
							<td class="vtable">
1595
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>" />
1596
								<?php
1597
									$ip = getenv('REMOTE_ADDR');
1598
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1599
									$mac = str_replace("\n","",$mac);
1600
									if($mac):
1601
								?>
1602
									<a onclick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1603
								<?php endif; ?>
1604
								<br/>
1605
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1606
								"address of this interface"); ?><br/>
1607
								<?=gettext("(may be required with some cable connections)"); ?><br/>
1608
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1609
								"or leave blank"); ?>
1610
							</td>
1611
						</tr>
1612
						<tr>
1613
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1614
							<td class="vtable">
1615
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>" />
1616
								<br/>
1617
								<?php
1618
									print gettext("If you leave this field blank, the adapter's default MTU will " .
1619
									"be used. This is typically 1500 bytes but can vary in some circumstances.");
1620
								?>
1621
							</td>
1622
						</tr>
1623
						<tr>
1624
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1625
							<td class="vtable">
1626
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>" />
1627
								<br/>
1628
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1629
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1630
								"header size) will be in effect."); ?>
1631
							</td>
1632
						</tr>
1633
						<?php
1634
						if (count($mediaopts_list) > 0){
1635
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1636
						echo "<tr>";
1637
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1638
							echo '<td class="vtable">';
1639
							echo '<div id="showadvmediabox"';
1640
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1641
								else echo '>';
1642
								echo '<input type="button" onclick="show_advanced_media()" value="' . gettext("Advanced") . '" /> - ' . gettext("Show advanced option");
1643
							echo "</div>";
1644
							echo '<div id="showmediaadv" ';
1645
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1646
							else echo '>';
1647
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1648
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1649
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1650
								foreach($mediaopts_list as $mediaopt){
1651
									if ($mediaopt != rtrim($mediaopt_from_config)){
1652
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1653
									} else {
1654
										print "<option value=\"$mediaopt\" selected=\"selected\">" . gettext("$mediaopt") . "</option>";
1655
									}
1656
								}
1657
								echo '</select><br/>';
1658
								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.");
1659
						echo '</div>';
1660
							echo '</td>';
1661
						echo '</tr>';
1662
						}
1663
						?>
1664
						<tr>
1665
							<td colspan="2" valign="top" height="16"></td>
1666
						</tr>
1667
						<tr style="display:none;" name="none" id="none"><td style="display:none;"></td></tr>
1668
						<tr style="display:none;" name="staticv4" id="staticv4">
1669
							<td colspan="2" style="padding:0px;">
1670
								<a name="gatewaysection"></a>
1671
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv4">
1672
									<tr>
1673
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1674
									</tr>
1675
									<tr>
1676
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1677
										<td width="78%" class="vtable">
1678
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" />
1679
											/
1680
											<select name="subnet" class="formselect" id="subnet">
1681
												<?php
1682
												for ($i = 32; $i > 0; $i--) {
1683
													if($i <> 31) {
1684
														echo "<option value=\"{$i}\" ";
1685
														if ($i == $pconfig['subnet']) echo "selected=\"selected\"";
1686
														echo ">" . $i . "</option>";
1687
													}
1688
												}
1689
												?>
1690
											</select>
1691
										</td>
1692
									</tr>
1693
									<tr>
1694
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1695
										<td width="78%" class="vtable">
1696
											<select name="gateway" class="formselect" id="gateway">
1697
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1698
													<?php
1699
													if(count($a_gateways) > 0) {
1700
														foreach ($a_gateways as $gateway) {
1701
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1702
													?>
1703
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected=\"selected\""; ?>>
1704
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1705
															</option>
1706
													<?php
1707
															}
1708
														}
1709
													}
1710
													?>
1711
											</select>
1712
											- or  <strong><a onclick="show_add_gateway();" href="#gatewaysection"><?=gettext("add a new one."); ?></a></strong>
1713
											<br/>
1714
											<div id='addgwbox'>
1715
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1716
											</div>
1717
											<div id='notebox'>
1718
											</div>
1719
											<div id="status">
1720
											</div>
1721
											<div style="display:none" id="addgateway" name="addgateway">
1722
												<p>&nbsp;</p>
1723
												<table border="1" class="addgatewaybox" summary="addgateway">
1724
													<tr>
1725
														<td>
1726
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgateway">
1727
																<tr><td>&nbsp;</td></tr>
1728
																<tr>
1729
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1730
																</tr>
1731
																<tr><td>&nbsp;</td></tr>
1732
																<?php
1733
																if($if == "wan" || $if == "WAN")
1734
																	$checked = " checked=\"checked\"";
1735
																?>
1736
																<tr>
1737
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></font></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?> /></td>
1738
																</tr>
1739
																<tr>
1740
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></font></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>" /></td>
1741
																</tr>
1742
																<tr>
1743
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></font></td><td><input id="gatewayip" name="gatewayip" /></td>
1744
																</tr>
1745
																<tr>
1746
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescr" name="gatewaydescr" /></td>
1747
																</tr>
1748
																<tr><td>&nbsp;</td></tr>
1749
																<tr>
1750
																	<td colspan="2">
1751
																		<center>
1752
																			<div id='savebuttondiv'>
1753
																				<input id="gwsave" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave();' />
1754
																				<input id="gwcancel" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway();' />
1755
																			</div>
1756
																		</center>
1757
																	</td>
1758
																</tr>
1759
																<tr><td>&nbsp;</td></tr>
1760
															</table>
1761
														</td>
1762
													</tr>
1763
												</table>
1764
											</div>
1765
										</td>
1766
									</tr>
1767
									<tr>
1768
										<td colspan="2" valign="top" height="16"></td>
1769
									</tr>
1770
								</table>
1771
							</td>
1772
						</tr>
1773
						<tr style="display:none;" name="staticv6" id="staticv6">
1774
							<td colspan="2" style="padding:0px;">
1775
								<a name="gatewayv6section"></a>
1776
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv6">
1777
									<tr>
1778
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1779
									</tr>
1780
									<tr>
1781
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1782
										<td width="78%" class="vtable">
1783
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>" />
1784
											/
1785
											<select name="subnetv6" class="formselect" id="subnetv6">
1786
												<?php
1787
												for ($i = 128; $i > 0; $i--) {
1788
													if($i <> 127) {
1789
														echo "<option value=\"{$i}\" ";
1790
														if ($i == $pconfig['subnetv6']) echo "selected=\"selected\"";
1791
														echo ">" . $i . "</option>";
1792
													}
1793
												}
1794
												?>
1795
											</select>
1796
										</td>
1797
									</tr>
1798
									<tr>
1799
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1800
										<td width="78%" class="vtable">
1801
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1802
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1803
													<?php
1804
													if(count($a_gateways) > 0) {
1805
														foreach ($a_gateways as $gateway) {
1806
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1807
													?>
1808
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected=\"selected\""; ?>>
1809
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1810
															</option>
1811
													<?php
1812
															}
1813
														}
1814
													}
1815
													?>
1816
											</select>
1817
											- or <strong><a onclick="show_add_gateway_v6();" href="#gatewayv6section"><?=gettext("add a new one."); ?></a></strong>
1818
											<br/>
1819
											<div id='addgwboxv6'>
1820
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1821
											</div>
1822
											<div id='noteboxv6'>
1823
											</div>
1824
											<div id="statusv6">
1825
											</div>
1826
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1827
												<p>&nbsp;</p>
1828
												<table border="1" class="addgatewaybox" summary="addgatewayv6">
1829
													<tr>
1830
														<td>
1831
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgatewayv6">
1832
																<tr><td>&nbsp;</td></tr>
1833
																<tr>
1834
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1835
																</tr>
1836
																<tr><td>&nbsp;</td></tr>
1837
																<?php
1838
																if($if == "wan" || $if == "WAN")
1839
																	$checked = " checked=\"checked\"";
1840
																?>
1841
																<tr>
1842
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></font></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?> /></td>
1843
																</tr>
1844
																<tr>
1845
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></font></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>" /></td>
1846
																</tr>
1847
																<tr>
1848
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></font></td><td><input id="gatewayipv6" name="gatewayipv6" /></td>
1849
																</tr>
1850
																<tr>
1851
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescrv6" name="gatewaydescrv6" /></td>
1852
																</tr>
1853
																<tr><td>&nbsp;</td></tr>
1854
																<tr>
1855
																	<td colspan="2">
1856
																		<center>
1857
																			<div id='savebuttondivv6'>
1858
																				<input id="gwsavev6" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave_v6();' />
1859
																				<input id="gwcancelv6" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway_v6();' />
1860
																			</div>
1861
																		</center>
1862
																	</td>
1863
																</tr>
1864
																<tr><td>&nbsp;</td></tr>
1865
															</table>
1866
														</td>
1867
													</tr>
1868
												</table>
1869
											</div>
1870
										</td>
1871
									</tr>
1872
									<tr>
1873
										<td colspan="2" valign="top" height="16"></td>
1874
									</tr>
1875
								</table>
1876
							</td>
1877
						</tr>
1878
						<tr style="display:none;" name="dhcp" id="dhcp">
1879
							<td colspan="2" style="padding: 0px;">
1880
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp">
1881
									<tr>
1882
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration &nbsp &nbsp " .
1883
										' <input name="adv_dhcp_config_advanced" type="checkbox" id="adv_dhcp_config_advanced" value="" onClick="show_adv_dhcp_config(this)";> ' .
1884
										" Advanced &nbsp &nbsp " .
1885
										' <input name="adv_dhcp_config_file_override" type="checkbox" id="adv_dhcp_config_file_override" value="" onClick="show_adv_dhcp_config(this)";> ' .
1886
										" Config File Override &nbsp &nbsp "); ?>
1887
										</td>
1888
									</tr>
1889
									<!-- Uncomment to expose DHCP+ in GUI
1890
									<tr>
1891
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1892
										<td width="78%" class="vtable">
1893
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked=\"checked\""; ?> />
1894
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1895
										<br/>
1896
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1897
										</td>
1898
									</tr>
1899
									-->
1900
									<tr style='display:none' name="show_basic_dhcphostname" id="show_basic_dhcphostname">
1901
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1902
										<td width="78%" class="vtable">
1903
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>" />
1904
											<br/>
1905
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1906
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1907
											"this (for client identification)."); ?>
1908
										</td>
1909
									</tr>
1910
									<tr style='display:none' name="show_basic_dhcpalias-address" id="show_basic_dhcpalias-address">
1911
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1912
										<td width="78%" class="vtable">
1913
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>" />
1914
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1915
												<?php
1916
												for ($i = 32; $i > 0; $i--) {
1917
													if($i <> 31) {
1918
														echo "<option value=\"{$i}\" ";
1919
														if ($i == $pconfig['alias-subnet']) echo "selected=\"selected\"";
1920
														echo ">" . $i . "</option>";
1921
													}
1922
												}
1923
												?>
1924
											</select>
1925
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1926
											"DHCP client."); ?>
1927
										</td>
1928
									</tr>
1929
									<tr>
1930
										<td width="22%" valign="top" class="vncell"><?=gettext("Reject Leases From"); ?></td>
1931
										<td width="78%" class="vtable">
1932
											<input name="dhcprejectfrom" type="text" class="formfld unknown" id="dhcprejectfrom" size="20" value="<?=htmlspecialchars($pconfig['dhcprejectfrom']);?>" />
1933
											<br/>
1934
											<?=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."); ?>
1935
											<?=gettext("this is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync."); ?>
1936
										</td>
1937
									</tr>
1938
									<tr>
1939
										<td colspan="2" valign="top" height="16"></td>
1940

    
1941
									<tr style='display:none' name="show_adv_dhcp_protocol_timing" id="show_adv_dhcp_protocol_timing">
1942
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#PROTOCOL_TIMING>Protocol Timing</a>"); ?></td>
1943
										<td width="48%" class="vtable">
1944
											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, '');">
1945
											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, '');">
1946
											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, '');">
1947

    
1948
											&nbsp &nbsp &nbsp &nbsp 
1949
											Presets: &nbsp
1950
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	unchecked	enabled id="customdhcpptdhcpdefaults"	onClick="customdhcpptsetvalues(this, iform);">FreeBSD Default &nbsp 
1951
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	unchecked	enabled id="customdhcpptclear"		onClick="customdhcpptsetvalues(this, iform);">Clear
1952

    
1953
											<br>
1954
											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, '');">
1955
											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, '');">
1956
											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, '');">
1957

    
1958
											&nbsp &nbsp &nbsp &nbsp &nbsp 
1959
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	unchecked	enabled id="customdhcpptpfsensedefaults"	onClick="customdhcpptsetvalues(this, iform);">pfSense Default &nbsp 
1960
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked	enabled id="customdhcpptsavedcfg"		onClick="customdhcpptsetvalues(this, iform);">Saved Cfg 
1961

    
1962
											<br>
1963
											<?=gettext("The values in these fields are DHCP protocol timings used when requesting a lease. <br> " ); ?>
1964

    
1965
											<script type="text/javascript">
1966
												function customdhcpptcheckradiobuton(T, BUTTON) {
1967
													for (var i = 0; i < T.length; i++) {
1968
														T[i].checked = false;
1969
														if (T[i].value == BUTTON) T[i].checked = true;
1970
													}
1971
													T.value = BUTTON;
1972
												}
1973

    
1974
												function customdhcpptsetvalues(T, FORM) {
1975
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
1976
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
1977
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
1978
													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']);?>");
1979
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
1980
												}
1981

    
1982
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
1983
													FORM.adv_dhcp_pt_timeout.value = timeout;
1984
													FORM.adv_dhcp_pt_retry.value = retry;
1985
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
1986
													FORM.adv_dhcp_pt_reboot.value = reboot;
1987
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
1988
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
1989

    
1990
													FORM.adv_dhcp_pt_values.value = T.value;
1991
												}
1992

    
1993
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
1994
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
1995
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
1996
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
1997
											</script>
1998
										</td>
1999
									</tr>
2000

    
2001
									<tr style='display:none' name="show_adv_dhcp_lease_requirements_and_requests" id="show_adv_dhcp_lease_requirements_and_requests">
2002
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS>Lease Requirements and Requests</a>"); ?></td>
2003
										<td width="78%" class="vtable">
2004
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS>Send</a> <a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&sektion=5>Options</a>"); ?><br>
2005
											<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']);?>">
2006
											<br>
2007
											<?=gettext("The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br>" .
2008
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2009
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2010
											"Some ISPs may require certain options be or not be sent. "); ?>
2011
											<hr>
2012
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS>Request</a> <a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&sektion=5>Options</a>"); ?><br>
2013
											<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']);?>">
2014
											<br>
2015
											<?=gettext("The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] <br>" .
2016
											"Some ISPs may require certain options be or not be requested. "); ?>
2017
											<hr>
2018
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS>Require</a> <a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&sektion=5>Options</a>"); ?><br>
2019
											<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']);?>">
2020
											<br>
2021
											<?=gettext("The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]] "); ?>
2022
										</td>
2023
									</tr>
2024

    
2025
									<tr style='display:none' name="show_adv_dhcp_option_modifiers" id="show_adv_dhcp_option_modifiers">
2026
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&sektion=5>Option</a> <a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#OPTION_MODIFIERS>Modifiers</a>"); ?></td>
2027
										<td width="78%" class="vtable">
2028
											<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']);?>">
2029
											<br>
2030
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br> " .
2031
											"modifiers: (default, supersede, prepend, append)"); ?>
2032
										</td>
2033
									</tr>
2034

    
2035
									<tr style='display:none' name="show_adv_dhcp_config_file_override" id="show_adv_dhcp_config_file_override">
2036
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5>Configuration File</a> Override"); ?></td>
2037
										<td width="78%" class="vtable">
2038
 											<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']);?>">
2039
											<br>
2040
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br> " .
2041
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2042
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2043
											"Some ISPs may require certain options be or not be sent. "); ?>
2044
										</td>
2045
									</tr>
2046

    
2047
 									<tr>
2048
 										<td colspan="2" valign="top" height="16"></td>
2049
 									</tr>
2050

    
2051
									<script type="text/javascript">
2052
										function show_adv_dhcp_config(T) {
2053

    
2054
											if (T.checked) T.value = "Selected";
2055
											else T.value = "";
2056

    
2057
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2058
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2059
											else 									show_hide_adv_dhcp('', 'none', 'none');
2060
										}
2061

    
2062
										function show_hide_adv_dhcp(basic, advanced, override) {
2063

    
2064
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2065
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2066

    
2067
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2068
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2069
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2070

    
2071
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2072
										}
2073

    
2074
										<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2075
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") document.iform.adv_dhcp_config_advanced.checked = true;
2076
										show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2077

    
2078
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2079
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2080
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2081
									</script>
2082

    
2083
								</table>
2084
							</td>
2085
						</tr>
2086
						<tr style="display:none;" name="dhcp6" id="dhcp6">
2087
							<td colspan="2" style="padding: 0px;">
2088
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp6">
2089
									<tr>
2090
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration &nbsp &nbsp " .
2091
										' <input name="adv_dhcp6_config_advanced" type="checkbox" id="adv_dhcp6_config_advanced" value="" onClick="show_adv_dhcp6_config(this)";> ' .
2092
										" Advanced &nbsp &nbsp " .
2093
										' <input name="adv_dhcp6_config_file_override" type="checkbox" id="adv_dhcp6_config_file_override" value="" onClick="show_adv_dhcp6_config(this)";> ' .
2094
										" Config File Override &nbsp &nbsp "); ?>
2095
										</td>
2096
									</tr>
2097
									<!--- Leave commented out for now
2098
									<tr style='display:none' name="basicdhcp6_show_dhcp6_duid" id="basicdhcp6_show_dhcp6_duid">
2099
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
2100
										<td width="78%" class="vtable">
2101
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>" />
2102
											<br/>
2103
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
2104
											"when requesting a DHCPv6 lease."); ?><br />
2105
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
2106
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
2107
												}
2108
												printf(gettext("The current DUID is: '%s'"),$current_duid);
2109
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
2110
											?>
2111
										</td>
2112
									</tr>
2113
									-->
2114
									<tr style='display:none' name="basicdhcp6_show_dhcp6_prefix_delegation_size" id="basicdhcp6_show_dhcp6_prefix_delegation_size">
2115
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
2116
										<td width="78%" class="vtable">
2117
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
2118
												<?php
2119
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
2120
												foreach($sizes as $bits => $length) {
2121
													echo "<option value=\"{$bits}\" ";
2122
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected=\"selected\"";
2123
													echo ">" . $length . "</option>";
2124
												}
2125
												?>
2126
											</select>
2127
											<br/>
2128
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
2129
										</td>
2130
									</tr>
2131

    
2132
									<tr style='display:none' name="show_adv_dhcp6_interface_statement" id="show_adv_dhcp6_interface_statement">
2133
										<td width="22%" valign="top" class="vncell">
2134
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports#Interface_statement>Interface Statement</a>"); ?>
2135
											<br><br>
2136
											<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)";>
2137
											<?=gettext("Information Only"); ?>
2138
										</td>
2139
										<td width="78%" class="vtable">
2140
											<?=gettext("Send Options"); ?><br>
2141
											<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']);?>">
2142
											<br>
2143
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br>" .
2144
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2145
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2146
											"Some DHCP services may require certain options be or not be sent. "); ?>
2147
											<br>
2148
											<br>
2149
											<?=gettext("Request Options"); ?><br>
2150
											<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']);?>">
2151
											<br>
2152
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br>" .
2153
											"Some DHCP services may require certain options be or not be requested. "); ?>
2154
											<br>
2155
											<br>
2156
											<?=gettext("Script"); ?><br>
2157
											<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']);?>">
2158
											<br>
2159
											<?=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>" .
2160
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2161
										</td>
2162
									</tr>
2163

    
2164
									<tr style='display:none' name="show_adv_dhcp6_id_assoc_statement" id="show_adv_dhcp6_id_assoc_statement">
2165
										<td width="22%" valign="top" class="vncell">
2166
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports#Identity_association_statement>Identity Association Statement</a>"); ?>
2167
										</td>
2168
										<td width="78%" class="vtable">
2169

    
2170
											<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)";>
2171
											<?=gettext("Non-Temporary Address Allocation"); ?>
2172
											<div style='display:none'  name="show_adv_dhcp6_id_assoc_statement_address" id="show_adv_dhcp6_id_assoc_statement_address">
2173
											<?=gettext("id-assoc na"); ?>
2174
											<?=gettext("<i>ID</i>"); ?>
2175
											<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']);?>">
2176
											<br>
2177
											<?=gettext("Address"); ?>
2178
											<?=gettext("<i>ipv6-address</i>"); ?>
2179
											<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']);?>">
2180
											<?=gettext("<i>pltime</i>"); ?>
2181
											<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']);?>">
2182
											<?=gettext("<i>vltime</i>"); ?>
2183
											<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']);?>">
2184
											</div>
2185
											<hr>
2186

    
2187
											<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)";>
2188
											<?=gettext("Prefix Delegation"); ?>
2189
											<div style='display:none'  name="show_adv_dhcp6_id_assoc_statement_prefix" id="show_adv_dhcp6_id_assoc_statement_prefix">
2190
											<?=gettext("id-assoc pd"); ?>
2191
											<?=gettext("<i>ID</i>"); ?>
2192
											<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']);?>">
2193
											<br>
2194
											<?=gettext("Prefix"); ?>
2195
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2196
											<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']);?>">
2197
											<?=gettext("<i>pltime</i>"); ?>
2198
											<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']);?>">
2199
											<?=gettext("<i>vltime</i>"); ?>
2200
											<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']);?>">
2201
											</div>
2202
										</td>
2203
									</tr>
2204

    
2205
									<tr style='display:none' name="show_adv_dhcp6_prefix_interface_statement" id="show_adv_dhcp6_prefix_interface_statement">
2206
										<td width="22%" valign="top" class="vncell">
2207
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports#Prefix_interface_statement>Prefix Interface Statement</a>"); ?>
2208
										</td>
2209
										<td width="78%" class="vtable">
2210
											<?=gettext("Prefix Interface "); ?>
2211
											<?=gettext("<i>sla-id</i>"); ?>
2212
											<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']);?>">
2213
											<?=gettext("<i>sla-len</i>"); ?>
2214
											<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']);?>">
2215
										</td>
2216
									</tr>
2217

    
2218
									<tr style='display:none' name="show_adv_dhcp6_authentication_statement" id="show_adv_dhcp6_authentication_statement">
2219
										<td width="22%" valign="top" class="vncell">
2220
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports#Authentication_statement>Authentication Statement</a>"); ?>
2221
										</td>
2222
										<td width="78%" class="vtable">
2223
											<?=gettext("<i>authname</i>"); ?>
2224
											<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']);?>">
2225
											<?=gettext("<i>protocol</i>"); ?>
2226
											<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']);?>">
2227
											<?=gettext("<i>algorithm</i>"); ?>
2228
											<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']);?>">
2229
											<?=gettext("<i>rdm</i>"); ?>
2230
											<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']);?>">
2231
										</td>
2232
									</tr>
2233

    
2234
									<tr style='display:none' name="show_adv_dhcp6_key_info_statement" id="show_adv_dhcp6_key_info_statement">
2235
										<td width="22%" valign="top" class="vncell">
2236
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports#Keyinfo_statement>Keyinfo Statement</a>"); ?>
2237
										</td>
2238
										<td width="78%" class="vtable">
2239
											<?=gettext("<i>keyname</i>"); ?>
2240
											<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']);?>">
2241
											<?=gettext("<i>realm</i>"); ?>
2242
											<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']);?>">
2243
											<br>
2244
											<?=gettext("<i>keyid</i>"); ?>
2245
											<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']);?>">
2246
											<?=gettext("<i>secret</i>"); ?>
2247
											<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']);?>">
2248
											<?=gettext("<i>expire</i>"); ?>
2249
											<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']);?>">
2250
										</td>
2251
									</tr>
2252

    
2253
									<tr style='display:none' name="show_adv_dhcp6_config_file_override" id="show_adv_dhcp6_config_file_override">
2254
										<td width="22%" valign="top" class="vncell">
2255
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports>Configuration File</a> Override"); ?>
2256
										</td>
2257
										<td width="78%" class="vtable">
2258
 											<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']);?>">
2259
											<br>
2260
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br> " .
2261
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2262
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2263
											"Some ISPs may require certain options be or not be sent. "); ?>
2264
										</td>
2265
									</tr>
2266

    
2267
 									<tr>
2268
 										<td colspan="2" valign="top" height="16"></td>
2269
 									</tr>
2270

    
2271
									<script type="text/javascript">
2272
										function show_adv_dhcp6_config(T) {
2273

    
2274
											if (T.checked) T.value = "Selected";
2275
											else T.value = "";
2276

    
2277
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2278
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2279
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2280
										}
2281

    
2282
										function show_hide_adv_dhcp6(basic, advanced, override) {
2283

    
2284
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2285

    
2286
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2287
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2288

    
2289
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2290
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2291
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2292
											}
2293

    
2294
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2295
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2296
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2297
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2298
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2299
											}
2300

    
2301
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2302
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2303

    
2304
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2305
										}
2306

    
2307
										<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2308
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") document.iform.adv_dhcp6_config_advanced.checked = true;
2309
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2310

    
2311
										<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
2312
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override']);?>" == "Selected") document.iform.adv_dhcp6_config_file_override.checked = true;
2313
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
2314

    
2315
										<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
2316
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable']);?>" == "Selected") document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
2317
										show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
2318

    
2319
										<!-- Set the adv_dhcp6_id_assoc_statement_address_enable checkbox from saved config -->
2320
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked = true;
2321
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_address_enable);
2322

    
2323
										<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
2324
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
2325
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
2326
									</script>
2327

    
2328
								</table>
2329
							</td>
2330
						</tr>
2331
						<tr style="display:none;" name="6rd" id="6rd">
2332
							<td colspan="2" style="padding: 0px;">
2333
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="6rd">
2334
									<tr>
2335
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
2336
									</tr>
2337
									<tr>
2338
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
2339
										<td width="78%" class="vtable">
2340
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>" />
2341
											<br/>
2342
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
2343
										</td>
2344
									</tr>
2345
									<tr>
2346
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
2347
										<td width="78%" class="vtable">
2348
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>" />
2349
											<br/>
2350
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
2351
										</td>
2352
									</tr>
2353
									<tr>
2354
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
2355
										<td width="78%" class="vtable">
2356
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
2357
												<?php
2358
												for ($i = 0; $i < 32; $i++) {
2359
													echo "<option value=\"{$i}\" ";
2360
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected=\"selected\"";
2361
													echo ">" . $i . " bits</option>";
2362
												}
2363
												?>
2364
											</select>
2365
											<br/>
2366
											<?=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."); ?>
2367
										</td>
2368
									</tr>
2369
									<tr>
2370
										<td colspan="2" valign="top" height="16"></td>
2371
									</tr>
2372
								</table>
2373
							</td>
2374
						</tr>
2375
						<tr style="display:none;" name="track6" id="track6">
2376
							<td colspan="2" style="padding: 0px;">
2377
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="track6">
2378
									<tr>
2379
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
2380
									</tr>
2381
									<tr>
2382
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
2383
										<td width="78%" class="vtable">
2384
										<select name='track6-interface' class='formselect' >
2385
										<?php
2386
											$interfaces = get_configured_interface_with_descr(false, true);
2387
											$dynv6ifs = array();
2388
											foreach ($interfaces as $iface => $ifacename) {
2389
												switch($config['interfaces'][$iface]['ipaddrv6']) {
2390
													case "6to4":
2391
													case "6rd":
2392
													case "dhcp6":
2393
														$dynv6ifs[$iface] = $ifacename;
2394
														break;
2395
													default:
2396
														continue;
2397
												}
2398
											}
2399
											foreach($dynv6ifs as $iface => $ifacename) {
2400
												echo "<option value=\"{$iface}\"";
2401
												if ($iface == $pconfig['track6-interface'])
2402
													echo " selected=\"selected\"";
2403
												echo ">" . htmlspecialchars($ifacename) . "</option>";
2404
											}
2405
										?>
2406
										</select> <br/>
2407
											<br/>
2408
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
2409
										</td>
2410
									</tr>
2411
									<tr>
2412
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
2413
										<td width="78%" class="vtable">
2414
											<?php
2415
												if ($pconfig['track6-prefix-id'] == "")
2416
													$pconfig['track6-prefix-id'] = 0;
2417
												$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
2418
											?>
2419
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
2420
											<br />
2421
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
2422
											<br />
2423
											<?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, default value is 0."), 0, $ipv6_num_prefix_ids - 1); ?>
2424
										</td>
2425
									</tr>
2426
									<tr>
2427
										<td colspan="2" valign="top" height="16"></td>
2428
									</tr>
2429
								</table>
2430
							</td>
2431
						</tr>
2432
						<tr style="display:none;" name="ppp" id="ppp">
2433
							<td colspan="2" style="padding: 0px;">
2434
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="ppp">
2435
									<tr>
2436
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
2437
									</tr>
2438
									<tr name="ppp_provider" id="ppp_provider">
2439
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
2440
										<td width="78%" class="vtable">
2441
											<table border="0" cellpadding="0" cellspacing="0" summary="service provider">
2442
												<tr id="trcountry">
2443
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
2444
													<td>
2445
														<select class="formselect" name="country" id="country" onchange="providers_list()">
2446
															<option></option>
2447
														</select>
2448
													</td>
2449
												</tr>
2450
												<tr id="trprovider" style="display:none">
2451
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
2452
													<td>
2453
														<select class="formselect" name="provider" id="provider" onchange="providerplan_list()">
2454
															<option></option>
2455
														</select>
2456
													</td>
2457
												</tr>
2458
												<tr id="trproviderplan" style="display:none">
2459
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
2460
													<td>
2461
														<select class="formselect" name="providerplan" id="providerplan" onchange="prefill_provider()">
2462
															<option></option>
2463
														</select>
2464
													</td>
2465
												</tr>
2466
											</table>
2467
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
2468
										</td>
2469
									</tr>
2470
									<tr>
2471
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
2472
										<td width="78%" class="vtable">
2473
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>" />
2474
										</td>
2475
									</tr>
2476
									<tr>
2477
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
2478
										<td width="78%" class="vtable">
2479
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>" />
2480
										</td>
2481
									</tr>
2482
									<tr name="phone_num" id="phone_num">
2483
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
2484
										<td width="78%" class="vtable">
2485
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>" />
2486
										</td>
2487
									</tr>
2488
									<tr name="apn_" id="apn_">
2489
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
2490
										<td width="78%" class="vtable">
2491
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>" />
2492
										</td>
2493
									</tr>
2494
									<tr name="interface" id="interface" >
2495
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
2496
										<td width="78%" class="vtable">
2497
											<select name="port" id="port" class="formselect">
2498
											<?php
2499
												$portlist = glob("/dev/cua*");
2500
												$modems = glob("/dev/modem*");
2501
												$portlist = array_merge($portlist, $modems);
2502
												foreach ($portlist as $port) {
2503
													if(preg_match("/\.(lock|init)$/", $port))
2504
														continue;
2505
													echo "<option value=\"".trim($port)."\"";
2506
													if ($pconfig['port'] == $port)
2507
														echo " selected=\"selected\"";
2508
													echo ">{$port}</option>";
2509
												}?>
2510
											</select>
2511
										</td>
2512
									</tr>
2513
									<tr>
2514
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
2515
										<?php if (isset($pconfig['pppid'])): ?>
2516
											<td width="78%" class="vtable">
2517
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2518
											<?=gettext("to edit PPP configuration."); ?>
2519
											</td>
2520
										<?php else: ?>
2521
											<td width="78%" class="vtable">
2522
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2523
											<?=gettext("to create a PPP configuration."); ?>
2524
											</td>
2525
										<?php endif; ?>
2526
									</tr>
2527
									<tr>
2528
										<td colspan="2" valign="top" height="16"></td>
2529
									</tr>
2530
								</table>
2531
							</td>
2532
						</tr>
2533
						<tr style="display:none;" name="pppoe" id="pppoe">
2534
							<td colspan="2" style="padding:0px;">
2535
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pppoe">
2536
									<tr>
2537
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
2538
									</tr>
2539
									<tr>
2540
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2541
										<td width="78%" class="vtable">
2542
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>" />
2543
										</td>
2544
									</tr>
2545
									<tr>
2546
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2547
										<td width="78%" class="vtable">
2548
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>" />
2549
										</td>
2550
									</tr>
2551
									<tr>
2552
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
2553
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>" />
2554
											<br/> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
2555
										</td>
2556
									</tr>
2557
									<tr>
2558
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2559
										<td width="78%" class="vtable">
2560
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked=\"checked\""; ?> />
2561
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br/>
2562
											<?=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."); ?>
2563
										</td>
2564
									</tr>
2565
									<tr>
2566
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2567
										<td width="78%" class="vtable">
2568
											<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."); ?>
2569
										</td>
2570
									</tr>
2571
									<tr>
2572
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
2573
										<td width="78%" class="vtable">
2574
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" summary="periodic reset">
2575
												<tr>
2576
													<td align="left" valign="top">
2577
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
2578
														<select style="vertical-align:top" id="reset_type" name="pppoe-reset-type" class="formselect" onchange="show_reset_settings(this.value);">
2579
															<option value=""><?=gettext("Disabled"); ?></option>
2580
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected=\"selected\""; ?>><?=gettext("Custom"); ?></option>
2581
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected=\"selected\""; ?>><?=gettext("Pre-Set"); ?></option>
2582
														</select> <?=gettext("Select a reset timing type"); ?>
2583
														</p>
2584
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2585
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2586
														<?php else: ?>
2587
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2588
														<?php endif; ?>
2589
														<input type="text" name="pppoe_resethour" class="fd_incremental_inp_range_0_23 fd_increment_1 fd_classname_dec_buttonDec fd_classname_inc_buttonInc" maxlength="2" id="pppoe_resethour" value="<?= $pconfig['pppoe_resethour']; ?>" size="3" />
2590
														<?=gettext("hour (0-23)"); ?><br />
2591
														<input type="text" name="pppoe_resetminute" class="fd_incremental_inp_range_0_59 fd_increment_1 fd_classname_dec_buttonDec fd_classname_inc_buttonInc" maxlength="2" id="pppoe_resetminute" value="<?= $pconfig['pppoe_resetminute']; ?>" size="3" />
2592
														<?=gettext("minute (0-59)"); ?><br />
2593
														<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']);?>" />
2594
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2595
														<br />&nbsp;<br />
2596
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2597
														<?=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."); ?>
2598
														</p>
2599
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2600
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2601
														<?php else: ?>
2602
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2603
														<?php endif; ?>
2604
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2605
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2606
														<br />
2607
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2608
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2609
														<br />
2610
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2611
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2612
														<br />
2613
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2614
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2615
														</p>
2616
													</td>
2617
												</tr>
2618
											</table>
2619
										</td>
2620
									</tr>
2621

    
2622
									<tr>
2623
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2624
										<?php if (isset($pconfig['pppid'])): ?>
2625
											<td width="78%" class="vtable">
2626
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2627
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2628
											</td>
2629
										<?php else: ?>
2630
											<td width="78%" class="vtable">
2631
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2632
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2633
											</td>
2634
										<?php endif; ?>
2635
									</tr>
2636
									<tr>
2637
										<td colspan="2" valign="top" height="16"></td>
2638
									</tr>
2639
								</table>
2640
							</td>
2641
						</tr>
2642
						<tr style="display:none;" name="pptp" id="pptp">
2643
							<td colspan="2" style="padding:0px;">
2644
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pptp">
2645
									<tr>
2646
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2647
									</tr>
2648
									<tr>
2649
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2650
										<td width="78%" class="vtable">
2651
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>" />
2652
										</td>
2653
									</tr>
2654
									<tr>
2655
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2656
										<td width="78%" class="vtable">
2657
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>" />
2658
										</td>
2659
									</tr>
2660
									<tr>
2661
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2662
										<td width="78%" class="vtable">
2663
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>" />
2664
											/
2665
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2666
												<?php for ($i = 31; $i > 0; $i--): ?>
2667
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected=\"selected\""; ?>>
2668
														<?=$i;?></option>
2669
												<?php endfor; ?>
2670
											</select>
2671
										</td>
2672
									</tr>
2673
									<tr>
2674
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2675
										<td width="78%" class="vtable">
2676
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>" />
2677
										</td>
2678
									</tr>
2679
									<tr>
2680
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2681
										<td width="78%" class="vtable">
2682
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked=\"checked\""; ?> />
2683
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br/>
2684
											<?=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."); ?>
2685
										</td>
2686
									</tr>
2687
									<tr>
2688
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2689
										<td width="78%" class="vtable">
2690
											<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."); ?>
2691
										</td>
2692
									</tr>
2693
									<tr>
2694
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2695
										<?php if (isset($pconfig['pppid'])): ?>
2696
											<td width="78%" class="vtable">
2697
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2698
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2699
											</td>
2700
										<?php else: ?>
2701
											<td width="78%" class="vtable">
2702
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2703
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2704
											</td>
2705
										<?php endif; ?>
2706
									</tr>
2707
									<tr>
2708
										<td colspan="2" valign="top" height="16"></td>
2709
									</tr>
2710
								</table>
2711
							</td>
2712
						</tr>
2713
						<?php
2714
							/* Wireless interface? */
2715
							if (isset($wancfg['wireless'])):
2716
						?>
2717
						<tr>
2718
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2719
						</tr>
2720
						<tr>
2721
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2722
							<td class="vtable">
2723
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked=\"checked\"";?> />
2724
								<br/><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2725
							</td>
2726
						</tr>
2727
						<tr>
2728
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2729
							<td class="vtable">
2730
							<select name="standard" class="formselect" id="standard">
2731
								<?php
2732
								foreach($wl_modes as $wl_standard => $wl_channels) {
2733
									echo "<option ";
2734
									if ($pconfig['standard'] == "$wl_standard")
2735
										echo "selected=\"selected\" ";
2736
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2737
								}
2738
								?>
2739
							</select>
2740
							</td>
2741
						</tr>
2742
						<?php if (isset($wl_modes['11g'])): ?>
2743
						<tr>
2744
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2745
							<td class="vtable">
2746
								<select name="protmode" class="formselect" id="protmode">
2747
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected=\"selected\"";?> value="off"><?=gettext("Protection mode off"); ?></option>
2748
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected=\"selected\"";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2749
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected=\"selected\"";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2750
								</select>
2751
								<br/>
2752
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2753
								<br/>
2754
							</td>
2755
						</tr>
2756
						<?php else: ?>
2757
						<input name="protmode" type="hidden" id="protmode" value="off" />
2758
						<?php endif; ?>
2759
						<tr>
2760
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2761
							<td class="vtable">
2762
								<select name="txpower" class="formselect" id="txpower">
2763
									<?
2764
									for($x = 99; $x > 0; $x--) {
2765
										if($pconfig["txpower"] == $x)
2766
											$SELECTED = " selected=\"selected\"";
2767
										else
2768
											$SELECTED = "";
2769
										echo "<option {$SELECTED}>{$x}</option>\n";
2770
									}
2771
									?>
2772
								</select><br/>
2773
								<?=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."); ?>
2774
							</td>
2775
						</tr>
2776
						<tr>
2777
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
2778
							<td class="vtable">
2779
								<select name="channel" class="formselect" id="channel">
2780
									<option <?php if ($pconfig['channel'] == 0) echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2781
									<?php
2782
									foreach($wl_modes as $wl_standard => $wl_channels) {
2783
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
2784
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
2785
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
2786
										foreach($wl_channels as $wl_channel) {
2787
											echo "<option ";
2788
											if ($pconfig['channel'] == "$wl_channel") {
2789
												echo "selected=\"selected\" ";
2790
											}
2791
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
2792
											if(isset($wl_chaninfo[$wl_channel]))
2793
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
2794
											echo "</option>\n";
2795
										}
2796
									}
2797
									?>
2798
								</select>
2799
								<br/>
2800
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
2801
								<br/>
2802
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
2803
							</td>
2804
						</tr>
2805
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2806
						<tr>
2807
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
2808
							<td class="vtable">
2809
								<table border="0" cellpadding="0" cellspacing="0" summary="antenna settings">
2810
									<tr>
2811
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
2812
										<td>
2813
											<?=gettext("Diversity"); ?><br/>
2814
											<select name="diversity" class="formselect" id="diversity">
2815
												<option <?php if (!isset($pconfig['diversity'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2816
												<option <?php if ($pconfig['diversity'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Off"); ?></option>
2817
												<option <?php if ($pconfig['diversity'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("On"); ?></option>
2818
											</select>
2819
										</td>
2820
										<td>&nbsp;&nbsp</td>
2821
										<?php endif; ?>
2822
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
2823
										<td>
2824
											<?=gettext("Transmit antenna"); ?><br/>
2825
											<select name="txantenna" class="formselect" id="txantenna">
2826
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2827
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2828
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
2829
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
2830
											</select>
2831
										</td>
2832
										<td>&nbsp;&nbsp</td>
2833
										<?php endif; ?>
2834
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2835
										<td>
2836
											<?=gettext("Receive antenna"); ?><br/>
2837
											<select name="rxantenna" class="formselect" id="rxantenna">
2838
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2839
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2840
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
2841
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
2842
											</select>
2843
										</td>
2844
										<?php endif; ?>
2845
									</tr>
2846
								</table>
2847
								<br/>
2848
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
2849
							</td>
2850
						</tr>
2851
						<?php endif; ?>
2852
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
2853
						<tr>
2854
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
2855
							<td class="vtable">
2856
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>" />
2857
								<br/>
2858
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br/>
2859
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
2860
							</td>
2861
						</tr>
2862
						<?php endif; ?>
2863
						<tr>
2864
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
2865
							<td class="vtable">
2866
								<?=gettext("Regulatory domain"); ?><br/>
2867
								<select name="regdomain" class="formselect" id="regdomain">
2868
									<option <?php if (empty($pconfig['regdomain'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2869
									<?php
2870
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
2871
										echo "<option ";
2872
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
2873
											echo "selected=\"selected\" ";
2874
										}
2875
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
2876
									}
2877
									?>
2878
								</select>
2879
								<br/>
2880
								<?=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."); ?>
2881
								<br/><br/>
2882
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br/>
2883
								<select name="regcountry" class="formselect" id="regcountry">
2884
									<option <?php if (empty($pconfig['regcountry'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2885
									<?php
2886
									foreach($wl_countries as $wl_country_key => $wl_country) {
2887
										echo "<option ";
2888
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
2889
											echo "selected=\"selected\" ";
2890
										}
2891
										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";
2892
									}
2893
									?>
2894
								</select>
2895
								<br/>
2896
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
2897
								<br/><br/>
2898
								<?=gettext("Location"); ?><br/>
2899
								<select name="reglocation" class="formselect" id="reglocation">
2900
									<option <?php if (empty($pconfig['reglocation'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2901
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected=\"selected\""; ?> value="indoor"><?=gettext("Indoor"); ?></option>
2902
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected=\"selected\""; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
2903
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected=\"selected\""; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
2904
								</select>
2905
								<br/><br/>
2906
								<?=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."); ?>
2907
								<br/>
2908
								<?=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."); ?>
2909
							</td>
2910
						</tr>
2911
						<tr>
2912
							<td colspan="2" valign="top" height="16"></td>
2913
						</tr>
2914
						<tr>
2915
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
2916
						</tr>
2917
						<tr>
2918
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
2919
							<td class="vtable">
2920
								<select name="mode" class="formselect" id="mode">
2921
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected=\"selected\"";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
2922
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected=\"selected\"";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
2923
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected=\"selected\"";?> value="hostap"><?=gettext("Access Point"); ?></option>
2924
								</select>
2925
							</td>
2926
						</tr>
2927
						<tr>
2928
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
2929
							<td class="vtable">
2930
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>" />
2931
								<br/>
2932
								<?=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"); ?>
2933
							</td>
2934
						</tr>
2935
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
2936
						<tr>
2937
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
2938
							<td class="vtable">
2939
								<select name="puremode" class="formselect" id="puremode">
2940
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected=\"selected\"";?> value="any"><?=gettext("Any"); ?></option>
2941
									<?php if (isset($wl_modes['11g'])): ?>
2942
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected=\"selected\"";?> value="11g"><?=gettext("802.11g"); ?></option>
2943
									<?php endif; ?>
2944
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected=\"selected\"";?> value="11n"><?=gettext("802.11n"); ?></option>
2945
								</select>
2946
								<br/>
2947
								<?=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)."); ?>
2948
							</td>
2949
						</tr>
2950
						<?php elseif (isset($wl_modes['11g'])): ?>
2951
						<tr>
2952
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
2953
							<td class="vtable">
2954
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked=\"checked\"";?> />
2955
								<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)."); ?>
2956
							</td>
2957
						</tr>
2958
						<?php endif; ?>
2959
						<tr>
2960
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
2961
							<td class="vtable">
2962
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked=\"checked\"";?> />
2963
								<br/>
2964
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
2965
								<br/>
2966
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
2967
							</td>
2968
						</tr>
2969
						<tr>
2970
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
2971
							<td class="vtable">
2972
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked=\"checked\"";?> />
2973
								<br/><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
2974
							</td>
2975
						</tr>
2976
						<tr>
2977
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
2978
							<td class="vtable">
2979
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked=\"checked\"";?> />
2980
								<br/>
2981
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
2982
								<br/>
2983
								<?=gettext("(this might create problems for some clients)."); ?>
2984
							</td>
2985
						</tr>
2986
						<tr>
2987
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
2988
							<td class="vtable">
2989
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked=\"checked\""; ?> />
2990
								<strong><?=gettext("Enable WEP"); ?></strong>
2991
								<table border="0" cellspacing="0" cellpadding="0" summary="wep">
2992
									<tr>
2993
										<td>&nbsp;</td>
2994
										<td>&nbsp;</td>
2995
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
2996
									</tr>
2997
									<tr>
2998
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
2999
										<td>
3000
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>" />
3001
										</td>
3002
										<td align="center">
3003
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked=\"checked\"";?>>
3004
										</td>
3005
									</tr>
3006
									<tr>
3007
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
3008
										<td>
3009
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>" />
3010
										</td>
3011
										<td align="center">
3012
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked=\"checked\"";?> />
3013
										</td>
3014
									</tr>
3015
									<tr>
3016
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
3017
										<td>
3018
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>" />
3019
										</td>
3020
										<td align="center">
3021
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked=\"checked\"";?> />
3022
										</td>
3023
									</tr>
3024
									<tr>
3025
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
3026
										<td>
3027
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>" />
3028
										</td>
3029
										<td align="center">
3030
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked=\"checked\"";?> />
3031
										</td>
3032
									</tr>
3033
								</table>
3034
								<br/>
3035
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br/>
3036
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
3037
							</td>
3038
						</tr>
3039
						<tr>
3040
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
3041
							<td class="vtable">
3042
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked=\"checked\""; ?> />
3043
								<strong><?=gettext("Enable WPA"); ?></strong>
3044
								<br/><br/>
3045
								<table border="0" cellspacing="0" cellpadding="0" summary="wpa">
3046
									<tr>
3047
										<td>&nbsp;</td>
3048
										<td>&nbsp;<?=gettext("WPA Pre-Shared Key"); ?>&nbsp;</td>
3049
									</tr>
3050
									<tr>
3051
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
3052
										<td>
3053
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>" />
3054
										</td>
3055
									</tr>
3056
								</table>
3057
								<br/><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
3058
							</td>
3059
						</tr>
3060
						<tr>
3061
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
3062
							<td class="vtable">
3063
								<select name="wpa_mode" class="formselect" id="wpa_mode">
3064
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("WPA"); ?></option>
3065
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("WPA2"); ?></option>
3066
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3067
								</select>
3068
							</td>
3069
						</tr>
3070
						<tr>
3071
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
3072
							<td class="vtable">
3073
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
3074
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected=\"selected\"";?> value="WPA-PSK"><?=gettext("Pre-Shared Key"); ?></option>
3075
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected=\"selected\"";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
3076
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected=\"selected\"";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
3077
								</select>
3078
							</td>
3079
						</tr>
3080
						<tr>
3081
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
3082
							<td class="vtable">
3083
								<select name="auth_algs" class="formselect" id="auth_algs">
3084
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("Open System Authentication"); ?></option>
3085
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
3086
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3087
								</select>
3088
								<br/><?=gettext("Note: Shared Key Authentication requires WEP."); ?></br>
3089
							</td>
3090
						</tr>
3091
						<tr>
3092
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
3093
							<td class="vtable">
3094
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
3095
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected=\"selected\"";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
3096
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected=\"selected\"";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
3097
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected=\"selected\"";?> value="TKIP"><?=gettext("TKIP"); ?></option>
3098
								</select>
3099
							</td>
3100
						</tr>
3101
						<tr>
3102
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
3103
							<td class="vtable">
3104
								<input name="wpa_group_rekey" type="text" class="formfld unknown" id="wpa_group_rekey" size="30" value="<?php echo $pconfig['wpa_group_rekey'] ? $pconfig['wpa_group_rekey'] : "60";?>" />
3105
								<br/><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
3106
							</td>
3107
						</tr>
3108
						<tr>
3109
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
3110
							<td class="vtable">
3111
								<input name="wpa_gmk_rekey" type="text" class="formfld" id="wpa_gmk_rekey" size="30" value="<?php echo $pconfig['wpa_gmk_rekey'] ? $pconfig['wpa_gmk_rekey'] : "3600";?>" />
3112
								<br/><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
3113
							</td>
3114
						</tr>
3115
						<tr>
3116
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
3117
							<td class="vtable">
3118
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked=\"checked\""; ?> />
3119
								<br/><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
3120
							</td>
3121
						</tr>
3122
						<tr>
3123
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
3124
							<td class="vtable">
3125
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked=\"checked\"";?> />
3126
								<br/><?=gettext("Setting this option will enable 802.1x authentication."); ?>
3127
								<br/><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
3128
							</td>
3129
						</tr>
3130
						<tr>
3131
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
3132
							<td class="vtable">
3133
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>" />
3134
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3135
							</td>
3136
						</tr>
3137
						<tr>
3138
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
3139
							<td class="vtable">
3140
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>" />
3141
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
3142
							</td>
3143
						</tr>
3144
						<tr>
3145
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
3146
							<td class="vtable">
3147
								<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']);?>" />
3148
								<br/>
3149
							</td>
3150
						</tr>
3151
						<tr>
3152
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
3153
							<td class="vtable">
3154
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>" />
3155
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3156
							</td>
3157
						</tr>
3158
						<tr>
3159
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
3160
							<td class="vtable">
3161
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>" />
3162
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
3163
							</td>
3164
						</tr>
3165
						<tr>
3166
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
3167
							<td class="vtable">
3168
								<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']);?>" />
3169
								<br/>
3170
							</td>
3171
						</tr>
3172
						<tr>
3173
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
3174
							<td class="vtable">
3175
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <?php if ($pconfig['rsn_preauth']) echo "checked=\"checked\""; ?> />
3176
								<br/>
3177
							</td>
3178
						</tr>
3179
						<tr>
3180
							<td colspan="2" valign="top" height="16"></td>
3181
						</tr>
3182
						<?php endif; ?>
3183
						<tr>
3184
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
3185
						</tr>
3186
						<tr>
3187
							<td valign="middle" class="vncell">&nbsp;</td>
3188
							<td class="vtable">
3189
								<a name="rfc1918"></a>
3190
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked=\"checked\""; ?> />
3191
								<strong><?=gettext("Block private networks"); ?></strong><br/>
3192
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3193
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
3194
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
3195
								"leave this option turned on, unless your WAN network lies in such " .
3196
								"a private address space, too."); ?>
3197
							</td>
3198
						</tr>
3199
						<tr>
3200
							<td valign="middle" class="vncell">&nbsp;</td>
3201
							<td class="vtable">
3202
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked=\"checked\""; ?> />
3203
								<strong><?=gettext("Block bogon networks"); ?></strong><br/>
3204
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3205
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
3206
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
3207
								"and obviously should not appear as the source address in any packets you receive."); ?>
3208
								<br/><br/>
3209
								<?=gettext("Note: The update frequency can be changed under System->Advanced Firewall/NAT settings.")?>
3210
							</td>
3211
						</tr>
3212
					</table> <!-- End "allcfg" table -->
3213
					</div> <!-- End "allcfg" div -->
3214

    
3215
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
3216
						<tr>
3217
							<td width="22%" valign="top">
3218
								&nbsp;
3219
							</td>
3220
							<td width="78%">
3221
								<br/>
3222
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
3223
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
3224
								<input name="if" type="hidden" id="if" value="<?=$if;?>" />
3225
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
3226
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>" />
3227
								<?php endif; ?>
3228
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>" />
3229
							</td>
3230
						</tr>
3231
					</table>
3232
					</div>
3233
				</td>
3234
			</tr>
3235
		</table>
3236
	</form>
3237
	<script type="text/javascript">
3238
	//<![CDATA[
3239
		var gatewayip;
3240
		var name;
3241
		var gatewayipv6;
3242
		var namev6;
3243
		function show_add_gateway() {
3244
			document.getElementById("addgateway").style.display = '';
3245
			document.getElementById("addgwbox").style.display = 'none';
3246
			document.getElementById("gateway").style.display = 'none';
3247
			document.getElementById("save").style.display = 'none';
3248
			document.getElementById("cancel").style.display = 'none';
3249
			document.getElementById("gwsave").style.display = '';
3250
			document.getElementById("gwcancel").style.display = '';
3251
			jQuery('#notebox').html("");
3252
		}
3253
		function show_add_gateway_v6() {
3254
			document.getElementById("addgatewayv6").style.display = '';
3255
			document.getElementById("addgwboxv6").style.display = 'none';
3256
			document.getElementById("gatewayv6").style.display = 'none';
3257
			document.getElementById("save").style.display = 'none';
3258
			document.getElementById("cancel").style.display = 'none';
3259
			document.getElementById("gwsave").style.display = '';
3260
			document.getElementById("gwcancel").style.display = '';
3261
			jQuery('#noteboxv6').html("");
3262
		}
3263
		function hide_add_gateway() {
3264
			document.getElementById("addgateway").style.display = 'none';
3265
			document.getElementById("addgwbox").style.display = '';
3266
			document.getElementById("gateway").style.display = '';
3267
			document.getElementById("save").style.display = '';
3268
			document.getElementById("cancel").style.display = '';
3269
			document.getElementById("gwsave").style.display = '';
3270
			document.getElementById("gwcancel").style.display = '';
3271
			jQuery('#status').html('');
3272
		}
3273
		function hide_add_gateway_v6() {
3274
			document.getElementById("addgatewayv6").style.display = 'none';
3275
			document.getElementById("addgwboxv6").style.display = '';
3276
			document.getElementById("gatewayv6").style.display = '';
3277
			document.getElementById("save").style.display = '';
3278
			document.getElementById("cancel").style.display = '';
3279
			document.getElementById("gwsave").style.display = '';
3280
			document.getElementById("gwcancel").style.display = '';
3281
			jQuery('#statusv6').html('');
3282
		}
3283
		function hide_add_gatewaysave() {
3284
			document.getElementById("addgateway").style.display = 'none';
3285
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif" alt="loader" /> One moment please...');
3286
			var iface = jQuery('#if').val();
3287
			name = jQuery('#name').val();
3288
			var descr = jQuery('#gatewaydescr').val();
3289
			gatewayip = jQuery('#gatewayip').val();
3290

    
3291
			var defaultgw = jQuery('#defaultgw').val();
3292
			var url = "system_gateways_edit.php";
3293
			var pars = 'isAjax=true&ipprotocol=inet&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3294
			jQuery.ajax(
3295
				url,
3296
				{
3297
					type: 'post',
3298
					data: pars,
3299
					error: report_failure,
3300
					success: save_callback
3301
				});
3302
		}
3303
		function hide_add_gatewaysave_v6() {
3304
			document.getElementById("addgatewayv6").style.display = 'none';
3305
			jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif" alt="loader" /> One moment please...');
3306
			var iface = jQuery('#if').val();
3307
			name = jQuery('#namev6').val();
3308
			var descr = jQuery('#gatewaydescrv6').val();
3309
			gatewayip = jQuery('#gatewayipv6').val();
3310
			var defaultgw = jQuery('#defaultgwv6').val();
3311
			var url_v6 = "system_gateways_edit.php";
3312
			var pars_v6 = 'isAjax=true&ipprotocol=inet6&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3313
			jQuery.ajax(
3314
				url_v6,
3315
				{
3316
					type: 'post',
3317
					data: pars_v6,
3318
					error: report_failure_v6,
3319
					success: save_callback_v6
3320
				});
3321
		}
3322
		function addOption(selectbox,text,value)
3323
		{
3324
			var optn = document.createElement("OPTION");
3325
			optn.text = text;
3326
			optn.value = value;
3327
			selectbox.append(optn);
3328
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3329
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3330
		}
3331
		function addOption_v6(selectbox,text,value)
3332
		{
3333
			var optn = document.createElement("OPTION");
3334
			optn.text = text;
3335
			optn.value = value;
3336
			selectbox.append(optn);
3337
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3338
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3339
		}
3340
		function report_failure(request, textStatus, errorThrown) {
3341
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3342
				alert(request.responseText);
3343
			} else {
3344
				alert("Sorry, we could not create your IPv4 gateway at this time.");
3345
			}
3346
			hide_add_gateway();
3347
		}
3348
		function report_failure_v6(request, textStatus, errorThrown) {
3349
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3350
				alert(request.responseText);
3351
			} else {
3352
				alert("Sorry, we could not create your IPv6 gateway at this time.");
3353
			}
3354
			hide_add_gateway_v6();
3355
		}
3356
		function save_callback(response) {
3357
			if(response) {
3358
				document.getElementById("addgateway").style.display = 'none';
3359
				hide_add_gateway();
3360
				var gwtext = escape(name) + " - " + gatewayip;
3361
				addOption(jQuery('#gateway'), gwtext, name);
3362
				// Auto submit form?
3363
				//document.iform.submit();
3364
				//jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif" alt="loader /">');
3365
			} else {
3366
				report_failure();
3367
			}
3368
		}
3369
		function show_advanced_media() {
3370
			document.getElementById("showadvmediabox").innerHTML='';
3371
			aodiv = document.getElementById('showmediaadv');
3372
			aodiv.style.display = "block";
3373
		}
3374
		function save_callback_v6(response_v6) {
3375
			if(response_v6) {
3376
				document.getElementById("addgatewayv6").style.display = 'none';
3377
				hide_add_gateway_v6();
3378
				var gwtext_v6 = escape(name) + " - " + gatewayip;
3379
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
3380
				// Auto submit form?
3381
				//document.iform.submit();
3382
				//jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif" alt="loader" />');
3383
			} else {
3384
				report_failure_v6();
3385
			}
3386
		}
3387
		<?php
3388
		echo "show_allcfg(document.iform.enable);";
3389
		echo "updateType('{$pconfig['type']}');\n";
3390
		echo "updateTypeSix('{$pconfig['type6']}');\n";
3391
		?>
3392
	//]]>
3393
	</script>
3394
	<?php include("fend.inc"); ?>
3395
	</body>
3396
</html>
(93-93/246)