Project

General

Profile

Download (145 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces.php
5
*/
6
/* ====================================================================
7
 *  Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved. 
8
 *  Copyright (c)  2004-2008 Scott Ullrich
9
 *	Copyright (c) 2006 Daniel S. Haischt
10
 *	Copyright (c) 2008-2010 Ermal Luçi
11
 *
12
 *  Redistribution and use in source and binary forms, with or without modification, 
13
 *  are permitted provided that the following conditions are met: 
14
 *
15
 *  1. Redistributions of source code must retain the above copyright notice,
16
 *	  this list of conditions and the following disclaimer.
17
 *
18
 *  2. Redistributions in binary form must reproduce the above copyright
19
 *	  notice, this list of conditions and the following disclaimer in
20
 *	  the documentation and/or other materials provided with the
21
 *	  distribution. 
22
 *
23
 *  3. All advertising materials mentioning features or use of this software 
24
 *	  must display the following acknowledgment:
25
 *	  "This product includes software developed by the pfSense Project
26
 *	   for use in the pfSense software distribution. (http://www.pfsense.org/). 
27
 *
28
 *  4. The names "pfSense" and "pfSense Project" must not be used to
29
 *	   endorse or promote products derived from this software without
30
 *	   prior written permission. For written permission, please contact
31
 *	   coreteam@pfsense.org.
32
 *
33
 *  5. Products derived from this software may not be called "pfSense"
34
 *	  nor may "pfSense" appear in their names without prior written
35
 *	  permission of the Electric Sheep Fencing, LLC.
36
 *
37
 *  6. Redistributions of any form whatsoever must retain the following
38
 *	  acknowledgment:
39
 *
40
 *  "This product includes software developed by the pfSense Project
41
 *  for use in the pfSense software distribution (http://www.pfsense.org/).
42
 *
43
 *  THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
44
 *  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46
 *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
47
 *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49
 *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51
 *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52
 *  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54
 *  OF THE POSSIBILITY OF SUCH DAMAGE.
55
 *
56
 *  ====================================================================
57
 *
58
 */
59
/*
60
	pfSense_BUILDER_BINARIES:	/usr/sbin/arp
61
	pfSense_MODULE:	interfaces
62
*/
63

    
64
##|+PRIV
65
##|*IDENT=page-interfaces
66
##|*NAME=Interfaces: WAN page
67
##|*DESCR=Allow access to the 'Interfaces' page.
68
##|*MATCH=interfaces.php*
69
##|-PRIV
70

    
71
require_once("guiconfig.inc");
72
require_once("ipsec.inc");
73
require_once("functions.inc");
74
require_once("captiveportal.inc");
75
require_once("filter.inc");
76
require_once("shaper.inc");
77
require_once("rrd.inc");
78
require_once("vpn.inc");
79
require_once("xmlparse_attr.inc");
80

    
81

    
82
if (isset($_POST['referer'])) {
83
	$referer = $_POST['referer'];
84
} else {
85
	$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces.php');
86
}
87

    
88
// Get configured interface list
89
$ifdescrs = get_configured_interface_with_descr(false, true);
90

    
91
$if = "wan";
92
if ($_REQUEST['if']) {
93
	$if = $_REQUEST['if'];
94
}
95

    
96
if (empty($ifdescrs[$if])) {
97
	header("Location: interfaces.php");
98
	exit;
99
}
100

    
101
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
102
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
103
define("CRON_DAILY_PATTERN", "0 0 * * *");
104
define("CRON_HOURLY_PATTERN", "0 * * * *");
105

    
106
if (!is_array($pconfig)) {
107
	$pconfig = array();
108
}
109

    
110
if (!is_array($config['ppps'])) {
111
	$config['ppps'] = array();
112
}
113
if (!is_array($config['ppps']['ppp'])) {
114
	$config['ppps']['ppp'] = array();
115
}
116
$a_ppps = &$config['ppps']['ppp'];
117

    
118
function remove_bad_chars($string) {
119
	return preg_replace('/[^a-z_0-9]/i', '', $string);
120
}
121

    
122
if (!is_array($config['gateways']['gateway_item'])) {
123
	$config['gateways']['gateway_item'] = array();
124
}
125
$a_gateways = &$config['gateways']['gateway_item'];
126

    
127
$wancfg = &$config['interfaces'][$if];
128
$old_wancfg = $wancfg;
129
$old_wancfg['realif'] = get_real_interface($if);
130
$old_ppps = $a_ppps;
131
// Populate page descr if it does not exist.
132
if ($if == "wan" && !$wancfg['descr']) {
133
	$wancfg['descr'] = "WAN";
134
} else if ($if == "lan" && !$wancfg['descr']) {
135
	$wancfg['descr'] = "LAN";
136
}
137

    
138
/* NOTE: The code here is used to set the $pppid for the curious */
139
foreach ($a_ppps as $pppid => $ppp) {
140
	if ($wancfg['if'] == $ppp['if']) {
141
		break;
142
	}
143
}
144

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

    
147
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
148
	$pconfig['pppid'] = $pppid;
149
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
150
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
151
	if ($a_ppps[$pppid]['type'] == "ppp") {
152
		$pconfig['ppp_username'] = $a_ppps[$pppid]['username'];
153
		$pconfig['ppp_password'] = base64_decode($a_ppps[$pppid]['password']);
154

    
155
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
156
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
157
	} else if ($a_ppps[$pppid]['type'] == "pppoe") {
158
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
159
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
160
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
161
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
162
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
163

    
164
		/* ================================================ */
165
		/* = force a connection reset at a specific time? = */
166
		/* ================================================ */
167

    
168
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
169
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
170
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
171
			if ($itemhash) {
172
				$cronitem = $itemhash['ITEM'];
173
			}
174
			if (isset($cronitem)) {
175
				$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
176
			} else {
177
				$resetTime = NULL;
178
			}
179
			//log_error("ResetTime:".$resetTime);
180
			if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
181
				if ($cronitem) {
182
					$pconfig['pppoe_pr_custom'] = true;
183
					$pconfig['pppoe_resetminute'] = $cronitem['minute'];
184
					$pconfig['pppoe_resethour'] = $cronitem['hour'];
185
					if ($cronitem['mday'] != "*" && $cronitem['month'] != "*") {
186
						$pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y");
187
					}
188
				}
189
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
190
				$pconfig['pppoe_pr_preset'] = true;
191
				switch ($resetTime) {
192
					case CRON_MONTHLY_PATTERN:
193
						$pconfig['pppoe_monthly'] = true;
194
						break;
195
					case CRON_WEEKLY_PATTERN:
196
						$pconfig['pppoe_weekly'] = true;
197
						break;
198
					case CRON_DAILY_PATTERN:
199
						$pconfig['pppoe_daily'] = true;
200
						break;
201
					case CRON_HOURLY_PATTERN:
202
						$pconfig['pppoe_hourly'] = true;
203
						break;
204
				}
205
			}
206
		} // End force pppoe reset at specific time
207
		// End if type == pppoe
208
	} else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp") {
209
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
210
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
211
		$pconfig['pptp_local'] = explode(",", $a_ppps[$pppid]['localip']);
212
		$pconfig['pptp_subnet'] = explode(",", $a_ppps[$pppid]['subnet']);
213
		$pconfig['pptp_remote'] = explode(",", $a_ppps[$pppid]['gateway']);
214
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
215
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
216
	}
217
} else {
218
	$pconfig['ptpid'] = interfaces_ptpid_next();
219
	$pppid = count($a_ppps);
220
}
221
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
222
$pconfig['alias-address'] = $wancfg['alias-address'];
223
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
224
$pconfig['dhcprejectfrom'] = $wancfg['dhcprejectfrom'];
225

    
226
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
227
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
228
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
229
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
230
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
231
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
232

    
233
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
234

    
235
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
236
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
237
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
238
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
239

    
240
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
241
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
242
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
243

    
244
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
245
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
246
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
247
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
248

    
249
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
250
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
251
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
252
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
253
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
254

    
255
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
256
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
257
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
258
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
259
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
260

    
261
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
262
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
263

    
264
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
265
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
266
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
267
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
268

    
269
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
270
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
271
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
272
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
273
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
274

    
275
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
276
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
277
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
278

    
279
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
280
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
281
$pconfig['enable'] = isset($wancfg['enable']);
282

    
283
if (is_array($config['aliases']['alias'])) {
284
	foreach ($config['aliases']['alias'] as $alias) {
285
		if ($alias['name'] == $wancfg['descr']) {
286
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $wancfg['descr']);
287
		}
288
	}
289
}
290

    
291
switch ($wancfg['ipaddr']) {
292
	case "dhcp":
293
		$pconfig['type'] = "dhcp";
294
		break;
295
	case "pppoe":
296
	case "pptp":
297
	case "l2tp":
298
	case "ppp":
299
		$pconfig['type'] = $wancfg['ipaddr'];
300
		break;
301
	default:
302
		if (is_ipaddrv4($wancfg['ipaddr'])) {
303
			$pconfig['type'] = "staticv4";
304
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
305
			$pconfig['subnet'] = $wancfg['subnet'];
306
			$pconfig['gateway'] = $wancfg['gateway'];
307
		} else {
308
			$pconfig['type'] = "none";
309
		}
310
		break;
311
}
312

    
313
switch ($wancfg['ipaddrv6']) {
314
	case "slaac":
315
		$pconfig['type6'] = "slaac";
316
		break;
317
	case "dhcp6":
318
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
319
		if (!isset($wancfg['dhcp6-ia-pd-len'])) {
320
			$wancfg['dhcp6-ia-pd-len'] = "none";
321
		}
322
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
323
		$pconfig['dhcp6-ia-pd-send-hint'] = isset($wancfg['dhcp6-ia-pd-send-hint']);
324
		$pconfig['type6'] = "dhcp6";
325
		$pconfig['dhcp6prefixonly'] = isset($wancfg['dhcp6prefixonly']);
326
		$pconfig['dhcp6usev4iface'] = isset($wancfg['dhcp6usev4iface']);
327
		break;
328
	case "6to4":
329
		$pconfig['type6'] = "6to4";
330
		break;
331
	case "track6":
332
		$pconfig['type6'] = "track6";
333
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
334
		if ($wancfg['track6-prefix-id'] == "") {
335
			$pconfig['track6-prefix-id'] = 0;
336
		} else {
337
			$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
338
		}
339
		$pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
340
		break;
341
	case "6rd":
342
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
343
		if ($wancfg['prefix-6rd-v4plen'] == "") {
344
			$wancfg['prefix-6rd-v4plen'] = "0";
345
		}
346
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
347
		$pconfig['type6'] = "6rd";
348
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
349
		break;
350
	default:
351
		if (is_ipaddrv6($wancfg['ipaddrv6'])) {
352
			$pconfig['type6'] = "staticv6";
353
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
354
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
355
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
356
		} else {
357
			$pconfig['type6'] = "none";
358
		}
359
		break;
360
}
361

    
362
// print_r($pconfig);
363

    
364
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
365
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
366
$pconfig['spoofmac'] = $wancfg['spoofmac'];
367
$pconfig['mtu'] = $wancfg['mtu'];
368
$pconfig['mss'] = $wancfg['mss'];
369

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

    
463
if ($_POST['apply']) {
464
	unset($input_errors);
465
	if (!is_subsystem_dirty('interfaces')) {
466
		$input_errors[] = gettext("You have already applied your settings!");
467
	} else {
468
		unlink_if_exists("{$g['tmp_path']}/config.cache");
469
		clear_subsystem_dirty('interfaces');
470

    
471
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
472
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
473
			foreach ($toapplylist as $ifapply => $ifcfgo) {
474
				if (isset($config['interfaces'][$ifapply]['enable'])) {
475
					interface_bring_down($ifapply, false, $ifcfgo);
476
					interface_configure($ifapply, true);
477
				} else {
478
					interface_bring_down($ifapply, true, $ifcfgo);
479
					if (isset($config['dhcpd'][$ifapply]['enable']) ||
480
						isset($config['dhcpdv6'][$ifapply]['enable'])) {
481
						services_dhcpd_configure();
482
					}
483
				}
484
			}
485
		}
486
		/* restart snmp so that it binds to correct address */
487
		services_snmpd_configure();
488

    
489
		/* sync filter configuration */
490
		setup_gateways_monitor();
491

    
492
		clear_subsystem_dirty('interfaces');
493

    
494
		filter_configure();
495

    
496
		enable_rrd_graphing();
497

    
498
		if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0)) {
499
			clear_subsystem_dirty('staticroutes');
500
		}
501
	}
502
	@unlink("{$g['tmp_path']}/.interfaces.apply");
503
	header("Location: interfaces.php?if={$if}");
504
	exit;
505
} else if ($_POST && $_POST['enable'] != "yes") {
506
	unset($wancfg['enable']);
507
	if (isset($wancfg['wireless'])) {
508
		interface_sync_wireless_clones($wancfg, false);
509
	}
510
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
511
	mark_subsystem_dirty('interfaces');
512
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
513
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
514
	} else {
515
		$toapplylist = array();
516
	}
