Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
95

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

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

    
109
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
110
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
111
	}
112

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

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

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

    
183
if (is_array($config['aliases']['alias'])) {
184
	foreach($config['aliases']['alias'] as $alias) {
185
		if($alias['name'] == $wancfg['descr']) {
186
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']);
187
		}
188
	}
189
}
190

    
191
switch($wancfg['ipaddr']) {
192
	case "dhcp":
193
		$pconfig['type'] = "dhcp";
194
		break;
195
	case "carpdev-dhcp":
196
		$pconfig['ipaddr'] = "";
197
		break;
198
	case "pppoe":
199
	case "pptp":
200
	case "l2tp":
201
	case "ppp":
202
		$pconfig['type'] = $wancfg['ipaddr'];
203
		break;
204
	default:
205
		if(is_ipaddr($wancfg['ipaddr'])) {
206
			$pconfig['type'] = "staticv4";
207
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
208
			$pconfig['subnet'] = $wancfg['subnet'];
209
			$pconfig['gateway'] = $wancfg['gateway'];
210
		} else
211
			$pconfig['type'] = "none";
212
		break;
213
}
214

    
215
switch($wancfg['ipaddrv6']) {
216
	case "dhcp6":
217
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
218
		if($wancfg['dhcp6-ia-pd-len'] == "")
219
			$wancfg['dhcp6-ia-pd-len'] = "none";
220
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
221
		$pconfig['type6'] = "dhcp6";
222
		break;
223
	case "6to4":
224
		$pconfig['type6'] = "6to4";
225
		break;
226
	case "track6":
227
		$pconfig['type6'] = "track6";
228
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
229
		$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
230
		break;
231
	case "6rd":
232
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
233
		if($wancfg['prefix-6rd-v4plen'] == "")
234
			$wancfg['prefix-6rd-v4plen'] = "0";
235
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
236
		$pconfig['type6'] = "6rd";
237
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
238
		break;
239
	default:
240
		if(is_ipaddr($wancfg['ipaddrv6'])) {
241
			$pconfig['type6'] = "staticv6";
242
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
243
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
244
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
245
		} else
246
			$pconfig['type6'] = "none";
247
		break;
248
}
249

    
250
// print_r($pconfig);
251

    
252
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
253
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
254
$pconfig['spoofmac'] = $wancfg['spoofmac'];
255
$pconfig['mtu'] = $wancfg['mtu'];
256
$pconfig['mss'] = $wancfg['mss'];
257

    
258
/* Wireless interface? */
259
if (isset($wancfg['wireless'])) {
260
	/* Sync first to be sure it displays the actual settings that will be used */
261
	interface_sync_wireless_clones($wancfg, false);
262
	/* Get wireless modes */
263
	$wlanif = get_real_interface($if);
264
	if (!does_interface_exist($wlanif))
265
		interface_wireless_clone($wlanif, $wancfg);
266
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
267
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
268
	$wl_modes = get_wireless_modes($if);
269
	$wl_chaninfo = get_wireless_channel_info($if);
270
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
271
	$wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna",
272
	                              "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout"));
273
	$wl_regdomain_xml_attr = array();
274
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
275
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
276
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
277
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
278
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
279
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
280
	$pconfig['standard'] = $wancfg['wireless']['standard'];
281
	$pconfig['mode'] = $wancfg['wireless']['mode'];
282
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
283
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
284
	$pconfig['channel'] = $wancfg['wireless']['channel'];
285
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
286
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
287
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
288
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
289
	$pconfig['distance'] = $wancfg['wireless']['distance'];
290
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
291
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
292
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
293
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
294
	if (isset($wancfg['wireless']['puren']['enable']))
295
		$pconfig['puremode'] = '11n';
296
	else if (isset($wancfg['wireless']['pureg']['enable']))
297
		$pconfig['puremode'] = '11g';
298
	else
299
		$pconfig['puremode'] = 'any';
300
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
301
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
302
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
303
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
304
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
305
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
306
	$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
307
	$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
308
	$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
309
	if (is_array($wancfg['wireless']['wpa'])) {
310
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
311
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
312
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
313
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
314
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
315
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
316
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
317
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
318
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
319
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
320
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
321
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
322
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
323
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
324
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
325
	}
326
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
327
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
328
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
329
		$i = 1;
330
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
331
			$pconfig['key' . $i] = $wepkey['value'];
332
			if (isset($wepkey['txkey']))
333
				$pconfig['txkey'] = $i;
334
			$i++;
335
		}
336
		if (!isset($wepkey['txkey']))
337
			$pconfig['txkey'] = 1;
338
	}
339
}
340

    
341
if ($_POST['apply']) {
342
	unset($input_errors);
343
	if (!is_subsystem_dirty('interfaces'))
344
		$intput_errors[] = gettext("You have already applied your settings!");
345
	else {
346
		unlink_if_exists("{$g['tmp_path']}/config.cache");
347
		clear_subsystem_dirty('interfaces');
348

    
349
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
350
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
351
			foreach ($toapplylist as $ifapply => $values) {
352
				if (isset($config['interfaces'][$ifapply]['enable'])) {
353
					/* check if any old addresses need purging */
354
					if(is_ipaddrv6($values['ipaddrv6'])) {
355
						$realif = get_real_interface("$ifapply");
356
						log_error("removing old v6 address {$values['ipaddrv6']} on {$realif}");
357
						mwexec("/sbin/ifconfig {$realif} inet6 {$values['ipaddrv6']} -alias");
358
					}
359
					interface_reconfigure($ifapply, true);
360
				} else {
361

    
362
					interface_bring_down($ifapply);
363
				}
364
			}
365
		}
366
		/* restart snmp so that it binds to correct address */
367
		services_snmpd_configure();
368

    
369
		/* sync filter configuration */
370
		setup_gateways_monitor();
371

    
372
		clear_subsystem_dirty('staticroutes');
373

    
374
		filter_configure();
375

    
376
		enable_rrd_graphing();
377
	}
378
	@unlink("{$g['tmp_path']}/.interfaces.apply");
379
	header("Location: interfaces.php?if={$if}");
380
	exit;
381
} else if ($_POST && $_POST['enable'] != "yes") {
382
	unset($wancfg['enable']);
383
	if (isset($wancfg['wireless']))
384
		interface_sync_wireless_clones($wancfg, false);
385
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
386
	mark_subsystem_dirty('interfaces');
387
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
388
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
389
	} else {
390
		$toapplylist = array();
391
	}
392
	$toapplylist[$if] = array();
393
	/* we need to be able remove IP aliases for IPv6 */
394
	if(($old_wancfg['ipaddrv6'] != $wancfg['ipaddrv6']) && (is_ipaddrv6($old_wancfg['ipaddrv6']))) {
395
		$toapplylist[$if]['ipaddrv6'] = "{$old_wancfg['ipaddrv6']}";
396
	}
397
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
398
	header("Location: interfaces.php?if={$if}");
399
	exit;
400
} else if ($_POST) {
401

    
402
	unset($input_errors);
403
	$pconfig = $_POST;
404
	conf_mount_rw();
405

    
406
	/* filter out spaces from descriptions  */
407
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
408

    
409
	/* okay first of all, cause we are just hiding the PPPoE HTML
410
	 * fields releated to PPPoE resets, we are going to unset $_POST
411
	 * vars, if the reset feature should not be used. Otherwise the
412
	 * data validation procedure below, may trigger a false error
413
	 * message.
414
	 */
415
	if (empty($_POST['pppoe-reset-type'])) {
416
		unset($_POST['pppoe_pr_type']);
417
		unset($_POST['pppoe_resethour']);
418
		unset($_POST['pppoe_resetminute']);
419
		unset($_POST['pppoe_resetdate']);
420
		unset($_POST['pppoe_pr_preset_val']);
421
	}
422
	/* description unique? */
423
	foreach ($ifdescrs as $ifent => $ifdescr) {
424
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
425
			$input_errors[] = gettext("An interface with the specified description already exists.");
426
			break;
427
		}
428
	}
429
	/* input validation */
430
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
431
		$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.");
432
	if (isset($config['dhcpd6']) && isset($config['dhcpd6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
433
		$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.");
434

    
435
	switch(strtolower($_POST['type'])) {
436
		case "staticv4":
437
			$reqdfields = explode(" ", "ipaddr subnet gateway");
438
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
439
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
440
			break;
441
		case "none":
442
			if(is_array($config['virtualip']['vip'])) {
443
				foreach ($config['virtualip']['vip'] as $vip) {
444
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if)
445
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
446
				}
447
			}
448
		case "dhcp":
449
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
450
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
451
			break;
452
		case "ppp":
453
			$reqdfields = explode(" ", "port phone");
454
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
455
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
456
			break;
457
		case "pppoe":
458
			if ($_POST['pppoe_dialondemand']) {
459
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
460
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
461
			} else {
462
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
463
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
464
			}
465
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
466
			break;
467
		case "pptp":
468
			if ($_POST['pptp_dialondemand']) {
469
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
470
				$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"));
471
			} else {
472
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
473
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
474
			}
475
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
476
			break;
477
		case "l2tp":
478
			if ($_POST['pptp_dialondemand']) {
479
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
480
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
481
			} else {
482
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
483
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
484
			}
485
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
486
			break;
487
	}
488
	switch(strtolower($_POST['type6'])) {
489
		case "staticv6":
490
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
491
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
492
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
493
			break;
494
		case "none":
495
			if(is_array($config['virtualip']['vip'])) {
496
				foreach ($config['virtualip']['vip'] as $vip) {
497
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if)
498
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
499
				}
500
			}
501
		case "dhcp6":
502
			if (in_array($wancfg['ipaddrv6'], array()))
503
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
504
			break;
505
		case "6rd":
506
			if (in_array($wancfg['ipaddrv6'], array()))
507
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
508
			break;
509
		case "6to4":
510
			if (in_array($wancfg['ipaddrv6'], array()))
511
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
512
			break;
513
		case "track6":
514
			/* needs to check if $track6-prefix-id is used on another interface */
515
			if (in_array($wancfg['ipaddrv6'], array()))
516
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
517
			break;
518
	}
519

    
520
	
521
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
522
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
523
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr'])))
524
		$input_errors[] = gettext("A valid IPv4 address must be specified.");
525
	if (($_POST['ipaddrv6'] && !is_ipaddr($_POST['ipaddrv6'])))
526
		$input_errors[] = gettext("A valid IPv6 address must be specified.");
527
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
528
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
529
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
530
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
531
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address'])))
532
		$input_errors[] = gettext("A valid alias IP address must be specified.");
533
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
534
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
535
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
536
		$match = false;
537
		foreach($a_gateways as $gateway) {
538
			if(in_array($_POST['gateway'], $gateway)) {
539
				$match = true;
540
			}
541
		}
542
		foreach($a_gateways as $gateway) {
543
			if(in_array($_POST['gatewayv6'], $gateway)) {
544
				$match = true;
545
			}
546
		}
547
		if(!$match) {
548
			$input_errors[] = gettext("A valid gateway must be specified.");
549
		}
550
	}
