Project

General

Profile

Download (18.4 KB) Statistics
| Branch: | Tag: | Revision:
1 5ef4a9e1 Darren Embry
<?php
2
/*
3 9bd56e9d Christian McDonald
 * services_radvd.php
4 c80e6a6a Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8 402c98a2 Reid Linnemann
 * Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
9 c5d81585 Renato Botelho
 * Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
10
 * All rights reserved.
11 191cb31d 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 c80e6a6a 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 c80e6a6a Stephen Beaver
 *
20 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
21 c80e6a6a 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 c80e6a6a Stephen Beaver
 */
28 5ef4a9e1 Darren Embry
29
##|+PRIV
30 9bd56e9d Christian McDonald
##|*IDENT=page-services-router-advertisement
31
##|*NAME=Services: Router Advertisement
32
##|*DESCR=Allow access to the 'Services: Router Advertisement' page.
33
##|*MATCH=services_radvd.php*
34 5ef4a9e1 Darren Embry
##|-PRIV
35
36 9bd56e9d Christian McDonald
require_once('guiconfig.inc');
37 5ef4a9e1 Darren Embry
38 2568e151 Christian McDonald
if (!g_get('services_dhcp_server_enable')) {
39 9bd56e9d Christian McDonald
	header('Location: /');
40 5ef4a9e1 Darren Embry
	exit;
41
}
42
43 13541a81 Steve Beaver
$if = $_REQUEST['if'];
44 5ef4a9e1 Darren Embry
$iflist = get_configured_interface_with_descr();
45
46
/* set the starting interface */
47
if (!$if || !isset($iflist[$if])) {
48
	foreach ($iflist as $ifent => $ifname) {
49 0d121100 jim-p
		$ifaddr = config_get_path("interfaces/{$ifent}/ipaddrv6");
50
		if (!config_path_enabled("dhcpdv6/{$ifent}") &&
51
		    !(($ifaddr == 'track6') ||
52
		    (is_ipaddrv6($ifaddr) &&
53
		    !is_linklocal($ifaddr)))) {
54 5ef4a9e1 Darren Embry
			continue;
55 56463a6c Phil Davis
		}
56 5ef4a9e1 Darren Embry
		$if = $ifent;
57
		break;
58
	}
59
}
60
61 0d121100 jim-p
if (!empty(config_get_path("dhcpdv6/{$if}"))) {
62 5ef4a9e1 Darren Embry
	/* RA specific */
63 829322b3 Christian McDonald
	$pconfig['ramode'] = config_get_path("dhcpdv6/{$if}/ramode");
64
	$pconfig['rapriority'] = config_get_path("dhcpdv6/{$if}/rapriority");
65
	$pconfig['rainterface'] = config_get_path("dhcpdv6/{$if}/rainterface");
66 56463a6c Phil Davis
	if ($pconfig['rapriority'] == "") {
67 5ef4a9e1 Darren Embry
		$pconfig['rapriority'] = "medium";
68 56463a6c Phil Davis
	}
69 352defe4 schinken
70 829322b3 Christian McDonald
	$pconfig['ravalidlifetime'] = config_get_path("dhcpdv6/{$if}/ravalidlifetime");
71
	$pconfig['rapreferredlifetime'] = config_get_path("dhcpdv6/{$if}/rapreferredlifetime");
72
	$pconfig['raminrtradvinterval'] = config_get_path("dhcpdv6/{$if}/raminrtradvinterval");
73
	$pconfig['ramaxrtradvinterval'] = config_get_path("dhcpdv6/{$if}/ramaxrtradvinterval");
74
	$pconfig['raadvdefaultlifetime'] = config_get_path("dhcpdv6/{$if}/raadvdefaultlifetime");
75 352defe4 schinken
76 829322b3 Christian McDonald
	$pconfig['radomainsearchlist'] = config_get_path("dhcpdv6/{$if}/radomainsearchlist");
77
	list($pconfig['radns1'], $pconfig['radns2'], $pconfig['radns3']) = config_get_path("dhcpdv6/{$if}/radnsserver");
78 96270d7c Viktor G
	$pconfig['radvd-dns'] = ($config['dhcpdv6'][$if]['radvd-dns'] != 'disabled') ? true : false;
79 163e4b91 Darren Embry
	$pconfig['rasamednsasdhcp6'] = isset($config['dhcpdv6'][$if]['rasamednsasdhcp6']);
80 8c4ee062 Darren Embry
81 829322b3 Christian McDonald
	$pconfig['subnets'] = config_get_path("dhcpdv6/{$if}/subnets/item");
82 8c4ee062 Darren Embry
}
83 56463a6c Phil Davis
if (!is_array($pconfig['subnets'])) {
84 8c4ee062 Darren Embry
	$pconfig['subnets'] = array();
85 56463a6c Phil Davis
}
86 5ef4a9e1 Darren Embry
87 b50d30c3 Stephen Beaver
$advertise_modes = array(
88
	"disabled" => 	gettext("Disabled"),
89 69bfc8ed doktornotor
	"router" => 	gettext("Router Only - RA Flags [none], Prefix Flags [router]"),
90
	"unmanaged" => 	gettext("Unmanaged - RA Flags [none], Prefix Flags [onlink, auto, router]"),
91
	"managed" => 	gettext("Managed - RA Flags [managed, other stateful], Prefix Flags [onlink, router]"),
92
	"assist" => 	gettext("Assisted - RA Flags [managed, other stateful], Prefix Flags [onlink, auto, router]"),
93
	"stateless_dhcp" => gettext("Stateless DHCP - RA Flags [other stateful], Prefix Flags [onlink, auto, router]"));
