Project

General

Profile

Download (172 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['dhcp6-ia-pd-send-hint'] = isset($wancfg['dhcp6-ia-pd-send-hint']);
276
		$pconfig['type6'] = "dhcp6";
277
		$pconfig['dhcp6prefixonly'] = isset($wancfg['dhcp6prefixonly']);
278
		$pconfig['dhcp6usev4iface'] = isset($wancfg['dhcp6usev4iface']);
279
		break;
280
	case "6to4":
281
		$pconfig['type6'] = "6to4";
282
		break;
283
	case "track6":
284
		$pconfig['type6'] = "track6";
285
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
286
		if ($wancfg['track6-prefix-id'] == "")
287
			$pconfig['track6-prefix-id'] = 0;
288
		else
289
			$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
290
		$pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
291
		break;
292
	case "6rd":
293
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
294
		if($wancfg['prefix-6rd-v4plen'] == "")
295
			$wancfg['prefix-6rd-v4plen'] = "0";
296
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
297
		$pconfig['type6'] = "6rd";
298
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
299
		break;
300
	default:
301
		if(is_ipaddrv6($wancfg['ipaddrv6'])) {
302
			$pconfig['type6'] = "staticv6";
303
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
304
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
305
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
306
		} else
307
			$pconfig['type6'] = "none";
308
		break;
309
}
310

    
311
// print_r($pconfig);
312

    
313
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
314
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
315
$pconfig['spoofmac'] = $wancfg['spoofmac'];
316
$pconfig['mtu'] = $wancfg['mtu'];
317
$pconfig['mss'] = $wancfg['mss'];
318

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

    
402
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
403
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
404

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

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

    
426
		/* sync filter configuration */
427
		setup_gateways_monitor();
428

    
429
		clear_subsystem_dirty('interfaces');
430

    
431
		filter_configure();
432

    
433
		enable_rrd_graphing();
434

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

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

    
468
	/* filter out spaces from descriptions  */
469
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
470

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

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

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

    
605

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

    
616
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
617
			if ($_POST['subnet'] < 31) {
618
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet']))
619
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
620
				else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet']))
621
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
622
			}
623

    
624
			foreach ($staticroutes as $route_subnet) {
625
				list($network, $subnet) = explode("/", $route_subnet);
626
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
627
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
628
					break;
629
				}
630
				unset($network, $subnet);
631
			}
632
		}
633
	}
