Project

General

Profile

Download (31.3 KB) Statistics
| Branch: | Tag: | Revision:
1 99caa67c Seth Mos
<?php
2
/*
3
	services_dhcpv6.php
4
*/
5 df6cb8fe Stephen Beaver
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *	Copyright (c)  2010 Seth Mos <seth.mos@dds.nl>
8
 *
9 cb41dd63 Renato Botelho
 *	Some or all of this file is based on the m0n0wall project which is
10
 *	Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
11 191cb31d Stephen Beaver
 *
12 df6cb8fe Stephen Beaver
 *	Redistribution and use in source and binary forms, with or without modification,
13
 *	are permitted provided that the following conditions are met:
14
 *
15
 *	1. Redistributions of source code must retain the above copyright notice,
16
 *		this list of conditions and the following disclaimer.
17
 *
18
 *	2. Redistributions in binary form must reproduce the above copyright
19
 *		notice, this list of conditions and the following disclaimer in
20
 *		the documentation and/or other materials provided with the
21
 *		distribution.
22
 *
23
 *	3. All advertising materials mentioning features or use of this software
24
 *		must display the following acknowledgment:
25
 *		"This product includes software developed by the pfSense Project
26
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
27
 *
28
 *	4. The names "pfSense" and "pfSense Project" must not be used to
29
 *		 endorse or promote products derived from this software without
30
 *		 prior written permission. For written permission, please contact
31
 *		 coreteam@pfsense.org.
32
 *
33
 *	5. Products derived from this software may not be called "pfSense"
34
 *		nor may "pfSense" appear in their names without prior written
35
 *		permission of the Electric Sheep Fencing, LLC.
36
 *
37
 *	6. Redistributions of any form whatsoever must retain the following
38
 *		acknowledgment:
39
 *
40
 *	"This product includes software developed by the pfSense Project
41
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
42
 *
43
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
44
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
47
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
55
 *
56
 *	====================================================================
57
 *
58
 */
59 99caa67c Seth Mos
/*
60
	pfSense_BUILDER_BINARIES:	/bin/rm
61 cd2c7940 sbeaver
	pfSense_MODULE: interfaces
62 99caa67c Seth Mos
*/
63
64
##|+PRIV
65
##|*IDENT=page-services-dhcpv6server
66
##|*NAME=Services: DHCPv6 server page
67
##|*DESCR=Allow access to the 'Services: DHCPv6 server' page.
68
##|*MATCH=services_dhcpv6.php*
69
##|-PRIV
70
71
require("guiconfig.inc");
72 472ad9a0 Renato Botelho
require_once("filter.inc");
73 99caa67c Seth Mos
74 8f8682f7 Phil Davis
if (!$g['services_dhcp_server_enable']) {
75 6f3d2063 Renato Botelho
	header("Location: /");
76 99caa67c Seth Mos
	exit;
77
}
78
79 cd2c7940 sbeaver
/*	Fix failover DHCP problem
80
 *	http://article.gmane.org/gmane.comp.security.firewalls.pfsense.support/18749
81 99caa67c Seth Mos
 */
