Project

General

Profile

Download (142 KB) Statistics
| Branch: | Tag: | Revision:
1 8a9edda5 Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 c5d81585 Renato Botelho
 * interfaces.php
4 9da2cf1c Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8 402c98a2 Reid Linnemann
 * Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
9 c5d81585 Renato Botelho
 * Copyright (c) 2006 Daniel S. Haischt
10
 * All rights reserved.
11 fd9ebcd5 Stephen Beaver
 *
12 c5d81585 Renato Botelho
 * originally based on m0n0wall (http://m0n0.ch/wall)
13
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
14
 * All rights reserved.
15 fd9ebcd5 Stephen Beaver
 *
16 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
17
 * you may not use this file except in compliance with the License.
18
 * You may obtain a copy of the License at
19 fd9ebcd5 Stephen Beaver
 *
20 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
21 fd9ebcd5 Stephen Beaver
 *
22 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
23
 * distributed under the License is distributed on an "AS IS" BASIS,
24
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
 * See the License for the specific language governing permissions and
26
 * limitations under the License.
27 fd9ebcd5 Stephen Beaver
 */
28 5b237745 Scott Ullrich
29 6b07c15a Matthew Grooms
##|+PRIV
30 01eb687d Ermal Luçi
##|*IDENT=page-interfaces
31 5230f468 jim-p
##|*NAME=Interfaces: WAN
32 998552f8 Ermal Luçi
##|*DESCR=Allow access to the 'Interfaces' page.
33 01eb687d Ermal Luçi
##|*MATCH=interfaces.php*
34 6b07c15a Matthew Grooms
##|-PRIV
35
36 f81cfcc9 jim-p
require_once("guiconfig.inc");
37
require_once("ipsec.inc");
38
require_once("functions.inc");
39
require_once("captiveportal.inc");
40
require_once("filter.inc");
41
require_once("shaper.inc");
42
require_once("rrd.inc");
43
require_once("vpn.inc");
44 1fb064e8 Erik Fonnesbeck
require_once("xmlparse_attr.inc");
45 bc68ed41 Viktor G
require_once("util.inc");
46 199d8121 Ermal Luçi
47 c6c398c6 jim-p
function remove_bad_chars($string) {
48
	return preg_replace('/[^a-z_0-9]/i', '', $string);
49
}
50
51 6dee9957 Stephen Beaver
define("ANTENNAS", false);
52 ae4c4bac Stephen Beaver
53 5eabad3d Phil Davis
if (isset($_POST['referer'])) {
54 68933ba7 Stephen Beaver
	$referer = $_POST['referer'];
55 5eabad3d Phil Davis
} else {
56 68933ba7 Stephen Beaver
	$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces.php');
57 5eabad3d Phil Davis
}
58 62424bdb Renato Botelho
59 94556105 Scott Ullrich
// Get configured interface list
60 f593f80b Phil Davis
$ifdescrs = get_configured_interface_with_descr(true);
61 04d726ac Reid Linnemann
$if = $_REQUEST['if'] ?? 'wan';
62
$bridged = link_interface_to_bridge($if);
63 94556105 Scott Ullrich
64 dd18038e Ermal
65
if (empty($ifdescrs[$if])) {
66 68933ba7 Stephen Beaver
	header("Location: interfaces.php");
67
	exit;
68 9ff9a1c7 Seth Mos
}
69 6b07c15a Matthew Grooms
70 58af5941 Scott Ullrich
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
71
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
72
define("CRON_DAILY_PATTERN", "0 0 * * *");
73
define("CRON_HOURLY_PATTERN", "0 * * * *");
74 dc711694 Scott Ullrich
75 1caf2209 Phil Davis
if (!is_array($pconfig)) {
76 68933ba7 Stephen Beaver
	$pconfig = array();
77 1caf2209 Phil Davis
}
78 89c7a9c8 Ermal
79 c6c398c6 jim-p
init_config_arr(array('ppps', 'ppp'));
80 d85ba87f gnhb
$a_ppps = &$config['ppps']['ppp'];
81 58af5941 Scott Ullrich
82 c6c398c6 jim-p
init_config_arr(array('gateways', 'gateway_item'));
83 d173230c Seth Mos
$a_gateways = &$config['gateways']['gateway_item'];
84
85 58a185ae marjohn56
$interfaces = get_configured_interface_with_descr();
86 f3f98e97 Phil Davis
/* Interfaces which have addresses configured elsewhere and should not be
87 cc240e32 jim-p
 * configured here. See https://redmine.pfsense.org/issues/8687 */
88 992335fc Viktor G
$no_address_interfaces = array("ovpn", "ipsec", "gif", "gre", "l2tps");
89 cc240e32 jim-p
$show_address_controls = true;
90
$realifname = get_real_interface($if);
91
foreach ($no_address_interfaces as $ifbl) {
92
	if (substr($realifname, 0, strlen($ifbl)) == $ifbl) {
93
		$show_address_controls = false;
94
	}
95
}
96
97 c6c398c6 jim-p
init_config_arr(array('interfaces', $if));
98 f1f60c92 Ermal Luçi
$wancfg = &$config['interfaces'][$if];
99 ee5c01b5 Seth Mos
$old_wancfg = $wancfg;
100 e12ad49f Renato Botelho
$old_wancfg['realif'] = get_real_interface($if);
101
$old_ppps = $a_ppps;
102 564599fa Stephen Beaver
103 dd18038e Ermal
// Populate page descr if it does not exist.
104 1caf2209 Phil Davis
if ($if == "wan" && !$wancfg['descr']) {
105 68933ba7 Stephen Beaver
	$wancfg['descr'] = "WAN";
106 1caf2209 Phil Davis
} else if ($if == "lan" && !$wancfg['descr']) {
107 68933ba7 Stephen Beaver
	$wancfg['descr'] = "LAN";
108 1caf2209 Phil Davis
}
109 dd18038e Ermal
110 c4642eb1 Ermal LUÇI
/* NOTE: The code here is used to set the $pppid for the curious */
111 efe80217 jim-p
$pppid = null;
112
foreach ($a_ppps as $pid => $ppp) {
113 68933ba7 Stephen Beaver
	if ($wancfg['if'] == $ppp['if']) {
114 efe80217 jim-p
		$pppid = $pid;
115 68933ba7 Stephen Beaver
		break;
116
	}
117 30ade846 gnhb
}
118
119 c4b60a9a Colin Fleming
$type_disabled = (substr($wancfg['if'], 0, 3) == 'gre') ? 'disabled' : '';
120 f3d88511 Renato Botelho
121 1d7e1d6c gnhb
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
122 68933ba7 Stephen Beaver
	$pconfig['pppid'] = $pppid;
123
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
124
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
125
	if ($a_ppps[$pppid]['type'] == "ppp") {
126
		$pconfig['ppp_username'] = $a_ppps[$pppid]['username'];
127
		$pconfig['ppp_password'] = base64_decode($a_ppps[$pppid]['password']);
128
129
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
130
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
131 71465708 Viktor G
	} elseif ($a_ppps[$pppid]['type'] == "pppoe") {
132 68933ba7 Stephen Beaver
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
133
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
134
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
135 71465708 Viktor G
		$pconfig['hostuniq'] = $a_ppps[$pppid]['hostuniq'];
136 68933ba7 Stephen Beaver
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
137
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
138
139
		/* ================================================ */
140
		/* = force a connection reset at a specific time? = */
141
		/* ================================================ */
142
143
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
144
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
145
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
146
			if ($itemhash) {
147
				$cronitem = $itemhash['ITEM'];
148
			}
149
			if (isset($cronitem)) {
150
				$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
151
			} else {
152
				$resetTime = NULL;
153
			}
154
			//log_error("ResetTime:".$resetTime);
155
			if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
156
				if ($cronitem) {
157
					$pconfig['pppoe_pr_custom'] = true;
158
					$pconfig['pppoe_resetminute'] = $cronitem['minute'];
159
					$pconfig['pppoe_resethour'] = $cronitem['hour'];
160
					if ($cronitem['mday'] != "*" && $cronitem['month'] != "*") {
161
						$pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y");
162
					}
163
				}
164
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
165
				$pconfig['pppoe_pr_preset'] = true;
166
				switch ($resetTime) {
167
					case CRON_MONTHLY_PATTERN:
168
						$pconfig['pppoe_monthly'] = true;
169
						break;
170
					case CRON_WEEKLY_PATTERN:
171
						$pconfig['pppoe_weekly'] = true;
172
						break;
173
					case CRON_DAILY_PATTERN:
174
						$pconfig['pppoe_daily'] = true;
175
						break;
176
					case CRON_HOURLY_PATTERN:
177
						$pconfig['pppoe_hourly'] = true;
178
						break;
179
				}
180
			}
181
		} // End force pppoe reset at specific time
182
		// End if type == pppoe
183
	} else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp") {
184
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
185
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
186 8e267d3b Viktor G
		if (($a_ppps[$pppid]['type'] == 'l2tp') && isset($a_ppps[$pppid]['secret'])) {
187
			$pconfig['l2tp_secret'] = base64_decode($a_ppps[$pppid]['secret']);
188
		}
189 66fd7b47 Phil Davis
		$pconfig['pptp_localip'] = explode(",", $a_ppps[$pppid]['localip']);
190 68933ba7 Stephen Beaver
		$pconfig['pptp_subnet'] = explode(",", $a_ppps[$pppid]['subnet']);
191
		$pconfig['pptp_remote'] = explode(",", $a_ppps[$pppid]['gateway']);
192
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
193
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
194
	}
195 8256f324 gnhb
} else {
196 68933ba7 Stephen Beaver
	$pconfig['ptpid'] = interfaces_ptpid_next();
197
	$pppid = count($a_ppps);
198 d85ba87f gnhb
}
199 564599fa Stephen Beaver
200 5b237745 Scott Ullrich
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
201 bc40d758 Seth Mos
$pconfig['alias-address'] = $wancfg['alias-address'];
202
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
203 57c83fd6 jim-p
$pconfig['dhcprejectfrom'] = $wancfg['dhcprejectfrom'];
204 f4dd8b4c N0YB
205
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
206
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
207
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
208
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
209
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
210
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
211
212
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
213
214
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
215
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
216
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
217
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
218
219
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
220
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
221
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
222
223
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
224
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
225
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
226
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
227
228
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
229
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
230
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
231
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
232
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
233
234
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
235
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
236
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
237
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
238
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
239
240
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
241
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
242 58a185ae marjohn56
$pconfig['adv_dhcp6_prefix_selected_interface'] = $wancfg['adv_dhcp6_prefix_selected_interface'];
243 f4dd8b4c N0YB
244
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
245
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
246
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
247
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
248
249
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
250
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
251
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
252
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
253
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
254
255
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
256
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
257
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
258
259 e4d40f41 gnhb
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
260 f1f60c92 Ermal Luçi
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
261 6a688547 Ermal
$pconfig['enable'] = isset($wancfg['enable']);
262 f1f60c92 Ermal Luçi
263 1caf2209 Phil Davis
switch ($wancfg['ipaddr']) {
264 68933ba7 Stephen Beaver
	case "dhcp":
265
		$pconfig['type'] = "dhcp";
266 62ed56dc Luiz Souza
		$pconfig['dhcpvlanenable'] = isset($wancfg['dhcpvlanenable']);
267
		$pconfig['dhcpcvpt'] = $wancfg['dhcpcvpt'];
268 68933ba7 Stephen Beaver
		break;
269
	case "pppoe":
270
	case "pptp":
271
	case "l2tp":
272
	case "ppp":
273
		$pconfig['type'] = $wancfg['ipaddr'];
274
		break;
275
	default:
276
		if (is_ipaddrv4($wancfg['ipaddr'])) {
277
			$pconfig['type'] = "staticv4";
278
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
279
			$pconfig['subnet'] = $wancfg['subnet'];
280
			$pconfig['gateway'] = $wancfg['gateway'];
281 7957389b Viktor G
		} elseif (in_array(remove_ifindex($wancfg['if']), array("ppp", "pppoe", "pptp", "l2tp"))) {
282
			$pconfig['type'] = remove_ifindex($wancfg['if']);
283 68933ba7 Stephen Beaver
		} else {
284
			$pconfig['type'] = "none";
285
		}
286
		break;
287 9ff9a1c7 Seth Mos
}
288 5b237745 Scott Ullrich
289 1caf2209 Phil Davis
switch ($wancfg['ipaddrv6']) {
290 68933ba7 Stephen Beaver
	case "slaac":
291
		$pconfig['type6'] = "slaac";
292 9210d0aa Viktor Gurov
		$pconfig['slaacusev4iface'] = isset($wancfg['slaacusev4iface']);
293 68933ba7 Stephen Beaver
		break;
294
	case "dhcp6":
295
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
296
		if (!isset($wancfg['dhcp6-ia-pd-len'])) {
297
			$wancfg['dhcp6-ia-pd-len'] = "none";
298
		}
299
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
300
		$pconfig['dhcp6-ia-pd-send-hint'] = isset($wancfg['dhcp6-ia-pd-send-hint']);
301
		$pconfig['type6'] = "dhcp6";
302
		$pconfig['dhcp6prefixonly'] = isset($wancfg['dhcp6prefixonly']);
303
		$pconfig['dhcp6usev4iface'] = isset($wancfg['dhcp6usev4iface']);
304 8c661bc8 marjohn56
		$pconfig['dhcp6withoutra'] = isset($wancfg['dhcp6withoutra']);
305 6b8680a7 marjohn56
		$pconfig['dhcp6vlanenable'] = isset($wancfg['dhcp6vlanenable']);
306
		$pconfig['dhcp6cvpt'] = $wancfg['dhcp6cvpt'];
307 68933ba7 Stephen Beaver
		break;
308
	case "6to4":
309
		$pconfig['type6'] = "6to4";
310
		break;
311
	case "track6":
312
		$pconfig['type6'] = "track6";
313
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
314
		if ($wancfg['track6-prefix-id'] == "") {
315
			$pconfig['track6-prefix-id'] = 0;
316
		} else {
317
			$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
318
		}
319
		$pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
320
		break;
321
	case "6rd":
322
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
323
		if ($wancfg['prefix-6rd-v4plen'] == "") {
324
			$wancfg['prefix-6rd-v4plen'] = "0";
325
		}
326
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
327
		$pconfig['type6'] = "6rd";
328
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
329
		break;
330
	default:
331
		if (is_ipaddrv6($wancfg['ipaddrv6'])) {
332
			$pconfig['type6'] = "staticv6";
333 b7331383 marjohn56
			$pconfig['ipv6usev4iface'] = isset($wancfg['ipv6usev4iface']);
334 68933ba7 Stephen Beaver
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
335
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
336
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
337
		} else {
338
			$pconfig['type6'] = "none";
339
		}
340
		break;
341 47593ac6 Seth Mos
}
342
343 5b237745 Scott Ullrich
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
344 ff1955ee Bill Marquette
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
345 5b237745 Scott Ullrich
$pconfig['spoofmac'] = $wancfg['spoofmac'];
346
$pconfig['mtu'] = $wancfg['mtu'];
347 4cea5cf8 Ermal
$pconfig['mss'] = $wancfg['mss'];
348 5b237745 Scott Ullrich
349
/* Wireless interface? */
350 b7f01f59 Bill Marquette
if (isset($wancfg['wireless'])) {
351 68933ba7 Stephen Beaver
	/* Sync first to be sure it displays the actual settings that will be used */
352
	interface_sync_wireless_clones($wancfg, false);
353
	/* Get wireless modes */
354
	$wlanif = get_real_interface($if);
355
	if (!does_interface_exist($wlanif)) {
356
		interface_wireless_clone($wlanif, $wancfg);
357
	}
358
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
359
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
360
	$wl_modes = get_wireless_modes($if);
361 91fd7459 Viktor G
	$wl_ht_modes = get_wireless_ht_modes($if);
362
	$wl_ht_list = get_wireless_ht_list($if);
363 68933ba7 Stephen Beaver
	$wl_chaninfo = get_wireless_channel_info($if);
364
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
365
	$wl_sysctl = get_sysctl(
366
		array(
367
			"{$wl_sysctl_prefix}.diversity",
368
			"{$wl_sysctl_prefix}.txantenna",
369
			"{$wl_sysctl_prefix}.rxantenna",
370
			"{$wl_sysctl_prefix}.slottime",
371
			"{$wl_sysctl_prefix}.acktimeout",
372
			"{$wl_sysctl_prefix}.ctstimeout"));
373
	$wl_regdomain_xml_attr = array();
374
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
375
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
376
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
377
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
378
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
379
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
380
	$pconfig['standard'] = $wancfg['wireless']['standard'];
381
	$pconfig['mode'] = $wancfg['wireless']['mode'];
382
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
383
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
384
	$pconfig['channel'] = $wancfg['wireless']['channel'];
385 91fd7459 Viktor G
	$pconfig['channel_width'] = $wancfg['wireless']['channel_width'];
386 68933ba7 Stephen Beaver
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
387
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
388
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
389
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
390
	$pconfig['distance'] = $wancfg['wireless']['distance'];
391
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
392
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
393
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
394
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
395
	if (isset($wancfg['wireless']['puren']['enable'])) {
396
		$pconfig['puremode'] = '11n';
397
	} else if (isset($wancfg['wireless']['pureg']['enable'])) {
398
		$pconfig['puremode'] = '11g';
399
	} else {
400
		$pconfig['puremode'] = 'any';
401
	}
402
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
403
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
404
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
405
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
406
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
407
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
408
	$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
409
	$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
410
	$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
411
	if (is_array($wancfg['wireless']['wpa'])) {
412
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
413
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
414
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
415
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
416
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
417
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
418
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
419
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
420
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
421
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
422
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
423
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
424
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
425
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
426 5f120301 Viktor G
		$pconfig['wpa_eap_client_mode'] = $wancfg['wireless']['wpa']['wpa_eap_client_mode'];
427
		$pconfig['wpa_eap_inner_auth'] = $wancfg['wireless']['wpa']['wpa_eap_inner_auth'];
428
		$pconfig['wpa_eap_inner_id'] = $wancfg['wireless']['wpa']['wpa_eap_inner_id'];
429
		$pconfig['wpa_eap_inner_password'] = base64_decode($wancfg['wireless']['wpa']['wpa_eap_inner_password']);
430
		$pconfig['wpa_eap_cert'] = $wancfg['wireless']['wpa']['wpa_eap_cert'];
431
		$pconfig['wpa_eap_ca'] = $wancfg['wireless']['wpa']['wpa_eap_ca'];
432 68933ba7 Stephen Beaver
	}
433
434
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
435
436 5b237745 Scott Ullrich
}
437
438 44c42356 Phil Davis
$changes_applied = false;
439
440 43e255d2 Ermal Luçi
if ($_POST['apply']) {
441 68933ba7 Stephen Beaver
	unset($input_errors);
442
	if (!is_subsystem_dirty('interfaces')) {
443 eaa948d6 NOYB
		$input_errors[] = gettext("The settings have already been applied!");
444 68933ba7 Stephen Beaver
	} else {
445 44c42356 Phil Davis
		$retval = 0;
446 68933ba7 Stephen Beaver
		unlink_if_exists("{$g['tmp_path']}/config.cache");
447
		clear_subsystem_dirty('interfaces');
448
449 c6d22ee1 Viktor G
		$vlan_redo = array();
450 68933ba7 Stephen Beaver
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
451
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
452
			foreach ($toapplylist as $ifapply => $ifcfgo) {
453 9bb98111 Viktor G
				$realif = get_real_interface($ifapply);
454
				$ifmtu = get_interface_mtu($realif);
455 2d5c75fa Reid Linnemann
				if (config_path_enabled("interfaces/{$ifapply}")) {
456 68933ba7 Stephen Beaver
					interface_bring_down($ifapply, false, $ifcfgo);
457
					interface_configure($ifapply, true);
458 2d5c75fa Reid Linnemann
					if (config_get_path("interfaces/{$ifapply}/ipaddrv6") == "track6") {
459 3a8a9028 Chris Buechler
						/* call interface_track6_configure with linkup true so
460
						   IPv6 IPs are added back. dhcp6c needs a HUP. Can't
461
						   just call interface_configure with linkup true as
462 7e653b50 Stephen Beaver
						   that skips bridge membership addition.
463 3a8a9028 Chris Buechler
						*/
464 2d5c75fa Reid Linnemann
						$wancfg = config_get_path("interfaces/{$ifapply}");
465 3a8a9028 Chris Buechler
						interface_track6_configure($ifapply, $wancfg, true);
466
					}
467 68933ba7 Stephen Beaver
				} else {
468
					interface_bring_down($ifapply, true, $ifcfgo);
469
				}
470 318714cb Viktor G
				restart_interface_services($ifapply, $ifcfg['ipaddrv6']);
471 2d5c75fa Reid Linnemann
				$mtu = config_get_path("interfaces/{$ifapply}/mtu");
472 9bb98111 Viktor G
				if (interface_has_clones($realif) &&
473 2d5c75fa Reid Linnemann
				    ($mtu && ($mtu != $ifmtu)) ||
474
				    (!$mtu && (get_interface_default_mtu() != $ifmtu))) { 
475 9bb98111 Viktor G
					$vlan_redo[] = $realif;
476
				}
477 68933ba7 Stephen Beaver
			}
478
		}
479 c9f69485 Luiz Souza
480
		/*
481 69ffb456 Viktor G
                 * If the parent interface has changed MTU above, the VLANs needs to be
482
                 * redone.
483 c9f69485 Luiz Souza
		 */
484 c6d22ee1 Viktor G
		if (!empty($vlan_redo)) {
485
			foreach ($vlan_redo as $vlredo) {
486 be732dba Viktor G
				interfaces_vlan_configure_mtu($vlredo);
487 c6d22ee1 Viktor G
			}
488 c9f69485 Luiz Souza
		}
489
490 68933ba7 Stephen Beaver
		/* sync filter configuration */
491
		setup_gateways_monitor();
492
493
		clear_subsystem_dirty('interfaces');
494
495 44c42356 Phil Davis
		$retval |= filter_configure();
496 68933ba7 Stephen Beaver
497
		enable_rrd_graphing();
498
499 44c42356 Phil Davis
		$changes_applied = true;
500
501 68933ba7 Stephen Beaver
		if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0)) {
502
			clear_subsystem_dirty('staticroutes');
503
		}
504 fd3af9eb Viktor G
505 bc68ed41 Viktor G
		send_event("service reload packages");
506 68933ba7 Stephen Beaver
	}
507
	@unlink("{$g['tmp_path']}/.interfaces.apply");
508 c946d721 Steve Beaver
} else if ($_POST['save']) {
509 270c4607 Scott Ullrich
510 68933ba7 Stephen Beaver
	unset($input_errors);
511
	$pconfig = $_POST;
512
513 b6f6210a jim-p
	if (ctype_xdigit($_POST['track6-prefix-id--hex'])) {
514 68933ba7 Stephen Beaver
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
515
	} else {
516
		$pconfig['track6-prefix-id'] = 0;
517
	}
518
519
	/* filter out spaces from descriptions */
520
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
521
522
	/* okay first of all, cause we are just hiding the PPPoE HTML
523
	 * fields related to PPPoE resets, we are going to unset $_POST
524
	 * vars, if the reset feature should not be used. Otherwise the
525
	 * data validation procedure below, may trigger a false error
526
	 * message.
527
	 */
528
	if (empty($_POST['pppoe-reset-type'])) {
529
		unset($_POST['pppoe_pr_type']);
530
		unset($_POST['pppoe_resethour']);
531
		unset($_POST['pppoe_resetminute']);
532
		unset($_POST['pppoe_resetdate']);
533
		unset($_POST['pppoe_pr_preset_val']);
534
	}
535 f57a3d90 Phil Davis
536
	/* input validation */
537
	$reqdfields = explode(" ", "descr");
538
	$reqdfieldsn = array(gettext("Description"));
539 b07adc11 Phil Davis
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
540 f57a3d90 Phil Davis
541
	if (!$input_errors) {
542 7ce12dcb jim-p
		/* Reserved name? */
543
		global $pf_reserved_keywords, $reserved_table_names;
544
		$pf_reserved_keywords = array_merge($pf_reserved_keywords, $reserved_table_names);
545
		foreach ($pf_reserved_keywords as $rk) {
546
			if (strcasecmp($rk, $_POST['descr']) == 0) {
547
				$input_errors[] = sprintf(gettext("Cannot use a reserved keyword as an interface name: %s"), $rk);
548
			}
549
		}
550
551 f57a3d90 Phil Davis
		/* description unique? */
552
		foreach ($ifdescrs as $ifent => $ifdescr) {
553 b101627a Phil Davis
			if ($if != $ifent && (strcasecmp($ifdescr, $_POST['descr']) == 0)) {
554 f57a3d90 Phil Davis
				$input_errors[] = gettext("An interface with the specified description already exists.");
555
				break;
556
			}
557 68933ba7 Stephen Beaver
		}
558 f8bf3fe8 Phil Davis
559 f57a3d90 Phil Davis
		/* Is the description already used as an alias name? */
560 2d5c75fa Reid Linnemann
		foreach (config_get_path('aliases/alias', []) as $alias) {
561
			if (strcasecmp($alias['name'], $_POST['descr']) == 0) {
562
				$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $_POST['descr']);
563 f8bf3fe8 Phil Davis
			}
564
		}
565
566 f57a3d90 Phil Davis
		/* Is the description already used as an interface group name? */
567 2d5c75fa Reid Linnemann
		foreach (config_get_path('ifgroups/ifgroupentry', []) as $ifgroupentry) {
568
			if (strcasecmp($ifgroupentry['ifname'], $_POST['descr']) == 0) {
569
				$input_errors[] = sprintf(gettext("Sorry, an interface group with the name %s already exists."), $_POST['descr']);
570 b824f18c Renato Botelho
			}
571
		}
572
573 f57a3d90 Phil Davis
		if (is_numeric($_POST['descr'])) {
574
			$input_errors[] = gettext("The interface description cannot contain only numbers.");
575
		}
576 c9d93b62 Phil Davis
577 cec267cb Viktor G
		if ((strlen(trim($_POST['descr'])) > 25) && ((substr($realifname, 0, 4) == 'ovpn') ||
578 281dede0 Renato Botelho do Couto
		    (substr($realifname, 0, 5) == 'ipsec'))) {
579
			$input_errors[] = gettext("The OpenVPN and VTI interface description must be less than 26 characters long.");
580 cec267cb Viktor G
		}
581
582
		if ((strlen(trim($_POST['descr'])) > 22) && ((substr($realifname, 0, 3) == 'gif') ||
583
		    (substr($realifname, 0, 3) == 'gre'))) {
584
			$input_errors[] = gettext("The GIF and GRE interface description must be less than 23 characters long.");
585
		}
586
587 c9d93b62 Phil Davis
		/*
588
		 * Packages (e.g. tinc) create interface groups, reserve this
589
		 * namespace pkg_ for them.
590
		 * One namespace is shared by Interfaces, Interface Groups and Aliases.
591
		 */
592
		if (substr($_POST['descr'], 0, 4) == 'pkg_') {
593
			$input_errors[] = gettext("The interface description cannot start with pkg_");
594
		}
595 68933ba7 Stephen Beaver
	}