517
	$toapplylist[$if]['ifcfg'] = $wancfg;
518
	$toapplylist[$if]['ppps'] = $a_ppps;
519
	/* we need to be able remove IP aliases for IPv6 */
520
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
521
	header("Location: interfaces.php?if={$if}");
522
	exit;
523
} else if ($_POST) {
524

    
525
	unset($input_errors);
526
	$pconfig = $_POST;
527

    
528
	if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
529
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
530
	} else {
531
		$pconfig['track6-prefix-id'] = 0;
532
	}
533
	conf_mount_rw();
534

    
535
	/* filter out spaces from descriptions */
536
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
537

    
538
	/* okay first of all, cause we are just hiding the PPPoE HTML
539
	 * fields related to PPPoE resets, we are going to unset $_POST
540
	 * vars, if the reset feature should not be used. Otherwise the
541
	 * data validation procedure below, may trigger a false error
542
	 * message.
543
	 */
544
	if (empty($_POST['pppoe-reset-type'])) {
545
		unset($_POST['pppoe_pr_type']);
546
		unset($_POST['pppoe_resethour']);
547
		unset($_POST['pppoe_resetminute']);
548
		unset($_POST['pppoe_resetdate']);
549
		unset($_POST['pppoe_pr_preset_val']);
550
	}
551
	/* description unique? */
552
	foreach ($ifdescrs as $ifent => $ifdescr) {
553
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
554
			$input_errors[] = gettext("An interface with the specified description already exists.");
555
			break;
556
		}
557
	}
558
	if (is_numeric($_POST['descr'])) {
559
		$input_errors[] = gettext("The interface description cannot contain only numbers.");
560
	}
561
	/* input validation */
562
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (!preg_match("/^staticv4/", $_POST['type']))) {
563
		$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.");
564
	}
565
	if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (!preg_match("/^staticv6/", $_POST['type6']))) {
566
		$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.");
567
	}
568

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

    
673
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
674
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
675
			} else {
676
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
677
				if ($track6_prefix_id < 0 || $track6_prefix_id > $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) {
678
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.") .
679
						" ({$_POST['track6-interface']}) - (0) - (" . sprintf('%x', $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) . ")";
680
				} else {
681
					foreach ($ifdescrs as $ifent => $ifdescr) {
682
						if ($if == $ifent) {
683
							continue;
684
						}
685
						if ($config['interfaces'][$ifent]['ipaddrv6'] == 'track6' &&
686
							$config['interfaces'][$ifent]['track6-interface'] == $_POST['track6-interface'] &&
687
							$config['interfaces'][$ifent]['track6-prefix-id'] == $track6_prefix_id) {
688
							$input_errors[] = sprintf(gettext("This track6 prefix ID is already being used in %s."), $ifdescr);
689
						}
690
					}
691
				}
692
			}
693
			break;
694
	}
695

    
696
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
697
	$staticroutes = get_staticroutes(true);
698
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
699
	if ($_POST['ipaddr']) {
700
		if (!is_ipaddrv4($_POST['ipaddr'])) {
701
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
702
		} else {
703
			$where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddr'], $if, true, true, $_POST['subnet']);
704
			if (count($where_ipaddr_configured)) {
705
				$subnet_conflict_text = sprintf(gettext("IPv4 address %s is being used by or overlaps with:"), $_POST['ipaddr'] . "/" . $_POST['subnet']);
706
				foreach ($where_ipaddr_configured as $subnet_conflict) {
707
					$subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
708
				}
709
				$input_errors[] = $subnet_conflict_text;
710
			}
711

    
712
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
713
			if ($_POST['subnet'] < 31) {
714
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
715
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
716
				} else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet'])) {
717
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
718
				}
719
			}
720

    
721
			foreach ($staticroutes as $route_subnet) {
722
				list($network, $subnet) = explode("/", $route_subnet);
723
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
724
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
725
					break;
726
				}
727
				unset($network, $subnet);
728
			}
729
		}
730
	}
731
	if ($_POST['ipaddrv6']) {
732
		if (!is_ipaddrv6($_POST['ipaddrv6'])) {
733
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
734
		} else {
735
			$where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddrv6'], $if, true, true, $_POST['subnetv6']);
736
			if (count($where_ipaddr_configured)) {
737
				$subnet_conflict_text = sprintf(gettext("IPv6 address %s is being used by or overlaps with:"), $_POST['ipaddrv6'] . "/" . $_POST['subnetv6']);
738
				foreach ($where_ipaddr_configured as $subnet_conflict) {
739
					$subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
740
				}
741
				$input_errors[] = $subnet_conflict_text;
742
			}
743

    
744
			foreach ($staticroutes as $route_subnet) {
745
				list($network, $subnet) = explode("/", $route_subnet);
746
				if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
747
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
748
					break;
749
				}
750
				unset($network, $subnet);
751
			}
752
		}
753
	}
754
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
755
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
756
	}
757
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6']))) {
758
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
759
	}
760
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address']))) {
761
		$input_errors[] = gettext("A valid alias IP address must be specified.");
762
	}
763
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
764
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
765
	}
766
	if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom'])) {
767
		$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
768
	}
769
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
770
		$match = false;
771
		foreach ($a_gateways as $gateway) {
772
			if (in_array($_POST['gateway'], $gateway)) {
773
				$match = true;
774
			}
775
		}
776
		foreach ($a_gateways as $gateway) {
777
			if (in_array($_POST['gatewayv6'], $gateway)) {
778
				$match = true;
779
			}
780
		}
781
		if (!$match) {
782
			$input_errors[] = gettext("A valid gateway must be specified.");
783
		}
784
	}
785
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
786
		$input_errors[] = gettext("The service name contains invalid characters.");
787
	}
788
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
789
		$input_errors[] = gettext("The idle timeout value must be an integer.");
790
	}
791
	if ($_POST['pppoe_resethour'] != "" && !is_numericint($_POST['pppoe_resethour']) &&
792
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) {
793
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
794
	}
795
	if ($_POST['pppoe_resetminute'] != "" && !is_numericint($_POST['pppoe_resetminute']) &&
796
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) {
797
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
798
	}
799
	if ($_POST['pppoe_resetdate'] != "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
800
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
801
	}
802
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local']))) {
803
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
804
	}
805
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) {
806
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
807
	}
808
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface]))) {
809
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
810
	}
811
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
812
		$input_errors[] = gettext("The idle timeout value must be an integer.");
813
	}
814
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
815
		$input_errors[] = gettext("A valid MAC address must be specified.");
816
	}
817
	if ($_POST['mtu']) {
818
		if (!is_numericint($_POST['mtu'])) {
819
			$input_errors[] = "MTU must be an integer.";
820
		}
821
		if (substr($wancfg['if'], 0, 3) == 'gif') {
822
			$min_mtu = 1280;
823
			$max_mtu = 8192;
824
		} else {
825
			$min_mtu = 576;
826
			$max_mtu = 9000;
827
		}
828

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

    
833
		unset($min_mtu, $max_mtu);
834

    
835
		if (stristr($wancfg['if'], "_vlan")) {
836
			$realhwif_array = get_parent_interface($wancfg['if']);
837
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
838
			$parent_realhwif = $realhwif_array[0];
839
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
840
			if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
841
				if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu'])) {
842
					$input_errors[] = gettext("The MTU of a VLAN cannot be greater than that of its parent interface.");
843
				}
844
			}
845
		} else {
846
			foreach ($config['interfaces'] as $idx => $ifdata) {
847
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if'])) {
848
					continue;
849
				}
850

    
851
				$realhwif_array = get_parent_interface($ifdata['if']);
852
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
853
				$parent_realhwif = $realhwif_array[0];
854

    
855
				if ($parent_realhwif != $wancfg['if']) {
856
					continue;
857
				}
858

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

    
985
		if ($_POST['passphrase']) {
986
			$passlen = strlen($_POST['passphrase']);
987
			if ($passlen < 8 || $passlen > 63) {
988
				$input_errors[] = gettext("The WPA passphrase must be between 8 and 63 characters long.");
989
			}
990
		}
991
		if ($_POST['wpa_enable'] == "yes") {
992
			if (empty($_POST['passphrase']) && stristr($_POST['wpa_key_mgmt'], "WPA-PSK")) {
993
				$input_errors[] = gettext("A WPA Passphrase must be specified when WPA PSK is enabled.");
994
			}
995
		}
996
	}
997
	if (!$input_errors) {
998
		if ($wancfg['ipaddr'] != $_POST['type']) {
999
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
1000
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
1001
				unset($a_ppps[$pppid]);
1002
			} else if ($wancfg['ipaddr'] == "dhcp") {
1003
				kill_dhclient_process($wancfg['if']);
1004
			}
1005
			if ($wancfg['ipaddrv6'] == "dhcp6") {
1006
				$pid = find_dhcp6c_process($wancfg['if']);
1007
				if ($pid) {
1008
					posix_kill($pid, SIGTERM);
1009
				}
1010
			}
1011
		}
1012
		$ppp = array();
1013
		if ($wancfg['ipaddr'] != "ppp") {
1014
			unset($wancfg['ipaddr']);
1015
		}
1016
		if ($wancfg['ipaddrv6'] != "ppp") {
1017
			unset($wancfg['ipaddrv6']);
1018
		}
1019
		unset($wancfg['subnet']);
1020
		unset($wancfg['gateway']);
1021
		unset($wancfg['subnetv6']);
1022
		unset($wancfg['gatewayv6']);
1023
		unset($wancfg['dhcphostname']);
1024
		unset($wancfg['dhcprejectfrom']);
1025
		unset($wancfg['dhcp6-duid']);
1026
		unset($wancfg['dhcp6-ia-pd-len']);
1027
		unset($wancfg['dhcp6-ia-pd-send-hint']);
1028
		unset($wancfg['dhcp6prefixonly']);
1029
		unset($wancfg['dhcp6usev4iface']);
1030
		unset($wancfg['track6-interface']);
1031
		unset($wancfg['track6-prefix-id']);
1032
		unset($wancfg['prefix-6rd']);
1033
		unset($wancfg['prefix-6rd-v4plen']);
1034
		unset($wancfg['gateway-6rd']);
1035

    
1036
		unset($wancfg['adv_dhcp_pt_timeout']);
1037
		unset($wancfg['adv_dhcp_pt_retry']);
1038
		unset($wancfg['adv_dhcp_pt_select_timeout']);
1039
		unset($wancfg['adv_dhcp_pt_reboot']);
1040
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
1041
		unset($wancfg['adv_dhcp_pt_initial_interval']);
1042

    
1043
		unset($wancfg['adv_dhcp_pt_values']);
1044

    
1045
		unset($wancfg['adv_dhcp_send_options']);
1046
		unset($wancfg['adv_dhcp_request_options']);
1047
		unset($wancfg['adv_dhcp_required_options']);
1048
		unset($wancfg['adv_dhcp_option_modifiers']);
1049

    
1050
		unset($wancfg['adv_dhcp_config_advanced']);
1051
		unset($wancfg['adv_dhcp_config_file_override']);
1052
		unset($wancfg['adv_dhcp_config_file_override_path']);
1053

    
1054
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
1055
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
1056
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
1057
		unset($wancfg['adv_dhcp6_interface_statement_script']);
1058

    
1059
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
1060
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
1061
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
1062
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
1063
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
1064

    
1065
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
1066
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
1067
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
1068
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
1069
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
1070

    
1071
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
1072
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
1073

    
1074
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
1075
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
1076
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
1077
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
1078

    
1079
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
1080
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
1081
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
1082
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
1083
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
1084

    
1085
		unset($wancfg['adv_dhcp6_config_advanced']);
1086
		unset($wancfg['adv_dhcp6_config_file_override']);
1087
		unset($wancfg['adv_dhcp6_config_file_override_path']);
1088

    
1089
		unset($wancfg['pppoe_password']);
1090
		unset($wancfg['pptp_username']);
1091
		unset($wancfg['pptp_password']);
1092
		unset($wancfg['provider']);
1093
		unset($wancfg['ondemand']);
1094
		unset($wancfg['timeout']);
1095
		if (empty($wancfg['pppoe']['pppoe-reset-type'])) {
1096
			unset($wancfg['pppoe']['pppoe-reset-type']);
1097
		}
1098
		unset($wancfg['local']);
1099

    
1100
		unset($wancfg['remote']);