634
	if ($_POST['ipaddrv6']) {
635
		if (!is_ipaddrv6($_POST['ipaddrv6']))
636
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
637
		else {
638
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
639
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
640

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

    
703
		if (stristr($wancfg['if'], "_vlan")) {
704
			$realhwif_array = get_parent_interface($wancfg['if']);
705
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
706
			$parent_realhwif = $realhwif_array[0];
707
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
708
			if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
709
				if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu']))
710
					$input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface.");
711
			}
712
		} else {
713
			foreach ($config['interfaces'] as $idx => $ifdata) {
714
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
715
					continue;
716

    
717
				$realhwif_array = get_parent_interface($ifdata['if']);
718
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
719
				$parent_realhwif = $realhwif_array[0];
720

    
721
				if ($parent_realhwif != $wancfg['if'])
722
					continue;
723

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

    
777
		if ($_POST['passphrase']) {
778
			$passlen = strlen($_POST['passphrase']);
779
			if ($passlen < 8 || $passlen > 63)
780
				$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
781
		}
782
	}
783
	if (!$input_errors) {
784
		if ($wancfg['ipaddr'] != $_POST['type']) {
785
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
786
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
787
				unset($a_ppps[$pppid]);
788
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
789
				$pid = find_dhcp6c_process($wancfg['if']);
790
				if($pid)
791
					posix_kill($pid, SIGTERM);
792
			} else if ($wancfg['ipaddr'] == "dhcp") {
793
				$pid = find_dhclient_process($wancfg['if']);
794
				if($pid)
795
					posix_kill($pid, SIGTERM);
796
			}
797

    
798
		}
799
		$ppp = array();
800
		if ($wancfg['ipaddr'] != "ppp")
801
			unset($wancfg['ipaddr']);
802
		if ($wancfg['ipaddrv6'] != "ppp")
803
			unset($wancfg['ipaddrv6']);
804
		unset($wancfg['subnet']);
805
		unset($wancfg['gateway']);
806
		unset($wancfg['subnetv6']);
807
		unset($wancfg['gatewayv6']);
808
		unset($wancfg['dhcphostname']);
809
		unset($wancfg['dhcprejectfrom']);
810
		unset($wancfg['dhcp6-duid']);
811
		unset($wancfg['dhcp6-ia-pd-len']);
812
		unset($wancfg['dhcp6-ia-pd-send-hint']);
813
		unset($wancfg['dhcp6prefixonly']);
814
		unset($wancfg['dhcp6usev4iface']);
815
		unset($wancfg['track6-interface']);
816
		unset($wancfg['track6-prefix-id']);
817
		unset($wancfg['prefix-6rd']);
818
		unset($wancfg['prefix-6rd-v4plen']);
819
		unset($wancfg['gateway-6rd']);
820

    
821
		unset($wancfg['adv_dhcp_pt_timeout']);
822
		unset($wancfg['adv_dhcp_pt_retry']);
823
		unset($wancfg['adv_dhcp_pt_select_timeout']);
824
		unset($wancfg['adv_dhcp_pt_reboot']);
825
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
826
		unset($wancfg['adv_dhcp_pt_initial_interval']);
827

    
828
		unset($wancfg['adv_dhcp_pt_values']);
829

    
830
		unset($wancfg['adv_dhcp_send_options']);
831
		unset($wancfg['adv_dhcp_request_options']);
832
		unset($wancfg['adv_dhcp_required_options']);
833
		unset($wancfg['adv_dhcp_option_modifiers']);
834

    
835
		unset($wancfg['adv_dhcp_config_advanced']);
836
		unset($wancfg['adv_dhcp_config_file_override']);
837
		unset($wancfg['adv_dhcp_config_file_override_path']);
838

    
839
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
840
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
841
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
842
		unset($wancfg['adv_dhcp6_interface_statement_script']);
843

    
844
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
845
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
846
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
847
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
848
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
849

    
850
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
851
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
852
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
853
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
854
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
855

    
856
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
857
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
858

    
859
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
860
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
861
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
862
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
863

    
864
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
865
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
866
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
867
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
868
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
869

    
870
		unset($wancfg['adv_dhcp6_config_advanced']);
871
		unset($wancfg['adv_dhcp6_config_file_override']);
872
		unset($wancfg['adv_dhcp6_config_file_override_path']);
873

    
874
		unset($wancfg['pppoe_password']);
875
		unset($wancfg['pptp_username']);
876
		unset($wancfg['pptp_password']);
877
		unset($wancfg['provider']);
878
		unset($wancfg['ondemand']);
879
		unset($wancfg['timeout']);
880
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
881
			unset($wancfg['pppoe']['pppoe-reset-type']);
882
		unset($wancfg['local']);
883

    
884
		unset($wancfg['remote']);
885
		unset($a_ppps[$pppid]['apn']);
886
		unset($a_ppps[$pppid]['phone']);
887
		unset($a_ppps[$pppid]['localip']);
888
		unset($a_ppps[$pppid]['subnet']);
889
		unset($a_ppps[$pppid]['gateway']);
890
		unset($a_ppps[$pppid]['pppoe-reset-type']);
891
		unset($a_ppps[$pppid]['provider']);
892

    
893
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
894
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
895

    
896
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
897
		switch($_POST['type']) {
898
			case "staticv4":
899
				$wancfg['ipaddr'] = $_POST['ipaddr'];
900
				$wancfg['subnet'] = $_POST['subnet'];
901
				if ($_POST['gateway'] != "none") {
902
					$wancfg['gateway'] = $_POST['gateway'];
903
				}
904
				break;
905
			case "dhcp":
906
				$wancfg['ipaddr'] = "dhcp";
907
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
908
				$wancfg['alias-address'] = $_POST['alias-address'];
909
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
910
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
911

    
912
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
913
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
914
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
915
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
916
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
917
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
918

    
919
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
920

    
921
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
922
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
923
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
924
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
925

    
926
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
927
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
928
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
929

    
930
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
931
				if($gateway_item) {
932
					$a_gateways[] = $gateway_item;
933
				}
934
				break;
935
			case "ppp":
936
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
937
				$a_ppps[$pppid]['type'] = $_POST['type'];
938
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
939
				$a_ppps[$pppid]['ports'] = $_POST['port'];
940
				$a_ppps[$pppid]['username'] = $_POST['username'];
941
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
942
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
943
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
944
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
945
				$wancfg['ipaddr'] = $_POST['type'];
946
				unset($a_ppps[$pppid]['ondemand']);
947
				unset($a_ppps[$pppid]['idletimeout']);
948
				break;
949

    
950
			case "pppoe":
951
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
952
				$a_ppps[$pppid]['type'] = $_POST['type'];
953
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
954
				if (isset($_POST['ppp_port']))
955
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
956
				else
957
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
958
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
959
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
960
				if (!empty($_POST['provider']))
961
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
962
				else
963
					$a_ppps[$pppid]['provider'] = true;
964
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
965
				if (!empty($_POST['pppoe_idletimeout']))
966
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
967
				else
968
					unset($a_ppps[$pppid]['idletimeout']);
969

    
970
				if (!empty($_POST['pppoe-reset-type']))
971
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
972
				else
973
					unset($a_ppps[$pppid]['pppoe-reset-type']);
974
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
975
				$wancfg['ipaddr'] = $_POST['type'];
976
				if($gateway_item) {
977
					$a_gateways[] = $gateway_item;
978
				}
979

    
980
				break;
981
			case "pptp":
982
			case "l2tp":
983
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
984
				$a_ppps[$pppid]['type'] = $_POST['type'];
985
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
986
				if (isset($_POST['ppp_port']))
987
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
988
				else
989
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
990
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
991
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
992
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
993
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
994
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
995
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
996
				if (!empty($_POST['pptp_idletimeout']))
997
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
998
				else
999
					unset($a_ppps[$pppid]['idletimeout']);
1000
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1001
				$wancfg['ipaddr'] = $_POST['type'];
1002
				if($gateway_item) {
1003
					$a_gateways[] = $gateway_item;
1004
				}
1005
				break;
1006
			case "none":
1007
				break;
1008
		}
1009
		switch($_POST['type6']) {
1010
			case "staticv6":
1011
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
1012
				$wancfg['subnetv6'] = $_POST['subnetv6'];
1013
				if ($_POST['gatewayv6'] != "none") {
1014
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
1015
				}
1016
				break;
1017
			case "slaac":
1018
				$wancfg['ipaddrv6'] = "slaac";
1019
				break;
1020
			case "dhcp6":
1021
				$wancfg['ipaddrv6'] = "dhcp6";
1022
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
1023
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
1024
				if($_POST['dhcp6-ia-pd-send-hint'] == "yes")
1025
					$wancfg['dhcp6-ia-pd-send-hint'] = true;
1026
				if($_POST['dhcp6prefixonly'] == "yes")
1027
					$wancfg['dhcp6prefixonly'] = true;
1028
				if($_POST['dhcp6usev4iface'] == "yes")
1029
					$wancfg['dhcp6usev4iface'] = true;
1030

    
1031
				$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1032
				$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1033
				$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1034
				$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1035

    
1036
				$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1037
				$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1038
				$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1039
				$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1040
				$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1041

    
1042
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1043
				$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1044
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1045
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1046
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1047

    
1048
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1049
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1050

    
1051
				$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1052
				$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1053
				$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1054
				$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1055

    
1056
				$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1057
				$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1058
				$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1059
				$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1060
				$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1061

    
1062
				$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1063
				$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1064
				$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1065

    
1066
				if($gateway_item) {
1067
					$a_gateways[] = $gateway_item;
1068
				}
1069
				break;
1070
			case "6rd":
1071
				$wancfg['ipaddrv6'] = "6rd";
1072
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1073
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1074
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1075
				if($gateway_item) {
1076
					$a_gateways[] = $gateway_item;
1077
				}
1078
				break;
1079
			case "6to4":
1080
				$wancfg['ipaddrv6'] = "6to4";
1081
				break;
1082
			case "track6":
1083
				$wancfg['ipaddrv6'] = "track6";
1084
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1085
				if ($_POST['track6-prefix-id--hex'] === "")
1086
					$wancfg['track6-prefix-id'] = 0;
1087
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
1088
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1089
				else
1090
					$wancfg['track6-prefix-id'] = 0;
1091
				break;
1092
			case "none":
1093
				break;
1094
		}
1095
		handle_pppoe_reset($_POST);
1096

    
1097
		if($_POST['blockpriv'] == "yes") {
1098
			$wancfg['blockpriv'] = true;
1099
		} else {
1100
			unset($wancfg['blockpriv']);
1101
		}
1102
		if($_POST['blockbogons'] == "yes") {
1103
			$wancfg['blockbogons'] = true;
1104
		} else {
1105
			unset($wancfg['blockbogons']);
1106
		}
1107
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1108
		if (empty($_POST['mtu'])) {
1109
			unset($wancfg['mtu']);
1110
		} else {
1111
			$wancfg['mtu'] = $_POST['mtu'];
1112
		}
1113
		if (empty($_POST['mss'])) {
1114
			unset($wancfg['mss']);
1115
		} else {
1116
			$wancfg['mss'] = $_POST['mss'];
1117
		}
1118
		if (empty($_POST['mediaopt'])) {
1119
			unset($wancfg['media']);
1120
			unset($wancfg['mediaopt']);
1121
		} else {
1122
			$mediaopts = explode(' ', $_POST['mediaopt']);
1123
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
1124
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
1125
			else { unset($wancfg['mediaopt']); }
1126
		}
1127
		if (isset($wancfg['wireless'])) {
1128
			handle_wireless_post();
1129
		}
1130

    
1131
		conf_mount_ro();
1132
		write_config();
1133

    
1134
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1135
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1136
		} else {
1137
			$toapplylist = array();
1138
		}
1139
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1140
		$toapplylist[$if]['ppps'] = $old_ppps;
1141
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1142

    
1143
		mark_subsystem_dirty('interfaces');
1144

    
1145
		/* regenerate cron settings/crontab file */
1146
		configure_cron();
1147

    
1148
		header("Location: interfaces.php?if={$if}");
1149
		exit;
1150
	}