94 b50d30c3 Stephen Beaver
$priority_modes = array(
95
	"low" => 	gettext("Low"),
96
	"medium" => gettext("Normal"),
97
	"high" => 	gettext("High"));
98 5ef4a9e1 Darren Embry
99 9bd56e9d Christian McDonald
100 8c4ee062 Darren Embry
101 297190ed Steve Beaver
// THe use of <div class="infoblock"> here causes the text to be hidden until the user clicks the "info" icon
102 e9650eeb Steve Beaver
$ramode_help = gettext('Select the Operating Mode for the Router Advertisement (RA) Daemon.') .
103 297190ed Steve Beaver
	'<div class="infoblock">' .
104 652ce2b5 Steve Beaver
	'<dl class="dl-horizontal responsive">' .
105 e9650eeb Steve Beaver
	'<dt>' . gettext('Disabled') . 		 '</dt><dd>' . gettext('RADVD will not be enabled on this interface.') . '</dd>' .
106
	'<dt>' . gettext('Router Only') . 	 '</dt><dd>' . gettext('Will advertise this router.') . '</dd>' .
107 9bd56e9d Christian McDonald
	'<dt>' . gettext('Unmanaged') . 	 '</dt><dd>' . gettext('Will advertise this router with Stateless Address Auto-Configuration (SLAAC).') . '</dd>' .
108 e9650eeb Steve Beaver
	'<dt>' . gettext('Managed') . 		 '</dt><dd>' . gettext('Will advertise this router with all configuration through a DHCPv6 server.') . '</dd>' .
109 9bd56e9d Christian McDonald
	'<dt>' . gettext('Assisted') . 		 '</dt><dd>' . gettext('Will advertise this router with configuration through a DHCPv6 server and/or SLAAC.') . '</dd>' .
110
	'<dt>' . gettext('Stateless DHCP') . '</dt><dd>' . gettext('Will advertise this router with SLAAC and other configuration information available via DHCPv6.') . '</dd>' .
111 652ce2b5 Steve Beaver
	'</dl>' .
112 573ec19d Renato Botelho do Couto
	sprintf(gettext('It is not required to activate DHCPv6 server on %s ' .
113
	    'when set to "Managed", "Assisted" or "Stateless DHCP", it can ' .
114 2568e151 Christian McDonald
	    'be another host on the network.'), g_get('product_label')) .
115 e9650eeb Steve Beaver
	'</div>';