1101
		if (is_array($a_ppps[$pppid]) && in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
1102
			if ($wancfg['ipaddr'] != 'ppp') {
1103
				unset($a_ppps[$pppid]['apn']);
1104
				unset($a_ppps[$pppid]['phone']);
1105
				unset($a_ppps[$pppid]['provider']);
1106
				unset($a_ppps[$pppid]['ondemand']);
1107
			}
1108
			if (in_array($wancfg['ipaddr'], array("pppoe", "pptp", "l2tp"))) {
1109
				unset($a_ppps[$pppid]['localip']);
1110
				unset($a_ppps[$pppid]['subnet']);
1111
				unset($a_ppps[$pppid]['gateway']);
1112
			}
1113
			if ($wancfg['ipaddr'] != 'pppoe') {
1114
				unset($a_ppps[$pppid]['pppoe-reset-type']);
1115
			}
1116
			if ($wancfg['type'] != $_POST['type']) {
1117
				unset($a_ppps[$pppid]['idletimeout']);
1118
			}
1119
		}
1120

    
1121
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
1122
		$wancfg['enable'] = $_POST['enable'] == "yes" ? true : false;
1123

    
1124
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
1125
		switch ($_POST['type']) {
1126
			case "staticv4":
1127
				$wancfg['ipaddr'] = $_POST['ipaddr'];
1128
				$wancfg['subnet'] = $_POST['subnet'];
1129
				if ($_POST['gateway'] != "none") {
1130
					$wancfg['gateway'] = $_POST['gateway'];
1131
				}
1132
				break;
1133
			case "dhcp":
1134
				$wancfg['ipaddr'] = "dhcp";
1135
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
1136
				$wancfg['alias-address'] = $_POST['alias-address'];
1137
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
1138
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
1139

    
1140
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
1141
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
1142
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
1143
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
1144
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
1145
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
1146

    
1147
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
1148

    
1149
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
1150
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
1151
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
1152
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
1153

    
1154
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
1155
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
1156
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
1157

    
1158
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
1159
				if ($gateway_item) {
1160
					$a_gateways[] = $gateway_item;
1161
				}
1162
				break;
1163
			case "ppp":
1164
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1165
				$a_ppps[$pppid]['type'] = $_POST['type'];
1166
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1167
				$a_ppps[$pppid]['ports'] = $_POST['port'];
1168
				$a_ppps[$pppid]['username'] = $_POST['ppp_username'];
1169
				$a_ppps[$pppid]['password'] = base64_encode($_POST['ppp_password']);
1170
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
1171
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
1172
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
1173
				$wancfg['ipaddr'] = $_POST['type'];
1174
				break;
1175

    
1176
			case "pppoe":
1177
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1178
				$a_ppps[$pppid]['type'] = $_POST['type'];
1179
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1180
				if (isset($_POST['ppp_port'])) {
1181
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1182
				} else {
1183
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1184
				}
1185
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
1186
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
1187
				if (!empty($_POST['provider'])) {
1188
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
1189
				} else {
1190
					$a_ppps[$pppid]['provider'] = true;
1191
				}
1192
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
1193
				if (!empty($_POST['pppoe_idletimeout'])) {
1194
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
1195
				} else {
1196
					unset($a_ppps[$pppid]['idletimeout']);
1197
				}
1198

    
1199
				if (!empty($_POST['pppoe-reset-type'])) {
1200
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
1201
				} else {
1202
					unset($a_ppps[$pppid]['pppoe-reset-type']);
1203
				}
1204
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1205
				$wancfg['ipaddr'] = $_POST['type'];
1206
				if ($gateway_item) {
1207
					$a_gateways[] = $gateway_item;
1208
				}
1209

    
1210
				break;
1211
			case "pptp":
1212
			case "l2tp":
1213
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1214
				$a_ppps[$pppid]['type'] = $_POST['type'];
1215
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1216
				if (isset($_POST['ppp_port'])) {
1217
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1218
				} else {
1219
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1220
				}
1221
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
1222
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
1223
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
1224
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
1225
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
1226
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
1227
				if (!empty($_POST['pptp_idletimeout'])) {
1228
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
1229
				} else {
1230
					unset($a_ppps[$pppid]['idletimeout']);
1231
				}
1232
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1233
				$wancfg['ipaddr'] = $_POST['type'];
1234
				if ($gateway_item) {
1235
					$a_gateways[] = $gateway_item;
1236
				}
1237
				break;
1238
			case "none":
1239
				break;
1240
		}
1241
		switch ($_POST['type6']) {
1242
			case "staticv6":
1243
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
1244
				$wancfg['subnetv6'] = $_POST['subnetv6'];
1245
				if ($_POST['gatewayv6'] != "none") {
1246
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
1247
				}
1248
				break;
1249
			case "slaac":
1250
				$wancfg['ipaddrv6'] = "slaac";
1251
				break;
1252
			case "dhcp6":
1253
				$wancfg['ipaddrv6'] = "dhcp6";
1254
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
1255
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
1256
				if ($_POST['dhcp6-ia-pd-send-hint'] == "yes") {
1257
					$wancfg['dhcp6-ia-pd-send-hint'] = true;
1258
				}
1259
				if ($_POST['dhcp6prefixonly'] == "yes") {
1260
					$wancfg['dhcp6prefixonly'] = true;
1261
				}
1262
				if ($_POST['dhcp6usev4iface'] == "yes") {
1263
					$wancfg['dhcp6usev4iface'] = true;
1264
				}
1265

    
1266
				if (!empty($_POST['adv_dhcp6_interface_statement_send_options'])) {
1267
					$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1268
				}
1269
				if (!empty($_POST['adv_dhcp6_interface_statement_request_options'])) {
1270
					$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1271
				}
1272
				if (isset($_POST['adv_dhcp6_interface_statement_information_only_enable'])) {
1273
					$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1274
				}
1275
				if (!empty($_POST['adv_dhcp6_interface_statement_script'])) {
1276
					$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1277
				}
1278

    
1279
				if (isset($_POST['adv_dhcp6_id_assoc_statement_address_enable'])) {
1280
					$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1281
				}
1282
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address'])) {
1283
					$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1284
				}
1285
				if (is_numericint($_POST['adv_dhcp6_id_assoc_statement_address_id'])) {
1286
					$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1287
				}
1288
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_pltime'])) {
1289
					$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1290
				}
1291
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_vltime'])) {
1292
					$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1293
				}
1294

    
1295
				if (isset($_POST['adv_dhcp6_id_assoc_statement_prefix_enable'])) {
1296
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1297
				}
1298
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix'])) {
1299
					$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1300
				}
1301
				if (is_numericint($_POST['adv_dhcp6_id_assoc_statement_prefix_id'])) {
1302
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1303
				}
1304
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'])) {
1305
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1306
				}
1307
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'])) {
1308
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1309
				}
1310

    
1311
				if (is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_id'])) {
1312
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1313
				}
1314
				if (is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_len'])) {
1315
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1316
				}
1317

    
1318
				if (!empty($_POST['adv_dhcp6_authentication_statement_authname'])) {
1319
					$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1320
				}
1321
				if (!empty($_POST['adv_dhcp6_authentication_statement_protocol'])) {
1322
					$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1323
				}
1324
				if (!empty($_POST['adv_dhcp6_authentication_statement_algorithm'])) {
1325
					$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1326
				}
1327
				if (!empty($_POST['adv_dhcp6_authentication_statement_rdm'])) {
1328
					$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1329
				}
1330

    
1331
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyname'])) {
1332
					$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1333
				}
1334
				if (!empty($_POST['adv_dhcp6_key_info_statement_realm'])) {
1335
					$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1336
				}
1337
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyid'])) {
1338
					$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1339
				}
1340
				if (!empty($_POST['adv_dhcp6_key_info_statement_secret'])) {
1341
					$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1342
				}
1343
				if (!empty($_POST['adv_dhcp6_key_info_statement_expire'])) {
1344
					$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1345
				}
1346

    
1347
				if (!empty($_POST['adv_dhcp6_config_advanced'])) {
1348
					$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1349
				}
1350
				if (!empty($_POST['adv_dhcp6_config_file_override'])) {
1351
					$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1352
				}
1353
				if (!empty($_POST['adv_dhcp6_config_file_override_path'])) {
1354
					$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1355
				}
1356

    
1357
				if ($gateway_item) {
1358
					$a_gateways[] = $gateway_item;
1359
				}
1360
				break;
1361
			case "6rd":
1362
				$wancfg['ipaddrv6'] = "6rd";
1363
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1364
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1365
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1366
				if ($gateway_item) {
1367
					$a_gateways[] = $gateway_item;
1368
				}
1369
				break;
1370
			case "6to4":
1371
				$wancfg['ipaddrv6'] = "6to4";
1372
				break;
1373
			case "track6":
1374
				$wancfg['ipaddrv6'] = "track6";
1375
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1376
				if ($_POST['track6-prefix-id--hex'] === "") {
1377
					$wancfg['track6-prefix-id'] = 0;
1378
				} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
1379
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1380
				} else {
1381
					$wancfg['track6-prefix-id'] = 0;
1382
				}
1383
				break;
1384
			case "none":
1385
				break;
1386
		}
1387
		handle_pppoe_reset($_POST);
1388

    
1389
		if ($_POST['blockpriv'] == "yes") {
1390
			$wancfg['blockpriv'] = true;
1391
		} else {
1392
			unset($wancfg['blockpriv']);
1393
		}
1394
		if ($_POST['blockbogons'] == "yes") {
1395
			$wancfg['blockbogons'] = true;
1396
		} else {
1397
			unset($wancfg['blockbogons']);
1398
		}
1399
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1400
		if (empty($_POST['mtu'])) {
1401
			unset($wancfg['mtu']);
1402
		} else {
1403
			$wancfg['mtu'] = $_POST['mtu'];
1404
		}
1405
		if (empty($_POST['mss'])) {
1406
			unset($wancfg['mss']);
1407
		} else {
1408
			$wancfg['mss'] = $_POST['mss'];
1409
		}
1410
		if (empty($_POST['mediaopt'])) {
1411
			unset($wancfg['media']);
1412
			unset($wancfg['mediaopt']);
1413
		} else {
1414
			$mediaopts = explode(' ', $_POST['mediaopt']);
1415
			if ($mediaopts[0] != '') {
1416
				$wancfg['media'] = $mediaopts[0];
1417
			}
1418
			if ($mediaopts[1] != '') {
1419
				$wancfg['mediaopt'] = $mediaopts[1];
1420
			} else {
1421
				unset($wancfg['mediaopt']);
1422
			}
1423
		}
1424
		if (isset($wancfg['wireless'])) {
1425
			handle_wireless_post();
1426
		}
1427

    
1428
		conf_mount_ro();
1429
		write_config();
1430

    
1431
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1432
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1433
		} else {
1434
			$toapplylist = array();
1435
		}
1436
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1437
		$toapplylist[$if]['ppps'] = $old_ppps;
1438
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1439

    
1440
		mark_subsystem_dirty('interfaces');
1441

    
1442
		/* regenerate cron settings/crontab file */
1443
		configure_cron();
1444

    
1445
		header("Location: interfaces.php?if={$if}");
1446
		exit;
1447
	}
1448

    
1449
} // end if ($_POST)
1450

    
1451
function handle_wireless_post() {
1452
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1453
	if (!is_array($wancfg['wireless'])) {
1454
		$wancfg['wireless'] = array();
1455
	}
1456
	$wancfg['wireless']['standard'] = $_POST['standard'];
1457
	$wancfg['wireless']['mode'] = $_POST['mode'];
1458
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1459
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1460
	$wancfg['wireless']['channel'] = $_POST['channel'];
1461
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1462
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1463
	$wancfg['wireless']['distance'] = $_POST['distance'];
1464
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1465
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1466
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1467
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1468
		foreach ($wl_countries_attr as $wl_country) {
1469
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1470
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1471
				break;
1472
			}
1473
		}
1474
	}
1475
	if (!is_array($wancfg['wireless']['wpa'])) {
1476
		$wancfg['wireless']['wpa'] = array();
1477
	}
1478
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1479
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1480
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1481
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1482
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1483
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1484
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1485
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1486
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1487
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1488
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1489
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1490
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1491
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1492
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1493

    
1494
	if ($_POST['persistcommonwireless'] == "yes") {
1495
		if (!is_array($config['wireless'])) {
1496
			$config['wireless'] = array();
1497
		}
1498
		if (!is_array($config['wireless']['interfaces'])) {
1499
			$config['wireless']['interfaces'] = array();
1500
		}
1501
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif])) {
1502
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1503
		}
1504
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif])) {
1505
		unset($config['wireless']['interfaces'][$wlanbaseif]);
1506
	}
1507
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity'])) {
1508
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1509
	} else if (isset($wancfg['wireless']['diversity'])) {
1510
		unset($wancfg['wireless']['diversity']);
1511
	}
1512
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna'])) {
1513
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1514
	} else if (isset($wancfg['wireless']['txantenna'])) {
1515
		unset($wancfg['wireless']['txantenna']);
1516
	}
1517
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna'])) {
1518
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1519
	} else if (isset($wancfg['wireless']['rxantenna'])) {
1520
		unset($wancfg['wireless']['rxantenna']);
1521
	}