1151

    
1152
} // end if($_POST)
1153

    
1154
function handle_wireless_post() {
1155
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1156
	if (!is_array($wancfg['wireless']))
1157
		$wancfg['wireless'] = array();
1158
	$wancfg['wireless']['standard'] = $_POST['standard'];
1159
	$wancfg['wireless']['mode'] = $_POST['mode'];
1160
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1161
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1162
	$wancfg['wireless']['channel'] = $_POST['channel'];
1163
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1164
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1165
	$wancfg['wireless']['distance'] = $_POST['distance'];
1166
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1167
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1168
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1169
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1170
		foreach($wl_countries_attr as $wl_country) {
1171
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1172
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1173
				break;
1174
			}
1175
		}
1176
	}
1177
	if (!is_array($wancfg['wireless']['wpa']))
1178
		$wancfg['wireless']['wpa'] = array();
1179
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1180
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1181
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1182
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1183
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1184
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1185
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1186
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1187
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1188
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1189
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1190
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1191
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1192
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1193
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1194

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

    
1295
function check_wireless_mode() {
1296
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1297

    
1298
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1299
		return;
1300

    
1301
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1302
		$clone_count = 1;
1303
	else
1304
		$clone_count = 0;
1305
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1306
		foreach ($config['wireless']['clone'] as $clone) {
1307
			if ($clone['if'] == $wlanbaseif)
1308
				$clone_count++;
1309
		}
1310
	}
1311
	if ($clone_count > 1) {
1312
		$old_wireless_mode = $wancfg['wireless']['mode'];
1313
		$wancfg['wireless']['mode'] = $_POST['mode'];
1314
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1315
			$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']]);
1316
		} else {
1317
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1318
		}
1319
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1320
	}
1321
}
1322

    
1323
// Find all possible media options for the interface
1324
$mediaopts_list = array();
1325
$intrealname = $config['interfaces'][$if]['if'];
1326
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1327
foreach ($mediaopts as $mediaopt){
1328
	preg_match("/media (.*)/", $mediaopt, $matches);
1329
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1330
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1331
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1332
	}else{
1333
		// there is only media like "media 1000baseT"
1334
		array_push($mediaopts_list, $matches[1]);
1335
	}
