Project

General

Profile

Download (36.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services_dhcpv6.php
5
	parts of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	part of pfSense (http://www.pfsense.org)
11
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
12
	All rights reserved.
13

    
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16

    
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19

    
20
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23

    
24
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35
/*
36
	pfSense_BUILDER_BINARIES:	/bin/rm
37
	pfSense_MODULE:	interfaces
38
*/
39

    
40
##|+PRIV
41
##|*IDENT=page-services-dhcpv6server
42
##|*NAME=Services: DHCPv6 server page
43
##|*DESCR=Allow access to the 'Services: DHCPv6 server' page.
44
##|*MATCH=services_dhcpv6.php*
45
##|-PRIV
46

    
47
require("guiconfig.inc");
48

    
49
if(!$g['services_dhcp_server_enable']) {
50
	Header("Location: /");
51
	exit;
52
}
53

    
54
/*  Fix failover DHCP problem
55
 *  http://article.gmane.org/gmane.comp.security.firewalls.pfsense.support/18749
56
 */
57
ini_set("memory_limit","64M");
58

    
59
$if = $_GET['if'];
60
if ($_POST['if'])
61
	$if = $_POST['if'];
62

    
63
/* if OLSRD is enabled, allow WAN to house DHCP. */
64
if($config['installedpackages']['olsrd']) {
65
	foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
66
			if($olsrd['enable']) {
67
				$is_olsr_enabled = true;
68
				break;
69
			}
70
	}
71
}
72

    
73
if (!$_GET['if'])
74
	$savemsg = "<b>" . gettext("The DHCPv6 Server can only be enabled on interfaces configured with static IP addresses") . ".<p>" . gettext("Only interfaces configured with a static IP will be shown") . ".</p></b>";
75

    
76
$iflist = get_configured_interface_with_descr();
77

    
78
/* set the starting interface */
79
if (!$if || !isset($iflist[$if])) {
80
	foreach ($iflist as $ifent => $ifname) {
81
		$oc = $config['interfaces'][$ifent];
82
		if ((is_array($config['dhcpdv6'][$ifent]) && !isset($config['dhcpdv6'][$ifent]['enable']) && (!is_ipaddrv6($oc['ipaddrv6']))) ||
83
			(!is_array($config['dhcpdv6'][$ifent]) && (!is_ipaddrv6($oc['ipaddrv6']))))
84
			continue;
85
		$if = $ifent;
86
		break;
87
	}
88
}
89

    
90
if (is_array($config['dhcpdv6'][$if])){
91
	if (is_array($config['dhcpdv6'][$if]['range'])) {
92
		$pconfig['range_from'] = $config['dhcpdv6'][$if]['range']['from'];
93
		$pconfig['range_to'] = $config['dhcpdv6'][$if]['range']['to'];
94
	}
95
	if (is_array($config['dhcpdv6'][$if]['prefixrange'])) {
96
		$pconfig['prefixrange_from'] = $config['dhcpdv6'][$if]['prefixrange']['from'];
97
		$pconfig['prefixrange_to'] = $config['dhcpdv6'][$if]['prefixrange']['to'];
98
		$pconfig['prefixrange_length'] = $config['dhcpdv6'][$if]['prefixrange']['prefixlength'];
99
	}
100
	$pconfig['mode'] = $config['dhcpdv6'][$if]['mode'];
101
	$pconfig['deftime'] = $config['dhcpdv6'][$if]['defaultleasetime'];
102
	$pconfig['maxtime'] = $config['dhcpdv6'][$if]['maxleasetime'];
103
	$pconfig['gateway'] = $config['dhcpdv6'][$if]['gateway'];
104
	$pconfig['domain'] = $config['dhcpdv6'][$if]['domain'];
105
	$pconfig['domainsearchlist'] = $config['dhcpdv6'][$if]['domainsearchlist'];
106
	list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpdv6'][$if]['winsserver'];
107
	list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpdv6'][$if]['dnsserver'];
108
	$pconfig['enable'] = isset($config['dhcpdv6'][$if]['enable']);
109
	$pconfig['denyunknown'] = isset($config['dhcpdv6'][$if]['denyunknown']);
110
	$pconfig['ddnsdomain'] = $config['dhcpdv6'][$if]['ddnsdomain'];
111
	$pconfig['ddnsupdate'] = isset($config['dhcpdv6'][$if]['ddnsupdate']);
112
	list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpdv6'][$if]['ntpserver'];
113
	$pconfig['tftp'] = $config['dhcpdv6'][$if]['tftp'];
114
	$pconfig['ldap'] = $config['dhcpdv6'][$if]['ldap'];
115
	$pconfig['netboot'] = isset($config['dhcpdv6'][$if]['netboot']);
116
	$pconfig['nextserver'] = $config['dhcpdv6'][$if]['next-server'];
117
	$pconfig['filename'] = $config['dhcpdv6'][$if]['filename'];
118
	$pconfig['rootpath'] = $config['dhcpdv6'][$if]['rootpath'];
119
	$pconfig['failover_peerip'] = $config['dhcpdv6'][$if]['failover_peerip'];
120
	$pconfig['netmask'] = $config['dhcpdv6'][$if]['netmask'];
121
	$pconfig['numberoptions'] = $config['dhcpdv6'][$if]['numberoptions'];
122
	if (!is_array($config['dhcpdv6'][$if]['staticmap']))
123
		$config['dhcpdv6'][$if]['staticmap'] = array();
124
	$a_maps = &$config['dhcpdv6'][$if]['staticmap'];
125
}
126

    
127
$ifcfgip = get_interface_ipv6($if);
128
$ifcfgsn = get_interface_subnetv6($if);
129

    
130
/*   set the enabled flag which will tell us if DHCP relay is enabled
131
 *   on any interface. We will use this to disable DHCP server since
132
 *   the two are not compatible with each other.
133
 */
134

    
135
$dhcrelay_enabled = false;
136
$dhcrelaycfg = $config['dhcrelay'];
137

    
138
if(is_array($dhcrelaycfg)) {
139
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
140
		if (isset($dhcrelayifconf['enable']) && isset($iflist[$dhcrelayif]) &&
141
			(!link_interface_to_bridge($dhcrelayif)))
142
			$dhcrelay_enabled = true;
143
	}
144
}
145

    
146
/* FIXME needs v6 code, use in subnet v6? */
147
function is_inrange($test, $start, $end) {
148
	if ( (ip2ulong($test) < ip2ulong($end)) && (ip2ulong($test) > ip2ulong($start)) )
149
		return true;
150
	else
151
		return false;
152
}
153

    
154
$advertise_modes = array("disabled" => "Disabled", "router" => "Router Only", "unmanaged" => "Unmanaged", "managed" => "Managed", "assist" => "Assisted");
155

    
156
if ($_POST) {
157

    
158
	unset($input_errors);
159

    
160
	$pconfig = $_POST;
161

    
162
	$numberoptions = array();
163
	for($x=0; $x<99; $x++) {
164
		if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
165
			$numbervalue = array();
166
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
167
			$numbervalue['value'] = htmlspecialchars($_POST["value{$x}"]);
168
			$numberoptions['item'][] = $numbervalue;
169
		}
170
	}