596 f57a3d90 Phil Davis
597 2d113b12 Renato Botelho
	if ($_POST['blockbogons'] == "yes" &&
598 2d5c75fa Reid Linnemann
	    config_path_enabled('system','ipv6allow') &&
599
	    (config_get_path('system/maximumtableentries', 0) <
600 2568e151 Christian McDonald
	     g_get('minimumtableentries_bogonsv6'))) {
601 2d113b12 Renato Botelho
		$input_errors[] = sprintf(gettext(
602
		    "In order to block bogon networks the Firewall Maximum Table Entries value in System / Advanced / Firewall must be increased at least to %s."),
603 2568e151 Christian McDonald
		    g_get('minimumtableentries_bogonsv6'));
604 2d113b12 Renato Botelho
	}
605
606 2d5c75fa Reid Linnemann
	if (config_path_enabled("dhcpd/{$if}")) {
607 403dad2a Renato Botelho
		if (!preg_match("/^staticv4/", $_POST['type'])) {
608
			$input_errors[] = gettext("The DHCP Server is active " .
609
			    "on this interface and it can be used only with " .
610
			    "a static IP configuration. Please disable the " .
611
			    "DHCP Server service on this interface first, " .
612
			    "then change the interface configuration.");
613
		} elseif (!empty($_POST['subnet']) && $_POST['subnet'] >= 31) {
614
			$input_errors[] = gettext("The DHCP Server is active " .
615
			    "on this interface and it can be used only with " .
616
			    "IPv4 subnet < 31. Please disable the " .
617
			    "DHCP Server service on this interface first, " .
618
			    "then change the interface configuration.");
619
		}
620 68933ba7 Stephen Beaver
	}
621 91cd1741 Viktor G
	if (isset($config['dhcpdv6']) && ($_POST['type6'] != "staticv6" && $_POST['type6'] != "track6")) {
622 2d5c75fa Reid Linnemann
		if (config_path_enabled("dhcpdv6/{$if}")) {
623 91cd1741 Viktor G
			$input_errors[] = gettext("The DHCP6 Server is active on this interface and it can be used only " .
624
			    "with a static IPv6 configuration. Please disable the DHCPv6 Server service on this " .
625
			    "interface first, then change the interface configuration.");
626
		}
627 2d5c75fa Reid Linnemann
		if (config_get_path("dhcpdv6/{$if}/ramode", "disabled") != "disabled") {
628 91cd1741 Viktor G
			$input_errors[] = gettext("The Router Advertisements Server is active on this interface and it can " .
629
			    "be used only with a static IPv6 configuration. Please disable the Router Advertisements " .
630
			    "Server service on this interface first, then change the interface configuration.");
631
		}
632 68933ba7 Stephen Beaver
	}
633
634
	switch (strtolower($_POST['type'])) {
635
		case "staticv4":
636
			$reqdfields = explode(" ", "ipaddr subnet gateway");
637
			$reqdfieldsn = array(gettext("IPv4 address"), gettext("Subnet bit count"), gettext("Gateway"));
638
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
639
			break;
640
		case "none":
641 2d5c75fa Reid Linnemann
			foreach (config_get_path('virtualip/vip', []) as $vip) {
642
				if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if) {
643
					$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
644 68933ba7 Stephen Beaver
				}
645
			}
646
			break;
647
		case "ppp":
648
			$reqdfields = explode(" ", "port phone");
649
			$reqdfieldsn = array(gettext("Modem Port"), gettext("Phone Number"));
650
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
651
			break;
652
		case "pppoe":
653
			if ($_POST['pppoe_dialondemand']) {
654
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
655
				$reqdfieldsn = array(gettext("PPPoE username"), gettext("PPPoE password"), gettext("Dial on demand"), gettext("Idle timeout value"));
656
			} else {
657
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
658
				$reqdfieldsn = array(gettext("PPPoE username"), gettext("PPPoE password"));
659
			}
660
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
661
			break;
662
		case "pptp":
663
			if ($_POST['pptp_dialondemand']) {
664 66fd7b47 Phil Davis
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local0 pptp_subnet0 pptp_remote0 pptp_dialondemand pptp_idletimeout");
665 68933ba7 Stephen Beaver
				$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"));
666
			} else {
667 ca28c12c Phil Davis
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local0 pptp_subnet0 pptp_remote0");
668 68933ba7 Stephen Beaver
				$reqdfieldsn = array(gettext("PPTP username"), gettext("PPTP password"), gettext("PPTP local IP address"), gettext("PPTP subnet"), gettext("PPTP remote IP address"));
669
			}
670
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
671
			break;
672
		case "l2tp":
673
			if ($_POST['pptp_dialondemand']) {
674 66fd7b47 Phil Davis
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote0 pptp_dialondemand pptp_idletimeout");
675 68933ba7 Stephen Beaver
				$reqdfieldsn = array(gettext("L2TP username"), gettext("L2TP password"), gettext("L2TP remote IP address"), gettext("Dial on demand"), gettext("Idle timeout value"));
676
			} else {
677 66fd7b47 Phil Davis
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote0");
678 68933ba7 Stephen Beaver
				$reqdfieldsn = array(gettext("L2TP username"), gettext("L2TP password"), gettext("L2TP remote IP address"));
679
			}
680
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
681
			break;
682
	}
683
	switch (strtolower($_POST['type6'])) {
684
		case "staticv6":
685
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
686
			$reqdfieldsn = array(gettext("IPv6 address"), gettext("Subnet bit count"), gettext("Gateway"));
687
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
688
			break;
689
		case "none":
690 2d5c75fa Reid Linnemann
			foreach (config_get_path('virtualip/vip', []) as $vip) {
691
				if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if) {
692
					$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
693 68933ba7 Stephen Beaver
				}
694
			}
695
			break;
696
		case "dhcp6":
697
			if (in_array($wancfg['ipaddrv6'], array())) {
698 e4517c3c jim-p
				$input_errors[] = sprintf(gettext("The interface must be reassigned to configure as %s."), $_POST['type6']);
699 68933ba7 Stephen Beaver
			}
700
			if ($_POST['dhcp6-ia-pd-send-hint'] && strtolower($_POST['dhcp6-ia-pd-len']) == 'none') {
701
				$input_errors[] = gettext('DHCPv6 Prefix Delegation size must be provided when Send IPv6 prefix hint flag is checked');
702
			}
703 522e3f91 jim-p
			if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_id']) &&
704
			    !is_numericint($_POST['adv_dhcp6_id_assoc_statement_address_id'])) {
705
				$input_errors[] = gettext('DHCPv6 advanced id-assoc na ID value must be empty or an integer.');
706
			}
707
			if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_id']) &&
708
			    !is_numericint($_POST['adv_dhcp6_id_assoc_statement_prefix_id'])) {
709
				$input_errors[] = gettext('DHCPv6 advanced id-assoc pd ID value must be empty or an integer.');
710
			}
711
			if (!empty($_POST['adv_dhcp6_prefix_interface_statement_sla_id']) &&
712
			    !is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_id'])) {
713
				$input_errors[] = gettext('DHCPv6 advanced Prefix Interface sla-id value must be empty or an integer.');
714
			}
715
			if (!empty($_POST['adv_dhcp6_prefix_interface_statement_sla_len']) &&
716
			    !is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_len'])) {
717
				$input_errors[] = gettext('DHCPv6 advanced Prefix Interface sla-len value must be empty or an integer.');
718
			}
719 68933ba7 Stephen Beaver
			break;
720
		case "6rd":
721
			foreach ($ifdescrs as $ifent => $ifdescr) {
722 2d5c75fa Reid Linnemann
				if ($if != $ifent && (config_get_path("interfaces/{$ifent}/ipaddrv6") == $_POST['type6'])) {
723
					if (config_get_path("interfaces/{$ifent}/prefix-6rd") == $_POST['prefix-6rd']) {
724 e4517c3c jim-p
						$input_errors[] = gettext("Only one interface can be configured within a single 6rd prefix.");
725 68933ba7 Stephen Beaver
						break;
726
					}
727
				}
728
			}
729 b8cfee9d Viktor G
			if (!is_subnetv6($_POST['prefix-6rd'])) {
730
				$input_errors[] = gettext("6RD Prefix must be a valid IPv6 prefix.");
731
			}
732 2239959d Chris Buechler
			if (!is_ipaddrv4($_POST['gateway-6rd'])) {
733 1a9ec5cc Phil Davis
				$input_errors[] = gettext("6RD Border Relay must be an IPv4 address.");
734 3c596efc Chris Buechler
			}
735 68933ba7 Stephen Beaver
			if (in_array($wancfg['ipaddrv6'], array())) {
736 e4517c3c jim-p
				$input_errors[] = sprintf(gettext("The interface must be reassigned to configure as %s."), $_POST['type6']);
737 68933ba7 Stephen Beaver
			}
738
			break;
739
		case "6to4":
740
			foreach ($ifdescrs as $ifent => $ifdescr) {
741 2d5c75fa Reid Linnemann
				if ($if != $ifent && (config_get_path("interfaces/{$ifent}/ipaddrv6") == $_POST['type6'])) {
742 eaa948d6 NOYB
					$input_errors[] = sprintf(gettext("Only one interface can be configured as 6to4."), $_POST['type6']);
743 68933ba7 Stephen Beaver
					break;
744
				}
745
			}
746
			if (in_array($wancfg['ipaddrv6'], array())) {
747 e4517c3c jim-p
				$input_errors[] = sprintf(gettext("The interface must be reassigned to configure as %s."), $_POST['type6']);
748 68933ba7 Stephen Beaver
			}
749
			break;
750
		case "track6":
751
			/* needs to check if $track6-prefix-id is used on another interface */
752
			if (in_array($wancfg['ipaddrv6'], array())) {
753 e4517c3c jim-p
				$input_errors[] = sprintf(gettext("The interface must be reassigned to configure as %s."), $_POST['type6']);
754 68933ba7 Stephen Beaver
			}
755
756 f09d4db4 Renato Botelho
			if (empty($_POST['track6-interface'])) {
757 eaa948d6 NOYB
				$input_errors[] = gettext("A valid interface to track must be selected.");
758 f09d4db4 Renato Botelho
			}
759
760 1b5fbae4 Stephen Jones
			if ($_POST['track6-prefix-id--hex'] != "" && !ctype_xdigit($_POST['track6-prefix-id--hex'])) {
761 eaa948d6 NOYB
				$input_errors[] = gettext("A valid hexadecimal number must be entered for the IPv6 prefix ID.");
762 68933ba7 Stephen Beaver
			} else {
763
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
764
				if ($track6_prefix_id < 0 || $track6_prefix_id > $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) {
765 e4517c3c jim-p
					$input_errors[] = gettext("The specified IPv6 Prefix ID is out of range.") .
766 68933ba7 Stephen Beaver
						" ({$_POST['track6-interface']}) - (0) - (" . sprintf('%x', $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) . ")";
767
				} else {
768
					foreach ($ifdescrs as $ifent => $ifdescr) {
769
						if ($if == $ifent) {
770
							continue;
771
						}
772 123efede Reid Linnemann
						if (config_get_path("interfaces/{$ifent}/ipaddrv6") == 'track6' &&
773
						    config_get_path("interfaces/{$ifent}/track6-interface") == $_POST['track6-interface'] &&
774
						    config_get_path("interfaces/{$ifent}/track6-prefix-id") == $track6_prefix_id) {
775 68933ba7 Stephen Beaver
							$input_errors[] = sprintf(gettext("This track6 prefix ID is already being used in %s."), $ifdescr);
776
						}
777
					}
778
				}
779
			}
780
			break;
781
	}
782
783
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
784
	$staticroutes = get_staticroutes(true);
785
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
786 8c6190e8 Phil Davis
	if (($_POST['type'] == 'staticv4') && $_POST['ipaddr']) {
787 b959ca07 jim-p
		$_POST['ipaddr'] = trim($_POST['ipaddr']);
788 68933ba7 Stephen Beaver
		if (!is_ipaddrv4($_POST['ipaddr'])) {
789
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
790
		} else {
791
			$where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddr'], $if, true, true, $_POST['subnet']);
792
			if (count($where_ipaddr_configured)) {
793
				$subnet_conflict_text = sprintf(gettext("IPv4 address %s is being used by or overlaps with:"), $_POST['ipaddr'] . "/" . $_POST['subnet']);
794
				foreach ($where_ipaddr_configured as $subnet_conflict) {
795
					$subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
796
				}
797
				$input_errors[] = $subnet_conflict_text;
798
			}
799
800
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
801
			if ($_POST['subnet'] < 31) {
802
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
803
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
804
				} else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet'])) {
805
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
806
				}
807
			}
808
809
			foreach ($staticroutes as $route_subnet) {
810
				list($network, $subnet) = explode("/", $route_subnet);
811
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
812
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
813
					break;
814
				}
815
				unset($network, $subnet);
816
			}
817
		}
818
	}
819 d1630d95 Luiz Souza
	if (($_POST['type6'] == 'staticv6') && $_POST['ipaddrv6']) {
820 b959ca07 jim-p
		$_POST['ipaddrv6'] = trim(addrtolower($_POST['ipaddrv6']));
821 5af93827 Steve Beaver
822 68933ba7 Stephen Beaver
		if (!is_ipaddrv6($_POST['ipaddrv6'])) {
823
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
824
		} else {
825 352f8085 Chris Buechler
			if (ip_in_subnet($_POST['ipaddrv6'], "fe80::/10")) {
826
				$input_errors[] = gettext("IPv6 link local addresses cannot be configured as an interface IP.");
827
			}
828 68933ba7 Stephen Beaver
			$where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddrv6'], $if, true, true, $_POST['subnetv6']);
829
			if (count($where_ipaddr_configured)) {
830
				$subnet_conflict_text = sprintf(gettext("IPv6 address %s is being used by or overlaps with:"), $_POST['ipaddrv6'] . "/" . $_POST['subnetv6']);
831
				foreach ($where_ipaddr_configured as $subnet_conflict) {
832
					$subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
833
				}
834
				$input_errors[] = $subnet_conflict_text;
835
			}
836
837
			foreach ($staticroutes as $route_subnet) {
838
				list($network, $subnet) = explode("/", $route_subnet);
839
				if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
840
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
841
					break;
842
				}
843
				unset($network, $subnet);
844
			}
845
		}
846
	}
847
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
848
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
849
	}
850
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6']))) {
851
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
852
	}
853
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address']))) {
854
		$input_errors[] = gettext("A valid alias IP address must be specified.");
855
	}
856
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
857
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
858
	}
859 392a7045 lukehamburg
	if ($_POST['dhcprejectfrom'] && !validate_ipv4_list($_POST['dhcprejectfrom'])) {
860
		$input_errors[] = gettext("An invalid IP address was detected in the 'Reject leases from' field.");
861 68933ba7 Stephen Beaver
	}
862 f1bb5c7f Phil Davis
863
	// Only check the IPv4 gateway already exists if it is not "none" and it is not a gateway that the user is adding
864
	if (($_POST['gateway'] != "none") && (!$_POST['gatewayip4'] || ($_POST['gateway'] != $_POST['gatewayname4']))) {
865 68933ba7 Stephen Beaver
		$match = false;
866
		foreach ($a_gateways as $gateway) {
867
			if (in_array($_POST['gateway'], $gateway)) {
868
				$match = true;
869
			}
870
		}
871 f1bb5c7f Phil Davis
		if (!$match) {
872
			$input_errors[] = gettext("A valid IPv4 gateway must be specified.");
873
		}
874
	}
875
	// Only check the IPv6 gateway already exists if it is not "none" and it is not a gateway that the user is adding
876
	if (($_POST['gatewayv6'] != "none") && (!$_POST['gatewayip6'] || ($_POST['gatewayv6'] != $_POST['gatewayname6']))) {
877
		$match = false;
878 68933ba7 Stephen Beaver
		foreach ($a_gateways as $gateway) {
879
			if (in_array($_POST['gatewayv6'], $gateway)) {
880
				$match = true;
881
			}
882
		}
883
		if (!$match) {
884 f1bb5c7f Phil Davis
			$input_errors[] = gettext("A valid IPv6 gateway must be specified.");
885 68933ba7 Stephen Beaver
		}
886
	}
887 dac4cd09 Steve Beaver
888 71465708 Viktor G
	if ($_POST['provider'] && strpos($_POST['provider'], "\"")) {
889 dac4cd09 Steve Beaver
		$input_errors[] = gettext("The service name may not contain quote characters.");
890 68933ba7 Stephen Beaver
	}
891 71465708 Viktor G
	if ($_POST['hostuniq'] && !preg_match('/^[a-zA-Z0-9]+$/i', $_POST['hostuniq'])) {
892
		$input_errors[] = gettext("The Host-Uniq value can only be hexadecimal or letters and numbers.");
893
	}
894 68933ba7 Stephen Beaver
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
895
		$input_errors[] = gettext("The idle timeout value must be an integer.");
896
	}
897
	if ($_POST['pppoe_resethour'] != "" && !is_numericint($_POST['pppoe_resethour']) &&
898 aa82505e Phil Davis
	    $_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) {
899
		$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
900 68933ba7 Stephen Beaver
	}
901
	if ($_POST['pppoe_resetminute'] != "" && !is_numericint($_POST['pppoe_resetminute']) &&
902 aa82505e Phil Davis
	    $_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) {
903
		$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
904 68933ba7 Stephen Beaver
	}
905
	if ($_POST['pppoe_resetdate'] != "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
906
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
907
	}
908 66fd7b47 Phil Davis
	if (($_POST['pptp_local0'] && !is_ipaddrv4($_POST['pptp_local0']))) {
909 68933ba7 Stephen Beaver
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
910
	}
911 66fd7b47 Phil Davis
	if (($_POST['pptp_subnet0'] && !is_numeric($_POST['pptp_subnet0']))) {
912 68933ba7 Stephen Beaver
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
913
	}
914 8d89682e Phil Davis
	if (($_POST['pptp_remote0'] && !is_ipaddrv4($_POST['pptp_remote0']) && !is_hostname($_POST['pptp_remote0']))) {
915 68933ba7 Stephen Beaver
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
916
	}
917
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
918
		$input_errors[] = gettext("The idle timeout value must be an integer.");
919
	}
920
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
921
		$input_errors[] = gettext("A valid MAC address must be specified.");
922
	}
923
	if ($_POST['mtu']) {
924
		if (!is_numericint($_POST['mtu'])) {
925
			$input_errors[] = "MTU must be an integer.";
926
		}
927
		if (substr($wancfg['if'], 0, 3) == 'gif') {
928
			$min_mtu = 1280;
929
			$max_mtu = 8192;
930 4fa69727 Viktor G
		} elseif (($_POST['ipaddrv6'] == '6rd') || ($_POST['ipaddrv6'] == '6to4')) {
931
			$min_mtu = 1300;
932
			$max_mtu = 9000;
933 68933ba7 Stephen Beaver
		} else {
934
			$min_mtu = 576;
935
			$max_mtu = 9000;
936
		}
937
938
		if ($_POST['mtu'] < $min_mtu || $_POST['mtu'] > $max_mtu) {
939
			$input_errors[] = sprintf(gettext("The MTU must be between %d and %d bytes."), $min_mtu, $max_mtu);
940
		}
941
942
		unset($min_mtu, $max_mtu);
943
944 12bcf7e9 Luiz Souza
		if (interface_is_vlan($wancfg['if']) != NULL) {
945 68933ba7 Stephen Beaver
			$realhwif_array = get_parent_interface($wancfg['if']);
946
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
947
			$parent_realhwif = $realhwif_array[0];
948
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
949 4a3a45c4 Luiz Otavio O Souza
			$mtu = 0;
950 2d5c75fa Reid Linnemann
			if (!empty($parent_if) && !(config_get_path("interfaces/{$parent_if}/mtu")))
951
				$mtu = intval(config_get_path("interfaces/{$parent_if}/mtu"));
952 4a3a45c4 Luiz Otavio O Souza
			if ($mtu == 0)
953
				$mtu = get_interface_mtu($parent_realhwif);
954
			if ($_POST['mtu'] > $mtu)
955
				$input_errors[] = gettext("The MTU of a VLAN cannot be greater than that of its parent interface.");
956 68933ba7 Stephen Beaver
		} else {
957
			foreach ($config['interfaces'] as $idx => $ifdata) {
958 12bcf7e9 Luiz Souza
				if (($idx == $if) || interface_is_vlan($ifdata['if']) == NULL) {
959 68933ba7 Stephen Beaver
					continue;
960
				}
961
962
				$realhwif_array = get_parent_interface($ifdata['if']);
963
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
964
				$parent_realhwif = $realhwif_array[0];
965
966
				if ($parent_realhwif != $wancfg['if']) {
967
					continue;
968
				}
969
970
				if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu']) {
971 4a3a45c4 Luiz Otavio O Souza
					$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a larger value."), $ifdata['descr']);
972 68933ba7 Stephen Beaver
				}
973
			}
974
		}
975
	}
976
	if ($_POST['mss'] != '') {
977
		if (!is_numericint($_POST['mss']) || ($_POST['mss'] < 576 || $_POST['mss'] > 65535)) {
978
			$input_errors[] = gettext("The MSS must be an integer between 576 and 65535 bytes.");
979
		}
980
	}
981
	/* Wireless interface? */
982
	if (isset($wancfg['wireless'])) {
983
		$reqdfields = array("mode");
984
		$reqdfieldsn = array(gettext("Mode"));
985
		if ($_POST['mode'] == 'hostap') {
986
			$reqdfields[] = "ssid";
987
			$reqdfieldsn[] = gettext("SSID");
988
			if (isset($_POST['channel']) && $_POST['channel'] == "0") {
989
				// auto channel with hostap is broken, prevent this for now.
990
				$input_errors[] = gettext("A specific channel, not auto, must be selected for Access Point mode.");
991
			}
992
		}
993 91fd7459 Viktor G
		if (!stristr($_POST['standard'], '11n') && ($_POST['channel_width'] != "0")) {
994
			$input_errors[] = gettext("Channel width selection is only supported by 802.11n standards.");
995
		}
996 68933ba7 Stephen Beaver
		if (stristr($_POST['standard'], '11n')) {
997
			if (!($_POST['wme_enable'])) {
998
				$input_errors[] = gettext("802.11n standards require enabling WME.");
999
			}
1000 91fd7459 Viktor G
			if (($_POST['channel_width'] != "0") && ($_POST['channel'] != "0") &&
1001
			    is_array($wl_ht_list[$_POST['standard']][$_POST['channel']]) &&
1002
			    !empty($wl_ht_list[$_POST['standard']][$_POST['channel']]) &&
1003
			    !in_array($_POST['channel_width'], $wl_ht_list[$_POST['standard']][$_POST['channel']])) {
1004
				$input_errors[] = sprintf(gettext("Unable to use %s channel width with channel %s."), strtoupper($_POST['channel_width']), $_POST['channel']);
1005
			}
1006 68933ba7 Stephen Beaver
		}
1007
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
1008
		check_wireless_mode();
1009
		if (isset($_POST['wpa_group_rekey']) && (!is_numericint($_POST['wpa_group_rekey']) || $_POST['wpa_group_rekey'] < 1 || $_POST['wpa_group_rekey'] > 9999)) {
1010
			$input_errors[] = gettext("Key Rotation must be an integer between 1 and 9999.");
1011
		}
1012
		if (isset($_POST['wpa_gmk_rekey']) && (!is_numericint($_POST['wpa_gmk_rekey']) || $_POST['wpa_gmk_rekey'] < 1 || $_POST['wpa_gmk_rekey'] > 9999)) {
1013
			$input_errors[] = gettext("Master Key Regeneration must be an integer between 1 and 9999.");
1014
		}
1015
		if (isset($_POST['wpa_group_rekey']) && isset($_POST['wpa_gmk_rekey'])) {
1016
			if ($_POST['wpa_group_rekey'] > $_POST['wpa_gmk_rekey']) {
1017
				$input_errors[] = gettext("Master Key Regeneration must be greater than Key Rotation.");
1018
			}
1019
		}
1020
		if (!empty($_POST['auth_server_addr'])) {
1021
			if (!is_domain($_POST['auth_server_addr']) && !is_ipaddr($_POST['auth_server_addr'])) {
1022
				$input_errors[] = gettext("802.1X Authentication Server must be an IP or hostname.");
1023
			}
1024
		}
1025
		if (!empty($_POST['auth_server_addr2'])) {
1026
			if (!is_domain($_POST['auth_server_addr2']) && !is_ipaddr($_POST['auth_server_addr2'])) {
1027
				$input_errors[] = gettext("Secondary 802.1X Authentication Server must be an IP or hostname.");
1028
			}
1029
		}
1030
		if (!empty($_POST['auth_server_port'])) {
1031
			if (!is_port($_POST['auth_server_port'])) {
1032
				$input_errors[] = gettext("802.1X Authentication Server Port must be a valid port number (1-65535).");
1033
			}
1034
		}
1035
		if (!empty($_POST['auth_server_port2'])) {
1036
			if (!is_port($_POST['auth_server_port2'])) {
1037
				$input_errors[] = gettext("Secondary 802.1X Authentication Server Port must be a valid port number (1-65535).");
1038
			}
1039
		}
1040
		if (isset($_POST['channel']) && !is_numericint($_POST['channel'])) {
1041
			if (!is_numericint($_POST['channel'])) {
1042
				$input_errors[] = gettext("Invalid channel specified.");
1043
			} else {
1044
				if ($_POST['channel'] > 255 || $_POST['channel'] < 0) {
1045
					$input_errors[] = gettext("Channel must be between 0-255.");
1046
				}
1047
			}
1048
		}
1049
		if (!empty($_POST['distance']) && !is_numericint($_POST['distance'])) {
1050
			$input_errors[] = gettext("Distance must be an integer.");
1051
		}
1052
		if (isset($_POST['standard']) && (stristr($_POST['standard'], '11na') || stristr($_POST['standard'], '11a'))) {
1053
			if ($_POST['channel'] != 0 && $_POST['channel'] < 15) {
1054
				$input_errors[] = gettext("Channel selected is not valid for 802.11a or 802.11na.");
1055
			}
1056
		}
1057
		if (isset($_POST['standard']) && ($_POST['standard'] == "11b" || $_POST['standard'] == "11g")) {
1058
			if ($_POST['channel'] > 14) {
1059
				$input_errors[] = gettext("Channel selected is not valid for 802.11b or 802.11g.");
1060
			}
1061
		}
1062
		if (!empty($_POST['protmode']) && !in_array($_POST['protmode'], array("off", "cts", "rtscts"))) {
1063
			$input_errors[] = gettext("Invalid option chosen for OFDM Protection Mode");
1064
		}
1065
1066
		if ($_POST['passphrase']) {
1067
			$passlen = strlen($_POST['passphrase']);
1068
			if ($passlen < 8 || $passlen > 63) {
1069
				$input_errors[] = gettext("The WPA passphrase must be between 8 and 63 characters long.");
1070
			}
1071
		}
1072
1073
		if ($_POST['wpa_enable'] == "yes") {
1074
			if (empty($_POST['passphrase']) && stristr($_POST['wpa_key_mgmt'], "WPA-PSK")) {
1075
				$input_errors[] = gettext("A WPA Passphrase must be specified when WPA PSK is enabled.");
1076
			}
1077 5f120301 Viktor G
			if (($_POST['mode'] == 'bss') & ($_POST['wpa_key_mgmt'] == "WPA-EAP") &&
1078
			    ($_POST['wpa_eap_client_mode'] != 'tls')) {
1079
				if (empty($_POST['wpa_eap_inner_id'])) {
1080
					$input_errors[] = gettext("An Inner Authentication Identity must be specified " .
1081
					    "when PEAP/TTLS authentication method is selected.");
1082
				}
1083
				if (empty($_POST['wpa_eap_inner_password'])) {
1084
					$input_errors[] = gettext("An Inner Authentication Passphrase must be specified " .
1085
					    "when PEAP/TTLS authentication method is selected.");
1086
				}
1087
			}
1088 68933ba7 Stephen Beaver
		}
1089
	}