1336
}
1337

    
1338
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1339
$shortcut_section = "interfaces";
1340

    
1341
$closehead = false;
1342
include("head.inc");
1343
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1344
$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"));
1345

    
1346
?>
1347

    
1348
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1349
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1350
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1351
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1352

    
1353
<script type="text/javascript">
1354
	function updateType(t) {
1355
		switch(t) {
1356
			case "none": {
1357
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1358
				break;
1359
			}
1360
			case "staticv4": {
1361
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1362
				break;
1363
			}
1364
			case "dhcp": {
1365
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1366
				break;
1367
			}
1368
			case "ppp": {
1369
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1370
				country_list();
1371
				break;
1372
			}
1373
			case "pppoe": {
1374
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1375
				break;
1376
			}
1377
			case "l2tp":
1378
			case "pptp": {
1379
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1380
				jQuery('#pptp').show();
1381
				break;
1382
			}
1383
		}
1384
		if (t != "l2tp" && t != "pptp")
1385
			jQuery('#'+t).show();
1386
	}
1387
	function updateTypeSix(t) {
1388
		switch(t) {
1389
			case "none": {
1390
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1391
				break;
1392
			}
1393
			case "staticv6": {
1394
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1395
				break;
1396
			}
1397
			case "slaac": {
1398
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1399
				break;
1400
			}
1401
			case "dhcp6": {
1402
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1403
				break;
1404
			}
1405
			case "6rd": {
1406
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1407
				break;
1408
			}
1409
			case "6to4": {
1410
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1411
				break;
1412
			}
1413
			case "track6": {
1414
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1415
				break;
1416
			}
1417
		}
1418
		if (t != "l2tp" && t != "pptp")
1419
			jQuery('#'+t).show();
1420
	}
1421

    
1422
	function show_allcfg(obj) {
1423
		if (obj.checked)
1424
			jQuery('#allcfg').show();
1425
		else
1426
			jQuery('#allcfg').hide();
1427
	}
1428

    
1429
	function show_reset_settings(reset_type) {
1430
		if (reset_type == 'preset') {
1431
			jQuery('#pppoepresetwrap').show();
1432
			jQuery('#pppoecustomwrap').hide();
1433
		}
1434
		else if (reset_type == 'custom') {
1435
			jQuery('#pppoecustomwrap').show();
1436
			jQuery('#pppoepresetwrap').hide();
1437
		} else {
1438
			jQuery('#pppoecustomwrap').hide();
1439
			jQuery('#pppoepresetwrap').hide();
1440
		}
1441
	}
1442
	function show_mon_config() {
1443
		jQuery("#showmonbox").html('');
1444
		jQuery('#showmon').css('display','block');
1445
	}
1446

    
1447
	function openwindow(url) {
1448
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1449
		if (oWin==null || typeof(oWin)=="undefined")
1450
			return false;
1451
		else
1452
			return true;
1453
	}
1454
	function country_list() {
1455
		jQuery('#country').children().remove();
1456
		jQuery('#provider').children().remove();
1457
		jQuery('#providerplan').children().remove();
1458
		jQuery.ajax("getserviceproviders.php",{
1459
			success: function(response) {
1460
				var responseTextArr = response.split("\n");
1461
				responseTextArr.sort();
1462
				responseTextArr.each( function(value) {
1463
					var option = new Element('option');
1464
					country = value.split(":");
1465
					option.text = country[0];
1466
					option.value = country[1];
1467
					jQuery('#country').append(option);
1468
				});
1469
			}
1470
		});
1471
		jQuery('#trcountry').css('display',"table-row");
1472
	}
1473

    
1474
	function providers_list() {
1475
		jQuery('#provider').children().remove();
1476
		jQuery('#providerplan').children().remove();
1477
		jQuery.ajax("getserviceproviders.php",{
1478
			type: 'post',
1479
			data: {country : jQuery('#country').val()},
1480
			success: function(response) {
1481
				var responseTextArr = response.split("\n");
1482
				responseTextArr.sort();
1483
				responseTextArr.each( function(value) {
1484
					var option = new Element('option');
1485
					option.text = value;
1486
					option.value = value;
1487
					jQuery('#provider').append(option);
1488
				});
1489
			}
1490
		});
1491
		jQuery('#trprovider').css("display","table-row");
1492
		jQuery('#trproviderplan').css("display","none");
1493
	}
1494

    
1495
	function providerplan_list() {
1496
		jQuery('#providerplan').children().remove();
1497
		jQuery('#providerplan').append( new Element('option') );
1498
		jQuery.ajax("getserviceproviders.php",{
1499
			type: 'post',
1500
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1501
			success: function(response) {
1502
				var responseTextArr = response.split("\n");
1503
				responseTextArr.sort();
1504
				responseTextArr.each( function(value) {
1505
					if(value != "") {
1506
						providerplan = value.split(":");
1507

    
1508
						var option = new Element('option');
1509
						option.text = providerplan[0] + " - " + providerplan[1];
1510
						option.value = providerplan[1];
1511
						jQuery('#providerplan').append(option);
1512
					}
1513
				});
1514
			}
1515
		});
1516
		jQuery('#trproviderplan').css("display","table-row");
1517
	}
1518

    
1519
	function prefill_provider() {
1520
		jQuery.ajax("getserviceproviders.php",{
1521
			type: 'post',
1522
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1523
			success: function(data,textStatus,response) {
1524
				var xmldoc = response.responseXML;
1525
				var provider = xmldoc.getElementsByTagName('connection')[0];
1526
				jQuery('#username').val('');
1527
				jQuery('#password').val('');
1528
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1529
					jQuery('#phone').val('#777');
1530
					jQuery('#apn').val('');
1531
				} else {
1532
					jQuery('#phone').val('*99#');
1533
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1534
				}
1535
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1536
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1537
				jQuery('#username').val(username);
1538
				jQuery('#password').val(password);
1539
			}
1540
		});
1541
	}
1542

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

    
1957
									<tr style='display:none' name="show_adv_dhcp_protocol_timing" id="show_adv_dhcp_protocol_timing">
1958
										<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>
