Project

General

Profile

« Previous | Next » 

Revision f3475477

Added by Darren Embry about 13 years ago

split dhcpv6 server and ra #2361

View differences:

usr/local/www/services_router_advertisements.php
1 1
<?php
2 2
/* $Id$ */
3 3
/*
4
	services_dhcpv6.php
5
	parts of m0n0wall (http://m0n0.ch/wall)
4
	services_router_advertisements.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 6

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

  
40 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*
41
##|*IDENT=page-services-router-advertisements
42
##|*NAME=Services: Router advertisementspage
43
##|*DESCR=Allow access to the 'Services: Router Advertisements' page.
44
##|*MATCH=services_router_advertisements.php*
45 45
##|-PRIV
46 46

  
47 47
require("guiconfig.inc");
......
71 71
}
72 72

  
73 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>";
74
	$savemsg = "<p><b>" . gettext("The DHCPv6 Server can only be enabled on interfaces configured with static IP addresses") . ".</b></p>" .
75
		   "<p><b>" . gettext("Only interfaces configured with a static IP will be shown") . ".</b></p>";
75 76

  
76 77
$iflist = get_configured_interface_with_descr();
77 78

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

  
132
$ifcfgip = get_interface_ipv6($if);
133
$ifcfgsn = get_interface_subnetv6($if);
134

  
135
/*   set the enabled flag which will tell us if DHCP relay is enabled
136
 *   on any interface. We will use this to disable DHCP server since
137
 *   the two are not compatible with each other.
138
 */
139

  
140
$dhcrelay_enabled = false;
141
$dhcrelaycfg = $config['dhcrelay6'];
142

  
143
if(is_array($dhcrelaycfg)) {
144
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
145
		if (isset($dhcrelayifconf['enable']) && isset($iflist[$dhcrelayif]) &&
146
			(!link_interface_to_bridge($dhcrelayif)))
147
			$dhcrelay_enabled = true;
148
	}
149
}
150

  
151
function is_inrange($test, $start, $end) {
152
	if ( (inet_pton($test) < inet_pton($end)) && (inet_pton($test) > inet_pton($start)) )
153
		return true;
154
	else
155
		return false;
156 98
}
157 99

  
158 100
$advertise_modes = array("disabled" => "Disabled",
159
					"router" => "Router Only",
160
					"unmanaged" => "Unmanaged",
161
					"managed" => "Managed",
162
					"assist" => "Assisted");
101
			 "router" => "Router Only",
102
			 "unmanaged" => "Unmanaged",
103
			 "managed" => "Managed",
104
			 "assist" => "Assisted");
163 105
$priority_modes = array("low" => "Low",
164
					"medium" => "Normal",
165
					"high" => "High");
106
			"medium" => "Normal",
107
			"high" => "High");
166 108
$carplist = get_configured_carp_interface_list();
167 109

  
168 110
if ($_POST) {
......
171 113

  
172 114
	$pconfig = $_POST;
173 115

  
174
	$numberoptions = array();
175
	for($x=0; $x<99; $x++) {
176
		if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
177
			$numbervalue = array();
178
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
179
			$numbervalue['value'] = htmlspecialchars($_POST["value{$x}"]);
180
			$numberoptions['item'][] = $numbervalue;
181
		}
182
	}
183
	// Reload the new pconfig variable that the forum uses.
184
	$pconfig['numberoptions'] = $numberoptions;
185

  
186
	/* input validation */