1090 c8b10b4c Stephen Beaver
1091
	if ($_POST['ppp_password'] != $_POST['ppp_password_confirm']) {
1092
		$input_errors[] = gettext("PPP Password and confirmed password must match!");
1093
	}
1094
1095 6fb95fa2 heper
	if ($_POST['pppoe_password'] != $_POST['pppoe_password_confirm']) {
1096 c8b10b4c Stephen Beaver
		$input_errors[] = gettext("PPPoE Password and confirmed password must match!");
1097
	}
1098
1099
	if ($_POST['pptp_password'] != $_POST['pptp_password_confirm']) {
1100
		$input_errors[] = gettext("PTPP Password and confirmed password must match!");
1101
	}
1102
1103 f1bb5c7f Phil Davis
	if ($_POST['gatewayip4']) {
1104
		// The user wants to add an IPv4 gateway - validate the settings
1105
		$gateway_settings4 = array();
1106
1107
		$gateway_settings4['name'] = $_POST['gatewayname4'];
1108
		$gateway_settings4['interface'] = $_POST['if'];
1109
		$gateway_settings4['gateway'] = $_POST['gatewayip4'];
1110
		$gateway_settings4['descr'] = $_POST['gatewaydescr4'];
1111
		$gateway_settings4['defaultgw'] = $_POST['defaultgw4'];
1112 264f4423 PiBa-NL
		$gateway_settings4['ipprotocol'] = 'inet';
1113 f1bb5c7f Phil Davis
		$gw_input_errors = validate_gateway($gateway_settings4, '', $_POST['ipaddr'], $_POST['subnet']);
1114
		foreach ($gw_input_errors as $input_error_text) {
1115
			$input_errors[] = $input_error_text;
1116
		}
1117
	}
1118
1119
	if ($_POST['gatewayip6']) {
1120
		// The user wants to add an IPv6 gateway - validate the settings
1121
		$gateway_settings6 = array();
1122
1123
		$gateway_settings6['name'] = $_POST['gatewayname6'];
1124
		$gateway_settings6['interface'] = $_POST['if'];
1125
		$gateway_settings6['gateway'] = $_POST['gatewayip6'];
1126
		$gateway_settings6['descr'] = $_POST['gatewaydescr6'];
1127
		$gateway_settings6['defaultgw'] = $_POST['defaultgw6'];
1128 264f4423 PiBa-NL
		$gateway_settings6['ipprotocol'] = 'inet6';
1129 f1bb5c7f Phil Davis
		$gw_input_errors = validate_gateway($gateway_settings6, '', $_POST['ipaddrv6'], $_POST['subnetv6']);
1130
		foreach ($gw_input_errors as $input_error_text) {
1131
			$input_errors[] = $input_error_text;
1132
		}
1133
	}
1134
1135 68933ba7 Stephen Beaver
	if (!$input_errors) {
1136 66fd7b47 Phil Davis
		// These 3 fields can be a list of multiple data items when used for MLPPP.
1137
		// The UI in this code only processes the first of the list, so save the data here then we can preserve any other entries.
1138
		$poriginal['pptp_localip'] = explode(",", $a_ppps[$pppid]['localip']);
1139
		$poriginal['pptp_subnet'] = explode(",", $a_ppps[$pppid]['subnet']);
1140
		$poriginal['pptp_remote'] = explode(",", $a_ppps[$pppid]['gateway']);
1141
1142 68933ba7 Stephen Beaver
		if ($wancfg['ipaddr'] != $_POST['type']) {
1143
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
1144
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
1145
				unset($a_ppps[$pppid]);
1146
			} else if ($wancfg['ipaddr'] == "dhcp") {
1147
				kill_dhclient_process($wancfg['if']);
1148
			}
1149 dd3d48af Viktor G
			if (($wancfg['ipaddrv6'] == "dhcp6") && ($_POST['type6'] != "dhcp6")) {
1150
				interface_dhcpv6_configure($if, $wancfg, true);
1151 68933ba7 Stephen Beaver
			}
1152
		}
1153
		$ppp = array();
1154
		if ($wancfg['ipaddr'] != "ppp") {
1155
			unset($wancfg['ipaddr']);
1156
		}
1157
		if ($wancfg['ipaddrv6'] != "ppp") {
1158
			unset($wancfg['ipaddrv6']);
1159
		}
1160
		unset($wancfg['subnet']);
1161
		unset($wancfg['gateway']);
1162
		unset($wancfg['subnetv6']);
1163
		unset($wancfg['gatewayv6']);
1164
		unset($wancfg['dhcphostname']);
1165
		unset($wancfg['dhcprejectfrom']);
1166
		unset($wancfg['dhcp6-duid']);
1167
		unset($wancfg['dhcp6-ia-pd-len']);
1168
		unset($wancfg['dhcp6-ia-pd-send-hint']);
1169
		unset($wancfg['dhcp6prefixonly']);
1170
		unset($wancfg['dhcp6usev4iface']);
1171 9210d0aa Viktor Gurov
		unset($wancfg['slaacusev4iface']);
1172 b7331383 marjohn56
		unset($wancfg['ipv6usev4iface']);
1173 68933ba7 Stephen Beaver
		unset($wancfg['track6-interface']);
1174
		unset($wancfg['track6-prefix-id']);
1175 8c661bc8 marjohn56
		unset($wancfg['dhcp6withoutra']);
1176 6b8680a7 marjohn56
		unset($wancfg['dhcp6vlanenable']);
1177
		unset($wancfg['dhcp6cvpt']);
1178 68933ba7 Stephen Beaver
		unset($wancfg['prefix-6rd']);
1179
		unset($wancfg['prefix-6rd-v4plen']);
1180
		unset($wancfg['gateway-6rd']);
1181
1182 62ed56dc Luiz Souza
		unset($wancfg['dhcpvlanenable']);
1183
		unset($wancfg['dhcpcvpt']);
1184
1185 68933ba7 Stephen Beaver
		unset($wancfg['adv_dhcp_pt_timeout']);
1186
		unset($wancfg['adv_dhcp_pt_retry']);
1187
		unset($wancfg['adv_dhcp_pt_select_timeout']);
1188
		unset($wancfg['adv_dhcp_pt_reboot']);
1189
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
1190
		unset($wancfg['adv_dhcp_pt_initial_interval']);
1191
1192
		unset($wancfg['adv_dhcp_pt_values']);
1193
1194
		unset($wancfg['adv_dhcp_send_options']);
1195
		unset($wancfg['adv_dhcp_request_options']);
1196
		unset($wancfg['adv_dhcp_required_options']);
1197
		unset($wancfg['adv_dhcp_option_modifiers']);
1198
1199
		unset($wancfg['adv_dhcp_config_advanced']);
1200
		unset($wancfg['adv_dhcp_config_file_override']);
1201
		unset($wancfg['adv_dhcp_config_file_override_path']);
1202
1203
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
1204
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
1205
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
1206
		unset($wancfg['adv_dhcp6_interface_statement_script']);
1207
1208
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
1209
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
1210
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
1211
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
1212
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
1213
1214
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
1215
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
1216
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
1217
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
1218
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
1219
1220
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
1221
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
1222 58a185ae marjohn56
		unset($wancfg['adv_dhcp6_prefix_selected_interface']);
1223 68933ba7 Stephen Beaver
1224
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
1225
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
1226
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
1227
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
1228
1229
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
1230
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
1231
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
1232
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
1233
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
1234
1235
		unset($wancfg['adv_dhcp6_config_advanced']);
1236
		unset($wancfg['adv_dhcp6_config_file_override']);
1237
		unset($wancfg['adv_dhcp6_config_file_override_path']);
1238
1239
		unset($wancfg['pppoe_password']);
1240
		unset($wancfg['pptp_username']);
1241
		unset($wancfg['pptp_password']);
1242 8e267d3b Viktor G
		unset($wancfg['l2tp_secret']);
1243 68933ba7 Stephen Beaver
		unset($wancfg['provider']);
1244 71465708 Viktor G
		unset($wancfg['hostuniq']);
1245 68933ba7 Stephen Beaver
		unset($wancfg['ondemand']);
1246
		unset($wancfg['timeout']);
1247
		if (empty($wancfg['pppoe']['pppoe-reset-type'])) {
1248
			unset($wancfg['pppoe']['pppoe-reset-type']);
1249
		}
1250
		unset($wancfg['local']);
1251
1252
		unset($wancfg['remote']);
1253
		if (is_array($a_ppps[$pppid]) && in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
1254
			if ($wancfg['ipaddr'] != 'ppp') {
1255
				unset($a_ppps[$pppid]['apn']);
1256
				unset($a_ppps[$pppid]['phone']);
1257
				unset($a_ppps[$pppid]['provider']);
1258
				unset($a_ppps[$pppid]['ondemand']);
1259
			}
1260
			if (in_array($wancfg['ipaddr'], array("pppoe", "pptp", "l2tp"))) {
1261
				unset($a_ppps[$pppid]['localip']);
1262
				unset($a_ppps[$pppid]['subnet']);
1263
				unset($a_ppps[$pppid]['gateway']);
1264
			}
1265
			if ($wancfg['ipaddr'] != 'pppoe') {
1266
				unset($a_ppps[$pppid]['pppoe-reset-type']);
1267 71465708 Viktor G
				unset($a_ppps[$pppid]['hostuniq']);
1268 68933ba7 Stephen Beaver
			}
1269
			if ($wancfg['type'] != $_POST['type']) {
1270
				unset($a_ppps[$pppid]['idletimeout']);
1271
			}
1272
		}
1273
1274
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
1275
		$wancfg['enable'] = $_POST['enable'] == "yes" ? true : false;
1276
1277
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
1278
		switch ($_POST['type']) {
1279
			case "staticv4":
1280
				$wancfg['ipaddr'] = $_POST['ipaddr'];
1281
				$wancfg['subnet'] = $_POST['subnet'];
1282
				if ($_POST['gateway'] != "none") {
1283
					$wancfg['gateway'] = $_POST['gateway'];
1284
				}
1285
				break;
1286
			case "dhcp":
1287
				$wancfg['ipaddr'] = "dhcp";
1288
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
1289
				$wancfg['alias-address'] = $_POST['alias-address'];
1290
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
1291
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
1292
1293
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
1294
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
1295
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
1296
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
1297
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
1298
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
1299
1300
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
1301
1302
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
1303
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
1304
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
1305
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
1306
1307
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
1308
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
1309
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
1310
1311
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
1312
				if ($gateway_item) {
1313
					$a_gateways[] = $gateway_item;
1314
				}
1315 62ed56dc Luiz Souza
				if ($_POST['dhcpvlanenable'] == "yes") {
1316
					$wancfg['dhcpvlanenable'] = true;
1317
				}
1318
				if (!empty($_POST['dhcpcvpt'])) {
1319
					$wancfg['dhcpcvpt'] = $_POST['dhcpcvpt'];
1320
				} else {
1321
					unset($wancfg['dhcpcvpt']);
1322
				}
1323 68933ba7 Stephen Beaver
				break;
1324
			case "ppp":
1325
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1326
				$a_ppps[$pppid]['type'] = $_POST['type'];
1327
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1328
				$a_ppps[$pppid]['ports'] = $_POST['port'];
1329
				$a_ppps[$pppid]['username'] = $_POST['ppp_username'];
1330 76d6d925 Stephen Beaver
				if ($_POST['ppp_password'] != DMYPWD) {
1331
					$a_ppps[$pppid]['password'] = base64_encode($_POST['ppp_password']);
1332
				}
1333 68933ba7 Stephen Beaver
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
1334
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
1335
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
1336
				$wancfg['ipaddr'] = $_POST['type'];
1337
				break;
1338
1339
			case "pppoe":
1340
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1341
				$a_ppps[$pppid]['type'] = $_POST['type'];
1342
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1343 6a9435a6 Viktor G
				if (isset($_POST['ppp_port'])) {
1344
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1345
				} else {
1346
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1347
				}
1348 68933ba7 Stephen Beaver
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
1349 76d6d925 Stephen Beaver
				if ($_POST['pppoe_password'] != DMYPWD) {
1350
					$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
1351
				}
1352 68933ba7 Stephen Beaver
				if (!empty($_POST['provider'])) {
1353
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
1354
				} else {
1355
					$a_ppps[$pppid]['provider'] = true;
1356
				}
1357 71465708 Viktor G
				if (!empty($_POST['hostuniq'])) {
1358
					$a_ppps[$pppid]['hostuniq'] = strtolower($_POST['hostuniq']);
1359
				} else {
1360
					$a_ppps[$pppid]['hostuniq'] = true;
1361
				}
1362 68933ba7 Stephen Beaver
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
1363
				if (!empty($_POST['pppoe_idletimeout'])) {
1364
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
1365
				} else {
1366
					unset($a_ppps[$pppid]['idletimeout']);
1367
				}
1368
1369
				if (!empty($_POST['pppoe-reset-type'])) {
1370
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
1371
				} else {
1372
					unset($a_ppps[$pppid]['pppoe-reset-type']);
1373
				}
1374
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1375
				$wancfg['ipaddr'] = $_POST['type'];
1376
				if ($gateway_item) {
1377
					$a_gateways[] = $gateway_item;
1378
				}
1379
1380
				break;
1381
			case "pptp":
1382
			case "l2tp":
1383
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1384
				$a_ppps[$pppid]['type'] = $_POST['type'];
1385
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1386 6a9435a6 Viktor G
				if (isset($_POST['ppp_port'])) {
1387
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1388
				} else {
1389
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1390
				}
1391 68933ba7 Stephen Beaver
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
1392 76d6d925 Stephen Beaver
				if ($_POST['pptp_password'] != DMYPWD) {
1393
					$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
1394
				}
1395 8e267d3b Viktor G
				if (($_POST['type'] == 'l2tp') && (!empty($_POST['l2tp_secret']))) {
1396
					$a_ppps[$pppid]['secret'] = base64_encode($_POST['l2tp_secret']);
1397
				} else {
1398
					unset($a_ppps[$pppid]['secret']);
1399
				}
1400 66fd7b47 Phil Davis
				// Replace the first (0) entry with the posted data. Preserve any other entries that might be there.
1401
				$poriginal['pptp_localip'][0] = $_POST['pptp_local0'];
1402
				$a_ppps[$pppid]['localip'] = implode(',', $poriginal['pptp_localip']);
1403
				$poriginal['pptp_subnet'][0] = $_POST['pptp_subnet0'];
1404
				$a_ppps[$pppid]['subnet'] = implode(',', $poriginal['pptp_subnet']);
1405
				$poriginal['pptp_remote'][0] = $_POST['pptp_remote0'];
1406
				$a_ppps[$pppid]['gateway'] = implode(',', $poriginal['pptp_remote']);
1407 68933ba7 Stephen Beaver
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
1408
				if (!empty($_POST['pptp_idletimeout'])) {
1409
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
1410
				} else {
1411
					unset($a_ppps[$pppid]['idletimeout']);
1412
				}
1413
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1414
				$wancfg['ipaddr'] = $_POST['type'];
1415
				if ($gateway_item) {
1416
					$a_gateways[] = $gateway_item;
1417
				}
1418
				break;
1419
			case "none":
1420
				break;
1421
		}
1422
		switch ($_POST['type6']) {
1423
			case "staticv6":
1424
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
1425
				$wancfg['subnetv6'] = $_POST['subnetv6'];
1426 b7331383 marjohn56
				if ($_POST['ipv6usev4iface'] == "yes") {
1427
					$wancfg['ipv6usev4iface'] = true;
1428
				}
1429 68933ba7 Stephen Beaver
				if ($_POST['gatewayv6'] != "none") {
1430
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
1431
				}
1432
				break;
1433
			case "slaac":
1434
				$wancfg['ipaddrv6'] = "slaac";
1435 9210d0aa Viktor Gurov
				if ($_POST['slaacusev4iface'] == "yes") {
1436
					$wancfg['slaacusev4iface'] = true;
1437 c9b49393 Viktor Gurov
				}
1438 68933ba7 Stephen Beaver
				break;
1439
			case "dhcp6":
1440
				$wancfg['ipaddrv6'] = "dhcp6";
1441
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
1442
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
1443
				if ($_POST['dhcp6-ia-pd-send-hint'] == "yes") {
1444
					$wancfg['dhcp6-ia-pd-send-hint'] = true;
1445
				}
1446
				if ($_POST['dhcp6prefixonly'] == "yes") {
1447
					$wancfg['dhcp6prefixonly'] = true;
1448
				}
1449
				if ($_POST['dhcp6usev4iface'] == "yes") {
1450
					$wancfg['dhcp6usev4iface'] = true;
1451
				}
1452 8c661bc8 marjohn56
				if ($_POST['dhcp6withoutra'] == "yes") {
1453
					$wancfg['dhcp6withoutra'] = true;
1454
				}
1455 6b8680a7 marjohn56
				if ($_POST['dhcp6vlanenable'] == "yes") {
1456
					$wancfg['dhcp6vlanenable'] = true;
1457
				}
1458
				if (!empty($_POST['dhcp6cvpt'])) {
1459
					$wancfg['dhcp6cvpt'] = $_POST['dhcp6cvpt'];
1460
				} else {
1461
					unset($wancfg['dhcp6cvpt']);
1462
				}
1463
1464 68933ba7 Stephen Beaver
				if (!empty($_POST['adv_dhcp6_interface_statement_send_options'])) {
1465
					$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1466
				}
1467
				if (!empty($_POST['adv_dhcp6_interface_statement_request_options'])) {
1468
					$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1469
				}
1470
				if (isset($_POST['adv_dhcp6_interface_statement_information_only_enable'])) {
1471
					$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1472
				}
1473
				if (!empty($_POST['adv_dhcp6_interface_statement_script'])) {
1474
					$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1475
				}
1476
1477
				if (isset($_POST['adv_dhcp6_id_assoc_statement_address_enable'])) {
1478
					$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1479
				}
1480
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address'])) {
1481
					$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1482
				}
1483
				if (is_numericint($_POST['adv_dhcp6_id_assoc_statement_address_id'])) {
1484
					$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1485
				}
1486
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_pltime'])) {
1487
					$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1488
				}
1489
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_vltime'])) {
1490
					$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1491
				}
1492
1493
				if (isset($_POST['adv_dhcp6_id_assoc_statement_prefix_enable'])) {
1494
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1495
				}
1496
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix'])) {
1497
					$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1498
				}
1499
				if (is_numericint($_POST['adv_dhcp6_id_assoc_statement_prefix_id'])) {
1500
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1501
				}
1502
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'])) {
1503
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1504
				}
1505
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'])) {
1506
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1507
				}
1508
1509
				if (is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_id'])) {
1510
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1511
				}
1512
				if (is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_len'])) {
1513
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1514
				}
1515 58a185ae marjohn56
				if (!empty($_POST['adv_dhcp6_prefix_selected_interface'])) {
1516
					$wancfg['adv_dhcp6_prefix_selected_interface'] = $_POST['adv_dhcp6_prefix_selected_interface'];
1517
				}
1518 68933ba7 Stephen Beaver
				if (!empty($_POST['adv_dhcp6_authentication_statement_authname'])) {
1519
					$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1520
				}
1521
				if (!empty($_POST['adv_dhcp6_authentication_statement_protocol'])) {
1522
					$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1523
				}
1524
				if (!empty($_POST['adv_dhcp6_authentication_statement_algorithm'])) {
1525
					$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1526
				}
1527
				if (!empty($_POST['adv_dhcp6_authentication_statement_rdm'])) {
1528
					$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1529
				}
1530
1531
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyname'])) {
1532
					$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1533
				}
1534
				if (!empty($_POST['adv_dhcp6_key_info_statement_realm'])) {
1535
					$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1536
				}
1537
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyid'])) {
1538
					$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1539
				}
1540
				if (!empty($_POST['adv_dhcp6_key_info_statement_secret'])) {
1541
					$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1542
				}
1543
				if (!empty($_POST['adv_dhcp6_key_info_statement_expire'])) {
1544
					$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1545
				}
1546
1547
				if (!empty($_POST['adv_dhcp6_config_advanced'])) {
1548
					$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1549
				}
1550
				if (!empty($_POST['adv_dhcp6_config_file_override'])) {
1551
					$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1552
				}
1553
				if (!empty($_POST['adv_dhcp6_config_file_override_path'])) {
1554
					$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1555
				}
1556
1557
				if ($gateway_item) {
1558
					$a_gateways[] = $gateway_item;
1559
				}
1560
				break;
1561
			case "6rd":
1562
				$wancfg['ipaddrv6'] = "6rd";
1563
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1564
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1565
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1566
				if ($gateway_item) {
1567
					$a_gateways[] = $gateway_item;
1568
				}
1569
				break;
1570
			case "6to4":
1571
				$wancfg['ipaddrv6'] = "6to4";
1572
				break;
1573
			case "track6":
1574
				$wancfg['ipaddrv6'] = "track6";
1575
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1576
				if ($_POST['track6-prefix-id--hex'] === "") {
1577
					$wancfg['track6-prefix-id'] = 0;
1578 b6f6210a jim-p
				} else if (ctype_xdigit($_POST['track6-prefix-id--hex'])) {
1579 68933ba7 Stephen Beaver
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1580
				} else {
1581
					$wancfg['track6-prefix-id'] = 0;
1582
				}
1583
				break;
1584
			case "none":
1585
				break;
1586
		}
1587
		handle_pppoe_reset($_POST);
1588
1589
		if ($_POST['blockpriv'] == "yes") {
1590
			$wancfg['blockpriv'] = true;
1591
		} else {
1592
			unset($wancfg['blockpriv']);
1593
		}
1594
		if ($_POST['blockbogons'] == "yes") {
1595
			$wancfg['blockbogons'] = true;
1596
		} else {
1597
			unset($wancfg['blockbogons']);
1598
		}
1599
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1600 04d726ac Reid Linnemann
		/* Only update MTU in the config if the if is not a member of a
1601
		 * bridge. The display will show the bridge MTU in a disabled input
1602
		 * field, and we will maintain the user configured MTU for initial
1603
		 * configuration and in the event that the interface is removed from the
1604
		 * bridge it will return to its original MTU. */
1605
		if (!$bridged) {
1606
			if (empty($_POST['mtu'])) {
1607
				unset($wancfg['mtu']);
1608
			} else {
1609
				$wancfg['mtu'] = $_POST['mtu'];
1610
			}
1611 68933ba7 Stephen Beaver
		}
1612
		if (empty($_POST['mss'])) {
1613
			unset($wancfg['mss']);
1614
		} else {
1615
			$wancfg['mss'] = $_POST['mss'];
1616
		}
1617
		if (empty($_POST['mediaopt'])) {
1618
			unset($wancfg['media']);
1619
			unset($wancfg['mediaopt']);
1620
		} else {
1621
			$mediaopts = explode(' ', $_POST['mediaopt']);
1622
			if ($mediaopts[0] != '') {
1623
				$wancfg['media'] = $mediaopts[0];
1624
			}
1625
			if ($mediaopts[1] != '') {
1626
				$wancfg['mediaopt'] = $mediaopts[1];
1627
			} else {
1628
				unset($wancfg['mediaopt']);
1629
			}
1630
		}
1631
		if (isset($wancfg['wireless'])) {
1632
			handle_wireless_post();
1633
		}