1522
	if ($_POST['hidessid_enable'] == "yes") {
1523
		$wancfg['wireless']['hidessid']['enable'] = true;
1524
	} else if (isset($wancfg['wireless']['hidessid']['enable'])) {
1525
		unset($wancfg['wireless']['hidessid']['enable']);
1526
	}
1527
	if ($_POST['mac_acl_enable'] == "yes") {
1528
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1529
	} else if (isset($wancfg['wireless']['wpa']['mac_acl_enable'])) {
1530
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1531
	}
1532
	if ($_POST['rsn_preauth'] == "yes") {
1533
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1534
	} else {
1535
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1536
	}
1537
	if ($_POST['ieee8021x'] == "yes") {
1538
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1539
	} else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable'])) {
1540
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1541
	}
1542
	if ($_POST['wpa_strict_rekey'] == "yes") {
1543
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1544
	} else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey'])) {
1545
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1546
	}	
1547
	if ($_POST['debug_mode'] == "yes") {
1548
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1549
	} else if (isset($wancfg['wireless']['wpa']['debug_mode'])) {
1550
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1551
	}
1552
	if ($_POST['wpa_enable'] == "yes") {
1553
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1554
	} else if (isset($wancfg['wireless']['wpa']['enable'])) {
1555
		unset($wancfg['wireless']['wpa']['enable']);
1556
	}
1557
	if ($_POST['wep_enable'] == "yes") {
1558
		if (!is_array($wancfg['wireless']['wep'])) {
1559
			$wancfg['wireless']['wep'] = array();
1560
		}
1561
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1562
	} else if (isset($wancfg['wireless']['wep'])) {
1563
		unset($wancfg['wireless']['wep']);
1564
	}
1565
	if ($_POST['wme_enable'] == "yes") {
1566
		if (!is_array($wancfg['wireless']['wme'])) {
1567
			$wancfg['wireless']['wme'] = array();
1568
		}
1569
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1570
	} else if (isset($wancfg['wireless']['wme']['enable'])) {
1571
		unset($wancfg['wireless']['wme']['enable']);
1572
	}
1573
	if ($_POST['puremode'] == "11g") {
1574
		if (!is_array($wancfg['wireless']['pureg'])) {
1575
			$wancfg['wireless']['pureg'] = array();
1576
		}
1577
		$wancfg['wireless']['pureg']['enable'] = true;
1578
	} else if ($_POST['puremode'] == "11n") {
1579
		if (!is_array($wancfg['wireless']['puren'])) {
1580
			$wancfg['wireless']['puren'] = array();
1581
		}
1582
		$wancfg['wireless']['puren']['enable'] = true;
1583
	} else {
1584
		if (isset($wancfg['wireless']['pureg'])) {
1585
			unset($wancfg['wireless']['pureg']);
1586
		}
1587
		if (isset($wancfg['wireless']['puren'])) {
1588
			unset($wancfg['wireless']['puren']);
1589
		}
1590
	}
1591
	if ($_POST['apbridge_enable'] == "yes") {
1592
		if (!is_array($wancfg['wireless']['apbridge'])) {
1593
			$wancfg['wireless']['apbridge'] = array();
1594
		}
1595
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1596
	} else if (isset($wancfg['wireless']['apbridge']['enable'])) {
1597
		unset($wancfg['wireless']['apbridge']['enable']);
1598
	}
1599
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1600
		if (!is_array($wancfg['wireless']['turbo'])) {
1601
			$wancfg['wireless']['turbo'] = array();
1602
		}
1603
		$wancfg['wireless']['turbo']['enable'] = true;
1604
	} else if (isset($wancfg['wireless']['turbo']['enable'])) {
1605
		unset($wancfg['wireless']['turbo']['enable']);
1606
	}
1607
	$wancfg['wireless']['wep']['key'] = array();
1608
	for ($i = 1; $i <= 4; $i++) {
1609
		if ($_POST['key' . $i]) {
1610
			$newkey = array();
1611
			$newkey['value'] = $_POST['key' . $i];
1612
			if ($_POST['txkey'] == $i) {
1613
				$newkey['txkey'] = true;
1614
			}
1615
			$wancfg['wireless']['wep']['key'][] = $newkey;
1616
		}
1617
	}
1618
	interface_sync_wireless_clones($wancfg, true);
1619
}
1620

    
1621
function check_wireless_mode() {
1622
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1623

    
1624
	if ($wancfg['wireless']['mode'] == $_POST['mode']) {
1625
		return;
1626
	}
1627

    
1628
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif))) {
1629
		$clone_count = 1;
1630
	} else {
1631
		$clone_count = 0;
1632
	}
1633

    
1634
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1635
		foreach ($config['wireless']['clone'] as $clone) {
1636
			if ($clone['if'] == $wlanbaseif) {
1637
				$clone_count++;
1638
			}
1639
		}
1640
	}
1641

    
1642
	if ($clone_count > 1) {
1643
		$old_wireless_mode = $wancfg['wireless']['mode'];
1644
		$wancfg['wireless']['mode'] = $_POST['mode'];
1645
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1646
			$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']]);
1647
		} else {
1648
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1649
		}
1650
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1651
	}
1652
}
1653

    
1654
// Find all possible media options for the interface
1655
$mediaopts_list = array();
1656
$intrealname = $config['interfaces'][$if]['if'];
1657
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1658
foreach ($mediaopts as $mediaopt) {
1659
	preg_match("/media (.*)/", $mediaopt, $matches);
1660
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)) {
1661
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1662
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1663
	} else {
1664
		// there is only media like "media 1000baseT"
1665
		array_push($mediaopts_list, $matches[1]);
1666
	}
1667
}
1668

    
1669
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1670
$shortcut_section = "interfaces";
1671

    
1672
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1673
$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"));
1674

    
1675
$closehead = false;
1676

    
1677
// Get the MAC address
1678
$ip = $_SERVER['REMOTE_ADDR'];
1679
$mymac = `/usr/sbin/arp -an | grep '('{$ip}')' | head -n 1 | cut -d" " -f4`;
1680
$mymac = str_replace("\n","",$mymac);
1681

    
1682
function build_mediaopts_list() {
1683
	global $mediaopts_list;
1684
	
1685
	$list = [""  =>  "Default (no preference, typically autoselect)", 
1686
			 " " =>  "------- Media Supported by this interface -------"
1687
			];
1688
			
1689
	foreach ($mediaopts_list as $mediaopt) {
1690
		$list[$mediaopt] = $mediaopt;
1691
	}
1692
	
1693
	return($list);
1694
}
1695

    
1696
function build_gateway_list() {
1697
	global $a_gateways;
1698
	
1699
	$list = array("none" => "None");
1700
	foreach ($a_gateways as $gateway) {
1701
		if (($gateway['interface'] == $if) && (is_ipaddrv4($gateway['gateway']))) {
1702
			$list[$gateway['name']] = $gateway['name'] . " - " . $gateway['gateway'];
1703
		}
1704
	}
1705
	
1706
	return($list);
1707
}
1708

    
1709
include("head.inc");
1710

    
1711
if ($input_errors)
1712
	print_input_errors($input_errors);
1713
	
1714
if (is_subsystem_dirty('interfaces'))
1715
	print_info_box_np(sprintf(gettext("The %s configuration has been changed."), $wancfg['descr']) . "<br />" . 
1716
					  gettext("You must apply the changes in order for them to take effect. Don't forget to adjust the DHCP Server range if needed after applying."));
1717
	
1718
if ($savemsg) 
1719
	print_info_box($savemsg, 'success');
1720

    
1721

    
1722
require('classes/Form.class.php');
1723

    
1724
$form = new Form(new Form_Button(
1725
	'Submit',
1726
	gettext("Save")
1727
));
1728

    
1729
$section = new Form_Section('General configuration');
1730

    
1731
$section->addInput(new Form_Checkbox(
1732
	'enable',
1733
	'Enable',
1734
	'Enable interface',
1735
	$pconfig['enable'],
1736
	'yes'
1737
));
1738

    
1739
$section->addInput(new Form_Input(
1740
	'descr',
1741
	'Description',
1742
	'text',
1743
	$pconfig['descr']
1744
))->setHelp('Enter a description (name) for the interface here.');
1745

    
1746
$section->addInput(new Form_Select(
1747
	'type',
1748
	'IPv4 Configuration Type',
1749
	$pconfig['type'],
1750
	$types4
1751
));
1752

    
1753
$section->addInput(new Form_Select(
1754
	'type6',
1755
	'IPv6 Configuration Type',
1756
	$pconfig['type6'],
1757
	$types6
1758
));
1759

    
1760
$macaddress = new Form_Input(
1761
	'mac',
1762
	'MAC Address',
1763
	'text',
1764
	$pconfig['mac'],
1765
	['placeholder' => 'xx:xx:xx:xx:xx:xx']
1766
);
1767

    
1768
$btnmymac = new Form_Button(
1769
	'btnmymac',
1770
	'Copy My MAC'
1771
	);
1772

    
1773
$btnmymac->removeClass('btn-primary')->addClass('btn-success btn-sm');
1774

    
1775
$group = new Form_Group('MAC controls');
1776
$group->add($macaddress);
1777
// $group->add($btnmymac);
1778
$group->setHelp('This field can be used to modify ("spoof") the MAC address of this interface.' . '<br />' . 
1779
				'Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx or leave blank');
1780
$section->add($group);
1781

    
1782
$section->addInput(new Form_Input(
1783
	'mtu',
1784
	'MTU',
1785
	'number',
1786
	$pconfig['mtu']
1787
))->setHelp('If you leave this field blank, the adapter\'s default MTU will be used. ' .
1788
			'This is typically 1500 bytes but can vary in some circumstances.');
1789

    
1790
$section->addInput(new Form_Input(
1791
	'mss',
1792
	'MSS',
1793
	'number',
1794
	$pconfig['mss']
1795
))->setHelp('If you enter a value in this field, then MSS clamping for TCP connections to the value entered above minus 40 (TCP/IP ' .
1796
			'header size) will be in effect.');
1797

    
1798
if (count($mediaopts_list) > 0) {
1799
	$section->addInput(new Form_Select(
1800
		'mediaopt',
1801
		'Speed and Duplex',
1802
		rtrim($mediaopt_from_config),
1803
		build_mediaopts_list()
1804
	))->setHelp('Here you can explicitly set speed and duplex mode for this interface.' . '<br />' .
1805
				'WARNING: You MUST leave this set to autoselect (automatically negotiate speed) unless the port this interface connects to has its speed and duplex forced.');
1806
}
1807
						
1808
$form->add($section);
1809

    
1810
$section = new Form_Section('Static IPv4 configuration');
1811

    
1812
$section->addInput(new Form_IpAddress(
1813
	'ipaddr',
1814
	'IPv4 Address',
1815
	$pconfig['ipaddr']
1816
))->addMask('subnet', $pconfig['subnet'], 32);
1817

    
1818
$group = new Form_Group('IPv4 Upstream gateway');
1819

    
1820
$group->add(new Form_Select(
1821
	'gateway',
1822
	'IPv4 Upstream Gateway',
1823
	$pconfig['gateway'],
1824
	build_gateway_list()
1825
));
1826

    
1827
$group->add(new Form_Button(
1828
	'addgw',
1829
	'Add a new gateway'
1830
))->removeClass('btn-primary');
1831

    
1832
$group->setHelp('If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the "Add" button.' . '<br />' .
1833
				'On local LANs the upstream gateway should be "none". ');
1834

    
1835
$section->add($group);
1836

    
1837
$group = new Form_group('New gateway');
1838

    
1839
$group->add(new Form_Checkbox(
1840
	'defaultgw',
1841
	null,
1842
	'Default gateway',
1843
	($if == "wan" || $if == "WAN")
1844
));
1845

    
1846
$group->add(new Form_Input(
1847
	'name',
1848
	'Gateway name',
1849
	'text',
1850
	$wancfg['descr'] . "GW"
1851
))->setHelp('Name');
1852

    
1853
$group->add(new Form_IpAddress(
1854
	'gatewayip',
1855
	'Gateway IPv4',
1856
	null
1857
))->setHelp('IP address');
1858

    
1859
$group->add(new Form_Input(
1860
	'gatewaydescr',
1861
	'Description',
1862
	'text'
1863
))->setHelp('Description');
1864

    
1865
$group->add(new Form_Button(
1866
	'add',
1867
	'Add'
1868
))->removeClass('btn-primary')->addClass('btn-success');
1869

    
1870
$section->add($group);
1871

    
1872
$form->add($section);
1873

    
1874
$section = new Form_Section('Static IPv6 configuration');
1875

    
1876
$section->addInput(new Form_IpAddress(
1877
	'ipaddrv6',
1878
	'IPv6 address',
1879
	$pconfig['ipaddrv6']
1880
))->addMask('subnetv6', $pconfig['sunbetv6'], 128);
1881

    
1882
$group = new Form_Group('IPv6 Upstream gateway');
1883

    
1884
$group->add(new Form_Select(
1885
	'gatewayv6',
1886
	'IPv4 Upstream Gateway',
1887
	$pconfig['gateway'],
1888
	build_gateway_list()
1889
));
1890

    
1891
$group->add(new Form_Button(
1892
	'addgwv6',
1893
	'Add a new gateway'
1894
))->removeClass('btn-primary');
1895

    
1896
$group->setHelp('If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the "Add" button.' . '<br />' .
1897
				'On local LANs the upstream gateway should be "none". ');