551
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
552
		$input_errors[] = gettext("The service name contains invalid characters.");
553
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
554
		$input_errors[] = gettext("The idle timeout value must be an integer.");
555
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
556
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
557
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
558
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
559
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
560
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
561
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
562
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
563
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local'])))
564
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
565
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
566
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
567
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
568
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
569
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
570
		$input_errors[] = gettext("The idle timeout value must be an integer.");
571
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
572
		$input_errors[] = gettext("A valid MAC address must be specified.");
573
	if ($_POST['mtu'] && ($_POST['mtu'] < 576))
574
		$input_errors[] = gettext("The MTU must be greater than 576 bytes.");
575
	if ($_POST['mss'] && ($_POST['mss'] < 576))
576
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
577
	/* Wireless interface? */
578
	if (isset($wancfg['wireless'])) {
579
		$reqdfields = array("mode");
580
		$reqdfieldsn = array(gettext("Mode"));
581
		if ($_POST['mode'] == 'hostap') {
582
			$reqdfields[] = "ssid";
583
			$reqdfieldsn[] = gettext("SSID");
584
		}
585
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
586
		check_wireless_mode();
587
		/* loop through keys and enforce size */
588
		for ($i = 1; $i <= 4; $i++) {
589
			if ($_POST['key' . $i]) {
590
				/* 64 bit */
591
				if (strlen($_POST['key' . $i]) == 5)
592
					continue;
593
				if (strlen($_POST['key' . $i]) == 10) {
594
					/* hex key */
595
					if (stristr($_POST['key' . $i], "0x") == false) {
596
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
597
					}
598
					continue;
599
				}
600
				if (strlen($_POST['key' . $i]) == 12) {
601
					/* hex key */
602
					if(stristr($_POST['key' . $i], "0x") == false) {
603
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
604
					}
605
					continue;
606
				}
607
				/* 128 bit */
608
				if (strlen($_POST['key' . $i]) == 13)
609
					continue;
610
				if (strlen($_POST['key' . $i]) == 26) {
611
					/* hex key */
612
					if (stristr($_POST['key' . $i], "0x") == false)
613
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
614
					continue;
615
				}
616
				if(strlen($_POST['key' . $i]) == 28)
617
					continue;
618
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
619
				break;
620
			}
621
		}
622

    
623
		if ($_POST['passphrase']) {
624
                	$passlen = strlen($_POST['passphrase']);
625
                	if ($passlen < 8 || $passlen > 64)
626
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
627
		}
628
	}
629
	if (!$input_errors) {
630
		if ($wancfg['ipaddr'] != $_POST['type']) {
631
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
632
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
633
				unset($a_ppps[$pppid]);
634
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
635
				$pid = find_dhcp6c_process($realif);
636
				if($pid)
637
					posix_kill($pid, SIGTERM);
638
			} else if ($wancfg['ipaddr'] == "dhcp") {
639
				$pid = find_dhclient_process($realif);
640
				if($pid)
641
					posix_kill($pid, SIGTERM);
642
			}
643
				
644
		}
645
		$ppp = array();
646
		if ($wancfg['ipaddr'] != "ppp")
647
			unset($wancfg['ipaddr']);
648
		if ($wancfg['ipaddrv6'] != "ppp")
649
			unset($wancfg['ipaddrv6']);
650
		unset($wancfg['subnet']);
651
		unset($wancfg['gateway']);
652
		unset($wancfg['subnetv6']);
653
		unset($wancfg['gatewayv6']);
654
		unset($wancfg['dhcphostname']);
655
		unset($wancfg['dhcp6-duid']);
656
		unset($wancfg['dhcp6-ia-pd-len']);
657
		unset($wancfg['track6-interface']);
658
		unset($wancfg['track6-prefix-id']);		
659
		unset($wancfg['prefix-6rd']);
660
		unset($wancfg['prefix-6rd-v4plen']);
661
		unset($wancfg['gateway-6rd']);
662
		unset($wancfg['pppoe_password']);
663
		unset($wancfg['pptp_username']);
664
		unset($wancfg['pptp_password']);
665
		unset($wancfg['provider']);
666
		unset($wancfg['ondemand']);
667
		unset($wancfg['timeout']);
668
		if (isset($wancfg['pppoe']['pppoe-reset-type']))
669
			unset($wancfg['pppoe']['pppoe-reset-type']);
670
		unset($wancfg['local']);
671
		
672
		unset($wancfg['remote']);
673
		unset($a_ppps[$pppid]['apn']);
674
		unset($a_ppps[$pppid]['phone']);
675
		unset($a_ppps[$pppid]['localip']);
676
		unset($a_ppps[$pppid]['subnet']);
677
		unset($a_ppps[$pppid]['gateway']);
678
		unset($a_ppps[$pppid]['pppoe-reset-type']);
679
		unset($a_ppps[$pppid]['provider']);
680

    
681
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
682
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
683

    
684
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
685
		 * log messages from appearing. They can also manually add these items */
686
		/* 1st added gateway gets a default bit */
687
		/* FIXME: Add address family check here! IPv6 needs a gateway bit too */
688
		if(!empty($a_gateways)) {
689
			$gateway_item = array();
690
			/* check for duplicates */
691
			$skip = false;
692
			foreach($a_gateways as $item) {
693
				if(($item['interface'] == "$if") && (trim($item['gateway']) == "dynamic")) {
694
					$skip4 = true;
695
				}
696
				if(($item['interface'] == "$if") && (trim($item['gateway']) == "dynamic6")) {
697
					$skip6 = true;
698
				}
699
			}
700
			if($skip4 == false) {
701
				$gateway_item['gateway'] = "dynamic";
702
				$gateway_item['descr'] = sprintf(gettext("Interface %s dynamic IPv4 gateway"),$if);
703
				$gateway_item['name'] = "GW_" . strtoupper($if);
704
				$gateway_item['interface'] = "{$if}";
705
				$gateway_item['family'] = "inet";
706
			} elseif($skip6 == false) {
707
				$gateway_item['gateway'] = "dynamic6";
708
				$gateway_item['descr'] = sprintf(gettext("Interface %s dynamic IPv6 gateway"),$if);
709
				$gateway_item['name'] = "GW_" . strtoupper($if) ."_v6";
710
				$gateway_item['interface'] = "{$if}";
711
				$gateway_item['family'] = "inet6";
712
			} else {
713
				unset($gateway_item);
714
			}
715
		}
716

    
717
		switch($_POST['type']) {
718
			case "staticv4":
719
				$wancfg['ipaddr'] = $_POST['ipaddr'];
720
				$wancfg['subnet'] = $_POST['subnet'];
721
				if ($_POST['gateway'] != "none") {
722
					$wancfg['gateway'] = $_POST['gateway'];
723
				}
724
				break;
725
			case "dhcp":
726
				$wancfg['ipaddr'] = "dhcp";
727
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
728
				$wancfg['alias-address'] = $_POST['alias-address'];
729
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
730
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
731
				if($gateway_item) {
732
					$a_gateways[] = $gateway_item;
733
				}
734
				break;
735
			case "carpdev-dhcp":
736
				$wancfg['ipaddr'] = "carpdev-dhcp";
737
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
738
				$wancfg['alias-address'] = $_POST['alias-address'];
739
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
740
				if($gateway_item) {
741
					$a_gateways[] = $gateway_item;
742
				}
743
				break;
744
			case "ppp":
745
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
746
				$a_ppps[$pppid]['type'] = $_POST['type'];
747
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
748
				$a_ppps[$pppid]['ports'] = $_POST['port'];
749
				$a_ppps[$pppid]['username'] = $_POST['username'];
750
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
751
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
752
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
753
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
754
				$wancfg['ipaddr'] = $_POST['type'];
755
				unset($a_ppps[$pppid]['ondemand']);
756
				unset($a_ppps[$pppid]['idletimeout']);
757
				break;
758

    
759
			case "pppoe":
760
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
761
				$a_ppps[$pppid]['type'] = $_POST['type'];
762
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
763
				if (isset($_POST['ppp_port']))
764
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
765
				else
766
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
767
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
768
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
769
				if (!empty($_POST['provider']))
770
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
771
				else
772
					$a_ppps[$pppid]['provider'] = true;
773
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
774
				if (!empty($_POST['idletimeout']))
775
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
776
				else
777
					unset($a_ppps[$pppid]['idletimeout']);
778

    
779
				if (!empty($_POST['pppoe-reset-type']))
780
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
781
				else
782
					unset($a_ppps[$pppid]['pppoe-reset-type']);
783
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
784
				$wancfg['ipaddr'] = $_POST['type'];
785
				if($gateway_item) {
786
					$a_gateways[] = $gateway_item;
787
				}
788

    
789
				break;
790
			case "pptp":
791
			case "l2tp":
792
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
793
				$a_ppps[$pppid]['type'] = $_POST['type'];
794
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
795
				if (isset($_POST['ppp_port']))
796
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
797
				else
798
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
799
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
800
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
801
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
802
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
803
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
804
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
805
				if (!empty($_POST['idletimeout']))
806
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
807
				else
808
					unset($a_ppps[$pppid]['idletimeout']);
809
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
810
				$wancfg['ipaddr'] = $_POST['type'];
811
				if($gateway_item) {
812
					$a_gateways[] = $gateway_item;
813
				}
814
				break;
815
			case "none":
816
				break;
817
		}
