Project

General

Profile

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