1634
1635 e85ae672 Renato Botelho do Couto
		write_config("Interfaces settings changed");
1636 68933ba7 Stephen Beaver
1637 f1bb5c7f Phil Davis
		if ($_POST['gatewayip4']) {
1638
			save_gateway($gateway_settings4);
1639
		}
1640
1641
		if ($_POST['gatewayip6']) {
1642
			save_gateway($gateway_settings6);
1643
		}
1644
1645 68933ba7 Stephen Beaver
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1646
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1647
		} else {
1648
			$toapplylist = array();
1649
		}
1650
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1651
		$toapplylist[$if]['ppps'] = $old_ppps;
1652
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1653
1654
		mark_subsystem_dirty('interfaces');
1655
1656
		/* regenerate cron settings/crontab file */
1657
		configure_cron();
1658
1659
		header("Location: interfaces.php?if={$if}");
1660
		exit;
1661
	}
1662 c0948c6c Renato Botelho
1663 6a9435a6 Viktor G
	/* keep port value, see https://redmine.pfsense.org/issues/12498 */
1664
	if (!empty($_POST['ppp_port'])) {
1665
		$pconfig['port'] = $_POST['ppp_port'];
1666
	}
1667
1668 4401107f Steve Beaver
} // end if ($_POST['save'])
1669 270c4607 Scott Ullrich
1670 25a6411a Scott Ullrich
function handle_wireless_post() {
1671 2d5c75fa Reid Linnemann
	global $_POST, $config, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1672 68933ba7 Stephen Beaver
	if (!is_array($wancfg['wireless'])) {
1673
		$wancfg['wireless'] = array();
1674
	}
1675
	$wancfg['wireless']['standard'] = $_POST['standard'];
1676
	$wancfg['wireless']['mode'] = $_POST['mode'];
1677
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1678
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1679
	$wancfg['wireless']['channel'] = $_POST['channel'];
1680 91fd7459 Viktor G
	$wancfg['wireless']['channel_width'] = $_POST['channel_width'];
1681 68933ba7 Stephen Beaver
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1682
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1683
	$wancfg['wireless']['distance'] = $_POST['distance'];
1684
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1685
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1686
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1687
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1688
		foreach ($wl_countries_attr as $wl_country) {
1689
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1690
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1691
				break;
1692
			}
1693
		}
1694
	}
1695
	if (!is_array($wancfg['wireless']['wpa'])) {
1696
		$wancfg['wireless']['wpa'] = array();
1697
	}
1698
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1699
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1700
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1701
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1702
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1703
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1704
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1705
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1706 5f120301 Viktor G
	$wancfg['wireless']['wpa']['wpa_eap_client_mode'] = $_POST['wpa_eap_client_mode'];
1707
	$wancfg['wireless']['wpa']['wpa_eap_inner_auth'] = $_POST['wpa_eap_inner_auth'];
1708
	$wancfg['wireless']['wpa']['wpa_eap_inner_id'] = $_POST['wpa_eap_inner_id'];
1709
	$wancfg['wireless']['wpa']['wpa_eap_inner_password'] = base64_encode($_POST['wpa_eap_inner_password']);
1710
	$wancfg['wireless']['wpa']['wpa_eap_cert'] = $_POST['wpa_eap_cert'];
1711
	$wancfg['wireless']['wpa']['wpa_eap_ca'] = $_POST['wpa_eap_ca'];
1712 68933ba7 Stephen Beaver
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1713
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1714
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1715
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1716
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1717
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1718
1719
	if ($_POST['persistcommonwireless'] == "yes") {
1720
		if (!is_array($config['wireless'])) {
1721 721fafba Christian McDonald
			config_set_path('wireless', array());
1722 68933ba7 Stephen Beaver
		}
1723 2d5c75fa Reid Linnemann
		if (!is_array(config_get_path('wireless/interfaces'))) {
1724 721fafba Christian McDonald
			config_set_path('wireless/interfaces', array());
1725 68933ba7 Stephen Beaver
		}
1726
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif])) {
1727
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1728
		}
1729
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif])) {
1730 7e3ea4a8 Christian McDonald
		config_del_path("wireless/interfaces/{$wlanbaseif}");
1731 68933ba7 Stephen Beaver
	}
1732
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity'])) {
1733
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1734
	} else if (isset($wancfg['wireless']['diversity'])) {
1735
		unset($wancfg['wireless']['diversity']);
1736
	}
1737
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna'])) {
1738
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1739
	} else if (isset($wancfg['wireless']['txantenna'])) {
1740
		unset($wancfg['wireless']['txantenna']);
1741
	}
1742
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna'])) {
1743
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1744
	} else if (isset($wancfg['wireless']['rxantenna'])) {
1745
		unset($wancfg['wireless']['rxantenna']);
1746
	}
1747
	if ($_POST['hidessid_enable'] == "yes") {
1748
		$wancfg['wireless']['hidessid']['enable'] = true;
1749
	} else if (isset($wancfg['wireless']['hidessid']['enable'])) {
1750
		unset($wancfg['wireless']['hidessid']['enable']);
1751
	}
1752
	if ($_POST['mac_acl_enable'] == "yes") {
1753
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1754
	} else if (isset($wancfg['wireless']['wpa']['mac_acl_enable'])) {
1755
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1756
	}
1757
	if ($_POST['rsn_preauth'] == "yes") {
1758
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1759
	} else {
1760
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1761
	}
1762
	if ($_POST['ieee8021x'] == "yes") {
1763
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1764
	} else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable'])) {
1765
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1766
	}
1767
	if ($_POST['wpa_strict_rekey'] == "yes") {
1768
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1769
	} else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey'])) {
1770
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1771
	}
1772
	if ($_POST['debug_mode'] == "yes") {
1773
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1774
	} else if (isset($wancfg['wireless']['wpa']['debug_mode'])) {
1775
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1776
	}
1777
	if ($_POST['wpa_enable'] == "yes") {
1778
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1779
	} else if (isset($wancfg['wireless']['wpa']['enable'])) {
1780
		unset($wancfg['wireless']['wpa']['enable']);
1781
	}
1782
1783
	if ($_POST['wme_enable'] == "yes") {
1784
		if (!is_array($wancfg['wireless']['wme'])) {
1785
			$wancfg['wireless']['wme'] = array();
1786
		}
1787
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1788
	} else if (isset($wancfg['wireless']['wme']['enable'])) {
1789
		unset($wancfg['wireless']['wme']['enable']);
1790
	}
1791
	if ($_POST['puremode'] == "11g") {
1792
		if (!is_array($wancfg['wireless']['pureg'])) {
1793
			$wancfg['wireless']['pureg'] = array();
1794
		}
1795
		$wancfg['wireless']['pureg']['enable'] = true;
1796
	} else if ($_POST['puremode'] == "11n") {
1797
		if (!is_array($wancfg['wireless']['puren'])) {
1798
			$wancfg['wireless']['puren'] = array();
1799
		}
1800
		$wancfg['wireless']['puren']['enable'] = true;
1801
	} else {
1802
		if (isset($wancfg['wireless']['pureg'])) {
1803
			unset($wancfg['wireless']['pureg']);
1804
		}
1805
		if (isset($wancfg['wireless']['puren'])) {
1806
			unset($wancfg['wireless']['puren']);
1807
		}
1808
	}
1809
	if ($_POST['apbridge_enable'] == "yes") {
1810
		if (!is_array($wancfg['wireless']['apbridge'])) {
1811
			$wancfg['wireless']['apbridge'] = array();
1812
		}
1813
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1814
	} else if (isset($wancfg['wireless']['apbridge']['enable'])) {
1815
		unset($wancfg['wireless']['apbridge']['enable']);
1816
	}
1817
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1818
		if (!is_array($wancfg['wireless']['turbo'])) {
1819
			$wancfg['wireless']['turbo'] = array();
1820
		}
1821
		$wancfg['wireless']['turbo']['enable'] = true;
1822
	} else if (isset($wancfg['wireless']['turbo']['enable'])) {
1823
		unset($wancfg['wireless']['turbo']['enable']);
1824
	}
1825
1826
	interface_sync_wireless_clones($wancfg, true);
1827 5b237745 Scott Ullrich
}
1828 7f43ca88 Scott Ullrich
1829 597330aa Erik Fonnesbeck
function check_wireless_mode() {
1830 68933ba7 Stephen Beaver
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1831
1832
	if ($wancfg['wireless']['mode'] == $_POST['mode']) {
1833
		return;
1834
	}
1835
1836
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif))) {
1837
		$clone_count = 1;
1838
	} else {
1839
		$clone_count = 0;
1840
	}
1841
1842 2d5c75fa Reid Linnemann
	foreach (config_get_path('wireless/clone', []) as $clone) {
1843
		if ($clone['if'] == $wlanbaseif) {
1844 68933ba7 Stephen Beaver
				$clone_count++;
1845
		}
1846
	}
1847
1848
	if ($clone_count > 1) {
1849
		$old_wireless_mode = $wancfg['wireless']['mode'];
1850
		$wancfg['wireless']['mode'] = $_POST['mode'];
1851
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1852 e4517c3c jim-p
			$input_errors[] = sprintf(gettext("Unable to change mode to %s. The maximum number of wireless clones supported in this mode may have been reached."), $wlan_modes[$wancfg['wireless']['mode']]);
1853 68933ba7 Stephen Beaver
		} else {
1854 414aa359 Renato Botelho
			pfSense_interface_destroy("{$wlanif}_");
1855 68933ba7 Stephen Beaver
		}
1856
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1857
	}
1858 597330aa Erik Fonnesbeck
}
1859
1860 509ca889 Evgeny Yurchenko
// Find all possible media options for the interface
1861
$mediaopts_list = array();
1862 2d5c75fa Reid Linnemann
$intrealname = config_get_path("interfaces/{$if}/if");
1863 281dede0 Renato Botelho do Couto
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1864
foreach ($mediaopts as $mediaopt) {
1865
	preg_match("/media (.*)/", $mediaopt, $matches);
1866
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)) {
1867
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1868
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1869
	} else {
1870
		// there is only media like "media 1000baseT"
1871
		array_push($mediaopts_list, $matches[1]);
1872 68933ba7 Stephen Beaver
	}