818
		switch($_POST['type6']) {
819
			case "staticv6":
820
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
821
				$wancfg['subnetv6'] = $_POST['subnetv6'];
822
				if ($_POST['gatewayv6'] != "none") {
823
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
824
				}
825
				break;
826
			case "dhcp6":
827
				$wancfg['ipaddrv6'] = "dhcp6";
828
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
829
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
830
				if($gateway_item) {
831
					$a_gateways[] = $gateway_item;
832
				}
833
				break;
834
			case "6rd":
835
				$wancfg['ipaddrv6'] = "6rd";
836
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
837
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
838
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
839
				if($gateway_item) {
840
					$a_gateways[] = $gateway_item;
841
				}
842
				break;
843
			case "6to4":
844
				$wancfg['ipaddrv6'] = "6to4";
845
				break;
846
			case "track6":
847
				$wancfg['ipaddrv6'] = "track6";
848
				$wancfg['track6-interface'] = $_POST['track6-interface'];
849
				$wancfg['track6-prefix-id'] = $_POST['track6-prefix-id'];
850
				break;
851
			case "none":
852
				break;
853
		}
854
		handle_pppoe_reset($_POST);
855

    
856
		if($_POST['blockpriv'] == "yes") {
857
			$wancfg['blockpriv'] = true;
858
		} else {
859
			unset($wancfg['blockpriv']);
860
		}
861
		if($_POST['blockbogons'] == "yes") {
862
			$wancfg['blockbogons'] = true;
863
		} else {
864
			unset($wancfg['blockbogons']);
865
		}
866
		$wancfg['spoofmac'] = $_POST['spoofmac'];
867
		if (empty($_POST['mtu'])) {
868
			unset($wancfg['mtu']);
869
		} else {
870
			$wancfg['mtu'] = $_POST['mtu'];
871
		}
872
		if (empty($_POST['mss'])) {
873
			unset($wancfg['mss']);
874
		} else {
875
			$wancfg['mss'] = $_POST['mss'];
876
		}
877
		if (empty($_POST['mediaopt'])) {
878
			unset($wancfg['media']);
879
			unset($wancfg['mediaopt']);
880
		} else {
881
			$mediaopts = explode(' ', $_POST['mediaopt']);	
882
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
883
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
884
			else { unset($wancfg['mediaopt']); }
885
		}
886
		if (isset($wancfg['wireless'])) {
887
			handle_wireless_post();
888
		}
889

    
890
		conf_mount_ro();
891
		write_config();
892

    
893
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
894
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
895
		} else {
896
			$toapplylist = array();
897
		}
898
		$toapplylist[$if] = array();
899
		/* we need to be able remove IP aliases for IPv6 */
900
		if(($old_wancfg['ipaddrv6'] != $wancfg['ipaddrv6']) && (is_ipaddrv6($old_wancfg['ipaddrv6']))) {
901
			$toapplylist[$if]['ipaddrv6'] = $old_wancfg['ipaddrv6'];
902
		}
903
		
904
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
905

    
906
		mark_subsystem_dirty('interfaces');
907

    
908
		/* regenerate cron settings/crontab file */
909
		configure_cron();
910

    
911
		header("Location: interfaces.php?if={$if}");
912
		exit;
913
	}
914

    
915
} // end if($_POST)
916

    
917
function handle_wireless_post() {
918
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
919
	if (!is_array($wancfg['wireless']))
920
		$wancfg['wireless'] = array();
921
	$wancfg['wireless']['standard'] = $_POST['standard'];
922
	$wancfg['wireless']['mode'] = $_POST['mode'];
923
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
924
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
925
	$wancfg['wireless']['channel'] = $_POST['channel'];
926
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
927
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
928
	$wancfg['wireless']['distance'] = $_POST['distance'];
929
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
930
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
931
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
932
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
933
		foreach($wl_countries_attr as $wl_country) {
934
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
935
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
936
				break;
937
			}
938
		}
939
	}
940
	if (!is_array($wancfg['wireless']['wpa']))
941
		$wancfg['wireless']['wpa'] = array();
942
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
943
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
944
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
945
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
946
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
947
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
948
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
949
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
950
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
951
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
952
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
953
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
954
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
955
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
956
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
957
	
958
	if ($_POST['persistcommonwireless'] == "yes") {
959
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
960
			$config['wireless']['interfaces'][$wlanbaseif] = array();
961
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
962
		unset($config['wireless']['interfaces'][$wlanbaseif]);
963
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
964
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
965
	else if (isset($wancfg['wireless']['diversity']))
966
		unset($wancfg['wireless']['diversity']);
967
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
968
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
969
	else if (isset($wancfg['wireless']['txantenna']))
970
		unset($wancfg['wireless']['txantenna']);
971
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
972
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
973
	else if (isset($wancfg['wireless']['rxantenna']))
974
		unset($wancfg['wireless']['rxantenna']);
975
	if ($_POST['hidessid_enable'] == "yes")
976
		$wancfg['wireless']['hidessid']['enable'] = true;
977
	else if (isset($wancfg['wireless']['hidessid']['enable']))
978
		unset($wancfg['wireless']['hidessid']['enable']);
979
	if ($_POST['mac_acl_enable'] == "yes")
980
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
981
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
982
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
983
	if ($_POST['rsn_preauth'] == "yes")
984
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
985
	else
986
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
987
	if ($_POST['ieee8021x'] == "yes")
988
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
989
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
990
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
991
	if ($_POST['wpa_strict_rekey'] == "yes")
992
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
993
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
994
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
995
	if ($_POST['debug_mode'] == "yes")
996
		$wancfg['wireless']['wpa']['debug_mode'] = true;
997
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
998
		sunset($wancfg['wireless']['wpa']['debug_mode']);
999
	if ($_POST['wpa_enable'] == "yes")
1000
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1001
	else if (isset($wancfg['wireless']['wpa']['enable']))
1002
		unset($wancfg['wireless']['wpa']['enable']);
1003
	if ($_POST['wep_enable'] == "yes") {
1004
		if (!is_array($wancfg['wireless']['wep']))
1005
			$wancfg['wireless']['wep'] = array();
1006
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1007
	} else if (isset($wancfg['wireless']['wep']))
1008
		unset($wancfg['wireless']['wep']);
1009
	if ($_POST['wme_enable'] == "yes") {
1010
		if (!is_array($wancfg['wireless']['wme']))
1011
			$wancfg['wireless']['wme'] = array();
1012
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1013
	} else if (isset($wancfg['wireless']['wme']['enable']))
1014
		unset($wancfg['wireless']['wme']['enable']);
1015
	if ($_POST['puremode'] == "11g") {
1016
		if (!is_array($wancfg['wireless']['pureg']))
1017
			$wancfg['wireless']['pureg'] = array();
1018
		$wancfg['wireless']['pureg']['enable'] = true;
1019
	} else if ($_POST['puremode'] == "11n") {
1020
		if (!is_array($wancfg['wireless']['puren']))
1021
			$wancfg['wireless']['puren'] = array();
1022
		$wancfg['wireless']['puren']['enable'] = true;
1023
	} else {
1024
		if (isset($wancfg['wireless']['pureg']))
1025
			unset($wancfg['wireless']['pureg']);
1026
		if (isset($wancfg['wireless']['puren']))
1027
			unset($wancfg['wireless']['puren']);
1028
	}
1029
	if ($_POST['apbridge_enable'] == "yes") {
1030
		if (!is_array($wancfg['wireless']['apbridge']))
1031
			$wancfg['wireless']['apbridge'] = array();
1032
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1033
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1034
		unset($wancfg['wireless']['apbridge']['enable']);
1035
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1036
		if (!is_array($wancfg['wireless']['turbo']))
1037
			$wancfg['wireless']['turbo'] = array();
1038
		$wancfg['wireless']['turbo']['enable'] = true;
1039
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1040
		unset($wancfg['wireless']['turbo']['enable']);
1041
	$wancfg['wireless']['wep']['key'] = array();
1042
	for ($i = 1; $i <= 4; $i++) {
1043
		if ($_POST['key' . $i]) {
1044
			$newkey = array();
1045
			$newkey['value'] = $_POST['key' . $i];
1046
			if ($_POST['txkey'] == $i)
1047
				$newkey['txkey'] = true;
1048
			$wancfg['wireless']['wep']['key'][] = $newkey;
1049
		}
1050
	}
1051
	interface_sync_wireless_clones($wancfg, true);
1052
}
1053

    
1054
function check_wireless_mode() {
1055
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1056

    
1057
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1058
		return;
1059

    
1060
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1061
		$clone_count = 1;
1062
	else
1063
		$clone_count = 0;
1064
	if (is_array($config['wireless']['clone'])) {
1065
		foreach ($config['wireless']['clone'] as $clone) {
1066
			if ($clone['if'] == $wlanbaseif)
1067
				$clone_count++;
1068
		}
1069
	}
1070
	if ($clone_count > 1) {
1071
		$old_wireless_mode = $wancfg['wireless']['mode'];
1072
		$wancfg['wireless']['mode'] = $_POST['mode'];
1073
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1074
			$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']]);
1075
		} else {
1076
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1077
		}
1078
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1079
	}
1080
}
1081

    
1082
// Find all possible media options for the interface
1083
$mediaopts_list = array();
1084
$intrealname = $config['interfaces'][$if]['if'];
1085
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1086
foreach ($mediaopts as $mediaopt){
1087
	preg_match("/media (.*)/", $mediaopt, $matches);
1088
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1089
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1090
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1091
	}else{
1092
		// there is only media like "media 1000baseT"
1093
		array_push($mediaopts_list, $matches[1]);
1094
	}
1095
}
1096

    
1097
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1098
$statusurl = "status_interfaces.php";
1099

    
1100
$closehead = false;
1101
include("head.inc");
1102
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP") /* , "carpdev-dhcp" => "CarpDev"*/);
1103
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "6rd" => gettext("6rd"), "6to4" => gettext("6to4"), "track6" => gettext("Track Interface"));
1104

    
1105
?>
1106

    
1107
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
1108
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1109
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1110
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1111
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1112

    
1113
<script type="text/javascript">
1114
	function updateType(t) {
1115
		switch(t) {
1116
			case "none": {
1117
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1118
				break;
1119
			}
1120
			case "staticv4": {
1121
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1122
				break;
1123
			}
1124
			case "dhcp": {
1125
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1126
				break;
1127
			}
1128
			case "ppp": {
1129
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1130
				country_list();
1131
				break;
1132
			}
1133
			case "pppoe": {
1134
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1135
				break;
1136
			}
1137
			case "l2tp":
1138
			case "pptp": {
1139
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1140
				jQuery('#pptp').show();
1141
				break;
1142
			}
1143
		}
1144
		if (t != "l2tp" && t != "pptp")
1145
			jQuery('#'+t).show();
1146
	}