116 297190ed Steve Beaver
117 13541a81 Steve Beaver
if ($_POST['save']) {
118 5ef4a9e1 Darren Embry
	unset($input_errors);
119
120
	$pconfig = $_POST;
121
122 163e4b91 Darren Embry
	/* input validation */
123 8c4ee062 Darren Embry
124
	$pconfig['subnets'] = array();
125
	for ($x = 0; $x < 5000; $x += 1) {
126
		$address = trim($_POST['subnet_address' . $x]);
127 56463a6c Phil Davis
		if ($address === "") {
128 8c4ee062 Darren Embry
			continue;
129 56463a6c Phil Davis
		}
130 fba196c3 Renato Botelho
131
		$bits = trim($_POST['subnet_bits' . $x]);
132 56463a6c Phil Davis
		if ($bits === "") {
133 fba196c3 Renato Botelho
			$bits = "128";
134 56463a6c Phil Davis
		}
135 fba196c3 Renato Botelho
136
		if (is_alias($address)) {
137 8c4ee062 Darren Embry
			$pconfig['subnets'][] = $address;
138 fba196c3 Renato Botelho
		} else {
139
			$pconfig['subnets'][] = $address . "/" . $bits;
140 56463a6c Phil Davis
			if (!is_ipaddrv6($address)) {
141 702fa4d0 Phil Davis
				$input_errors[] = sprintf(gettext('An invalid subnet or alias was specified. [%1$s/%2$s]'), $address, $bits);
142 56463a6c Phil Davis
			}
143 8c4ee062 Darren Embry
		}
144
	}
145
146 53436df6 Chris Buechler
	if (($_POST['radns1'] && !is_ipaddrv6($_POST['radns1'])) || ($_POST['radns2'] && !is_ipaddrv6($_POST['radns2'])) || ($_POST['radns3'] && !is_ipaddrv6($_POST['radns3']))) {
147 6190312f Phil Davis
		$input_errors[] = gettext("A valid IPv6 address must be specified for each of the DNS servers.");
148 56463a6c Phil Davis
	}
149 163e4b91 Darren Embry
	if ($_POST['radomainsearchlist']) {
150 56463a6c Phil Davis
		$domain_array=preg_split("/[ ;]+/", $_POST['radomainsearchlist']);
151 163e4b91 Darren Embry
		foreach ($domain_array as $curdomain) {
152
			if (!is_domain($curdomain)) {
153
				$input_errors[] = gettext("A valid domain search list must be specified.");
154
				break;
155
			}
156
		}
157
	}
158
159 c3099b79 Chris Buechler
	if ($_POST['ravalidlifetime'] && ($_POST['ravalidlifetime'] < 7200)) {
160
		$input_errors[] = gettext("A valid lifetime below 2 hours will be ignored by clients (RFC 4862 Section 5.5.3 point e)");
161
	}
162
	if ($_POST['ravalidlifetime'] && !is_numericint($_POST['ravalidlifetime'])) {
163
		$input_errors[] = gettext("Valid lifetime must be an integer.");
164
	}
165
	if ($_POST['raminrtradvinterval']) {
166
		if (!is_numericint($_POST['raminrtradvinterval'])) {
167
			$input_errors[] = gettext("Minimum advertisement interval must be an integer.");
168
		}
169 4d7bdf64 Viktor Gurov
		if ($_POST['raminrtradvinterval'] < 3) {
170 c3099b79 Chris Buechler
			$input_errors[] = gettext("Minimum advertisement interval must be no less than 3.");
171
		}
172
		if ($_POST['ramaxrtradvinterval'] && $_POST['raminrtradvinterval'] > (0.75 * $_POST['ramaxrtradvinterval'])) {
173
			$input_errors[] = gettext("Minimum advertisement interval must be no greater than 0.75 * Maximum advertisement interval");
174
		}
175
	}
176
	if ($_POST['ramaxrtradvinterval']) {
177
		if (!is_numericint($_POST['ramaxrtradvinterval'])) {
178
			$input_errors[] = gettext("Maximum advertisement interval must be an integer.");
179
		}
180 4d7bdf64 Viktor Gurov
		if ($_POST['ramaxrtradvinterval'] < 4 || $_POST['ramaxrtradvinterval'] > 1800) {
181 c3099b79 Chris Buechler
			$input_errors[] = gettext("Maximum advertisement interval must be no less than 4 and no greater than 1800.");
182
		}
183 352defe4 schinken
	}
184 7cf69c98 Viktor G
	if ($_POST['rapreferredlifetime']) {
185
		if (!is_numericint($_POST['rapreferredlifetime'])) {
186
			$input_errors[] = gettext("Default preferred lifetime must be an integer.");
187
		}
188
	}
189 4d7bdf64 Viktor Gurov
	if ($_POST['raadvdefaultlifetime'] && (($_POST['raadvdefaultlifetime'] < 1) || ($_POST['raadvdefaultlifetime'] > 9000))) {
190
		$input_errors[] = gettext("Router lifetime must be an integer between 1 and 9000.");
191 d37bd612 Chris Buechler
	}
192 1d0608f3 Viktor G
	if (($_POST['ravalidlifetime'] && $_POST['rapreferredlifetime'] &&
193
	    ($_POST['ravalidlifetime'] < $_POST['rapreferredlifetime'])) ||
194 dd0c42ea Seyfidin Hamraoui
	    ($_POST['ravalidlifetime'] && empty($_POST['rapreferredlifetime']) &&
195 1d0608f3 Viktor G
	    ($_POST['ravalidlifetime'] < 14400)) || (empty($_POST['ravalidlifetime']) &&
196 9bd56e9d Christian McDonald
	    $_POST['rapreferredlifetime'] && ($_POST['rapreferredlifetime'] > 86400))) {
197 1d0608f3 Viktor G
		$input_errors[] = gettext("Default valid lifetime must be greater than Default preferred lifetime.");
198
	}
199 352defe4 schinken
200 5ef4a9e1 Darren Embry
	if (!$input_errors) {
201 8701bad8 Steve Beaver
		if (!is_array($config['dhcpdv6'])) {
202 721fafba Christian McDonald
			config_set_path('dhcpdv6', array());
203 8701bad8 Steve Beaver
		}
204
205 56463a6c Phil Davis
		if (!is_array($config['dhcpdv6'][$if])) {
206 5ef4a9e1 Darren Embry
			$config['dhcpdv6'][$if] = array();
207 56463a6c Phil Davis
		}
208 5ef4a9e1 Darren Embry
209
		$config['dhcpdv6'][$if]['ramode'] = $_POST['ramode'];
210
		$config['dhcpdv6'][$if]['rapriority'] = $_POST['rapriority'];
211 c0509674 Chris Buechler
		$config['dhcpdv6'][$if]['rainterface'] = $_POST['rainterface'];
212 e1968b0d Renato Botelho
213 352defe4 schinken
		$config['dhcpdv6'][$if]['ravalidlifetime'] = $_POST['ravalidlifetime'];
214
		$config['dhcpdv6'][$if]['rapreferredlifetime'] = $_POST['rapreferredlifetime'];
215 c3099b79 Chris Buechler
		$config['dhcpdv6'][$if]['raminrtradvinterval'] = $_POST['raminrtradvinterval'];
216
		$config['dhcpdv6'][$if]['ramaxrtradvinterval'] = $_POST['ramaxrtradvinterval'];
217 d37bd612 Chris Buechler
		$config['dhcpdv6'][$if]['raadvdefaultlifetime'] = $_POST['raadvdefaultlifetime'];
218 352defe4 schinken
219 163e4b91 Darren Embry
		$config['dhcpdv6'][$if]['radomainsearchlist'] = $_POST['radomainsearchlist'];
220 7e3ea4a8 Christian McDonald
		config_del_path("dhcpdv6/{$if}/radnsserver");
221 56463a6c Phil Davis
		if ($_POST['radns1']) {
222 163e4b91 Darren Embry
			$config['dhcpdv6'][$if]['radnsserver'][] = $_POST['radns1'];
223 56463a6c Phil Davis
		}
224
		if ($_POST['radns2']) {
225 163e4b91 Darren Embry
			$config['dhcpdv6'][$if]['radnsserver'][] = $_POST['radns2'];
226 56463a6c Phil Davis
		}
227
		if ($_POST['radns3']) {
228 6190312f Phil Davis
			$config['dhcpdv6'][$if]['radnsserver'][] = $_POST['radns3'];
229 56463a6c Phil Davis
		}
230 163e4b91 Darren Embry
231 c58e56fb luckman212
		$config['dhcpdv6'][$if]['radvd-dns'] = ($_POST['radvd-dns']) ? "enabled" : "disabled";
232 163e4b91 Darren Embry
		$config['dhcpdv6'][$if]['rasamednsasdhcp6'] = ($_POST['rasamednsasdhcp6']) ? true : false;
233
234 8c4ee062 Darren Embry
		if (count($pconfig['subnets'])) {
235
			$config['dhcpdv6'][$if]['subnets']['item'] = $pconfig['subnets'];
236
		} else {
237 7e3ea4a8 Christian McDonald
			config_del_path("dhcpdv6/{$if}/subnets");
238 8c4ee062 Darren Embry
		}
239
240 e85ae672 Renato Botelho do Couto
		write_config("Router Advertisements settings saved");
241 44c42356 Phil Davis
		$changes_applied = true;
242
		$retval = 0;
243
		$retval |= services_radvd_configure();
244 5ef4a9e1 Darren Embry
	}
245
}
246
247 9bd56e9d Christian McDonald
$pgtitle = [gettext('Services'), gettext('Router Advertisement')];
248
$pglinks = [null, 'services_radvd.php'];
249 253fa019 k-paulius
250
if (!empty($if) && isset($iflist[$if])) {
251
	$pgtitle[] = $iflist[$if];
252 9bd56e9d Christian McDonald
	$pglinks[] = 'services_radvd.php?if=' . $if;
253 253fa019 k-paulius
}
254 9bd56e9d Christian McDonald
$shortcut_section = 'radvd';
255 5ef4a9e1 Darren Embry
256 9bd56e9d Christian McDonald
include('head.inc');
257 5ef4a9e1 Darren Embry
258 20db3e1a Phil Davis
if ($input_errors) {
259 c80e6a6a Stephen Beaver
	print_input_errors($input_errors);
260 20db3e1a Phil Davis
}
261 c80e6a6a Stephen Beaver
262 44c42356 Phil Davis
if ($changes_applied) {
263
	print_apply_result_box($retval);
264
}
265
266
if ($info_msg) {
267
	print_info_box($info_msg, 'success');
268 20db3e1a Phil Davis
}
269 c80e6a6a Stephen Beaver
270
/* active tabs */
271
$tab_array = array();
272
$tabscounter = 0;
273
$i = 0;
274
foreach ($iflist as $ifent => $ifname) {
275 829322b3 Christian McDonald
	$oc = config_get_path("interfaces/{$ifent}");
276 c0509674 Chris Buechler
	// We need interfaces configured with a static IPv6 address or track6 for PD.
277 7a9f8774 Chris Buechler
	if (!is_ipaddrv6($oc['ipaddrv6']) && $oc['ipaddrv6'] != "track6") {
278 c80e6a6a Stephen Beaver
		continue;
279
	}
280 8c4ee062 Darren Embry
281 c80e6a6a Stephen Beaver
	if ($ifent == $if) {
282
		$active = true;
283
	} else {
284
		$active = false;
285 8c4ee062 Darren Embry
	}
286
287 9bd56e9d Christian McDonald
	$tab_array[] = array($ifname, $active, 'services_radvd.php?if='.$ifent);
288 c80e6a6a Stephen Beaver
	$tabscounter++;
289
}
290
291
if ($tabscounter == 0) {
292 9bd56e9d Christian McDonald
	print_info_box(gettext('Router Advertisements can only be enabled on interfaces configured with a static IPv6 address. This system has none.'), 'danger', false);
293
	include('foot.inc');
294 c80e6a6a Stephen Beaver
	exit;
295
}
296
297 9bd56e9d Christian McDonald
$valid_ra = in_array(config_get_path('dhcpdv6/'.$if.'/ramode', 'disabled'), ['managed', 'assist', 'stateless_dhcp']);
298
if (config_path_enabled('dhcpdv6/'.$if) && !$valid_ra) {
299
	print_info_box(sprintf(gettext('DHCPv6 is enabled but not being advertised to clients on %1$s. Router Advertisement must be enabled and Router Mode set to "Managed", "Assisted" or "Stateless DHCP."'), $iflist[$if]), 'danger', false);
300
}
301 c80e6a6a Stephen Beaver
302 9bd56e9d Christian McDonald
display_top_tabs($tab_array);
303 c80e6a6a Stephen Beaver
304 8f58b51b jim-p
$form = new Form();
305 c80e6a6a Stephen Beaver
306 9bd56e9d Christian McDonald
$section = new Form_Section(gettext('Router Advertisement'));
307 c80e6a6a Stephen Beaver
308
$section->addInput(new Form_Select(
309
	'ramode',
310 9bd56e9d Christian McDonald
	'*'.gettext('Router Mode'),
311 c80e6a6a Stephen Beaver
	$pconfig['ramode'],
312
	$advertise_modes
313 297190ed Steve Beaver
))->setHelp($ramode_help);
314 c80e6a6a Stephen Beaver
315
$section->addInput(new Form_Select(
316
	'rapriority',
317 9bd56e9d Christian McDonald
	'*'.gettext('Router Priority'),
318 c80e6a6a Stephen Beaver
	$pconfig['rapriority'],
319
	$priority_modes
320 9bd56e9d Christian McDonald
))->setHelp(gettext('Select the Priority for the RA Daemon.'));
321 c80e6a6a Stephen Beaver
322 c0509674 Chris Buechler
$carplist = get_configured_vip_list("inet6", VIP_CARP);
323
324
$carplistif = array();
325
326 9d3e8723 Phil Davis
if (count($carplist) > 0) {
327
	foreach ($carplist as $ifname => $vip) {
328 c0509674 Chris Buechler
		if (get_configured_vip_interface($ifname) == $if) {
329
			$carplistif[$ifname] = $vip;
330
		}
331
	}
332
}
333
334
if (count($carplistif) > 0) {
335
	$iflist = array();
336
337 790e2a2f jim-p
	$iflist['interface'] = convert_friendly_interface_to_friendly_descr($if);
338 9d3e8723 Phil Davis
	foreach ($carplistif as $ifname => $vip) {
339 c0509674 Chris Buechler
		$iflist[$ifname] = get_vip_descr($vip) . " - " . $vip;
340
	}
341
342
	$section->addInput(new Form_Select(
343
		'rainterface',
344 9bd56e9d Christian McDonald
		gettext('RA Interface'),
345 c0509674 Chris Buechler
		$pconfig['rainterface'],
346
		$iflist
347 9bd56e9d Christian McDonald
	))->setHelp(gettext('Select the Interface for the Router Advertisement (RA) Daemon.'));
348 c0509674 Chris Buechler
}
349
350 352defe4 schinken
$section->addInput(new Form_Input(
351
	'ravalidlifetime',
352 9bd56e9d Christian McDonald
	gettext('Valid Lifetime'),
353 c3099b79 Chris Buechler
	'number',
354
	$pconfig['ravalidlifetime'],
355 4d7bdf64 Viktor Gurov
	['min' => 1, 'max' => 655350, 'placeholder' => 86400]
356 9bd56e9d Christian McDonald
))->setHelp(gettext('The length of time in seconds (relative to the time the packet is sent) that the prefix is valid for the purpose of on-link determination.%1$s' .
357
'The default is 86400 seconds.'), '<br />');
358 352defe4 schinken
359
$section->addInput(new Form_Input(
360
	'rapreferredlifetime',
361 9bd56e9d Christian McDonald
	gettext('Preferred Lifetime'),
362 7cf69c98 Viktor G
	'number',
363 4d7bdf64 Viktor Gurov
	$pconfig['rapreferredlifetime'],
364
	['placeholder' => 14400]
365 9bd56e9d Christian McDonald
))->setHelp(gettext('The length of time in seconds (relative to the time the packet is sent) that addresses generated from the prefix via SLAAC remain preferred.%1$s' .
366
			'The default is 14400 seconds.'), '<br />');