1873 509ca889 Evgeny Yurchenko
}
1874
1875 cc240e32 jim-p
$pgtitle = array(gettext("Interfaces"), "{$wancfg['descr']} ({$realifname})");
1876 b32dd0a6 jim-p
$shortcut_section = "interfaces";
1877 af1e2031 jim-p
1878 7957389b Viktor G
$types4 = array("ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1879
1880
if (!in_array($pconfig['type'], array("ppp", "pppoe", "pptp", "l2tp")) ||
1881
   !array_key_exists($a_ppps[$pppid]['ports'], get_configured_interface_list_by_realif())) { 
1882
	$types4 = array_merge(array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP")), $types4);
1883
}
1884
1885 feb88a14 smos
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "slaac" => gettext("SLAAC"), "6rd" => gettext("6rd Tunnel"), "6to4" => gettext("6to4 Tunnel"), "track6" => gettext("Track Interface"));
1886 7f43ca88 Scott Ullrich
1887 ae4c4bac Stephen Beaver
// Get the MAC address
1888 f1bb5c7f Phil Davis
$defgatewayname4 = $wancfg['descr'] . "GW";
1889
$defgatewayname6 = $wancfg['descr'] . "GWv6";
1890 ae4c4bac Stephen Beaver
1891
function build_mediaopts_list() {
1892 68933ba7 Stephen Beaver
	global $mediaopts_list;
1893 a0509b13 Stephen Beaver
1894 0fc3de67 Phil Davis
	$list = [""	 =>	 gettext("Default (no preference, typically autoselect)"),
1895
			 " " =>	 gettext("------- Media Supported by this interface -------")
1896 68933ba7 Stephen Beaver
			];
1897 a0509b13 Stephen Beaver
1898 68933ba7 Stephen Beaver
	foreach ($mediaopts_list as $mediaopt) {
1899
		$list[$mediaopt] = $mediaopt;
1900
	}
1901 a0509b13 Stephen Beaver
1902 68933ba7 Stephen Beaver
	return($list);
1903 ae4c4bac Stephen Beaver
}
1904 9978e156 gnhb
1905 ae4c4bac Stephen Beaver
function build_gateway_list() {
1906 9f3f4276 Stephen Beaver
	global $a_gateways, $if;
1907 a0509b13 Stephen Beaver
1908 0fc3de67 Phil Davis
	$list = array("none" => gettext("None"));
1909 68933ba7 Stephen Beaver
	foreach ($a_gateways as $gateway) {
1910 b767ea71 jim-p
		if (empty($gateway)) {
1911
			continue;
1912
		}
1913 68933ba7 Stephen Beaver
		if (($gateway['interface'] == $if) && (is_ipaddrv4($gateway['gateway']))) {
1914
			$list[$gateway['name']] = $gateway['name'] . " - " . $gateway['gateway'];
1915
		}
1916
	}
1917 a0509b13 Stephen Beaver
1918 68933ba7 Stephen Beaver
	return($list);
1919 ae4c4bac Stephen Beaver
}
1920 1caf2209 Phil Davis
1921 9f3f4276 Stephen Beaver
function build_gatewayv6_list() {
1922
	global $a_gateways, $if;
1923
1924 0fc3de67 Phil Davis
	$list = array("none" => gettext("None"));
1925 9f3f4276 Stephen Beaver
	foreach ($a_gateways as $gateway) {
1926 b767ea71 jim-p
		if (empty($gateway)) {
1927
			continue;
1928
		}
1929 9f3f4276 Stephen Beaver
		if (($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1930
			$list[$gateway['name']] = $gateway['name'] . " - " . $gateway['gateway'];
1931
		}
1932
	}
1933
1934
	return($list);
1935
}
1936
1937 ae4c4bac Stephen Beaver
include("head.inc");
1938 4634cb48 Ermal Luçi
1939 aa82505e Phil Davis
if ($input_errors) {
1940 68933ba7 Stephen Beaver
	print_input_errors($input_errors);
1941 aa82505e Phil Davis
}
1942 a0509b13 Stephen Beaver
1943 aa82505e Phil Davis
if (is_subsystem_dirty('interfaces')) {
1944 3b3a95e5 Phil Davis
	print_apply_box(sprintf(gettext("The %s configuration has been changed."), $wancfg['descr']) . "<br />" .
1945 e4517c3c jim-p
					gettext("The changes must be applied to take effect.") . "<br />" .
1946 f4bed461 k-paulius
					gettext("Don't forget to adjust the DHCP Server range if needed after applying."));
1947 aa82505e Phil Davis
}
1948 a0509b13 Stephen Beaver
1949 44c42356 Phil Davis
if ($changes_applied) {
1950
	print_apply_result_box($retval);
1951 aa82505e Phil Davis
}
1952 ae4c4bac Stephen Beaver
1953 8f58b51b jim-p
$form = new Form();
1954 ae4c4bac Stephen Beaver
1955 5f88f964 k-paulius
$section = new Form_Section('General Configuration');
1956 ae4c4bac Stephen Beaver
1957
$section->addInput(new Form_Checkbox(
1958 68933ba7 Stephen Beaver
	'enable',
1959
	'Enable',
1960
	'Enable interface',
1961
	$pconfig['enable'],
1962
	'yes'
1963 ae4c4bac Stephen Beaver
));
1964
1965
$section->addInput(new Form_Input(
1966 68933ba7 Stephen Beaver
	'descr',
1967 1095b204 Phil Davis
	'*Description',
1968 68933ba7 Stephen Beaver
	'text',
1969
	$pconfig['descr']
1970 ae4c4bac Stephen Beaver
))->setHelp('Enter a description (name) for the interface here.');
1971
1972 cc240e32 jim-p
if ($show_address_controls) {
1973
	$section->addInput(new Form_Select(
1974
		'type',
1975
		'IPv4 Configuration Type',
1976
		$pconfig['type'],
1977
		$types4
1978
	));
1979
	$section->addInput(new Form_Select(
1980
		'type6',
1981
		'IPv6 Configuration Type',
1982
		$pconfig['type6'],
1983
		$types6
1984
	));
1985
} else {
1986
	$section->addInput(new Form_StaticText(
1987
		'IPv4/IPv6 Configuration',
1988
		"This interface type does not support manual address configuration on this page. "
1989
	));
1990 ee12dd78 Peter Feichtinger
	$form->addGlobal(new Form_Input(
1991 cc240e32 jim-p
		'type',
1992
		null,
1993
		'hidden',
1994
		'none'
1995
	));
1996 ee12dd78 Peter Feichtinger
	$form->addGlobal(new Form_Input(
1997 cc240e32 jim-p
		'type6',
1998
		null,
1999
		'hidden',
2000
		'none'
2001
	));
2002
}
2003 ae4c4bac Stephen Beaver
2004 a628e8ca Viktor G
if (!is_pseudo_interface($intrealname, true)) {
2005
	$macaddress = new Form_Input(
2006
		'spoofmac',
2007
		'MAC Address',
2008
		'text',
2009
		$pconfig['spoofmac'],
2010
		['placeholder' => 'xx:xx:xx:xx:xx:xx']
2011
	);
2012
2013
	if (interface_is_vlan($realifname)) {
2014
		$macaddress->setDisabled();
2015
		$macaddress->setHelp('The MAC address of a VLAN interface must be ' .
2016
		    'set on its parent interface');
2017
	} else {
2018
		$macaddress->setHelp('This field can be used to modify ("spoof") the ' .
2019
		    'MAC address of this interface.%sEnter a MAC address in the ' .
2020
		    'following format: xx:xx:xx:xx:xx:xx or leave blank.', '<br />');
2021
	}
2022 ae4c4bac Stephen Beaver
2023 a628e8ca Viktor G
	$section->addInput($macaddress);
2024
}
2025 ae4c4bac Stephen Beaver
2026 04d726ac Reid Linnemann
$mtuInput = $section->addInput(new Form_Input(
2027 692b5e02 Stephen Beaver
	'mtu',
2028
	'MTU',
2029
	'number',
2030 04d726ac Reid Linnemann
	$pconfig['mtu'],
2031 eaa948d6 NOYB
))->setHelp('If this field is blank, the adapter\'s default MTU will be used. ' .
2032 692b5e02 Stephen Beaver
			'This is typically 1500 bytes but can vary in some circumstances.');
2033 04d726ac Reid Linnemann
/* Do not allow MTU changes for interfaces in a bridge */
2034
if ($bridged) {
2035
	$mtuInput->setDisabled();
2036
	$mtuInput->setHelp('This interface is a bridge member, its MTU is ' .
2037
					   'controlled by its parent bridge interface');
2038
	$mtuInput->setPlaceholder(get_interface_mtu($bridged));
2039
	$mtuInput->setValue(null);
2040
}
2041 ae4c4bac Stephen Beaver
2042
$section->addInput(new Form_Input(
2043 68933ba7 Stephen Beaver
	'mss',
2044
	'MSS',
2045
	'number',
2046
	$pconfig['mss']
2047 1d378c4e Viktor G
))->setHelp('If a value is entered in this field, then MSS clamping for TCP connections to the value entered above ' .
2048
	    'minus 40 for IPv4 (TCP/IPv4 header size) and minus 60 for IPv6 (TCP/IPv6 header size) will be in effect.');
2049 ae4c4bac Stephen Beaver
2050
if (count($mediaopts_list) > 0) {
2051 68933ba7 Stephen Beaver
	$section->addInput(new Form_Select(
2052
		'mediaopt',
2053
		'Speed and Duplex',
2054 8fec79ad Marcos Mendoza
		rtrim(config_get_path("interfaces/{$if}/media", "") . ' ' . config_get_path("interfaces/{$if}/mediaopt")),
2055 2d5c75fa Reid Linnemann
		build_mediaopts_list() 
2056 4d0c9c59 Phil Davis
	))->setHelp('Explicitly set speed and duplex mode for this interface.%s' .
2057
				'WARNING: MUST be set to autoselect (automatically negotiate speed) unless the port this interface connects to has its speed and duplex forced.', '<br />');
2058 ae4c4bac Stephen Beaver
}
2059 a0509b13 Stephen Beaver
2060 ae4c4bac Stephen Beaver
$form->add($section);
2061
2062 5f88f964 k-paulius
$section = new Form_Section('Static IPv4 Configuration');
2063 3375f236 Stephen Beaver
$section->addClass('staticv4');
2064 ae4c4bac Stephen Beaver
2065
$section->addInput(new Form_IpAddress(
2066 68933ba7 Stephen Beaver
	'ipaddr',
2067 1095b204 Phil Davis
	'*IPv4 Address',
2068 41fc88ec Phil Davis
	$pconfig['ipaddr'],
2069
	'V4'
2070 ae4c4bac Stephen Beaver
))->addMask('subnet', $pconfig['subnet'], 32);
2071
2072
$group = new Form_Group('IPv4 Upstream gateway');
2073
2074
$group->add(new Form_Select(
2075 68933ba7 Stephen Beaver
	'gateway',
2076
	'IPv4 Upstream Gateway',
2077
	$pconfig['gateway'],
2078
	build_gateway_list()
2079 ae4c4bac Stephen Beaver
));
2080
2081
$group->add(new Form_Button(
2082 dfafd8c2 Phil Davis
	'addgw4',
2083 faab522f Renato Botelho
	'Add a new gateway',
2084 2e7fa7ca jim-p
	null,
2085
	'fa-plus'
2086 dfafd8c2 Phil Davis
))->setAttribute('type','button')->addClass('btn-success')->setAttribute('data-target', '#newgateway4')->setAttribute('data-toggle', 'modal');
2087 aeeda8b4 Stephen Beaver
2088 4d0c9c59 Phil Davis
$group->setHelp('If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the "Add" button.%1$s' .
2089 d6bc49df Brett Keller
				'On local area network interfaces the upstream gateway should be "none".%1$s' .
2090
				'Selecting an upstream gateway causes the firewall to treat this interface as a %2$sWAN type interface%4$s.%1$s' .
2091
				'Gateways can be managed by %3$sclicking here%4$s.', '<br />', '<a target="_blank" href="https://docs.netgate.com/pfsense/en/latest/interfaces/wanvslan.html">', '<a target="_blank" href="system_gateways.php">', '</a>');
2092 ae4c4bac Stephen Beaver
2093
$section->add($group);
2094
2095 aeeda8b4 Stephen Beaver
$form->add($section);
2096 ae4c4bac Stephen Beaver
2097 c9b49393 Viktor Gurov
$section = new Form_Section('SLAAC IPv6 Configuration');
2098
$section->addClass('slaac');
2099
2100
$section->addInput(new Form_Checkbox(
2101 9210d0aa Viktor Gurov
	'slaacusev4iface',
2102 c9b49393 Viktor Gurov
	'Use IPv4 connectivity as parent interface',
2103
	'IPv6 will use the IPv4 connectivity link (PPPoE)',
2104 9210d0aa Viktor Gurov
	$pconfig['slaacusev4iface']
2105 c9b49393 Viktor Gurov
));
2106
2107
$form->add($section);
2108
2109 5f88f964 k-paulius
$section = new Form_Section('Static IPv6 Configuration');
2110 3375f236 Stephen Beaver
$section->addClass('staticv6');
2111 ae4c4bac Stephen Beaver
2112
$section->addInput(new Form_IpAddress(
2113 68933ba7 Stephen Beaver
	'ipaddrv6',
2114 1095b204 Phil Davis
	'*IPv6 address',
2115 41fc88ec Phil Davis
	$pconfig['ipaddrv6'],
2116
	'V6'
2117 241111d7 Stephen Beaver
))->addMask('subnetv6', $pconfig['subnetv6'], 128);
2118 ae4c4bac Stephen Beaver
2119 b7331383 marjohn56
$section->addInput(new Form_Checkbox(
2120
	'ipv6usev4iface',
2121
	'Use IPv4 connectivity as parent interface',
2122 3e86fa99 marjohn56
	'IPv6 will use the IPv4 connectivity link (PPPoE)',
2123 b7331383 marjohn56
	$pconfig['ipv6usev4iface']
2124
));
2125
2126 ae4c4bac Stephen Beaver
$group = new Form_Group('IPv6 Upstream gateway');
2127
2128
$group->add(new Form_Select(
2129 68933ba7 Stephen Beaver
	'gatewayv6',
2130 2288d860 Stephen Beaver
	'IPv6 Upstream Gateway',
2131 9f3f4276 Stephen Beaver
	$pconfig['gatewayv6'],
2132
	build_gatewayv6_list()
2133 ae4c4bac Stephen Beaver
));
2134
2135
$group->add(new Form_Button(
2136 68933ba7 Stephen Beaver
	'addgw6',
2137 faab522f Renato Botelho
	'Add a new gateway',
2138 2e7fa7ca jim-p
	null,
2139
	'fa-plus'
2140 347c0214 Phil Davis
))->setAttribute('type','button')->addClass('btn-success')->setAttribute('data-target', '#newgateway6')->setAttribute('data-toggle', 'modal');
2141 ae4c4bac Stephen Beaver
2142 4d0c9c59 Phil Davis
$group->setHelp('If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the "Add" button.%s' .
2143
				'On local LANs the upstream gateway should be "none". ', '<br />');
2144 a0509b13 Stephen Beaver
2145 8b5aac9f Stephen Beaver
$section->add($group);
2146
$form->add($section);
2147 ae4c4bac Stephen Beaver
2148 8b5aac9f Stephen Beaver
// Add new gateway modal pop-up for IPv6
2149 5f88f964 k-paulius
$modal = new Modal('New IPv6 Gateway', 'newgateway6', 'large');
2150 8b5aac9f Stephen Beaver
2151
$modal->addInput(new Form_Checkbox(
2152 68933ba7 Stephen Beaver
	'defaultgw6',
2153
	'Default',
2154
	'Default gateway',
2155 e8113404 Phil Davis
	isset($gateway_settings6['defaultgw']) ? $gateway_settings6['defaultgw'] : ($if == "wan" || $if == "WAN")
2156 ae4c4bac Stephen Beaver
));
2157
2158 8b5aac9f Stephen Beaver
$modal->addInput(new Form_Input(
2159 dfafd8c2 Phil Davis
	'gatewayname6',
2160 68933ba7 Stephen Beaver
	'Gateway name',
2161
	'text',
2162 e8113404 Phil Davis
	($gateway_settings6['name'] == "") ? $defgatewayname6 : $gateway_settings6['name']
2163 8b5aac9f Stephen Beaver
));
2164 ae4c4bac Stephen Beaver
2165 8b5aac9f Stephen Beaver
$modal->addInput(new Form_IpAddress(
2166 68933ba7 Stephen Beaver
	'gatewayip6',
2167 4dda3174 Stephen Beaver
	'Gateway IPv6',
2168 e8113404 Phil Davis
	$gateway_settings6['gateway'],
2169 41fc88ec Phil Davis
	'V6'
2170 8b5aac9f Stephen Beaver
));
2171 ae4c4bac Stephen Beaver
2172 8b5aac9f Stephen Beaver
$modal->addInput(new Form_Input(
2173 68933ba7 Stephen Beaver
	'gatewaydescr6',
2174
	'Description',
2175 e8113404 Phil Davis
	'text',
2176
	$gateway_settings6['descr']
2177 8b5aac9f Stephen Beaver
));
2178 ae4c4bac Stephen Beaver
2179 8b5aac9f Stephen Beaver
$btnaddgw6 = new Form_Button(
2180 68933ba7 Stephen Beaver
	'add6',
2181 faab522f Renato Botelho
	'Add',
2182 2e7fa7ca jim-p
	null,
2183
	'fa-plus'
2184 8b5aac9f Stephen Beaver
);
2185 ae4c4bac Stephen Beaver
2186 347c0214 Phil Davis
$btnaddgw6->setAttribute('type','button')->addClass('btn-success');
2187 ae4c4bac Stephen Beaver
2188 8b5aac9f Stephen Beaver
$btncnxgw6 = new Form_Button(
2189 68933ba7 Stephen Beaver
	'cnx6',
2190 faab522f Renato Botelho
	'Cancel',
2191 2e7fa7ca jim-p
	null,
2192
	'fa-undo'
2193 8b5aac9f Stephen Beaver
);
2194
2195 347c0214 Phil Davis
$btncnxgw6->setAttribute('type','button')->addClass('btn-warning');
2196 8b5aac9f Stephen Beaver
2197
$modal->addInput(new Form_StaticText(
2198 68933ba7 Stephen Beaver
	null,
2199
	$btnaddgw6 . $btncnxgw6
2200 8b5aac9f Stephen Beaver
));
2201
2202
$form->add($modal);
2203 ae4c4bac Stephen Beaver
2204
// ==== DHCP client configuration =============================
2205
2206 5f88f964 k-paulius
$section = new Form_Section('DHCP Client Configuration');
2207 3375f236 Stephen Beaver
$section->addClass('dhcp');
2208 ae4c4bac Stephen Beaver
2209 34ab580d Stephen Beaver
$group = new Form_Group('Options');
2210
2211
$group->add(new Form_Checkbox(
2212 0c5916ce NOYB
	'adv_dhcp_config_advanced',
2213 34ab580d Stephen Beaver
	null,
2214 79a1a27f NOYB
	'Advanced Configuration',
2215 0c5916ce NOYB
	$pconfig['adv_dhcp_config_advanced']
2216 79a1a27f NOYB
))->setHelp('Use advanced DHCP configuration options.');
2217 34ab580d Stephen Beaver
2218
$group->add(new Form_Checkbox(
2219 0c5916ce NOYB
	'adv_dhcp_config_file_override',
2220 34ab580d Stephen Beaver
	null,
2221 79a1a27f NOYB
	'Configuration Override',
2222 0c5916ce NOYB
	$pconfig['adv_dhcp_config_file_override']
2223 79a1a27f NOYB
))->setHelp('Override the configuration from this file.');
2224 34ab580d Stephen Beaver
2225
$section->add($group);
2226
2227 ae4c4bac Stephen Beaver
$section->addInput(new Form_Input(
2228 68933ba7 Stephen Beaver
	'dhcphostname',
2229
	'Hostname',
2230
	'text',
2231
	$pconfig['dhcphostname']
2232 ae4c4bac Stephen Beaver
))->setHelp('The value in this field is sent as the DHCP client identifier and hostname when requesting a DHCP lease. Some ISPs may require this (for client identification).');
2233
2234
$section->addInput(new Form_IpAddress(
2235 68933ba7 Stephen Beaver
	'alias-address',
2236
	'Alias IPv4 address',
2237 41fc88ec Phil Davis
	$pconfig['alias-address'],
2238
	'V4'
2239 ae4c4bac Stephen Beaver
))->addMask('alias-subnet', $pconfig['alias-subnet'], 32)->setHelp('The value in this field is used as a fixed alias IPv4 address by the DHCP client.');
2240
2241
$section->addInput(new Form_Input(
2242 68933ba7 Stephen Beaver
	'dhcprejectfrom',
2243
	'Reject leases from',
2244
	'text',
2245
	$pconfig['dhcprejectfrom']
2246 392a7045 lukehamburg
))->setHelp('To have the DHCP client reject offers from specific DHCP servers, enter their IP addresses here ' .
2247
			'(separate multiple entries with a comma). ' .
2248 3c36d8ce jim-p
			'This is useful for rejecting leases from cable modems that offer private IP addresses when they lose upstream sync.');
2249 ae4c4bac Stephen Beaver
2250 62ed56dc Luiz Souza
if (interface_is_vlan($wancfg['if']) != NULL) {
2251
2252
	$group = new Form_Group('DHCP VLAN Priority');
2253
	$group->add(new Form_Checkbox(
2254
		'dhcpvlanenable',
2255
		null,
2256
		'Enable dhcpclient VLAN Priority tagging',
2257
		$pconfig['dhcpvlanenable']
2258
	))->setHelp('Normally off unless specifically required by the ISP.');
2259
2260
	$group->add(new Form_Select(
2261
		'dhcpcvpt',
2262
		'VLAN Prio',
2263
		$pconfig['dhcpcvpt'],
2264
		$vlanprio
2265
	))->setHelp('Choose 802.1p priority to set.');
2266
2267
	$section->add($group);
2268
}
2269
2270 ae4c4bac Stephen Beaver
$group = new Form_Group('Protocol timing');
2271 34ab580d Stephen Beaver
$group->addClass('dhcpadvanced');
2272 f0e84135 Danilo-Z
$group->setHelp('The values in these fields are DHCP protocol timings used when requesting a lease.%1$s' .
2273
				'See %2$shere%3$s for more information.', '<br />', '<a target="_blank" href="https://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#PROTOCOL_TIMING">', '</a>');
2274 ae4c4bac Stephen Beaver
2275
$group->add(new Form_Input(
2276 68933ba7 Stephen Beaver
	'adv_dhcp_pt_timeout',
2277
	null,
2278
	'number',
2279
	$pconfig['adv_dhcp_pt_timeout']
2280 ae4c4bac Stephen Beaver
))->setHelp('Timeout');
2281
2282
$group->add(new Form_Input(
2283 68933ba7 Stephen Beaver
	'adv_dhcp_pt_retry',
2284
	null,
2285
	'number',
2286
	$pconfig['adv_dhcp_pt_retry']
2287 ae4c4bac Stephen Beaver
))->setHelp('Retry');
2288
2289
$group->add(new Form_Input(
2290 68933ba7 Stephen Beaver
	'adv_dhcp_pt_select_timeout',
2291
	null,
2292
	'number',
2293 a2239232 NOYB
	$pconfig['adv_dhcp_pt_select_timeout'],
2294
	['min' => 0]
2295 ae4c4bac Stephen Beaver
))->setHelp('Select timeout');
2296
2297
$group->add(new Form_Input(
2298 68933ba7 Stephen Beaver
	'adv_dhcp_pt_reboot',
2299
	null,
2300
	'number',
2301
	$pconfig['adv_dhcp_pt_reboot']
2302 ae4c4bac Stephen Beaver
))->setHelp('Reboot');
2303
2304
$group->add(new Form_Input(
2305 68933ba7 Stephen Beaver
	'adv_dhcp_pt_backoff_cutoff',
2306
	null,
2307
	'number',
2308
	$pconfig['adv_dhcp_pt_backoff_cutoff']
2309 ae4c4bac Stephen Beaver
))->setHelp('Backoff cutoff');
2310
2311
$group->add(new Form_Input(
2312 68933ba7 Stephen Beaver
	'adv_dhcp_pt_initial_interval',
2313
	null,
2314
	'number',
2315
	$pconfig['adv_dhcp_pt_initial_interval']
2316 ae4c4bac Stephen Beaver
))->setHelp('Initial interval');
2317
2318
$section->add($group);
2319
2320
$group = new Form_Group('Presets');
2321 34ab580d Stephen Beaver
$group->addClass('dhcpadvanced');
2322 ae4c4bac Stephen Beaver
2323
$group->add(new Form_Checkbox(
2324 68933ba7 Stephen Beaver
	'adv_dhcp_pt_values',
2325
	null,
2326
	'FreeBSD default',
2327
	null,
2328
	'DHCP'
2329 ae4c4bac Stephen Beaver
))->displayAsRadio();
2330
2331
$group->add(new Form_Checkbox(
2332 68933ba7 Stephen Beaver
	'adv_dhcp_pt_values',
2333
	null,
2334
	'Clear',
2335
	null,
2336
	'Clear'
2337 ae4c4bac Stephen Beaver
))->displayAsRadio();
2338
2339
$group->add(new Form_Checkbox(
2340 68933ba7 Stephen Beaver
	'adv_dhcp_pt_values',
2341
	null,
2342
	'pfSense Default',
2343
	null,
2344
	'pfSense'
2345 ae4c4bac Stephen Beaver
))->displayAsRadio();
2346
2347
$group->add(new Form_Checkbox(
2348 68933ba7 Stephen Beaver
	'adv_dhcp_pt_values',
2349
	null,
2350
	'Saved Cfg',
2351
	null,
2352
	'SavedCfg'
2353 ae4c4bac Stephen Beaver
))->displayAsRadio();
2354
2355
$section->add($group);
2356
2357 34ab580d Stephen Beaver
$section->addInput(new Form_Input(
2358
	'adv_dhcp_config_file_override_path',
2359 79a1a27f NOYB
	'Configuration File Override',
2360 34ab580d Stephen Beaver
	'text',
2361
	$pconfig['adv_dhcp_config_file_override_path']
2362 4d0c9c59 Phil Davis
))->setWidth(9)->sethelp('The value in this field is the full absolute path to a DHCP client configuration file.	 [/[dirname/[.../]]filename[.ext]] %1$s' .
2363
			'Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} %1$s'.
2364
			'Where C is U(pper) or L(ower) Case, and D is ":-." Delimiter (space, colon, hyphen, or period) (omitted for none).%1$s' .
2365
			'Some ISPs may require certain options be or not be sent.', '<br />');
2366 34ab580d Stephen Beaver
2367 ae4c4bac Stephen Beaver
$form->add($section);
2368
2369
$section = new Form_Section('Lease Requirements and Requests');
2370 34ab580d Stephen Beaver
$section->addClass('dhcpadvanced');
2371 ae4c4bac Stephen Beaver
2372
$section->addInput(new Form_Input(
2373 68933ba7 Stephen Beaver
	'adv_dhcp_send_options',
2374
	'Send options',
2375
	'text',
2376
	$pconfig['adv_dhcp_send_options']
2377 4d0c9c59 Phil Davis
))->setWidth(9)->sethelp('The values in this field are DHCP options to be sent when requesting a DHCP lease.	 [option declaration [, ...]] %1$s' .
2378
			'Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} %1$s' .
2379
			'Where C is U(pper) or L(ower) Case, and D is " :-." Delimiter (space, colon, hyphen, or period) (omitted for none).%1$s' .
2380
			'Some ISPs may require certain options be or not be sent.', '<br />');
2381 ae4c4bac Stephen Beaver
2382
$section->addInput(new Form_Input(
2383 68933ba7 Stephen Beaver
	'adv_dhcp_request_options',
2384
	'Request options',
2385
	'text',
2386
	$pconfig['adv_dhcp_request_options']
2387 4d0c9c59 Phil Davis
))->setWidth(9)->sethelp('The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] %1$s' .
2388
			'Some ISPs may require certain options be or not be requested.', '<br />');
2389 68933ba7 Stephen Beaver
2390
$section->addInput(new Form_Input(
2391 0683ff17 NOYB
	'adv_dhcp_required_options',
2392 583b40ee Phil Davis
	'Require options',
2393 68933ba7 Stephen Beaver
	'text',
2394 0683ff17 NOYB
	$pconfig['adv_dhcp_required_options']
2395 79a1a27f NOYB
))->setWidth(9)->sethelp('The values in this field are DHCP options required by the client when requesting a DHCP lease.	 [option [, ...]]');
2396 ae4c4bac Stephen Beaver
2397
$section->addInput(new Form_Input(
2398 68933ba7 Stephen Beaver
	'adv_dhcp_option_modifiers',
2399
	'Option modifiers',
2400
	'text',
2401
	$pconfig['adv_dhcp_option_modifiers']
2402 4d0c9c59 Phil Davis
))->setWidth(9)->sethelp('The values in this field are DHCP option modifiers applied to the obtained DHCP lease.	 [modifier option declaration [, ...]] %1$s' .
2403
			'modifiers: (default, supersede, prepend, append) %1$s' .
2404
			'See %2$shere%3$s more information', '<br />', '<a target="_blank" href="https://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS">', '</a>');
2405 ae4c4bac Stephen Beaver
2406
$form->add($section);
2407
2408
// DHCP6 client config
2409
2410 5f88f964 k-paulius
$section = new Form_Section('DHCP6 Client Configuration');
2411 3375f236 Stephen Beaver
$section->addClass('dhcp6');
2412
2413 79a1a27f NOYB
$group = new Form_Group('Options');
2414
2415
$group->add(new Form_Checkbox(
2416 7361f6c2 Stephen Beaver
	'adv_dhcp6_config_advanced',
2417 79a1a27f NOYB
	null,
2418
	'Advanced Configuration',
2419 0c5916ce NOYB
	$pconfig['adv_dhcp6_config_advanced']
2420 79a1a27f NOYB
))->setHelp('Use advanced DHCPv6 configuration options.');
2421 309e8f8f Stephen Beaver
2422 79a1a27f NOYB
$group->add(new Form_Checkbox(
2423 68933ba7 Stephen Beaver
	'adv_dhcp6_config_file_override',
2424 79a1a27f NOYB
	null,
2425
	'Configuration Override',
2426 0c5916ce NOYB
	$pconfig['adv_dhcp6_config_file_override']
2427 79a1a27f NOYB
))->setHelp('Override the configuration from this file.');
2428
2429
$section->add($group);
2430 309e8f8f Stephen Beaver
2431 ae4c4bac Stephen Beaver
$section->addInput(new Form_Checkbox(
2432 68933ba7 Stephen Beaver
	'dhcp6usev4iface',
2433
	'Use IPv4 connectivity as parent interface',
2434
	'Request a IPv6 prefix/information through the IPv4 connectivity link',
2435
	$pconfig['dhcp6usev4iface']
2436 ae4c4bac Stephen Beaver
));
2437
2438
$section->addInput(new Form_Checkbox(
2439 68933ba7 Stephen Beaver
	'dhcp6prefixonly',
2440
	'Request only an IPv6 prefix',
2441
	'Only request an IPv6 prefix, do not request an IPv6 address',
2442
	$pconfig['dhcp6prefixonly']
2443 ae4c4bac Stephen Beaver
));
2444
2445
$section->addInput(new Form_Select(
2446 68933ba7 Stephen Beaver
	'dhcp6-ia-pd-len',
2447
	'DHCPv6 Prefix Delegation size',
2448
	$pconfig['dhcp6-ia-pd-len'],
2449 51dc008b Andreas Bleischwitz
	array("none" => "None", 16 => "48", 15 => "49", 14 => "50", 13 => "51", 12 => "52", 11 => "53", 10 => "54", 9 => "55", 8 => "56", 7 => "57", 6 => "58", 5 => "59", 4 => "60", 3 => "61", 2 => "62", 1 => "63", 0 => "64")
2450 a0509b13 Stephen Beaver
))->setHelp('The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP.');
2451 ae4c4bac Stephen Beaver
2452
$section->addInput(new Form_Checkbox(
2453 68933ba7 Stephen Beaver
	'dhcp6-ia-pd-send-hint',
2454
	'Send IPv6 prefix hint',
2455
	'Send an IPv6 prefix hint to indicate the desired prefix size for delegation',
2456
	$pconfig['dhcp6-ia-pd-send-hint']
2457 ae4c4bac Stephen Beaver
));
2458
2459 8c661bc8 marjohn56
$section->addInput(new Form_Checkbox(
2460
	'dhcp6withoutra',
2461
	'Do not wait for a RA',
2462
	'Required by some ISPs, especially those not using PPPoE',
2463
	$pconfig['dhcp6withoutra']
2464
));
2465 6b8680a7 marjohn56
2466 966835f8 Luiz Souza
if (interface_is_vlan($wancfg['if']) != NULL) {
2467
	$group = new Form_Group('DHCP6 VLAN Priority');
2468
2469
	$group->add(new Form_Checkbox(
2470
		'dhcp6vlanenable',
2471
		null,
2472
		'Enable dhcp6c VLAN Priority tagging',
2473
		$pconfig['dhcp6vlanenable']
2474
	))->setHelp('Normally off unless specifically required by the ISP.');
2475
2476
	$group->add(new Form_Select(
2477
		'dhcp6cvpt',
2478
		'VLAN Prio',
2479
		$pconfig['dhcp6cvpt'],
2480
		$vlanprio
2481
	))->setHelp('Choose 802.1p priority to set.');
2482
2483
	$section->add($group);
2484
}
2485 6b8680a7 marjohn56
2486 309e8f8f Stephen Beaver
$section->addInput(new Form_Input(
2487 68933ba7 Stephen Beaver
	'adv_dhcp6_config_file_override_path',
2488
	'Configuration File Override',
2489
	'text',
2490
	$pconfig['adv_dhcp6_config_file_override_path']
2491 4d0c9c59 Phil Davis
))->setWidth(9)->setHelp('The value in this field is the full absolute path to a DHCP client configuration file.	 [/[dirname/[.../]]filename[.ext]] %1$s' .
2492
			'Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} %1$s' .
2493
			'Where C is U(pper) or L(ower) Case, and D is " :-." Delimiter (space, colon, hyphen, or period) (omitted for none).%1$s' .
2494
			'Some ISPs may require certain options be or not be sent.', '<br />');
2495 309e8f8f Stephen Beaver
2496 ae4c4bac Stephen Beaver
$form->add($section);
2497
2498
// DHCP6 client config - Advanced
2499
2500 5f88f964 k-paulius
$section = new Form_Section('Advanced DHCP6 Client Configuration');
2501 309e8f8f Stephen Beaver
$section->addClass('dhcp6advanced');
2502 3375f236 Stephen Beaver
2503 ae4c4bac Stephen Beaver
$section->addInput(new Form_Checkbox(
2504 68933ba7 Stephen Beaver
	'adv_dhcp6_interface_statement_information_only_enable',
2505
	'Information only',
2506 79a1a27f NOYB
	'Exchange Information Only',
2507 03911305 Stephen Beaver
	$pconfig['adv_dhcp6_interface_statement_information_only_enable'],
2508
	'Selected'
2509 79a1a27f NOYB
))->setHelp('Only exchange informational configuration parameters with servers.');
2510 ae4c4bac Stephen Beaver
2511
$section->addInput(new Form_Input(
2512 68933ba7 Stephen Beaver
	'adv_dhcp6_interface_statement_send_options',
2513
	'Send options',
2514
	'text',
2515
	$pconfig['adv_dhcp6_interface_statement_send_options']
2516 4d0c9c59 Phil Davis
))->setWidth(9)->sethelp('DHCP send options to be sent when requesting a DHCP lease.	 [option declaration [, ...]] %1$s' .
2517
			'Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} %1$s' .
2518
			'Where C is U(pper) or L(ower) Case, and D is " :-." Delimiter (space, colon, hyphen, or period) (omitted for none).%1$s' .
2519
			'Some DHCP services may require certain options be or not be sent.', '<br />');
2520 ae4c4bac Stephen Beaver
2521
$section->addInput(new Form_Input(
2522 68933ba7 Stephen Beaver
	'adv_dhcp6_interface_statement_request_options',
2523
	'Request Options',
2524
	'text',
2525
	$pconfig['adv_dhcp6_interface_statement_request_options']
2526 4d0c9c59 Phil Davis
))->setWidth(9)->sethelp('DHCP request options to be sent when requesting a DHCP lease.	[option [, ...]] %1$s' .
2527
			'Some DHCP services may require certain options be or not be requested.', '<br />');
2528 a0509b13 Stephen Beaver
2529 ae4c4bac Stephen Beaver
$section->addInput(new Form_Input(
2530 68933ba7 Stephen Beaver
	'adv_dhcp6_interface_statement_script',
2531
	'Scripts',
2532
	'text',
2533
	$pconfig['adv_dhcp6_interface_statement_script']
2534 4d0c9c59 Phil Davis
))->setWidth(9)->sethelp('Absolute path to a script invoked on certain conditions including when a reply message is received.%1$s' .
2535
			'[/[dirname/[.../]]filename[.ext]].', '<br />');
2536 a0509b13 Stephen Beaver
2537 ae4c4bac Stephen Beaver
$group = new Form_Group('Identity Association Statement');
2538
2539
$group->add(new Form_Checkbox(
2540 68933ba7 Stephen Beaver
	'adv_dhcp6_id_assoc_statement_address_enable',
2541
	null,
2542
	'Non-Temporary Address Allocation',
2543 03911305 Stephen Beaver
	$pconfig['adv_dhcp6_id_assoc_statement_address_enable'],
2544
	'Selected'
2545 ae4c4bac Stephen Beaver
));
2546 a0509b13 Stephen Beaver
2547 ae4c4bac Stephen Beaver
$group->add(new Form_Input(
2548 68933ba7 Stephen Beaver
	'adv_dhcp6_id_assoc_statement_address_id',
2549
	null,
2550
	'text',
2551
	$pconfig['adv_dhcp6_id_assoc_statement_address_id']
2552 ae4c4bac Stephen Beaver
))->sethelp('id-assoc na ID');
2553
2554
$group->add(new Form_IpAddress(
2555 68933ba7 Stephen Beaver
	'adv_dhcp6_id_assoc_statement_address',
2556
	null,
2557 41fc88ec Phil Davis
	$pconfig['adv_dhcp6_id_assoc_statement_address'],
2558
	'V6'
2559 ae4c4bac Stephen Beaver
))->sethelp('IPv6 address');
2560
2561
$group->add(new Form_Input(
2562 68933ba7 Stephen Beaver
	'adv_dhcp6_id_assoc_statement_address_pltime',
2563
	null,
2564
	'text',
2565
	$pconfig['adv_dhcp6_id_assoc_statement_address_pltime']
2566 ae4c4bac Stephen Beaver
))->sethelp('pltime');
2567
2568
$group->add(new Form_Input(
2569 68933ba7 Stephen Beaver
	'adv_dhcp6_id_assoc_statement_address_vltime',
2570
	null,
2571
	'text',
2572
	$pconfig['adv_dhcp6_id_assoc_statement_address_vltime']
2573 ae4c4bac Stephen Beaver
))->sethelp('vltime');
2574
2575
$section->add($group);
2576
2577 a0509b13 Stephen Beaver
// Prefix delegation
2578 ae4c4bac Stephen Beaver
$group = new Form_Group('');
2579
2580
$group->add(new Form_Checkbox(
2581 68933ba7 Stephen Beaver
	'adv_dhcp6_id_assoc_statement_prefix_enable',
2582
	null,
2583
	'Prefix Delegation ',
2584 03911305 Stephen Beaver
	$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'],
2585
	'Selected'
2586 ae4c4bac Stephen Beaver
));
2587 a0509b13 Stephen Beaver
2588 ae4c4bac Stephen Beaver
$group->add(new Form_Input(
2589 68933ba7 Stephen Beaver
	'adv_dhcp6_id_assoc_statement_prefix_id',
2590
	null,
2591
	'text',
2592
	$pconfig['adv_dhcp6_id_assoc_statement_prefix_id']
2593 ae4c4bac Stephen Beaver
))->sethelp('id-assoc pd ID');
2594
2595
$group->add(new Form_IpAddress(
2596 68933ba7 Stephen Beaver
	'adv_dhcp6_id_assoc_statement_prefix',
2597
	null,
2598 41fc88ec Phil Davis
	$pconfig['adv_dhcp6_id_assoc_statement_prefix'],
2599
	'V6'
2600 ae4c4bac Stephen Beaver
))->sethelp('IPv6 prefix');
2601
2602
$group->add(new Form_Input(
2603 68933ba7 Stephen Beaver
	'adv_dhcp6_id_assoc_statement_prefix_pltime',
2604
	null,
2605
	'text',
2606
	$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime']
2607 ae4c4bac Stephen Beaver
))->sethelp('pltime');
2608
2609
$group->add(new Form_Input(
2610 68933ba7 Stephen Beaver
	'adv_dhcp6_id_assoc_statement_prefix_vltime',
2611
	null,
2612
	'text',
2613
	$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime']
2614 ae4c4bac Stephen Beaver
))->sethelp('vltime');
2615
2616
$section->add($group);
2617
2618
$group = new Form_Group('Prefix interface statement');
2619
2620
$group->add(new Form_Input(
2621 68933ba7 Stephen Beaver
	'adv_dhcp6_prefix_interface_statement_sla_id',
2622
	null,
2623
	'text',
2624
	$pconfig['adv_dhcp6_prefix_interface_statement_sla_id']
2625 ae4c4bac Stephen Beaver
))->sethelp('Prefix Interface sla-id');
2626
2627
$group->add(new Form_Input(
2628 68933ba7 Stephen Beaver
	'adv_dhcp6_prefix_interface_statement_sla_len',
2629
	null,
2630
	'text',
2631
	$pconfig['adv_dhcp6_prefix_interface_statement_sla_len']
2632 ae4c4bac Stephen Beaver
))->sethelp('sla-len');
2633
2634
$section->add($group);
2635
2636 58a185ae marjohn56
$group = new Form_Group('Select prefix interface');
2637
$section->addInput(new Form_Select(
2638
	'adv_dhcp6_prefix_selected_interface',
2639
	'Prefix Interface',
2640
	$pconfig['adv_dhcp6_prefix_selected_interface'],
2641
	$interfaces
2642
))->setHelp('Select the interface on which to apply the prefix delegation.');
2643
2644 ae4c4bac Stephen Beaver
$group = new Form_Group('Authentication statement');
2645
2646
$group->add(new Form_Input(
2647 68933ba7 Stephen Beaver
	'adv_dhcp6_authentication_statement_authname',
2648
	null,
2649
	'text',
2650
	$pconfig['adv_dhcp6_authentication_statement_authname']
2651 ae4c4bac Stephen Beaver
))->sethelp('Authname');
2652
2653
$group->add(new Form_Input(
2654 68933ba7 Stephen Beaver
	'adv_dhcp6_authentication_statement_protocol',
2655
	null,
2656
	'text',
2657
	$pconfig['adv_dhcp6_authentication_statement_protocol']
2658 ae4c4bac Stephen Beaver
))->sethelp('Protocol');
2659
2660
$group->add(new Form_Input(
2661 68933ba7 Stephen Beaver
	'adv_dhcp6_authentication_statement_algorithm',
2662
	null,
2663
	'text',
2664
	$pconfig['adv_dhcp6_authentication_statement_algorithm']
2665 ae4c4bac Stephen Beaver
))->sethelp('Algorithm');
2666
2667
$group->add(new Form_Input(
2668 68933ba7 Stephen Beaver
	'adv_dhcp6_authentication_statement_rdm',
2669
	null,
2670
	'text',
2671
	$pconfig['adv_dhcp6_authentication_statement_rdm']
2672 ae4c4bac Stephen Beaver
))->sethelp('RDM');
2673
2674
$section->add($group);
2675
2676
$group = new Form_Group('Keyinfo statement');
2677
2678
$group->add(new Form_Input(
2679 68933ba7 Stephen Beaver
	'adv_dhcp6_key_info_statement_keyname',
2680
	null,
2681
	'text',
2682
	$pconfig['adv_dhcp6_key_info_statement_keyname']
2683 ae4c4bac Stephen Beaver
))->sethelp('Keyname');
2684
2685
$group->add(new Form_Input(
2686 68933ba7 Stephen Beaver
	'adv_dhcp6_key_info_statement_realm',
2687
	null,
2688
	'text',
2689
	$pconfig['adv_dhcp6_key_info_statement_realm']
2690 ae4c4bac Stephen Beaver
))->sethelp('Realm');
2691
2692
$section->add($group);
2693
2694
$group = new Form_Group('');
2695
2696
$group->add(new Form_Input(
2697 68933ba7 Stephen Beaver
	'adv_dhcp6_key_info_statement_keyid',
2698
	null,
2699
	'text',
2700
	$pconfig['adv_dhcp6_key_info_statement_keyid']
2701 ae4c4bac Stephen Beaver
))->sethelp('KeyID');
2702
2703
$group->add(new Form_Input(
2704 68933ba7 Stephen Beaver
	'adv_dhcp6_key_info_statement_secret',
2705
	null,
2706
	'text',
2707
	$pconfig['adv_dhcp6_key_info_statement_secret']
2708 ae4c4bac Stephen Beaver
))->sethelp('Secret');
2709
2710
$group->add(new Form_Input(
2711 68933ba7 Stephen Beaver
	'adv_dhcp6_key_info_statement_expire',
2712
	null,
2713
	'text',
2714
	$pconfig['adv_dhcp6_key_info_statement_expire']
2715 ae4c4bac Stephen Beaver
))->sethelp('Expire');
2716
2717 b3875714 jim-p
$group->setHelp('See %1$shere%2$s more information', '<a target="_blank" href="https://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+11.0-RELEASE+and+Ports#Interface_statement">', '</a>');
2718 79a1a27f NOYB
2719 ae4c4bac Stephen Beaver
$section->add($group);
2720
2721
$form->add($section);
2722
2723
$section = new Form_Section('6RD Configuration');
2724 c0c25504 Stephen Beaver
$section->addClass('_6rd');
2725 ae4c4bac Stephen Beaver
2726
$section->addInput(new Form_Input(
2727 68933ba7 Stephen Beaver
	'prefix-6rd',
2728
	'6RD Prefix',
2729
	'text',
2730
	$pconfig['prefix-6rd']
2731 eaa948d6 NOYB
))->sethelp('6RD IPv6 prefix assigned by the ISP. e.g. "2001:db8::/32"');
2732 ae4c4bac Stephen Beaver
2733
$section->addInput(new Form_Input(
2734 68933ba7 Stephen Beaver
	'gateway-6rd',
2735 1095b204 Phil Davis
	'*6RD Border relay',
2736 68933ba7 Stephen Beaver
	'text',
2737
	$pconfig['gateway-6rd']
2738 eaa948d6 NOYB
))->sethelp('6RD IPv4 gateway address assigned by the ISP');
2739 ae4c4bac Stephen Beaver
2740
$section->addInput(new Form_Select(
2741 68933ba7 Stephen Beaver
	'prefix-6rd-v4plen',
2742 6bb806c6 Chris Buechler
	'6RD IPv4 Prefix length',
2743 68933ba7 Stephen Beaver
	$pconfig['prefix-6rd-v4plen'],
2744
	array_combine(range(0, 32), range(0, 32))
2745 ab9b8aad NOYB
))->setHelp('6RD IPv4 prefix length. Normally specified by the ISP. A value of 0 means embed the entire IPv4 address in the 6RD prefix.');
2746 ae4c4bac Stephen Beaver
2747
$form->add($section);
2748
2749
// Track IPv6 ointerface section
2750
$section = new Form_Section('Track IPv6 Interface');
2751 3375f236 Stephen Beaver
$section->addClass('track6');
2752 ae4c4bac Stephen Beaver
2753
function build_ipv6interface_list() {
2754 5a41b18c Renato Botelho
	global $config, $form;
2755 9abccff3 Stephen Beaver
2756 68933ba7 Stephen Beaver
	$list = array('' => '');
2757
2758 f593f80b Phil Davis
	$interfaces = get_configured_interface_with_descr(true);
2759 68933ba7 Stephen Beaver
	$dynv6ifs = array();
2760
2761
	foreach ($interfaces as $iface => $ifacename) {
2762 2d5c75fa Reid Linnemann
		switch (config_get_path("interfaces/{$iface}/ipaddrv6")) {
2763 68933ba7 Stephen Beaver
			case "6to4":
2764
			case "6rd":
2765
			case "dhcp6":
2766
				$dynv6ifs[$iface] = array(
2767
					'name' => $ifacename,
2768 2456ecc9 jim-p
					'ipv6_num_prefix_ids' => pow(2, (int) calculate_ipv6_delegation_length($iface)) - 1
2769 68933ba7 Stephen Beaver
				);
2770
				break;
2771
			default:
2772 86ec819a jim-p
				continue 2;
2773 68933ba7 Stephen Beaver
		}
2774
	}
2775
2776
	foreach ($dynv6ifs as $iface => $ifacedata) {
2777
		$list[$iface] = $ifacedata['name'];
2778
2779 ee12dd78 Peter Feichtinger
		$form->addGlobal(new Form_Input(
2780 68933ba7 Stephen Beaver
			'ipv6-num-prefix-ids-' . $iface,
2781
			null,
2782
			'hidden',
2783
			$ifacedata['ipv6_num_prefix_ids']
2784
		));
2785
	}
2786
2787
	return($list);
2788 ae4c4bac Stephen Beaver
}
2789 c0948c6c Renato Botelho
2790 ae4c4bac Stephen Beaver
$section->addInput(new Form_Select(
2791 68933ba7 Stephen Beaver
	'track6-interface',
2792 1095b204 Phil Davis
	'*IPv6 Interface',
2793 68933ba7 Stephen Beaver
	$pconfig['track6-interface'],
2794
	build_ipv6interface_list()
2795 a6a344d8 NOYB
))->setHelp('Selects the dynamic IPv6 WAN interface to track for configuration.');
2796 c0948c6c Renato Botelho
2797 ae4c4bac Stephen Beaver
if ($pconfig['track6-prefix-id'] == "") {
2798 68933ba7 Stephen Beaver
	$pconfig['track6-prefix-id'] = 0;
2799 ae4c4bac Stephen Beaver
}
2800 3a906378 gnhb
2801 ae4c4bac Stephen Beaver
$section->addInput(new Form_Input(
2802 1ee6d09a Phil Davis
	'track6-prefix-id--hex',
2803 68933ba7 Stephen Beaver
	'IPv6 Prefix ID',
2804
	'text',
2805
	sprintf("%x", $pconfig['track6-prefix-id'])
2806 4d0c9c59 Phil Davis
))->setHelp('(%1$shexadecimal%2$s from 0 to %3$s) The value in this field is the (Delegated) IPv6 prefix ID. This determines the configurable network ID based on the dynamic IPv6 connection. The default value is 0.', '<b>', '</b>', '<span id="track6-prefix-id-range"></span>');
2807 a0509b13 Stephen Beaver
2808 ee12dd78 Peter Feichtinger
$form->addGlobal(new Form_Input(
2809 1ee6d09a Phil Davis
	'track6-prefix-id-max',
2810 68933ba7 Stephen Beaver
	null,
2811
	'hidden',
2812
	0
2813 aeeda8b4 Stephen Beaver
));
2814 a9929d56 Stephen Beaver
2815 ae4c4bac Stephen Beaver
$form->add($section);
2816
2817
/// PPP section
2818
2819
$section = new Form_Section('PPP Configuration');
2820 3375f236 Stephen Beaver
$section->addClass('ppp');
2821 ae4c4bac Stephen Beaver
2822
$section->addInput(new Form_Select(
2823 68933ba7 Stephen Beaver
	'country',
2824
	'Country',
2825
	$pconfig['country'],
2826
	[]
2827 ae4c4bac Stephen Beaver
));
2828
2829
$section->addInput(new Form_Select(
2830 68933ba7 Stephen Beaver
	'provider_list',
2831
	'Provider',
2832
	$pconfig['provider_list'],
2833
	[]
2834 ae4c4bac Stephen Beaver
));
2835
2836
$section->addInput(new Form_Select(
2837 68933ba7 Stephen Beaver
	'providerplan',
2838
	'Plan',
2839
	$pconfig['providerplan'],
2840
	[]
2841 eaa948d6 NOYB
))->setHelp('Select to fill in service provider data.');
2842 ae4c4bac Stephen Beaver
2843
$section->addInput(new Form_Input(
2844 68933ba7 Stephen Beaver
	'ppp_username',
2845
	'Username',
2846
	'text',
2847 659a8a26 jim-p
	$pconfig['ppp_username'],
2848
	['autocomplete' => 'new-password']
2849 ae4c4bac Stephen Beaver
));
2850
2851 c8b10b4c Stephen Beaver
$section->addPassword(new Form_Input(
2852 68933ba7 Stephen Beaver
	'ppp_password',
2853
	'Password',
2854
	'password',
2855
	$pconfig['ppp_password']
2856 ae4c4bac Stephen Beaver
));
2857
2858 309e8f8f Stephen Beaver
$section->addInput(new Form_Input(
2859 68933ba7 Stephen Beaver
	'phone',
2860 1095b204 Phil Davis
	'*Phone number',
2861 68933ba7 Stephen Beaver
	'text',
2862
	$pconfig['phone']
2863 a6a344d8 NOYB
))->setHelp('Typically *99# for GSM networks and #777 for CDMA networks.');
2864 986fd3d9 Renato Botelho
2865 ae4c4bac Stephen Beaver
$section->addInput(new Form_Input(
2866 68933ba7 Stephen Beaver
	'apn',
2867
	'Access Point Name',
2868
	'text',
2869
	$pconfig['apn']
2870 ae4c4bac Stephen Beaver
));
2871
2872 309e8f8f Stephen Beaver
2873 ae4c4bac Stephen Beaver
function build_port_list() {
2874 68933ba7 Stephen Beaver
	$list = array("" => "None");
2875 a0509b13 Stephen Beaver
2876 68933ba7 Stephen Beaver
	$portlist = glob("/dev/cua*");
2877
	$modems	  = glob("/dev/modem*");
2878
	$portlist = array_merge($portlist, $modems);
2879 ae4c4bac Stephen Beaver
2880 68933ba7 Stephen Beaver
	foreach ($portlist as $port) {
2881
		if (preg_match("/\.(lock|init)$/", $port)) {
2882
			continue;
2883
		}
2884 ae4c4bac Stephen Beaver
2885 68933ba7 Stephen Beaver
	$list[trim($port)] = $port;
2886
	}
2887 a0509b13 Stephen Beaver
2888 68933ba7 Stephen Beaver
	return($list);
2889 a0509b13 Stephen Beaver
}
2890 309e8f8f Stephen Beaver
2891 ae4c4bac Stephen Beaver
$section->addInput(new Form_Select(
2892 68933ba7 Stephen Beaver
	'port',
2893 1095b204 Phil Davis
	"*Modem port",
2894 68933ba7 Stephen Beaver
	$pconfig['port'],
2895
	build_port_list()
2896 ae4c4bac Stephen Beaver
));
2897 a0509b13 Stephen Beaver
2898 309e8f8f Stephen Beaver
$section->addInput(new Form_Button(
2899 68933ba7 Stephen Beaver
	'btnadvppp',
2900 faab522f Renato Botelho
	'Advanced PPP',
2901 827a3812 jim-p
	isset($pconfig['pppid']) ? 'interfaces_ppps_edit.php?id=' . htmlspecialchars($pconfig['pppid']) : 'interfaces_ppps_edit.php',
2902
	'fa-cog'
2903 a6a344d8 NOYB
))->setAttribute('type','button')->addClass('btn-info')->setAttribute('id')->setHelp('Create a new PPP configuration.');
2904 a0509b13 Stephen Beaver
2905 ae4c4bac Stephen Beaver
$form->add($section);
2906
2907
// PPPoE configuration
2908
$section = new Form_Section('PPPoE Configuration');
2909 3375f236 Stephen Beaver
$section->addClass('pppoe');
2910 ae4c4bac Stephen Beaver
2911
$section->addInput(new Form_Input(
2912 68933ba7 Stephen Beaver
	'pppoe_username',
2913 32a85c63 Phil Davis
	'*Username',
2914 68933ba7 Stephen Beaver
	'text',
2915 659a8a26 jim-p
	$pconfig['pppoe_username'],
2916
	['autocomplete' => 'new-password']
2917 ae4c4bac Stephen Beaver
));
2918
2919 c8b10b4c Stephen Beaver
$section->addPassword(new Form_Input(
2920 68933ba7 Stephen Beaver
	'pppoe_password',
2921 32a85c63 Phil Davis
	'*Password',
2922 68933ba7 Stephen Beaver
	'password',
2923
	$pconfig['pppoe_password']
2924 ae4c4bac Stephen Beaver
));
2925
2926
$section->addInput(new Form_Input(
2927 68933ba7 Stephen Beaver
	'provider',
2928
	'Service name',
2929
	'text',
2930
	$pconfig['provider']
2931 a6a344d8 NOYB
))->setHelp('This field can usually be left empty.');
2932 ae4c4bac Stephen Beaver
2933 71465708 Viktor G
$section->addInput(new Form_Input(
2934
	'hostuniq',
2935
	'Host-Uniq',
2936
	'text',
2937
	$pconfig['hostuniq']
2938
))->setHelp('A unique host tag value for this PPPoE client. Leave blank unless a value is required by the service provider.');
2939
2940 ae4c4bac Stephen Beaver
$section->addInput(new Form_Checkbox(
2941 68933ba7 Stephen Beaver
	'pppoe_dialondemand',
2942
	'Dial on demand',
2943
	'Enable Dial-On-Demand mode ',
2944
	$pconfig['pppoe_dialondemand'],
2945
	'enable'
2946 ae4c4bac Stephen Beaver
));
2947
2948
$section->addInput(new Form_Input(
2949 68933ba7 Stephen Beaver
	'pppoe_idletimeout',
2950
	'Idle timeout',
2951
	'number',
2952
	$pconfig['pppoe_idletimeout'],
2953 6e78a06f BBcan177
	['min' => 0]
2954 ae4c4bac Stephen Beaver
))->setHelp('If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. ' .
2955 68933ba7 Stephen Beaver
			'An idle timeout of zero disables this feature.');
2956 ae4c4bac Stephen Beaver
2957 eaf7cb2a Stephen Beaver
$section->addInput(new Form_Select(
2958 68933ba7 Stephen Beaver
	'pppoe-reset-type',
2959
	'Periodic reset',
2960
	$pconfig['pppoe-reset-type'],
2961 6e8892c5 Stephen Beaver
	['' => gettext('Disabled'), 'custom' => gettext('Custom'), 'preset' => gettext('Pre-set')]
2962 a6a344d8 NOYB
))->setHelp('Select a reset timing type.');
2963 eaf7cb2a Stephen Beaver
2964 635f649d Stephen Beaver
$group = new Form_Group('Custom reset');
2965 aeeda8b4 Stephen Beaver
$group->addClass('pppoecustom');
2966 eaf7cb2a Stephen Beaver
2967
$group->add(new Form_Input(
2968 68933ba7 Stephen Beaver
	'pppoe_resethour',
2969
	null,
2970
	'number',
2971 b381fa76 jim-p
	(strlen($pconfig['pppoe_resethour']) > 0) ? $pconfig['pppoe_resethour'] : "0",
2972 6e78a06f BBcan177
	['min' => 0, 'max' => 23]
2973 b381fa76 jim-p
))->setHelp('Hour (0-23), blank for * (every)');
2974 eaf7cb2a Stephen Beaver
2975
$group->add(new Form_Input(
2976 68933ba7 Stephen Beaver
	'pppoe_resetminute',
2977
	null,
2978
	'number',
2979 b381fa76 jim-p
	(strlen($pconfig['pppoe_resetminute']) > 0) ? $pconfig['pppoe_resetminute'] : "0",
2980 6e78a06f BBcan177
	['min' => 0, 'max' => 59]
2981 b381fa76 jim-p
))->setHelp('Minute (0-59), blank for * (every)');
2982 eaf7cb2a Stephen Beaver
2983
$group->add(new Form_Input(
2984 68933ba7 Stephen Beaver
	'pppoe_resetdate',
2985
	null,
2986
	'text',
2987
	$pconfig['pppoe_resetdate']
2988 eaf7cb2a Stephen Beaver
))->setHelp('Specific date (mm/dd/yyyy)');
2989
2990 eaa948d6 NOYB
$group->setHelp('Leave the date field empty, for the reset to be executed each day at the time specified by the minutes and hour fields');
2991 eaf7cb2a Stephen Beaver
2992
$section->add($group);
2993
2994
$group = new Form_MultiCheckboxGroup('cron based reset');
2995 7957389b Viktor G
$group->addClass('pppoepreset');
2996 eaf7cb2a Stephen Beaver
2997
$group->add(new Form_MultiCheckbox(
2998 68933ba7 Stephen Beaver
	'pppoe_pr_preset_val',
2999
	null,
3000
	'Reset at each month ("0 0 1 * *")',
3001
	$pconfig['pppoe_monthly'],
3002
	'monthly'
3003 eaf7cb2a Stephen Beaver
))->displayAsRadio();
3004
3005
$group->add(new Form_MultiCheckbox(
3006 68933ba7 Stephen Beaver
	'pppoe_pr_preset_val',
3007
	null,
3008
	'Reset at each week ("0 0 * * 0")',
3009
	$pconfig['pppoe_weekly'],
3010
	'weekly'
3011 eaf7cb2a Stephen Beaver
))->displayAsRadio();
3012
3013
$group->add(new Form_MultiCheckbox(
3014 68933ba7 Stephen Beaver
	'pppoe_pr_preset_val',
3015
	null,
3016
	'Reset at each day ("0 0 * * *")',
3017
	$pconfig['pppoe_daily'],
3018
	'daily'
3019 eaf7cb2a Stephen Beaver
))->displayAsRadio();
3020
3021
$group->add(new Form_MultiCheckbox(
3022 68933ba7 Stephen Beaver
	'pppoe_pr_preset_val',
3023
	null,
3024
	'Reset at each hour ("0 * * * *")',
3025
	$pconfig['pppoe_hourly'],
3026
	'hourly'
3027 eaf7cb2a Stephen Beaver
))->displayAsRadio();
3028
3029
$section->add($group);
3030
3031 827a3812 jim-p
$section->addInput(new Form_Button(
3032
	'btnadvppp',
3033 faab522f Renato Botelho
	'Advanced and MLPPP',
3034 827a3812 jim-p
	isset($pconfig['pppid']) ? 'interfaces_ppps_edit.php?id=' . htmlspecialchars($pconfig['pppid']) : 'interfaces_ppps_edit.php',
3035
	'fa-cog'
3036 347c0214 Phil Davis
))->setAttribute('type','button')->addClass('btn-info')->setAttribute('id')->setHelp('Click for additional PPPoE configuration options. Save first if changes have been made.');
3037 eaf7cb2a Stephen Beaver
3038
$form->add($section);
3039
3040
// PPTP & L2TP Configuration section
3041 aeeda8b4 Stephen Beaver
$section = new Form_Section('PPTP/L2TP Configuration');
3042 3375f236 Stephen Beaver
$section->addClass('pptp');
3043 eaf7cb2a Stephen Beaver
3044
$section->addInput(new Form_Input(
3045 68933ba7 Stephen Beaver
	'pptp_username',
3046 1095b204 Phil Davis
	'*Username',
3047 68933ba7 Stephen Beaver
	'text',
3048 659a8a26 jim-p
	$pconfig['pptp_username'],
3049
	['autocomplete' => 'new-password']
3050 eaf7cb2a Stephen Beaver
));
3051
3052 c8b10b4c Stephen Beaver
$section->addPassword(new Form_Input(
3053 68933ba7 Stephen Beaver
	'pptp_password',
3054 1095b204 Phil Davis
	'*Password',
3055 68933ba7 Stephen Beaver
	'password',
3056
	$pconfig['pptp_password']
3057 eaf7cb2a Stephen Beaver
));
3058
3059 8e267d3b Viktor G
$group = new Form_Group('Shared Secret');
3060
3061
$group->add(new Form_Input(
3062
	'l2tp_secret',
3063
	'*Secret',
3064
	'password',
3065
	$pconfig['l2tp_secret']
3066
))->setHelp('L2TP tunnel Shared Secret. Used to authenticate tunnel connection and encrypt ' .
3067 9623ec5b Viktor G
	    'important control packet contents. (Optional)');
3068 8e267d3b Viktor G
3069
$group->addClass('l2tp_secret');
3070
$section->add($group);
3071
3072 eaf7cb2a Stephen Beaver
$section->addInput(new Form_IpAddress(
3073 66fd7b47 Phil Davis
	'pptp_local0',
3074 1095b204 Phil Davis
	'*Local IP address',
3075 7e38cc2c Viktor G
	$_POST['pptp_local0'] ? $_POST['pptp_local0'] : $pconfig['pptp_localip'][0],
3076 41fc88ec Phil Davis
	'V4'
3077 7e38cc2c Viktor G
))->addMask('pptp_subnet0', $_POST['pptp_subnet0'] ? $_POST['pptp_subnet0'] : $pconfig['pptp_subnet'][0]);
3078 eaf7cb2a Stephen Beaver
3079 4890b6ec Phil Davis
$section->addInput(new Form_IpAddress(
3080 66fd7b47 Phil Davis
	'pptp_remote0',
3081 1095b204 Phil Davis
	'*Remote IP address',
3082 7e38cc2c Viktor G
	$_POST['pptp_remote0'] ? $_POST['pptp_remote0'] : $pconfig['pptp_remote'][0],
3083 4890b6ec Phil Davis
	'HOSTV4'
3084 eaf7cb2a Stephen Beaver
));
3085
3086
$section->addInput(new Form_Checkbox(
3087 68933ba7 Stephen Beaver
	'pptp_dialondemand',
3088
	'Dial on demand',
3089
	'Enable Dial-On-Demand mode ',
3090
	$pconfig['pptp_dialondemand'],
3091
	'enable'
3092 eaa948d6 NOYB
))->setHelp('This option causes the interface to operate in dial-on-demand mode, allowing it to be a virtual full time connection. ' .
3093 68933ba7 Stephen Beaver
			'The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected.');
3094 eaf7cb2a Stephen Beaver
3095
$section->addInput(new Form_Input(
3096 68933ba7 Stephen Beaver
	'pptp_idletimeout',
3097
	'Idle timeout (seconds)',
3098
	'number',
3099
	$pconfig['pptp_idletimeout'],
3100 6e78a06f BBcan177
	['min' => 0]
3101 eaf7cb2a Stephen Beaver
))->setHelp('If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. ' .
3102 68933ba7 Stephen Beaver
			'An idle timeout of zero disables this feature.');
3103 a0509b13 Stephen Beaver
3104 827a3812 jim-p
if (isset($pconfig['pptp_localip'][1]) || isset($pconfig['pptp_subnet'][1]) || isset($pconfig['pptp_remote'][1])) {
3105
	$mlppp_text = gettext("There are additional Local and Remote IP addresses defined for MLPPP.") . "<br />";
3106 eaf7cb2a Stephen Beaver
} else {
3107 827a3812 jim-p
	$mlppp_text = "";
3108 eaf7cb2a Stephen Beaver
}
3109
3110 827a3812 jim-p
$section->addInput(new Form_Button(
3111
	'btnadvppp',
3112 faab522f Renato Botelho
	'Advanced and MLPPP',
3113 827a3812 jim-p
	isset($pconfig['pppid']) ? 'interfaces_ppps_edit.php?id=' . htmlspecialchars($pconfig['pppid']) : 'interfaces_ppps_edit.php',
3114
	'fa-cog'
3115 4d0c9c59 Phil Davis
))->setAttribute('type','button')->addClass('btn-info')->setAttribute('id')->setHelp('%sClick for additional PPTP and L2TP configuration options. Save first if changes have been made.', $mlppp_text);
3116 827a3812 jim-p
3117 ae4c4bac Stephen Beaver
$form->add($section);
3118 eaf7cb2a Stephen Beaver
3119
// Wireless interface
3120 a0509b13 Stephen Beaver
if (isset($wancfg['wireless'])) {
3121
3122 5f88f964 k-paulius
	$section = new Form_Section('Common Wireless Configuration - Settings apply to all wireless networks on ' . $wlanbaseif . '.');
3123 68933ba7 Stephen Beaver
3124
	$section->addInput(new Form_Checkbox(
3125
		'persistcommonwireless',
3126
		'Persist common settings',
3127
		'Preserve common wireless configuration through interface deletions and reassignments.',
3128
		$pconfig['persistcommonwireless'],
3129
		'yes'
3130
	));
3131
3132
	$mode_list = ['auto' => 'Auto'];
3133
3134
	if (is_array($wl_modes)) {
3135
		foreach ($wl_modes as $wl_standard => $wl_channels) {
3136
			$mode_list[$wl_standard] = '802.' . $wl_standard;
3137
		}
3138
	}
3139
3140 aa82505e Phil Davis
	if (count($mode_list) == 1) {
3141 68933ba7 Stephen Beaver
		$mode_list[''] = '';
3142 aa82505e Phil Davis
	}
3143 68933ba7 Stephen Beaver
3144
	$section->addInput(new Form_Select(
3145
		'standard',
3146
		'Standard',
3147
		($pconfig['standard'] == "") ? "11ng":$pconfig['standard'],
3148
		$mode_list
3149
	));
3150
3151
	if (isset($wl_modes['11g'])) {
3152
		$section->addInput(new Form_Select(
3153
			'protmode',
3154
			'802.11g OFDM Protection Mode',
3155
			$pconfig['protmode'],
3156 0fc3de67 Phil Davis
			['off' => gettext('Off'), 'cts' => gettext('CTS to self'), 'rtscts' => gettext('RTS and CTS')]
3157 68933ba7 Stephen Beaver
		))->setHelp('For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network.');
3158 aa82505e Phil Davis
	} else {
3159 ee12dd78 Peter Feichtinger
		$form->addGlobal(new Form_Input(
3160 68933ba7 Stephen Beaver
			'protmode',
3161
			null,
3162
			'hidden',
3163
			'off'
3164
		));
3165
	}
3166
3167 0fc3de67 Phil Davis
	$mode_list = ['0' => gettext('Auto')];
3168 68933ba7 Stephen Beaver
3169
	if (is_array($wl_modes)) {
3170
		foreach ($wl_modes as $wl_standard => $wl_channels) {
3171
			if ($wl_standard == "11g") {
3172
				$wl_standard = "11b/g";
3173
			} else if ($wl_standard == "11ng") {
3174
				$wl_standard = "11b/g/n";
3175
			} else if ($wl_standard == "11na") {
3176
				$wl_standard = "11a/n";
3177
			}
3178
3179
			foreach ($wl_channels as $wl_channel) {
3180
				if (isset($wl_chaninfo[$wl_channel])) {
3181 91fd7459 Viktor G
					$mode_list[$wl_channel] = $wl_standard . ' - ' . $wl_channel;
3182 68933ba7 Stephen Beaver
				} else {
3183 91fd7459 Viktor G
					$mode_list[$wl_channel] = $wl_standard . ' - ' . $wl_channel . ' (' . $wl_chaninfo[$wl_channel][1] . ' @ ' . $wl_chaninfo[$wl_channel][2] . ' / ' . $wl_chaninfo[$wl_channel][3] . ')';
3184 68933ba7 Stephen Beaver
				}
3185
			}
3186
		}
3187
	}
3188
3189
	$section->addInput(new Form_Select(
3190
		'channel',
3191
		'Channel',
3192
		$pconfig['channel'],
3193
		$mode_list
3194 4d0c9c59 Phil Davis
	))->setHelp('Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain) %1$s' .
3195
				'Not all channels may be supported by some cards.  Auto may override the wireless standard selected above.', '<br />');
3196 68933ba7 Stephen Beaver
3197 91fd7459 Viktor G
	$section->addInput(new Form_Select(
3198
		'channel_width',
3199
		'Channel width',
3200
		$pconfig['channel_width'],
3201
		$wl_ht_modes
3202
	))->setHelp('Channel width for 802.11n mode. Not all cards may support channel width changing.');
3203
3204 725f987f Stephen Beaver
	if (ANTENNAS) {
3205
		if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])) {
3206
			$group = new Form_Group('Antenna Settings');
3207
3208
			if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])) {
3209
				$group->add(new Form_Select(
3210
					'diversity',
3211
					null,
3212
					(isset($pconfig['diversity'])) ? $pconfig['diversity']:'',
3213 0fc3de67 Phil Davis
					['' => gettext('Default'), '0' => gettext('Off'), '1' => gettext('On')]
3214 725f987f Stephen Beaver
				))->setHelp('Diversity');
3215
			}