82 8f8682f7 Phil Davis
ini_set("memory_limit", "64M");
83 99caa67c Seth Mos
84
$if = $_GET['if'];
85 8f8682f7 Phil Davis
if ($_POST['if']) {
86 99caa67c Seth Mos
	$if = $_POST['if'];
87 8f8682f7 Phil Davis
}
88 99caa67c Seth Mos
89
/* if OLSRD is enabled, allow WAN to house DHCP. */
90 8f8682f7 Phil Davis
if ($config['installedpackages']['olsrd']) {
91
	foreach ($config['installedpackages']['olsrd']['config'] as $olsrd) {
92
		if ($olsrd['enable']) {
93 cd2c7940 sbeaver
			$is_olsr_enabled = true;
94
			break;
95
		}
96 99caa67c Seth Mos
	}
97
}
98
99
$iflist = get_configured_interface_with_descr();
100 16d9ad13 smos
$iflist = array_merge($iflist, get_configured_pppoe_server_interfaces());
101 99caa67c Seth Mos
102
/* set the starting interface */
103
if (!$if || !isset($iflist[$if])) {
104
	foreach ($iflist as $ifent => $ifname) {
105
		$oc = $config['interfaces'][$ifent];
106 c80e6a6a Stephen Beaver
107 db7a628c Renato Botelho
		if ((is_array($config['dhcpdv6'][$ifent]) && !isset($config['dhcpdv6'][$ifent]['enable']) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6'])))) ||
108 c80e6a6a Stephen Beaver
			(!is_array($config['dhcpdv6'][$ifent]) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6']))))) {
109 99caa67c Seth Mos
			continue;
110 8f8682f7 Phil Davis
		}
111 99caa67c Seth Mos
		$if = $ifent;
112
		break;
113
	}
114
}
115
116 8f8682f7 Phil Davis
if (is_array($config['dhcpdv6'][$if])) {
117 fe838158 smos
	/* DHCPv6 */
118 99caa67c Seth Mos
	if (is_array($config['dhcpdv6'][$if]['range'])) {
119
		$pconfig['range_from'] = $config['dhcpdv6'][$if]['range']['from'];
120
		$pconfig['range_to'] = $config['dhcpdv6'][$if]['range']['to'];
121
	}
122 bfb3e717 Seth Mos
	if (is_array($config['dhcpdv6'][$if]['prefixrange'])) {
123
		$pconfig['prefixrange_from'] = $config['dhcpdv6'][$if]['prefixrange']['from'];
124
		$pconfig['prefixrange_to'] = $config['dhcpdv6'][$if]['prefixrange']['to'];
125
		$pconfig['prefixrange_length'] = $config['dhcpdv6'][$if]['prefixrange']['prefixlength'];
126
	}
127 99caa67c Seth Mos
	$pconfig['deftime'] = $config['dhcpdv6'][$if]['defaultleasetime'];
128
	$pconfig['maxtime'] = $config['dhcpdv6'][$if]['maxleasetime'];
129
	$pconfig['domain'] = $config['dhcpdv6'][$if]['domain'];
130
	$pconfig['domainsearchlist'] = $config['dhcpdv6'][$if]['domainsearchlist'];
131 8f8682f7 Phil Davis
	list($pconfig['wins1'], $pconfig['wins2']) = $config['dhcpdv6'][$if]['winsserver'];
132
	list($pconfig['dns1'], $pconfig['dns2'], $pconfig['dns3'], $pconfig['dns4']) = $config['dhcpdv6'][$if]['dnsserver'];
133 99caa67c Seth Mos
	$pconfig['enable'] = isset($config['dhcpdv6'][$if]['enable']);
134
	$pconfig['ddnsdomain'] = $config['dhcpdv6'][$if]['ddnsdomain'];
135 87019fc4 Andres Petralli
	$pconfig['ddnsdomainprimary'] = $config['dhcpdv6'][$if]['ddnsdomainprimary'];
136
	$pconfig['ddnsdomainkeyname'] = $config['dhcpdv6'][$if]['ddnsdomainkeyname'];
137
	$pconfig['ddnsdomainkey'] = $config['dhcpdv6'][$if]['ddnsdomainkey'];
138 99caa67c Seth Mos
	$pconfig['ddnsupdate'] = isset($config['dhcpdv6'][$if]['ddnsupdate']);
139 8f8682f7 Phil Davis
	list($pconfig['ntp1'], $pconfig['ntp2']) = $config['dhcpdv6'][$if]['ntpserver'];
140 99caa67c Seth Mos
	$pconfig['tftp'] = $config['dhcpdv6'][$if]['tftp'];
141
	$pconfig['ldap'] = $config['dhcpdv6'][$if]['ldap'];
142
	$pconfig['netboot'] = isset($config['dhcpdv6'][$if]['netboot']);
143 bd942860 Renato Botelho
	$pconfig['bootfile_url'] = $config['dhcpdv6'][$if]['bootfile_url'];
144 99caa67c Seth Mos
	$pconfig['netmask'] = $config['dhcpdv6'][$if]['netmask'];
145
	$pconfig['numberoptions'] = $config['dhcpdv6'][$if]['numberoptions'];
146 138208bf Joecowboy
	$pconfig['dhcpv6leaseinlocaltime'] = $config['dhcpdv6'][$if]['dhcpv6leaseinlocaltime'];
147 8f8682f7 Phil Davis
	if (!is_array($config['dhcpdv6'][$if]['staticmap'])) {
148 99caa67c Seth Mos
		$config['dhcpdv6'][$if]['staticmap'] = array();
149 8f8682f7 Phil Davis
	}
150 99caa67c Seth Mos
	$a_maps = &$config['dhcpdv6'][$if]['staticmap'];
151
}
152
153
$ifcfgip = get_interface_ipv6($if);
154
$ifcfgsn = get_interface_subnetv6($if);
155
156 cd2c7940 sbeaver
/*	 set the enabled flag which will tell us if DHCP relay is enabled
157
 *	 on any interface. We will use this to disable DHCP server since
158
 *	 the two are not compatible with each other.
159 99caa67c Seth Mos
 */
160
161
$dhcrelay_enabled = false;
162 80c88a68 smos
$dhcrelaycfg = $config['dhcrelay6'];
163 99caa67c Seth Mos
164 8f8682f7 Phil Davis
if (is_array($dhcrelaycfg)) {
165 99caa67c Seth Mos
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
166
		if (isset($dhcrelayifconf['enable']) && isset($iflist[$dhcrelayif]) &&
167 c80e6a6a Stephen Beaver
			(!link_interface_to_bridge($dhcrelayif))) {
168 99caa67c Seth Mos
			$dhcrelay_enabled = true;
169 8f8682f7 Phil Davis
		}
170 99caa67c Seth Mos
	}
171
}
172
173
if ($_POST) {
174
	unset($input_errors);
175
176 472ad9a0 Renato Botelho
	$old_dhcpdv6_enable = ($pconfig['enable'] == true);
177
	$new_dhcpdv6_enable = ($_POST['enable'] ? true : false);
178
	$dhcpdv6_enable_changed = ($old_dhcpdv6_enable != $new_dhcpdv6_enable);
179
180 99caa67c Seth Mos
	$pconfig = $_POST;
181
182
	$numberoptions = array();
183 6c07db48 Phil Davis
	for ($x = 0; $x < 99; $x++) {
184 8f8682f7 Phil Davis
		if (isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
185 99caa67c Seth Mos
			$numbervalue = array();
186
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
187
			$numbervalue['value'] = htmlspecialchars($_POST["value{$x}"]);
188
			$numberoptions['item'][] = $numbervalue;
189
		}
190
	}
191
	// Reload the new pconfig variable that the forum uses.
192
	$pconfig['numberoptions'] = $numberoptions;
193
194
	/* input validation */
195
	if ($_POST['enable']) {
196
		$reqdfields = explode(" ", "range_from range_to");
197 8f8682f7 Phil Davis
		$reqdfieldsn = array(gettext("Range begin"), gettext("Range end"));
198 99caa67c Seth Mos
199 1e9b4611 Renato Botelho
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
200 99caa67c Seth Mos
201 8f8682f7 Phil Davis
		if (($_POST['prefixrange_from'] && !is_ipaddrv6($_POST['prefixrange_from']))) {
202 bfb3e717 Seth Mos
			$input_errors[] = gettext("A valid range must be specified.");
203 8f8682f7 Phil Davis
		}
204
		if (($_POST['prefixrange_to'] && !is_ipaddrv6($_POST['prefixrange_to']))) {
205 bfb3e717 Seth Mos
			$input_errors[] = gettext("A valid prefix range must be specified.");
206 8f8682f7 Phil Davis
		}
207
		if (($_POST['range_from'] && !is_ipaddrv6($_POST['range_from']))) {
208 99caa67c Seth Mos
			$input_errors[] = gettext("A valid range must be specified.");
209 8f8682f7 Phil Davis
		}
210
		if (($_POST['range_to'] && !is_ipaddrv6($_POST['range_to']))) {
211 99caa67c Seth Mos
			$input_errors[] = gettext("A valid range must be specified.");
212 8f8682f7 Phil Davis
		}
213
		if (($_POST['gateway'] && !is_ipaddrv6($_POST['gateway']))) {
214 99caa67c Seth Mos
			$input_errors[] = gettext("A valid IPv6 address must be specified for the gateway.");
215 8f8682f7 Phil Davis
		}
216
		if (($_POST['dns1'] && !is_ipaddrv6($_POST['dns1'])) ||
217 c80e6a6a Stephen Beaver
			($_POST['dns2'] && !is_ipaddrv6($_POST['dns2'])) ||
218
			($_POST['dns3'] && !is_ipaddrv6($_POST['dns3'])) ||
219
			($_POST['dns4'] && !is_ipaddrv6($_POST['dns4']))) {
220 3d88ea11 Phil Davis
			$input_errors[] = gettext("A valid IPv6 address must be specified for each of the DNS servers.");
221 8f8682f7 Phil Davis
		}
222 99caa67c Seth Mos
223 8f8682f7 Phil Davis
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60))) {
224 99caa67c Seth Mos
			$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
225 8f8682f7 Phil Davis
		}