1959
										<td width="48%" class="vtable">
1960
											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, '');">
1961
											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, '');">
1962
											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, '');">
1963

    
1964
											&nbsp &nbsp &nbsp &nbsp 
1965
											Presets: &nbsp
1966
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	unchecked	enabled id="customdhcpptdhcpdefaults"	onClick="customdhcpptsetvalues(this, iform);">FreeBSD Default &nbsp 
1967
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	unchecked	enabled id="customdhcpptclear"		onClick="customdhcpptsetvalues(this, iform);">Clear
1968

    
1969
											<br>
1970
											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, '');">
1971
											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, '');">
1972
											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, '');">
1973

    
1974
											&nbsp &nbsp &nbsp &nbsp &nbsp 
1975
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	unchecked	enabled id="customdhcpptpfsensedefaults"	onClick="customdhcpptsetvalues(this, iform);">pfSense Default &nbsp 
1976
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked	enabled id="customdhcpptsavedcfg"		onClick="customdhcpptsetvalues(this, iform);">Saved Cfg 
1977

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

    
1981
											<script type="text/javascript">
1982
												function customdhcpptcheckradiobuton(T, BUTTON) {
1983
													for (var i = 0; i < T.length; i++) {
1984
														T[i].checked = false;
1985
														if (T[i].value == BUTTON) T[i].checked = true;
1986
													}
1987
													T.value = BUTTON;
1988
												}
1989

    
1990
												function customdhcpptsetvalues(T, FORM) {
1991
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
1992
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
1993
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
1994
													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']);?>");
1995
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
1996
												}
1997

    
1998
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
1999
													FORM.adv_dhcp_pt_timeout.value = timeout;
2000
													FORM.adv_dhcp_pt_retry.value = retry;
2001
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2002
													FORM.adv_dhcp_pt_reboot.value = reboot;
2003
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2004
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2005

    
2006
													FORM.adv_dhcp_pt_values.value = T.value;
2007
												}
2008

    
2009
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
2010
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
2011
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
2012
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
2013
											</script>
2014
										</td>
2015
									</tr>
2016

    
2017
									<tr style='display:none' name="show_adv_dhcp_lease_requirements_and_requests" id="show_adv_dhcp_lease_requirements_and_requests">
2018
										<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>
2019
										<td width="78%" class="vtable">
2020
											<?=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>
2021
											<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']);?>">
2022
											<br>
2023
											<?=gettext("The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br>" .
2024
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2025
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2026
											"Some ISPs may require certain options be or not be sent. "); ?>
2027
											<hr>
2028
											<?=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>
2029
											<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']);?>">
2030
											<br>
2031
											<?=gettext("The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] <br>" .
2032
											"Some ISPs may require certain options be or not be requested. "); ?>
2033
											<hr>
2034
											<?=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>
2035
											<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']);?>">
2036
											<br>
2037
											<?=gettext("The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]] "); ?>
2038
										</td>
2039
									</tr>
2040

    
2041
									<tr style='display:none' name="show_adv_dhcp_option_modifiers" id="show_adv_dhcp_option_modifiers">
2042
										<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>
2043
										<td width="78%" class="vtable">
2044
											<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']);?>">
2045
											<br>
2046
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br> " .
2047
											"modifiers: (default, supersede, prepend, append)"); ?>
2048
										</td>
2049
									</tr>
2050

    
2051
									<tr style='display:none' name="show_adv_dhcp_config_file_override" id="show_adv_dhcp_config_file_override">
2052
										<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>
2053
										<td width="78%" class="vtable">
2054
 											<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']);?>">
2055
											<br>
2056
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br> " .
2057
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2058
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2059
											"Some ISPs may require certain options be or not be sent. "); ?>
2060
										</td>
2061
									</tr>
2062

    
2063
 									<tr>
2064
 										<td colspan="2" valign="top" height="16"></td>
2065
 									</tr>
2066

    
2067
									<script type="text/javascript">
2068
										function show_adv_dhcp_config(T) {
2069

    
2070
											if (T.checked) T.value = "Selected";
2071
											else T.value = "";
2072

    
2073
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2074
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2075
											else 									show_hide_adv_dhcp('', 'none', 'none');
2076
										}
2077

    
2078
										function show_hide_adv_dhcp(basic, advanced, override) {
2079

    
2080
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2081
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2082
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2083

    
2084
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2085
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2086
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2087

    
2088
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2089
										}
2090

    
2091
										<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2092
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") document.iform.adv_dhcp_config_advanced.checked = true;
2093
										show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2094

    
2095
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2096
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2097
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2098
									</script>
2099

    
2100
								</table>
2101
							</td>
2102
						</tr>
2103
						<tr style="display:none;" name="dhcp6" id="dhcp6">
2104
							<td colspan="2" style="padding: 0px;">
2105
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp6">
2106
									<tr>
2107
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration &nbsp &nbsp " .
2108
										' <input name="adv_dhcp6_config_advanced" type="checkbox" id="adv_dhcp6_config_advanced" value="" onClick="show_adv_dhcp6_config(this)";> ' .
2109
										" Advanced &nbsp &nbsp " .
2110
										' <input name="adv_dhcp6_config_file_override" type="checkbox" id="adv_dhcp6_config_file_override" value="" onClick="show_adv_dhcp6_config(this)";> ' .
2111
										" Config File Override &nbsp &nbsp "); ?>
2112
										</td>
2113
									</tr>
2114
									<!--- Leave commented out for now
2115
									<tr style='display:none' name="basicdhcp6_show_dhcp6_duid" id="basicdhcp6_show_dhcp6_duid">
2116
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
2117
										<td width="78%" class="vtable">
2118
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>" />
2119
											<br/>
2120
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
2121
											"when requesting a DHCPv6 lease."); ?><br />