367 352defe4 schinken
368 c3099b79 Chris Buechler
$section->addInput(new Form_Input(
369
	'raminrtradvinterval',
370 9bd56e9d Christian McDonald
	gettext('Minimum RA Interval'),
371 c3099b79 Chris Buechler
	'number',
372
	$pconfig['raminrtradvinterval'],
373 762d3cc9 Viktor G
	['min' => 3, 'max' => 1350, 'placeholder' => 200]
374 9bd56e9d Christian McDonald
))->setHelp(gettext('The minimum time allowed between sending unsolicited multicast router advertisements in seconds.%1$s' .
375
'The default is 200 seconds.'), '<br />');
376 c3099b79 Chris Buechler
377
$section->addInput(new Form_Input(
378
	'ramaxrtradvinterval',
379 9bd56e9d Christian McDonald
	gettext('Maximum RA Interval'),
380 c3099b79 Chris Buechler
	'number',
381
	$pconfig['ramaxrtradvinterval'],
382 762d3cc9 Viktor G
	['min' => 4, 'max' => 1800, 'placeholder' => 600]
383 9bd56e9d Christian McDonald
))->setHelp(gettext('The maximum time allowed between sending unsolicited multicast router advertisements in seconds.%1$s' .
384
'The default is 600 seconds.'), '<br />');
385 762d3cc9 Viktor G
386
if (isset($pconfig['raadvdefaultlifetime']) &&
387
    is_numeric($pconfig['raadvdefaultlifetime'])) {
388
	$raadvdefaultlifetime = $pconfig['raadvdefaultlifetime'];
389
} elseif (isset($pconfig['ramaxrtradvinterval']) &&
390
    is_numeric($pconfig['ramaxrtradvinterval'])) {
391
	$raadvdefaultlifetime = $pconfig['ramaxrtradvinterval'] * 3;
392
} else {
393
	$raadvdefaultlifetime = 1800;
394 9bd56e9d Christian McDonald
}
395 c3099b79 Chris Buechler
396 d37bd612 Chris Buechler
$section->addInput(new Form_Input(
397
	'raadvdefaultlifetime',
398 9bd56e9d Christian McDonald
	gettext('Router Lifetime'),
399 d37bd612 Chris Buechler
	'number',
400
	$pconfig['raadvdefaultlifetime'],
401 762d3cc9 Viktor G
	['min' => 1, 'max' => 9000, 'placeholder' => $raadvdefaultlifetime]
402 9bd56e9d Christian McDonald
))->setHelp(gettext('The lifetime associated with the default router in seconds.%1$s' .
403
'The default is 3 * Maximum RA interval seconds.'), '<br />');
404 c3099b79 Chris Buechler
405 c80e6a6a Stephen Beaver
406 20db3e1a Phil Davis
if (empty($pconfig['subnets'])) {
407 c80e6a6a Stephen Beaver
	$pconfig['subnets'] = array('0' => '/128');
408 20db3e1a Phil Davis
}
409 c80e6a6a Stephen Beaver
410
$counter = 0;
411 9bd56e9d Christian McDonald
$last = (count($pconfig['subnets']) - 1);
412 c80e6a6a Stephen Beaver
foreach ($pconfig['subnets'] as $subnet) {
413 9bd56e9d Christian McDonald
	$group = new Form_Group(($counter == 0) ? gettext('RA Subnet(s)') : '');
414
	$group->addClass('repeatable');
415 c80e6a6a Stephen Beaver
416 9bd56e9d Christian McDonald
	[$address, $subnet] = explode('/', $subnet);
417 c80e6a6a Stephen Beaver
	$group->add(new Form_IpAddress(
418 9bd56e9d Christian McDonald
		'subnet_address' . $counter,
419
		gettext('RA Subnet'),
420 45541aae Phil Davis
		$address,
421
		'V6'
422 9bd56e9d Christian McDonald
	))->addClass('autotrim')
423
          ->addMask('subnet_bits' . $counter, $subnet)
424
	  ->setHelp(($counter === $last) ? gettext('Subnets are specified in CIDR format. Select the CIDR mask that pertains to each entry. If no subnets are specified here, the RA Daemon will advertise to the subnet to which the router\'s interface is assigned.') : '');
425 c80e6a6a Stephen Beaver
426
	$group->add(new Form_Button(
427
		'deleterow' . $counter,
428 9bd56e9d Christian McDonald
		gettext('Delete'),
429 cd7ddae6 jim-p
		null,
430
		'fa-trash'
431 9bd56e9d Christian McDonald
	))->addClass('btn-sm btn-warning');
432 c80e6a6a Stephen Beaver
433
	$section->add($group);
434
	$counter++;
435
}
436
437 9bd56e9d Christian McDonald
$group = new Form_Group(null);
438
$input = new Form_Button(
439 c80e6a6a Stephen Beaver
	'addrow',
440 9bd56e9d Christian McDonald
	gettext('Add RA Subnet'),
441 cd7ddae6 jim-p
	null,
442
	'fa-plus'
443 9bd56e9d Christian McDonald
);
444
$input->addClass('btn-success');
445
$group->add($input);
446
447
$section->add($group);
448 c80e6a6a Stephen Beaver
449
$form->add($section);
450
451 9bd56e9d Christian McDonald
$section = new Form_Section(gettext('DNS Configuration'));
452
453
$section->addInput(new Form_Checkbox(
454
	'radvd-dns',
455
	gettext('Enable DNS'),
456
	gettext('Provide DNS Configuration via the RA Daemon'),
457
	$pconfig['radvd-dns']
458
))->setHelp(gettext('Unchecking this box disables the RA Daemon RDNSS/DNSSL options. ' .
459
			'Use with caution, as the resulting behavior may violate some RFCs.'));