3216 68933ba7 Stephen Beaver
3217 725f987f Stephen Beaver
			if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])) {
3218
				$group->add(new Form_Select(
3219
					'txantenna',
3220
					null,
3221
					(isset($pconfig['txantenna'])) ? $pconfig['txantenna']:'',
3222 0fc3de67 Phil Davis
					['' => gettext('Default'), '0' => gettext('Auto'), '1' => gettext('#1'), '2' => gettext('#2')]
3223 725f987f Stephen Beaver
				))->setHelp('Transmit antenna');
3224
			}
3225 68933ba7 Stephen Beaver
3226 725f987f Stephen Beaver
			if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])) {
3227
				$group->add(new Form_Select(
3228
					'rxantenna',
3229
					null,
3230
					(isset($pconfig['rxantenna'])) ? $pconfig['rxantenna']:'',
3231 0fc3de67 Phil Davis
					['' => gettext('Default'), '0' => gettext('Auto'), '1' => gettext('#1'), '2' => gettext('#2')]
3232 725f987f Stephen Beaver
				))->setHelp('Receive antenna');
3233
			}
3234 68933ba7 Stephen Beaver
3235 725f987f Stephen Beaver
			$group->setHelp('Note: The antenna numbers do not always match up with the labels on the card.');
3236 68933ba7 Stephen Beaver
3237 725f987f Stephen Beaver
			$section->add($group);