2122
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
2123
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
2124
												}
2125
												printf(gettext("The current DUID is: '%s'"),$current_duid);
2126
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
2127
											?>
2128
										</td>
2129
									</tr>
2130
									-->
2131
									<tr style='display:none' name="basicdhcp6_use_pppoeinterface" id="basicdhcp6_use_pppoeinterface">
2132
										<td width="22%" valign="top" class="vncell"><?=gettext("Use IPv4 connectivity as parent interface"); ?></td>
2133
										<td width="78%" class="vtable">
2134
											<input name="dhcp6usev4iface" type="checkbox" id="dhcp6usev4iface" value="yes" <?php if ($pconfig['dhcp6usev4iface'] == true) echo "checked=\"checked\""; ?> />
2135
											<?=gettext("Request a IPv6 prefix/information through the IPv4 connectivity link"); ?>
2136
										</td>
2137
									</tr>
2138
									<tr style='display:none' name="basicdhcp6_show_dhcp6_prefix_only" id="basicdhcp6_show_dhcp6_prefix_only">
2139
										<td width="22%" valign="top" class="vncell"><?=gettext("Request only a IPv6 prefix"); ?></td>
2140
										<td width="78%" class="vtable">
2141
											<input name="dhcp6prefixonly" type="checkbox" id="dhcp6prefixonly" value="yes" <?php if ($pconfig['dhcp6prefixonly'] == true) echo "checked=\"checked\""; ?> />
2142
											<?=gettext("Only request a IPv6 prefix, do not request a IPv6 address"); ?>
2143
										</td>
2144
									</tr>
2145
									<tr style='display:none' name="basicdhcp6_show_dhcp6_prefix_delegation_size" id="basicdhcp6_show_dhcp6_prefix_delegation_size">
2146
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
2147
										<td width="78%" class="vtable">
2148
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
2149
												<?php
2150
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
2151
												foreach($sizes as $bits => $length) {
2152
													echo "<option value=\"{$bits}\" ";
2153
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected=\"selected\"";
2154
													echo ">" . $length . "</option>";
2155
												}
2156
												?>
2157
											</select>
2158
											<br/>
2159
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
2160
										</td>
2161
									</tr>
2162
									<tr style='display:none' name="basicdhcp6_show_dhcp6_prefix_send_hint" id="basicdhcp6_show_dhcp6_prefix_send_hint">
2163
										<td width="22%" valign="top" class="vncell"><?=gettext("Send IPv6 prefix hint"); ?></td>
2164
										<td width="78%" class="vtable">
2165
											<input name="dhcp6-ia-pd-send-hint" type="checkbox" id="dhcp6-ia-pd-send-hint" value="yes" <?php if ($pconfig['dhcp6-ia-pd-send-hint'] == true) echo "checked=\"checked\""; ?> />
2166
											<?=gettext("Send an IPv6 prefix hint to indicate the desired prefix size for delegation"); ?>
2167
										</td>
2168
									</tr>
2169

    
2170
									<tr style='display:none' name="show_adv_dhcp6_interface_statement" id="show_adv_dhcp6_interface_statement">
2171
										<td width="22%" valign="top" class="vncell">
2172
											<?=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>"); ?>
2173
											<br><br>
2174
											<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)";>
2175
											<?=gettext("Information Only"); ?>
2176
										</td>
2177
										<td width="78%" class="vtable">
2178
											<?=gettext("Send Options"); ?><br>
2179
											<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']);?>">
2180
											<br>
2181
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br>" .
2182
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2183
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2184
											"Some DHCP services may require certain options be or not be sent. "); ?>
2185
											<br>
2186
											<br>
2187
											<?=gettext("Request Options"); ?><br>
2188
											<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']);?>">
2189
											<br>
2190
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br>" .
2191
											"Some DHCP services may require certain options be or not be requested. "); ?>
2192
											<br>
2193
											<br>
2194
											<?=gettext("Script"); ?><br>
2195
											<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']);?>">
2196
											<br>
2197
											<?=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>" .
2198
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2199
										</td>
2200
									</tr>
2201

    
2202
									<tr style='display:none' name="show_adv_dhcp6_id_assoc_statement" id="show_adv_dhcp6_id_assoc_statement">
2203
										<td width="22%" valign="top" class="vncell">
2204
											<?=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>"); ?>
2205
										</td>
2206
										<td width="78%" class="vtable">
2207

    
2208
											<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)";>
2209
											<?=gettext("Non-Temporary Address Allocation"); ?>
2210
											<div style='display:none'  name="show_adv_dhcp6_id_assoc_statement_address" id="show_adv_dhcp6_id_assoc_statement_address">
2211
											<?=gettext("id-assoc na"); ?>
2212
											<?=gettext("<i>ID</i>"); ?>
2213
											<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']);?>">
2214
											<br>
2215
											<?=gettext("Address"); ?>
2216
											<?=gettext("<i>ipv6-address</i>"); ?>
2217
											<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']);?>">
2218
											<?=gettext("<i>pltime</i>"); ?>
2219
											<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']);?>">
2220
											<?=gettext("<i>vltime</i>"); ?>
2221
											<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']);?>">
2222
											</div>
2223
											<hr>
2224

    
2225
											<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)";>
2226
											<?=gettext("Prefix Delegation"); ?>
2227
											<div style='display:none'  name="show_adv_dhcp6_id_assoc_statement_prefix" id="show_adv_dhcp6_id_assoc_statement_prefix">
2228
											<?=gettext("id-assoc pd"); ?>
2229
											<?=gettext("<i>ID</i>"); ?>
2230
											<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']);?>">
2231
											<br>
2232
											<?=gettext("Prefix"); ?>
2233
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2234
											<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']);?>">