1898
				
1899
$group = new Form_group('IPv6 upstream gateway');
1900

    
1901
$group->add(new Form_Checkbox(
1902
	'defaultgwv6',
1903
	null,
1904
	'Default gateway',
1905
	($if == "wan" || $if == "WAN")
1906
));
1907

    
1908
$group->add(new Form_Input(
1909
	'namev6',
1910
	'Gateway name',
1911
	'text',
1912
	$wancfg['descr'] . "GWv6"
1913
))->setHelp('Name');
1914

    
1915
$group->add(new Form_IpAddress(
1916
	'gatewayipv6',
1917
	'Gateway IPv6',
1918
	null
1919
))->setHelp('IP address');
1920

    
1921
$group->add(new Form_Input(
1922
	'gatewaydescrv6',
1923
	'Description',
1924
	'text'
1925
))->setHelp('Description');
1926

    
1927
$group->add(new Form_Button(
1928
	'addv6',
1929
	'Add'
1930
))->removeClass('btn-primary')->addClass('btn-success');
1931

    
1932
$section->add($group);
1933

    
1934
$form->add($section);
1935

    
1936
// ==== DHCP client configuration =============================
1937

    
1938
$section = new Form_Section('DHCP client configuration');
1939

    
1940
$section->addInput(new Form_Input(
1941
	'dhcphostname',
1942
	'Hostname',
1943
	'text',
1944
	$pconfig['dhcphostname']
1945
))->setHelp('The value in this field is sent as the DHCP client identifier and hostname when requesting a DHCP lease. Some ISPs may require this (for client identification).');
1946

    
1947
$section->addInput(new Form_IpAddress(
1948
	'alias-address',
1949
	'Alias IPv4 address',
1950
	$pconfig['alias-address']
1951
))->addMask('alias-subnet', $pconfig['alias-subnet'], 32)->setHelp('The value in this field is used as a fixed alias IPv4 address by the DHCP client.');
1952

    
1953
$section->addInput(new Form_Input(
1954
	'dhcprejectfrom',
1955
	'Reject leases from',
1956
	'text',
1957
	$pconfig['dhcprejectfrom']
1958
))->setHelp('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. ' .
1959
			'This is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync.');
1960

    
1961
$group = new Form_Group('Protocol timing');
1962

    
1963
$group->add(new Form_Input(
1964
	'adv_dhcp_pt_timeout',
1965
	null,
1966
	'number',
1967
	$pconfig['adv_dhcp_pt_timeout']
1968
))->setHelp('Timeout');
1969

    
1970
$group->add(new Form_Input(
1971
	'adv_dhcp_pt_retry',
1972
	null,
1973
	'number',
1974
	$pconfig['adv_dhcp_pt_retry']
1975
))->setHelp('Retry');
1976

    
1977
$group->add(new Form_Input(
1978
	'adv_dhcp_pt_select_timeout',
1979
	null,
1980
	'number',
1981
	$pconfig['adv_dhcp_pt_select_timeout']
1982
))->setHelp('Select timeout');
1983

    
1984
$group->add(new Form_Input(
1985
	'adv_dhcp_pt_reboot',
1986
	null,
1987
	'number',
1988
	$pconfig['adv_dhcp_pt_reboot']
1989
))->setHelp('Reboot');
1990

    
1991
$group->add(new Form_Input(
1992
	'adv_dhcp_pt_backoff_cutoff',
1993
	null,
1994
	'number',
1995
	$pconfig['adv_dhcp_pt_backoff_cutoff']
1996
))->setHelp('Backoff cutoff');
1997

    
1998
$group->add(new Form_Input(
1999
	'adv_dhcp_pt_initial_interval',
2000
	null,
2001
	'number',
2002
	$pconfig['adv_dhcp_pt_initial_interval']
2003
))->setHelp('Initial interval');
2004

    
2005
$section->add($group);
2006

    
2007
$group = new Form_Group('Presets');
2008

    
2009
$group->add(new Form_Checkbox(
2010
	'adv_dhcp_pt_values',
2011
	null,
2012
	'Free BDS default',
2013
	null,
2014
	'DHCP'
2015
))->displayAsRadio();
2016

    
2017
$group->add(new Form_Checkbox(
2018
	'adv_dhcp_pt_values',
2019
	null,
2020
	'Clear',
2021
	null,
2022
	'Clear'
2023
))->displayAsRadio();
2024

    
2025
$group->add(new Form_Checkbox(
2026
	'adv_dhcp_pt_values',
2027
	null,
2028
	'pfSense Default',
2029
	null,
2030
	'pfSense'
2031
))->displayAsRadio();
2032

    
2033
$group->add(new Form_Checkbox(
2034
	'adv_dhcp_pt_values',
2035
	null,
2036
	'Saved Cfg',
2037
	null,
2038
	'SavedCfg'
2039
))->displayAsRadio();
2040

    
2041
$group->setHelp('The values in these fields are DHCP protocol timings used when requesting a lease.' . '<br />' .
2042
				'<a href="http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#PROTOCOL_TIMING">' . 'See here more information' . '</a>');
2043
				
2044
$section->add($group);
2045

    
2046
$form->add($section);
2047

    
2048
$section = new Form_Section('Lease Requirements and Requests');
2049

    
2050
$section->addInput(new Form_Input(
2051
	'adv_dhcp_send_options',
2052
	'Send options',
2053
	'text',
2054
	$pconfig['adv_dhcp_send_options']
2055
))->sethelp('The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]]' . '<br />' .
2056
			'Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD}' . '<br />' .
2057
			'Where C is U(pper) or L(ower) Case, and D is " :-." Delimiter (space, colon, hyphen, or period) (omitted for none).' . '<br />' .
2058
			'Some ISPs may require certain options be or not be sent.');
2059

    
2060
$section->addInput(new Form_Input(
2061
	'adv_dhcp_request_options',
2062
	'Request options',
2063
	'text',
2064
	$pconfig['adv_dhcp_request_options']
2065
))->sethelp('The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]]' . '<br />' .
2066
			'Some ISPs may require certain options be or not be requested.');
2067

    
2068
$section->addInput(new Form_Input(
2069
	'adv_dhcp_require_options',
2070
	'Request options',
2071
	'text',
2072
	$pconfig['adv_dhcp_require_options']
2073
))->sethelp('The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]]');
2074

    
2075
$section->addInput(new Form_Input(
2076
	'adv_dhcp_option_modifiers',
2077
	'Option modifiers',
2078
	'text',
2079
	$pconfig['adv_dhcp_option_modifiers']
2080
))->sethelp('The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]]' . '<br />' .
2081
			'modifiers: (default, supersede, prepend, append)');
2082

    
2083
$section->addInput(new Form_Input(
2084
	'adv_dhcp_config_file_override_path',
2085
	'Option modifiers',
2086
	'text',
2087
	$pconfig['adv_dhcp_config_file_override_path']
2088
))->sethelp('The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]]' . '<br />' .
2089
			'Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD}' . '<br />' .
2090
			'Where C is U(pper) or L(ower) Case, and D is ":-." Delimiter (space, colon, hyphen, or period) (omitted for none).' . '<br />' .
2091
			'Some ISPs may require certain options be or not be sent.');
2092

    
2093
$form->add($section);
2094

    
2095
// DHCP6 client config
2096

    
2097
$section = new Form_Section('DHCP6 client configuration');
2098
$section->addInput(new Form_Checkbox(
2099
	'dhcp6usev4iface',
2100
	'Use IPv4 connectivity as parent interface',
2101
	'Request a IPv6 prefix/information through the IPv4 connectivity link',
2102
	$pconfig['dhcp6usev4iface']
2103
));
2104

    
2105
$section->addInput(new Form_Checkbox(
2106
	'dhcp6prefixonly',
2107
	'Request only an IPv6 prefix',
2108
	'Only request an IPv6 prefix, do not request an IPv6 address',
2109
	$pconfig['dhcp6prefixonly']
2110
));
2111

    
2112
$section->addInput(new Form_Select(
2113
	'dhcp6-ia-pd-len',
2114
	'DHCPv6 Prefix Delegation size',
2115
	$pconfig['dhcp6-ia-pd-len'],
2116
	array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 3 => "61",  2 => "62", 1 => "63", 0 => "64")
2117
))->setHelp('The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP.');	
2118

    
2119
$section->addInput(new Form_Checkbox(
2120
	'dhcp6-ia-pd-send-hint',
2121
	'Send IPv6 prefix hint',
2122
	'Send an IPv6 prefix hint to indicate the desired prefix size for delegation',
2123
	$pconfig['dhcp6-ia-pd-send-hint']
2124
));
2125

    
2126
$form->add($section);
2127

    
2128
// DHCP6 client config - Advanced
2129

    
2130
$section = new Form_Section('Advanced DHCP6 client configuration');
2131
$section->addInput(new Form_Checkbox(
2132
	'adv_dhcp6_interface_statement_information_only_enable',
2133
	'Information only',
2134
	null,
2135
	false
2136
));
2137

    
2138
$section->addInput(new Form_Input(
2139
	'adv_dhcp6_interface_statement_send_options',
2140
	'Send options',
2141
	'text',
2142
	$pconfig['adv_dhcp6_interface_statement_send_options']
2143
))->sethelp('DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]]' . '<br />' .
2144
			'Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD}' . '<br />' .
2145
			'Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none).' . '<br />' .
2146
			'Some DHCP services may require certain options be or not be sent.');
2147

    
2148
$section->addInput(new Form_Input(
2149
	'adv_dhcp6_interface_statement_request_options',
2150
	'Request Options',
2151
	'text',
2152
	$pconfig['adv_dhcp6_interface_statement_request_options']
2153
))->sethelp('DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]]' . '<br />' .
2154
			'Some DHCP services may require certain options be or not be requested.');
2155
	
2156
$section->addInput(new Form_Input(
2157
	'adv_dhcp6_interface_statement_script',
2158
	'Scripts',
2159
	'text',
2160
	$pconfig['adv_dhcp6_interface_statement_request_options']
2161
))->sethelp('Absolute path to a script invoked on certain conditions including when a reply message is received.' . '<br />' .
2162
			'[/[dirname/[.../]]filename[.ext]].');
2163
	
2164
$group = new Form_Group('Identity Association Statement');
2165

    
2166
$group->add(new Form_Checkbox(
2167
	'adv_dhcp6_id_assoc_statement_address_enable',
2168
	null,
2169
	'Non-Temporary Address Allocation',
2170
	false
2171
));
2172
	
2173
$group->add(new Form_Input(
2174
	'adv_dhcp6_id_assoc_statement_address_id',
2175
	null,
2176
	'text',
2177
	$pconfig['adv_dhcp6_id_assoc_statement_address_id']
2178
))->sethelp('id-assoc na ID');
2179

    
2180
$group->add(new Form_IpAddress(
2181
	'adv_dhcp6_id_assoc_statement_address',
2182
	null,
2183
	$pconfig['adv_dhcp6_id_assoc_statement_address']
2184
))->sethelp('IPv6 address');
2185

    
2186
$group->add(new Form_Input(
2187
	'adv_dhcp6_id_assoc_statement_address_pltime',
2188
	null,
2189
	'text',
2190
	$pconfig['adv_dhcp6_id_assoc_statement_address_pltime']
2191
))->sethelp('pltime');
2192

    
2193
$group->add(new Form_Input(
2194
	'adv_dhcp6_id_assoc_statement_address_vltime',
2195
	null,
2196
	'text',
2197
	$pconfig['adv_dhcp6_id_assoc_statement_address_vltime']
2198
))->sethelp('vltime');
2199

    
2200
$section->add($group);
2201

    
2202
// Prefix delegation	
2203
$group = new Form_Group('');
2204

    
2205
$group->add(new Form_Checkbox(
2206
	'adv_dhcp6_id_assoc_statement_prefix_enable',
2207
	null,
2208
	'Prefix Delegation ',
2209
	false
2210
));
2211
	