3238
		}
3239 68933ba7 Stephen Beaver
	}
3240
3241
	if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])) {
3242
			$section->addInput(new Form_Input(
3243
				'distance',
3244
				'Distance setting (meters)',
3245
				'test',
3246
				$pconfig['distance']
3247
			))->setHelp('This field can be used to tune ACK/CTS timers to fit the distance between AP and Client');
3248
	}
3249
3250
	$form->add($section);
3251
3252
	// Regulatory settings
3253 5f88f964 k-paulius
	$section = new Form_Section('Regulatory Settings');
3254 68933ba7 Stephen Beaver
3255
	$domain_list = array("" => 'Default');
3256
3257
	if (is_array($wl_regdomains)) {
3258
		foreach ($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
3259
			$domain_list[$wl_regdomains_attr[$wl_regdomain_key]['ID']] = $wl_regdomain['name'];
3260
		}
3261
	}
3262
3263
	$section->addInput(new Form_Select(
3264
		'regdomain',
3265
		'Regulatory domain',
3266
		$pconfig['regdomain'],
3267
		$domain_list
3268
	))->setHelp('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');
3269
3270
	$country_list = array('' => 'Default');
3271
3272
	if (is_array($wl_countries)) {
3273
		foreach ($wl_countries as $wl_country_key => $wl_country) {
3274
			$country_list[	$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']);
3275
		}
3276
	}
3277
3278
	$section->addInput(new Form_Select(
3279
		'regcountry',
3280
		'Country',
3281
		$pconfig['regcountry'],
3282
		$country_list
3283
	))->setHelp('Any country setting other than "Default" will override the regulatory domain setting');
3284
3285
	$section->addInput(new Form_Select(
3286
		'reglocation',
3287
		'Location',
3288
		$pconfig['reglocation'],
3289 0fc3de67 Phil Davis
		['' => gettext('Default'), 'indoor' => gettext('Indoor'), 'outdoor' => gettext('Outdoor'), 'anywhere' => gettext('Anywhere')]
3290 68933ba7 Stephen Beaver
	))->setHelp('These settings may affect which channels are available and the maximum transmit power allowed on those channels. ' .
3291 4d0c9c59 Phil Davis
				'Using the correct settings to comply with local regulatory requirements is recommended.%1$s' .
3292 68933ba7 Stephen Beaver
				'All wireless networks on this interface will be temporarily brought down when changing regulatory settings.  ' .
3293
				'Some of the regulatory domains or country codes may not be allowed by some cards.	' .
3294 4d0c9c59 Phil Davis
				'These settings may not be able to add additional channels that are not already supported.', '<br />');
3295 68933ba7 Stephen Beaver
3296
	$form->add($section);
3297
3298 5f88f964 k-paulius
	$section = new Form_Section('Network-Specific Wireless Configuration');
3299 68933ba7 Stephen Beaver
3300
	$section->addInput(new Form_Select(
3301
		'mode',
3302
		'Mode',
3303
		$pconfig['mode'],
3304 0fc3de67 Phil Davis
		['bss' => gettext('Infrastructure (BSS)'), 'adhoc' => gettext('Ad-hoc (IBSS)'), 'hostap' => gettext('Access Point')]
3305 68933ba7 Stephen Beaver
	));
3306
3307
	$section->addInput(new Form_Input(
3308
		'ssid',
3309
		'SSID',
3310
		'text',
3311
		$pconfig['ssid']
3312
	));
3313
3314
	if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])) {
3315
		$section->addInput(new Form_Select(
3316
			'puremode',
3317
			'Minimum wireless standard',
3318
			$pconfig['puremode'],
3319 0fc3de67 Phil Davis
			['any' => gettext('Any'), '11g' => gettext('802.11g'), '11n' => gettext('802.11n')]
3320 68933ba7 Stephen Beaver
		))->setHelp('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)');
3321
	} elseif (isset($wl_modes['11g'])) {
3322
		$section->addInput(new Form_Checkbox(
3323
			'puremode',
3324
			'802.11g only',
3325 109ebe80 Stephen Beaver
			null,
3326 68933ba7 Stephen Beaver
			$pconfig['puremode'],
3327
			'11g'
3328
		))->setHelp('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)');
3329
	}
3330
3331
	$section->addInput(new Form_Checkbox(
3332
		'apbridge_enable',
3333
		'Allow intra-BSS communication',
3334
		'Allow packets to pass between wireless clients directly when operating as an access point',
3335
		$pconfig['apbridge_enable'],
3336
		'yes'
3337 11439ca3 jim-p
	))->setHelp('Provides extra security by isolating clients so they cannot directly communicate with one another');
3338 68933ba7 Stephen Beaver
3339
	$section->addInput(new Form_Checkbox(
3340
		'wme_enable',
3341
		'Enable WME',
3342
		'Force the card to use WME (wireless QoS)',
3343
		$pconfig['wme_enable'],
3344
		'yes'
3345
	));
3346
3347
	$section->addInput(new Form_Checkbox(
3348
		'hidessid_enable',
3349
		'Hide SSID',
3350 11439ca3 jim-p
		'Disable broadcasting of the SSID for this network (This may cause problems for some clients, and the SSID may still be discovered by other means.)',
3351 68933ba7 Stephen Beaver
		$pconfig['hidessid_enable'],
3352
		'yes'
3353
	));
3354
3355
	$form->add($section);
3356
3357
	// WPA Section
3358
	$section = new Form_Section('WPA');
3359
3360
	$section->addInput(new Form_Checkbox(
3361
		'wpa_enable',
3362
		'Enable',
3363
		'Enable WPA',
3364
		$pconfig['wpa_enable'],
3365
		'yes'
3366
	));
3367
3368
	$section->addInput(new Form_Select(
3369
		'wpa_mode',
3370
		'WPA mode',
3371
		(isset($pconfig['wpa_mode'])) ? $pconfig['wpa_mode']: '2',
3372 0fc3de67 Phil Davis
		['1' => gettext('WPA'), '2' => gettext('WPA2'), '3' => gettext('Both')]
3373 68933ba7 Stephen Beaver
	));
3374
3375 5f120301 Viktor G
	$section->addInput(new Form_Select(
3376
		'wpa_pairwise',
3377
		'WPA Pairwise',
3378
		(isset($pconfig['wpa_pairwise'])) ? $pconfig['wpa_pairwise']:'CCMP',
3379
		['CCMP TKIP' => gettext('Both'), 'CCMP' => gettext('AES (recommended)'), 'TKIP' => gettext('TKIP')]
3380
	));
3381
3382 68933ba7 Stephen Beaver
	$section->addInput(new Form_Select(
3383
		'wpa_key_mgmt',
3384
		'WPA Key Management Mode',
3385
		$pconfig['wpa_key_mgmt'],
3386 0fc3de67 Phil Davis
		['WPA-PSK' => gettext('Pre-Shared Key'), 'WPA-EAP' => gettext('Extensible Authentication Protocol'), 'WPA-PSK WPA-EAP' => gettext('Both')]
3387 68933ba7 Stephen Beaver
	));
3388
3389 5f120301 Viktor G
	$section->addInput(new Form_Input(
3390
		'passphrase',
3391
		'WPA Pre-Shared Key',
3392
		'text',
3393
		$pconfig['passphrase']
3394
	))->setHelp('WPA Passphrase must be between 8 and 63 characters long');
3395
3396 68933ba7 Stephen Beaver
	$section->addInput(new Form_Select(
3397 5f120301 Viktor G
		'wpa_eap_client_mode',
3398
		'EAP Client Mode',
3399
		$pconfig['wpa_eap_client_mode'],
3400
		['PEAP' => 'PEAP', 'TLS' => 'TLS', 'TTLS' => 'TTLS']
3401
	));
3402
3403
	$section->addInput(new Form_Select(
3404
		'wpa_eap_ca',
3405
		'Certificate Authority',
3406
		$pconfig['wpa_eap_ca'],
3407
		cert_build_list('ca', 'HTTPS')
3408
	));
3409
3410
	$section->addInput(new Form_Select(
3411
		'wpa_eap_inner_auth',
3412
		'Inner Authentication Method',
3413
		$pconfig['wpa_eap_inner_auth'],
3414 296c5881 Viktor G
		['MSCHAPV2' => gettext('MSCHAPv2'), 'MD5' => gettext('MD5'), 'PAP' => gettext('PAP')]
3415 5f120301 Viktor G
	));
3416
3417
	$section->addInput(new Form_Input(
3418
		'wpa_eap_inner_id',
3419
		'*Inner Authentication Identity',
3420
		'text',
3421
		$pconfig['wpa_eap_inner_id']
3422
	));
3423
3424
	$section->addInput(new Form_Input(
3425
		'wpa_eap_inner_password',
3426
		'*Inner Authentication Passphrase',
3427
		'text',
3428
		$pconfig['wpa_eap_inner_password']
3429
	));
3430
3431
	$section->addInput(new Form_Select(
3432
		'wpa_eap_cert',
3433
		'TLS/TTLS Client Certificate',
3434
		$pconfig['wpa_eap_cert'],
3435
		cert_build_list('cert', 'HTTPS')
3436 68933ba7 Stephen Beaver
	));
3437
3438
	$section->addInput(new Form_Input(
3439
		'wpa_group_rekey',
3440 11439ca3 jim-p
		'Group Key Rotation',
3441 68933ba7 Stephen Beaver
		'number',
3442
		$pconfig['wpa_group_rekey'] ? $pconfig['wpa_group_rekey'] : "60",
3443
		['min' => '1', 'max' => 9999]
3444 11439ca3 jim-p
	))->setHelp('Time between group rekey events, specified in seconds. Allowed values are 1-9999. Must be shorter than Master Key Regeneration time');
3445 68933ba7 Stephen Beaver
3446
	$section->addInput(new Form_Input(
3447
		'wpa_gmk_rekey',
3448 11439ca3 jim-p
		'Group Master Key Regeneration',
3449 68933ba7 Stephen Beaver
		'number',
3450
		$pconfig['wpa_gmk_rekey'] ? $pconfig['wpa_gmk_rekey'] : "3600",
3451
		['min' => '1', 'max' => 9999]
3452 11439ca3 jim-p
	))->setHelp('Time between GMK rekey events, specified in seconds. Allowed values are 1-9999. Must be longer than Group Key Rotation time');
3453 68933ba7 Stephen Beaver
3454
	$section->addInput(new Form_Checkbox(
3455
		'wpa_strict_rekey',
3456
		'Strict Key Regeneration',
3457
		'Force the AP to rekey whenever a client disassociates',
3458
		$pconfig['wpa_strict_rekey'],
3459
		'yes'
3460
	));
3461
3462 d65e45d3 Stephen Beaver
	$form->add($section);
3463
3464 5f88f964 k-paulius
	$section = new Form_Section('802.1x RADIUS Options');
3465 5f120301 Viktor G
	$section->addClass('ieee8021x_group');
3466 d65e45d3 Stephen Beaver
3467 68933ba7 Stephen Beaver
	$section->addInput(new Form_Checkbox(
3468
		'ieee8021x',
3469
		'IEEE802.1X',
3470
		'Enable 802.1X authentication',
3471
		$pconfig['ieee8021x'],
3472
		'yes'
3473 5f120301 Viktor G
	));
3474 68933ba7 Stephen Beaver
3475
	$group = new Form_Group('Primary 802.1X server');
3476
3477
	$group->add(new Form_IpAddress(
3478
		'auth_server_addr',
3479
		'IP Address',
3480
		$pconfig['auth_server_addr']
3481 11439ca3 jim-p
	))->setHelp('IP address of the RADIUS server');
3482 68933ba7 Stephen Beaver
3483
	$group->add(new Form_Input(
3484
		'auth_server_port',
3485
		'Port',
3486
		'number',
3487
		$pconfig['auth_server_port']
3488 11439ca3 jim-p
	))->setHelp('Server auth port. Default is 1812');
3489 68933ba7 Stephen Beaver
3490
	$group->add(new Form_Input(
3491
		'auth_server_shared_secret',
3492 11439ca3 jim-p
		'Shared Secret',
3493 1b2527f2 jim-p
		'text',
3494 68933ba7 Stephen Beaver
		$pconfig['auth_server_shared_secret']
3495 11439ca3 jim-p
	))->setHelp('RADIUS Shared secret for this firewall');
3496 68933ba7 Stephen Beaver
3497
	$section->add($group);
3498
3499
	$group = new Form_Group('Secondary 802.1X server');
3500
3501
	$group->add(new Form_IpAddress(
3502
		'auth_server_addr2',
3503
		'IP Address',
3504
		$pconfig['auth_server_addr2']
3505 11439ca3 jim-p
	))->setHelp('IP address of the RADIUS server');
3506 68933ba7 Stephen Beaver
3507
	$group->add(new Form_Input(
3508
		'auth_server_port2',
3509
		'Port',
3510
		'number',
3511
		$pconfig['auth_server_port2']
3512 11439ca3 jim-p
	))->setHelp('Server auth port. Default is 1812');
3513 68933ba7 Stephen Beaver
3514
	$group->add(new Form_Input(
3515
		'auth_server_shared_secret2',
3516 11439ca3 jim-p
		'Shared Secret',
3517 1b2527f2 jim-p
		'text',
3518 68933ba7 Stephen Beaver
		$pconfig['auth_server_shared_secret2']
3519 11439ca3 jim-p
	))->setHelp('RADIUS Shared secret for this firewall');
3520 68933ba7 Stephen Beaver
3521
	$section->add($group);
3522
3523
	$section->addInput(new Form_Checkbox(
3524
		'rsn_preauth',
3525
		'Authentication Roaming Preauth',
3526
		null,
3527
		$pconfig['rsn_preauth'],
3528
		'yes'
3529 5f120301 Viktor G
	))->setHelp('Pre-authentication to speed up roaming between access points.');
3530 68933ba7 Stephen Beaver
3531
	$form->add($section);
3532 a0509b13 Stephen Beaver
}
3533
3534 3cf65ce0 NOYB
$section = new Form_Section('Reserved Networks');
3535 a0509b13 Stephen Beaver
3536
$section->addInput(new Form_Checkbox(
3537 68933ba7 Stephen Beaver
	'blockpriv',
3538 eaa948d6 NOYB
	'Block private networks and loopback addresses',
3539 68933ba7 Stephen Beaver
	'',
3540
	$pconfig['blockpriv'],
3541
	'yes'
3542 a0509b13 Stephen Beaver
))->setHelp('Blocks traffic from IP addresses that are reserved for private networks per RFC 1918 (10/8, 172.16/12, 192.168/16) ' .
3543 eaa948d6 NOYB
			'and unique local addresses per RFC 4193 (fc00::/7) as well as loopback addresses (127/8). This option should ' .
3544
			'generally be turned on, unless this network interface resides in such a private address space, too.');
3545 68933ba7 Stephen Beaver
3546 aa82505e Phil Davis
$section->addInput(new Form_Checkbox(
3547 68933ba7 Stephen Beaver
	'blockbogons',
3548
	'Block bogon networks',
3549
	'',
3550
	$pconfig['blockbogons'],
3551
	'yes'
3552 a0509b13 Stephen Beaver
))->setHelp('Blocks traffic from reserved IP addresses (but not RFC 1918) or not yet assigned by IANA. Bogons are prefixes that should ' .
3553 4d0c9c59 Phil Davis
			'never appear in the Internet routing table, and so should not appear as the source address in any packets received.%1$s' .
3554 d16ea02a jim-p
			'This option should only be used on external interfaces (WANs), it is not necessary on local interfaces and it can potentially block required local traffic.%1$s' .
3555 7dfb18da Joseph Reeves
			'Note: The update frequency can be changed under System > Advanced, Firewall & NAT settings.', '<br />');
3556 eaf7cb2a Stephen Beaver
3557
$form->add($section);
3558 a0509b13 Stephen Beaver
3559
$form->addGlobal(new Form_Input(
3560 68933ba7 Stephen Beaver
	'if',
3561
	null,
3562
	'hidden',
3563
	$if
3564 a0509b13 Stephen Beaver
));
3565
3566 6a9435a6 Viktor G
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
3567
	$form->addGlobal(new Form_Input(
3568
		'ppp_port',
3569
		null,
3570
		'hidden',
3571
		$pconfig['port']
3572
	));