1147
	function updateTypeSix(t) {
1148
		switch(t) {
1149
			case "none": {
1150
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6').hide();
1151
				break;
1152
			}
1153
			case "staticv6": {
1154
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6').hide();
1155
				break;
1156
			}
1157
			case "dhcp6": {
1158
				jQuery('#none, #staticv6, #6rd, #6to4, #track6').hide();
1159
				break;
1160
			}
1161
			case "6rd": {
1162
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6').hide();
1163
				break;
1164
			}
1165
			case "6to4": {
1166
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6').hide();
1167
				break;
1168
			}
1169
			case "track6": {
1170
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4').hide();
1171
				break;
1172
			}
1173
		}
1174
		if (t != "l2tp" && t != "pptp")
1175
			jQuery('#'+t).show();
1176
	}
1177

    
1178
	function show_allcfg(obj) {
1179
		if (obj.checked)
1180
			jQuery('#allcfg').show();
1181
		else
1182
			jQuery('#allcfg').hide();
1183
	}
1184

    
1185
	function show_reset_settings(reset_type) {
1186
		if (reset_type == 'preset') {
1187
			jQuery('#pppoepresetwrap').show();
1188
			jQuery('#pppoecustomwrap').hide();
1189
		}
1190
		else if (reset_type == 'custom') {
1191
			jQuery('#pppoecustomwrap').show();
1192
			jQuery('#pppoepresetwrap').hide();
1193
		} else {
1194
			jQuery('#pppoecustomwrap').hide();
1195
			jQuery('#pppoepresetwrap').hide();
1196
		}
1197
	}
1198
	function show_mon_config() {
1199
		jQuery("#showmonbox").html('');
1200
		jQuery('#showmon').css('display','block');
1201
	}
1202

    
1203
	function openwindow(url) {
1204
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1205
		if (oWin==null || typeof(oWin)=="undefined")
1206
			return false;
1207
		else
1208
			return true;
1209
	}
1210
	function country_list() {
1211
		jQuery('#country').children().remove();
1212
		jQuery('#provider').children().remove();
1213
		jQuery('#providerplan').children().remove();
1214
		jQuery.ajax("getserviceproviders.php",{
1215
			success: function(response) {
1216
				var responseTextArr = response.split("\n");
1217
				responseTextArr.sort();
1218
				responseTextArr.each( function(value) {
1219
					var option = new Element('option');
1220
					country = value.split(":");
1221
					option.text = country[0];
1222
					option.value = country[1];
1223
					jQuery('#country').append(option);
1224
				});
1225
			}
1226
		});
1227
		jQuery('#trcountry').css('display',"table-row");
1228
	}
1229

    
1230
	function providers_list() {
1231
		jQuery('#provider').children().remove();
1232
		jQuery('#providerplan').children().remove();
1233
		jQuery.ajax("getserviceproviders.php",{
1234
			type: 'post',
1235
			data: {country : jQuery('#country').val()},
1236
			success: function(response) {
1237
				var responseTextArr = response.split("\n");
1238
				responseTextArr.sort();
1239
				responseTextArr.each( function(value) {
1240
					var option = new Element('option');
1241
					option.text = value;
1242
					option.value = value;
1243
					jQuery('#provider').append(option);
1244
				});
1245
			}
1246
		});
1247
		jQuery('#trprovider').css("display","table-row");
1248
		jQuery('#trproviderplan').css("display","none");
1249
	}
1250

    
1251
	function providerplan_list() {
1252
		jQuery('#providerplan').children().remove();
1253
		jQuery('#providerplan').append( new Element('option') );
1254
		jQuery.ajax("getserviceproviders.php",{
1255
			type: 'post',
1256
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1257
			success: function(response) {
1258
				var responseTextArr = response.split("\n");
1259
				responseTextArr.sort();
1260
				responseTextArr.each( function(value) {
1261
					if(value != "") {
1262
						providerplan = value.split(":");
1263

    
1264
						var option = new Element('option');
1265
						option.text = providerplan[0] + " - " + providerplan[1];
1266
						option.value = providerplan[1];
1267
						jQuery('#providerplan').append(option);
1268
					}
1269
				});
1270
			}
1271
		});
1272
		jQuery('#trproviderplan').css("display","table-row");
1273
	}
1274

    
1275
	function prefill_provider() {
1276
		jQuery.ajax("getserviceproviders.php",{
1277
			type: 'post',
1278
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1279
			success: function(data,textStatus,response) {
1280
				var xmldoc = response.responseXML;
1281
				var provider = xmldoc.getElementsByTagName('connection')[0];
1282
				jQuery('#username').val('');
1283
				jQuery('#password').val('');
1284
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1285
					jQuery('#phone').val('#777');
1286
					jQuery('#apn').val('');
1287
				} else {
1288
					jQuery('#phone').val('*99#');
1289
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1290
				}
1291
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1292
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1293
				jQuery('#username').val(username);
1294
				jQuery('#password').val(password);
1295
			}
1296
		});
1297
	}
1298

    
1299
</script>
1300
</head>
1301
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1302
	<?php include("fbegin.inc"); ?>
1303
	<form action="interfaces.php" method="post" name="iform" id="iform">
1304
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1305
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1306
		<?php print_info_box_np(sprintf(gettext("The %s configuration has been changed."),$wancfg['descr'])."<p>".gettext("You must apply the changes in order for them to take effect.")."<p>".gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?><br />
1307
		<?php endif; ?>
1308
		<?php if ($savemsg) print_info_box($savemsg); ?>
1309
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1310
			<tr>
1311
				<td id="mainarea">
1312
					<div class="tabcont">
1313
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1314
						<tr>
1315
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1316
						</tr>
1317
						<tr>
1318
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1319
							<td width="78%" class="vtable">
1320
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1321
							<strong><?=gettext("Enable Interface"); ?></strong>
1322
							</td>
1323
						</tr>
1324
					</table>
1325
					<div style="display:none;" name="allcfg" id="allcfg">
1326
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1327
						<tr>
1328
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1329
							<td width="78%" class="vtable">
1330
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1331
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1332
							</td>
1333
						</tr>
1334
						<tr>
1335
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1336
							<td class="vtable">
1337
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1338
								<?php
1339
									foreach ($types4 as $key => $opt) {
1340
										echo "<option onClick=\"updateType('{$key}');\"";
1341
										if ($key == $pconfig['type'])
1342
											echo " selected";
1343
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1344
										echo "</option>";
1345
									}
1346
								?>
1347
								</select>
1348
							</td>
1349
						</tr>
1350
						<tr>
1351
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1352
							<td class="vtable">
1353
								<select name="type6" onChange="updateTypeSix(this.value);" class="formselect" id="type6">
1354
								<?php
1355
									foreach ($types6 as $key => $opt) {
1356
										echo "<option onClick=\"updateTypeSix('{$key}');\"";
1357
										if ($key == $pconfig['type6'])
1358
											echo " selected";
1359
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1360
										echo "</option>";
1361
									}
1362
								?>
1363
								</select>
1364
							</td>
1365
						</tr>
1366
						<tr>
1367
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1368
							<td class="vtable">
1369
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1370
								<?php
1371
									$ip = getenv('REMOTE_ADDR');
1372
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1373
									$mac = str_replace("\n","",$mac);
1374
									if($mac):
1375
								?>
1376
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1377
								<?php endif; ?>
1378
								<br>
1379
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1380
								"address of this interface"); ?><br>
1381
								<?=gettext("(may be required with some cable connections)"); ?><br>
1382
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1383
								"or leave blank"); ?>
1384
							</td>
1385
						</tr>
1386
						<tr>
1387
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1388
							<td class="vtable">
1389
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1390
								<br>
1391
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1392
								"be used. This is typically 1500 bytes but can vary in some circumstances."); ?>
1393
							</td>
1394
						</tr>
1395
						<tr>
1396
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1397
							<td class="vtable">
1398
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1399
								<br>
1400
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1401
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1402
								"header size) will be in effect."); ?>
1403
							</td>
1404
						</tr>
1405
						<?php 
1406
						if (count($mediaopts_list) > 0){
1407
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1408
						echo "<tr>";
1409
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1410
							echo '<td class="vtable">';
1411
                                			echo '<div id="showadvmediabox"';
1412
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1413
								else echo '>';
1414
								echo '<input type="button" onClick="show_advanced_media()" value="' . gettext("Advanced") . '"></input> - ' . gettext("Show advanced option");
1415
							echo "</div>";
1416
							echo '<div id="showmediaadv" ';
1417
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1418
							else echo '>';
1419
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1420
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1421
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1422
								foreach($mediaopts_list as $mediaopt){
1423
									if ($mediaopt != rtrim($mediaopt_from_config)){
1424
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1425
									} else {
1426
										print "<option value=\"$mediaopt\" selected>" . gettext("$mediaopt") . "</option>";
1427
									}
1428
								}
1429
								echo '</select><br>';
1430
								echo gettext("Here you can explicitly set speed and duplex mode for this interface. WARNING: You MUST leave this set to autoselect (automatically negotiate speed) unless the port this interface connects to has its speed and duplex forced.");
1431
						echo '</div>';
1432
							echo '</td>';
1433
						echo '</tr>';
1434
						}
1435
						?>
1436
						<tr>
1437
							<td colspan="2" valign="top" height="16"></td>
1438
						</tr>
1439
						<tr style="display:none;" name="none" id="none">
1440
						</tr>
1441
						<tr style="display:none;" name="staticv4" id="staticv4">
1442
							<td colspan="2" style="padding:0px;">
1443
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1444
									<tr>
1445
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1446
									</tr>
1447
									<tr>
1448
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1449
										<td width="78%" class="vtable">
1450
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1451
											/
1452
											<select name="subnet" class="formselect" id="subnet">
1453
												<?php
1454
												for ($i = 32; $i > 0; $i--) {
1455
													if($i <> 31) {
1456
														echo "<option value=\"{$i}\" ";
1457
														if ($i == $pconfig['subnet']) echo "selected";
1458
														echo ">" . $i . "</option>";
1459
													}
1460
												}
1461
												?>
1462
											</select>
1463
										</td>
1464
									</tr>
1465
									<tr>
1466
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1467
										<td width="78%" class="vtable">
1468
											<select name="gateway" class="formselect" id="gateway">
1469
												<option value="none" selected><?=gettext("None"); ?></option>
1470
													<?php
1471
													if(count($a_gateways) > 0) {
1472
														foreach ($a_gateways as $gateway) {
1473
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1474
													?>
1475
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1476
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1477
															</option>
1478
													<?php
1479
															}
1480
														}