187
	if ($_POST['enable']) {
188
		$reqdfields = explode(" ", "range_from range_to");
189
		$reqdfieldsn = array(gettext("Range begin"),gettext("Range end"));
190

  
191
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
192

  
193
		if (($_POST['prefixrange_from'] && !is_ipaddrv6($_POST['prefixrange_from'])))
194
			$input_errors[] = gettext("A valid range must be specified.");
195
		if (($_POST['prefixrange_to'] && !is_ipaddrv6($_POST['prefixrange_to'])))
196
			$input_errors[] = gettext("A valid prefix range must be specified.");
197
		if (($_POST['range_from'] && !is_ipaddrv6($_POST['range_from'])))
198
			$input_errors[] = gettext("A valid range must be specified.");
199
		if (($_POST['range_to'] && !is_ipaddrv6($_POST['range_to'])))
200
			$input_errors[] = gettext("A valid range must be specified.");
201
		if (($_POST['gateway'] && !is_ipaddrv6($_POST['gateway'])))
202
			$input_errors[] = gettext("A valid IPv6 address must be specified for the gateway.");
203
		if (($_POST['dns1'] && !is_ipaddrv6($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv6($_POST['dns2'])))
204
			$input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary DNS servers.");
205

  
206
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
207
			$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
208
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
209
			$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
210
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
211
			$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
212
		if ($_POST['domainsearchlist']) {
213
			$domain_array=preg_split("/[ ;]+/",$_POST['domainsearchlist']);
214
			foreach ($domain_array as $curdomain) {
215
				if (!is_domain($curdomain)) {
216
					$input_errors[] = gettext("A valid domain search list must be specified.");
217
					break;
218
				}
219
			}
220
		}
221

  
222
		if (($_POST['ntp1'] && !is_ipaddrv6($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv6($_POST['ntp2'])))
223
			$input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary NTP servers.");
224
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
225
			$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
226
		if ($_POST['tftp'] && !is_ipaddr($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
227
			$input_errors[] = gettext("A valid IPv6 address or hostname must be specified for the TFTP server.");
228
		if (($_POST['nextserver'] && !is_ipaddrv6($_POST['nextserver'])))
229
			$input_errors[] = gettext("A valid IPv6 address must be specified for the network boot server.");
230

  
231
		// Disallow a range that includes the virtualip
232
		if (is_array($config['virtualip']['vip'])) {
233
			foreach($config['virtualip']['vip'] as $vip) {
234
				if($vip['interface'] == $if)
235
					if($vip['subnetv6'] && is_inrange($vip['subnetv6'], $_POST['range_from'], $_POST['range_to']))
236
						$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IPv6 address %s."),$vip['subnetv6']);
237
			}
238
		}
239

  
240
		$noip = false;
241
		if(is_array($a_maps))
242
			foreach ($a_maps as $map)
243
				if (empty($map['ipaddrv6']))
244
					$noip = true;
245
		if (!$input_errors) {
246
			/* make sure the range lies within the current subnet */
247
			$subnet_start = gen_subnetv6($ifcfgip, $ifcfgsn);
248
			$subnet_end = gen_subnetv6_max($ifcfgip, $ifcfgsn);
249

  
250
			if ((! is_inrange($_POST['range_from'], $subnet_start, $subnet_end)) ||
251
			    (! is_inrange($_POST['range_to'], $subnet_start, $subnet_end))) {
252
				$input_errors[] = gettext("The specified range lies outside of the current subnet.");
253
			}
254

  
255
			/* "from" cannot be higher than "to" */
256
			if (inet_pton($_POST['range_from']) > inet_pton($_POST['range_to']))
257
				$input_errors[] = gettext("The range is invalid (first element higher than second element).");
258

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

  
263

  
264
			/* Verify static mappings do not overlap:
265
			   - available DHCP range
266
			   - prefix delegation range (FIXME: still need to be completed) */
267
			$dynsubnet_start = inet_pton($_POST['range_from']);
268
			$dynsubnet_end = inet_pton($_POST['range_to']);
269

  
270
			if(is_array($a_maps)) {
271
				foreach ($a_maps as $map) {
272
					if (empty($map['ipaddrv6']))
273
						continue;
274
					if ((inet_pton($map['ipaddrv6']) > $dynsubnet_start) &&
275
						(inet_pton($map['ipaddrv6']) < $dynsubnet_end)) {
276
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
277
						break;
278
					}
279
				}
280
			}
281
		}
282
	}
283

  
284 116
	if (!$input_errors) {
285 117
		if (!is_array($config['dhcpdv6'][$if]))
286 118
			$config['dhcpdv6'][$if] = array();
287
		if (!is_array($config['dhcpdv6'][$if]['range']))
288
			$config['dhcpdv6'][$if]['range'] = array();
289
		if (!is_array($config['dhcpdv6'][$if]['prefixrange']))
290
			$config['dhcpdv6'][$if]['prefixrange'] = array();
291 119

  
292 120
		$config['dhcpdv6'][$if]['ramode'] = $_POST['ramode'];
293 121
		$config['dhcpdv6'][$if]['rapriority'] = $_POST['rapriority'];
294 122
		$config['dhcpdv6'][$if]['rainterface'] = $_POST['rainterface'];
295 123
		
296
		$config['dhcpdv6'][$if]['range']['from'] = $_POST['range_from'];
297
		$config['dhcpdv6'][$if]['range']['to'] = $_POST['range_to'];
298
		$config['dhcpdv6'][$if]['prefixrange']['from'] = $_POST['prefixrange_from'];
299
		$config['dhcpdv6'][$if]['prefixrange']['to'] = $_POST['prefixrange_to'];
300
		$config['dhcpdv6'][$if]['prefixrange']['prefixlength'] = $_POST['prefixrange_length'];
301
		$config['dhcpdv6'][$if]['defaultleasetime'] = $_POST['deftime'];
302
		$config['dhcpdv6'][$if]['maxleasetime'] = $_POST['maxtime'];
303
		$config['dhcpdv6'][$if]['netmask'] = $_POST['netmask'];
304
		$previous = $config['dhcpdv6'][$if]['failover_peerip'];
305
		if($previous <> $_POST['failover_peerip'])
306
			mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
307

  
308
		$config['dhcpdv6'][$if]['failover_peerip'] = $_POST['failover_peerip'];
309

  
310
		unset($config['dhcpdv6'][$if]['winsserver']);
311

  
312
		unset($config['dhcpdv6'][$if]['dnsserver']);
313
		if ($_POST['dns1'])
314
			$config['dhcpdv6'][$if]['dnsserver'][] = $_POST['dns1'];
315
		if ($_POST['dns2'])
316
			$config['dhcpdv6'][$if]['dnsserver'][] = $_POST['dns2'];
317

  
318
		$config['dhcpdv6'][$if]['domain'] = $_POST['domain'];
319
		$config['dhcpdv6'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
320
		$config['dhcpdv6'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
321
		$config['dhcpdv6'][$if]['enable'] = ($_POST['enable']) ? true : false;
322
		$config['dhcpdv6'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
323
		$config['dhcpdv6'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
324

  
325
		unset($config['dhcpdv6'][$if]['ntpserver']);
326
		if ($_POST['ntp1'])
327
			$config['dhcpdv6'][$if]['ntpserver'][] = $_POST['ntp1'];
328
		if ($_POST['ntp2'])
329
			$config['dhcpdv6'][$if]['ntpserver'][] = $_POST['ntp2'];
330

  
331
		$config['dhcpdv6'][$if]['tftp'] = $_POST['tftp'];
332
		$config['dhcpdv6'][$if]['ldap'] = $_POST['ldap'];
333
		$config['dhcpdv6'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
334
		$config['dhcpdv6'][$if]['nextserver'] = $_POST['nextserver'];
335
		$config['dhcpdv6'][$if]['filename'] = $_POST['filename'];
336
		$config['dhcpdv6'][$if]['rootpath'] = $_POST['rootpath'];
337
		$config['dhcpdv6'][$if]['dhcpv6leaseinlocaltime'] = $_POST['dhcpv6leaseinlocaltime'];
338

  
339
		// Handle the custom options rowhelper
340
		if(isset($config['dhcpdv6'][$if]['numberoptions']['item']))
341
			unset($config['dhcpdv6'][$if]['numberoptions']['item']);
342

  
343
		$config['dhcpdv6'][$if]['numberoptions'] = $numberoptions;
344

  
345 124
		write_config();
346

  
347
		$retval = 0;
348
		$retvaldhcp = 0;
349
		$retvaldns = 0;
350
		/* Stop DHCPv6 so we can cleanup leases */
351
		killbyname("dhcpd -6");
352
		// dhcp_clean_leases();
353
		/* dnsmasq_configure calls dhcpd_configure */
354
		/* no need to restart dhcpd twice */
355
		if (isset($config['dnsmasq']['regdhcpstatic']))	{
356
			$retvaldns = services_dnsmasq_configure();
357
			if ($retvaldns == 0) {
358
				clear_subsystem_dirty('hosts');
359
				clear_subsystem_dirty('staticmaps');
360
			}
361
		} else {
362
			$retvaldhcp = services_dhcpd_configure();
363
			if ($retvaldhcp == 0)
364
				clear_subsystem_dirty('staticmaps');
365
		}
366
		if($retvaldhcp == 1 || $retvaldns == 1)
367
			$retval = 1;
125
		$retval = services_radvd_configure();
368 126
		$savemsg = get_std_save_message($retval);
369 127
	}
370 128
}
371 129

  
372
if ($_GET['act'] == "del") {
373
	if ($a_maps[$_GET['id']]) {
374
		unset($a_maps[$_GET['id']]);
375
		write_config();
376
		if(isset($config['dhcpdv6'][$if]['enable'])) {
377
			mark_subsystem_dirty('staticmapsv6');
378
			if (isset($config['dnsmasq']['regdhcpstaticv6']))
379
				mark_subsystem_dirty('hosts');
380
		}
381
		header("Location: services_dhcpv6.php?if={$if}");
382
		exit;
383
	}
384
}
385

  
386
$pgtitle = array(gettext("Services"),gettext("DHCPv6 server"));
387
$statusurl = "status_dhcpv6_leases.php";
388
$logurl = "diag_logs_dhcp.php";
130
$pgtitle = array(gettext("Services"),gettext("Router advertisements"));
389 131

  
390 132
include("head.inc");
391 133

  
392 134
?>
393 135

  
394
<script type="text/javascript" src="/javascript/row_helper.js">
395
</script>
396

  
397
<script type="text/javascript">
398
	rowname[0] = "number";
399
	rowtype[0] = "textbox";
400
	rowsize[0] = "10";
401
	rowname[1] = "value";
402
	rowtype[1] = "textbox";
403
	rowsize[1] = "55";
404
</script>
405

  
406
<script type="text/javascript" language="JavaScript">
407
	function enable_change(enable_over) {
408
		var endis;
409
		endis = !(document.iform.enable.checked || enable_over);
410
		document.iform.range_from.disabled = endis;
411
		document.iform.range_to.disabled = endis;
412
		document.iform.prefixrange_from.disabled = endis;
413
		document.iform.prefixrange_to.disabled = endis;
414
		document.iform.prefixrange_length.disabled = endis;
415
		document.iform.dns1.disabled = endis;
416
		document.iform.dns2.disabled = endis;
417
		document.iform.deftime.disabled = endis;
418
		document.iform.maxtime.disabled = endis;
419
		//document.iform.gateway.disabled = endis;
420
		document.iform.failover_peerip.disabled = endis;
421
		document.iform.dhcpv6leaseinlocaltime.disabled = endis;
422
		document.iform.domain.disabled = endis;
423
		document.iform.domainsearchlist.disabled = endis;
424
		document.iform.ddnsdomain.disabled = endis;
425
		document.iform.ddnsupdate.disabled = endis;
426
		document.iform.ntp1.disabled = endis;
427
		document.iform.ntp2.disabled = endis;
428
		//document.iform.tftp.disabled = endis;
429
		document.iform.ldap.disabled = endis;
430
		document.iform.netboot.disabled = endis;
431
		document.iform.nextserver.disabled = endis;
432
		document.iform.filename.disabled = endis;
433
		document.iform.rootpath.disabled = endis;
434
		document.iform.denyunknown.disabled = endis;
435
	}
436

  
437
	function show_shownumbervalue() {
438
		document.getElementById("shownumbervaluebox").innerHTML='';
439
		aodiv = document.getElementById('shownumbervalue');
440
		aodiv.style.display = "block";
441
	}
442

  
443
	function show_ddns_config() {
444
		document.getElementById("showddnsbox").innerHTML='';
445
		aodiv = document.getElementById('showddns');
446
		aodiv.style.display = "block";
447
	}
448
	function show_ntp_config() {
449
		document.getElementById("showntpbox").innerHTML='';
450
		aodiv = document.getElementById('showntp');
451
		aodiv.style.display = "block";
452
	}
453
	/*
454
	function show_tftp_config() {
455
		document.getElementById("showtftpbox").innerHTML='';
456
		aodiv = document.getElementById('showtftp');
457
		aodiv.style.display = "block";
458
	}
459
	*/
460
	function show_ldap_config() {
461
		document.getElementById("showldapbox").innerHTML='';
462
		aodiv = document.getElementById('showldap');
463
		aodiv.style.display = "block";
464
	}
465

  
466
	function show_netboot_config() {
467
		document.getElementById("shownetbootbox").innerHTML='';
468
		aodiv = document.getElementById('shownetboot');
469
		aodiv.style.display = "block";
470
	}
471
</script>
472

  
473 136
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
474 137
<?php include("fbegin.inc"); ?>
475
<form action="services_dhcpv6.php" method="post" name="iform" id="iform">
138
<form action="services_router_advertisements.php" method="post" name="iform" id="iform">
476 139
<?php if ($input_errors) print_input_errors($input_errors); ?>
477 140
<?php if ($savemsg) print_info_box($savemsg); ?>
478
<?php
479
	if ($dhcrelay_enabled) {
480
		echo gettext("DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.");
481
		include("fend.inc");
482
		echo "</body>";
483
		echo "</html>";
484
		exit;
485
	}
486
?>
487
<?php if (is_subsystem_dirty('staticmaps')): ?><p>
488
<?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>
489
<?php endif; ?>
490 141
<table width="100%" border="0" cellpadding="0" cellspacing="0">
491 142
<tr><td>
492 143
<?php
......
516 167
	display_top_tabs($tab_array);
517 168
?>
518 169
</td></tr>
170
<tr><td class="tabnavtbl">
171
<?php
172
$tab_array = array();
173
$tab_array[] = array(gettext("DHCPv6 Server"),         false, "services_dhcpv6.php?if={$if}");
174
$tab_array[] = array(gettext("Router Advertisements"), true,  "services_router_advertisements.php?if={$if}");
175
display_top_tabs($tab_array);
176
?>
177
</td></tr>
519 178
<tr>
520 179
<td>
521 180
	<div id="mainarea">
......
570 229
			<tr>
571 230
			<td width="22%" valign="top">&nbsp;</td>
572 231
			<td width="78%">
573
				<input name="if" type="hidden" value="<?=$if;?>">
574
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)">
575
			</td>
576
			</tr>
577
		</table>
578
	<hr>
579
		<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
580
		<tr>
581
			<td width="22%" valign="top" class="vncellreq"><?=gettext("DHCPv6 Server");?></td>
582
			<td width="78%" class="vtable">
583
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false);">
584
			<strong><?php printf(gettext("Enable DHCPv6 server on " .
585
			"%s " .
586
			"interface"),htmlspecialchars($iflist[$if]));?></strong></td>
587
			</tr>
588
			<tr>
589
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
590
			<td width="78%" class="vtable">
591
				<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
592
				<strong><?=gettext("Deny unknown clients");?></strong><br>
593
				<?=gettext("If this is checked, only the clients defined below will get DHCP leases from this server. ");?></td>
594
			</tr>
595
			<tr>
596
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet");?></td>
597
			<td width="78%" class="vtable">
598
				<?=gen_subnetv6($ifcfgip, $ifcfgsn);?>
232
				<input name="if" type="hidden" value="<?=$if;?>" />
233
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
599 234
			</td>
600 235
			</tr>
601
			<tr>
602
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet mask");?></td>
603
			<td width="78%" class="vtable">
604
				<?=$ifcfgsn;?> bits
605
			</td>
606
			</tr>
607
			<tr>
608
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Available range");?></td>
609
			<td width="78%" class="vtable">
610
			<?php
611
				$range_from = gen_subnetv6($ifcfgip, $ifcfgsn);
612
				$range_from++;
613
				echo $range_from;
614

  
615
			?>
616
			-
617
			<?php
618
				$range_to = gen_subnetv6_max($ifcfgip, $ifcfgsn);
619
				echo $range_to;
620
			?>
621
			</td>
622
			</tr>
623
			<?php if($is_olsr_enabled): ?>
624
			<tr>
625
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
626
			<td width="78%" class="vtable">
627
				<select name="netmask" class="formselect" id="netmask">
628
				<?php
629
				for ($i = 128; $i > 0; $i--) {
630
					if($i <> 127) {
631
						echo "<option value=\"{$i}\" ";
632
						if ($i == $pconfig['netmask']) echo "selected";
633
						echo ">" . $i . "</option>";
634
					}
635
				}
636
				?>
637
				</select>
638
			</td>
639
			</tr>
640
			<?php endif; ?>
641
			<tr>
642
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
643
			<td width="78%" class="vtable">
644
				<input name="range_from" type="text" class="formfld unknown" id="range_from" size="28" value="<?=htmlspecialchars($pconfig['range_from']);?>">
645
				&nbsp;<?=gettext("to"); ?>&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="28" value="<?=htmlspecialchars($pconfig['range_to']);?>">
646
			</td>
647
			</tr>
648
			<tr>
649
			<td width="22%" valign="top" class="vncell"><?=gettext("Prefix Delegation Range");?></td>
650
			<td width="78%" class="vtable">
651
				<input name="prefixrange_from" type="text" class="formfld unknown" id="prefixrange_from" size="28" value="<?=htmlspecialchars($pconfig['prefixrange_from']);?>">
652
				&nbsp;<?=gettext("to"); ?>&nbsp; <input name="prefixrange_to" type="text" class="formfld unknown" id="prefixrange_to" size="28" value="<?=htmlspecialchars($pconfig['prefixrange_to']);?>">
653
				&nbsp;<?=gettext("prefix delegation size"); ?>&nbsp; <select name="prefixrange_length" class="formselect" id="prefixrange_length">
654
					<option value="48" <?php if($pconfig['prefixrange_length'] == 48) echo "selected"; ?>>48</option>
655
					<option value="52" <?php if($pconfig['prefixrange_length'] == 52) echo "selected"; ?>>52</option>
656
					<option value="56" <?php if($pconfig['prefixrange_length'] == 56) echo "selected"; ?>>56</option>
657
					<option value="60" <?php if($pconfig['prefixrange_length'] == 60) echo "selected"; ?>>60</option>
658
					<option value="62" <?php if($pconfig['prefixrange_length'] == 62) echo "selected"; ?>>62</option>
659
					<option value="63" <?php if($pconfig['prefixrange_length'] == 63) echo "selected"; ?>>63</option>
660
					<option value="64" <?php if($pconfig['prefixrange_length'] == 64) echo "selected"; ?>>64</option>
661
				</select> <br/>
662
				<?php echo gettext("You can define a Prefix range here for DHCP Prefix Delegation. This allows for 
663
					assigning networks to subrouters. The start and end of the range must end on boundaries of the prefix delegation size."); ?>
664
			</td>
665
			</tr>
666
			<tr>
667
			<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
668
			<td width="78%" class="vtable">
669
				<input name="dns1" type="text" class="formfld unknown" id="dns1" size="28" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
670
				<input name="dns2" type="text" class="formfld unknown" id="dns2" size="28" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
671
				<?=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.");?>
672
			</td>
673
			</tr>
674
			<tr>
675
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
676
			<td width="78%" class="vtable">
677
				<input name="domain" type="text" class="formfld unknown" id="domain" size="28" value="<?=htmlspecialchars($pconfig['domain']);?>"><br>
678
				 <?=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.");?>
679
			 </td>
680
			</tr>
681
			<tr>
682
			<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
683
			<td width="78%" class="vtable">
684
				<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="28" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>"><br>
685
				<?=gettext("The DHCP server can optionally provide a domain search list. Use the semicolon character as seperator");?>
686
			</td>
687
			</tr>
688
			<tr>
689
			<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
690
			<td width="78%" class="vtable">
691
				<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
692
				<?=gettext("seconds");?><br>
693
				<?=gettext("This is used for clients that do not ask for a specific " .
694
				"expiration time."); ?><br>
695
				<?=gettext("The default is 7200 seconds.");?>
696
			</td>
697
			</tr>
698
			<tr>
699
			<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
700
			<td width="78%" class="vtable">
701
				<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
702
				<?=gettext("seconds");?><br>
703
				<?=gettext("This is the maximum lease time for clients that ask".
704
				" for a specific expiration time."); ?><br>
705
				<?=gettext("The default is 86400 seconds.");?>
706
			</td>
707
			</tr>
708
			<tr>
709
			<td width="22%" valign="top" class="vncell"><?=gettext("Failover peer IP:");?></td>
710
			<td width="78%" class="vtable">
711
				<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="28" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
712
				<?=gettext("Leave blank to disable.  Enter the interface IP address of the other machine.  Machines must be using CARP.");?>
713
			</td>
714
			</tr>
715
			<tr>
716
				<td width="22%" valign="top" class="vncell"><?=gettext("Time format change"); ?></td>
717
				<td width="78%" class="vtable">
718
				<table>
719
					<tr>
720
					<td>
721
						<input name="dhcpv6leaseinlocaltime" type="checkbox" id="dhcpv6leaseinlocaltime" value="yes" <?php if ($pconfig['dhcpv6leaseinlocaltime']) echo "checked"; ?>>
722
					</td>
723
					<td>
724
						<strong>
725
							<?=gettext("Change DHCPv6 display lease time from UTC to local time."); ?>
726
						</strong>
727
					</td>
728
					</tr>
729
					<tr>
730
					<td>&nbsp;</td>
731
					<td>
732
						<span class="red"><strong><?=gettext("Note:");?></strong></span> <?=gettext("By default DHCPv6 leases are displayed in UTC time.  By checking this 
733
						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."); ?>
734
					
735
					</td>
736
					</tr>
737
				</table>
738
				</td>
739
			</tr>
740
			<tr>
741
			<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
742
			<td width="78%" class="vtable">
743
				<div id="showddnsbox">
744
					<input type="button" onClick="show_ddns_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Dynamic DNS");?></a>
745
				</div>
746
				<div id="showddns" style="display:none">
747
					<input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>&nbsp;
748
					<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
749
					<p>
750
					<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="28" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
751
					<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
752
					<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?>
753
				</div>
754
			</td>
755
			</tr>
756
			<tr>
757
			<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
758
			<td width="78%" class="vtable">
759
				<div id="showntpbox">
760
					<input type="button" onClick="show_ntp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show NTP configuration");?></a>
761
				</div>
762
				<div id="showntp" style="display:none">
763
					<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="28" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
764
					<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="28" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
765
				</div>
766
			</td>
767
			</tr>
768
			<!-- ISC dhcpd does not support tftp for ipv6 yet. See redmine #2016
769
			<tr>
770
			<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
771
			<td width="78%" class="vtable">
772
			<div id="showtftpbox">
773
				<input type="button" onClick="show_tftp_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show TFTP configuration");?></a>
774
			</div>
775
			<div id="showtftp" style="display:none">
776
				<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>"><br>
777
				<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
778
			</div>
779
			</td>
780
			</tr>
781
			-->
782
			<tr>
783
			<td width="22%" valign="top" class="vncell"><?=gettext("LDAP URI");?></td>
784
			<td width="78%" class="vtable">
785
				<div id="showldapbox">
786
					<input type="button" onClick="show_ldap_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show LDAP configuration");?></a>
787
				</div>
788
				<div id="showldap" style="display:none">
789
					<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>"><br>
790
					<?=gettext("Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com");?>
791
				</div>
792
			</td>
793
			</tr>
794
			<tr>
795
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable network booting");?></td>
796
			<td width="78%" class="vtable">
797
				<div id="shownetbootbox">
798
					<input type="button" onClick="show_netboot_config()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Network booting");?></a>
799
				</div>
800
				<div id="shownetboot" style="display:none">
801
					<input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>&nbsp;
802
					<b><?=gettext("Enables network booting.");?></b>
803
					<p>
804
					<?=gettext("Enter the IP of the"); ?> <b><?=gettext("next-server"); ?></b>
805
					<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="28" value="<?=htmlspecialchars($pconfig['nextserver']);?>">
806
					<?=gettext("and the filename");?>
807
					<input name="filename" type="text" class="formfld unknown" id="filename" size="28" value="<?=htmlspecialchars($pconfig['filename']);?>"><br>
808
					<?=gettext("Note: You need both a filename and a boot server configured for this to work!");?>
809
					<p>
810
					<?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>
811
					<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br>
812
					<?=gettext("Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname");?>
813
				</div>
814
			</td>
815
			</tr>
816
			<tr>
817
			<td width="22%" valign="top" class="vncell"><?=gettext("Additional BOOTP/DHCP Options");?></td>
818
			<td width="78%" class="vtable">
819
				<div id="shownumbervaluebox">
820
					<input type="button" onClick="show_shownumbervalue()" value="<?=gettext("Advanced");?>"></input> - <?=gettext("Show Additional BOOTP/DHCP Options");?></a>
821
				</div>
822
				<div id="shownumbervalue" style="display:none">
823
				<table id="maintable">
824
				<tbody>
825
				<tr>
826
				<td colspan="3">
827
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
828
					<?=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>
829
					</div>
830
				</td>
831
				</tr>
832
				<tr>
833
				<td><div id="onecolumn"><?=gettext("Number");?></div></td>
834
				<td><div id="twocolumn"><?=gettext("Value");?></div></td>
835
				</tr>
836
				<?php $counter = 0; ?>
837
				<?php
838
					if($pconfig['numberoptions'])
839
						foreach($pconfig['numberoptions']['item'] as $item):
840
				?>
841
					<?php
842
						$number = $item['number'];
843
						$value = $item['value'];
844
					?>
845
				<tr>
846
				<td>
847
					<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
848
				</td>
849
				<td>
850
					<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld" id="value<?php echo $counter; ?>" size="55" value="<?=htmlspecialchars($value);?>" />
851
				</td>
852
				<td>
853
					<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="<?=gettext("Delete");?>" />
854
				</td>
855
				</tr>
856
				<?php $counter++; ?>
857
				<?php endforeach; ?>
858
				</tbody>
859
				<tfoot>
860
				</tfoot>
861
				</table>
862
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
863
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
864
				</a>
865
				<script type="text/javascript">
866
					field_counter_js = 2;
867
					rows = 1;
868
					totalrows = <?php echo $counter; ?>;
869
					loaded = <?php echo $counter; ?>;
870
				</script>
871
				</div>
872

  
873
				</td>
874
			</tr>
875
			<tr>
876
			<td width="22%" valign="top">&nbsp;</td>
877
			<td width="78%">
878
				<input name="if" type="hidden" value="<?=$if;?>">
879
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)">
880
			</td>
881
			</tr>
882
			<tr>
883
			<td width="22%" valign="top">&nbsp;</td>
884
			<td width="78%"> <p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br>
885
				</strong></span><?=gettext("The DNS servers entered in"); ?> <a href="system.php"><?=gettext("System: " .
886
				"General setup"); ?></a> <?=gettext("(or the"); ?> <a href="services_dnsmasq.php"><?=gettext("DNS " .
887
				"forwarder"); ?></a>, <?=gettext("if enabled)"); ?> </span><span class="vexpl"><?=gettext("will " .
888
				"be assigned to clients by the DHCP server."); ?><br>
889
				<br>
890
				<?=gettext("The DHCP lease table can be viewed on the"); ?> <a href="status_dhcp_leases.php"><?=gettext("Status: " .
891
				"DHCP leases"); ?></a> <?=gettext("page."); ?><br>
892
				</span></p>
893
			</td>
894
			</tr>
895
		</table>
896
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
897
		<tr>
898
			<td width="25%" class="listhdrr"><?=gettext("DUID");?></td>
899
			<td width="15%" class="listhdrr"><?=gettext("IPv6 address");?></td>
900
			<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
901
			<td width="30%" class="listhdr"><?=gettext("Description");?></td>
902
			<td width="10%" class="list">
903
			<table border="0" cellspacing="0" cellpadding="1">
904
			<tr>
905
			<td valign="middle" width="17"></td>
906
			<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>
907
			</tr>
908
			</table>
909
			</td>
910
		</tr>
911
			<?php if(is_array($a_maps)): ?>
912
			<?php $i = 0; foreach ($a_maps as $mapent): ?>
913
			<?php if($mapent['duid'] <> "" or $mapent['ipaddrv6'] <> ""): ?>
914
		<tr>
915
		<td class="listlr" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
916
			<?=htmlspecialchars($mapent['duid']);?>
917
		</td>
918
		<td class="listr" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
919
			<?=htmlspecialchars($mapent['ipaddrv6']);?>&nbsp;
920
		</td>
921
		<td class="listr" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
922
			<?=htmlspecialchars($mapent['hostname']);?>&nbsp;
923
		</td>
924
		<td class="listbg" ondblclick="document.location='services_dhcpv6_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
925
			<?=htmlspecialchars($mapent['descr']);?>&nbsp;
926
		</td>
927
		<td valign="middle" nowrap class="list">
928
			<table border="0" cellspacing="0" cellpadding="1">
929
			<tr>
930
			<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>
931
			<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>
932
			</tr>
933
			</table>
934
		</td>
935
		</tr>
936
		<?php endif; ?>
937
		<?php $i++; endforeach; ?>
938
		<?php endif; ?>
939
		<tr>
940
		<td class="list" colspan="4"></td>
941
		<td class="list">
942
			<table border="0" cellspacing="0" cellpadding="1">
943
			<tr>
944
			<td valign="middle" width="17"></td>
945
			<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>
946
			</tr>
947
			</table>
948
		</td>
949
		</tr>
950 236
		</table>
951 237
	</div>
952 238
</td>
953 239
</tr>
954 240
</table>
955 241
</form>
956
<script language="JavaScript">
957
<!--
958
enable_change(false);
959
//-->
960
</script>
961 242
<?php include("fend.inc"); ?>
962 243
</body>
963 244
</html>

Also available in: Unified diff