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($pconfig))
75
	$pconfig = array();
76

    
77
if (!is_array($config['ppps']['ppp']))
78
	$config['ppps']['ppp'] = array();
79

    
80
$a_ppps = &$config['ppps']['ppp'];
81

    
82
function remove_bad_chars($string) {
83
	return preg_replace('/[^a-z_0-9]/i','',$string);
84
}
85

    
86
if (!is_array($config['gateways']['gateway_item']))
87
	$config['gateways']['gateway_item'] = array();
88
$a_gateways = &$config['gateways']['gateway_item'];
89

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

    
100
foreach ($a_ppps as $pppid => $ppp) {
101
	if ($wancfg['if'] == $ppp['if'])
102
		break;
103
}
104

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

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

    
123
		/* ================================================ */
124
		/* = force a connection reset at a specific time? = */
125
		/* ================================================ */
126

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

    
183
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
184
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
185
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
186
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
187
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
188
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
189

    
190
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
191

    
192
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
193
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
194
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
195
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
196

    
197
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
198
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
199
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
200

    
201
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
202
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
203
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
204
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
205

    
206
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
207
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
208
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
209
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
210
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
211

    
212
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
213
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
214
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
215
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
216
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
217

    
218
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
219
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
220

    
221
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
222
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
223
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
224
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
225

    
226
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
227
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
228
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
229
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
230
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
231

    
232
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
233
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
234
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
235

    
236
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
237
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
238
$pconfig['enable'] = isset($wancfg['enable']);
239

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

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

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

    
314
// print_r($pconfig);
315

    
316
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
317
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
318
$pconfig['spoofmac'] = $wancfg['spoofmac'];
319
$pconfig['mtu'] = $wancfg['mtu'];
320
$pconfig['mss'] = $wancfg['mss'];
321

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

    
405
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
406
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
407

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

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

    
429
		/* sync filter configuration */
430
		setup_gateways_monitor();
431

    
432
		clear_subsystem_dirty('interfaces');
433

    
434
		filter_configure();
435

    
436
		enable_rrd_graphing();
437

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

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

    
471
	/* filter out spaces from descriptions  */
472
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
473

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

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

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

    
608

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

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

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

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

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

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

    
724
				if ($parent_realhwif != $wancfg['if'])
725
					continue;
726

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

    
780
		if ($_POST['passphrase']) {
781
			$passlen = strlen($_POST['passphrase']);
782
			if ($passlen < 8 || $passlen > 63)
783
				$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
784
		}
785
	}
786
	if (!$input_errors) {
787
		if ($wancfg['ipaddr'] != $_POST['type']) {
788
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
789
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
790
				unset($a_ppps[$pppid]);
791
			} else if ($wancfg['ipaddr'] == "dhcp") {
792
				$pid = find_dhclient_process($wancfg['if']);
793
				if($pid)
794
					posix_kill($pid, SIGTERM);
795
			}
796
			if ($wancfg['ipaddrv6'] == "dhcp6") {
797
				$pid = find_dhcp6c_process($wancfg['if']);
798
				if($pid)
799
					posix_kill($pid, SIGTERM);
800
			}
801
		}
802
		$ppp = array();
803
		if ($wancfg['ipaddr'] != "ppp")
804
			unset($wancfg['ipaddr']);
805
		if ($wancfg['ipaddrv6'] != "ppp")
806
			unset($wancfg['ipaddrv6']);
807
		unset($wancfg['subnet']);
808
		unset($wancfg['gateway']);
809
		unset($wancfg['subnetv6']);
810
		unset($wancfg['gatewayv6']);
811
		unset($wancfg['dhcphostname']);
812
		unset($wancfg['dhcprejectfrom']);
813
		unset($wancfg['dhcp6-duid']);
814
		unset($wancfg['dhcp6-ia-pd-len']);
815
		unset($wancfg['dhcp6-ia-pd-send-hint']);
816
		unset($wancfg['dhcp6prefixonly']);
817
		unset($wancfg['dhcp6usev4iface']);
818
		unset($wancfg['track6-interface']);
819
		unset($wancfg['track6-prefix-id']);
820
		unset($wancfg['prefix-6rd']);
821
		unset($wancfg['prefix-6rd-v4plen']);
822
		unset($wancfg['gateway-6rd']);
823

    
824
		unset($wancfg['adv_dhcp_pt_timeout']);
825
		unset($wancfg['adv_dhcp_pt_retry']);
826
		unset($wancfg['adv_dhcp_pt_select_timeout']);
827
		unset($wancfg['adv_dhcp_pt_reboot']);
