Projet

Général

Profil

Télécharger (36,3 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / services_dhcpv6.php @ 7e736f38

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 (https://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
require_once("filter.inc");
49

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

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

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

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

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

    
78
$iflist = get_configured_interface_with_descr();
79
$iflist = array_merge($iflist, get_configured_pppoe_server_interfaces());
80

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

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

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

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

    
134
$dhcrelay_enabled = false;
135
$dhcrelaycfg = $config['dhcrelay6'];
136

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

    
145
if ($_POST) {
146

    
147
	unset($input_errors);
148

    
149
	$old_dhcpdv6_enable = ($pconfig['enable'] == true);
150
	$new_dhcpdv6_enable = ($_POST['enable'] ? true : false);
151
	$dhcpdv6_enable_changed = ($old_dhcpdv6_enable != $new_dhcpdv6_enable);
152

    
153
	$pconfig = $_POST;
154

    
155
	$numberoptions = array();
156
	for($x=0; $x<99; $x++) {
157
		if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
158
			$numbervalue = array();
159
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
160
			$numbervalue['value'] = htmlspecialchars($_POST["value{$x}"]);
161
			$numberoptions['item'][] = $numbervalue;
162
		}
163
	}
164
	// Reload the new pconfig variable that the forum uses.
165
	$pconfig['numberoptions'] = $numberoptions;
166

    
167
	/* input validation */
168
	if ($_POST['enable']) {
169
		$reqdfields = explode(" ", "range_from range_to");
170
		$reqdfieldsn = array(gettext("Range begin"),gettext("Range end"));
171

    
172
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
173

    
174
		if (($_POST['prefixrange_from'] && !is_ipaddrv6($_POST['prefixrange_from'])))
175
			$input_errors[] = gettext("A valid range must be specified.");
176
		if (($_POST['prefixrange_to'] && !is_ipaddrv6($_POST['prefixrange_to'])))
177
			$input_errors[] = gettext("A valid prefix range must be specified.");
178
		if (($_POST['range_from'] && !is_ipaddrv6($_POST['range_from'])))
179
			$input_errors[] = gettext("A valid range must be specified.");
180
		if (($_POST['range_to'] && !is_ipaddrv6($_POST['range_to'])))
181
			$input_errors[] = gettext("A valid range must be specified.");
182
		if (($_POST['gateway'] && !is_ipaddrv6($_POST['gateway'])))
183
			$input_errors[] = gettext("A valid IPv6 address must be specified for the gateway.");
184
		if (($_POST['dns1'] && !is_ipaddrv6($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv6($_POST['dns2'])))
185
			$input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary DNS servers.");
186

    
187
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
188
			$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
189
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
190
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
191
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
192
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
193
		if ($_POST['domainsearchlist']) {
194
			$domain_array=preg_split("/[ ;]+/",$_POST['domainsearchlist']);
195
			foreach ($domain_array as $curdomain) {
196
				if (!is_domain($curdomain)) {
197
					$input_errors[] = gettext("A valid domain search list must be specified.");
198
					break;
199
				}
200
			}
201
		}
202

    
203
		if (($_POST['ntp1'] && !is_ipaddrv6($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv6($_POST['ntp2'])))
204
			$input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary NTP servers.");
205
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
206
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
207
		if ($_POST['tftp'] && !is_ipaddr($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
208
			$input_errors[] = gettext("A valid IPv6 address or hostname must be specified for the TFTP server.");
209
		if (($_POST['bootfile_url'] && !is_URL($_POST['bootfile_url'])))
210
			$input_errors[] = gettext("A valid URL must be specified for the network bootfile.");
211

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

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

    
231
			if (is_ipaddrv6($ifcfgip)) {
232
				if ((! is_inrange_v6($_POST['range_from'], $subnet_start, $subnet_end)) ||
233
			   	 (! is_inrange_v6($_POST['range_to'], $subnet_start, $subnet_end))) {
234
					$input_errors[] = gettext("The specified range lies outside of the current subnet.");
235
				}
236
			}
237
			/* "from" cannot be higher than "to" */
238
			if (inet_pton($_POST['range_from']) > inet_pton($_POST['range_to']))
239
				$input_errors[] = gettext("The range is invalid (first element higher than second element).");
240

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

    
245

    
246
			/* Verify static mappings do not overlap:
247
			   - available DHCP range
248
			   - prefix delegation range (FIXME: still need to be completed) */
249
			$dynsubnet_start = inet_pton($_POST['range_from']);
250
			$dynsubnet_end = inet_pton($_POST['range_to']);
251

    
252
			if(is_array($a_maps)) {
253
				foreach ($a_maps as $map) {
254
					if (empty($map['ipaddrv6']))
255
						continue;
256
					if ((inet_pton($map['ipaddrv6']) > $dynsubnet_start) &&
257
						(inet_pton($map['ipaddrv6']) < $dynsubnet_end)) {
258
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
259
						break;
260
					}
261
				}
262
			}
263
		}
264
	}
265

    
266
	if (!$input_errors) {
267
		if (!is_array($config['dhcpdv6'][$if]))
268
			$config['dhcpdv6'][$if] = array();
269
		if (!is_array($config['dhcpdv6'][$if]['range']))
270
			$config['dhcpdv6'][$if]['range'] = array();
271
		if (!is_array($config['dhcpdv6'][$if]['prefixrange']))
272
			$config['dhcpdv6'][$if]['prefixrange'] = array();
273

    
274
		$config['dhcpdv6'][$if]['range']['from'] = $_POST['range_from'];
275
		$config['dhcpdv6'][$if]['range']['to'] = $_POST['range_to'];
276
		$config['dhcpdv6'][$if]['prefixrange']['from'] = $_POST['prefixrange_from'];
277
		$config['dhcpdv6'][$if]['prefixrange']['to'] = $_POST['prefixrange_to'];
278
		$config['dhcpdv6'][$if]['prefixrange']['prefixlength'] = $_POST['prefixrange_length'];
279
		$config['dhcpdv6'][$if]['defaultleasetime'] = $_POST['deftime'];
280
		$config['dhcpdv6'][$if]['maxleasetime'] = $_POST['maxtime'];
281
		$config['dhcpdv6'][$if]['netmask'] = $_POST['netmask'];
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]['domain'] = $_POST['domain'];
292
		$config['dhcpdv6'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
293
		$config['dhcpdv6'][$if]['enable'] = ($_POST['enable']) ? true : false;
294
		$config['dhcpdv6'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
295
		$config['dhcpdv6'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
296

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

    
303
		$config['dhcpdv6'][$if]['tftp'] = $_POST['tftp'];
304
		$config['dhcpdv6'][$if]['ldap'] = $_POST['ldap'];
305
		$config['dhcpdv6'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
306
		$config['dhcpdv6'][$if]['bootfile_url'] = $_POST['bootfile_url'];
307
		$config['dhcpdv6'][$if]['dhcpv6leaseinlocaltime'] = $_POST['dhcpv6leaseinlocaltime'];
308

    
309
		// Handle the custom options rowhelper
310
		if(isset($config['dhcpdv6'][$if]['numberoptions']['item']))
311
			unset($config['dhcpdv6'][$if]['numberoptions']['item']);
312

    
313
		$config['dhcpdv6'][$if]['numberoptions'] = $numberoptions;
314

    
315
		write_config();
316

    
317
		$retval = 0;
318
		$retvaldhcp = 0;
319
		$retvaldns = 0;
320
		/* Stop DHCPv6 so we can cleanup leases */
321
		killbypid("{$g['dhcpd_chroot_path']}{$g['varrun_path']}/dhcpdv6.pid");
322
		// dhcp_clean_leases();
323
		/* dnsmasq_configure calls dhcpd_configure */
324
		/* no need to restart dhcpd twice */
325
		if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))	{
326
			$retvaldns = services_dnsmasq_configure();
327
			if ($retvaldns == 0) {
328
				clear_subsystem_dirty('hosts');
329
				clear_subsystem_dirty('staticmaps');
330
			}
331
		} else {
332
			$retvaldhcp = services_dhcpd_configure();
333
			if ($retvaldhcp == 0)
334
				clear_subsystem_dirty('staticmaps');
335
		}
336
		if ($dhcpdv6_enable_changed)
337
			$retvalfc = filter_configure();
338
		if($retvaldhcp == 1 || $retvaldns == 1 || $retvalfc == 1)
339
			$retval = 1;
340
		$savemsg = get_std_save_message($retval);
341
	}
342
}
343

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

    
358
$pgtitle = array(gettext("Services"),gettext("DHCPv6 server"));
359
$shortcut_section = "dhcp6";
360

    
361
include("head.inc");
362

    
363
?>
364

    
365
<script type="text/javascript" src="/javascript/row_helper.js">
366
</script>
367

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

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

    
404
	function show_shownumbervalue() {
405
		document.getElementById("shownumbervaluebox").innerHTML='';
406
		aodiv = document.getElementById('shownumbervalue');
407
		aodiv.style.display = "block";
408
	}
409

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

    
433
	function show_netboot_config() {
434
		document.getElementById("shownetbootbox").innerHTML='';
435
		aodiv = document.getElementById('shownetboot');
436
		aodiv.style.display = "block";
437
	}
438
</script>
439

    
440
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
441
<?php include("fbegin.inc"); ?>
442
<form action="services_dhcpv6.php" method="post" name="iform" id="iform">
443
<?php if ($input_errors) print_input_errors($input_errors); ?>
444
<?php if ($savemsg) print_info_box($savemsg); ?>
445
<?php
446
	if ($dhcrelay_enabled) {
447
		echo gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.");
448
		include("fend.inc");
449
		echo "</body>";
450
		echo "</html>";
451
		exit;
452
	}
453
?>
454
<?php if (is_subsystem_dirty('staticmaps')): ?><p>
455
<?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>
456
<?php endif; ?>
457
<table width="100%" border="0" cellpadding="0" cellspacing="0">
458
<tr><td>
459
<?php
460
	/* active tabs */
461
	$tab_array = array();
462
	$tabscounter = 0;
463
	$i = 0;
464
	foreach ($iflist as $ifent => $ifname) {
465
		$oc = $config['interfaces'][$ifent];
466
		if ((is_array($config['dhcpdv6'][$ifent]) && !isset($config['dhcpdv6'][$ifent]['enable']) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6'])))) ||
467
			(!is_array($config['dhcpdv6'][$ifent]) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6'])))))
468
			continue;
469
		if ($ifent == $if)
470
			$active = true;
471
		else
472
			$active = false;
473
		$tab_array[] = array($ifname, $active, "services_dhcpv6.php?if={$ifent}");
474
		$tabscounter++;
475
	}
476
	/* tack on PPPoE or PPtP servers here */
477
	/* pppoe server */
478
	if (is_array($config['pppoes']['pppoe'])) {
479
		foreach($config['pppoes']['pppoe'] as $pppoe) {
480
			if ($pppoe['mode'] == "server") {
481
				$ifent = "poes". $pppoe['pppoeid'];
482
				$ifname = strtoupper($ifent);
483
				if ($ifent == $if)
484
					$active = true;
485
				else
486
					$active = false;
487
				$tab_array[] = array($ifname, $active, "services_dhcpv6.php?if={$ifent}");
488
				$tabscounter++;
489
			}
490
		}
491
	}
492
	if ($tabscounter == 0) {
493
		echo "</td></tr></table></form>";
494
		include("fend.inc");
495
		echo "</body>";
496
		echo "</html>";
497
		exit;
498
	}
499
	display_top_tabs($tab_array);
500
?>
501
</td></tr>
502
<tr><td class="tabnavtbl">
503
<?php
504
$tab_array = array();
505
$tab_array[] = array(gettext("DHCPv6 Server"),         true,  "services_dhcpv6.php?if={$if}");
506
$tab_array[] = array(gettext("Router Advertisements"), false, "services_router_advertisements.php?if={$if}");
507
display_top_tabs($tab_array);
508
?>
509
</td></tr>
510
<tr>
511
<td>
512
	<div id="mainarea">
513
		<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
514
		<tr>
515
			<td width="22%" valign="top" class="vncellreq"><?=gettext("DHCPv6 Server");?></td>
516
			<td width="78%" class="vtable">
517
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false);">
518
			<strong><?php printf(gettext("Enable DHCPv6 server on " .
519
			"%s " .
520
			"interface"),htmlspecialchars($iflist[$if]));?></strong></td>
521
			</tr>
522
			<tr>
523
			<?php
524
			/* the PPPoE Server could well have no IPv6 address and operate fine with just link-local, just hide these */
525
			if(is_ipaddrv6($ifcfgip)) {
526
			?>
527
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet");?></td>
528
			<td width="78%" class="vtable">
529
				<?=gen_subnetv6($ifcfgip, $ifcfgsn);?>
530
			</td>
531
			</tr>
532
			<tr>
533
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet mask");?></td>
534
			<td width="78%" class="vtable">
535
				<?=$ifcfgsn;?> bits
536
			</td>
537
			</tr>
538
			<tr>
539
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Available range");?></td>
540
			<td width="78%" class="vtable">
541
			<?php
542
				$range_from = gen_subnetv6($ifcfgip, $ifcfgsn);
543
				$range_from++;
544
				echo $range_from;
545

    
546
			?>
547
			-
548
			<?php
549
				$range_to = gen_subnetv6_max($ifcfgip, $ifcfgsn);
550
				echo $range_to;
551
			?>
552
			</td>
553
			</tr>
554
			<?php } ?>
555

    
556
			<?php if($is_olsr_enabled): ?>
557
			<tr>
558
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
559
			<td width="78%" class="vtable">
560
				<select name="netmask" class="formselect" id="netmask">
561
				<?php
562
				for ($i = 128; $i > 0; $i--) {
563
					if($i <> 127) {
564
						echo "<option value=\"{$i}\" ";
565
						if ($i == $pconfig['netmask']) echo "selected";
566
						echo ">" . $i . "</option>";
567
					}
568
				}
569
				?>
570
				</select>
571
			</td>
572
			</tr>
573
			<?php endif; ?>
574
			<tr>
575
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
576
			<td width="78%" class="vtable">
577
				<input name="range_from" type="text" class="formfld unknown" id="range_from" size="28" value="<?=htmlspecialchars($pconfig['range_from']);?>">
578
				&nbsp;<?=gettext("to"); ?>&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="28" value="<?=htmlspecialchars($pconfig['range_to']);?>">
579
			</td>
580
			</tr>
581
			<tr>
582
			<td width="22%" valign="top" class="vncell"><?=gettext("Prefix Delegation Range");?></td>
583
			<td width="78%" class="vtable">
584
				<input name="prefixrange_from" type="text" class="formfld unknown" id="prefixrange_from" size="28" value="<?=htmlspecialchars($pconfig['prefixrange_from']);?>">
585
				&nbsp;<?=gettext("to"); ?>&nbsp; <input name="prefixrange_to" type="text" class="formfld unknown" id="prefixrange_to" size="28" value="<?=htmlspecialchars($pconfig['prefixrange_to']);?>">
586
				&nbsp;<br/><?=gettext("Prefix Delegation Size"); ?>:&nbsp; <select name="prefixrange_length" class="formselect" id="prefixrange_length">
587
					<option value="48" <?php if($pconfig['prefixrange_length'] == 48) echo "selected"; ?>>48</option>
588
					<option value="52" <?php if($pconfig['prefixrange_length'] == 52) echo "selected"; ?>>52</option>
589
					<option value="56" <?php if($pconfig['prefixrange_length'] == 56) echo "selected"; ?>>56</option>
590
					<option value="60" <?php if($pconfig['prefixrange_length'] == 60) echo "selected"; ?>>60</option>
591
					<option value="62" <?php if($pconfig['prefixrange_length'] == 62) echo "selected"; ?>>62</option>
592
					<option value="63" <?php if($pconfig['prefixrange_length'] == 63) echo "selected"; ?>>63</option>
593
					<option value="64" <?php if($pconfig['prefixrange_length'] == 64) echo "selected"; ?>>64</option>
594
				</select> <br/>
595
				<?php echo gettext("You can define a Prefix range here for DHCP Prefix Delegation. This allows for 
596
					assigning networks to subrouters. The start and end of the range must end on boundaries of the prefix delegation size."); ?>
597
			</td>
598
			</tr>
599
			<tr>
600
			<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
601
			<td width="78%" class="vtable">
602
				<input name="dns1" type="text" class="formfld unknown" id="dns1" size="28" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
603
				<input name="dns2" type="text" class="formfld unknown" id="dns2" size="28" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
604
				<?=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.");?>
605
			</td>
606
			</tr>
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. Use the semicolon character as separator");?>
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("Time format change"); ?></td>
643
				<td width="78%" class="vtable">
644
				<table>
645
					<tr>
646
					<td>
647
						<input name="dhcpv6leaseinlocaltime" type="checkbox" id="dhcpv6leaseinlocaltime" value="yes" <?php if ($pconfig['dhcpv6leaseinlocaltime']) echo "checked"; ?>>
648
					</td>
649
					<td>
650
						<strong>
651
							<?=gettext("Change DHCPv6 display lease time from UTC to local time."); ?>
652
						</strong>
653
					</td>
654
					</tr>
655
					<tr>
656
					<td>&nbsp;</td>
657
					<td>
658
						<span class="red"><strong><?=gettext("Note:");?></strong></span> <?=gettext("By default DHCPv6 leases are displayed in UTC time.  By checking this 
659
						box DHCPv6 lease time will be displayed in local time and set to time zone selected.  This will be used for all DHCPv6 interfaces lease time."); ?>
660
					
661
					</td>
662
					</tr>
663
				</table>
664
				</td>
665
			</tr>
666
			<tr>
667
			<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
668
			<td width="78%" class="vtable">
669
				<div id="showddnsbox">
670
					<input type="button" onClick="show_ddns_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Dynamic DNS");?></a>
671
				</div>
672
				<div id="showddns" style="display:none">
673
					<input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>&nbsp;
674
					<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
675
					<p>
676
					<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="28" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
677
					<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
678
					<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?>
679
				</div>
680
			</td>
681
			</tr>
682
			<tr>
683
			<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
684
			<td width="78%" class="vtable">
685
				<div id="showntpbox">
686
					<input type="button" onClick="show_ntp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show NTP configuration");?></a>
687
				</div>
688
				<div id="showntp" style="display:none">
689
					<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="28" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
690
					<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="28" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
691
				</div>
692
			</td>
693
			</tr>
694
			<!-- ISC dhcpd does not support tftp for ipv6 yet. See redmine #2016
695
			<tr>
696
			<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
697
			<td width="78%" class="vtable">
698
			<div id="showtftpbox">
699
				<input type="button" onClick="show_tftp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show TFTP configuration");?></a>
700
			</div>
701
			<div id="showtftp" style="display:none">
702
				<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>"><br>
703
				<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
704
			</div>
705
			</td>
706
			</tr>
707
			-->
708
			<tr>
709
			<td width="22%" valign="top" class="vncell"><?=gettext("LDAP URI");?></td>
710
			<td width="78%" class="vtable">
711
				<div id="showldapbox">
712
					<input type="button" onClick="show_ldap_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show LDAP configuration");?></a>
713
				</div>
714
				<div id="showldap" style="display:none">
715
					<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>"><br>
716
					<?=gettext("Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com");?>
717
				</div>
718
			</td>
719
			</tr>
720
			<tr>
721
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable network booting");?></td>
722
			<td width="78%" class="vtable">
723
				<div id="shownetbootbox">
724
					<input type="button" onClick="show_netboot_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Network booting");?></a>
725
				</div>
726
				<div id="shownetboot" style="display:none">
727
					<input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>&nbsp;
728
					<b><?=gettext("Enables network booting.");?></b>
729
					<p>
730
					<?=gettext("Enter the Bootfile URL");?>
731
					<input name="bootfile_url" type="text" class="formfld unknown" id="bootfile_url" size="28" value="<?=htmlspecialchars($pconfig['bootfile_url']);?>">
732
				</div>
733
			</td>
734
			</tr>
735
			<tr>
736
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
737
			<td width="78%" class="vtable">
738
				<div id="shownumbervaluebox">
739
					<input type="button" onClick="show_shownumbervalue()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Additional BOOTP/DHCP Options");?></a>
740
				</div>
741
				<div id="shownumbervalue" style="display:none">
742
				<table id="maintable">
743
				<tbody>
744
				<tr>
745
				<td colspan="3">
746
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
747
					<?=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>
748
					</div>
749
				</td>
750
				</tr>
751
				<tr>
752
				<td><div id="onecolumn"><?=gettext("Number");?></div></td>
753
				<td><div id="twocolumn"><?=gettext("Value");?></div></td>
754
				</tr>
755
				<?php $counter = 0; ?>
756
				<?php
757
					if($pconfig['numberoptions'])
758
						foreach($pconfig['numberoptions']['item'] as $item):
759
				?>
760
					<?php
761
						$number = $item['number'];
762
						$value = $item['value'];
763
					?>
764
				<tr>
765
				<td>
766
					<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
767
				</td>
768
				<td>
769
					<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld" id="value<?php echo $counter; ?>" size="55" value="<?=htmlspecialchars($value);?>" />
770
				</td>
771
				<td>
772
					<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="<?=gettext("Delete");?>" />
773
				</td>
774
				</tr>
775
				<?php $counter++; ?>
776
				<?php endforeach; ?>
777
				</tbody>
778
				<tfoot>
779
				</tfoot>
780
				</table>
781
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
782
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
783
				</a>
784
				<script type="text/javascript">
785
					field_counter_js = 2;
786
					rows = 1;
787
					totalrows = <?php echo $counter; ?>;
788
					loaded = <?php echo $counter; ?>;
789
				</script>
790
				</div>
791

    
792
				</td>
793
			</tr>
794
			<tr>
795
			<td width="22%" valign="top">&nbsp;</td>
796
			<td width="78%">
797
				<input name="if" type="hidden" value="<?=$if;?>">
798
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)">
799
			</td>
800
			</tr>
801
			<tr>
802
			<td width="22%" valign="top">&nbsp;</td>
803
			<td width="78%"> <p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br>
804
				</strong></span><?=gettext("The DNS servers entered in"); ?> <a href="system.php"><?=gettext("System: " .
805
				"General setup"); ?></a> <?=gettext("(or the"); ?> <a href="services_dnsmasq.php"><?=gettext("DNS " .
806
				"forwarder"); ?></a>, <?=gettext("if enabled)"); ?> </span><span class="vexpl"><?=gettext("will " .
807
				"be assigned to clients by the DHCP server."); ?><br>
808
				<br>
809
				<?=gettext("The DHCP lease table can be viewed on the"); ?> <a href="status_dhcpv6_leases.php"><?=gettext("Status: " .
810
				"DHCPv6 leases"); ?></a> <?=gettext("page."); ?><br>
811
				</span></p>
812
			</td>
813
			</tr>
814
		</table>
815
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
816
		<tr>
817
			<td colspan="4" valign="top" class="listtopic"><?=gettext("DHCPv6 Static Mappings for this interface.");?></td>
818
			<td>&nbsp;</td>
819
		</tr>
820
		<tr>
821
			<td width="25%" class="listhdrr"><?=gettext("DUID");?></td>
822
			<td width="15%" class="listhdrr"><?=gettext("IPv6 address");?></td>
823
			<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
824
			<td width="30%" class="listhdr"><?=gettext("Description");?></td>
825
			<td width="10%" class="list">
826
			<table border="0" cellspacing="0" cellpadding="1">
827
			<tr>
828
			<td valign="middle" width="17"></td>
829
			<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>
830
			</tr>
831
			</table>
832
			</td>
833
		</tr>
834
			<?php if(is_array($a_maps)): ?>
835
			<?php $i = 0; foreach ($a_maps as $mapent): ?>
836
			<?php if($mapent['duid'] <> "" or $mapent['ipaddrv6'] <> ""): ?>
837
		<tr>
838
		<td class="listlr" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
839
			<?=htmlspecialchars($mapent['duid']);?>
840
		</td>
841
		<td class="listr" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
842
			<?=htmlspecialchars($mapent['ipaddrv6']);?>&nbsp;
843
		</td>
844
		<td class="listr" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
845
			<?=htmlspecialchars($mapent['hostname']);?>&nbsp;
846
		</td>
847
		<td class="listbg" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
848
			<?=htmlspecialchars($mapent['descr']);?>&nbsp;
849
		</td>
850
		<td valign="middle" nowrap="nowrap" class="list">
851
			<table border="0" cellspacing="0" cellpadding="1">
852
			<tr>
853
			<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>
854
			<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>
855
			</tr>
856
			</table>
857
		</td>
858
		</tr>
859
		<?php endif; ?>
860
		<?php $i++; endforeach; ?>
861
		<?php endif; ?>
862
		<tr>
863
		<td class="list" colspan="4"></td>
864
		<td class="list">
865
			<table border="0" cellspacing="0" cellpadding="1">
866
			<tr>
867
			<td valign="middle" width="17"></td>
868
			<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>
869
			</tr>
870
			</table>
871
		</td>
872
		</tr>
873
		</table>
874
	</div>
875
</td>
876
</tr>
877
</table>
878
</form>
879
<script language="JavaScript">
880
<!--
881
enable_change(false);
882
//-->
883
</script>
884
<?php include("fend.inc"); ?>
885
</body>
886
</html>
(151-151/246)