1 |
c1640267
|
Seth Mos
|
<?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 |
ff5fa759
|
Phil Davis
|
originally part of m0n0wall (http://m0n0.ch/wall)
|
10 |
c1640267
|
Seth Mos
|
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 |
9d539cb5
|
jim-p
|
pfSense_BUILDER_BINARIES: /usr/bin/awk /bin/cat /usr/sbin/ndp /usr/bin/wc /usr/bin/grep
|
37 |
c1640267
|
Seth Mos
|
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 |
468618f0
|
Joecowboy
|
require_once("config.inc");
|
49 |
c1640267
|
Seth Mos
|
|
50 |
|
|
$pgtitle = array(gettext("Status"),gettext("DHCPv6 leases"));
|
51 |
b32dd0a6
|
jim-p
|
$shortcut_section = "dhcp6";
|
52 |
c1640267
|
Seth Mos
|
|
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 |
20df6ed7
|
jim-p
|
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 |
c1640267
|
Seth Mos
|
/* 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 |
f7cd2ed8
|
jim-p
|
// Load MAC-Manufacturer table
|
91 |
|
|
$mac_man = load_mac_manufacturer_table();
|
92 |
|
|
|
93 |
c1640267
|
Seth Mos
|
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 |
a4dd274b
|
jim-p
|
return strcmp($a[$_GET['order']], $b[$_GET['order']]);
|
103 |
c1640267
|
Seth Mos
|
}
|
104 |
|
|
|
105 |
|
|
function adjust_gmt($dt) {
|
106 |
f6bda83c
|
jim-p
|
global $config;
|
107 |
a8ab2b76
|
Ermal
|
|
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 |
ee0f23b4
|
Joecowboy
|
}
|
117 |
a8ab2b76
|
Ermal
|
|
118 |
f6bda83c
|
jim-p
|
$timezone = $config['system']['timezone'];
|
119 |
a4dd274b
|
jim-p
|
$ts = strtotime($dt . " GMT");
|
120 |
ee0f23b4
|
Joecowboy
|
if ($dhcpv6leaseinlocaltime == "yes") {
|
121 |
f6bda83c
|
jim-p
|
$this_tz = new DateTimeZone($timezone);
|
122 |
|
|
$dhcp_lt = new DateTime(strftime("%I:%M:%S%p", $ts), $this_tz);
|
123 |
468618f0
|
Joecowboy
|
$offset = $this_tz->getOffset($dhcp_lt);
|
124 |
|
|
$ts = $ts + $offset;
|
125 |
|
|
return strftime("%Y/%m/%d %I:%M:%S%p", $ts);
|
126 |
f6bda83c
|
jim-p
|
}
|
127 |
468618f0
|
Joecowboy
|
else
|
128 |
|
|
return strftime("%Y/%m/%d %H:%M:%S", $ts);
|
129 |
c1640267
|
Seth Mos
|
}
|
130 |
|
|
|
131 |
a4dd274b
|
jim-p
|
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 |
f393a514
|
jim-p
|
$iaid = array_slice($parsed_duid, 0, 4);
|
157 |
|
|
$duid = array_slice($parsed_duid, 4);
|
158 |
|
|
return array($iaid, $duid);
|
159 |
c1640267
|
Seth Mos
|
}
|
160 |
|
|
|
161 |
|
|
$awk = "/usr/bin/awk";
|
162 |
ffdcbeb6
|
jim-p
|
|
163 |
c1640267
|
Seth Mos
|
/* this pattern sticks comments into a single array item */
|
164 |
0f03ae0f
|
jim-p
|
$cleanpattern = "'{ gsub(\"^#.*\", \"\");} { gsub(\"^server-duid.*\", \"\");} { gsub(\";$\", \"\"); print;}'";
|
165 |
c1640267
|
Seth Mos
|
/* 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 |
f6bda83c
|
jim-p
|
exec("/bin/cat {$leasesfile} | {$awk} {$cleanpattern} | {$awk} {$splitpattern} | /usr/bin/grep '^ia-.. '", $leases_content);
|
170 |
c1640267
|
Seth Mos
|
$leases_count = count($leases_content);
|
171 |
bcb24b81
|
jim-p
|
exec("/usr/sbin/ndp -an", $rawdata);
|
172 |
9d539cb5
|
jim-p
|
$ndpdata = array();
|
173 |
c1640267
|
Seth Mos
|
foreach ($rawdata as $line) {
|
174 |
bcb24b81
|
jim-p
|
$elements = preg_split('/\s+/ ',$line);
|
175 |
|
|
if ($elements[1] != "(incomplete)") {
|
176 |
9d539cb5
|
jim-p
|
$ndpent = array();
|
177 |
2fdc8262
|
jim-p
|
$ip = trim(str_replace(array('(',')'),'',$elements[0]));
|
178 |
9d539cb5
|
jim-p
|
$ndpent['mac'] = trim($elements[1]);
|
179 |
|
|
$ndpent['interface'] = trim($elements[2]);
|
180 |
|
|
$ndpdata[$ip] = $ndpent;
|
181 |
c1640267
|
Seth Mos
|
}
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
$pools = array();
|
185 |
|
|
$leases = array();
|
186 |
f6bda83c
|
jim-p
|
$prefixes = array();
|
187 |
|
|
$mappings = array();
|
188 |
c1640267
|
Seth Mos
|
$i = 0;
|
189 |
|
|
$l = 0;
|
190 |
|
|
$p = 0;
|
191 |
|
|
|
192 |
|
|
// Put everything together again
|
193 |
|
|
while($i < $leases_count) {
|
194 |
f6bda83c
|
jim-p
|
$entry = array();
|
195 |
c1640267
|
Seth Mos
|
/* split the line by space */
|
196 |
a4dd274b
|
jim-p
|
$duid_split = array();
|
197 |
f6bda83c
|
jim-p
|
preg_match('/ia-.. "(.*)" { (.*)/ ', $leases_content[$i], $duid_split);
|
198 |
a4dd274b
|
jim-p
|
if (!empty($duid_split[1])) {
|
199 |
f393a514
|
jim-p
|
$iaid_duid = parse_duid($duid_split[1]);
|
200 |
f6bda83c
|
jim-p
|
$entry['iaid'] = hexdec(implode("", array_reverse($iaid_duid[0])));
|
201 |
|
|
$entry['duid'] = implode(":", $iaid_duid[1]);
|
202 |
a4dd274b
|
jim-p
|
$data = explode(" ", $duid_split[2]);
|
203 |
|
|
} else {
|
204 |
|
|
$data = explode(" ", $leases_content[$i]);
|
205 |
|
|
}
|
206 |
c1640267
|
Seth Mos
|
/* walk the fields */
|
207 |
|
|
$f = 0;
|
208 |
|
|
$fcount = count($data);
|
209 |
a4dd274b
|
jim-p
|
/* with less then 12 fields there is nothing useful */
|
210 |
|
|
if($fcount < 12) {
|
211 |
c1640267
|
Seth Mos
|
$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 |
f6bda83c
|
jim-p
|
case "ia-pd":
|
228 |
|
|
$is_prefix = true;
|
229 |
bcb24b81
|
jim-p
|
case "ia-na":
|
230 |
f6bda83c
|
jim-p
|
$entry['iaid'] = $tmp_iaid;
|
231 |
|
|
$entry['duid'] = $tmp_duid;
|
232 |
c1f4af16
|
jim-p
|
if ($data[$f+1][0] == '"') {
|
233 |
|
|
$duid = "";
|
234 |
ffdcbeb6
|
jim-p
|
/* FIXME: This needs a safety belt to prevent an infinite loop */
|
235 |
c1f4af16
|
jim-p
|
while ($data[$f][strlen($data[$f])-1] != '"') {
|
236 |
|
|
$duid .= " " . $data[$f+1];
|
237 |
|
|
$f++;
|
238 |
|
|
}
|
239 |
f6bda83c
|
jim-p
|
$entry['duid'] = $duid;
|
240 |
c1f4af16
|
jim-p
|
} else {
|
241 |
f6bda83c
|
jim-p
|
$entry['duid'] = $data[$f+1];
|
242 |
c1f4af16
|
jim-p
|
}
|
243 |
f6bda83c
|
jim-p
|
$entry['type'] = "dynamic";
|
244 |
c1640267
|
Seth Mos
|
$f = $f+2;
|
245 |
|
|
break;
|
246 |
bcb24b81
|
jim-p
|
case "iaaddr":
|
247 |
f6bda83c
|
jim-p
|
$entry['ip'] = $data[$f+1];
|
248 |
|
|
$entry['type'] = "dynamic";
|
249 |
|
|
if (in_array($entry['ip'], array_keys($ndpdata))) {
|
250 |
|
|
$entry['online'] = 'online';
|
251 |
c1f4af16
|
jim-p
|
} else {
|
252 |
f6bda83c
|
jim-p
|
$entry['online'] = 'offline';
|
253 |
c1f4af16
|
jim-p
|
}
|
254 |
bcb24b81
|
jim-p
|
$f = $f+2;
|
255 |
|
|
break;
|
256 |
f6bda83c
|
jim-p
|
case "iaprefix":
|
257 |
|
|
$is_prefix = true;
|
258 |
|
|
$entry['prefix'] = $data[$f+1];
|
259 |
|
|
$entry['type'] = "dynamic";
|
260 |
|
|
$f = $f+2;
|
261 |
|
|
break;
|
262 |
c1640267
|
Seth Mos
|
case "starts":
|
263 |
f6bda83c
|
jim-p
|
$entry['start'] = $data[$f+2];
|
264 |
|
|
$entry['start'] .= " " . $data[$f+3];
|
265 |
c1640267
|
Seth Mos
|
$f = $f+3;
|
266 |
|
|
break;
|
267 |
|
|
case "ends":
|
268 |
f6bda83c
|
jim-p
|
$entry['end'] = $data[$f+2];
|
269 |
|
|
$entry['end'] .= " " . $data[$f+3];
|
270 |
c1640267
|
Seth Mos
|
$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 |
f6bda83c
|
jim-p
|
$entry['start'] = $data[$f+2];
|
283 |
|
|
$entry['start'] .= " " . $data[$f+3];
|
284 |
c1640267
|
Seth Mos
|
$f = $f+3;
|
285 |
|
|
break;
|
286 |
|
|
case "binding":
|
287 |
|
|
switch($data[$f+2]) {
|
288 |
|
|
case "active":
|
289 |
f6bda83c
|
jim-p
|
$entry['act'] = "active";
|
290 |
c1640267
|
Seth Mos
|
break;
|
291 |
|
|
case "free":
|
292 |
f6bda83c
|
jim-p
|
$entry['act'] = "expired";
|
293 |
|
|
$entry['online'] = "offline";
|
294 |
c1640267
|
Seth Mos
|
break;
|
295 |
|
|
case "backup":
|
296 |
f6bda83c
|
jim-p
|
$entry['act'] = "reserved";
|
297 |
|
|
$entry['online'] = "offline";
|
298 |
c1640267
|
Seth Mos
|
break;
|
299 |
f6bda83c
|
jim-p
|
case "released":
|
300 |
|
|
$entry['act'] = "released";
|
301 |
|
|
$entry['online'] = "offline";
|
302 |
c1640267
|
Seth Mos
|
}
|
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 |
f6bda83c
|
jim-p
|
$entry['hostname'] = preg_replace('/"/','',$data[$f+1]);
|
315 |
c1640267
|
Seth Mos
|
} else {
|
316 |
f6bda83c
|
jim-p
|
$hostname = gethostbyaddr($entry['ip']);
|
317 |
c1640267
|
Seth Mos
|
if($hostname <> "") {
|
318 |
f6bda83c
|
jim-p
|
$entry['hostname'] = $hostname;
|
319 |
c1640267
|
Seth Mos
|
}
|
320 |
|
|
}
|
321 |
|
|
$f = $f+1;
|
322 |
|
|
break;
|
323 |
|
|
case "uid":
|
324 |
|
|
$f = $f+1;
|
325 |
|
|
break;
|
326 |
|
|
}
|
327 |
|
|
$f++;
|
328 |
|
|
}
|
329 |
f6bda83c
|
jim-p
|
if ($is_prefix) {
|
330 |
|
|
$prefixes[] = $entry;
|
331 |
|
|
} else {
|
332 |
|
|
$leases[] = $entry;
|
333 |
|
|
$mappings[$entry['iaid'] . $entry['duid']] = $entry['ip'];
|
334 |
|
|
}
|
335 |
c1640267
|
Seth Mos
|
$l++;
|
336 |
|
|
$i++;
|
337 |
f6bda83c
|
jim-p
|
$is_prefix = false;
|
338 |
c1640267
|
Seth Mos
|
}
|
339 |
|
|
|
340 |
|
|
if(count($leases) > 0) {
|
341 |
|
|
$leases = remove_duplicate($leases,"ip");
|
342 |
|
|
}
|
343 |
|
|
|
344 |
f6bda83c
|
jim-p
|
if(count($prefixes) > 0) {
|
345 |
|
|
$prefixes = remove_duplicate($prefixes,"prefix");
|
346 |
|
|
}
|
347 |
|
|
|
348 |
c1640267
|
Seth Mos
|
if(count($pools) > 0) {
|
349 |
|
|
$pools = remove_duplicate($pools,"name");
|
350 |
|
|
asort($pools);
|
351 |
|
|
}
|
352 |
|
|
|
353 |
|
|
foreach($config['interfaces'] as $ifname => $ifarr) {
|
354 |
f6bda83c
|
jim-p
|
if (is_array($config['dhcpdv6'][$ifname]) &&
|
355 |
c1640267
|
Seth Mos
|
is_array($config['dhcpdv6'][$ifname]['staticmap'])) {
|
356 |
|
|
foreach($config['dhcpdv6'][$ifname]['staticmap'] as $static) {
|
357 |
|
|
$slease = array();
|
358 |
4151bdba
|
jim-p
|
$slease['ip'] = $static['ipaddrv6'];
|
359 |
c1640267
|
Seth Mos
|
$slease['type'] = "static";
|
360 |
4151bdba
|
jim-p
|
$slease['duid'] = $static['duid'];
|
361 |
c1640267
|
Seth Mos
|
$slease['start'] = "";
|
362 |
|
|
$slease['end'] = "";
|
363 |
|
|
$slease['hostname'] = htmlentities($static['hostname']);
|
364 |
|
|
$slease['act'] = "static";
|
365 |
9d539cb5
|
jim-p
|
if (in_array($slease['ip'], array_keys($ndpdata))) {
|
366 |
c1640267
|
Seth Mos
|
$slease['online'] = 'online';
|
367 |
|
|
} else {
|
368 |
|
|
$slease['online'] = 'offline';
|
369 |
|
|
}
|
370 |
4e85523b
|
jim-p
|
|
371 |
c1640267
|
Seth Mos
|
$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 |
61b07343
|
Colin Fleming
|
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases">
|
383 |
f6bda83c
|
jim-p
|
<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 |
c1640267
|
Seth Mos
|
<?php
|
391 |
|
|
foreach ($pools as $data) {
|
392 |
|
|
echo "<tr>\n";
|
393 |
61b07343
|
Colin Fleming
|
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 |
c1640267
|
Seth Mos
|
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 |
61b07343
|
Colin Fleming
|
<br/>
|
412 |
c1640267
|
Seth Mos
|
|
413 |
61b07343
|
Colin Fleming
|
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases">
|
414 |
c1640267
|
Seth Mos
|
<tr>
|
415 |
|
|
<td class="listhdrr"><a href="#"><?=gettext("IPv6 address"); ?></a></td>
|
416 |
f393a514
|
jim-p
|
<td class="listhdrr"><a href="#"><?=gettext("IAID"); ?></a></td>
|
417 |
c1f4af16
|
jim-p
|
<td class="listhdrr"><a href="#"><?=gettext("DUID"); ?></a></td>
|
418 |
2fdc8262
|
jim-p
|
<td class="listhdrr"><a href="#"><?=gettext("Hostname/MAC"); ?></a></td>
|
419 |
c1640267
|
Seth Mos
|
<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 |
61b07343
|
Colin Fleming
|
$fspane = " </span>";
|
430 |
c1640267
|
Seth Mos
|
} else {
|
431 |
61b07343
|
Colin Fleming
|
$fspans = "";
|
432 |
|
|
$fspane = " ";
|
433 |
c1640267
|
Seth Mos
|
}
|
434 |
9c070452
|
jim-p
|
|
435 |
c1640267
|
Seth Mos
|
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 |
9c070452
|
jim-p
|
$data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip']));
|
451 |
f6bda83c
|
jim-p
|
}
|
452 |
c1640267
|
Seth Mos
|
echo "<tr>\n";
|
453 |
61b07343
|
Colin Fleming
|
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 |
2fdc8262
|
jim-p
|
echo "<td class=\"listr\">{$fspans}";
|
457 |
|
|
if (!empty($data['hostname'])) {
|
458 |
8cd558b6
|
ayvis
|
echo htmlentities($data['hostname']) . "<br />";
|
459 |
2fdc8262
|
jim-p
|
}
|
460 |
f7cd2ed8
|
jim-p
|
|
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 |
8cd558b6
|
ayvis
|
if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; }
|
466 |
f7cd2ed8
|
jim-p
|
}
|
467 |
|
|
|
468 |
2fdc8262
|
jim-p
|
echo "{$fspane} </td>\n";
|
469 |
f6bda83c
|
jim-p
|
if ($data['type'] != "static") {
|
470 |
61b07343
|
Colin Fleming
|
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 |
f6bda83c
|
jim-p
|
} else {
|
473 |
61b07343
|
Colin Fleming
|
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
|
474 |
|
|
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
|
475 |
f6bda83c
|
jim-p
|
}
|
476 |
61b07343
|
Colin Fleming
|
echo "<td class=\"listr\">{$fspans}{$data['online']}{$fspane}</td>\n";
|
477 |
|
|
echo "<td class=\"listr\">{$fspans}{$data['act']}{$fspane}</td>\n";
|
478 |
f6bda83c
|
jim-p
|
|
479 |
c1640267
|
Seth Mos
|
if ($data['type'] == "dynamic") {
|
480 |
61b07343
|
Colin Fleming
|
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 |
c1640267
|
Seth Mos
|
} else {
|
483 |
f6bda83c
|
jim-p
|
echo "<td class=\"list\" valign=\"middle\">";
|
484 |
61b07343
|
Colin Fleming
|
echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_plus_mo.gif\" width=\"17\" height=\"17\" border=\"0\" alt=\"add\" /></td>\n";
|
485 |
c1640267
|
Seth Mos
|
}
|
486 |
|
|
|
487 |
|
|
/* Only show the button for offline dynamic leases */
|
488 |
|
|
if (($data['type'] == "dynamic") && ($data['online'] != "online")) {
|
489 |
61b07343
|
Colin Fleming
|
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 |
c1640267
|
Seth Mos
|
}
|
492 |
f6bda83c
|
jim-p
|
echo "</tr>\n";
|
493 |
c1640267
|
Seth Mos
|
}
|
494 |
|
|
}
|
495 |
f6bda83c
|
jim-p
|
?>
|
496 |
|
|
</table>
|
497 |
61b07343
|
Colin Fleming
|
<br/>
|
498 |
f6bda83c
|
jim-p
|
<h3>Delegated Prefixes</h3>
|
499 |
61b07343
|
Colin Fleming
|
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="prefixes">
|
500 |
f6bda83c
|
jim-p
|
<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 |
61b07343
|
Colin Fleming
|
$fspane = " </span>";
|
514 |
f6bda83c
|
jim-p
|
} else {
|
515 |
61b07343
|
Colin Fleming
|
$fspans = "";
|
516 |
|
|
$fspane = " ";
|
517 |
f6bda83c
|
jim-p
|
}
|
518 |
c1640267
|
Seth Mos
|
|
519 |
f6bda83c
|
jim-p
|
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 |
8cd558b6
|
ayvis
|
$dip = "<br />Routed To: {$mappings[$data['iaid'] . $data['duid']]}";
|
539 |
f6bda83c
|
jim-p
|
}
|
540 |
61b07343
|
Colin Fleming
|
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 |
f6bda83c
|
jim-p
|
if ($data['type'] != "static") {
|
544 |
61b07343
|
Colin Fleming
|
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 |
f6bda83c
|
jim-p
|
} else {
|
547 |
61b07343
|
Colin Fleming
|
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
|
548 |
|
|
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
|
549 |
f6bda83c
|
jim-p
|
}
|
550 |
61b07343
|
Colin Fleming
|
echo "<td class=\"listr\">{$fspans}{$data['act']}{$fspane}</td>\n";
|
551 |
f6bda83c
|
jim-p
|
echo "</tr>\n";
|
552 |
|
|
}
|
553 |
|
|
}
|
554 |
c1640267
|
Seth Mos
|
?>
|
555 |
|
|
</table>
|
556 |
61b07343
|
Colin Fleming
|
<br/>
|
557 |
|
|
<form action="status_dhcpv6_leases.php" method="get">
|
558 |
|
|
<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
|
559 |
c1640267
|
Seth Mos
|
<?php if ($_GET['all']): ?>
|
560 |
61b07343
|
Colin Fleming
|
<input type="hidden" name="all" value="0" />
|
561 |
|
|
<input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" />
|
562 |
c1640267
|
Seth Mos
|
<?php else: ?>
|
563 |
61b07343
|
Colin Fleming
|
<input type="hidden" name="all" value="1" />
|
564 |
|
|
<input type="submit" class="formbtn" value="<?=gettext("Show all configured leases"); ?>" />
|
565 |
c1640267
|
Seth Mos
|
<?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>
|