2235
											<?=gettext("<i>pltime</i>"); ?>
2236
											<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']);?>">
2237
											<?=gettext("<i>vltime</i>"); ?>
2238
											<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']);?>">
2239
											</div>
2240
										</td>
2241
									</tr>
2242

    
2243
									<tr style='display:none' name="show_adv_dhcp6_prefix_interface_statement" id="show_adv_dhcp6_prefix_interface_statement">
2244
										<td width="22%" valign="top" class="vncell">
2245
											<?=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>"); ?>
2246
										</td>
2247
										<td width="78%" class="vtable">
2248
											<?=gettext("Prefix Interface "); ?>
2249
											<?=gettext("<i>sla-id</i>"); ?>
2250
											<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']);?>">
2251
											<?=gettext("<i>sla-len</i>"); ?>
2252
											<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']);?>">
2253
										</td>
2254
									</tr>
2255

    
2256
									<tr style='display:none' name="show_adv_dhcp6_authentication_statement" id="show_adv_dhcp6_authentication_statement">
2257
										<td width="22%" valign="top" class="vncell">
2258
											<?=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>"); ?>
2259
										</td>
2260
										<td width="78%" class="vtable">
2261
											<?=gettext("<i>authname</i>"); ?>
2262
											<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']);?>">
2263
											<?=gettext("<i>protocol</i>"); ?>
2264
											<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']);?>">
2265
											<?=gettext("<i>algorithm</i>"); ?>
2266
											<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']);?>">
2267
											<?=gettext("<i>rdm</i>"); ?>
2268
											<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']);?>">
2269
										</td>
2270
									</tr>
2271

    
2272
									<tr style='display:none' name="show_adv_dhcp6_key_info_statement" id="show_adv_dhcp6_key_info_statement">
2273
										<td width="22%" valign="top" class="vncell">
2274
											<?=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>"); ?>
2275
										</td>
2276
										<td width="78%" class="vtable">
2277
											<?=gettext("<i>keyname</i>"); ?>
2278
											<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']);?>">
2279
											<?=gettext("<i>realm</i>"); ?>
2280
											<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']);?>">
2281
											<br>
2282
											<?=gettext("<i>keyid</i>"); ?>
2283
											<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']);?>">
2284
											<?=gettext("<i>secret</i>"); ?>
2285
											<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']);?>">
2286
											<?=gettext("<i>expire</i>"); ?>
2287
											<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']);?>">
2288
										</td>
2289
									</tr>
2290

    
2291
									<tr style='display:none' name="show_adv_dhcp6_config_file_override" id="show_adv_dhcp6_config_file_override">
2292
										<td width="22%" valign="top" class="vncell">
2293
											<?=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"); ?>
2294
										</td>
2295
										<td width="78%" class="vtable">
2296
 											<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']);?>">
2297
											<br>
2298
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br> " .
2299
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2300
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2301
											"Some ISPs may require certain options be or not be sent. "); ?>
2302
										</td>
2303
									</tr>
2304

    
2305
 									<tr>
2306
 										<td colspan="2" valign="top" height="16"></td>
2307
 									</tr>
2308

    
2309
									<script type="text/javascript">
2310
										function show_adv_dhcp6_config(T) {
2311

    
2312
											if (T.checked) T.value = "Selected";
2313
											else T.value = "";
2314

    
2315
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2316
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2317
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2318
										}
2319

    
2320
										function show_hide_adv_dhcp6(basic, advanced, override) {
2321

    
2322
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2323
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2324
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2325
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2326

    
2327
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2328
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2329

    
2330
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2331
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2332
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2333
											}
2334

    
2335
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2336
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2337
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2338
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2339
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2340
											}
2341

    
2342
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2343
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2344

    
2345
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2346
										}
2347

    
2348
										<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2349
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") document.iform.adv_dhcp6_config_advanced.checked = true;
2350
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2351

    
2352
										<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
2353
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override']);?>" == "Selected") document.iform.adv_dhcp6_config_file_override.checked = true;
2354
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
2355

    
2356
										<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
2357
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable']);?>" == "Selected") document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
2358
										show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
2359

    
2360
										<!-- Set the adv_dhcp6_id_assoc_statement_address_enable checkbox from saved config -->
2361
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked = true;
2362
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_address_enable);
2363

    
2364
										<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
2365
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
2366
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
2367
									</script>
2368

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

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

    
3256
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
3257
						<tr>
3258
							<td width="22%" valign="top">
3259
								&nbsp;
3260
							</td>
3261
							<td width="78%">
3262
								<br/>
3263
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
3264
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
3265
								<input name="if" type="hidden" id="if" value="<?=$if;?>" />
3266
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
3267
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>" />
3268
								<?php endif; ?>
3269
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>" />
3270
							</td>
3271
						</tr>
3272
					</table>
3273
					</div>
3274
				</td>
3275
			</tr>
3276
		</table>
3277
	</form>
3278
	<script type="text/javascript">
3279
	//<![CDATA[
3280
		var gatewayip;
3281
		var name;
3282
		var gatewayipv6;
3283
		var namev6;
3284
		function show_add_gateway() {
3285
			document.getElementById("addgateway").style.display = '';
3286
			document.getElementById("addgwbox").style.display = 'none';
3287
			document.getElementById("gateway").style.display = 'none';
3288
			document.getElementById("save").style.display = 'none';
3289
			document.getElementById("cancel").style.display = 'none';
3290
			document.getElementById("gwsave").style.display = '';
3291
			document.getElementById("gwcancel").style.display = '';
3292
			jQuery('#notebox').html("");
3293
		}