171
	// Reload the new pconfig variable that the forum uses.
172
	$pconfig['numberoptions'] = $numberoptions;
173

    
174
	/* input validation */
175
	if ($_POST['enable']) {
176
		$reqdfields = explode(" ", "range_from range_to");
177
		$reqdfieldsn = array(gettext("Range begin"),gettext("Range end"));
178

    
179
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
180

    
181
		if (($_POST['prefixrange_from'] && !is_ipaddrv6($_POST['prefixrange_from'])))
182
			$input_errors[] = gettext("A valid range must be specified.");
183
		if (($_POST['prefixrange_to'] && !is_ipaddrv6($_POST['prefixrange_to'])))
184
			$input_errors[] = gettext("A valid prefix range must be specified.");
185
		if (($_POST['range_from'] && !is_ipaddrv6($_POST['range_from'])))
186
			$input_errors[] = gettext("A valid range must be specified.");
187
		if (($_POST['range_to'] && !is_ipaddrv6($_POST['range_to'])))
188
			$input_errors[] = gettext("A valid range must be specified.");
189
		if (($_POST['gateway'] && !is_ipaddrv6($_POST['gateway'])))
190
			$input_errors[] = gettext("A valid IPv6 address must be specified for the gateway.");
191
		if (($_POST['dns1'] && !is_ipaddrv6($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv6($_POST['dns2'])))
192
			$input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary DNS servers.");
193

    
194
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
195
			$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
196
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
197
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
198
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
199
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
200
		if (($_POST['ntp1'] && !is_ipaddrv6($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv6($_POST['ntp2'])))
201
			$input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary NTP servers.");
202
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
203
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
204
		if ($_POST['tftp'] && !is_ipaddr($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
205
			$input_errors[] = gettext("A valid IPv6 address or hostname must be specified for the TFTP server.");
206
		if (($_POST['nextserver'] && !is_ipaddrv6($_POST['nextserver'])))
207
			$input_errors[] = gettext("A valid IPv6 address must be specified for the network boot server.");
208

    
209
		// Disallow a range that includes the virtualip
210
		if (is_array($config['virtualip']['vip'])) {
211
			foreach($config['virtualip']['vip'] as $vip) {
212
				if($vip['interface'] == $if)
213
					if($vip['subnetv6'] && is_inrange($vip['subnetv6'], $_POST['range_from'], $_POST['range_to']))
214
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IPv6 address %s."),$vip['subnetv6']);
215
			}
216
		}
217

    
218
		$noip = false;
219
		if(is_array($a_maps))
220
			foreach ($a_maps as $map)
221
				if (empty($map['ipaddrv6']))
222
					$noip = true;
223
		if (!$input_errors) {
224
			/* make sure the range lies within the current subnet */
225
			/* FIXME change for ipv6 subnet */
226
			$subnet_start = gen_subnetv6($ifcfgip, $ifcfgsn);
227
			$subnet_end = gen_subnetv6_max($ifcfgip, $ifcfgsn);
228

    
229
			if((! ip_in_subnet($_POST['range_from'], $subnet_start)) || (! ip_in_subnet($_POST['range_to'], $subnet_start))) {
230
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
231
			}
232

    
233
			/* no idea how to do this yet 
234
			if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to']))
235
				$input_errors[] = gettext("The range is invalid (first element higher than second element).");
236
			*/
237

    
238
			/* make sure that the DHCP Relay isn't enabled on this interface */
239
			if (isset($config['dhcrelay'][$if]['enable']))
240
				$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."),$iflist[$if]);
241

    
242
			// $dynsubnet_start = ip2ulong($_POST['range_from']);
243
			// $dynsubnet_end = ip2ulong($_POST['range_to']);
244
			/* FIX later. Also applies to prefix delegation
245
			if(is_array($a_maps)) {
246
				foreach ($a_maps as $map) {
247
					if (empty($map['ipaddrv6']))
248
						continue;
249
					if ((ip2ulong($map['ipaddrv6']) > $dynsubnet_start) &&
250
						(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
251
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
252
						break;
253
					}
254
				}
255
			}
256
			*/
257
		}
258
	}
259

    
260
	if (!$input_errors) {
261
		if (!is_array($config['dhcpdv6'][$if]))
262
			$config['dhcpdv6'][$if] = array();
263
		if (!is_array($config['dhcpdv6'][$if]['range']))
264
			$config['dhcpdv6'][$if]['range'] = array();
265
		if (!is_array($config['dhcpdv6'][$if]['prefixrange']))
266
			$config['dhcpdv6'][$if]['prefixrange'] = array();
267

    
268
		$config['dhcpdv6'][$if]['mode'] = $_POST['mode'];
269
		$config['dhcpdv6'][$if]['range']['from'] = $_POST['range_from'];
270
		$config['dhcpdv6'][$if]['range']['to'] = $_POST['range_to'];
271
		$config['dhcpdv6'][$if]['prefixrange']['from'] = $_POST['prefixrange_from'];
272
		$config['dhcpdv6'][$if]['prefixrange']['to'] = $_POST['prefixrange_to'];
273
		$config['dhcpdv6'][$if]['prefixrange']['prefixlength'] = $_POST['prefixrange_length'];
274
		$config['dhcpdv6'][$if]['defaultleasetime'] = $_POST['deftime'];
275
		$config['dhcpdv6'][$if]['maxleasetime'] = $_POST['maxtime'];
276
		$config['dhcpdv6'][$if]['netmask'] = $_POST['netmask'];
277
		$previous = $config['dhcpdv6'][$if]['failover_peerip'];
278
		if($previous <> $_POST['failover_peerip'])
279
			mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
280

    
281
		$config['dhcpdv6'][$if]['failover_peerip'] = $_POST['failover_peerip'];
282

    
283
		unset($config['dhcpdv6'][$if]['winsserver']);
284

    
285
		unset($config['dhcpdv6'][$if]['dnsserver']);
286
		if ($_POST['dns1'])
287
			$config['dhcpdv6'][$if]['dnsserver'][] = $_POST['dns1'];
288
		if ($_POST['dns2'])
289
			$config['dhcpdv6'][$if]['dnsserver'][] = $_POST['dns2'];
290

    
291
		$config['dhcpdv6'][$if]['gateway'] = $_POST['gateway'];
292
		$config['dhcpdv6'][$if]['domain'] = $_POST['domain'];
293
		$config['dhcpdv6'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
294
		$config['dhcpdv6'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
295
		$config['dhcpdv6'][$if]['enable'] = ($_POST['enable']) ? true : false;
296
		$config['dhcpdv6'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
297
		$config['dhcpdv6'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
298

    
299
		unset($config['dhcpdv6'][$if]['ntpserver']);
300
		if ($_POST['ntp1'])
301
			$config['dhcpdv6'][$if]['ntpserver'][] = $_POST['ntp1'];
302
		if ($_POST['ntp2'])
303
			$config['dhcpdv6'][$if]['ntpserver'][] = $_POST['ntp2'];
304

    
305
		$config['dhcpdv6'][$if]['tftp'] = $_POST['tftp'];
306
		$config['dhcpdv6'][$if]['ldap'] = $_POST['ldap'];
307
		$config['dhcpdv6'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
308
		$config['dhcpdv6'][$if]['next-server'] = $_POST['nextserver'];
309
		$config['dhcpdv6'][$if]['filename'] = $_POST['filename'];
310
		$config['dhcpdv6'][$if]['rootpath'] = $_POST['rootpath'];
311

    
312
		// Handle the custom options rowhelper
313
		if(isset($config['dhcpdv6'][$if]['numberoptions']['item']))
314
			unset($config['dhcpdv6'][$if]['numberoptions']['item']);
315

    
316
		$config['dhcpdv6'][$if]['numberoptions'] = $numberoptions;
317

    
318
		write_config();
319

    
320
		$retval = 0;
321
		$retvaldhcp = 0;
322
		$retvaldns = 0;
323
		/* Stop DHCPv6 so we can cleanup leases */
324
		killbyname("dhcpd -6");
325
		// dhcp_clean_leases();
326
		/* dnsmasq_configure calls dhcpd_configure */
327
		/* no need to restart dhcpd twice */
328
		if (isset($config['dnsmasq']['regdhcpstatic']))	{
329
			$retvaldns = services_dnsmasq_configure();
330
			if ($retvaldns == 0) {
331
				clear_subsystem_dirty('hosts');
332
				clear_subsystem_dirty('staticmaps');
333
			}
334
		} else {
335
			$retvaldhcp = services_dhcpd_configure();
336
			if ($retvaldhcp == 0)
337
				clear_subsystem_dirty('staticmaps');
338
		}
339
		if($retvaldhcp == 1 || $retvaldns == 1)
340
			$retval = 1;
341
		$savemsg = get_std_save_message($retval);
342
	}
343
}
344

    
345
if ($_GET['act'] == "del") {
346
	if ($a_maps[$_GET['id']]) {
347
		unset($a_maps[$_GET['id']]);
348
		write_config();
349
		if(isset($config['dhcpdv6'][$if]['enable'])) {
350
			mark_subsystem_dirty('staticmapsv6');
351
			if (isset($config['dnsmasq']['regdhcpstaticv6']))
352
				mark_subsystem_dirty('hosts');
353
		}
354
		header("Location: services_dhcpv6.php?if={$if}");
355
		exit;
356
	}
357
}
358

    
359
$pgtitle = array(gettext("Services"),gettext("DHCPv6 server"));
360
$statusurl = "status_dhcpv6_leases.php";
361
$logurl = "diag_logs_dhcp.php";
362

    
363
include("head.inc");
364

    
365
?>
366

    
367
<script type="text/javascript" src="/javascript/row_helper.js">
368
</script>
369

    
370
<script type="text/javascript">
371
	rowname[0] = "number";
372
	rowtype[0] = "textbox";
373
	rowsize[0] = "10";
374
	rowname[1] = "value";
375
	rowtype[1] = "textbox";
376
	rowsize[1] = "55";
377
</script>
378

    
379
<script type="text/javascript" language="JavaScript">
380
	function enable_change(enable_over) {
381
		var endis;
382
		endis = !(document.iform.enable.checked || enable_over);
383
		document.iform.range_from.disabled = endis;
384
		document.iform.range_to.disabled = endis;
385
		document.iform.prefixrange_from.disabled = endis;
386
		document.iform.prefixrange_to.disabled = endis;
387
		document.iform.prefixrange_length.disabled = endis;
388
		document.iform.dns1.disabled = endis;
389
		document.iform.dns2.disabled = endis;
390
		document.iform.deftime.disabled = endis;
391
		document.iform.maxtime.disabled = endis;
392
		document.iform.gateway.disabled = endis;
393
		document.iform.failover_peerip.disabled = endis;
394
		document.iform.domain.disabled = endis;
395
		document.iform.domainsearchlist.disabled = endis;
396
		document.iform.ddnsdomain.disabled = endis;
397
		document.iform.ddnsupdate.disabled = endis;
398
		document.iform.ntp1.disabled = endis;
399
		document.iform.ntp2.disabled = endis;
400
		document.iform.tftp.disabled = endis;
401
		document.iform.ldap.disabled = endis;
402
		document.iform.netboot.disabled = endis;
403
		document.iform.nextserver.disabled = endis;
404
		document.iform.filename.disabled = endis;
405
		document.iform.rootpath.disabled = endis;
406
		document.iform.denyunknown.disabled = endis;
407
	}
408

    
409
	function show_shownumbervalue() {
410
		document.getElementById("shownumbervaluebox").innerHTML='';
411
		aodiv = document.getElementById('shownumbervalue');
412
		aodiv.style.display = "block";
413
	}
414

    
415
	function show_ddns_config() {
416
		document.getElementById("showddnsbox").innerHTML='';
417
		aodiv = document.getElementById('showddns');
418
		aodiv.style.display = "block";
419
	}
420
	/*
421
	function show_ntp_config() {
422
		document.getElementById("showntpbox").innerHTML='';
423
		aodiv = document.getElementById('showntp');
424
		aodiv.style.display = "block";
425
	}
426
	*/
427
	/*
428
	function show_tftp_config() {
429
		document.getElementById("showtftpbox").innerHTML='';
430
		aodiv = document.getElementById('showtftp');
431
		aodiv.style.display = "block";
432
	}
433
	*/
434
	function show_ldap_config() {
435
		document.getElementById("showldapbox").innerHTML='';
436
		aodiv = document.getElementById('showldap');
437
		aodiv.style.display = "block";
438
	}
439

    
440
	function show_netboot_config() {
441
		document.getElementById("shownetbootbox").innerHTML='';
442
		aodiv = document.getElementById('shownetboot');
443
		aodiv.style.display = "block";
444
	}
445
</script>
446

    
447
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
448
<?php include("fbegin.inc"); ?>
449
<form action="services_dhcpv6.php" method="post" name="iform" id="iform">
450
<?php if ($input_errors) print_input_errors($input_errors); ?>
451
<?php if ($savemsg) print_info_box($savemsg); ?>
452
<?php
453
	if ($dhcrelay_enabled) {
454
		echo gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.");
455
		include("fend.inc");
456
		echo "</body>";
457
		echo "</html>";
458
		exit;
459
	}
460
?>
461
<?php if (is_subsystem_dirty('staticmaps')): ?><p>
462
<?php 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."));?><br>
463
<?php endif; ?>
464
<table width="100%" border="0" cellpadding="0" cellspacing="0">
465
<tr><td>
466
<?php
467
	/* active tabs */
468
	$tab_array = array();
469
	$tabscounter = 0;
470
	$i = 0;
471
	foreach ($iflist as $ifent => $ifname) {
472
		$oc = $config['interfaces'][$ifent];
473
		if ((is_array($config['dhcpdv6'][$ifent]) && !isset($config['dhcpdv6'][$ifent]['enable']) && (!is_ipaddrv6($oc['ipaddrv6']))) ||
474
			(!is_array($config['dhcpdv6'][$ifent]) && (!is_ipaddrv6($oc['ipaddrv6']))))
475
			continue;
476
		if ($ifent == $if)
477
			$active = true;
478
		else
479
			$active = false;
480
		$tab_array[] = array($ifname, $active, "services_dhcpv6.php?if={$ifent}");
481
		$tabscounter++;
482
	}
483
	if ($tabscounter == 0) {
484
		echo "</td></tr></table></form>";
485
		include("fend.inc");
486
		echo "</body>";
487
		echo "</html>";
488
		exit;
489
	}
490
	display_top_tabs($tab_array);
491
?>
492
</td></tr>
493
<tr>
494
<td>
495
	<div id="mainarea">
496
		<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
497
			<tr>
498
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Router Advertisements");?></td>
499
			<td width="78%" class="vtable">
500
				<select name="mode" id="mode">
501
					<?php foreach($advertise_modes as $name => $value) { ?>
502
					<option value="<?=$name ?>" <?php if ($pconfig['mode'] == $name) echo "selected"; ?> > <?=$value ?></option>
503
					<?php } ?>
504
				</select><br />
505
			<strong><?php printf(gettext("Select the Operating Mode for the router advertisement Daemon. Use \"Router Only\" to only advertise the router, \"Unmanaged\" for Router Advertising with Stateless Autoconfig, \"Managed\" for DHCPv6 only with router advertisements, \"Assisted\" for DHCPv6 Combined with Stateless Autoconfig"));?></strong></td>
506
			</tr>
507
			<tr>
508
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
509
			<td width="78%" class="vtable">
510
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false);">
511
			<strong><?php printf(gettext("Enable DHCPv6 server on " .
512
			"%s " .
513
			"interface"),htmlspecialchars($iflist[$if]));?></strong></td>
514
			</tr>
515
			<tr>
516
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
517
			<td width="78%" class="vtable">
518
				<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
519
				<strong><?=gettext("Deny unknown clients");?></strong><br>
520
				<?=gettext("If this is checked, only the clients defined below will get DHCP leases from this server. ");?></td>
521
			</tr>
522
			<tr>
523
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet");?></td>
524
			<td width="78%" class="vtable">
525
				<?=gen_subnetv6($ifcfgip, $ifcfgsn);?>
526
			</td>
527
			</tr>
528
			<tr>
529
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet mask");?></td>
530
			<td width="78%" class="vtable">
531
				<?=$ifcfgsn;?> bits
532
			</td>
533
			</tr>
534
			<tr>
535
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Available range");?></td>
536
			<td width="78%" class="vtable">
537
			<?php
538
				$range_from = gen_subnetv6($ifcfgip, $ifcfgsn);
539
				$range_from++;
540
				echo $range_from;
541

    
542
			?>
543
			-
544
			<?php
545
				/* FIXME end of subnet calculation here */
546
				$range_to = gen_subnetv6_max($ifcfgip, $ifcfgsn);;
547
				echo $range_to;
548
			?>
549
			</td>
550
			</tr>
551
			<?php if($is_olsr_enabled): ?>
552
			<tr>
553
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
554
			<td width="78%" class="vtable">
555
				<select name="netmask" class="formselect" id="netmask">
556
				<?php
557
				for ($i = 128; $i > 0; $i--) {
558
					if($i <> 127) {
559
						echo "<option value=\"{$i}\" ";
560
						if ($i == $pconfig['netmask']) echo "selected";
561
						echo ">" . $i . "</option>";
562
					}
563
				}
564
				?>
565
				</select>
566
			</td>
567
			</tr>
568
			<?php endif; ?>
569
			<tr>
570
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
571
			<td width="78%" class="vtable">
572
				<input name="range_from" type="text" class="formfld unknown" id="range_from" size="28" value="<?=htmlspecialchars($pconfig['range_from']);?>">
573
				&nbsp;<?=gettext("to"); ?>&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="28" value="<?=htmlspecialchars($pconfig['range_to']);?>">
574
			</td>
575
			</tr>
576
			<tr>
577
			<td width="22%" valign="top" class="vncell"><?=gettext("Prefix Delegation Range");?></td>
578
			<td width="78%" class="vtable">
579
				<input name="prefixrange_from" type="text" class="formfld unknown" id="prefixrange_from" size="28" value="<?=htmlspecialchars($pconfig['prefixrange_from']);?>">
580
				&nbsp;<?=gettext("to"); ?>&nbsp; <input name="prefixrange_to" type="text" class="formfld unknown" id="prefixrange_to" size="28" value="<?=htmlspecialchars($pconfig['prefixrange_to']);?>">
581
				&nbsp;<?=gettext("prefix length"); ?>&nbsp; <select name="prefixrange_length" class="formselect" id="prefixrange_length">
582
					<option value="48" <?php if($pconfig['prefixrange_length'] == 48) echo "selected"; ?>>48</option>
583
					<option value="56" <?php if($pconfig['prefixrange_length'] == 56) echo "selected"; ?>>56</option>
584
					<option value="60" <?php if($pconfig['prefixrange_length'] == 60) echo "selected"; ?>>60</option>
585
				</select> <br/>
586
				<?php echo gettext("You can define a Prefix range here for DHCP Prefix Delegation. This allows for 
587
					assigning networks to subrouters"); ?>
588
			</td>
589
			</tr>
590
			<tr>
591
			<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
592
			<td width="78%" class="vtable">
593
				<input name="dns1" type="text" class="formfld unknown" id="dns1" size="28" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
594
				<input name="dns2" type="text" class="formfld unknown" id="dns2" size="28" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
595
				<?=gettext("NOTE: leave blank to use the system default DNS servers - this interface's IP if DNS forwarder is enabled, otherwise the servers configured on the General page.");?>
596
			</td>
597
			</tr>
598
			<!--
599
			<tr>
600
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
601
			<td width="78%" class="vtable">
602
				<input name="gateway" type="text" class="formfld host" id="gateway" size="28" value="<?=htmlspecialchars($pconfig['gateway']);?>"><br>
603
			 	 <?=gettext("The default is to use the IP on this interface of the firewall as the gateway. Specify an alternate gateway here if this is not the correct gateway for your network.");?>
604
			</td>
605
			</tr>
606
			-->
607
			<tr>
608
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
609
			<td width="78%" class="vtable">
610
				<input name="domain" type="text" class="formfld unknown" id="domain" size="28" value="<?=htmlspecialchars($pconfig['domain']);?>"><br>
611
				 <?=gettext("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.");?>
612
			 </td>
613
			</tr>
614
			<tr>
615
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
616
			<td width="78%" class="vtable">
617
				<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="28" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>"><br>
618
				<?=gettext("The DHCP server can optionally provide a domain search list.");?>
619
			</td>
620
			</tr>
621
			<tr>
622
			<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
623
			<td width="78%" class="vtable">
624
				<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
625
				<?=gettext("seconds");?><br>
626
				<?=gettext("This is used for clients that do not ask for a specific " .
627
				"expiration time."); ?><br>
628
				<?=gettext("The default is 7200 seconds.");?>
629
			</td>
630
			</tr>
631
			<tr>
632
			<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
633
			<td width="78%" class="vtable">
634
				<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
635
				<?=gettext("seconds");?><br>
636
				<?=gettext("This is the maximum lease time for clients that ask".
637
				" for a specific expiration time."); ?><br>
638
				<?=gettext("The default is 86400 seconds.");?>
639
			</td>
640
			</tr>
641
			<tr>
642
			<td width="22%" valign="top" class="vncell"><?=gettext("Failover peer IP:");?></td>
643
			<td width="78%" class="vtable">
644
				<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="28" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
645
				<?=gettext("Leave blank to disable.  Enter the interface IP address of the other machine.  Machines must be using CARP.");?>
646
			</td>
647
			</tr>
648
			<tr>
649
			<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
650
			<td width="78%" class="vtable">
651
				<div id="showddnsbox">
652
					<input type="button" onClick="show_ddns_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Dynamic DNS");?></a>
653
				</div>
654
				<div id="showddns" style="display:none">
655
					<input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>&nbsp;
656
					<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
657
					<p>
658
					<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="28" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
659
					<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
660
					<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?>
661
				</div>
662
			</td>
663
			</tr>
664
			<!-- ISC dhcpd does not support ntp for ipv6 yet. See redmine #2016
665
			<tr>
666
			<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
667
			<td width="78%" class="vtable">
668
				<div id="showntpbox">
669
					<input type="button" onClick="show_ntp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show NTP configuration");?></a>
670
				</div>
671
				<div id="showntp" style="display:none">
672
					<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="28" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
673
					<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="28" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
674
				</div>
675
			</td>
676
			</tr>
677
			-->
678
			<!-- ISC dhcpd does not support tftp for ipv6 yet. See redmine #2016
679
			<tr>
680
			<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
681
			<td width="78%" class="vtable">
682
			<div id="showtftpbox">
683
				<input type="button" onClick="show_tftp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show TFTP configuration");?></a>
684
			</div>
685
			<div id="showtftp" style="display:none">
686
				<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>"><br>
687
				<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
688
			</div>
689
			</td>
690
			</tr>
691
			-->
692
			<tr>
693
			<td width="22%" valign="top" class="vncell"><?=gettext("LDAP URI");?></td>
694
			<td width="78%" class="vtable">
695
				<div id="showldapbox">
696
					<input type="button" onClick="show_ldap_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show LDAP configuration");?></a>
697
				</div>
698
				<div id="showldap" style="display:none">
699
					<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>"><br>
700
					<?=gettext("Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com");?>
701
				</div>
702
			</td>
703
			</tr>
704
			<tr>
705
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable network booting");?></td>
706
			<td width="78%" class="vtable">
707
				<div id="shownetbootbox">
708
					<input type="button" onClick="show_netboot_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Network booting");?></a>
709
				</div>
710
				<div id="shownetboot" style="display:none">
711
					<input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>&nbsp;
712
					<b><?=gettext("Enables network booting.");?></b>
713
					<p>
714
					<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
715
					<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="28" value="<?=htmlspecialchars($pconfig['nextserver']);?>">
716
					<?=gettext("and the filename");?>
717
					<input name="filename" type="text" class="formfld unknown" id="filename" size="28" value="<?=htmlspecialchars($pconfig['filename']);?>"><br>
718
					<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
719
					<p>
720
					<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
721
					<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br>
722
					<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
723
				</div>
724
			</td>
725
			</tr>
726
			<tr>
727
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
728
			<td width="78%" class="vtable">
729
				<div id="shownumbervaluebox">
730
					<input type="button" onClick="show_shownumbervalue()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Additional BOOTP/DHCP Options");?></a>
731
				</div>
732
				<div id="shownumbervalue" style="display:none">
733
				<table id="maintable">
734
				<tbody>
735
				<tr>
736
				<td colspan="3">
737
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
738
					<?=gettext("Enter the DHCP option number and the value for each item you would like to include in the DHCP lease information.  For a list of available options please visit this"); ?> <a href="http://www.iana.org/assignments/bootp-dhcp-parameters/" target="_new"><?=gettext("URL"); ?></a>
739
					</div>
740
				</td>
741
				</tr>
742
				<tr>
743
				<td><div id="onecolumn"><?=gettext("Number");?></div></td>
744
				<td><div id="twocolumn"><?=gettext("Value");?></div></td>
745
				</tr>
746
				<?php $counter = 0; ?>
747
				<?php
748
					if($pconfig['numberoptions'])
749
						foreach($pconfig['numberoptions']['item'] as $item):
750
				?>
751
					<?php
752
						$number = $item['number'];
753
						$value = $item['value'];
754
					?>
755
				<tr>
756
				<td>
757
					<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
758
				</td>
759
				<td>
760
					<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld" id="value<?php echo $counter; ?>" size="55" value="<?=htmlspecialchars($value);?>" />
761
				</td>
762
				<td>
763
					<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="<?=gettext("Delete");?>" />
764
				</td>
765
				</tr>
766
				<?php $counter++; ?>
767
				<?php endforeach; ?>
768
				</tbody>
769
				<tfoot>
770
				</tfoot>
771
				</table>
772
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
773
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
774
				</a>
775
				<script type="text/javascript">
776
					field_counter_js = 2;
777
					rows = 1;
778
					totalrows = <?php echo $counter; ?>;
779
					loaded = <?php echo $counter; ?>;
780
				</script>
781
				</div>
782

    
783
				</td>
784
			</tr>
785
			<tr>
786
			<td width="22%" valign="top">&nbsp;</td>
787
			<td width="78%">
788
				<input name="if" type="hidden" value="<?=$if;?>">
789
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)">
790
			</td>
791
			</tr>
792
			<tr>
793
			<td width="22%" valign="top">&nbsp;</td>
794
			<td width="78%"> <p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br>
795
				</strong></span><?=gettext("The DNS servers entered in"); ?> <a href="system.php"><?=gettext("System: " .
796
				"General setup"); ?></a> <?=gettext("(or the"); ?> <a href="services_dnsmasq.php"><?=gettext("DNS " .
797
				"forwarder"); ?></a>, <?=gettext("if enabled)"); ?> </span><span class="vexpl"><?=gettext("will " .
798
				"be assigned to clients by the DHCP server."); ?><br>
799
				<br>
800
				<?=gettext("The DHCP lease table can be viewed on the"); ?> <a href="status_dhcp_leases.php"><?=gettext("Status: " .
801
				"DHCP leases"); ?></a> <?=gettext("page."); ?><br>
802
				</span></p>
803
			</td>
804
			</tr>
805
		</table>
806
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
807
		<tr>
808
			<td width="25%" class="listhdrr"><?=gettext("DUID");?></td>
809
			<td width="15%" class="listhdrr"><?=gettext("IPv6 address");?></td>
810
			<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
811
			<td width="30%" class="listhdr"><?=gettext("Description");?></td>
812
			<td width="10%" class="list">
813
			<table border="0" cellspacing="0" cellpadding="1">
814
			<tr>
815
			<td valign="middle" width="17"></td>
816
			<td valign="middle"><a href="services_dhcpv6_edit.php?if=<?=$if;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
817
			</tr>
818
			</table>
819
			</td>
820
		</tr>
821
			<?php if(is_array($a_maps)): ?>
822
			<?php $i = 0; foreach ($a_maps as $mapent): ?>
823
			<?php if($mapent['duid'] <> "" or $mapent['ipaddrv6'] <> ""): ?>
824
		<tr>
825
		<td class="listlr" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
826
			<?=htmlspecialchars($mapent['duid']);?>
827
		</td>
828
		<td class="listr" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
829
			<?=htmlspecialchars($mapent['ipaddrv6']);?>&nbsp;
830
		</td>
831
		<td class="listr" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
832
			<?=htmlspecialchars($mapent['hostname']);?>&nbsp;
833
		</td>
834
		<td class="listbg" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
835
			<?=htmlspecialchars($mapent['descr']);?>&nbsp;
836
		</td>
837
		<td valign="middle" nowrap class="list">
838
			<table border="0" cellspacing="0" cellpadding="1">
839
			<tr>
840
			<td valign="middle"><a href="services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
841
			<td valign="middle"><a href="services_dhcpv6.php?if=<?=$if;?>&act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this mapping?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
842
			</tr>
843
			</table>
844
		</td>
845
		</tr>
846
		<?php endif; ?>
847
		<?php $i++; endforeach; ?>
848
		<?php endif; ?>
849
		<tr>
850
		<td class="list" colspan="4"></td>
851
		<td class="list">
852
			<table border="0" cellspacing="0" cellpadding="1">
853
			<tr>
854
			<td valign="middle" width="17"></td>
855
			<td valign="middle"><a href="services_dhcpv6_edit.php?if=<?=$if;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
856
			</tr>
857
			</table>
858
		</td>
859
		</tr>
860
		</table>
861
	</div>
862
</td>
863
</tr>
864
</table>
865
</form>
866
<script language="JavaScript">
867
<!--
868
enable_change(false);
869
//-->
870
</script>
871
<?php include("fend.inc"); ?>
872
</body>
873
</html>
(148-148/238)