1481
													}
1482
													?>
1483
											</select>
1484
											- or  <strong><a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a></strong>
1485
											<br/>
1486
											<div id='addgwbox'>
1487
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1488
											</div>
1489
											<div id='notebox'>
1490
											</div>
1491
											<div id="status">
1492
											</div>
1493
											<div style="display:none" id="addgateway" name="addgateway">
1494
												<p>
1495
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1496
													<tr>
1497
														<td>
1498
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1499
																<tr><td>&nbsp;</td>
1500
																<tr>
1501
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1502
																</tr>
1503
																<tr><td>&nbsp;</td>
1504
																<?php
1505
																if($if == "wan" || $if == "WAN")
1506
																	$checked = " CHECKED";
1507
																?>
1508
																<tr>
1509
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1510
																</tr>
1511
																<tr>
1512
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1513
																</tr>
1514
																<tr>
1515
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1516
																</tr>
1517
																<tr>
1518
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1519
																</tr>
1520
																<tr><td>&nbsp;</td>
1521
																<tr>
1522
																	<td>&nbsp;</td>
1523
																	<td>
1524
																		<center>
1525
																			<div id='savebuttondiv'>
1526

    
1527

    
1528
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1529
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1530
																			</div>
1531
																		</center>
1532
																	</td>
1533
																</tr>
1534
																<tr><td>&nbsp;</td></tr>
1535
															</table>
1536
														</td>
1537
													</tr>
1538
												</table>
1539
												<p/>
1540
											</div>
1541
										</td>
1542
									</tr>
1543
								</table>
1544
							</td>
1545
						</tr>
1546
						<tr style="display:none;" name="staticv6" id="staticv6">
1547
							<td colspan="2" style="padding:0px;">
1548
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1549
									<tr>
1550
										<td colspan="2" valign="top">&nbsp;</td>
1551
									</tr>
1552
									<tr>
1553
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1554
									</tr>
1555
									<tr>
1556
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1557
										<td width="78%" class="vtable">
1558
											<input name="ipaddrv6" type="text" class="formfld unknown ipv4v6" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>">
1559
											/
1560
											<select name="subnetv6" class="formselect ipv4v6" id="subnetv6">
1561
												<?php
1562
												for ($i = 128; $i > 0; $i--) {
1563
													if($i <> 127) {
1564
														echo "<option value=\"{$i}\" ";
1565
														if ($i == $pconfig['subnetv6']) echo "selected";
1566
														echo ">" . $i . "</option>";
1567
													}
1568
												}
1569
												?>
1570
											</select>
1571
										</td>
1572
									</tr>
1573
									<tr>
1574
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1575
										<td width="78%" class="vtable">
1576
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1577
												<option value="none" selected><?=gettext("None"); ?></option>
1578
													<?php
1579
													if(count($a_gateways) > 0) {
1580
														foreach ($a_gateways as $gateway) {
1581
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1582
													?>
1583
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>>
1584
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1585
															</option>
1586
													<?php
1587
															}
1588
														}
1589
													}
1590
													?>
1591
											</select>
1592
											- or <strong><a OnClick="show_add_gateway_v6();" href="#"><?=gettext("add a new one."); ?></a></strong>
1593
											<br/>
1594
											<div id='addgwboxv6'>
1595
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1596
											</div>
1597
											<div id='noteboxv6'>
1598
											</div>
1599
											<div id="statusv6">
1600
											</div>
1601
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1602
												<p>
1603
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1604
													<tr>
1605
														<td>
1606
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1607
																<tr><td>&nbsp;</td>
1608
																<tr>
1609
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1610
																</tr>
1611
																<tr><td>&nbsp;</td>
1612
																<?php
1613
																if($if == "wan" || $if == "WAN")
1614
																	$checked = " CHECKED";
1615
																?>
1616
																<tr>
1617
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td>
1618
																</tr>
1619
																<tr>
1620
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>"></td>
1621
																</tr>
1622
																<tr>
1623
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayipv6" name="gatewayipv6"></td>
1624
																</tr>
1625
																<tr>
1626
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescrv6" name="gatewaydescrv6"></td>
1627
																</tr>
1628
																<tr><td>&nbsp;</td>
1629
																<tr>
1630
																	<td>&nbsp;</td>
1631
																	<td>
1632
																		<center>
1633
																			<div id='savebuttondivv6'>
1634
																				<input id="gwsavev6" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave_v6();'>
1635
																				<input id="gwcancelv6" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway_v6();'>
1636
																			</div>
1637
																		</center>
1638
																	</td>
1639
																</tr>
1640
																<tr><td>&nbsp;</td></tr>
1641
															</table>
1642
														</td>
1643
													</tr>
1644
												</table>
1645
												<p/>
1646
											</div>
1647
										</td>
1648
									</tr>
1649
								</table>
1650
							</td>
1651
						</tr>
1652
						<tr style="display:none;" name="dhcp" id="dhcp">
1653
							<td colspan="2" style="padding: 0px;">
1654
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1655
									<tr>
1656
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1657
									</tr>
1658
									<!-- Uncomment to expose DHCP+ in GUI
1659
									<tr>
1660
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1661
										<td width="78%" class="vtable">
1662
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked"; ?> >
1663
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1664
										<br/>
1665
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1666
										</td>
1667
									</tr>
1668
									-->
1669
									<tr>
1670
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1671
										<td width="78%" class="vtable">
1672
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1673
											<br>
1674
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1675
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1676
											"this (for client identification)."); ?>
1677
										</td>
1678
									</tr>
1679
									<tr>
1680
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1681
										<td width="78%" class="vtable">
1682
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1683
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1684
												<?php
1685
												for ($i = 32; $i > 0; $i--) {
1686
													if($i <> 31) {
1687
														echo "<option value=\"{$i}\" ";
1688
														if ($i == $pconfig['alias-subnet']) echo "selected";
1689
														echo ">" . $i . "</option>";
1690
													}
1691
												}
1692
												?>
1693
											</select>
1694
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1695
											"DHCP client."); ?>
1696
										</td>
1697
									</tr>
1698
								</table>
1699
							</td>
1700
						</tr>
1701
						<tr style="display:none;" name="dhcp6" id="dhcp6">
1702
							<td colspan="2" style="padding: 0px;">
1703
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1704
									<tr>
1705
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration"); ?></td>
1706
									</tr>
1707
									<!--- Leave commented out for now
1708
									<tr>
1709
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1710
										<td width="78%" class="vtable">
1711
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>">
1712
											<br>
1713
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1714
											"when requesting a DHCPv6 lease."); ?><br />
1715
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1716
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
1717
												}
1718
												printf(gettext("The current DUID is: '%s'"),$current_duid);
1719
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
1720
											?>
1721
										</td>
1722
									</tr>
1723
									-->
1724
									<tr>
1725
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1726
										<td width="78%" class="vtable">
1727
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
1728
												<?php
1729
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1730
												foreach($sizes as $bits => $length) {
1731
													echo "<option value=\"{$bits}\" ";
1732
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected";
1733
													echo ">" . $length . "</option>";
1734
												}
1735
												?>
1736
											</select>
1737
											<br>
1738
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
1739
										</td>
1740
									</tr>
1741
								</table>
1742
							</td>
1743
						</tr>
1744
						<tr style="display:none;" name="6rd" id="6rd">
1745
							<td colspan="2" style="padding: 0px;">
1746
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1747
									<tr>
1748
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
1749
									</tr>
1750
									<tr>
1751
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
1752
										<td width="78%" class="vtable">
1753
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>">
1754
											<br>
1755
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
1756
										</td>
1757
									</tr>
1758
									<tr>
1759
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
1760
										<td width="78%" class="vtable">
1761
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>">
1762
											<br>
1763
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
1764
										</td>
1765
									</tr>
1766
									<tr>
1767
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
1768
										<td width="78%" class="vtable">
1769
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
1770
												<?php
1771
												for ($i = 0; $i < 32; $i++) {
1772
													echo "<option value=\"{$i}\" ";
1773
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected";
1774
													echo ">" . $i . " bits</option>";
1775
												}
1776
												?>
1777
											</select>
1778
											<br>
1779
											<?=gettext("The value in this field is the 6RD IPv4 prefix length. Normally specified by the ISP. A value of 0 means we embed the entire IPv4 address in the 6RD prefix."); ?>
1780
										</td>
1781
									</tr>
1782
								</table>
1783
							</td>
1784
						</tr>
1785
						<tr style="display:none;" name="track6" id="track6">
1786
							<td colspan="2" style="padding: 0px;">
1787
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1788
									<tr>
1789
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
1790
									</tr>
1791
									<tr>
1792
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
1793
										<td width="78%" class="vtable">
1794
										<select name='track6-interface' class='formselect' >
1795
										<?php 
1796
											$interfaces = get_configured_interface_with_descr(false, true);
1797
											$dynv6ifs = array();
1798
											foreach ($interfaces as $iface => $ifacename) {
1799
												switch($config['interfaces'][$iface]['ipaddrv6']) {
1800
													case "6to4":
1801
													case "6rd":
1802
													case "dhcp6":
1803
														$dynv6ifs[$iface] = $ifacename;
1804
														break;
1805
													default:
1806
														continue;
1807
												}
1808
											}
1809
											foreach($dynv6ifs as $iface => $ifacename) {
1810
												echo "<option value=\"{$iface}\"";
1811
												if ($iface == $pconfig['track6-interface'])
1812
													echo " selected";
1813
												echo ">" . htmlspecialchars($ifacename) . "</option>";
1814
											}
1815
										  ?>
1816
										</select> <br>
1817
											<br>
1818
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
1819
										</td>
1820
									</tr>
1821
									<tr>
1822
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
1823
										<td width="78%" class="vtable">
1824
											<select name="track6-prefix-id" class="formselect" id="track6-prefix-id">
1825
												<?php
1826
												/* DHCP-PD is variable, calculate from the prefix-len on the WAN interface */
1827
												/* 6rd is variable, calculate from 64 - (v6 prefixlen - (32 - v4 prefixlen)) */
1828
												/* 6to4 is 16 bits, e.g. 65535 */
