Revision 5f601060
Added by Phil Davis over 10 years ago
usr/local/www/diag_ndp.php | ||
---|---|---|
14 | 14 |
modification, are permitted provided that the following conditions are met: |
15 | 15 |
|
16 | 16 |
1. Redistributions of source code must retain the above copyright notice, |
17 |
this list of conditions and the following disclaimer. |
|
17 |
this list of conditions and the following disclaimer.
|
|
18 | 18 |
|
19 | 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. |
|
20 |
notice, this list of conditions and the following disclaimer in the
|
|
21 |
documentation and/or other materials provided with the distribution.
|
|
22 | 22 |
|
23 | 23 |
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
24 | 24 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
... | ... | |
60 | 60 |
$hwif[$config['interfaces'][$key]['if']] = $interface; |
61 | 61 |
} |
62 | 62 |
|
63 |
/* Array ( [0] => Neighbor [1] => Linklayer [2] => Address
|
|
64 |
[3] => Netif [4] => Expire [5] => S
|
|
63 |
/* Array ( [0] => Neighbor [1] => Linklayer [2] => Address |
|
64 |
[3] => Netif [4] => Expire [5] => S |
|
65 | 65 |
[6] => Flags ) */ |
66 | 66 |
$data = array(); |
67 | 67 |
array_shift($rawdata); |
... | ... | |
77 | 77 |
|
78 | 78 |
/* FIXME: Not ipv6 compatible dns resolving. PHP needs fixing */ |
79 | 79 |
function _getHostName($mac,$ip) |
80 |
{
|
|
81 |
if(is_ipaddr($ip)) { |
|
80 |
{ |
|
81 |
if (is_ipaddr($ip)) {
|
|
82 | 82 |
list($ip, $scope) = explode("%", $ip); |
83 |
if(gethostbyaddr($ip) <> "" and gethostbyaddr($ip) <> $ip)
|
|
83 |
if (gethostbyaddr($ip) <> "" and gethostbyaddr($ip) <> $ip) {
|
|
84 | 84 |
return gethostbyaddr($ip); |
85 |
else
|
|
85 |
} else {
|
|
86 | 86 |
return ""; |
87 |
} |
|
87 | 88 |
} |
88 | 89 |
} |
89 | 90 |
|
... | ... | |
92 | 93 |
// resolvable addresses will appear last in the list. |
93 | 94 |
foreach ($data as &$entry) { |
94 | 95 |
$dns = trim(_getHostName($entry['mac'], $entry['ipv6'])); |
95 |
if(trim($dns))
|
|
96 |
if (trim($dns)) {
|
|
96 | 97 |
$entry['dnsresolve'] = "$dns"; |
97 |
else
|
|
98 |
} else {
|
|
98 | 99 |
$entry['dnsresolve'] = "Z_ "; |
100 |
} |
|
99 | 101 |
} |
100 |
|
|
102 |
|
|
101 | 103 |
// Sort the data alpha first |
102 | 104 |
$data = msort($data, "dnsresolve"); |
103 | 105 |
|
... | ... | |
121 | 123 |
<?php |
122 | 124 |
|
123 | 125 |
// Flush buffers out to client so that they see Loading, please wait.... |
124 |
for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); } |
|
126 |
for ($i = 0; $i < ob_get_level(); $i++) { |
|
127 |
ob_end_flush(); |
|
128 |
} |
|
125 | 129 |
ob_implicit_flush(1); |
126 | 130 |
|
127 | 131 |
?> |
... | ... | |
144 | 148 |
$mac=trim($entry['mac']); |
145 | 149 |
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]); |
146 | 150 |
print $mac; |
147 |
if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; } |
|
151 |
if (isset($mac_man[$mac_hi])) { |
|
152 |
print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; |
|
153 |
} |
|
148 | 154 |
?> |
149 | 155 |
</td> |
150 | 156 |
<td class="listr"> |
... | ... | |
153 | 159 |
?> |
154 | 160 |
</td> |
155 | 161 |
<td class="listr"> |
156 |
<?php
|
|
157 |
if(isset($hwif[$entry['interface']]))
|
|
162 |
<?php |
|
163 |
if (isset($hwif[$entry['interface']])) {
|
|
158 | 164 |
echo $hwif[$entry['interface']]; |
159 |
else
|
|
165 |
} else {
|
|
160 | 166 |
echo $entry['interface']; |
167 |
} |
|
161 | 168 |
?> |
162 | 169 |
</td> |
163 | 170 |
</tr> |
Also available in: Unified diff
Code style usr-local-www diag