2212
$group->add(new Form_Input(
2213
	'adv_dhcp6_id_assoc_statement_prefix_id',
2214
	null,
2215
	'text',
2216
	$pconfig['adv_dhcp6_id_assoc_statement_prefix_id']
2217
))->sethelp('id-assoc pd ID');
2218

    
2219
$group->add(new Form_IpAddress(
2220
	'adv_dhcp6_id_assoc_statement_prefix',
2221
	null,
2222
	$pconfig['adv_dhcp6_id_assoc_statement_prefix']
2223
))->sethelp('IPv6 prefix');
2224

    
2225
$group->add(new Form_Input(
2226
	'adv_dhcp6_id_assoc_statement_prefix_pltime',
2227
	null,
2228
	'text',
2229
	$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime']
2230
))->sethelp('pltime');
2231

    
2232
$group->add(new Form_Input(
2233
	'adv_dhcp6_id_assoc_statement_prefix_vltime',
2234
	null,
2235
	'text',
2236
	$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime']
2237
))->sethelp('vltime');
2238

    
2239
$section->add($group);
2240

    
2241
$group = new Form_Group('Prefix interface statement');
2242

    
2243
$group->add(new Form_Input(
2244
	'adv_dhcp6_prefix_interface_statement_sla_id',
2245
	null,
2246
	'text',
2247
	$pconfig['adv_dhcp6_prefix_interface_statement_sla_id']
2248
))->sethelp('Prefix Interface sla-id');
2249

    
2250
$group->add(new Form_Input(
2251
	'adv_dhcp6_prefix_interface_statement_sla_len',
2252
	null,
2253
	'text',
2254
	$pconfig['adv_dhcp6_prefix_interface_statement_sla_len']
2255
))->sethelp('sla-len');
2256

    
2257
$section->add($group);
2258

    
2259
$group = new Form_Group('Authentication statement');
2260

    
2261
$group->add(new Form_Input(
2262
	'adv_dhcp6_authentication_statement_authname',
2263
	null,
2264
	'text',
2265
	$pconfig['adv_dhcp6_authentication_statement_authname']
2266
))->sethelp('Authname');
2267

    
2268
$group->add(new Form_Input(
2269
	'adv_dhcp6_authentication_statement_protocol',
2270
	null,
2271
	'text',
2272
	$pconfig['adv_dhcp6_authentication_statement_protocol']
2273
))->sethelp('Protocol');
2274

    
2275
$group->add(new Form_Input(
2276
	'adv_dhcp6_authentication_statement_algorithm',
2277
	null,
2278
	'text',
2279
	$pconfig['adv_dhcp6_authentication_statement_algorithm']
2280
))->sethelp('Algorithm');
2281

    
2282
$group->add(new Form_Input(
2283
	'adv_dhcp6_authentication_statement_rdm',
2284
	null,
2285
	'text',
2286
	$pconfig['adv_dhcp6_authentication_statement_rdm']
2287
))->sethelp('RDM');
2288

    
2289
$section->add($group);
2290

    
2291
$group = new Form_Group('Keyinfo statement');
2292

    
2293
$group->add(new Form_Input(
2294
	'adv_dhcp6_key_info_statement_keyname',
2295
	null,
2296
	'text',
2297
	$pconfig['adv_dhcp6_key_info_statement_keyname']
2298
))->sethelp('Keyname');
2299

    
2300
$group->add(new Form_Input(
2301
	'adv_dhcp6_key_info_statement_realm',
2302
	null,
2303
	'text',
2304
	$pconfig['adv_dhcp6_key_info_statement_realm']
2305
))->sethelp('Realm');
2306

    
2307
$section->add($group);
2308

    
2309
$group = new Form_Group('');
2310

    
2311
$group->add(new Form_Input(
2312
	'adv_dhcp6_key_info_statement_keyid',
2313
	null,
2314
	'text',
2315
	$pconfig['adv_dhcp6_key_info_statement_keyid']
2316
))->sethelp('KeyID');
2317

    
2318
$group->add(new Form_Input(
2319
	'adv_dhcp6_key_info_statement_secret',
2320
	null,
2321
	'text',
2322
	$pconfig['adv_dhcp6_key_info_statement_secret']
2323
))->sethelp('Secret');
2324

    
2325
$group->add(new Form_Input(
2326
	'adv_dhcp6_key_info_statement_expire',
2327
	null,
2328
	'text',
2329
	$pconfig['adv_dhcp6_key_info_statement_expire']
2330
))->sethelp('Expire');
2331

    
2332
$section->add($group);
2333

    
2334
$section->addInput(new Form_Input(
2335
	'adv_dhcp6_config_file_override_path',
2336
	'Configuration File Override',
2337
	'text',
2338
	$pconfig['adv_dhcp6_config_file_override_path']
2339
))->setHelp('The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]]' . '<br />' .
2340
			'Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD}' . '<br />' .
2341
			'Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none).' . '<br />' .
2342
			'Some ISPs may require certain options be or not be sent.');
2343

    
2344
$form->add($section);
2345

    
2346
$section = new Form_Section('6RD Configuration');
2347

    
2348
$section->addInput(new Form_Input(
2349
	'prefix-6rd',
2350
	'6RD Prefix',
2351
	'text',
2352
	$pconfig['prefix-6rd']
2353
))->sethelp('6RD IPv6 prefix assigned by your ISP. e.g. "2001:db8::/32"');
2354

    
2355
$section->addInput(new Form_Input(
2356
	'gateway-6rd',
2357
	'6RD Border relay',
2358
	'text',
2359
	$pconfig['prefix-6rd']
2360
))->sethelp('6RD IPv4 gateway address assigned by your ISP');
2361

    
2362
$section->addInput(new Form_Select(
2363
	'prefix-6rd-v4plen',
2364
	'DHCPv6 Prefix Delegation size',
2365
	$pconfig['prefix-6rd-v4plen'],
2366
	array_combine(range(0, 32), range(0,32))
2367
))->setHelp('6RD IPv4 prefix length. Normally specified by the ISP. A value of 0 means we embed the entire IPv4 address in the 6RD prefix..');	
2368

    
2369
$form->add($section);
2370

    
2371
// Track IPv6 ointerface section
2372
$section = new Form_Section('Track IPv6 Interface');
2373

    
2374
function build_ipv6interface_list() {
2375
	$list = array('' => '');
2376
	
2377
	$interfaces = get_configured_interface_with_descr(false, true);
2378
	$dynv6ifs = array();
2379
	
2380
	foreach ($interfaces as $iface => $ifacename) {
2381
		switch ($config['interfaces'][$iface]['ipaddrv6']) {
2382
			case "6to4":
2383
			case "6rd":
2384
			case "dhcp6":
2385
				$dynv6ifs[$iface] = array(
2386
					'name' => $ifacename,
2387
					'ipv6_num_prefix_ids' => pow(2, calculate_ipv6_delegation_length($iface)) - 1
2388
				);
2389
				break;
2390
			default:
2391
				continue;
2392
		}
2393
	}
2394

    
2395
	foreach ($dynv6ifs as $iface => $ifacedata) {
2396
		$list[$iface] = $ifacedata['name'];
2397
		
2398
		$section->addInput(new Form_Input(
2399
			'ipv6-num-prefix-ids-' . $iface,
2400
			null,
2401
			'hidden',
2402
			$ifacedata['ipv6_num_prefix_ids']
2403
		));
2404
	}
2405
	
2406
	return($list);
2407
}
2408

    
2409

    
2410

    
2411
$section->addInput(new Form_Select(
2412
	'prefix-6rd-v4plen',
2413
	'IPv6 Interface',
2414
	$pconfig['prefix-6rd-v4plen'],
2415
	build_ipv6interface_list()
2416
))->setHelp('selects the dynamic IPv6 WAN interface to track for configuration');
2417

    
2418
if ($pconfig['track6-prefix-id'] == "") {
2419
	$pconfig['track6-prefix-id'] = 0;
2420
}
2421

    
2422
$section->addInput(new Form_Input(
2423
	'track6-prefix-id--hex' . $iface,
2424
	'IPv6 Prefix ID',
2425
	'text',
2426
	sprintf("%x", $pconfig['track6-prefix-id'])
2427
))->setHelp('The value in this field is the (Delegated) IPv6 prefix ID. This determines the configurable network ID based on the dynamic IPv6 connection. The default value is 0.');
2428
		
2429
$form->add($section);
2430

    
2431
/// PPP section
2432

    
2433
$section = new Form_Section('PPP Configuration');
2434

    
2435
$section->addInput(new Form_Select(
2436
	'country',
2437
	'Country',
2438
	$pconfig['country'],
2439
	[]
2440
));
2441

    
2442
$section->addInput(new Form_Select(
2443
	'provider_list',
2444
	'Provider',
2445
	$pconfig['provider_list'],
2446
	[]
2447
));
2448

    
2449
$section->addInput(new Form_Select(
2450
	'providerplan',
2451
	'Plan',
2452
	$pconfig['providerplan'],
2453
	[]
2454
))->setHelp('Select to fill in data for your service provider.');
2455

    
2456
$section->addInput(new Form_Input(
2457
	'ppp_username',
2458
	'Username',
2459
	'text',
2460
	$pconfig['ppp_username']
2461
));
2462

    
2463
$section->addInput(new Form_Input(
2464
	'ppp_password',
2465
	'Password',
2466
	'password',
2467
	$pconfig['ppp_password']
2468
));
2469

    
2470
if($pconfig['type'] == 'ppp') {
2471
	$section->addInput(new Form_Input(
2472
		'phone',
2473
		'Phone number',
2474
		'text',
2475
		$pconfig['phone']
2476
	))->setHelp('Typically *99# for GSM networks and #777 for CDMA networks');
2477
}
2478

    
2479
$section->addInput(new Form_Input(
2480
	'apn',
2481
	'Access Point Name (APN)',
2482
	'text',
2483
	$pconfig['apn']
2484
));
2485

    
2486
function build_port_list() {
2487
	$list = array('' => '');
2488
	
2489
	$portlist = glob("/dev/cua*");
2490
	$modems   = glob("/dev/modem*");
2491
	$portlist = array_merge($portlist, $modems);
2492

    
2493
	foreach ($portlist as $port) {
2494
		if (preg_match("/\.(lock|init)$/", $port)) {
2495
			continue;
2496
		}
2497

    
2498
	$list[trim($port)] = $port;
2499
	}
2500
	
2501
	return($list);											
2502
}	
2503
$section->addInput(new Form_Select(
2504
	'port',
2505
	'Modem port',
2506
	$pconfig['port'],
2507
	build_port_list()
2508
));
2509
	
2510
if (isset($pconfig['pppid'])) {
2511
	$section->addInput(new Form_StaticText(
2512
		'Advanced PPP',
2513
		'<a href="/interfaces_ppps_edit.php?id=' . htmlspecialchars($pconfig['pppid']). '" class="navlnk">' . gettext("Click here to edit PPP configuration") . '</a>'
2514
	));
2515
}	else {
2516
	$section->addInput(new Form_StaticText(
2517
		'Advanced PPP',
2518
		'<a href="/interfaces_ppps_edit.php" class="navlnk">' . gettext("Click here to create a PPP configuration") . '</a>'
2519
	));	
2520
}		
2521
				
2522
$form->add($section);
2523

    
2524
// PPPoE configuration
2525
$section = new Form_Section('PPPoE Configuration');
2526

    
2527
$section->addInput(new Form_Input(
2528
	'pppoe_username',
2529
	'Username',
2530
	'text',
2531
	$pconfig['pppoe_username']
2532
));
2533

    
2534
$section->addInput(new Form_Input(
2535
	'pppoe_password',
2536
	'Password',
2537
	'password',
2538
	$pconfig['pppoe_password']
2539
));
2540

    
2541
$section->addInput(new Form_Input(
2542
	'provider',
2543
	'Service name',
2544
	'text',
2545
	$pconfig['provider']
2546
))->setHelp('This field can usually be left empty');
2547

    
2548
$section->addInput(new Form_Checkbox(
2549
	'pppoe_dialondemand',
2550
	'Dial on demand',
2551
	'Enable Dial-On-Demand mode ',
2552
	$pconfig['pppoe_dialondemand'],
2553
	'enable'
2554
));
2555

    
2556
$section->addInput(new Form_Input(
2557
	'pppoe_idletimeout',
2558
	'Idle timeout',
2559
	'number',
2560
	$pconfig['pppoe_idletimeout'],
2561
	[min => 0]
2562
))->setHelp('If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. ' .
2563
			'An idle timeout of zero disables this feature.');