226
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime']))) {
227 99caa67c Seth Mos
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
228 8f8682f7 Phil Davis
		}
229
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) {
230 99caa67c Seth Mos
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
231 8f8682f7 Phil Davis
		}
232
		if (($_POST['ddnsdomain'] && !is_ipaddrv4($_POST['ddnsdomainprimary']))) {
233 87019fc4 Andres Petralli
			$input_errors[] = gettext("A valid primary domain name server IPv4 address must be specified for the dynamic domain name.");
234 8f8682f7 Phil Davis
		}
235 87019fc4 Andres Petralli
		if (($_POST['ddnsdomainkey'] && !$_POST['ddnsdomainkeyname']) ||
236 c80e6a6a Stephen Beaver
			($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey'])) {
237 87019fc4 Andres Petralli
			$input_errors[] = gettext("You must specify both a valid domain key and key name.");
238 8f8682f7 Phil Davis
		}
239 a3de8b9e Pierre POMES
		if ($_POST['domainsearchlist']) {
240 8f8682f7 Phil Davis
			$domain_array=preg_split("/[ ;]+/", $_POST['domainsearchlist']);
241 a3de8b9e Pierre POMES
			foreach ($domain_array as $curdomain) {
242
				if (!is_domain($curdomain)) {
243
					$input_errors[] = gettext("A valid domain search list must be specified.");
244
					break;
245
				}
246
			}
247
		}
248
249 8f8682f7 Phil Davis
		if (($_POST['ntp1'] && !is_ipaddrv6($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv6($_POST['ntp2']))) {
250 99caa67c Seth Mos
			$input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary NTP servers.");
251 8f8682f7 Phil Davis
		}
252
		if (($_POST['domain'] && !is_domain($_POST['domain']))) {
253 99caa67c Seth Mos
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
254 8f8682f7 Phil Davis
		}
255
		if ($_POST['tftp'] && !is_ipaddr($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp'])) {
256 99caa67c Seth Mos
			$input_errors[] = gettext("A valid IPv6 address or hostname must be specified for the TFTP server.");
257 8f8682f7 Phil Davis
		}
258
		if (($_POST['bootfile_url'] && !is_URL($_POST['bootfile_url']))) {
259 bd942860 Renato Botelho
			$input_errors[] = gettext("A valid URL must be specified for the network bootfile.");
260 8f8682f7 Phil Davis
		}
261 99caa67c Seth Mos
262
		// Disallow a range that includes the virtualip
263
		if (is_array($config['virtualip']['vip'])) {
264 8f8682f7 Phil Davis
			foreach ($config['virtualip']['vip'] as $vip) {
265
				if ($vip['interface'] == $if) {
266
					if ($vip['subnetv6'] && is_inrange_v6($vip['subnetv6'], $_POST['range_from'], $_POST['range_to'])) {
267
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IPv6 address %s."), $vip['subnetv6']);
268
					}
269
				}
270 99caa67c Seth Mos
			}
271
		}
272
273
		$noip = false;
274 8f8682f7 Phil Davis
		if (is_array($a_maps)) {
275 cd2c7940 sbeaver
			foreach ($a_maps as $map) {
276 8f8682f7 Phil Davis
				if (empty($map['ipaddrv6'])) {
277 99caa67c Seth Mos
					$noip = true;
278 8f8682f7 Phil Davis
				}
279 cd2c7940 sbeaver
			}
280
		}
281 99caa67c Seth Mos
		if (!$input_errors) {
282
			/* make sure the range lies within the current subnet */
283
			$subnet_start = gen_subnetv6($ifcfgip, $ifcfgsn);
284
			$subnet_end = gen_subnetv6_max($ifcfgip, $ifcfgsn);
285
286 16d9ad13 smos
			if (is_ipaddrv6($ifcfgip)) {
287 8f8682f7 Phil Davis
				if ((!is_inrange_v6($_POST['range_from'], $subnet_start, $subnet_end)) ||
288 c80e6a6a Stephen Beaver
					(!is_inrange_v6($_POST['range_to'], $subnet_start, $subnet_end))) {
289 16d9ad13 smos
					$input_errors[] = gettext("The specified range lies outside of the current subnet.");
290
				}
291 99caa67c Seth Mos
			}
292 731de711 Pierre POMES
			/* "from" cannot be higher than "to" */
293 8f8682f7 Phil Davis
			if (inet_pton($_POST['range_from']) > inet_pton($_POST['range_to'])) {
294 99caa67c Seth Mos
				$input_errors[] = gettext("The range is invalid (first element higher than second element).");
295 8f8682f7 Phil Davis
			}
296 99caa67c Seth Mos
297
			/* make sure that the DHCP Relay isn't enabled on this interface */
298 8f8682f7 Phil Davis
			if (isset($config['dhcrelay'][$if]['enable'])) {
299
				$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."), $iflist[$if]);
300
			}
301 99caa67c Seth Mos
302 731de711 Pierre POMES
303
			/* Verify static mappings do not overlap:
304
			   - available DHCP range
305
			   - prefix delegation range (FIXME: still need to be completed) */
306
			$dynsubnet_start = inet_pton($_POST['range_from']);
307
			$dynsubnet_end = inet_pton($_POST['range_to']);
308
309 8f8682f7 Phil Davis
			if (is_array($a_maps)) {
310 99caa67c Seth Mos
				foreach ($a_maps as $map) {
311 8f8682f7 Phil Davis
					if (empty($map['ipaddrv6'])) {
312 99caa67c Seth Mos
						continue;
313 8f8682f7 Phil Davis
					}
314 731de711 Pierre POMES
					if ((inet_pton($map['ipaddrv6']) > $dynsubnet_start) &&
315 c80e6a6a Stephen Beaver
						(inet_pton($map['ipaddrv6']) < $dynsubnet_end)) {
316 99caa67c Seth Mos
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
317
						break;
318
					}
319
				}
320
			}
321
		}
322
	}
323
324
	if (!$input_errors) {
325 8f8682f7 Phil Davis
		if (!is_array($config['dhcpdv6'][$if])) {
326 99caa67c Seth Mos
			$config['dhcpdv6'][$if] = array();
327 8f8682f7 Phil Davis
		}
328
		if (!is_array($config['dhcpdv6'][$if]['range'])) {
329 99caa67c Seth Mos
			$config['dhcpdv6'][$if]['range'] = array();
330 8f8682f7 Phil Davis
		}
331
		if (!is_array($config['dhcpdv6'][$if]['prefixrange'])) {
332 bfb3e717 Seth Mos
			$config['dhcpdv6'][$if]['prefixrange'] = array();
333 8f8682f7 Phil Davis
		}
334 99caa67c Seth Mos
335
		$config['dhcpdv6'][$if]['range']['from'] = $_POST['range_from'];
336
		$config['dhcpdv6'][$if]['range']['to'] = $_POST['range_to'];
337 bfb3e717 Seth Mos
		$config['dhcpdv6'][$if]['prefixrange']['from'] = $_POST['prefixrange_from'];
338
		$config['dhcpdv6'][$if]['prefixrange']['to'] = $_POST['prefixrange_to'];
339
		$config['dhcpdv6'][$if]['prefixrange']['prefixlength'] = $_POST['prefixrange_length'];
340 99caa67c Seth Mos
		$config['dhcpdv6'][$if]['defaultleasetime'] = $_POST['deftime'];
341
		$config['dhcpdv6'][$if]['maxleasetime'] = $_POST['maxtime'];
342
		$config['dhcpdv6'][$if]['netmask'] = $_POST['netmask'];
343
344
		unset($config['dhcpdv6'][$if]['winsserver']);
345
346
		unset($config['dhcpdv6'][$if]['dnsserver']);
347 8f8682f7 Phil Davis
		if ($_POST['dns1']) {
348 99caa67c Seth Mos
			$config['dhcpdv6'][$if]['dnsserver'][] = $_POST['dns1'];
349 8f8682f7 Phil Davis
		}
350
		if ($_POST['dns2']) {
351 99caa67c Seth Mos
			$config['dhcpdv6'][$if]['dnsserver'][] = $_POST['dns2'];
352 8f8682f7 Phil Davis
		}
353
		if ($_POST['dns3']) {
354 3d88ea11 Phil Davis
			$config['dhcpdv6'][$if]['dnsserver'][] = $_POST['dns3'];
355 8f8682f7 Phil Davis
		}
356
		if ($_POST['dns4']) {
357 3d88ea11 Phil Davis
			$config['dhcpdv6'][$if]['dnsserver'][] = $_POST['dns4'];
358 8f8682f7 Phil Davis
		}
359 99caa67c Seth Mos
360
		$config['dhcpdv6'][$if]['domain'] = $_POST['domain'];
361
		$config['dhcpdv6'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
362
		$config['dhcpdv6'][$if]['enable'] = ($_POST['enable']) ? true : false;
363
		$config['dhcpdv6'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
364 87019fc4 Andres Petralli
		$config['dhcpdv6'][$if]['ddnsdomainprimary'] = $_POST['ddnsdomainprimary'];
365
		$config['dhcpdv6'][$if]['ddnsdomainkeyname'] = $_POST['ddnsdomainkeyname'];
366
		$config['dhcpdv6'][$if]['ddnsdomainkey'] = $_POST['ddnsdomainkey'];
367 99caa67c Seth Mos
		$config['dhcpdv6'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
368
369
		unset($config['dhcpdv6'][$if]['ntpserver']);
370 8f8682f7 Phil Davis
		if ($_POST['ntp1']) {
371 99caa67c Seth Mos
			$config['dhcpdv6'][$if]['ntpserver'][] = $_POST['ntp1'];
372 8f8682f7 Phil Davis
		}
373
		if ($_POST['ntp2']) {
374 99caa67c Seth Mos
			$config['dhcpdv6'][$if]['ntpserver'][] = $_POST['ntp2'];
375 8f8682f7 Phil Davis
		}
376 99caa67c Seth Mos
377
		$config['dhcpdv6'][$if]['tftp'] = $_POST['tftp'];
378
		$config['dhcpdv6'][$if]['ldap'] = $_POST['ldap'];
379
		$config['dhcpdv6'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
380 bd942860 Renato Botelho
		$config['dhcpdv6'][$if]['bootfile_url'] = $_POST['bootfile_url'];
381 138208bf Joecowboy
		$config['dhcpdv6'][$if]['dhcpv6leaseinlocaltime'] = $_POST['dhcpv6leaseinlocaltime'];
382 99caa67c Seth Mos
383
		// Handle the custom options rowhelper
384 8f8682f7 Phil Davis
		if (isset($config['dhcpdv6'][$if]['numberoptions']['item'])) {
385 99caa67c Seth Mos
			unset($config['dhcpdv6'][$if]['numberoptions']['item']);
386 8f8682f7 Phil Davis
		}
387 99caa67c Seth Mos
388
		$config['dhcpdv6'][$if]['numberoptions'] = $numberoptions;
389
390
		write_config();
391
392
		$retval = 0;
393
		$retvaldhcp = 0;
394
		$retvaldns = 0;
395
		/* Stop DHCPv6 so we can cleanup leases */
396 e074fb75 Renato Botelho
		killbypid("{$g['dhcpd_chroot_path']}{$g['varrun_path']}/dhcpdv6.pid");
397 2fb056d8 Seth Mos
		// dhcp_clean_leases();
398 99caa67c Seth Mos
		/* dnsmasq_configure calls dhcpd_configure */
399
		/* no need to restart dhcpd twice */
400 ea1aca13 Renato Botelho
		if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))	{
401 99caa67c Seth Mos
			$retvaldns = services_dnsmasq_configure();
402
			if ($retvaldns == 0) {
403
				clear_subsystem_dirty('hosts');
404
				clear_subsystem_dirty('staticmaps');
405
			}
406 d939c1d4 Warren Baker
		} else if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
407
			$retvaldns = services_unbound_configure();
408 6877666e Robert Nelson
			if ($retvaldns == 0) {
409 d939c1d4 Warren Baker
				clear_subsystem_dirty('unbound');
410 6877666e Robert Nelson
				clear_subsystem_dirty('staticmaps');
411
			}
412 99caa67c Seth Mos
		} else {
413
			$retvaldhcp = services_dhcpd_configure();
414 8f8682f7 Phil Davis
			if ($retvaldhcp == 0) {
415 99caa67c Seth Mos
				clear_subsystem_dirty('staticmaps');
416 8f8682f7 Phil Davis
			}
417 99caa67c Seth Mos
		}
418 8f8682f7 Phil Davis
		if ($dhcpdv6_enable_changed) {
419 472ad9a0 Renato Botelho
			$retvalfc = filter_configure();
420 8f8682f7 Phil Davis
		}
421
		if ($retvaldhcp == 1 || $retvaldns == 1 || $retvalfc == 1) {
422 99caa67c Seth Mos
			$retval = 1;
423 8f8682f7 Phil Davis
		}
424 99caa67c Seth Mos
		$savemsg = get_std_save_message($retval);
425
	}
426
}
427
428
if ($_GET['act'] == "del") {
429
	if ($a_maps[$_GET['id']]) {
430
		unset($a_maps[$_GET['id']]);
431
		write_config();
432 8f8682f7 Phil Davis
		if (isset($config['dhcpdv6'][$if]['enable'])) {
433 99caa67c Seth Mos
			mark_subsystem_dirty('staticmapsv6');
434 8f8682f7 Phil Davis
			if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstaticv6'])) {
435 99caa67c Seth Mos
				mark_subsystem_dirty('hosts');
436 8f8682f7 Phil Davis
			}
437 99caa67c Seth Mos
		}
438
		header("Location: services_dhcpv6.php?if={$if}");
439
		exit;
440
	}
441
}
442
443 cd2c7940 sbeaver
// Delete a row in the options table
444
if($_GET['act'] == "delopt") {
445
	$idx = $_GET['id'];
446
447
	if($pconfig['numberoptions'] && is_array($pconfig['numberoptions']['item'][$idx])) {
448
	   unset($pconfig['numberoptions']['item'][$idx]);
449
	}
450
}
451
452
// Add an option row
453
if($_GET['act'] == "addopt") {
454 18231f7b sbeaver
	if(!is_array($pconfig['numberoptions']['item']))
455
		$pconfig['numberoptions']['item'] = array();
456 ea6649f7 sbeaver
457 cd2c7940 sbeaver
	array_push($pconfig['numberoptions']['item'], array('number' => null, 'value' => null));
458
}
459
460 ee9530e1 Colin Fleming
$closehead = false;
461 e32f02a5 Phil Davis
$pgtitle = array(gettext("Services"), gettext("DHCPv6 Server"));
462 b32dd0a6 jim-p
$shortcut_section = "dhcp6";
463 99caa67c Seth Mos
464
include("head.inc");
465
466 cd2c7940 sbeaver
if ($input_errors)
467
	print_input_errors($input_errors);
468 99caa67c Seth Mos
469 cd2c7940 sbeaver
if ($savemsg)
470
	print_info_box($savemsg, 'success');
471 99caa67c Seth Mos
472 cd2c7940 sbeaver
if ($dhcrelay_enabled) {
473
	print_info_box(gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface."), 'danger');
474
	include("foot.inc");
475
	exit;
476
}
477 99caa67c Seth Mos
478 cd2c7940 sbeaver
if (is_subsystem_dirty('staticmaps'))
479
	print_info_box_np(gettext('The static mapping configuration has been changed') . '.<br />' . gettext('You must apply the changes in order for them to take effect.'));
480 99caa67c Seth Mos
481 cd2c7940 sbeaver
/* active tabs */
482
$tab_array = array();
483
$tabscounter = 0;
484
$i = 0;
485 c80e6a6a Stephen Beaver
486 cd2c7940 sbeaver
foreach ($iflist as $ifent => $ifname) {
487
	$oc = $config['interfaces'][$ifent];
488 c80e6a6a Stephen Beaver
489
490
	if((is_array($config['dhcpdv6'][$ifent]) && !isset($config['dhcpdv6'][$ifent]['enable']) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6'])))) ||
491 cd2c7940 sbeaver
		(!is_array($config['dhcpdv6'][$ifent]) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6'])))))
492
		continue;
493
494
	if ($ifent == $if)
495
		$active = true;
496
	else
497
		$active = false;
498
499
	$tab_array[] = array($ifname, $active, "services_dhcpv6.php?if={$ifent}");
500
	$tabscounter++;
501
}
502 c80e6a6a Stephen Beaver
503 cd2c7940 sbeaver
/* tack on PPPoE or PPtP servers here */
504
/* pppoe server */
505
if (is_array($config['pppoes']['pppoe'])) {
506
	foreach($config['pppoes']['pppoe'] as $pppoe) {
507
		if ($pppoe['mode'] == "server") {
508
			$ifent = "poes". $pppoe['pppoeid'];
509
			$ifname = strtoupper($ifent);
510
511
			if ($ifent == $if)
512
				$active = true;
513
			else
514
				$active = false;
515
516
			$tab_array[] = array($ifname, $active, "services_dhcpv6.php?if={$ifent}");
517
			$tabscounter++;
518
		}
519 99caa67c Seth Mos
	}
520 cd2c7940 sbeaver
}
521 99caa67c Seth Mos
522 c80e6a6a Stephen Beaver
if ($tabscounter == 0) {
523 cd2c7940 sbeaver
	print_info_box(gettext("The DHCPv6 Server can only be enabled on interfaces configured with a static IPv6 address. This system has none."), 'danger');
524
	include("foot.inc");
525
	exit;
526
}
527 99caa67c Seth Mos
528 9b54ac32 Stephen Beaver
display_top_tabs($tab_array);
529
530 cd2c7940 sbeaver
$tab_array = array();
531
$tab_array[] = array(gettext("DHCPv6 Server"),		 true,	"services_dhcpv6.php?if={$if}");
532
$tab_array[] = array(gettext("Router Advertisements"), false, "services_router_advertisements.php?if={$if}");
533 9b54ac32 Stephen Beaver
display_top_tabs($tab_array, false, 'nav nav-tabs' );
534 99caa67c Seth Mos
535 ad2879b8 PiBa-NL
require_once('classes/Form.class.php');
536 cd2c7940 sbeaver
537
$form = new Form(new Form_Button(
538
	'Submit',
539 ea6649f7 sbeaver
	'Save'
540 cd2c7940 sbeaver
));
541
542
$section = new Form_Section('DHCPv6 Options');
543
544
$section->addInput(new Form_Checkbox(
545
	'enable',
546
	'DHCPv6 Server',
547 ea6649f7 sbeaver
	'Enable DHCPv6 server on interface ' . $iflist[$if],
548 cd2c7940 sbeaver
	$pconfig['enable']
549 546d4b34 sbeaver
))->toggles('.form-group:not(:first-child)');
550 cd2c7940 sbeaver
551
if(is_ipaddrv6($ifcfgip)) {
552
553
	$section->addInput(new Form_StaticText(
554
		'Subnet',
555
		gen_subnetv6($ifcfgip, $ifcfgsn)
556
		));
557
558
	$section->addInput(new Form_StaticText(
559
		'Subnet Mask',
560
		$ifcfgsn . ' bits'
561
		));
562
563
	$section->addInput(new Form_StaticText(
564
		'Available Range',
565
		$range_from = gen_subnetv6($ifcfgip, $ifcfgsn) . ' to ' . gen_subnetv6_max($ifcfgip, $ifcfgsn)
566
		));
567
}
568
569
if($is_olsr_enabled) {
570
	$section->addInput(new Form_Select(
571
	'netmask',
572 e32f02a5 Phil Davis
	'Subnet Mask',
573 cd2c7940 sbeaver
	$pconfig['netmask'],
574
	array_combine(range(128, 1, -1), range(128, 1, -1))
575
	));
576
}
577
578
$f1 = new Form_Input(
579
	'range_from',
580
	null,
581
	'text',
582
	$pconfig['range_from']
583
);
584
585
$f1->setHelp('To');
586
587
$f2 = new Form_Input(
588
	'range_to',
589
	null,
590
	'text',
591
	$pconfig['range_to']
592
);
593
594
$f2->setHelp('From');
595
596
$group = new Form_Group('Range');
597
598
$group->add($f1);
599
$group->add($f2);
600
601
$section->add($group);
602
603
$f1 = new Form_Input(
604
	'prefix_from',
605
	null,
606
	'text',
607
	$pconfig['prefix_from']
608
);
609
610
$f1->setHelp('To');
611
612
$f2 = new Form_Input(
613
	'prefix_to',
614
	null,
615
	'text',
616
	$pconfig['prefix_to']
617
);
618
619
$f2->setHelp('From');
620
$group = new Form_Group('Prefix Delegation Range');
621
622
$group->add($f1);
623
$group->add($f2);
624
625
$section->add($group);
626
627
$section->addInput(new Form_Select(
628
	'prefixrange_length',
629
	'Prefix Delegation Size',
630
	$pconfig['prefixrange_length'],
631
	array(
632
		'48' => '48',
633
		'52' => '52',
634
		'56' => '56',
635
		'60' => '60',
636
		'62' => '62',
637
		'63' => '63',
638
		'64' => '64'
639
		)
640
))->setHelp('You can define a Prefix range here for DHCP Prefix Delegation. This allows for assigning networks to subrouters. The start and end of the range must end on boundaries of the prefix delegation size.');
641
642
$group = new Form_Group('DNS Servers');
643
644
for($i=1;$i<=4; $i++) {
645
	$group->add(new Form_input(
646
		'dns' . $i,
647
		null,
648
		'text',
649 e32f02a5 Phil Davis
		$pconfig['dns' . $i],
650
		['placeholder' => 'DNS ' . $i]
651
	));
652 cd2c7940 sbeaver
}
653
654
$group->setHelp('Leave blank to use the system default DNS servers,this interface\'s IP if DNS forwarder is enabled, or the servers configured on the "General" page.');
655
$section->add($group);
656
657
$section->addInput(new Form_Input(
658
	'domain',
659
	'Domain Name',
660
	'text',
661 ea6649f7 sbeaver
	$pconfig['domain']
662 cd2c7940 sbeaver
))->setHelp('The default is to use the domain name of this system as the default domain name provided by DHCP. You may specify an alternate domain name here. ');
663
664
$section->addInput(new Form_Input(
665
	'domainsearchlist',
666
	'Domain search list',
667
	'text',
668 ea6649f7 sbeaver
	$pconfig['domainsearchlist']
669 cd2c7940 sbeaver
))->setHelp('The DHCP server can optionally provide a domain search list. Use the semicolon character as separator');
670
671
$section->addInput(new Form_Input(
672
	'deftime',
673
	'Default lease time',
674
	'text',
675 ea6649f7 sbeaver
	$pconfig['deftime']
676 cd2c7940 sbeaver
))->setHelp('Seconds . Used for clients that do not ask for a specific expiration time. ' . ' <br />' .
677
			'The default is 7200 seconds.');
678
679
$section->addInput(new Form_Input(
680
	'maxtime',
681
	'Max lease time',
682
	'text',
683 ea6649f7 sbeaver
	$pconfig['maxtime']
684 cd2c7940 sbeaver
))->setHelp('Maximum lease time for clients that ask for a specific expiration time.' . ' <br />' .
685
			'The default is 86400 seconds.');
686
687
$section->addInput(new Form_Checkbox(
688
	'dhcpv6leaseinlocaltime',
689
	'Time Format Change',
690
	'Change DHCPv6 display lease time from UTC to local time',
691
	$pconfig['dhcpv6leaseinlocaltime']
692
))->setHelp('By default DHCPv6 leases are displayed in UTC time. ' .
693
			'By checking this box DHCPv6 lease time will be displayed in local time and set to time zone selected. ' .
694
			'This will be used for all DHCPv6 interfaces lease time.');
695
696
$btndyndns = new Form_Button(
697
	'btndyndns',
698
	'Advanced'
699
);
700
701
$btndyndns->removeClass('btn-primary')->addClass('btn-default btn-sm');
702
703
$section->addInput(new Form_StaticText(
704
	'Dynamic DNS',
705
	$btndyndns . '&nbsp;' . 'Show dynamic DNS settings'
706
));
707
708
$section->addInput(new Form_Checkbox(
709
	'ddnsupdate',
710
	'DHCP Registration',
711
	'Enable registration of DHCP client names in DNS.',
712
	$pconfig['ddnsupdate']
713
));
714
715
$section->addInput(new Form_Input(
716
	'ddnsdomain',
717
	'DDNS Domain',
718
	'text',
719 ea6649f7 sbeaver
	$pconfig['ddnsdomain']
720 cd2c7940 sbeaver
))->setHelp('Leave blank to disable dynamic DNS registration. Enter the dynamic DNS domain which will be used to register client names in the DNS server.');
721
722
$section->addInput(new Form_IpAddress(
723
	'ddnsdomainprimary',
724
	'DDNS Server IP',
725 ea6649f7 sbeaver
	$pconfig['ddnsdomainprimary']
726 cd2c7940 sbeaver
))->setHelp('Enter the primary domain name server IP address for the dynamic domain name.');
727
728
$section->addInput(new Form_Input(
729
	'ddnsdomainkeyname',
730
	'DDNS Domain Key name',
731
	'text',
732 ea6649f7 sbeaver
	$pconfig['ddnsdomainkeyname']
733 cd2c7940 sbeaver
))->setHelp('Enter the dynamic DNS domain key name which will be used to register client names in the DNS server.');
734
735
$section->addInput(new Form_Input(
736
	'ddnsdomainkey',
737
	'DDNS Domain Key secret',
738
	'text',
739 ea6649f7 sbeaver
	$pconfig['ddnsdomainkey']
740 cd2c7940 sbeaver
))->setHelp('Enter the dynamic DNS domain key secret which will be used to register client names in the DNS server.');
741
742
$btnntp = new Form_Button(
743
	'btnntp',
744
	'Advanced'
745
);
746
747
$btnntp->removeClass('btn-primary')->addClass('btn-default btn-sm');
748
749
$section->addInput(new Form_StaticText(
750
	'NTP servers',
751
	$btnntp . '&nbsp;' . 'Show NTP Configuration'
752
));
753
754
$group = new Form_Group('NTP Servers');
755
756
$group->add(new Form_Input(
757
	'ntp1',
758
	'NTP Server 1',
759
	'text',
760 ea6649f7 sbeaver
	$pconfig['ntp1'],
761 cd2c7940 sbeaver
	['placeholder' => 'NTP 1']
762
));
763
764
$group->add(new Form_Input(
765
	'ntp2',
766 e32f02a5 Phil Davis
	'NTP Server 2',
767 cd2c7940 sbeaver
	'text',
768 ea6649f7 sbeaver
	$pconfig['ntp2'],
769 cd2c7940 sbeaver
	['placeholder' => 'NTP 2']
770
));
771
772
$group->addClass('ntpclass');
773
774
$section->add($group);
775
776
$btnldap = new Form_Button(
777
	'btnldap',
778
	'Advanced'
779
);
780
781
$btnldap->removeClass('btn-primary')->addClass('btn-default btn-sm');
782
783
$section->addInput(new Form_StaticText(
784
	'LDAP',
785
	$btnldap . '&nbsp;' . 'Show LDAP Configuration'
786
));
787
788
$section->addInput(new Form_Input(
789
	'ldap',
790
	'LDAP URI',
791
	'text',
792 ea6649f7 sbeaver
	$pconfig['ldap']
793 cd2c7940 sbeaver
));
794
795
$btnnetboot = new Form_Button(
796
	'btnnetboot',
797
	'Advanced'
798
);
799
800
$btnnetboot->removeClass('btn-primary')->addClass('btn-default btn-sm');
801
802
$section->addInput(new Form_StaticText(
803
	'Network booting',
804 e32f02a5 Phil Davis
	$btnnetboot . '&nbsp;' . 'Show Network booting'
805 cd2c7940 sbeaver
));
806
807
$section->addInput(new Form_Checkbox(
808
	'shownetboot',
809
	'Network booting',
810
	'Enable Network Booting',
811
	$pconfig['shownetboot']
812
));
813
814
$section->addInput(new Form_Input(
815
	'bootfile_url',
816
	'Bootfile URL',
817
	'text',
818 ea6649f7 sbeaver
	$pconfig['bootfile_url']
819 cd2c7940 sbeaver
));
820
821
$btnadnl = new Form_Button(
822
	'btnadnl',
823
	'Advanced'
824
);
825
826
$btnadnl->removeClass('btn-primary')->addClass('btn-default btn-sm');
827
828
$section->addInput(new Form_StaticText(
829
	'Additional BOOTP/DHCP Options',
830 e32f02a5 Phil Davis
	$btnadnl . '&nbsp;' . 'Additional BOOTP/DHCP Options'
831 cd2c7940 sbeaver
));
832
833
$form->add($section);
834
835
$title = 'Show Additional BOOTP/DHCP Options';
836
837
if($pconfig['numberoptions']) {
838
	$counter = 0;
839
	$last = count($pconfig['numberoptions']['item']) - 1;
840
841
	foreach($pconfig['numberoptions']['item'] as $item) {
842
		$group = new Form_Group(null);
843
844
		$group->add(new Form_Input(
845
			'number' . $counter,
846
			null,
847
			'text',
848 ea6649f7 sbeaver
			$item['number']
849 cd2c7940 sbeaver
		))->setHelp($counter == $last ? 'Number':null);
850
851
		$group->add(new Form_Input(
852
			'value' . $counter,
853
			null,
854
			'text',
855 ea6649f7 sbeaver
			$item['value']
856 cd2c7940 sbeaver
		))->setHelp($counter == $last ? 'Value':null);
857
858
		$btn = new Form_Button(
859
			'btn' . $counter,
860
			'Delete',
861
			'services_dhcpv6.php?if=' . $if . '&act=delopt' . '&id=' . $counter
862
		);
863
864
		$btn->removeClass('btn-primary')->addClass('btn-danger btn-xs adnlopt');
865
		$group->addClass('adnlopt');
866
		$group->add($btn);
867
		$section->add($group);
868
		$counter++;
869 99caa67c Seth Mos
	}
870 cd2c7940 sbeaver
}
871
872
$btnaddopt = new Form_Button(
873
	'btnaddopt',
874
	'Add Option',
875
	'services_dhcpv6.php?if=' . $if . '&act=addopt'
876
);
877
878
$btnaddopt->removeClass('btn-primary')->addClass('btn-success btn-sm');
879
880
$section->addInput($btnaddopt);
881
882
$section->addInput(new Form_Input(
883
	'if',
884
	null,
885
	'hidden',
886
	$if
887
));
888
889
print($form);
890
891
print_info_box(gettext('The DNS servers entered in ') . '<a href="system.php">' . gettext(' System: General setup') . '</a>' .
892
			   gettext(' (or the ') . '<a href="services_dnsmasq.php"/>' . gettext('DNS forwarder') . '</a>, ' . gettext('if enabled) ') .
893
			   gettext('will be assigned to clients by the DHCP server.') . '<br />' .
894
			   gettext('The DHCP lease table can be viewed on the ') . '<a href="status_dhcpv6_leases.php">' .
895
			   gettext('Status: DHCPv6 leases') . '</a>' . gettext(' page.'));
896 99caa67c Seth Mos
?>
897 cd2c7940 sbeaver
898
<div class="panel panel-default">
899 f17594c7 Sjon Hortensius
	<div class="panel-heading"><h2 class="panel-title">DHCPv6 Static Mappings for this interface.</h2></div>
900 cd2c7940 sbeaver
	<div class="panel-body table-responsive">
901
		<table class="table table-striped table-hover table-condensed">
902
			<thead>
903
				<tr>
904
					<th><?=gettext("DUID")?></th>
905
					<th><?=gettext("IPv6 address")?></th>
906
					<th><?=gettext("Hostname")?></th>
907
					<th><?=gettext("Description")?></th>
908
					<th><!-- Buttons --></th>
909
				</tr>
910
			</thead>
911
			<tbody>
912 99caa67c Seth Mos
<?php
913 cd2c7940 sbeaver
if(is_array($a_maps)):
914 99caa67c Seth Mos
	$i = 0;
915 cd2c7940 sbeaver
	foreach ($a_maps as $mapent):
916
		if($mapent['duid'] != "" or $mapent['ipaddrv6'] != ""):
917 99caa67c Seth Mos
?>
918 cd2c7940 sbeaver
				<tr>
919 7d0ad4ec Joecowboy
					<td>
920 cd2c7940 sbeaver
						<?=htmlspecialchars($mapent['duid'])?>
921 7d0ad4ec Joecowboy
					</td>
922
					<td>
923 cd2c7940 sbeaver
						<?=htmlspecialchars($mapent['ipaddrv6'])?>
924 7d0ad4ec Joecowboy
					</td>
925
					<td>
926 cd2c7940 sbeaver
						<?=htmlspecialchars($mapent['hostname'])?>
927
					</td>
928
					<td>
929
						<?=htmlspecialchars($mapent['descr'])?>
930
					</td>
931
					<td>
932 33f0b0d5 Stephen Beaver
						<a class="fa fa-pencil"	title="<?=gettext('Edit static mapping')?>" href="services_dhcpv6_edit.php?if=<?=$if?>&amp;id=<?=$i?>"></a>
933
						<a class="fa fa-trash"	title="<?=gettext('Delete static mapping')?>" href="services_dhcpv6.php?if=<?=$if?>&amp;act=del&amp;id=<?=$i?>"></a>
934 7d0ad4ec Joecowboy
					</td>
935 99caa67c Seth Mos
				</tr>
936 cd2c7940 sbeaver
<?php
937
		endif;
938
	$i++;
939
	endforeach;
940
endif;
941
?>
942
			</tbody>
943 99caa67c Seth Mos
		</table>
944
	</div>
945 cd2c7940 sbeaver
</div>
946
947 c10cb196 Stephen Beaver
<nav class="action-buttons">
948 c9679d8c Stephen Beaver
	<a href="services_dhcpv6_edit.php?if=<?=$if?>" class="btn btn-sm btn-success"/>
949 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
950 c9679d8c Stephen Beaver
		<?=gettext("Add")?>
951
	</a>
952 cd2c7940 sbeaver
</nav>
953
954
<script>
955 ee9530e1 Colin Fleming
//<![CDATA[
956 cd2c7940 sbeaver
events.push(function(){
957
958
	function hideDDNS(hide) {
959
		hideCheckBox('ddnsupdate', hide);
960
		hideInput('ddnsdomain', hide);
961
		hideInput('ddnsdomainprimary', hide);
962
		hideInput('ddnsdomainkeyname', hide);
963
		hideInput('ddnsdomainkey', hide);
964
	}
965
966 2f5dafed heper
	// Make the 'Copy My MAC' button a plain button, not a submit button
967 cd2c7940 sbeaver
	$("#btnmymac").prop('type','button');
968
969
	// On click, copy the hidden 'mymac' text to the 'mac' input
970
	$("#btnmymac").click(function() {
971
		$('#mac').val('<?=$mymac?>');
972
	});
973
974 2f5dafed heper
	// Make the 'tftp' button a plain button, not a submit button
975 cd2c7940 sbeaver
	$("#btntftp").prop('type','button');
976
977
	// Show tftp controls
978
	$("#btntftp").click(function() {
979
		hideInput('tftp', false);
980
	});
981
982 2f5dafed heper
	// Make the 'ntp' button a plain button, not a submit button
983 cd2c7940 sbeaver
	$("#btnntp").prop('type','button');
984
985
	// Show ntp controls
986
	$("#btnntp").click(function() {
987
		hideClass('ntpclass', false);
988
	});
989
990 2f5dafed heper
	// Make the 'ddns' button a plain button, not a submit button
991 cd2c7940 sbeaver
	$("#btndyndns").prop('type','button');
992
993
	// Show ddns controls
994
	$("#btndyndns").click(function() {
995
		hideDDNS(false);
996
	});
997
998 2f5dafed heper
	// Make the 'ldap' button a plain button, not a submit button
999 cd2c7940 sbeaver
	$("#btnldap").prop('type','button');
1000
1001
	// Show ldap controls
1002
	$("#btnldap").click(function() {
1003
		hideInput('ldap', false);
1004
	});
1005
1006 2f5dafed heper
	// Make the 'netboot' button a plain button, not a submit button
1007 cd2c7940 sbeaver
	$("#btnnetboot").prop('type','button');
1008
1009
	// Show netboot controls
1010
	$("#btnnetboot").click(function() {
1011
		hideInput('bootfile_url', false);
1012
		hideCheckBox('shownetboot', false);
1013
	});
1014
1015 e32f02a5 Phil Davis
	// Make the 'additional options' button a plain button, not a submit button
1016 cd2c7940 sbeaver
	$("#btnadnl").prop('type','button');
1017
1018 e32f02a5 Phil Davis
	// Show additional  controls
1019 cd2c7940 sbeaver
	$("#btnadnl").click(function() {
1020
		hideClass('adnlopt', false);
1021
		hideInput('btnaddopt', false);
1022
	});
1023
1024
	// On initial load
1025
	hideDDNS(true);
1026
	hideClass('ntpclass', true);
1027
	hideInput('tftp', true);
1028
	hideInput('ldap', true);
1029
	hideInput('bootfile_url', true);
1030
	hideCheckBox('shownetboot', true);
1031
	hideClass('adnlopt', true);
1032
	hideInput('btnaddopt', true);
1033
});
1034 ee9530e1 Colin Fleming
//]]>
1035 99caa67c Seth Mos
</script>
1036 cd2c7940 sbeaver
1037 2f5dafed heper
<?php include('foot.inc');