828
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
829
		unset($wancfg['adv_dhcp_pt_initial_interval']);
830

    
831
		unset($wancfg['adv_dhcp_pt_values']);
832

    
833
		unset($wancfg['adv_dhcp_send_options']);
834
		unset($wancfg['adv_dhcp_request_options']);
835
		unset($wancfg['adv_dhcp_required_options']);
836
		unset($wancfg['adv_dhcp_option_modifiers']);
837

    
838
		unset($wancfg['adv_dhcp_config_advanced']);
839
		unset($wancfg['adv_dhcp_config_file_override']);
840
		unset($wancfg['adv_dhcp_config_file_override_path']);
841

    
842
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
843
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
844
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
845
		unset($wancfg['adv_dhcp6_interface_statement_script']);
846

    
847
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
848
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
849
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
850
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
851
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
852

    
853
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
854
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
855
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
856
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
857
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
858

    
859
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
860
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
861

    
862
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
863
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
864
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
865
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
866

    
867
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
868
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
869
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
870
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
871
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
872

    
873
		unset($wancfg['adv_dhcp6_config_advanced']);
874
		unset($wancfg['adv_dhcp6_config_file_override']);
875
		unset($wancfg['adv_dhcp6_config_file_override_path']);
876

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

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

    
896
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
897
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
898

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

    
915
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
916
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
917
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
918
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
919
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
920
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
921

    
922
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
923

    
924
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
925
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
926
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
927
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
928

    
929
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
930
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
931
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
932

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

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

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

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

    
1034
				$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1035
				$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1036
				$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1037
				$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1038

    
1039
				$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1040
				$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1041
				$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1042
				$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1043
				$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1044

    
1045
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1046
				$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1047
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1048
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1049
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1050

    
1051
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1052
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1053

    
1054
				$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1055
				$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1056
				$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1057
				$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1058

    
1059
				$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1060
				$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1061
				$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1062
				$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1063
				$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1064

    
1065
				$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1066
				$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1067
				$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1068

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

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

    
1134
		conf_mount_ro();
1135
		write_config();
1136

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

    
1146
		mark_subsystem_dirty('interfaces');
1147

    
1148
		/* regenerate cron settings/crontab file */
1149
		configure_cron();
1150

    
1151
		header("Location: interfaces.php?if={$if}");
1152
		exit;
1153
	}
1154

    
1155
} // end if($_POST)
1156

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

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

    
1298
function check_wireless_mode() {
1299
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1300

    
1301
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1302
		return;
1303

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

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

    
1341
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1342
$shortcut_section = "interfaces";
1343

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

    
1349
?>
1350

    
1351
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1352
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1353
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1354
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1355

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

    
1425
	function show_allcfg(obj) {
1426
		if (obj.checked)
1427
			jQuery('#allcfg').show();
1428
		else
1429
			jQuery('#allcfg').hide();
1430
	}
1431

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

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

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

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

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

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

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

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

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

    
1972
											<br>
1973
											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, '');">
1974
											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, '');">
1975
											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, '');">
1976

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

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

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

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

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

    
2009
													FORM.adv_dhcp_pt_values.value = T.value;
2010
												}
2011

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

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

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

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

    
2066
 									<tr>
2067
 										<td colspan="2" valign="top" height="16"></td>
2068
 									</tr>
2069

    
2070
									<script type="text/javascript">
2071
										function show_adv_dhcp_config(T) {
2072

    
2073
											if (T.checked) T.value = "Selected";
2074
											else T.value = "";
2075

    
2076
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2077
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2078
											else 									show_hide_adv_dhcp('', 'none', 'none');
2079
										}
2080

    
2081
										function show_hide_adv_dhcp(basic, advanced, override) {
2082

    
2083
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2084
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2085
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2086

    
2087
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2088
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2089
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2090

    
2091
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2092
										}
2093

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

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

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

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

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

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

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

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

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

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

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

    
2308
 									<tr>
2309
 										<td colspan="2" valign="top" height="16"></td>
2310
 									</tr>
2311

    
2312
									<script type="text/javascript">
2313
										function show_adv_dhcp6_config(T) {
2314

    
2315
											if (T.checked) T.value = "Selected";
2316
											else T.value = "";
2317

    
2318
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2319
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2320
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2321
										}
2322

    
2323
										function show_hide_adv_dhcp6(basic, advanced, override) {
2324

    
2325
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2326
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2327
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2328
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2329

    
2330
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2331
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2332

    
2333
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2334
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2335
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2336
											}
2337

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

    
2345
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2346
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2347

    
2348
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2349
										}
2350

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

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

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

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

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

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

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

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

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