2564

    
2565
$section->addInput(new Form_Select(
2566
	'pppoe-reset-type',
2567
	'Periodic reset',
2568
	$pconfig['pppoe-reset-type'],
2569
	['' => 'Disabled', 'custom' => 'Custom', 'preset' => 'Pre-set']
2570
))->setHelp('Select a reset timing type');
2571

    
2572
$group = new Form_Group('Custom reest');
2573

    
2574
$group->add(new Form_Input(
2575
	'pppoe_resethour',
2576
	null,
2577
	'number',
2578
	$pconfig['pppoe_resethour'],
2579
	[min => 0, max => 23]
2580
))->setHelp('Hour (0-23)');
2581

    
2582
$group->add(new Form_Input(
2583
	'pppoe_resetminute',
2584
	null,
2585
	'number',
2586
	$pconfig['pppoe_resetminute'],
2587
	[min => 0, max => 59]
2588
))->setHelp('Minutes (0-59)');
2589

    
2590
// ToDo: Need a date-picker here
2591
$group->add(new Form_Input(
2592
	'pppoe_resetdate',
2593
	null,
2594
	'text',
2595
	$pconfig['pppoe_resetdate']
2596
))->setHelp('Specific date (mm/dd/yyyy)');
2597

    
2598
$group->setHelp('If you leave the date field empty, the reset will be executed each day at the time you specified using the minutes and hour field');
2599

    
2600
$section->add($group);
2601

    
2602
$group = new Form_MultiCheckboxGroup('cron based reset');
2603

    
2604
$group->add(new Form_MultiCheckbox(
2605
	'pppoe_pr_preset_val',
2606
	null,
2607
	'Reset at each month ("0 0 1 * *")',
2608
	$pconfig['pppoe_monthly'],
2609
	'monthly'
2610
))->displayAsRadio();
2611

    
2612
$group->add(new Form_MultiCheckbox(
2613
	'pppoe_pr_preset_val',
2614
	null,
2615
	'Reset at each month ("0 0 * * 0")',
2616
	$pconfig['pppoe_weekly'],
2617
	'weekly'
2618
))->displayAsRadio();
2619

    
2620
$group->add(new Form_MultiCheckbox(
2621
	'pppoe_pr_preset_val',
2622
	null,
2623
	'Reset at each month ("0 0 * * *")',
2624
	$pconfig['pppoe_daily'],
2625
	'daily'
2626
))->displayAsRadio();
2627

    
2628
$group->add(new Form_MultiCheckbox(
2629
	'pppoe_pr_preset_val',
2630
	null,
2631
	'Reset at each month ("0 * * * *")',
2632
	$pconfig['pppoe_hourly'],
2633
	'hourly'
2634
))->displayAsRadio();
2635

    
2636
$section->add($group);
2637

    
2638
if (isset($pconfig['pppid'])) {
2639
	$section->addInput(new Form_StaticText(
2640
		'Advanced and MLPPP',
2641
		'<a href="/interfaces_ppps_edit.php?id=' . htmlspecialchars($pconfig['pppid']) . '" class="navlnk">Click here for additional PPPoE configuration options. Save first if you made changes.</a>'
2642
	));
2643
} else {
2644
	$section->addInput(new Form_StaticText(
2645
		'Advanced and MLPPP',
2646
		'<a href="/interfaces_ppps_edit.php" class="navlnk">Click here for additional PPPoE configuration options and for MLPPP configuration.</a>'
2647
	));	
2648
}
2649

    
2650
$form->add($section);
2651

    
2652
// PPTP & L2TP Configuration section
2653
$section = new Form_Section('PPTP/L2TP Configuraion');
2654

    
2655
$section->addInput(new Form_Input(
2656
	'pptp_username',
2657
	'Username',
2658
	'text',
2659
	$pconfig['pptp_username']
2660
));
2661

    
2662
$section->addInput(new Form_Input(
2663
	'pptp_password',
2664
	'Password',
2665
	'password',
2666
	$pconfig['pptp_password']
2667
));
2668

    
2669
$section->addInput(new Form_IpAddress(
2670
	'pptp_local',
2671
	'Local IP address',
2672
	$pconfig['pptp_local']
2673
))->addMask('pptp_subnet', $pconfig['pptp_subnet'][0]);
2674

    
2675
$section->addInput(new Form_IpAddress(
2676
	'pptp_remote',
2677
	'Remote IP address',
2678
	$pconfig['pptp_remote']
2679
));
2680

    
2681
$section->addInput(new Form_Checkbox(
2682
	'pptp_dialondemand',
2683
	'Dial on demand',
2684
	'Enable Dial-On-Demand mode ',
2685
	$pconfig['pptp_dialondemand'],
2686
	'enable'
2687
))->setHelp('This option causes the interface to operate in dial-on-demand mode, allowing you to have a virtual full time connection. ' . 
2688
			'The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected.');
2689

    
2690
$section->addInput(new Form_Input(
2691
	'pptp_idletimeout',
2692
	'Idle timeout (seconds)',
2693
	'number',
2694
	$pconfig['pptp_idletimeout'],
2695
	[min => 0]
2696
))->setHelp('If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. ' .
2697
			'An idle timeout of zero disables this feature.');
2698
			
2699
if (isset($pconfig['pppid'])) {
2700
	$section->addInput(new Form_StaticText(
2701
		'Advanced and MLPPP',
2702
		'<a href="/interfaces_ppps_edit.php?id=' . htmlspecialchars($pconfig['pppid']) . '" class="navlnk">Click here for additional PPTP and L2TP configuration options. Save first if you made changes.</a>'
2703
	));
2704
} else {
2705
	$section->addInput(new Form_StaticText(
2706
		'Advanced and MLPPP',
2707
		'<a href="/interfaces_ppps_edit.php" class="navlnk">Click here for additional PPTP and L2TP configuration options.</a>'
2708
	));	
2709
}
2710

    
2711
$form->add($section);
2712

    
2713
// Wireless interface
2714
if (true || isset($wancfg['wireless'])) { // DEBUG
2715

    
2716
$section = new Form_Section('Common wireless configuration - Settings apply to all wireless networks on ' . $wlanbaseif . '.');
2717

    
2718
$form->add($section);
2719
}
2720

    
2721
print($form);
2722
?>
2723
	<form action="interfaces.php" method="post" name="iform" id="iform">
2724
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
2725

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

    
3252
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
3253
						<tr>
3254
							<td width="22%" valign="top">
3255
								&nbsp;
3256
							</td>
3257
							<td width="78%">
3258
								<br />
3259
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
3260
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel")?>" onclick="window.location.href='<?=$referer?>'" />
3261
								<input name="referer" type="hidden" value="<?=$referer?>" />
3262
								<input name="if" type="hidden" id="if" value="<?=htmlspecialchars($if)?>" />
3263
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
3264
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port'])?>" />
3265
								<?php endif; ?>
3266
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid'])?>" />
3267
							</td>
3268
						</tr>
3269
					</table>
3270

    
3271
	</form>
3272
	
3273
<script type="text/javascript">
3274
	//<![CDATA[
