1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
status_dhcpv6_leases.php
|
5
|
Copyright (C) 2004-2009 Scott Ullrich
|
6
|
Copyright (C) 2011 Seth Mos
|
7
|
All rights reserved.
|
8
|
|
9
|
originially part of m0n0wall (http://m0n0.ch/wall)
|
10
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11
|
All rights reserved.
|
12
|
|
13
|
Redistribution and use in source and binary forms, with or without
|
14
|
modification, are permitted provided that the following conditions are met:
|
15
|
|
16
|
1. Redistributions of source code must retain the above copyright notice,
|
17
|
this list of conditions and the following disclaimer.
|
18
|
|
19
|
2. Redistributions in binary form must reproduce the above copyright
|
20
|
notice, this list of conditions and the following disclaimer in the
|
21
|
documentation and/or other materials provided with the distribution.
|
22
|
|
23
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
24
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
25
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
26
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
27
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
POSSIBILITY OF SUCH DAMAGE.
|
33
|
*/
|
34
|
|
35
|
/*
|
36
|
pfSense_BUILDER_BINARIES: /usr/bin/awk /bin/cat /usr/sbin/ndp /usr/bin/wc /usr/bin/grep
|
37
|
pfSense_MODULE: dhcpserver
|
38
|
*/
|
39
|
|
40
|
##|+PRIV
|
41
|
##|*IDENT=page-status-dhcpv6leases
|
42
|
##|*NAME=Status: DHCPv6 leases page
|
43
|
##|*DESCR=Allow access to the 'Status: DHCPv6 leases' page.
|
44
|
##|*MATCH=status_dhcpv6_leases.php*
|
45
|
##|-PRIV
|
46
|
|
47
|
require("guiconfig.inc");
|
48
|
require_once("config.inc");
|
49
|
|
50
|
$pgtitle = array(gettext("Status"),gettext("DHCPv6 leases"));
|
51
|
$shortcut_section = "dhcp6";
|
52
|
|
53
|
$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd6.leases";
|
54
|
|
55
|
if (($_GET['deleteip']) && (is_ipaddr($_GET['deleteip']))) {
|
56
|
/* Stop DHCPD */
|
57
|
killbyname("dhcpd");
|
58
|
|
59
|
/* Read existing leases */
|
60
|
$leases_contents = explode("\n", file_get_contents($leasesfile));
|
61
|
$newleases_contents = array();
|
62
|
$i=0;
|
63
|
while ($i < count($leases_contents)) {
|
64
|
/* Find the lease(s) we want to delete */
|
65
|
if ($leases_contents[$i] == " iaaddr {$_GET['deleteip']} {") {
|
66
|
/* The iaaddr line is two lines down from the start of the lease, so remove those two lines. */
|
67
|
array_pop($newleases_contents);
|
68
|
array_pop($newleases_contents);
|
69
|
/* Skip to the end of the lease declaration */
|
70
|
do {
|
71
|
$i++;
|
72
|
} while ($leases_contents[$i] != "}");
|
73
|
} else {
|
74
|
/* It's a line we want to keep, copy it over. */
|
75
|
$newleases_contents[] = $leases_contents[$i];
|
76
|
}
|
77
|
$i++;
|
78
|
}
|
79
|
|
80
|
/* Write out the new leases file */
|
81
|
$fd = fopen($leasesfile, 'w');
|
82
|
fwrite($fd, implode("\n", $newleases_contents));
|
83
|
fclose($fd);
|
84
|
|
85
|
/* Restart DHCP Service */
|
86
|
services_dhcpd_configure();
|
87
|
header("Location: status_dhcpv6_leases.php?all={$_GET['all']}");
|
88
|
}
|
89
|
|
90
|
// Load MAC-Manufacturer table
|
91
|
$mac_man = load_mac_manufacturer_table();
|
92
|
|
93
|
include("head.inc");
|
94
|
|
95
|
?>
|
96
|
|
97
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
98
|
<?php include("fbegin.inc"); ?>
|
99
|
<?php
|
100
|
|
101
|
function leasecmp($a, $b) {
|
102
|
return strcmp($a[$_GET['order']], $b[$_GET['order']]);
|
103
|
}
|
104
|
|
105
|
function adjust_gmt($dt) {
|
106
|
global $config;
|
107
|
|
108
|
$dhcpv6leaseinlocaltime == "no";
|
109
|
if (is_array($config['dhcpdv6'])) {
|
110
|
$dhcpdv6 = $config['dhcpdv6'];
|
111
|
foreach ($dhcpdv6 as $dhcpv6leaseinlocaltime) {
|
112
|
$dhcpv6leaseinlocaltime = $dhcpv6leaseinlocaltime['dhcpv6leaseinlocaltime'];
|
113
|
if ($dhcpv6leaseinlocaltime == "yes")
|
114
|
break;
|
115
|
}
|
116
|
}
|
117
|
|
118
|
$timezone = $config['system']['timezone'];
|
119
|
$ts = strtotime($dt . " GMT");
|
120
|
if ($dhcpv6leaseinlocaltime == "yes") {
|
121
|
$this_tz = new DateTimeZone($timezone);
|
122
|
$dhcp_lt = new DateTime(strftime("%I:%M:%S%p", $ts), $this_tz);
|
123
|
$offset = $this_tz->getOffset($dhcp_lt);
|
124
|
$ts = $ts + $offset;
|
125
|
return strftime("%Y/%m/%d %I:%M:%S%p", $ts);
|
126
|
}
|
127
|
else
|
128
|
return strftime("%Y/%m/%d %H:%M:%S", $ts);
|
129
|
}
|
130
|
|
131
|
function remove_duplicate($array, $field) {
|
132
|
foreach ($array as $sub)
|
133
|
$cmp[] = $sub[$field];
|
134
|
$unique = array_unique(array_reverse($cmp,true));
|
135
|
foreach ($unique as $k => $rien)
|
136
|
$new[] = $array[$k];
|
137
|
return $new;
|
138
|
}
|
139
|
|
140
|
function parse_duid($duid_string) {
|
141
|
$parsed_duid = array();
|
142
|
for ($i=0; $i < strlen($duid_string); $i++) {
|
143
|
$s = substr($duid_string, $i, 1);
|
144
|
if ($s == '\\') {
|
145
|
$n = substr($duid_string, $i+1, 1);
|
146
|
if (($n == '\\') || ($n == '"')) {
|
147
|
$parsed_duid[] = sprintf("%02x", ord($n));
|
148
|
} elseif (is_numeric($n)) {
|
149
|
$parsed_duid[] = sprintf("%02x", octdec(substr($duid_string, $i+1, 3)));
|
150
|
$i += 3;
|
151
|
}
|
152
|
} else {
|
153
|
$parsed_duid[] = sprintf("%02x", ord($s));
|
154
|
}
|
155
|
}
|
156
|
$iaid = array_slice($parsed_duid, 0, 4);
|
157
|
$duid = array_slice($parsed_duid, 4);
|
158
|
return array($iaid, $duid);
|
159
|
}
|
160
|
|
161
|
$awk = "/usr/bin/awk";
|
162
|
|
163
|
/* this pattern sticks comments into a single array item */
|
164
|
$cleanpattern = "'{ gsub(\"^#.*\", \"\");} { gsub(\"^server-duid.*\", \"\");} { gsub(\";$\", \"\"); print;}'";
|
165
|
/* We then split the leases file by } */
|
166
|
$splitpattern = "'BEGIN { RS=\"}\";} {for (i=1; i<=NF; i++) printf \"%s \", \$i; printf \"}\\n\";}'";
|
167
|
|
168
|
/* stuff the leases file in a proper format into a array by line */
|
169
|
exec("/bin/cat {$leasesfile} | {$awk} {$cleanpattern} | {$awk} {$splitpattern} | /usr/bin/grep '^ia-.. '", $leases_content);
|
170
|
$leases_count = count($leases_content);
|
171
|
exec("/usr/sbin/ndp -an", $rawdata);
|
172
|
$ndpdata = array();
|
173
|
foreach ($rawdata as $line) {
|
174
|
$elements = preg_split('/\s+/ ',$line);
|
175
|
if ($elements[1] != "(incomplete)") {
|
176
|
$ndpent = array();
|
177
|
$ip = trim(str_replace(array('(',')'),'',$elements[0]));
|
178
|
$ndpent['mac'] = trim($elements[1]);
|
179
|
$ndpent['interface'] = trim($elements[2]);
|
180
|
$ndpdata[$ip] = $ndpent;
|
181
|
}
|
182
|
}
|
183
|
|
184
|
$pools = array();
|
185
|
$leases = array();
|
186
|
$prefixes = array();
|
187
|
$mappings = array();
|
188
|
$i = 0;
|
189
|
$l = 0;
|
190
|
$p = 0;
|
191
|
|
192
|
// Put everything together again
|
193
|
while($i < $leases_count) {
|
194
|
$entry = array();
|
195
|
/* split the line by space */
|
196
|
$duid_split = array();
|
197
|
preg_match('/ia-.. "(.*)" { (.*)/ ', $leases_content[$i], $duid_split);
|
198
|
if (!empty($duid_split[1])) {
|
199
|
$iaid_duid = parse_duid($duid_split[1]);
|
200
|
$entry['iaid'] = hexdec(implode("", array_reverse($iaid_duid[0])));
|
201
|
$entry['duid'] = implode(":", $iaid_duid[1]);
|
202
|
$data = explode(" ", $duid_split[2]);
|
203
|
} else {
|
204
|
$data = explode(" ", $leases_content[$i]);
|
205
|
}
|
206
|
/* walk the fields */
|
207
|
$f = 0;
|
208
|
$fcount = count($data);
|
209
|
/* with less then 12 fields there is nothing useful */
|
210
|
if($fcount < 12) {
|
211
|
$i++;
|
212
|
continue;
|
213
|
}
|
214
|
while($f < $fcount) {
|
215
|
switch($data[$f]) {
|
216
|
case "failover":
|
217
|
$pools[$p]['name'] = $data[$f+2];
|
218
|
$pools[$p]['mystate'] = $data[$f+7];
|
219
|
$pools[$p]['peerstate'] = $data[$f+14];
|
220
|
$pools[$p]['mydate'] = $data[$f+10];
|
221
|
$pools[$p]['mydate'] .= " " . $data[$f+11];
|
222
|
$pools[$p]['peerdate'] = $data[$f+17];
|
223
|
$pools[$p]['peerdate'] .= " " . $data[$f+18];
|
224
|
$p++;
|
225
|
$i++;
|
226
|
continue 3;
|
227
|
case "ia-pd":
|
228
|
$is_prefix = true;
|
229
|
case "ia-na":
|
230
|
$entry['iaid'] = $tmp_iaid;
|
231
|
$entry['duid'] = $tmp_duid;
|
232
|
if ($data[$f+1][0] == '"') {
|
233
|
$duid = "";
|
234
|
/* FIXME: This needs a safety belt to prevent an infinite loop */
|
235
|
while ($data[$f][strlen($data[$f])-1] != '"') {
|
236
|
$duid .= " " . $data[$f+1];
|
237
|
$f++;
|
238
|
}
|
239
|
$entry['duid'] = $duid;
|
240
|
} else {
|
241
|
$entry['duid'] = $data[$f+1];
|
242
|
}
|
243
|
$entry['type'] = "dynamic";
|
244
|
$f = $f+2;
|
245
|
break;
|
246
|
case "iaaddr":
|
247
|
$entry['ip'] = $data[$f+1];
|
248
|
$entry['type'] = "dynamic";
|
249
|
if (in_array($entry['ip'], array_keys($ndpdata))) {
|
250
|
$entry['online'] = 'online';
|
251
|
} else {
|
252
|
$entry['online'] = 'offline';
|
253
|
}
|
254
|
$f = $f+2;
|
255
|
break;
|
256
|
case "iaprefix":
|
257
|
$is_prefix = true;
|
258
|
$entry['prefix'] = $data[$f+1];
|
259
|
$entry['type'] = "dynamic";
|
260
|
$f = $f+2;
|
261
|
break;
|
262
|
case "starts":
|
263
|
$entry['start'] = $data[$f+2];
|
264
|
$entry['start'] .= " " . $data[$f+3];
|
265
|
$f = $f+3;
|
266
|
break;
|
267
|
case "ends":
|
268
|
$entry['end'] = $data[$f+2];
|
269
|
$entry['end'] .= " " . $data[$f+3];
|
270
|
$f = $f+3;
|
271
|
break;
|
272
|
case "tstp":
|
273
|
$f = $f+3;
|
274
|
break;
|
275
|
case "tsfp":
|
276
|
$f = $f+3;
|
277
|
break;
|
278
|
case "atsfp":
|
279
|
$f = $f+3;
|
280
|
break;
|
281
|
case "cltt":
|
282
|
$entry['start'] = $data[$f+2];
|
283
|
$entry['start'] .= " " . $data[$f+3];
|
284
|
$f = $f+3;
|
285
|
break;
|
286
|
case "binding":
|
287
|
switch($data[$f+2]) {
|
288
|
case "active":
|
289
|
$entry['act'] = "active";
|
290
|
break;
|
291
|
case "free":
|
292
|
$entry['act'] = "expired";
|
293
|
$entry['online'] = "offline";
|
294
|
break;
|
295
|
case "backup":
|
296
|
$entry['act'] = "reserved";
|
297
|
$entry['online'] = "offline";
|
298
|
break;
|
299
|
case "released":
|
300
|
$entry['act'] = "released";
|
301
|
$entry['online'] = "offline";
|
302
|
}
|
303
|
$f = $f+1;
|
304
|
break;
|
305
|
case "next":
|
306
|
/* skip the next binding statement */
|
307
|
$f = $f+3;
|
308
|
break;
|
309
|
case "hardware":
|
310
|
$f = $f+2;
|
311
|
break;
|
312
|
case "client-hostname":
|
313
|
if($data[$f+1] <> "") {
|
314
|
$entry['hostname'] = preg_replace('/"/','',$data[$f+1]);
|
315
|
} else {
|
316
|
$hostname = gethostbyaddr($entry['ip']);
|
317
|
if($hostname <> "") {
|
318
|
$entry['hostname'] = $hostname;
|
319
|
}
|
320
|
}
|
321
|
$f = $f+1;
|
322
|
break;
|
323
|
case "uid":
|
324
|
$f = $f+1;
|
325
|
break;
|
326
|
}
|
327
|
$f++;
|
328
|
}
|
329
|
if ($is_prefix) {
|
330
|
$prefixes[] = $entry;
|
331
|
} else {
|
332
|
$leases[] = $entry;
|
333
|
$mappings[$entry['iaid'] . $entry['duid']] = $entry['ip'];
|
334
|
}
|
335
|
$l++;
|
336
|
$i++;
|
337
|
$is_prefix = false;
|
338
|
}
|
339
|
|
340
|
if(count($leases) > 0) {
|
341
|
$leases = remove_duplicate($leases,"ip");
|
342
|
}
|
343
|
|
344
|
if(count($prefixes) > 0) {
|
345
|
$prefixes = remove_duplicate($prefixes,"prefix");
|
346
|
}
|
347
|
|
348
|
if(count($pools) > 0) {
|
349
|
$pools = remove_duplicate($pools,"name");
|
350
|
asort($pools);
|
351
|
}
|
352
|
|
353
|
foreach($config['interfaces'] as $ifname => $ifarr) {
|
354
|
if (is_array($config['dhcpdv6'][$ifname]) &&
|
355
|
is_array($config['dhcpdv6'][$ifname]['staticmap'])) {
|
356
|
foreach($config['dhcpdv6'][$ifname]['staticmap'] as $static) {
|
357
|
$slease = array();
|
358
|
$slease['ip'] = $static['ipaddrv6'];
|
359
|
$slease['type'] = "static";
|
360
|
$slease['duid'] = $static['duid'];
|
361
|
$slease['start'] = "";
|
362
|
$slease['end'] = "";
|
363
|
$slease['hostname'] = htmlentities($static['hostname']);
|
364
|
$slease['act'] = "static";
|
365
|
if (in_array($slease['ip'], array_keys($ndpdata))) {
|
366
|
$slease['online'] = 'online';
|
367
|
} else {
|
368
|
$slease['online'] = 'offline';
|
369
|
}
|
370
|
|
371
|
$leases[] = $slease;
|
372
|
}
|
373
|
}
|
374
|
}
|
375
|
|
376
|
if ($_GET['order'])
|
377
|
usort($leases, "leasecmp");
|
378
|
|
379
|
/* only print pool status when we have one */
|
380
|
if(count($pools) > 0) {
|
381
|
?>
|
382
|
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases">
|
383
|
<tr>
|
384
|
<td class="listhdrr"><?=gettext("Failover Group"); ?></a></td>
|
385
|
<td class="listhdrr"><?=gettext("My State"); ?></a></td>
|
386
|
<td class="listhdrr"><?=gettext("Since"); ?></a></td>
|
387
|
<td class="listhdrr"><?=gettext("Peer State"); ?></a></td>
|
388
|
<td class="listhdrr"><?=gettext("Since"); ?></a></td>
|
389
|
</tr>
|
390
|
<?php
|
391
|
foreach ($pools as $data) {
|
392
|
echo "<tr>\n";
|
393
|
echo "<td class=\"listlr\">{$fspans}{$data['name']}{$fspane}</td>\n";
|
394
|
echo "<td class=\"listr\">{$fspans}{$data['mystate']}{$fspane}</td>\n";
|
395
|
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['mydate']) . "{$fspane}</td>\n";
|
396
|
echo "<td class=\"listr\">{$fspans}{$data['peerstate']}{$fspane}</td>\n";
|
397
|
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['peerdate']) . "{$fspane}</td>\n";
|
398
|
echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n";
|
399
|
echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n";
|
400
|
echo "</tr>\n";
|
401
|
}
|
402
|
|
403
|
?>
|
404
|
</table>
|
405
|
|
406
|
<?php
|
407
|
/* only print pool status when we have one */
|
408
|
}
|
409
|
?>
|
410
|
|
411
|
<br/>
|
412
|
|
413
|
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases">
|
414
|
<tr>
|
415
|
<td class="listhdrr"><a href="#"><?=gettext("IPv6 address"); ?></a></td>
|
416
|
<td class="listhdrr"><a href="#"><?=gettext("IAID"); ?></a></td>
|
417
|
<td class="listhdrr"><a href="#"><?=gettext("DUID"); ?></a></td>
|
418
|
<td class="listhdrr"><a href="#"><?=gettext("Hostname/MAC"); ?></a></td>
|
419
|
<td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td>
|
420
|
<td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td>
|
421
|
<td class="listhdrr"><a href="#"><?=gettext("Online"); ?></a></td>
|
422
|
<td class="listhdrr"><a href="#"><?=gettext("Lease Type"); ?></a></td>
|
423
|
</tr>
|
424
|
<?php
|
425
|
foreach ($leases as $data) {
|
426
|
if (($data['act'] == "active") || ($data['act'] == "static") || ($_GET['all'] == 1)) {
|
427
|
if ($data['act'] != "active" && $data['act'] != "static") {
|
428
|
$fspans = "<span class=\"gray\">";
|
429
|
$fspane = " </span>";
|
430
|
} else {
|
431
|
$fspans = "";
|
432
|
$fspane = " ";
|
433
|
}
|
434
|
|
435
|
if ($data['act'] == "static") {
|
436
|
foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) {
|
437
|
if(is_array($dhcpifconf['staticmap'])) {
|
438
|
foreach ($dhcpifconf['staticmap'] as $staticent) {
|
439
|
if ($data['ip'] == $staticent['ipaddr']) {
|
440
|
$data['if'] = $dhcpif;
|
441
|
break;
|
442
|
}
|
443
|
}
|
444
|
}
|
445
|
/* exit as soon as we have an interface */
|
446
|
if ($data['if'] != "")
|
447
|
break;
|
448
|
}
|
449
|
} else {
|
450
|
$data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip']));
|
451
|
}
|
452
|
echo "<tr>\n";
|
453
|
echo "<td class=\"listlr\">{$fspans}{$data['ip']}{$fspane}</td>\n";
|
454
|
echo "<td class=\"listr\">{$fspans}{$data['iaid']}{$fspane}</td>\n";
|
455
|
echo "<td class=\"listr\">{$fspans}{$data['duid']}{$fspane}</td>\n";
|
456
|
echo "<td class=\"listr\">{$fspans}";
|
457
|
if (!empty($data['hostname'])) {
|
458
|
echo htmlentities($data['hostname']) . "<br />";
|
459
|
}
|
460
|
|
461
|
$mac=trim($ndpdata[$data['ip']]['mac']);
|
462
|
if (!empty($mac)) {
|
463
|
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
|
464
|
print htmlentities($mac);
|
465
|
if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; }
|
466
|
}
|
467
|
|
468
|
echo "{$fspane} </td>\n";
|
469
|
if ($data['type'] != "static") {
|
470
|
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['start']) . "{$fspane}</td>\n";
|
471
|
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['end']) . "{$fspane}</td>\n";
|
472
|
} else {
|
473
|
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
|
474
|
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
|
475
|
}
|
476
|
echo "<td class=\"listr\">{$fspans}{$data['online']}{$fspane}</td>\n";
|
477
|
echo "<td class=\"listr\">{$fspans}{$data['act']}{$fspane}</td>\n";
|
478
|
|
479
|
if ($data['type'] == "dynamic") {
|
480
|
echo "<td valign=\"middle\"><a href=\"services_dhcpv6_edit.php?if={$data['if']}&duid={$data['duid']}&hostname={$data['hostname']}\">";
|
481
|
echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" width=\"17\" height=\"17\" border=\"0\" title=\"" . gettext("add a static mapping for this MAC address") ."\" alt=\"add\" /></a></td>\n";
|
482
|
} else {
|
483
|
echo "<td class=\"list\" valign=\"middle\">";
|
484
|
echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_plus_mo.gif\" width=\"17\" height=\"17\" border=\"0\" alt=\"add\" /></td>\n";
|
485
|
}
|
486
|
|
487
|
/* Only show the button for offline dynamic leases */
|
488
|
if (($data['type'] == "dynamic") && ($data['online'] != "online")) {
|
489
|
echo "<td class=\"list\" valign=\"middle\"><a href=\"status_dhcpv6_leases.php?deleteip={$data['ip']}&all=" . htmlspecialchars($_GET['all']) . "\">";
|
490
|
echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_x.gif\" width=\"17\" height=\"17\" border=\"0\" title=\"" . gettext("delete this DHCP lease") . "\" alt=\"delete\" /></a></td>\n";
|
491
|
}
|
492
|
echo "</tr>\n";
|
493
|
}
|
494
|
}
|
495
|
?>
|
496
|
</table>
|
497
|
<br/>
|
498
|
<h3>Delegated Prefixes</h3>
|
499
|
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="prefixes">
|
500
|
<tr>
|
501
|
<td class="listhdrr"><a href="#"><?=gettext("IPv6 Prefix"); ?></a></td>
|
502
|
<td class="listhdrr"><a href="#"><?=gettext("IAID"); ?></a></td>
|
503
|
<td class="listhdrr"><a href="#"><?=gettext("DUID"); ?></a></td>
|
504
|
<td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td>
|
505
|
<td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td>
|
506
|
<td class="listhdrr"><a href="#"><?=gettext("State"); ?></a></td>
|
507
|
</tr>
|
508
|
<?php
|
509
|
foreach ($prefixes as $data) {
|
510
|
if (($data['act'] == "active") || ($data['act'] == "static") || ($_GET['all'] == 1)) {
|
511
|
if ($data['act'] != "active" && $data['act'] != "static") {
|
512
|
$fspans = "<span class=\"gray\">";
|
513
|
$fspane = " </span>";
|
514
|
} else {
|
515
|
$fspans = "";
|
516
|
$fspane = " ";
|
517
|
}
|
518
|
|
519
|
if ($data['act'] == "static") {
|
520
|
foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) {
|
521
|
if(is_array($dhcpifconf['staticmap'])) {
|
522
|
foreach ($dhcpifconf['staticmap'] as $staticent) {
|
523
|
if ($data['ip'] == $staticent['ipaddr']) {
|
524
|
$data['if'] = $dhcpif;
|
525
|
break;
|
526
|
}
|
527
|
}
|
528
|
}
|
529
|
/* exit as soon as we have an interface */
|
530
|
if ($data['if'] != "")
|
531
|
break;
|
532
|
}
|
533
|
} else {
|
534
|
$data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip']));
|
535
|
}
|
536
|
echo "<tr>\n";
|
537
|
if ($mappings[$data['iaid'] . $data['duid']]) {
|
538
|
$dip = "<br />Routed To: {$mappings[$data['iaid'] . $data['duid']]}";
|
539
|
}
|
540
|
echo "<td class=\"listlr\">{$fspans}{$data['prefix']}{$dip}{$fspane}</td>\n";
|
541
|
echo "<td class=\"listr\">{$fspans}{$data['iaid']}{$fspane}</td>\n";
|
542
|
echo "<td class=\"listr\">{$fspans}{$data['duid']}{$fspane}</td>\n";
|
543
|
if ($data['type'] != "static") {
|
544
|
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['start']) . "{$fspane}</td>\n";
|
545
|
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['end']) . "{$fspane}</td>\n";
|
546
|
} else {
|
547
|
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
|
548
|
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
|
549
|
}
|
550
|
echo "<td class=\"listr\">{$fspans}{$data['act']}{$fspane}</td>\n";
|
551
|
echo "</tr>\n";
|
552
|
}
|
553
|
}
|
554
|
?>
|
555
|
</table>
|
556
|
<br/>
|
557
|
<form action="status_dhcpv6_leases.php" method="get">
|
558
|
<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
|
559
|
<?php if ($_GET['all']): ?>
|
560
|
<input type="hidden" name="all" value="0" />
|
561
|
<input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" />
|
562
|
<?php else: ?>
|
563
|
<input type="hidden" name="all" value="1" />
|
564
|
<input type="submit" class="formbtn" value="<?=gettext("Show all configured leases"); ?>" />
|
565
|
<?php endif; ?>
|
566
|
</form>
|
567
|
<?php if($leases == 0): ?>
|
568
|
<p><strong><?=gettext("No leases file found. Is the DHCP server active"); ?>?</strong></p>
|
569
|
<?php endif; ?>
|
570
|
|
571
|
<?php include("fend.inc"); ?>
|
572
|
</body>
|
573
|
</html>
|