1829
												switch($config['interfaces'][$pconfig['track6-interface']]['ipaddrv6']) {
1830
													case "6to4":
1831
														$pdlen = 16;
1832
														break;
1833
													case "6rd":
1834
														$rd6cfg = $config['interfaces'][$pconfig['track6-interface']];
1835
														$rd6plen = explode("/", $rd6cfg['prefix-6rd']);
1836
														$pdlen = (64 - ($rd6plen[1] + (32 - $rd6cfg['prefix-6rd-v4plen'])));
1837
														break;
1838
													case "dhcp6":
1839
														$dhcp6cfg = $config['interfaces'][$pconfig['track6-interface']];
1840
														$pdlen = $dhcp6cfg['dhcp6-ia-pd-len'];
1841
														break;
1842
													default:
1843
														$pdlen = 0;
1844
														break;
1845
												}
1846
												print_r($pconfig['track6-interface']);
1847
												if($pconfig['track6-prefix-id'] == "none")
1848
													$selected = "selected";
1849
												echo "<option value=\"none\" {$selected}>". gettext("None") ."</option>\n";
1850
												$numbers = pow(2, $pdlen);
1851
												for($i = 0;$i < $numbers; $i++) {
1852
													echo "<option value=\"{$i}\" ";
1853
													if ("$i" == $pconfig['track6-prefix-id']) {
1854
														echo "selected";
1855
													}
1856
													echo ">" . dechex($i) . "</option>\n";
1857
												}
1858
												?> 
1859
											</select>
1860
											<?=gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
1861
										</td>
1862
									</tr>
1863
										</td>
1864
									</tr>
1865
								</table>
1866
							</td>
1867
						</tr>
1868
						<tr style="display:none;" name="ppp" id="ppp">
1869
							<td colspan="2" style="padding: 0px;">
1870
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1871
									<tr>
1872
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1873
									</tr>
1874
									<tr name="ppp_provider" id="ppp_provider">
1875
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1876
										<td width="78%" class="vtable">
1877
											<table border="0" cellpadding="0" cellspacing="0">
1878
												<tr id="trcountry">
1879
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1880
													<td>
1881
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1882
															<option></option>
1883
														</select>
1884
													</td>
1885
												</tr>
1886
												<tr id="trprovider" style="display:none">
1887
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1888
													<td>
1889
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1890
															<option></option>
1891
														</select>
1892
													</td>
1893
												</tr>
1894
												<tr id="trproviderplan" style="display:none">
1895
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1896
													<td>
1897
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1898
															<option></option>
1899
														</select>
1900
													</td>
1901
												</tr>
1902
											</table>
1903
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1904
										</td>
1905
									</tr>
1906
									<tr>
1907
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1908
										<td width="78%" class="vtable">
1909
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1910
										</td>
1911
									</tr>
1912
									<tr>
1913
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1914
										<td width="78%" class="vtable">
1915
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1916
										</td>
1917
									</tr>
1918
									<tr name="phone_num" id="phone_num">
1919
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1920
										<td width="78%" class="vtable">
1921
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1922
										</td>
1923
									</tr>
1924
									<tr name="apn_" id="apn_">
1925
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1926
										<td width="78%" class="vtable">
1927
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1928
										</td>
1929
									</tr>
1930
									<tr name="interface" id="interface" >
1931
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1932
										<td width="78%" class="vtable">
1933
											<select name="port" id="port" class="formselect">
1934
											<?php
1935
												$portlist = glob("/dev/cua*");
1936
												$modems = glob("/dev/modem*");
1937
												$portlist = array_merge($portlist, $modems);
1938
												foreach ($portlist as $port) {
1939
													if(preg_match("/\.(lock|init)$/", $port))
1940
														continue;
1941
													echo "<option value=\"".trim($port)."\"";
1942
													if ($pconfig['port'] == $port)
1943
														echo "selected";
1944
													echo ">{$port}</option>";
1945
												}?>
1946
											</select>
1947
										</td>
1948
									</tr>
1949
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1950
										<?php if (isset($pconfig['pppid'])): ?>
1951
											<td width="78%" class="vtable">
1952
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1953
											<?=gettext("to edit PPP configuration."); ?>
1954
											</td>
1955
										<?php else: ?>
1956
											<td width="78%" class="vtable">
1957
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1958
											<?=gettext("to create a PPP configuration."); ?>
1959
											</td>
1960
										<?php endif; ?>
1961
									</tr>
1962
								</table>
1963
							</td>
1964
						</tr>
1965
						<tr style="display:none;" name="pppoe" id="pppoe">
1966
							<td colspan="2" style="padding:0px;">
1967
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1968
									<tr>
1969
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1970
									</tr>
1971
									<tr>
1972
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1973
										<td width="78%" class="vtable">
1974
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1975
										</td>
1976
									</tr>
1977
									<tr>
1978
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1979
										<td width="78%" class="vtable">
1980
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1981
										</td>
1982
									</tr>
1983
									<tr>
1984
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1985
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1986
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1987
										</td>
1988
									</tr>
1989
									<tr>
1990
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1991
										<td width="78%" class="vtable">
1992
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1993
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1994
											<?=gettext("This option causes the interface to operate in dial-on-demand mode, allowing you to have a "); ?><i><?=gettext("virtual full time"); ?></i> <?=gettext("connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected."); ?>
1995
										</td>
1996
									</tr>
1997
									<tr>
1998
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1999
										<td width="78%" class="vtable">
2000
											<input name="pppoe_idletimeout" type="text" class="formfld unknown" id="pppoe_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pppoe_idletimeout']);?>"> <?=gettext("seconds"); ?><br><?=gettext("If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature."); ?>
2001
										</td>
2002
									</tr>
2003
									<tr>
2004
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
2005
										<td width="78%" class="vtable">
2006
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
2007
												<tr>
2008
													<td align="left" valign="top">
2009
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
2010
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
2011
															<option value = ""><?=gettext("Disabled"); ?></option>
2012
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
2013
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
2014
														</select> <?=gettext("Select a reset timing type"); ?>
2015
														</p>
2016
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2017
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2018
														<?php else: ?>
2019
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2020
														<?php endif; ?>
2021
														<input type="text" name="pppoe_resethour" class="fd_incremental_inp_range_0_23 fd_increment_1 fd_classname_dec_buttonDec fd_classname_inc_buttonInc" maxlength="2" id="pppoe_resethour" value="<?= $pconfig['pppoe_resethour']; ?>" size="3" />
2022
														<?=gettext("hour (0-23)"); ?><br />
2023
														<input type="text" name="pppoe_resetminute" class="fd_incremental_inp_range_0_59 fd_increment_1 fd_classname_dec_buttonDec fd_classname_inc_buttonInc" maxlength="2" id="pppoe_resetminute" value="<?= $pconfig['pppoe_resetminute']; ?>" size="3" />
2024
														<?=gettext("minute (0-59)"); ?><br />
2025
														<input name="pppoe_resetdate" type="text" class="w8em format-m-d-y highlight-days-67" id="pppoe_resetdate" maxlength="10" size="10" value="<?=htmlspecialchars($pconfig['pppoe_resetdate']);?>" />
2026
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2027
														<br />&nbsp;<br />
2028
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2029
														<?=gettext("If you leave the date field empty, the reset will be executed each day at the time you did specify using the minutes and hour field."); ?>
2030
														</p>
2031
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2032
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2033
														<?php else: ?>
2034
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2035
														<?php endif; ?>
2036
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2037
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2038
														<br />
2039
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2040
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2041
														<br />
2042
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2043
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2044
														<br />
2045
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2046
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2047
														</p>
2048
													</td>
2049
												</tr>
2050
											</table>
2051
										</td>
2052
									</tr>
2053

    
2054
									<tr>
2055
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2056
										<?php if (isset($pconfig['pppid'])): ?>
2057
											<td width="78%" class="vtable">
2058
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2059
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2060
											</td>
2061
										<?php else: ?>
2062
											<td width="78%" class="vtable">
2063
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2064
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2065
											</td>
2066
										<?php endif; ?>
2067
									</tr>
2068
								</table>
2069
							</td>
2070
						</tr>
2071
						<tr style="display:none;" name="pptp" id="pptp">
2072
							<td colspan="2" style="padding:0px;">
2073
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
2074
									<tr>
2075
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2076
									</tr>
2077
									<tr>
2078
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2079
										<td width="78%" class="vtable">
2080
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
2081
										</td>
2082
									</tr>
2083
									<tr>
2084
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2085
										<td width="78%" class="vtable">
2086
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
2087
										</td>
2088
									</tr>
2089
									<tr>
2090
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2091
										<td width="78%" class="vtable">
2092
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>">
2093
											/
2094
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2095
												<?php for ($i = 31; $i > 0; $i--): ?>
2096
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected"; ?>>
2097
														<?=$i;?></option>
2098
												<?php endfor; ?>
2099
											</select>
2100
										</td>
2101
									</tr>
2102
									<tr>
2103
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2104
										<td width="78%" class="vtable">
2105
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>">
2106
										</td>
2107
									</tr>
2108
									<tr>
2109
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2110
										<td width="78%" class="vtable">
2111
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>>
2112
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
2113
											<?=gettext("This option causes the interface to operate in dial-on-demand mode, allowing you to have a"); ?> <i><?=gettext("virtual full time"); ?></i> <?=gettext("connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected."); ?>
2114
										</td>
2115
									</tr>
2116
									<tr>
2117
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2118
										<td width="78%" class="vtable">
2119
											<input name="pptp_idletimeout" type="text" class="formfld unknown" id="pptp_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pptp_idletimeout']);?>"> <?=gettext("seconds"); ?><br><?=gettext("If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature."); ?>
2120
										</td>
2121
									</tr>
2122
									<tr>
2123
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2124
										<?php if (isset($pconfig['pppid'])): ?>
2125
											<td width="78%" class="vtable">
2126
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2127
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2128
											</td>
2129
										<?php else: ?>
2130
											<td width="78%" class="vtable">
2131
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2132
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2133
											</td>
2134
										<?php endif; ?>
2135
									</tr>
2136
								</table>
2137
							</td>
2138
						</tr>
2139
						<?php
2140
							/* Wireless interface? */
2141
							if (isset($wancfg['wireless'])):
2142
						?>
2143
						<tr>
2144
							<td colspan="2" valign="top" height="16"></td>
2145
						</tr>
2146
						<tr>
2147
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2148
						</tr>
2149
						<tr>
2150
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2151
							<td class="vtable">
2152
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked";?>>
2153
								<br/><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2154
							</td>
2155
						</tr>
2156
						<tr>
2157
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2158
							<td class="vtable">
