Project

General

Profile

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