3573
}
3574
3575 a0509b13 Stephen Beaver
$form->addGlobal(new Form_Input(
3576 68933ba7 Stephen Beaver
	'ptpid',
3577
	null,
3578
	'hidden',
3579
	$pconfig['ptpid']
3580 a0509b13 Stephen Beaver
));
3581
3582 564599fa Stephen Beaver
3583
// Add new gateway modal pop-up
3584 dfafd8c2 Phil Davis
$modal = new Modal('New IPv4 Gateway', 'newgateway4', 'large');
3585 564599fa Stephen Beaver
3586
$modal->addInput(new Form_Checkbox(
3587 dfafd8c2 Phil Davis
	'defaultgw4',
3588 564599fa Stephen Beaver
	'Default',
3589
	'Default gateway',
3590 e8113404 Phil Davis
	isset($gateway_settings4['defaultgw']) ? $gateway_settings4['defaultgw'] : ($if == "wan" || $if == "WAN")
3591 564599fa Stephen Beaver
));
3592
3593
$modal->addInput(new Form_Input(
3594 dfafd8c2 Phil Davis
	'gatewayname4',
3595 564599fa Stephen Beaver
	'Gateway name',
3596
	'text',
3597 e8113404 Phil Davis
	($gateway_settings4['name'] == "") ? $defgatewayname4 : $gateway_settings4['name']
3598 564599fa Stephen Beaver
));
3599
3600
$modal->addInput(new Form_IpAddress(
3601 dfafd8c2 Phil Davis
	'gatewayip4',
3602 564599fa Stephen Beaver
	'Gateway IPv4',
3603 e8113404 Phil Davis
	$gateway_settings4['gateway'],
3604 41fc88ec Phil Davis
	'V4'
3605 564599fa Stephen Beaver
));
3606
3607
$modal->addInput(new Form_Input(
3608 dfafd8c2 Phil Davis
	'gatewaydescr4',
3609 564599fa Stephen Beaver
	'Description',
3610 e8113404 Phil Davis
	'text',
3611
	$gateway_settings4['descr']
3612 564599fa Stephen Beaver
));
3613
3614 dfafd8c2 Phil Davis
$btnaddgw4 = new Form_Button(
3615
	'add4',
3616 faab522f Renato Botelho
	'Add',
3617 2e7fa7ca jim-p
	null,
3618
	'fa-plus'
3619 564599fa Stephen Beaver
);
3620
3621 dfafd8c2 Phil Davis
$btnaddgw4->setAttribute('type','button')->addClass('btn-success');
3622 564599fa Stephen Beaver
3623 dfafd8c2 Phil Davis
$btncnxgw4 = new Form_Button(
3624
	'cnx4',
3625 faab522f Renato Botelho
	'Cancel',
3626 2e7fa7ca jim-p
	null,
3627
	'fa-undo'
3628 564599fa Stephen Beaver
);
3629
3630 dfafd8c2 Phil Davis
$btncnxgw4->setAttribute('type','button')->addClass('btn-warning');
3631 564599fa Stephen Beaver
3632
$modal->addInput(new Form_StaticText(
3633
	null,
3634 dfafd8c2 Phil Davis
	$btnaddgw4 . $btncnxgw4
3635 564599fa Stephen Beaver
));
3636
3637
$form->add($modal);
3638
3639 ae4c4bac Stephen Beaver
print($form);
3640
?>
3641 a0509b13 Stephen Beaver
3642 ae4c4bac Stephen Beaver
<script type="text/javascript">
3643 309e8f8f Stephen Beaver
//<![CDATA[
3644 aa82505e Phil Davis
events.push(function() {
3645 68933ba7 Stephen Beaver
	function updateType(t) {
3646 564599fa Stephen Beaver
3647 68933ba7 Stephen Beaver
		switch (t) {
3648
			case "none": {
3649 34ab580d Stephen Beaver
				$('.dhcpadvanced, .staticv4, .dhcp, .pppoe, .pptp, .ppp').hide();
3650 68933ba7 Stephen Beaver
				break;
3651
			}
3652
			case "staticv4": {
3653 2ed5fb61 Phil Davis
				$('.dhcpadvanced, .none, .dhcp').hide();
3654 564599fa Stephen Beaver
				$('.pppoe, .pptp, .ppp').hide();
3655 68933ba7 Stephen Beaver
				break;
3656
			}
3657
			case "dhcp": {
3658 564599fa Stephen Beaver
				$('.dhcpadvanced, .none').hide();
3659
				$('.staticv4').hide();	// MYSTERY: This line makes the page very slow to load, but why? There is nothing special
3660
										//			about the staticv4 class
3661
				$('.pppoe, .pptp, .ppp').hide();
3662 68933ba7 Stephen Beaver
				break;
3663
			}
3664
			case "ppp": {
3665 34ab580d Stephen Beaver
				$('.dhcpadvanced, .none, .staticv4, .dhcp, .pptp, .pppoe').hide();
3666 68933ba7 Stephen Beaver
				country_list();
3667
				break;
3668
			}
3669
			case "pppoe": {
3670 34ab580d Stephen Beaver
				$('.dhcpadvanced, .none, .staticv4, .dhcp, .pptp, .ppp').hide();
3671 68933ba7 Stephen Beaver
				break;
3672
			}
3673 8e267d3b Viktor G
			case "l2tp": {
3674 34ab580d Stephen Beaver
				$('.dhcpadvanced, .none, .staticv4, .dhcp, .pppoe, .ppp').hide();
3675 8e267d3b Viktor G
				$('.pptp, .l2tp_secret').show();
3676
				break;
3677
			}
3678
			case "pptp": {
3679
				$('.dhcpadvanced, .none, .staticv4, .dhcp, .pppoe, .ppp, .l2tp_secret').hide();
3680 68933ba7 Stephen Beaver
				$('.pptp').show();
3681
				break;
3682
			}
3683
		}
3684
3685
		if (t != "l2tp" && t != "pptp") {
3686
			$('.'+t).show();
3687
		}
3688
	}
3689
3690
	function updateTypeSix(t) {
3691 aa82505e Phil Davis
		if (!isNaN(t[0])) {
3692 68933ba7 Stephen Beaver
			t = '_' + t;
3693 aa82505e Phil Davis
		}
3694 68933ba7 Stephen Beaver
3695
		switch (t) {
3696
			case "none": {
3697 c0c25504 Stephen Beaver
				$('.dhcp6advanced, .staticv6, .dhcp6, ._6rd, ._6to4, .track6, .slaac').hide();
3698 68933ba7 Stephen Beaver
				break;
3699
			}
3700
			case "staticv6": {
3701 c0c25504 Stephen Beaver
				$('.dhcp6advanced, .none, .dhcp6, ._6rd, ._6to4, .track6, .slaac').hide();
3702 68933ba7 Stephen Beaver
				break;
3703
			}
3704
			case "slaac": {
3705 c0c25504 Stephen Beaver
				$('.dhcp6advanced, .none, .staticv6, ._6rd, ._6to4, .track6, .dhcp6').hide();
3706 68933ba7 Stephen Beaver
				break;
3707
			}
3708
			case "dhcp6": {
3709 c0c25504 Stephen Beaver
				$('.dhcp6advanced, .none, .staticv6, ._6rd, ._6to4, .track6, .slaac').hide();
3710 68933ba7 Stephen Beaver
				break;
3711
			}
3712 ea125f70 Chris Buechler
			case "_6rd": {
3713 c0c25504 Stephen Beaver
				$('.dhcp6advanced, .none, .dhcp6, .staticv6, ._6to4, .track6, .slaac').hide();
3714 68933ba7 Stephen Beaver
				break;
3715
			}
3716
			case "_6to4": {
3717 c0c25504 Stephen Beaver
				$('.dhcp6advanced, .none, .dhcp6, .staticv6, ._6rd, .track6, .slaac').hide();
3718 68933ba7 Stephen Beaver
				break;
3719
			}
3720
			case "track6": {
3721 c0c25504 Stephen Beaver
				$('.dhcp6advanced, .none, .dhcp6, .staticv6, ._6rd, ._6to4, .slaac').hide();
3722 68933ba7 Stephen Beaver
				update_track6_prefix();
3723
				break;
3724
			}
3725
		}
3726
3727
		if (t != "l2tp" && t != "pptp") {
3728
			$('.'+t).show();
3729
		}
3730
	}
3731
3732
	function show_reset_settings(reset_type) {
3733
		if (reset_type == 'preset') {
3734
			$('.pppoepreset').show();
3735
			$('.pppoecustom').hide();
3736
		} else if (reset_type == 'custom') {
3737
			$('.pppoecustom').show();
3738
			$('.pppoepreset').hide();
3739
		} else {
3740
			$('.pppoecustom').hide();
3741
			$('.pppoepreset').hide();
3742
		}
3743
	}
3744
3745
	function update_track6_prefix() {
3746
		var iface = $("#track6-interface").val();
3747
		if (iface == null) {
3748
			return;
3749
		}
3750
3751
		var track6_prefix_ids = $('#ipv6-num-prefix-ids-' + iface).val();
3752
		if (track6_prefix_ids == null) {
3753
			return;
3754
		}
3755
3756
		track6_prefix_ids = parseInt(track6_prefix_ids).toString(16);
3757 4d0c9c59 Phil Davis
		$('#track6-prefix-id-range').html(track6_prefix_ids);
3758 68933ba7 Stephen Beaver
	}
3759
3760 e8113404 Phil Davis
	function addOption_v4() {
3761
		var gwtext_v4 = escape($("#gatewayname4").val()) + " - " + $("#gatewayip4").val();
3762
		addSelectboxOption($('#gateway'), gwtext_v4, $("#gatewayname4").val());
3763 68933ba7 Stephen Beaver
	}
3764
3765 e8113404 Phil Davis
	function addOption_v6() {
3766
		var gwtext_v6 = escape($("#gatewayname6").val()) + " - " + $("#gatewayip6").val();
3767 b4538739 Phil Davis
		addSelectboxOption($('#gatewayv6'), gwtext_v6, $("#gatewayname6").val());
3768 68933ba7 Stephen Beaver
	}
3769
3770 e8113404 Phil Davis
	function addSelectboxOption(selectbox, text, value) {
3771 68933ba7 Stephen Beaver
		var optn = document.createElement("OPTION");
3772
		optn.text = text;
3773
		optn.value = value;
3774
		selectbox.append(optn);
3775
		selectbox.prop('selectedIndex', selectbox.children().length - 1);
3776
	}
3777
3778
	function country_list() {
3779
		$('#country').children().remove();
3780
		$('#provider_list').children().remove();
3781
		$('#providerplan').children().remove();
3782 543dc925 jim-p
		$.ajax({
3783
			type: 'post',
3784
			url: 'getserviceproviders.php',
3785
			data: { get_country_list: true },
3786 68933ba7 Stephen Beaver
			success: function(response) {
3787
3788
				var responseTextArr = response.split("\n");
3789
				responseTextArr.sort();
3790
3791
				responseTextArr.forEach( function(value) {
3792
					country = value.split(":");
3793
					$('#country').append($('<option>', {
3794
						value: country[1],
3795
						text : country[0]
3796
					}));
3797
				});
3798
			}
3799
		});
3800
	}
3801
3802
	function providers_list() {
3803
		$('#provider_list').children().remove();
3804
		$('#providerplan').children().remove();
3805
		$.ajax("getserviceproviders.php",{
3806
			type: 'post',
3807
			data: {country : $('#country').val()},
3808
			success: function(response) {
3809
				var responseTextArr = response.split("\n");
3810
				responseTextArr.sort();
3811
				responseTextArr.forEach( function(value) {
3812
					$('#provider_list').append($('<option>', {
3813
							value: value,
3814
							text : value
3815
					}));
3816
				});
3817
			}
3818
		});
3819
	}
3820
3821
	function providerplan_list() {
3822
		$('#providerplan').children().remove();
3823
		$.ajax("getserviceproviders.php",{
3824
			type: 'post',
3825
			data: {country : $('#country').val(), provider : $('#provider_list').val()},
3826
			success: function(response) {
3827
				var responseTextArr = response.split("\n");
3828
				responseTextArr.sort();
3829
3830
				$('#providerplan').append($('<option>', {
3831
					value: '',
3832
					text : ''
3833
				}));
3834
3835
				responseTextArr.forEach( function(value) {
3836
					if (value != "") {
3837
						providerplan = value.split(":");
3838
3839
						$('#providerplan').append($('<option>', {
3840
							value: providerplan[1],
3841
							text : providerplan[0] + " - " + providerplan[1]
3842
						}));
3843
					}
3844
				});
3845
			}
3846
		});
3847
	}
3848
3849
	function prefill_provider() {
3850
		$.ajax("getserviceproviders.php",{
3851
			type: 'post',
3852
			data: {country : $('#country').val(), provider : $('#provider_list').val(), plan : $('#providerplan').val()},
3853
			success: function(data, textStatus, response) {
3854
				var xmldoc = response.responseXML;
3855
				var provider = xmldoc.getElementsByTagName('connection')[0];
3856
				$('#ppp_username').val('');
3857
				$('#ppp_password').val('');
3858
				if (provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
3859
					$('#phone').val('#777');
3860
					$('#apn').val('');
3861
				} else {
3862
					$('#phone').val('*99#');
3863
					$('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
3864
				}
3865
				ppp_username = provider.getElementsByTagName('ppp_username')[0].firstChild.data;
3866
				ppp_password = provider.getElementsByTagName('ppp_password')[0].firstChild.data;
3867
				$('#ppp_username').val(ppp_username);
3868
				$('#ppp_password').val(ppp_password);
3869
			}
3870
		});
3871
	}
3872
3873
	function show_dhcp6adv() {
3874
		var ovr = $('#adv_dhcp6_config_file_override').prop('checked');
3875 7361f6c2 Stephen Beaver
		var adv = $('#adv_dhcp6_config_advanced').prop('checked');
3876 68933ba7 Stephen Beaver
3877
		hideCheckbox('dhcp6usev4iface', ovr);
3878
		hideCheckbox('dhcp6prefixonly', ovr);
3879
		hideInput('dhcp6-ia-pd-len', ovr);
3880
		hideCheckbox('dhcp6-ia-pd-send-hint', ovr);
3881
		hideInput('adv_dhcp6_config_file_override_path', !ovr);
3882
3883
		hideClass('dhcp6advanced', !adv || ovr);
3884
	}
3885
3886 34ab580d Stephen Beaver
	function setDHCPoptions() {
3887 0c5916ce NOYB
		var adv = $('#adv_dhcp_config_advanced').prop('checked');
3888
		var ovr = $('#adv_dhcp_config_file_override').prop('checked');
3889 34ab580d Stephen Beaver
3890 aa82505e Phil Davis
		if (ovr) {
3891 34ab580d Stephen Beaver
			hideInput('dhcphostname', true);
3892
			hideIpAddress('alias-address', true);
3893
			hideInput('dhcprejectfrom', true);
3894
			hideInput('adv_dhcp_config_file_override_path', false);
3895
			hideClass('dhcpadvanced', true);
3896
		} else {
3897
			hideInput('dhcphostname', false);
3898
			hideIpAddress('alias-address', false);
3899
			hideInput('dhcprejectfrom', false);
3900
			hideInput('adv_dhcp_config_file_override_path', true);
3901
			hideClass('dhcpadvanced', !adv);
3902
		}
3903
	}
3904
3905 564599fa Stephen Beaver
	// DHCP preset actions
3906
	// Set presets from value of radio buttons
3907
	function setPresets(val) {
3908
		// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
3909
		if (val == "DHCP")		setPresetsnow("60", "300", "0", "10", "120", "10");
3910
		if (val == "pfSense")	setPresetsnow("60", "15", "0", "", "", "1");
3911
		if (val == "SavedCfg")	setPresetsnow("<?=htmlspecialchars($pconfig['adv_dhcp_pt_timeout']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_retry']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_select_timeout']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_reboot']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_backoff_cutoff']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_initial_interval']);?>");
3912
		if (val == "Clear")		setPresetsnow("", "", "", "", "", "");
3913
	}
3914
3915
	function setPresetsnow(timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
3916
		$('#adv_dhcp_pt_timeout').val(timeout);
3917
		$('#adv_dhcp_pt_retry').val(retry);
3918
		$('#adv_dhcp_pt_select_timeout').val(selecttimeout);
3919
		$('#adv_dhcp_pt_reboot').val(reboot);
3920
		$('#adv_dhcp_pt_backoff_cutoff').val(backoffcutoff);
3921
		$('#adv_dhcp_pt_initial_interval').val(initialinterval);
3922
	}
3923
3924 fb572e81 Phil Davis
	function setPPPoEDialOnDemandItems() {
3925 32a85c63 Phil Davis
		setRequired('pppoe_idletimeout', $('#pppoe_dialondemand').prop('checked'));
3926
	}
3927
3928 fb572e81 Phil Davis
	function setPPTPDialOnDemandItems() {
3929
		setRequired('pptp_idletimeout', $('#pptp_dialondemand').prop('checked'));
3930
	}
3931
3932 5f120301 Viktor G
	function show_wpaoptions() {
3933
		var wpa = !($('#wpa_enable').prop('checked'));
3934
3935
		hideInput('passphrase', wpa);
3936
		hideInput('wpa_mode', wpa);
3937
		hideInput('wpa_key_mgmt', wpa);
3938
		hideInput('wpa_pairwise', wpa);
3939
		hideCheckbox('wpa_strict_rekey', wpa);
3940
		hideClass('ieee8021x_group', true);
3941
		if ($('#mode').val() == 'hostap') {
3942
			hideInput('wpa_group_rekey', wpa);
3943
			hideInput('wpa_gmk_rekey', wpa);
3944
			hideCheckbox('wpa_strict_rekey', wpa);
3945
		} else {
3946
			hideInput('wpa_group_rekey', true);
3947
			hideInput('wpa_gmk_rekey', true);
3948
			hideCheckbox('wpa_strict_rekey', true);
3949
		}
3950
		updatewpakeymgmt($('#wpa_key_mgmt').val());
3951
	}
3952
3953
	function updatewifistandard(s) {
3954
		switch (s) {
3955
			case "auto": {
3956
				hideInput('protmode', false);
3957
				hideInput('channel_width', false);
3958
				break;
3959
			}
3960
			case "11b": {
3961
				hideInput('protmode', true);
3962
				hideInput('channel_width', true);
3963
				break;
3964
			}
3965
			case "11g": {
3966
				hideInput('protmode', false);
3967
				hideInput('channel_width', true);
3968
				break;
3969
			}
3970
			case "11ng": {
3971
				hideInput('protmode', false);
3972
				hideInput('channel_width', false);
3973
				break;
3974
			}
3975
			case "11a": {
3976
				hideInput('protmode', true);
3977
				hideInput('channel_width', true);
3978
				break;
3979
			}
3980
			case "11na": {
3981
				hideInput('protmode', true);
3982
				hideInput('channel_width', false);
3983
				break;
3984
			}
3985
			default: {
3986
				break;
3987
			}
3988
		}
3989
	}
3990
3991
	function updatewifimode(m) {
3992
		switch (m) {
3993
			case "adhoc": {
3994
				hideInput('puremode', true);
3995
				hideCheckbox('apbridge_enable', true);
3996
				hideCheckbox('hidessid_enable', false);
3997
				break;
3998
			}
3999
			case "hostap": {
4000
				hideInput('puremode', false);
4001
				hideCheckbox('apbridge_enable', false);
4002
				hideCheckbox('hidessid_enable', false);
4003
				break;
4004
			}
4005
			default: {
4006
				hideInput('puremode', true);
4007
				hideCheckbox('apbridge_enable', true);
4008
				hideCheckbox('hidessid_enable', true);
4009
				break;
4010
			}
4011
		}
4012
		show_wpaoptions();
4013 f9d9d77e Viktor G
		updateeapclientmode($('#wpa_eap_client_mode').val());
4014
		updatewpakeymgmt($('#wpa_key_mgmt').val());
4015 5f120301 Viktor G
	}
4016
4017
	function updateeapclientmode(m) {
4018 f9d9d77e Viktor G
		if ($('#mode').val() == 'bss') {
4019
			var wpa = !($('#wpa_enable').prop('checked'));
4020
		} else {
4021
			var wpa = true;
4022
		}
4023 5f120301 Viktor G
		switch (m) {
4024 c7839f15 Viktor G
			case "PEAP": {
4025 5f120301 Viktor G
				hideInput('wpa_eap_cert', true);
4026
				hideInput('wpa_eap_inner_auth', wpa);
4027
				hideInput('wpa_eap_inner_id', wpa);
4028
				hideInput('wpa_eap_inner_password', wpa);
4029
				break;
4030
			}
4031 c7839f15 Viktor G
			case "TLS": {
4032 5f120301 Viktor G
				hideInput('wpa_eap_cert', wpa);
4033
				hideInput('wpa_eap_inner_auth', true);
4034
				hideInput('wpa_eap_inner_id', true);
4035
				hideInput('wpa_eap_inner_password', true);
4036
				break;
4037
			}
4038 c7839f15 Viktor G
			case "TTLS": {
4039 5f120301 Viktor G
				hideInput('wpa_eap_cert', wpa);
4040
				hideInput('wpa_eap_inner_auth', wpa);
4041
				hideInput('wpa_eap_inner_id', wpa);
4042
				hideInput('wpa_eap_inner_password', wpa);
4043
				break;
4044
			}
4045
			default: {
4046
				break;
4047
			}
4048
		}
4049
	}
4050
4051
	function updatewpakeymgmt(m) {
4052 f9d9d77e Viktor G
		hideInput('passphrase', false);
4053
		hideInput('wpa_eap_client_mode', true);
4054
		hideInput('wpa_eap_ca', true);
4055
		hideInput('wpa_eap_cert', true);
4056
		hideInput('wpa_eap_inner_auth', true);
4057
		hideInput('wpa_eap_inner_id', true);
4058
		hideInput('wpa_eap_inner_password', true);
4059
		hideClass('ieee8021x_group', true);
4060
		if (m == "WPA-EAP") {
4061 5f120301 Viktor G
			hideInput('passphrase', true);
4062 f9d9d77e Viktor G
			if ($('#mode').val() == 'bss') {
4063
				hideInput('wpa_eap_client_mode', false);
4064
				hideInput('wpa_eap_ca', false);
4065
				updateeapclientmode($('#wpa_eap_client_mode').val());
4066
			} else if ($('#mode').val() == 'hostap') {
4067
				hideClass('ieee8021x_group', false);
4068
			}
4069
		} else if (m != "WPA-PSK") {
4070
			hideInput('passphrase', false);
4071
			if ($('#mode').val() == 'bss') {
4072
				hideInput('wpa_eap_client_mode', false);
4073
				hideInput('wpa_eap_ca', false);
4074
				hideInput('wpa_eap_cert', false);
4075
				hideInput('wpa_eap_inner_auth', false);
4076
				hideInput('wpa_eap_inner_id', false);
4077
				hideInput('wpa_eap_inner_password', false);
4078
			} else if ($('#mode').val() == 'hostap') {
4079
				hideClass('ieee8021x_group', false);
4080
			}
4081 5f120301 Viktor G
		}
4082
	}
4083
4084 eef93144 Jared Dillard
	// ---------- On initial page load ------------------------------------------------------------
4085
4086 68933ba7 Stephen Beaver
	updateType($('#type').val());
4087
	updateTypeSix($('#type6').val());
4088
	show_reset_settings($('#pppoe-reset-type').val());
4089
	hideClass('dhcp6advanced', true);
4090 34ab580d Stephen Beaver
	hideClass('dhcpadvanced', true);
4091 68933ba7 Stephen Beaver
	show_dhcp6adv();
4092 32a85c63 Phil Davis
	setDHCPoptions();
4093 fb572e81 Phil Davis
	setPPPoEDialOnDemandItems();
4094
	setPPTPDialOnDemandItems();
4095 5f120301 Viktor G
	show_wpaoptions();
4096
	updatewifistandard($('#standard').val());
4097
	updatewifimode($('#mode').val());
4098 68933ba7 Stephen Beaver
4099 564599fa Stephen Beaver
	// Set preset buttons on page load
4100
	var sv = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
4101 aa82505e Phil Davis
	if (sv == "") {
4102 564599fa Stephen Beaver
		$("input[name=adv_dhcp_pt_values][value='SavedCfg']").prop('checked', true);
4103 b4f03056 NOYB
	} else {
4104
		$("input[name=adv_dhcp_pt_values][value="+sv+"]").prop('checked', true);
4105 aa82505e Phil Davis
	}
4106 564599fa Stephen Beaver
4107
	// Set preset from value
4108
	setPresets(sv);
4109 aa82505e Phil Davis
4110 e8113404 Phil Davis
	// If the user wants to add a gateway, then add that to the gateway selection
4111
	if ($("#gatewayip4").val() != '') {
4112
		addOption_v4();
4113
	}
4114
	if ($("#gatewayip6").val() != '') {
4115
		addOption_v6();
4116
	}
4117
4118 eef93144 Jared Dillard
	// ---------- Click checkbox handlers ---------------------------------------------------------
4119 9abccff3 Stephen Beaver
4120 564599fa Stephen Beaver
	$('#type').on('change', function() {
4121 aa82505e Phil Davis
		updateType(this.value);
4122 68933ba7 Stephen Beaver
	});
4123 3375f236 Stephen Beaver
4124 34ab580d Stephen Beaver
	$('#type6').on('change', function() {
4125 aa82505e Phil Davis
		updateTypeSix(this.value);
4126 68933ba7 Stephen Beaver
	});
4127 3375f236 Stephen Beaver
4128 5f120301 Viktor G
	$('#standard').on('change', function() {
4129
		updatewifistandard(this.value);
4130
	});
4131
4132
	$('#mode').on('change', function() {
4133
		updatewifimode(this.value);
4134
	});
4135
4136
	$('#wpa_key_mgmt').on('change', function() {
4137
		updatewpakeymgmt(this.value);
4138
	});
4139
4140
	$('#wpa_eap_client_mode').on('change', function() {
4141
		updateeapclientmode(this.value);
4142
	});
4143
4144 1ee6d09a Phil Davis
	$('#track6-interface').on('change', function() {
4145
		update_track6_prefix();
4146
	});
4147
4148 34ab580d Stephen Beaver
	$('#pppoe-reset-type').on('change', function() {
4149 aa82505e Phil Davis
		show_reset_settings(this.value);
4150 68933ba7 Stephen Beaver
	});
4151
4152 dfafd8c2 Phil Davis
	$("#add4").click(function() {
4153 e8113404 Phil Davis
		addOption_v4();
4154 f1bb5c7f Phil Davis
		$("#newgateway4").modal('hide');
4155 68933ba7 Stephen Beaver
	});
4156
4157 dfafd8c2 Phil Davis
	$("#cnx4").click(function() {
4158 f1bb5c7f Phil Davis
		$("#gatewayname4").val('<?=$defgatewayname4;?>');
4159
		$("#gatewayip4").val('');
4160
		$("#gatewaydescr4").val('');
4161 e8113404 Phil Davis
		$("#defaultgw4").prop("checked", false);
4162 dfafd8c2 Phil Davis
		$("#newgateway4").modal('hide');
4163 68933ba7 Stephen Beaver
	});
4164
4165
	$("#add6").click(function() {
4166 e8113404 Phil Davis
		addOption_v6();
4167 f1bb5c7f Phil Davis
		$("#newgateway6").modal('hide');
4168 68933ba7 Stephen Beaver
	});
4169
4170
	$("#cnx6").click(function() {
4171 f1bb5c7f Phil Davis
		$("#gatewayname6").val('<?=$defgatewayname6;?>');
4172
		$("#gatewayip6").val('');
4173
		$("#gatewaydescr6").val('');
4174 e8113404 Phil Davis
		$("#defaultgw6").prop("checked", false);
4175 68933ba7 Stephen Beaver
		$("#newgateway6").modal('hide');
4176
	});
4177
4178
	$('#country').on('change', function() {
4179
		providers_list();
4180
	});
4181
4182
	$('#provider_list').on('change', function() {
4183
		providerplan_list();
4184
	});
4185
4186
	$('#providerplan').on('change', function() {
4187
		prefill_provider();
4188
	});
4189
4190 0c5916ce NOYB
	$('#adv_dhcp_config_advanced, #adv_dhcp_config_file_override').click(function () {
4191 34ab580d Stephen Beaver
		setDHCPoptions();
4192
	});
4193
4194 7361f6c2 Stephen Beaver
	$('#adv_dhcp6_config_advanced').click(function () {
4195 68933ba7 Stephen Beaver
		show_dhcp6adv();
4196
	});
4197
4198
	$('#adv_dhcp6_config_file_override').click(function () {
4199
		show_dhcp6adv();
4200
	});
4201
4202
	// On click . .
4203 32a85c63 Phil Davis
	$('#pppoe_dialondemand').click(function () {
4204 fb572e81 Phil Davis
		setPPPoEDialOnDemandItems();
4205
	});
4206
4207
	$('#pptp_dialondemand').click(function () {
4208
		setPPTPDialOnDemandItems();
4209 32a85c63 Phil Davis
	});
4210
4211 b4f03056 NOYB
	$('[name=adv_dhcp_pt_values]').click(function () {
4212 68933ba7 Stephen Beaver
	   setPresets($('input[name=adv_dhcp_pt_values]:checked').val());
4213
	});
4214 564599fa Stephen Beaver
4215 5f120301 Viktor G
	$('#wpa_enable').click(function () {
4216
		show_wpaoptions();
4217
	});
4218
4219 d85d82b7 Stephen Beaver
	$('#pppoe_resetdate').datepicker();
4220
4221 aeeda8b4 Stephen Beaver
});
4222
//]]>
4223
</script>
4224 ae4c4bac Stephen Beaver
4225 241111d7 Stephen Beaver
<?php include("foot.inc");