2159
							<select name="standard" class="formselect" id="standard">
2160
								<?php
2161
								foreach($wl_modes as $wl_standard => $wl_channels) {
2162
									echo "<option ";
2163
									if ($pconfig['standard'] == "$wl_standard")
2164
										echo "selected ";
2165
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2166
								}
2167
								?>
2168
							</select>
2169
							</td>
2170
						</tr>
2171
						<?php if (isset($wl_modes['11g'])): ?>
2172
						<tr>
2173
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2174
							<td class="vtable">
2175
								<select name="protmode" class="formselect" id="protmode">
2176
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected";?> value="off"><?=gettext("Protection mode off"); ?></option>
2177
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2178
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2179
								</select>
2180
								<br/>
2181
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2182
								<br/>
2183
							</td>
2184
						</tr>
2185
						<?php else: ?>
2186
						<input name="protmode" type="hidden" id="protmode" value="off">
2187
						<?php endif; ?>
2188
						<tr>
2189
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2190
							<td class="vtable">
2191
								<select name="txpower" class="formselect" id="txpower">
2192
									<?
2193
									for($x = 99; $x > 0; $x--) {
2194
										if($pconfig["txpower"] == $x)
2195
											$SELECTED = " SELECTED";
2196
										else
2197
											$SELECTED = "";
2198
										echo "<option {$SELECTED}>{$x}</option>\n";
2199
									}
2200
									?>
2201
								</select><br/>
2202
								<?=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."); ?>
2203
							</td>
2204
						</tr>
2205
						<tr>
2206
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
2207
							<td class="vtable">
2208
								<select name="channel" class="formselect" id="channel">
2209
									<option <?php if ($pconfig['channel'] == 0) echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2210
									<?php
2211
									foreach($wl_modes as $wl_standard => $wl_channels) {
2212
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
2213
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
2214
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
2215
										foreach($wl_channels as $wl_channel) {
2216
											echo "<option ";
2217
											if ($pconfig['channel'] == "$wl_channel") {
2218
												echo "selected ";
2219
											}
2220
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
2221
											if(isset($wl_chaninfo[$wl_channel]))
2222
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
2223
											echo "</option>\n";
2224
										}
2225
									}
2226
									?>
2227
								</select>
2228
								<br/>
2229
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
2230
								<br/>
2231
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
2232
							</td>
2233
						</tr>
2234
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2235
						<tr>
2236
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
2237
							<td class="vtable">
2238
								<table border="0" cellpadding="0" cellspacing="0">
2239
									<tr>
2240
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
2241
										<td>
2242
											<?=gettext("Diversity"); ?><br/>
2243
											<select name="diversity" class="formselect" id="diversity">