460
461
$section->addInput(new Form_Checkbox(
462
	'rasamednsasdhcp6',
463
	gettext('Mirror DHCPv6'),
464
	gettext('Mirror DHCPv6 DNS Configuration'),
465
	$pconfig['rasamednsasdhcp6']
466
))->setHelp(gettext('When checked, the DNS configuration will be copied from the primary DHCPv6 options automatically.'));
467
468
$ifipv6 = get_interface_ipv6($if);
469
470
$dns_arrv6 = [];
471
foreach (config_get_path('system/dnsserver', []) as $dnsserver) {
472
	if (is_ipaddrv6($dnsserver)) {
473
		$dns_arrv6[] = $dnsserver;
474
	}
475
}
476
477
if (config_path_enabled('dnsmasq') ||
478
    config_path_enabled('unbound')) {
479
	$dns_arrv6 = [$ifipv6];
480
}
481
482
if (is_numeric($pool) || ($act === 'newpool')) {
483
	$subnet_dnsservers = config_get_path('dhcpdv6/'.$if.'/dnsserver', []);
484
	if (!empty($subnet_dnsservers)) {
485
		$dns_arrv6 = $subnet_dnsservers;
486
	}
487
}
488 c80e6a6a Stephen Beaver
489 9bd56e9d Christian McDonald
for ($idx = 1; $idx <= 4; $idx++) {
490
	$last = $section->addInput(new Form_IpAddress(
491 c80e6a6a Stephen Beaver
		'radns' . $idx,
492 9bd56e9d Christian McDonald
		gettext('DNS Server') . ' '. $idx,
493 45541aae Phil Davis
		$pconfig['radns' . $idx],
494
		'ALIASV6'
495 9bd56e9d Christian McDonald
	))->addClass('autotrim')
496
	  ->setAttribute('placeholder', $dns_arrv6[$idx - 1] ?? sprintf(gettext('DNS Server %s'), $idx));
497 c80e6a6a Stephen Beaver
}
498 9bd56e9d Christian McDonald
$last->setHelp(gettext('Leave blank to use the IP address of this firewall interface if DNS Resolver or Forwarder is enabled, the servers configured in General settings or those obtained dynamically.'));
499 c80e6a6a Stephen Beaver
500
$section->addInput(new Form_Input(
501
	'radomainsearchlist',
502 9bd56e9d Christian McDonald
	gettext('Domain Search List'),
503 c80e6a6a Stephen Beaver
	'text',
504
	$pconfig['radomainsearchlist']
505 9bd56e9d Christian McDonald
))->addClass('autotrim')
506
  ->setAttribute('placeholder', 'example.com;sub.example.com')