3294
		function show_add_gateway_v6() {
3295
			document.getElementById("addgatewayv6").style.display = '';
3296
			document.getElementById("addgwboxv6").style.display = 'none';
3297
			document.getElementById("gatewayv6").style.display = 'none';
3298
			document.getElementById("save").style.display = 'none';
3299
			document.getElementById("cancel").style.display = 'none';
3300
			document.getElementById("gwsave").style.display = '';
3301
			document.getElementById("gwcancel").style.display = '';
3302
			jQuery('#noteboxv6').html("");
3303
		}
3304
		function hide_add_gateway() {
3305
			document.getElementById("addgateway").style.display = 'none';
3306
			document.getElementById("addgwbox").style.display = '';
3307
			document.getElementById("gateway").style.display = '';
3308
			document.getElementById("save").style.display = '';
3309
			document.getElementById("cancel").style.display = '';
3310
			document.getElementById("gwsave").style.display = '';
3311
			document.getElementById("gwcancel").style.display = '';
3312
			jQuery('#status').html('');
3313
		}
3314
		function hide_add_gateway_v6() {
3315
			document.getElementById("addgatewayv6").style.display = 'none';
3316
			document.getElementById("addgwboxv6").style.display = '';
3317
			document.getElementById("gatewayv6").style.display = '';
3318
			document.getElementById("save").style.display = '';
3319
			document.getElementById("cancel").style.display = '';
3320
			document.getElementById("gwsave").style.display = '';
3321
			document.getElementById("gwcancel").style.display = '';
3322
			jQuery('#statusv6').html('');
3323
		}
3324
		function hide_add_gatewaysave() {
3325
			document.getElementById("addgateway").style.display = 'none';
3326
			jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3327
			var iface = jQuery('#if').val();
3328
			name = jQuery('#name').val();
3329
			var descr = jQuery('#gatewaydescr').val();
3330
			gatewayip = jQuery('#gatewayip').val();
3331

    
3332
			var defaultgw = '';
3333
			if (jQuery('#defaultgw').is(':checked'))
3334
				defaultgw = '&defaultgw=on';
3335
			var url = "system_gateways_edit.php";
3336
			var pars = 'isAjax=true&ipprotocol=inet' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3337
			jQuery.ajax(
3338
				url,
3339
				{
3340
					type: 'post',
3341
					data: pars,
3342
					error: report_failure,
3343
					success: save_callback
3344
				});
3345
		}
3346
		function hide_add_gatewaysave_v6() {
3347
			document.getElementById("addgatewayv6").style.display = 'none';
3348
			jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3349
			var iface = jQuery('#if').val();
3350
			name = jQuery('#namev6').val();
3351
			var descr = jQuery('#gatewaydescrv6').val();
3352
			gatewayip = jQuery('#gatewayipv6').val();
3353
			var defaultgw = '';
3354
			if (jQuery('#defaultgwv6').is(':checked'))
3355
				defaultgw = '&defaultgw=on';
3356
			var url_v6 = "system_gateways_edit.php";
3357
			var pars_v6 = 'isAjax=true&ipprotocol=inet6' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3358
			jQuery.ajax(
3359
				url_v6,
3360
				{
3361
					type: 'post',
3362
					data: pars_v6,
3363
					error: report_failure_v6,
3364
					success: save_callback_v6
3365
				});
3366
		}
3367
		function addOption(selectbox,text,value)
3368
		{
3369
			var optn = document.createElement("OPTION");
3370
			optn.text = text;
3371
			optn.value = value;
3372
			selectbox.append(optn);
3373
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3374
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3375
		}
3376
		function addOption_v6(selectbox,text,value)
3377
		{
3378
			var optn = document.createElement("OPTION");
3379
			optn.text = text;
3380
			optn.value = value;
3381
			selectbox.append(optn);
3382
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3383
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3384
		}
3385
		function report_failure(request, textStatus, errorThrown) {
3386
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3387
				alert(request.responseText);
3388
			} else {
3389
				alert("Sorry, we could not create your IPv4 gateway at this time.");
3390
			}
3391
			hide_add_gateway();
3392
		}
3393
		function report_failure_v6(request, textStatus, errorThrown) {
3394
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3395
				alert(request.responseText);
3396
			} else {
3397
				alert("Sorry, we could not create your IPv6 gateway at this time.");
3398
			}
3399
			hide_add_gateway_v6();
3400
		}
3401
		function save_callback(response) {
3402
			if(response) {
3403
				document.getElementById("addgateway").style.display = 'none';
3404
				hide_add_gateway();
3405
				var gwtext = escape(name) + " - " + gatewayip;
3406
				addOption(jQuery('#gateway'), gwtext, name);
3407
				// Auto submit form?
3408
				//document.iform.submit();
3409
				//jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader /">');
3410
			} else {
3411
				report_failure();
3412
			}
3413
		}
3414
		function show_advanced_media() {
3415
			document.getElementById("showadvmediabox").innerHTML='';
3416
			aodiv = document.getElementById('showmediaadv');
3417
			aodiv.style.display = "block";
3418
		}
3419
		function save_callback_v6(response_v6) {
3420
			if(response_v6) {
3421
				document.getElementById("addgatewayv6").style.display = 'none';
3422
				hide_add_gateway_v6();
3423
				var gwtext_v6 = escape(name) + " - " + gatewayip;
3424
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
3425
				// Auto submit form?
3426
				//document.iform.submit();
3427
				//jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" />');
3428
			} else {
3429
				report_failure_v6();
3430
			}
3431
		}
3432
		<?php
3433
		echo "show_allcfg(document.iform.enable);";
3434
		echo "updateType('{$pconfig['type']}');\n";
3435
		echo "updateTypeSix('{$pconfig['type6']}');\n";
3436
		?>
3437
	//]]>
3438
	</script>
3439
	<?php include("fend.inc"); ?>
3440
	</body>
3441
</html>
(93-93/249)