2244
												<option <?php if (!isset($pconfig['diversity'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2245
												<option <?php if ($pconfig['diversity'] === '0') echo "selected"; ?> value="0"><?=gettext("Off"); ?></option>
2246
												<option <?php if ($pconfig['diversity'] === '1') echo "selected"; ?> value="1"><?=gettext("On"); ?></option>
2247
											</select>
2248
										</td>
2249
										<td>&nbsp;&nbsp</td>
2250
										<?php endif; ?>
2251
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
2252
										<td>
2253
											<?=gettext("Transmit antenna"); ?><br/>
2254
											<select name="txantenna" class="formselect" id="txantenna">
2255
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2256
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2257
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
2258
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
2259
											</select>
2260
										</td>
2261
										<td>&nbsp;&nbsp</td>
2262
										<?php endif; ?>
2263
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2264
										<td>
2265
											<?=gettext("Receive antenna"); ?><br/>
2266
											<select name="rxantenna" class="formselect" id="rxantenna">
2267
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2268
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2269
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
2270
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
2271
											</select>
2272
										</td>
2273
										<?php endif; ?>
2274
									</tr>
2275
								</table>
2276
								<br/>
2277
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
2278
							</td>
2279
						</tr>
2280
						<?php endif; ?>
2281
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
2282
						<tr>
2283
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
2284
							<td class="vtable">
2285
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>">
2286
								<br/>
2287
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br/>
2288
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
2289
							</td>
2290
						</tr>
2291
						<?php endif; ?>
2292
						<tr>
2293
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
2294
							<td class="vtable">
2295
								<?=gettext("Regulatory domain"); ?><br/>
2296
								<select name="regdomain" class="formselect" id="regdomain">
2297
									<option <?php if (empty($pconfig['regdomain'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2298
									<?php
2299
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
2300
										echo "<option ";
2301
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
2302
											echo "selected ";
2303
										}
2304
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
2305
									}
2306
									?>
2307
								</select>
2308
								<br/>
2309
								<?=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."); ?>
2310
								<br/><br/>
2311
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br/>
2312
								<select name="regcountry" class="formselect" id="regcountry">
2313
									<option <?php if (empty($pconfig['regcountry'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2314
									<?php
2315
									foreach($wl_countries as $wl_country_key => $wl_country) {
2316
										echo "<option ";
2317
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
2318
											echo "selected ";
2319
										}
2320
										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";
2321
									}
2322
									?>
2323
								</select>
2324
								<br/>
2325
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
2326
								<br/><br/>
2327
								<?=gettext("Location"); ?><br/>
2328
								<select name="reglocation" class="formselect" id="reglocation">
2329
									<option <?php if (empty($pconfig['reglocation'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2330
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected"; ?> value="indoor"><?=gettext("Indoor"); ?></option>
2331
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected"; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
2332
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected"; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
2333
								</select>
2334
								<br/><br/>
2335
								<?=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."); ?>
2336
								<br/>
2337
								<?=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."); ?>
2338
							</td>
2339
						</tr>
2340
						<tr>
2341
							<td colspan="2" valign="top" height="16"></td>
2342
						</tr>
2343
						<tr>
2344
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
2345
						</tr>
2346
						<tr>
2347
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
2348
							<td class="vtable">
2349
								<select name="mode" class="formselect" id="mode">
2350
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
2351
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
2352
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap"><?=gettext("Access Point"); ?></option>
2353
								</select>
2354
							</td>
2355
						</tr>
2356
						<tr>
2357
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
2358
							<td class="vtable">
2359
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>">
2360
								<br/>
2361
								<?=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"); ?>
2362
							</td>
2363
						</tr>
2364
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
2365
						<tr>
2366
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
2367
							<td class="vtable">
2368
								<select name="puremode" class="formselect" id="puremode">
2369
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected";?> value="any"><?=gettext("Any"); ?></option>
2370
									<?php if (isset($wl_modes['11g'])): ?>
2371
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected";?> value="11g"><?=gettext("802.11g"); ?></option>
2372
									<?php endif; ?>
2373
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected";?> value="11n"><?=gettext("802.11n"); ?></option>
2374
								</select>
2375
								<br/>
2376
								<?=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)."); ?>
2377
							</td>
2378
						</tr>
2379
						<?php elseif (isset($wl_modes['11g'])): ?>
2380
						<tr>
2381
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
2382
							<td class="vtable">
2383
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked";?>>
2384
								<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)."); ?>
2385
							</td>
2386
						</tr>
2387
						<?php endif; ?>
2388
						<tr>
2389
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
2390
							<td class="vtable">
2391
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked";?>>
2392
								<br/>
2393
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
2394
								<br/>
2395
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
2396
							</td>
2397
						</tr>
2398
						<tr>
2399
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
2400
							<td class="vtable">
2401
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked";?>>
2402
								<br/><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
2403
							</td>
2404
						</tr>
2405
						<tr>
2406
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
2407
							<td class="vtable">
2408
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked";?>>
2409
								<br/>
2410
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
2411
								<br/>
2412
								<?=gettext("(this might create problems for some clients)."); ?>
2413
							</td>
2414
						</tr>
2415
						<tr>
2416
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
2417
							<td class="vtable">
2418
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked"; ?>>
2419
								<strong><?=gettext("Enable WEP"); ?></strong>
2420
								<table border="0" cellspacing="0" cellpadding="0">
2421
									<tr>
2422
										<td>&nbsp;</td>
2423
										<td>&nbsp;</td>
2424
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
2425
									</tr>
2426
									<tr>
2427
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
2428
										<td>
2429
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>">
2430
										</td>
2431
										<td align="center">
2432
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked";?>>
2433
										</td>
2434
									</tr>
2435
									<tr>
2436
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
2437
										<td>
2438
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>">
2439
										</td>
2440
										<td align="center">
2441
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked";?>>
2442
										</td>
2443
									</tr>
2444
									<tr>
2445
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
2446
										<td>
2447
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>">
2448
										</td>
2449
										<td align="center">
2450
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked";?>>
2451
										</td>
2452
									</tr>
2453
									<tr>
2454
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
2455
										<td>
2456
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>">
2457
										</td>
2458
										<td align="center">
2459
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked";?>>
2460
										</td>
2461
									</tr>
2462
								</table>
2463
								<br/>
2464
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br/>
2465
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
2466
							</td>
2467
						</tr>
2468
						<tr>
2469
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
2470
							<td class="vtable">
2471
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked"; ?>>
2472
								<strong><?=gettext("Enable WPA"); ?></strong>
2473
								<br/><br/>
2474
								<table border="0" cellspacing="0" cellpadding="0">
2475
									<tr>
2476
										<td>&nbsp;</td>
2477
										<td>&nbsp;<?=gettext("WPA Pre Shared Key"); ?>&nbsp;</td>
2478
									</tr>
2479
									<tr>
2480
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
2481
										<td>
2482
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>">
2483
										</td>
2484
									</tr>
2485
								</table>
2486
								<br/><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
2487
							</td>
2488
						</tr>
2489
						<tr>
2490
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
2491
							<td class="vtable">
2492
								<select name="wpa_mode" class="formselect" id="wpa_mode">
2493
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected";?> value="1"><?=gettext("WPA"); ?></option>
2494
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected";?> value="2"><?=gettext("WPA2"); ?></option>
2495
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2496
								</select>
2497
							</td>
2498
						</tr>
2499
						<tr>
2500
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
2501
							<td class="vtable">
2502
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
2503
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected";?> value="WPA-PSK"><?=gettext("Pre Shared Key"); ?></option>
2504
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
2505
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
2506
								</select>
2507
							</td>
2508
						</tr>
2509
						<tr>
2510
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
2511
							<td class="vtable">
2512
								<select name="auth_algs" class="formselect" id="auth_algs">
2513
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected";?> value="1"><?=gettext("Open System Authentication"); ?></option>
2514
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
2515
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2516
								</select>
2517
								<br/><?=gettext("Note: Shared Key Authentication requires WEP."); ?></br>
2518
							</td>
2519
						</tr>
2520
						<tr>
2521
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
2522
							<td class="vtable">
2523
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
2524
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
2525
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
2526
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected";?> value="TKIP"><?=gettext("TKIP"); ?></option>
2527
								</select>
2528
							</td>
2529
						</tr>
2530
						<tr>
2531
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
2532
							<td class="vtable">
2533
								<input name="wpa_group_rekey" type="text" class="formfld unknown" id="wpa_group_rekey" size="30" value="<?php echo $pconfig['wpa_group_rekey'] ? $pconfig['wpa_group_rekey'] : "60";?>">
2534
								<br/><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
2535
							</td>
2536
						</tr>
2537
						<tr>
2538
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
2539
							<td class="vtable">
2540
								<input name="wpa_gmk_rekey" type="text" class="formfld" id="wpa_gmk_rekey" size="30" value="<?php echo $pconfig['wpa_gmk_rekey'] ? $pconfig['wpa_gmk_rekey'] : "3600";?>">
2541
								<br/><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
2542
							</td>
2543
						</tr>
2544
						<tr>
2545
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
2546
							<td class="vtable">
2547
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked"; ?>>
2548
								<br/><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
2549
							</td>
2550
						</tr>
2551
						<tr>
2552
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
2553
							<td class="vtable">
2554
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked";?>>
2555
								<br/><?=gettext("Setting this option will enable 802.1x authentication."); ?>
2556
								<br/><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
2557
							</td>
2558
						</tr>
2559
						<tr>
2560
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
2561
							<td class="vtable">
2562
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>">
2563
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2564
							</td>
2565
						</tr>
2566
						<tr>
2567
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
2568
							<td class="vtable">
2569
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>">
2570
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2571
							</td>
2572
						</tr>
2573
						<tr>
2574
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
2575
							<td class="vtable">
2576
								<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']);?>">
2577
								<br/>
2578
							</td>
2579
						</tr>
2580
						<tr>
2581
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
2582
							<td class="vtable">
2583
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>">
2584
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2585
							</td>
2586
						</tr>
2587
						<tr>
2588
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
2589
							<td class="vtable">
2590
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>">
2591
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2592
							</td>
2593
						</tr>
2594
						<tr>
2595
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
2596
							<td class="vtable">
2597
								<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']);?>">
2598
								<br/>
2599
							</td>
2600
						</tr>
2601
						<tr>
2602
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
2603
							<td class="vtable">
2604
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <? if ($pconfig['rsn_preauth']) echo "checked"; ?>>
2605
								<br/>
2606
							</td>
2607
						</tr>
2608
						<?php endif; ?>
2609
						<tr>
2610
							<td colspan="2" valign="top" height="16"></td>
2611
						</tr>
2612
						<tr>
2613
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
2614
						</tr>
2615
						<tr>
2616
							<td valign="middle" class="vncell">&nbsp;</td>
2617
							<td class="vtable">
2618
								<a name="rfc1918"></a>
2619
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
2620
								<strong><?=gettext("Block private networks"); ?></strong><br>
2621
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2622
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
2623
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
2624
								"leave this option turned on, unless your WAN network lies in such " .
2625
								"a private address space, too."); ?>
2626
							</td>
2627
						</tr>
2628
						<tr>
2629
							<td valign="middle" class="vncell">&nbsp;</td>
2630
							<td class="vtable">
2631
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
2632
								<strong><?=gettext("Block bogon networks"); ?></strong><br>
2633
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2634
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
2635
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
2636
								"and obviously should not appear as the source address in any packets you receive."); ?>
2637
							</td>
2638
						</tr>
2639
					</table> <!-- End "allcfg" table -->
2640
					</div> <!-- End "allcfg" div -->
2641

    
2642
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2643
						<tr>
2644
							<td width="22%" valign="top">
2645
								&nbsp;
2646
							</td>
2647
							<td width="78%">
2648
								<br/>
2649
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2650
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2651
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2652
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2653
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2654
								<?php endif; ?>
2655
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2656
							</td>
2657
						</tr>
2658
					</table>
2659
				</td>
2660
			</tr>
2661
		</table>
2662
		<!--
2663
		</div>
2664
		</td></tr>
2665
		</table>
2666
		-->
2667
	</form>
2668
	<script type="text/javascript">
2669
		var gatewayip;
2670
		var name;
2671
		var gatewayipv6;
2672
		var namev6;
2673
		function show_add_gateway() {
2674
			document.getElementById("addgateway").style.display = '';
2675
			document.getElementById("addgwbox").style.display = 'none';
2676
			document.getElementById("gateway").style.display = 'none';
2677
			document.getElementById("save").style.display = 'none';
2678
			document.getElementById("cancel").style.display = 'none';
2679
			document.getElementById("gwsave").style.display = '';
2680
			document.getElementById("gwcancel").style.display = '';
2681
			jQuery('#notebox').html("");
2682
		}
2683
		function show_add_gateway_v6() {
2684
			document.getElementById("addgatewayv6").style.display = '';
2685
			document.getElementById("addgwboxv6").style.display = 'none';
2686
			document.getElementById("gatewayv6").style.display = 'none';
2687
			document.getElementById("save").style.display = 'none';
2688
			document.getElementById("cancel").style.display = 'none';
2689
			document.getElementById("gwsave").style.display = '';
2690
			document.getElementById("gwcancel").style.display = '';
2691
			jQuery('#noteboxv6').html("");
2692
		}
2693
		function hide_add_gateway() {
2694
			document.getElementById("addgateway").style.display = 'none';
2695
			document.getElementById("addgwbox").style.display = '';
2696
			document.getElementById("gateway").style.display = '';
2697
			document.getElementById("save").style.display = '';
2698
			document.getElementById("cancel").style.display = '';
2699
			document.getElementById("gwsave").style.display = '';
2700
			document.getElementById("gwcancel").style.display = '';
2701
		}
2702
		function hide_add_gateway_v6() {
2703
			document.getElementById("addgatewayv6").style.display = 'none';
2704
			document.getElementById("addgwboxv6").style.display = '';
2705
			document.getElementById("gatewayv6").style.display = '';
2706
			document.getElementById("save").style.display = '';
2707
			document.getElementById("cancel").style.display = '';
2708
			document.getElementById("gwsave").style.display = '';
2709
			document.getElementById("gwcancel").style.display = '';
2710
		}
2711
		function hide_add_gatewaysave() {
2712
			document.getElementById("addgateway").style.display = 'none';
2713
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2714
			var iface = jQuery('#if').val();
2715
			name = jQuery('#name').val();
2716
			var descr = jQuery('#gatewaydescr').val();
2717
			gatewayip = jQuery('#gatewayip').val();
2718

    
2719
			var defaultgw = jQuery('#defaultgw').val();
2720
			var url = "system_gateways_edit.php";
2721
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2722
			jQuery.ajax(
2723
				url,
2724
				{
2725
					type: 'post',
2726
					data: pars,
2727
					error: report_failure,
2728
					complete: save_callback
2729
				});
2730
		}
2731
		function hide_add_gatewaysave_v6() {
2732
			document.getElementById("addgatewayv6").style.display = 'none';
2733
			jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2734
			var iface = jQuery('#if').val();
2735
			name = jQuery('#namev6').val();
2736
			var descr = jQuery('#gatewaydescrv6').val();
2737
			gatewayip = jQuery('#gatewayipv6').val();
2738
			var defaultgw = jQuery('#defaultgwv6').val();
2739
			var url_v6 = "system_gateways_edit.php";
2740
			var pars_v6 = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2741
			jQuery.ajax(
2742
				url_v6,
2743
				{
2744
					type: 'post',
2745
					data: pars_v6,
2746
					error: report_failure_v6,
2747
					complete: save_callback_v6
2748
				});
2749
		}
2750
		function addOption(selectbox,text,value)
2751
		{
2752
			var optn = document.createElement("OPTION");
2753
			optn.text = text;
2754
			optn.value = value;
2755
			selectbox.append(optn);
2756
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2757
			jQuery('#notebox').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2758
		}
2759
		function addOption_v6(selectbox,text,value)
2760
		{
2761
			var optn = document.createElement("OPTION");
2762
			optn.text = text;
2763
			optn.value = value;
2764
			selectbox.append(optn);
2765
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2766
			jQuery('#noteboxv6').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2767
		}
2768
		function report_failure() {
2769
			alert("Sorry, we could not create your IPv4 gateway at this time.");
2770
			hide_add_gateway();
2771
		}
2772
		function report_failure_v6() {
2773
			alert("Sorry, we could not create your IPv6 gateway at this time.");
2774
			hide_add_gateway_v6();
2775
		}
2776
		function save_callback(transport) {
2777
			var response = transport.responseText;
2778
			if(response) {
2779
				document.getElementById("addgateway").style.display = 'none';
2780
				hide_add_gateway();
2781
				jQuery('#status').html('');
2782
				var gwtext = escape(name) + " - " + gatewayip;
2783
				addOption(jQuery('#gateway'), gwtext, name);
2784
				// Auto submit form?
2785
				//document.iform.submit();
2786
				//jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif">');
2787
			} else {
2788
				report_failure();
2789
			}
2790
		}
2791
		function show_advanced_media() {
2792
			document.getElementById("showadvmediabox").innerHTML='';
2793
			aodiv = document.getElementById('showmediaadv');
2794
			aodiv.style.display = "block";
2795
		}
2796
		function save_callback_v6(transport) {
2797
			var response_v6 = transport.responseText;
2798
			if(response_v6) {
2799
				document.getElementById("addgatewayv6").style.display = 'none';
2800
				hide_add_gateway_v6();
2801
				jQuery('#statusv6').html('');
2802
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2803
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
2804
				// Auto submit form?
2805
				//document.iform.submit();
2806
				//jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif">');
2807
			} else {
2808
				report_failure_v6();
2809
			}
2810
		}
2811
		<?php
2812
		echo "show_allcfg(document.iform.enable);";
2813
		echo "updateType('{$pconfig['type']}');\n";
2814
		echo "updateTypeSix('{$pconfig['type6']}');\n";
2815
		?>
2816
	</script>
2817
	<?php include("fend.inc"); ?>
2818
	</body>
2819
</html>
(91-91/245)