3275
events.push(function(){	
3276
	
3277
/*
3278
	function updateType(t) {
3279
		switch (t) {
3280
			case "none": {
3281
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
3282
				break;
3283
			}
3284
			case "staticv4": {
3285
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
3286
				break;
3287
			}
3288
			case "dhcp": {
3289
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
3290
				break;
3291
			}
3292
			case "ppp": {
3293
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
3294
				country_list();
3295
				break;
3296
			}
3297
			case "pppoe": {
3298
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
3299
				break;
3300
			}
3301
			case "l2tp":
3302
			case "pptp": {
3303
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
3304
				jQuery('#pptp').show();
3305
				break;
3306
			}
3307
		}
3308
		if (t != "l2tp" && t != "pptp") {
3309
			jQuery('#'+t).show();
3310
		}
3311
	}
3312
	
3313
	function updateTypeSix(t) {
3314
		if (!isNaN(t[0])) t = '_' + t;
3315
		switch (t) {
3316
			case "none": {
3317
				jQuery('#staticv6, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
3318
				break;
3319
			}
3320
			case "staticv6": {
3321
				jQuery('#none, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
3322
				break;
3323
			}
3324
			case "slaac": {
3325
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #dhcp6').hide();
3326
				break;
3327
			}
3328
			case "dhcp6": {
3329
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #slaac').hide();
3330
				break;
3331
			}
3332
			case "_6rd": {
3333
				jQuery('#none, #dhcp6, #staticv6, #_6to4, #track6, #slaac').hide();
3334
				break;
3335
			}
3336
			case "_6to4": {
3337
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #track6, #slaac').hide();
3338
				break;
3339
			}
3340
			case "track6": {
3341
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #_6to4, #slaac').hide();
3342
				update_track6_prefix();
3343
				break;
3344
			}
3345
		}
3346
		if (t != "l2tp" && t != "pptp") {
3347
			jQuery('#'+t).show();
3348
		}
3349
	}
3350

    
3351
	function show_allcfg(obj) {
3352
		if (obj.checked) {
3353
			jQuery('#allcfg').show();
3354
		} else {
3355
			jQuery('#allcfg').hide();
3356
		}
3357
	}
3358

    
3359
	function show_reset_settings(reset_type) {
3360
		if (reset_type == 'preset') {
3361
			jQuery('#pppoepresetwrap').show();
3362
			jQuery('#pppoecustomwrap').hide();
3363
		} else if (reset_type == 'custom') {
3364
			jQuery('#pppoecustomwrap').show();
3365
			jQuery('#pppoepresetwrap').hide();
3366
		} else {
3367
			jQuery('#pppoecustomwrap').hide();
3368
			jQuery('#pppoepresetwrap').hide();
3369
		}
3370
	}
3371

    
3372
	function show_mon_config() {
3373
		jQuery("#showmonbox").html('');
3374
		jQuery('#showmon').css('display', 'block');
3375
	}
3376

    
3377
	function openwindow(url) {
3378
		var oWin = window.open(url, "pfSensePop", "width=620,height=400,top=150,left=150");
3379
		if (oWin == null || typeof(oWin) == "undefined") {
3380
			return false;
3381
		} else {
3382
			return true;
3383
		}
3384
	}
3385

    
3386
	function country_list() {
3387
		jQuery('#country').children().remove();
3388
		jQuery('#provider_list').children().remove();
3389
		jQuery('#providerplan').children().remove();
3390
		jQuery.ajax("getserviceproviders.php",{
3391
			success: function(response) {
3392
				var responseTextArr = response.split("\n");
3393
				responseTextArr.sort();
3394
				responseTextArr.each( function(value) {
3395
					var option = new Element('option');
3396
					country = value.split(":");
3397
					option.text = country[0];
3398
					option.value = country[1];
3399
					jQuery('#country').append(option);
3400
				});
3401
			}
3402
		});
3403
		jQuery('#trcountry').css('display', "table-row");
3404
	}
3405

    
3406
	function providers_list() {
3407
		jQuery('#provider_list').children().remove();
3408
		jQuery('#providerplan').children().remove();
3409
		jQuery.ajax("getserviceproviders.php",{
3410
			type: 'post',
3411
			data: {country : jQuery('#country').val()},
3412
			success: function(response) {
3413
				var responseTextArr = response.split("\n");
3414
				responseTextArr.sort();
3415
				responseTextArr.each( function(value) {
3416
					var option = new Element('option');
3417
					option.text = value;
3418
					option.value = value;
3419
					jQuery('#provider_list').append(option);
3420
				});
3421
			}
3422
		});
3423
		jQuery('#trprovider').css("display", "table-row");
3424
		jQuery('#trproviderplan').css("display", "none");
3425
	}
3426

    
3427
	function providerplan_list() {
3428
		jQuery('#providerplan').children().remove();
3429
		jQuery('#providerplan').append( new Element('option') );
3430
		jQuery.ajax("getserviceproviders.php",{
3431
			type: 'post',
3432
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val()},
3433
			success: function(response) {
3434
				var responseTextArr = response.split("\n");
3435
				responseTextArr.sort();
3436
				responseTextArr.each( function(value) {
3437
					if (value != "") {
3438
						providerplan = value.split(":");
3439

    
3440
						var option = new Element('option');
3441
						option.text = providerplan[0] + " - " + providerplan[1];
3442
						option.value = providerplan[1];
3443
						jQuery('#providerplan').append(option);
3444
					}
3445
				});
3446
			}
3447
		});
3448
		jQuery('#trproviderplan').css("display", "table-row");
3449
	}
3450

    
3451
	function prefill_provider() {
3452
		jQuery.ajax("getserviceproviders.php",{
3453
			type: 'post',
3454
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val(), plan : jQuery('#providerplan').val()},
3455
			success: function(data, textStatus, response) {
3456
				var xmldoc = response.responseXML;
3457
				var provider = xmldoc.getElementsByTagName('connection')[0];
3458
				jQuery('#ppp_username').val('');
3459
				jQuery('#ppp_password').val('');
3460
				if (provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
3461
					jQuery('#phone').val('#777');
3462
					jQuery('#apn').val('');
3463
				} else {
3464
					jQuery('#phone').val('*99#');
3465
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
3466
				}
3467
				ppp_username = provider.getElementsByTagName('ppp_username')[0].firstChild.data;
3468
				ppp_password = provider.getElementsByTagName('ppp_password')[0].firstChild.data;
3469
				jQuery('#ppp_username').val(ppp_username);
3470
				jQuery('#ppp_password').val(ppp_password);
3471
			}
3472
		});
3473
	}
3474

    
3475
	function update_track6_prefix() {
3476
		var iface = jQuery("#track6-interface").val();
3477
		if (iface == null) {
3478
			return;
3479
		}
3480
		var track6_prefix_ids = jQuery('#ipv6-num-prefix-ids-' + iface).val();
3481
		if (track6_prefix_ids == null) {
3482
			return;
3483
		}
3484
		track6_prefix_ids = parseInt(track6_prefix_ids).toString(16);
3485
		jQuery('#track6-prefix-id-range').html('(<b>hexadecimal</b> from 0 to ' + track6_prefix_ids + ')');
3486
	}
3487

    
3488
		var gatewayip;
3489
		var name;
3490
		var gatewayipv6;
3491
		var namev6;
3492
		function show_add_gateway() {
3493
			document.getElementById("addgateway").style.display = '';
3494
			document.getElementById("addgwbox").style.display = 'none';
3495
			document.getElementById("gateway").style.display = 'none';
3496
			document.getElementById("save").style.display = 'none';
3497
			document.getElementById("cancel").style.display = 'none';
3498
			document.getElementById("gwsave").style.display = '';
3499
			document.getElementById("gwcancel").style.display = '';
3500
			jQuery('#notebox').html("");
3501
		}
3502
		function show_add_gateway_v6() {
3503
			document.getElementById("addgatewayv6").style.display = '';
3504
			document.getElementById("addgwboxv6").style.display = 'none';
3505
			document.getElementById("gatewayv6").style.display = 'none';
3506
			document.getElementById("save").style.display = 'none';
3507
			document.getElementById("cancel").style.display = 'none';
3508
			document.getElementById("gwsave").style.display = '';
3509
			document.getElementById("gwcancel").style.display = '';
3510
			jQuery('#noteboxv6').html("");
3511
		}
3512
		function hide_add_gateway() {
3513
			document.getElementById("addgateway").style.display = 'none';
3514
			document.getElementById("addgwbox").style.display = '';
3515
			document.getElementById("gateway").style.display = '';
3516
			document.getElementById("save").style.display = '';
3517
			document.getElementById("cancel").style.display = '';
3518
			document.getElementById("gwsave").style.display = '';
3519
			document.getElementById("gwcancel").style.display = '';
3520
			jQuery('#status').html('');
3521
		}
3522
		function hide_add_gateway_v6() {
3523
			document.getElementById("addgatewayv6").style.display = 'none';
3524
			document.getElementById("addgwboxv6").style.display = '';
3525
			document.getElementById("gatewayv6").style.display = '';
3526
			document.getElementById("save").style.display = '';
3527
			document.getElementById("cancel").style.display = '';
3528
			document.getElementById("gwsave").style.display = '';
3529
			document.getElementById("gwcancel").style.display = '';
3530
			jQuery('#statusv6').html('');
3531
		}
3532
		function hide_add_gatewaysave() {
3533
			document.getElementById("addgateway").style.display = 'none';
3534
			jQuery('#status').html('<img src="/themes/<?=$g['theme']?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3535
			var iface = jQuery('#if').val();
3536
			name = jQuery('#name').val();
3537
			var descr = jQuery('#gatewaydescr').val();
3538
			gatewayip = jQuery('#gatewayip').val();
3539

    
3540
			var defaultgw = '';
3541
			if (jQuery('#defaultgw').is(':checked')) {
3542
				defaultgw = '&defaultgw=on';
3543
			}
3544
			var url = "system_gateways_edit.php";
3545
			var pars = 'isAjax=true&ipprotocol=inet' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3546
			jQuery.ajax(
3547
				url,
3548
				{
3549
					type: 'post',
3550
					data: pars,
3551
					error: report_failure,
3552
					success: save_callback
3553
				});
3554
		}
3555
		
3556
		function hide_add_gatewaysave_v6() {
3557
			document.getElementById("addgatewayv6").style.display = 'none';
3558
			jQuery('#statusv6').html('<img src="/themes/<?=$g['theme']?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3559
			var iface = jQuery('#if').val();
3560
			name = jQuery('#namev6').val();
3561
			var descr = jQuery('#gatewaydescrv6').val();
3562
			gatewayip = jQuery('#gatewayipv6').val();
3563
			var defaultgw = '';
3564
			if (jQuery('#defaultgwv6').is(':checked')) {
3565
				defaultgw = '&defaultgw=on';
3566
			}
3567
			var url_v6 = "system_gateways_edit.php";
3568
			var pars_v6 = 'isAjax=true&ipprotocol=inet6' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3569
			jQuery.ajax(
3570
				url_v6,
3571
				{
3572
					type: 'post',
3573
					data: pars_v6,
3574
					error: report_failure_v6,
3575
					success: save_callback_v6
3576
				});
3577
		}
3578
		
3579
		function addOption(selectbox, text, value)
3580
		{
3581
			var optn = document.createElement("OPTION");
3582
			optn.text = text;
3583
			optn.value = value;
3584
			selectbox.append(optn);
3585
			selectbox.prop('selectedIndex', selectbox.children().length - 1);
3586
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong><?=gettext("You can manage Gateways"); ?><a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3587
		}
3588
		
3589
		function addOption_v6(selectbox, text, value)
3590
		{
3591
			var optn = document.createElement("OPTION");
3592
			optn.text = text;
3593
			optn.value = value;
3594
			selectbox.append(optn);
3595
			selectbox.prop('selectedIndex', selectbox.children().length - 1);
3596
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong><?=gettext("You can manage Gateways"); ?><a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3597
		}
3598
		
3599
		function report_failure(request, textStatus, errorThrown) {
3600
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3601
				alert(request.responseText);
3602
			} else {
3603
				alert("Sorry, we could not create your IPv4 gateway at this time.");
3604
			}
3605
			hide_add_gateway();
3606
		}
3607
		
3608
		function report_failure_v6(request, textStatus, errorThrown) {
3609
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3610
				alert(request.responseText);
3611
			} else {
3612
				alert("Sorry, we could not create your IPv6 gateway at this time.");
3613
			}
3614
			hide_add_gateway_v6();
3615
		}
3616
		
3617
		function save_callback(response) {
3618
			if (response) {
3619
				document.getElementById("addgateway").style.display = 'none';
3620
				hide_add_gateway();
3621
				var gwtext = escape(name) + " - " + gatewayip;
3622
				addOption(jQuery('#gateway'), gwtext, name);
3623
				// Auto submit form?
3624
				//document.iform.submit();
3625
				//jQuery('#status').html('<img src="/themes/<?=$g['theme']?>/images/misc/loader.gif" alt="loader /">');
3626
			} else {
3627
				report_failure();
3628
			}
3629
		}
3630
		
3631
		function show_advanced_media() {
3632
			document.getElementById("showadvmediabox").innerHTML='';
3633
			aodiv = document.getElementById('showmediaadv');
3634
			aodiv.style.display = "block";
3635
		}
3636
		
3637
		function save_callback_v6(response_v6) {
3638
			if (response_v6) {
3639
				document.getElementById("addgatewayv6").style.display = 'none';
3640
				hide_add_gateway_v6();
3641
				var gwtext_v6 = escape(name) + " - " + gatewayip;
3642
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
3643
				// Auto submit form?
3644
				//document.iform.submit();
3645
				//jQuery('#statusv6').html('<img src="/themes/<?=$g['theme']?>/images/misc/loader.gif" alt="loader" />');
3646
			} else {
3647
				report_failure_v6();
3648
			}
3649
		}
3650
		
3651
		
3652
	function customdhcpptcheckradiobuton(T, BUTTON) {
3653
		for (var i = 0; i < T.length; i++) {
3654
			T[i].checked = false;
3655
			if (T[i].value == BUTTON) T[i].checked = true;
3656
		}
3657
		T.value = BUTTON;
3658
	}
3659

    
3660
	function customdhcpptsetvalues(T, FORM) {
3661
		// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
3662
		if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
3663
		if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
3664
		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'])?>");
3665
		if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
3666
	}
3667

    
3668
	function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
3669
		FORM.adv_dhcp_pt_timeout.value = timeout;
3670
		FORM.adv_dhcp_pt_retry.value = retry;
3671
		FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
3672
		FORM.adv_dhcp_pt_reboot.value = reboot;
3673
		FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
3674
		FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
3675

    
3676
		FORM.adv_dhcp_pt_values.value = T.value;
3677
	}
3678

    
3679
	<!-- Set the adv_dhcp_pt_values radio button from saved config -->
3680
	var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values'])?>";
3681
	if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
3682
	//customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
3683

    
3684
	function show_adv_dhcp_config(T) {
3685

    
3686
		if (T.checked) {
3687
			T.value = "Selected";
3688
		} else {
3689
			T.value = "";
3690
		}
3691

    
3692
		if (document.iform.adv_dhcp_config_file_override.checked) {
3693
			show_hide_adv_dhcp('none', 'none', '');
3694
		} else if (document.iform.adv_dhcp_config_advanced.checked)	{
3695
			show_hide_adv_dhcp('', '', 'none');
3696
		} else {
3697
			show_hide_adv_dhcp('', 'none', 'none');
3698
		}
3699
	}
3700

    
3701
		function show_adv_dhcp6_config(T) {
3702

    
3703
			if (T.checked) {
3704
				T.value = "Selected";
3705
			} else {
3706
				T.value = "";
3707
			}
3708

    
3709
			if (document.iform.adv_dhcp6_config_file_override.checked) {
3710
				show_hide_adv_dhcp6('none', 'none', '');
3711
			} else if (document.iform.adv_dhcp6_config_advanced.checked) {
3712
				show_hide_adv_dhcp6('none', '', 'none');
3713
			} else {
3714
				show_hide_adv_dhcp6('', 'none', 'none');
3715
			}
3716
		}
3717

    
3718
		function show_hide_adv_dhcp6(basic, advanced, override) {
3719
				document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
3720
				document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
3721
				document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
3722
				document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
3723

    
3724
				document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
3725
				document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
3726

    
3727
				document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
3728
				if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked) {
3729
					document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
3730
				}
3731

    
3732
				document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
3733
				document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
3734
				if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked) {
3735
					document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
3736
					document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
3737
				}
3738

    
3739
				document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
3740
				document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
3741

    
3742
				document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
3743
			}
3744

    
3745
			<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
3746
			if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced'])?>" == "Selected") {
3747
				document.iform.adv_dhcp6_config_advanced.checked = true;
3748
			}
3749
			show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
3750

    
3751
			<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
3752
			if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override'])?>" == "Selected") {
3753
				document.iform.adv_dhcp6_config_file_override.checked = true;
3754
			}
3755
			show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
3756

    
3757
			<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
3758
			if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable'])?>" == "Selected") {
3759
				document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
3760
			}
3761
			show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
3762

    
3763
			<!-- Set the adv_dhcp6_id_assoc_statement_address_enable checkbox from saved config -->
3764
			if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_enable'])?>" == "Selected") {
3765
				document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked = true;
3766
			}
3767
			show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_address_enable);
3768

    
3769
			<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
3770
			if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'])?>" == "Selected") {
3771
				document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
3772
			}
3773
			show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
3774
									
3775
	function show_hide_adv_dhcp(basic, advanced, override) {
3776

    
3777
		document.getElementById("show_basic_dhcphostname").style.display = basic;
3778
		document.getElementById("show_basic_dhcpalias-address").style.display = basic;
3779
		document.getElementById("show_basic_dhcprejectlease").style.display = basic;
3780

    
3781
		document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
3782
		document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
3783
		document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
3784

    
3785
		document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
3786
	}
3787

    
3788
	<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
3789
	if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced'])?>" == "Selected") {
3790
		document.iform.adv_dhcp_config_advanced.checked = true;
3791
	}
3792
	show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
3793

    
3794
	<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
3795
	if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override'])?>" == "Selected") {
3796
		document.iform.adv_dhcp_config_file_override.checked = true;
3797
	}
3798
	show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
3799
*/																					
3800
	// Make the ‘Copy My MAC’ button a plain button, not a submit button
3801
	$("#btnmymac").prop('type','button');
3802

    
3803
	// On click, copy the hidden 'mymac' text to the 'mac' input
3804
	$("#btnmymac").click(function() {
3805
		$('#mac').val('<?=$mymac?>');
3806
	});
3807
	
3808
	$('#country').on('change', function() {
3809
		window.location = 'interfaces_ppps_edit.php?id=' + $('#id').val() + '&country=' + this.value + '&type=' + $('#type').val();
3810
	});
3811

    
3812
	$('#provider').on('change', function() {
3813
		window.location = 'interfaces_ppps_edit.php?id=' + $('#id').val() + '&provider=' + this.value + '&type=' + $('#type').val() + '&country=' + $('#country').val();
3814
	});
3815
	
3816
<?php
3817
		echo "show_allcfg(document.iform.enable);";
3818
		echo "updateType('{$pconfig['type']}');\n";
3819
		echo "updateTypeSix('{$pconfig['type6']}');\n";
3820
		?>
3821
	});
3822
	//]]>
3823
	</script>
3824

    
3825

    
3826
	<?php include("foot.inc"); 
(82-82/237)