507
  ->setHelp(gettext('The RA Daemon can optionally provide a domain search list. Use the semicolon character as separator.'));
508 c80e6a6a Stephen Beaver
509 ee12dd78 Peter Feichtinger
$form->addGlobal(new Form_Input(
510 c80e6a6a Stephen Beaver
	'if',
511
	null,
512
	'hidden',
513
	$if
514
));
515
516
517
$form->add($section);
518
print($form);
519 f3475477 Darren Embry
?>
520 c80e6a6a Stephen Beaver
521 8fd9052f Colin Fleming
<script type="text/javascript">
522 c80e6a6a Stephen Beaver
//<![CDATA[
523 20db3e1a Phil Davis
events.push(function() {
524 0bc61baa Stephen Beaver
	// Suppress "Delete row" button if there are fewer than two rows
525
	checkLastRow();
526 c80e6a6a Stephen Beaver
527 36c9e5fc Stephen Beaver
	// --------- Autocomplete -----------------------------------------------------------------------------------------
528 309ff2c7 Renato Botelho do Couto
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "urltable"))) ?>;
529 36c9e5fc Stephen Beaver
530 9bd56e9d Christian McDonald
	$('#radns1, #radns2, #radns3, #radns4').autocomplete({
531 36c9e5fc Stephen Beaver
		source: addressarray
532
	});
533
534 c80e6a6a Stephen Beaver
});
535 8c4ee062 Darren Embry
//]]>
536 4e0fc44f Darren Embry
</script>
537 8c4ee062 Darren Embry
538 9bd56e9d Christian McDonald
<?php
539
include("foot.inc");