Rev 19 | Rev 21 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
16 | daniel-mar | 4 | * MAC (EUI-48 and EUI-64) utils for PHP |
15 | daniel-mar | 5 | * Copyright 2017 - 2023 Daniel Marschall, ViaThinkSoft |
20 | daniel-mar | 6 | * Version 2023-05-03 |
2 | daniel-mar | 7 | * |
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
9 | * you may not use this file except in compliance with the License. |
||
10 | * You may obtain a copy of the License at |
||
11 | * |
||
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
13 | * |
||
14 | * Unless required by applicable law or agreed to in writing, software |
||
15 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
17 | * See the License for the specific language governing permissions and |
||
18 | * limitations under the License. |
||
19 | */ |
||
20 | |||
18 | daniel-mar | 21 | // Very good resources for information about OUI, EUI, MAC, ... |
22 | // - https://mac-address.alldatafeeds.com/faq#how-to-recognise-mac-address-application |
||
23 | // - https://standards.ieee.org/wp-content/uploads/import/documents/tutorials/eui.pdf |
||
24 | // - https://en.m.wikipedia.org/wiki/Organizationally_unique_identifier |
||
25 | |||
15 | daniel-mar | 26 | const IEEE_MAC_REGISTRY = __DIR__ . '/../web-data'; |
2 | daniel-mar | 27 | |
15 | daniel-mar | 28 | /** |
20 | daniel-mar | 29 | * Checks if a MAC, EUI, ELI, AAI, SAI, or IPv6-Link-Local address is valid |
19 | daniel-mar | 30 | * @param string $mac MAC, EUI, or IPv6-Link-Local Address |
17 | daniel-mar | 31 | * @return bool True if it is valid |
15 | daniel-mar | 32 | */ |
33 | function mac_valid(string $mac): bool { |
||
17 | daniel-mar | 34 | $tmp = ipv6linklocal_to_mac48($mac); |
16 | daniel-mar | 35 | if ($tmp !== false) $mac = $tmp; |
36 | |||
2 | daniel-mar | 37 | $mac = str_replace(array('-', ':'), '', $mac); |
38 | $mac = strtoupper($mac); |
||
39 | |||
16 | daniel-mar | 40 | if ((strlen($mac) != 12) && (strlen($mac) != 16)) return false; |
2 | daniel-mar | 41 | |
42 | $mac = preg_replace('@[0-9A-F]@', '', $mac); |
||
43 | |||
16 | daniel-mar | 44 | return ($mac === ''); |
2 | daniel-mar | 45 | } |
46 | |||
15 | daniel-mar | 47 | /** |
20 | daniel-mar | 48 | * Returns the amount of bits of a MAC, EUI, ELI, AAI, or SAI |
16 | daniel-mar | 49 | * @param string $mac |
17 | daniel-mar | 50 | * @return false|int |
16 | daniel-mar | 51 | */ |
17 | daniel-mar | 52 | function eui_bits(string $mac) { |
53 | if (!mac_valid($mac)) return false; |
||
54 | $mac = mac_canonize($mac, ''); |
||
55 | return (int)(strlen($mac)*4); |
||
56 | } |
||
57 | |||
58 | /** |
||
20 | daniel-mar | 59 | * Canonizes a MAC, EUI, ELI, AAI, SAI, or IPv6-Link-Local address |
19 | daniel-mar | 60 | * @param string $mac MAC, EUI, ELI, or IPv6-Link-Local Address |
17 | daniel-mar | 61 | * @param string $delimiter Desired delimiter for inserting between each octet |
19 | daniel-mar | 62 | * @return string|false The canonized address (Note: IPv6-Link-Local becomes EUI-64) |
17 | daniel-mar | 63 | */ |
16 | daniel-mar | 64 | function mac_canonize(string $mac, string $delimiter="-") { |
65 | if (!mac_valid($mac)) return false; |
||
66 | |||
17 | daniel-mar | 67 | $tmp = ipv6linklocal_to_mac48($mac); |
16 | daniel-mar | 68 | if ($tmp !== false) $mac = $tmp; |
69 | |||
70 | $mac = strtoupper($mac); |
||
71 | $mac = preg_replace('@[^0-9A-F]@', '', $mac); |
||
72 | if ((strlen($mac) != 12) && (strlen($mac) != 16)) return false; |
||
73 | $mac = preg_replace('@^(..)(..)(..)(..)(..)(..)(..)(..)$@', '\\1'.$delimiter.'\\2'.$delimiter.'\\3'.$delimiter.'\\4'.$delimiter.'\\5'.$delimiter.'\\6'.$delimiter.'\\7'.$delimiter.'\\8', $mac); |
||
74 | return preg_replace('@^(..)(..)(..)(..)(..)(..)$@', '\\1'.$delimiter.'\\2'.$delimiter.'\\3'.$delimiter.'\\4'.$delimiter.'\\5'.$delimiter.'\\6', $mac); |
||
75 | } |
||
76 | |||
77 | /** |
||
15 | daniel-mar | 78 | * @param string $file |
79 | * @param string $oui_name |
||
80 | * @param string $mac |
||
81 | * @return false|string |
||
82 | */ |
||
83 | function _lookup_ieee_registry(string $file, string $oui_name, string $mac) { |
||
16 | daniel-mar | 84 | $mac = mac_canonize($mac, ''); |
85 | if ($mac === false) return false; |
||
2 | daniel-mar | 86 | $begin = substr($mac, 0, 2).'-'.substr($mac, 2, 2).'-'.substr($mac, 4, 2); |
87 | $f = file_get_contents($file); |
||
88 | |||
89 | $f = str_replace("\r", '', $f); |
||
90 | |||
91 | # We are using a positive-lookahead because entries like the MA-M references have a blank line between organization and address |
||
92 | preg_match_all('@^\s*'.preg_quote($begin, '@').'\s+\(hex\)\s+(\S+)\s+(.*)\n\n\s*(?=[0-9A-F])@ismU', "$f\n\nA", $m, PREG_SET_ORDER); |
||
93 | foreach ($m as $n) { |
||
94 | preg_match('@(\S+)\s+\(base 16\)(.*)$@ism', $n[2], $m); |
||
95 | |||
15 | daniel-mar | 96 | if (preg_match('@(.+)-(.+)@ism', $m[1], $o)) { |
2 | daniel-mar | 97 | $z = hexdec(substr($mac, 6, 6)); |
98 | $beg = hexdec($o[1]); |
||
99 | $end = hexdec($o[2]); |
||
100 | if (($z < $beg) || ($z > $end)) continue; |
||
101 | } else { |
||
102 | $beg = 0x000000; |
||
103 | $end = 0xFFFFFF; |
||
104 | } |
||
105 | |||
15 | daniel-mar | 106 | $x = trim(preg_replace('@^\s+@im', '', $m[2])); |
2 | daniel-mar | 107 | |
108 | # "PRIVATE" entries are only marked at the "(hex)" line, but not at the "(base16)" line |
||
109 | if ($x == '') $x = trim($n[1]); |
||
110 | |||
111 | $x = explode("\n", $x); |
||
112 | |||
113 | $ra_len = strlen(dechex($end-$beg)); |
||
114 | |||
15 | daniel-mar | 115 | $out = sprintf("%-32s 0x%s\n", "IEEE $oui_name part:", substr($mac, 0, 12-$ra_len)); |
116 | $out .= sprintf("%-32s 0x%s\n", "NIC specific part:", substr($mac, 12-$ra_len)); |
||
117 | $out .= sprintf("%-32s %s\n", "Registrant:", $x[0]); |
||
2 | daniel-mar | 118 | foreach ($x as $n => $y) { |
119 | if ($n == 0) continue; |
||
15 | daniel-mar | 120 | else if ($n == 1) $out .= sprintf("%-32s %s\n", "Address of registrant:", $y); |
121 | else if ($n >= 2) $out .= sprintf("%-32s %s\n", "", $y); |
||
2 | daniel-mar | 122 | } |
123 | |||
124 | return $out; |
||
125 | } |
||
126 | |||
127 | return false; |
||
128 | } |
||
129 | |||
15 | daniel-mar | 130 | /** |
17 | daniel-mar | 131 | * Try to Decapsulate EUI-64 into MAC-48 or EUI-48 |
16 | daniel-mar | 132 | * @param string $eui64 |
17 | daniel-mar | 133 | * @return false|string If EUI-64 can be converted into EUI-48, returns EUI-48, otherwise returns EUI-64. On invalid input, return false. |
16 | daniel-mar | 134 | */ |
135 | function eui64_to_eui48(string $eui64) { |
||
136 | if (!mac_valid($eui64)) return false; |
||
137 | $eui64 = mac_canonize($eui64, ''); |
||
138 | if (eui_bits($eui64) == 48) return mac_canonize($eui64); |
||
20 | daniel-mar | 139 | if (($eui64[1] != '0') && ($eui64[1] != '4') && ($eui64[1] != '8') && ($eui64[1] != 'C')) return false; // only allow EUI |
16 | daniel-mar | 140 | |
17 | daniel-mar | 141 | if (substr($eui64, 6, 4) == 'FFFF') { |
142 | // EUI-64 to MAC-48 |
||
16 | daniel-mar | 143 | return mac_canonize(substr($eui64, 0, 6).substr($eui64, 10, 6)); |
17 | daniel-mar | 144 | } else if (substr($eui64, 6, 4) == 'FFFE') { |
145 | if ((hexdec($eui64[1])&2) == 2) { |
||
146 | // Modified EUI-64 to MAC/EUI-48 |
||
147 | $eui64[1] = dechex(hexdec($eui64[1])&253); // remove bit |
||
148 | return mac_canonize(substr($eui64, 0, 6).substr($eui64, 10, 6)); |
||
149 | } else { |
||
150 | // EUI-64 to EUI-48 |
||
151 | return mac_canonize(substr($eui64, 0, 6).substr($eui64, 10, 6)); |
||
152 | } |
||
16 | daniel-mar | 153 | } else { |
154 | return mac_canonize($eui64); |
||
155 | } |
||
156 | } |
||
157 | |||
158 | /** |
||
17 | daniel-mar | 159 | * MAC-48 to EUI-64 Encapsulation |
160 | * @param string $mac48 MAC-48 address |
||
161 | * @return false|string EUI-64 address |
||
16 | daniel-mar | 162 | */ |
17 | daniel-mar | 163 | function mac48_to_eui64(string $mac48) { |
164 | // Note: MAC-48 is used for network hardware; EUI-48 is used to identify other devices and software. |
||
165 | // MAC48-to-EUI64 Encapsulation uses 0xFFFF middle part |
||
166 | if (!mac_valid($mac48)) return false; |
||
167 | $mac48 = mac_canonize($mac48, ''); |
||
168 | if (eui_bits($mac48) == 64) return mac_canonize($mac48); |
||
20 | daniel-mar | 169 | if (($mac48[1] != '0') && ($mac48[1] != '4') && ($mac48[1] != '8') && ($mac48[1] != 'C')) return false; // only allow EUI |
17 | daniel-mar | 170 | |
171 | $eui64 = substr($mac48, 0, 6).'FFFF'.substr($mac48, 6, 6); |
||
172 | return mac_canonize($eui64); |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * EUI-48 to EUI-64 Encapsulation |
||
177 | * @param string $eui48 EUI-48 address |
||
178 | * @return false|string EUI-64 address |
||
179 | */ |
||
16 | daniel-mar | 180 | function eui48_to_eui64(string $eui48) { |
17 | daniel-mar | 181 | // Note: MAC-48 is used for network hardware; EUI-48 is used to identify other devices and software. |
182 | // EUI48-to-EUI64 Encapsulation uses 0xFFFF middle part |
||
16 | daniel-mar | 183 | if (!mac_valid($eui48)) return false; |
184 | $eui48 = mac_canonize($eui48, ''); |
||
185 | if (eui_bits($eui48) == 64) return mac_canonize($eui48); |
||
20 | daniel-mar | 186 | if (($eui48[1] != '0') && ($eui48[1] != '4') && ($eui48[1] != '8') && ($eui48[1] != 'C')) return false; // only allow EUI |
16 | daniel-mar | 187 | |
188 | $eui64 = substr($eui48, 0, 6).'FFFE'.substr($eui48, 6, 6); |
||
189 | return mac_canonize($eui64); |
||
190 | } |
||
191 | |||
192 | /** |
||
17 | daniel-mar | 193 | * MAC/EUI-48 to Modified EUI-64 Encapsulation |
194 | * @param string $eui48 MAC-48 or EUI-48 address |
||
195 | * @return false|string Modified EUI-64 address |
||
16 | daniel-mar | 196 | */ |
17 | daniel-mar | 197 | function maceui48_to_modeui64(string $eui48) { |
198 | // Note: MAC-48 is used for network hardware; EUI-48 is used to identify other devices and software. |
||
199 | // EUI48-to-ModifiedEUI64 Encapsulation uses 0xFFFE middle part (SIC! This was a mistake by IETF, since it should actually be 0xFFFF!) |
||
200 | if (!mac_valid($eui48)) return false; |
||
201 | $eui48 = mac_canonize($eui48, ''); |
||
202 | if (eui_bits($eui48) == 64) return mac_canonize($eui48); |
||
20 | daniel-mar | 203 | if (($eui48[1] != '0') && ($eui48[1] != '4') && ($eui48[1] != '8') && ($eui48[1] != 'C')) return false; // only allow EUI |
17 | daniel-mar | 204 | |
205 | $eui64 = substr($eui48, 0, 6).'FFFE'.substr($eui48, 6, 6); |
||
206 | |||
207 | $eui64[1] = dechex(hexdec($eui64[1]) | 2); // flip seventh bit |
||
208 | |||
209 | return mac_canonize($eui64); |
||
210 | } |
||
211 | |||
212 | /** |
||
19 | daniel-mar | 213 | * Try to convert IPv6-Link-Local address to MAC-48 |
214 | * @param string $ipv6 IPv6-Link-Local address |
||
17 | daniel-mar | 215 | * @return false|string MAC-48 (or IPv6 if it was no LinkLocal address, or Modified EUI-64 if it decapsulation failed) |
216 | */ |
||
217 | function ipv6linklocal_to_mac48(string $ipv6) { |
||
16 | daniel-mar | 218 | // https://stackoverflow.com/questions/12095835/quick-way-of-expanding-ipv6-addresses-with-php (modified) |
219 | $tmp = inet_pton($ipv6); |
||
220 | if ($tmp === false) return false; |
||
221 | $hex = unpack("H*hex", $tmp); |
||
222 | $ipv6 = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1); |
||
223 | |||
19 | daniel-mar | 224 | // Remove "fe80::" to convert IPv6-Link-Local address back to EUI-64 |
16 | daniel-mar | 225 | // see https://support.lenovo.com/de/de/solutions/ht509925-how-to-convert-a-mac-address-into-an-ipv6-link-local-address-eui-64 |
226 | $cnt = 0; |
||
227 | $mac = preg_replace('@^fe80:0000:0000:0000:@i', '', $ipv6, -1, $cnt); |
||
228 | if ($cnt == 0) return false; |
||
229 | |||
230 | // Set LAA to UAA again |
||
17 | daniel-mar | 231 | $mac_uaa_64 = $mac; |
232 | $mac_uaa_64[1] = dechex(hexdec($mac_uaa_64[1]) & 253); |
||
16 | daniel-mar | 233 | |
17 | daniel-mar | 234 | $mac_uaa_48 = eui64_to_eui48($mac_uaa_64); |
235 | if (eui_bits($mac_uaa_48) == 48) { |
||
236 | return $mac_uaa_48; // Output MAC-48 (UAA) |
||
237 | } else { |
||
238 | return $mac; // Failed decapsulation; output Modified EUI-64 instead |
||
239 | } |
||
16 | daniel-mar | 240 | } |
241 | |||
242 | /** |
||
19 | daniel-mar | 243 | * Converts MAC-48 or EUI-48 to IPv6-Link-Local (based on Modified EUI-64) |
15 | daniel-mar | 244 | * @param string $mac |
16 | daniel-mar | 245 | * @return false|string |
246 | */ |
||
17 | daniel-mar | 247 | function maceui_to_ipv6linklocal(string $mac) { |
16 | daniel-mar | 248 | if (!mac_valid($mac)) return false; |
249 | if (eui_bits($mac) == 48) { |
||
17 | daniel-mar | 250 | $mac = maceui48_to_modeui64($mac); |
16 | daniel-mar | 251 | } |
252 | $mac = mac_canonize($mac, ''); |
||
253 | $mac = str_pad($mac, 16, '0', STR_PAD_LEFT); |
||
254 | return strtolower('fe80::'.substr($mac,0, 4).':'.substr($mac,4, 4).':'.substr($mac,8, 4).':'.substr($mac,12, 4)); |
||
255 | } |
||
256 | |||
257 | /** |
||
20 | daniel-mar | 258 | * @param string $mac |
259 | * @return string |
||
15 | daniel-mar | 260 | * @throws Exception |
261 | */ |
||
20 | daniel-mar | 262 | function mac_type(string $mac): string { |
17 | daniel-mar | 263 | // Format MAC for machine readability |
264 | $mac = mac_canonize($mac, ''); |
||
265 | |||
20 | daniel-mar | 266 | /** |
267 | * |
||
268 | * ZYXM |
||
269 | * 0 0000 EUI (OUI) |
||
270 | * 1 0001 |
||
271 | * 2 0010 AAI |
||
272 | * 3 0011 |
||
273 | * 4 0100 EUI (OUI) |
||
274 | * 5 0101 |
||
275 | * 6 0110 Reserved |
||
276 | * 7 0111 |
||
277 | * 8 1000 EUI (OUI) |
||
278 | * 9 1001 |
||
279 | * A 1010 ELI (CID) |
||
280 | * B 1011 |
||
281 | * C 1100 EUI (OUI) |
||
282 | * D 1101 |
||
283 | * E 1110 SAI |
||
284 | * F 1111 |
||
285 | * |
||
286 | */ |
||
287 | |||
16 | daniel-mar | 288 | $type = ''; |
20 | daniel-mar | 289 | $tmp = ipv6linklocal_to_mac48($mac); |
290 | if ($tmp !== false) { |
||
291 | $mac = $tmp; |
||
292 | $type = 'IPv6-Link-Local'; |
||
293 | } |
||
294 | if (!mac_valid($mac)) throw new Exception("Invalid MAC address"); |
||
295 | if ($tmp === false) { |
||
296 | if ($mac[1] == '2') { |
||
297 | /* |
||
298 | * AAI: Administratively Assigned Identifier |
||
299 | * Administrators who wish to assign local MAC addresses in an |
||
300 | * arbitrary fashion (for example, randomly) and yet maintain |
||
301 | * compatibility with other assignment protocols operating under the |
||
302 | * SLAP on the same LAN may assign a local MAC address as AAI. |
||
303 | */ |
||
304 | $type = 'AAI-' . eui_bits($mac).' (Administratively Assigned Identifier)'; |
||
305 | } else if ($mac[1] == '6') { |
||
306 | /* |
||
307 | * Reserved |
||
308 | * may be administratively used and assigned in accordance with the |
||
309 | * considerations specified for AAI usage, without effect on SLAP |
||
310 | * assignments. However, administrators should be cognizant of |
||
311 | * possible future specifications… that would render administrative |
||
312 | * assignment incompatible with the SLAP. |
||
313 | */ |
||
314 | $type = 'Reserved-' . eui_bits($mac); |
||
315 | } else if ($mac[1] == 'A') { |
||
316 | /* |
||
317 | * ELI: Extended Local Identifier |
||
318 | * An ELI is based on a 24 bit CID |
||
319 | * A CID has ZYXM bits set to 1010 (0b1010 = 0xA) |
||
320 | * Since X=1 (U/L=1), the CID cannot be used to form a universal UAA MAC (only a local LAA MAC) |
||
321 | */ |
||
322 | $type = 'ELI-' . eui_bits($mac).' (Extended Local Identifier)'; |
||
323 | } else if ($mac[1] == 'E') { |
||
324 | /* |
||
325 | * SAI: Standard Assigned Identifier |
||
326 | * Specification of the use of the SAI quadrant for SLAP address |
||
327 | * assignments is reserved for the standard forthcoming from IEEE |
||
328 | * P802.1CQ. |
||
329 | * An SAI is assigned by a protocol specified in an IEEE 802 standard. |
||
330 | * Multiple protocols for assigning SAI may be specified within various |
||
331 | * IEEE 802 standards. Coexistence of such protocols may be supported |
||
332 | * by restricting each to assignments within a subspace of SAI space. |
||
333 | * In some cases, an SAI assignment protocol may assign the SAI to convey |
||
334 | * specific information. Such information may be interpreted by receivers |
||
335 | * and bridges that recognize the specific SAI assignment protocol, as |
||
336 | * identified by the subspace of the SAI. The functionality of receivers |
||
337 | * and bridges that do not recognize the protocol is not affected. |
||
338 | */ |
||
339 | $type = 'SAI-' . eui_bits($mac).' (Standard Assigned Identifier)'; |
||
340 | } else if ((hexdec($mac[1])&1) == 1) { |
||
341 | $type = 'Multicast MAC-'.eui_bits($mac); |
||
342 | } else if (($mac[1] == '0') || ($mac[1] == '4') || ($mac[1] == '8') || ($mac[1] == 'C')) { |
||
343 | /* |
||
344 | * Extended Unique Identifier |
||
345 | * Based on an OUI-24, OUI-28, or OUI-36 |
||
346 | */ |
||
18 | daniel-mar | 347 | if (eui_bits($mac) == 48) { |
20 | daniel-mar | 348 | // The name "MAC-48" has been deprecated by IEEE |
349 | //$type = 'MAC-48 (network hardware) or EUI-48 (other devices and software)'; |
||
350 | $type = 'EUI-48 (Extended Unique Identifier)'; |
||
18 | daniel-mar | 351 | } else if (eui_bits($mac) == 64) { |
20 | daniel-mar | 352 | if (substr($mac, 6, 4) == 'FFFE') { |
353 | if ((hexdec($mac[1]) & 2) == 2) { |
||
354 | $type = 'EUI-64 (Extended Unique Identifier, MAC/EUI-48 to Modified EUI-64 Encapsulation)'; |
||
18 | daniel-mar | 355 | } else { |
20 | daniel-mar | 356 | $type = 'EUI-64 (Extended Unique Identifier, EUI-48 to EUI-64 Encapsulation)'; |
18 | daniel-mar | 357 | } |
20 | daniel-mar | 358 | } else if (substr($mac, 6, 4) == 'FFFF') { |
359 | $type = 'EUI-64 (Extended Unique Identifier, MAC-48 to EUI-64 Encapsulation)'; |
||
17 | daniel-mar | 360 | } else { |
20 | daniel-mar | 361 | $type = 'EUI-64 (Extended Unique Identifier)'; |
17 | daniel-mar | 362 | } |
363 | } else { |
||
18 | daniel-mar | 364 | assert(false); /** @phpstan-ignore-line */ |
17 | daniel-mar | 365 | } |
366 | } |
||
16 | daniel-mar | 367 | } |
20 | daniel-mar | 368 | return $type; |
369 | } |
||
370 | |||
371 | /** |
||
372 | * Prints information about an IPv6-Link-Local address, MAC, EUI, ELI, AAI, or SAI. |
||
373 | * @param string $mac IPv6-Link-Local address, MAC, EUI, ELI, AAI, or SAI |
||
374 | * @return void |
||
375 | * @throws Exception |
||
376 | */ |
||
377 | function decode_mac(string $mac) { |
||
378 | echo sprintf("%-32s %s\n", "Input:", $mac); |
||
379 | |||
380 | // Format MAC for machine readability |
||
381 | $mac = mac_canonize($mac, ''); |
||
382 | |||
383 | $type = mac_type($mac); |
||
16 | daniel-mar | 384 | echo sprintf("%-32s %s\n", "Type:", $type); |
15 | daniel-mar | 385 | |
16 | daniel-mar | 386 | echo "\n"; |
387 | |||
388 | // Show various representations |
||
18 | daniel-mar | 389 | if ($mac[1] == 'A') { |
20 | daniel-mar | 390 | // Note: There does not seem to exist an algorithm for encapsulating/converting ELI-48 <=> ELI-64 |
18 | daniel-mar | 391 | echo sprintf("%-32s %s\n", "ELI-".eui_bits($mac).":", mac_canonize($mac)); |
19 | daniel-mar | 392 | $mac48 = eui64_to_eui48($mac); |
393 | echo sprintf("%-32s %s\n", "MAC-48 (Local):", (eui_bits($mac48) != 48) ? 'Not available' : $mac48); |
||
20 | daniel-mar | 394 | } else if (($mac[1] == '0') || ($mac[1] == '4') || ($mac[1] == '8') || ($mac[1] == 'C')) { |
18 | daniel-mar | 395 | $eui48 = eui64_to_eui48($mac); |
19 | daniel-mar | 396 | echo sprintf("%-32s %s\n", "EUI-48 or MAC-48:", (eui_bits($eui48) != 48) ? 'Not available' : $eui48); |
18 | daniel-mar | 397 | if (eui_bits($mac) == 48) { |
398 | $eui64 = mac48_to_eui64($mac); |
||
399 | echo sprintf("%-32s %s\n", "EUI-64:", ((eui_bits($eui64) != 64) ? 'Not available' : $eui64).' (MAC-48 to EUI-64 Encapsulation)'); |
||
400 | $eui64 = eui48_to_eui64($mac); |
||
401 | echo sprintf("%-32s %s\n", "", ((eui_bits($eui64) != 64) ? 'Not available' : $eui64).' (EUI-48 to EUI-64 Encapsulation)'); |
||
402 | $eui64 = maceui48_to_modeui64($mac); |
||
403 | echo sprintf("%-32s %s\n", "", ((eui_bits($eui64) != 64) ? 'Not available' : $eui64).' (MAC/EUI-48 to Modified EUI-64 Encapsulation)'); |
||
404 | $ipv6 = maceui_to_ipv6linklocal($mac); |
||
19 | daniel-mar | 405 | echo sprintf("%-32s %s\n", "IPv6-Link-Local address:", $ipv6); |
18 | daniel-mar | 406 | } else { |
407 | $eui64 = mac_canonize($mac); |
||
408 | echo sprintf("%-32s %s\n", "EUI-64:", $eui64); |
||
409 | } |
||
17 | daniel-mar | 410 | } |
2 | daniel-mar | 411 | |
412 | // Vergabestelle |
||
413 | $ul = hexdec($mac[1]) & 2; // Bit #LSB+1 of Byte 1 |
||
414 | $ul_ = ($ul == 0) ? '[0] Universally Administered Address (UAA)' : '[1] Locally Administered Address (LAA)'; |
||
15 | daniel-mar | 415 | echo sprintf("%-32s %s\n", "Administration type (U/L flag):", $ul_); |
2 | daniel-mar | 416 | |
16 | daniel-mar | 417 | // Empfaengergruppe |
418 | $ig = hexdec($mac[1]) & 1; // Bit #LSB+0 of Byte 1 |
||
18 | daniel-mar | 419 | $ig_ = ($ig == 0) ? '[0] Unicast (Individual)' : '[1] Multicast (Group)'; |
16 | daniel-mar | 420 | echo sprintf("%-32s %s\n", "Transmission type (I/G flag):", $ig_); |
421 | |||
2 | daniel-mar | 422 | // Query IEEE registries |
17 | daniel-mar | 423 | if (count(glob(IEEE_MAC_REGISTRY.DIRECTORY_SEPARATOR.'*.txt')) > 0) { |
18 | daniel-mar | 424 | if ($mac[1] == 'A') { |
425 | // Query the CID registry |
||
426 | if ( |
||
427 | ($x = _lookup_ieee_registry(IEEE_MAC_REGISTRY . DIRECTORY_SEPARATOR . 'cid.txt', 'CID', $mac)) |
||
428 | ) { |
||
429 | echo $x; |
||
430 | } |
||
431 | } else { |
||
432 | // Query the OUI registries |
||
433 | // TODO: Should we try to convert Unicast<=>Multicast if one of them can't be found? |
||
434 | if ( |
||
435 | # The IEEE Registration Authority distinguishes between IABs and OUI-36 values. Both are 36-bit values which may be used to generate EUI-48 values, but IABs may not be used to generate EUI-64 values.[6] |
||
436 | # Note: The Individual Address Block (IAB) is an inactive registry activity, which has been replaced by the MA-S registry product as of January 1, 2014. |
||
437 | ($x = _lookup_ieee_registry(IEEE_MAC_REGISTRY . DIRECTORY_SEPARATOR . 'iab.txt', 'IAB', $mac)) || |
||
438 | ($x = _lookup_ieee_registry(IEEE_MAC_REGISTRY . DIRECTORY_SEPARATOR . 'oui36.txt', 'OUI-36 (MA-S)', $mac)) || |
||
439 | ($x = _lookup_ieee_registry(IEEE_MAC_REGISTRY . DIRECTORY_SEPARATOR . 'mam.txt', 'OUI-28 (MA-M)', $mac)) || |
||
440 | ($x = _lookup_ieee_registry(IEEE_MAC_REGISTRY . DIRECTORY_SEPARATOR . 'oui.txt', 'OUI-24 (MA-L)', $mac)) |
||
441 | ) { |
||
442 | echo $x; |
||
443 | } |
||
15 | daniel-mar | 444 | } |
2 | daniel-mar | 445 | } |
446 | |||
15 | daniel-mar | 447 | $vm = ''; |
448 | // === FAQ "Detection rules which don't have their dedicated page yet" === |
||
449 | // https://wiki.xenproject.org/wiki/Xen_Networking |
||
450 | // https://mcpmag.com/articles/2007/11/27/hey-vm-whats-your-hypervisor.aspx |
||
451 | // https://www.techrepublic.com/blog/data-center/mac-address-scorecard-for-common-virtual-machine-platforms |
||
452 | if (mac_between($mac, '00:16:3E:00:00:00', '00:16:3E:FF:FF:FF')) $vm = "Red Hat Xen, XenSource, Novell Xen"; |
||
453 | // http://techgenix.com/mac-address-pool-duplication-hyper-v/ |
||
454 | // https://docs.microsoft.com/en-us/system-center/vmm/network-mac?view=sc-vmm-1807 |
||
455 | // https://blogs.technet.microsoft.com/gbanin/2014/08/27/how-to-solve-mac-address-conflict-on-hyper-v/ |
||
456 | if (mac_between($mac, '00:1D:D8:B7:1C:00', '00:1D:D8:F4:1F:FF')) $vm = "Microsoft SCVMM (System Center Virtual Machine Manager)"; |
||
457 | // https://mcpmag.com/articles/2007/11/27/hey-vm-whats-your-hypervisor.aspx |
||
458 | // https://www.techrepublic.com/blog/data-center/mac-address-scorecard-for-common-virtual-machine-platforms/ |
||
459 | // https://blogs.technet.microsoft.com/medv/2011/01/24/how-to-manage-vm-mac-addresses-with-the-globalimagedata-xml-file-in-med-v-v1/ |
||
460 | if (mac_between($mac, '00:03:FF:00:00:00', '00:03:FF:FF:FF:FF')) $vm = "Microsoft Virtual PC / Virtual Server"; |
||
461 | // https://mcpmag.com/articles/2007/11/27/hey-vm-whats-your-hypervisor.aspx |
||
462 | if (mac_between($mac, '00:18:51:00:00:00', '00:18:51:FF:FF:FF')) $vm = "SWsoft"; |
||
463 | // https://macaddress.io/statistics/company/17619 |
||
464 | if (mac_between($mac, '58:9C:FC:00:00:00', '58:9C:FC:FF:FF:FF')) $vm = "bhyve by FreebsdF"; |
||
465 | // https://macaddress.io/statistics/company/17388 |
||
466 | if (mac_between($mac, '50:6B:8D:00:00:00', '50:6B:8D:FF:FF:FF')) $vm = "Nutanix AHV"; |
||
467 | // https://www.centos.org/forums/viewtopic.php?t=26739 |
||
468 | if (mac_between($mac, '54:52:00:00:00:00', '54:52:FF:FF:FF:FF')) $vm = "KVM (proxmox)"; |
||
469 | // Self tested (alldatafeeds.com) |
||
470 | if (mac_between($mac, '96:00:00:00:00:00', '96:00:FF:FF:FF:FF')) $vm = "Hetzner vServer (based on KVM and libvirt)"; |
||
471 | // === FAQ "How to recognise a VMware's virtual machine by its MAC address?" === |
||
472 | if (mac_between($mac, '00:50:56:00:00:00', '00:50:56:FF:FF:FF')) $vm = "VMware vSphere, VMware Workstation, VMware ESX Server"; |
||
473 | if (mac_between($mac, '00:50:56:80:00:00', '00:50:56:BF:FF:FF')) $vm = "VMware vSphere managed by vCenter Server"; |
||
474 | if (mac_between($mac, '00:0C:29:00:00:00', '00:0C:29:FF:FF:FF')) $vm = "VMWare Standalone VMware vSphere, VMware Workstation, VMware Horizon"; |
||
475 | if (mac_between($mac, '00:05:69:00:00:00', '00:05:69:FF:FF:FF')) $vm = "VMware ESX, VMware GSX Server"; |
||
476 | if (mac_between($mac, '00:1C:14:00:00:00', '00:1C:14:FF:FF:FF')) $vm = "VMWare"; |
||
477 | // === FAQ "machine by its MAC address?" === |
||
478 | if (mac_between($mac, '00:1C:42:00:00:00', '00:1C:42:FF:FF:FF')) $vm = "Parallels Virtual Machine"; |
||
479 | // === FAQ "How to recognise a Docker container by its MAC address?" === |
||
480 | if (mac_between($mac, '02:42:00:00:00:00', '02:42:FF:FF:FF:FF')) $vm = "Docker container"; |
||
481 | // === FAQ =How to recognise a Microsoft Hyper-V's virtual machine by its MAC address?" === |
||
482 | if (mac_between($mac, '00:15:5D:00:00:00', '00:15:5D:FF:FF:FF')) $vm = "Microsoft Hyper-V"; |
||
483 | // === FAQ "How to recognise an Oracle Virtual machine by its MAC address?" === |
||
484 | if (mac_between($mac, '08:00:27:00:00:00', '08:00:27:FF:FF:FF')) $vm = "Oracle VirtualBox 5.2"; // Pcs Systemtechnik GmbH |
||
485 | if (mac_between($mac, '52:54:00:00:00:00', '52:54:00:FF:FF:FF')) $vm = "Oracle VirtualBox 5.2 + Vagrant"; // 52:54:00 (Exact MAC: 52:54:00:C9:C7:04) |
||
486 | if (mac_between($mac, '00:21:F6:00:00:00', '00:21:F6:FF:FF:FF')) $vm = "Oracle VirtualBox 3.3"; |
||
487 | if (mac_between($mac, '00:14:4F:00:00:00', '00:14:4F:FF:FF:FF')) $vm = "Oracle VM Server for SPARC"; |
||
488 | if (mac_between($mac, '00:0F:4B:00:00:00', '00:0F:4B:FF:FF:FF')) $vm = "Oracle Virtual Iron 4"; |
||
2 | daniel-mar | 489 | |
15 | daniel-mar | 490 | if ($vm) { |
491 | echo sprintf("%-32s %s\n", "Special use:", "Virtual machine $vm"); |
||
492 | } |
||
2 | daniel-mar | 493 | |
15 | daniel-mar | 494 | $app = ''; |
495 | |||
496 | // === FAQ "Other MAC address applications" |
||
497 | // http://www.cavebear.com/archive/cavebear/Ethernet/Ethernet.txt |
||
498 | // https://tools.ietf.org/html/rfc1060 |
||
499 | if (mac_between($mac, '03:00:00:01:00:00', '03:00:40:00:00:00')) $app = 'User-defined (per 802 spec), EtherType is 0x0802'; |
||
500 | if (mac_equals($mac, '01:00:1D:00:00:00')) $app = 'Cabletron PC-OV PC discover (on demand), EtherType is 0x0802'; |
||
501 | if (mac_equals($mac, '01:00:1D:42:00:00')) $app = 'Cabletron PC-OV Bridge discover (on demand), EtherType is 0x0802'; |
||
502 | if (mac_equals($mac, '01:00:1D:52:00:00')) $app = 'Cabletron PC-OV MMAC discover (on demand), EtherType is 0x0802'; |
||
503 | if (mac_between($mac, '01:00:3C:00:00:00' , '01:00:3C:FF:FF:FF')) $app = 'Auspex Systems (Serverguard)'; |
||
504 | if (mac_equals($mac, '01:00:10:00:00:20')) $app = 'Hughes Lan Systems Terminal Server S/W download, EtherType is 0x0802'; |
||
505 | if (mac_equals($mac, '01:00:10:FF:FF:20')) $app = 'Hughes Lan Systems Terminal Server S/W request, EtherType is 0x0802'; |
||
506 | if (mac_equals($mac, '01:00:81:00:00:00')) $app = 'Synoptics Network Management'; |
||
507 | if (mac_equals($mac, '01:00:81:00:00:02')) $app = 'Synoptics Network Management'; |
||
508 | if (mac_equals($mac, '01:00:81:00:01:00')) $app = 'Bay Networks (Synoptics) autodiscovery, EtherType is 0x0802 SNAP type is 0x01A2'; |
||
509 | if (mac_equals($mac, '01:00:81:00:01:01')) $app = 'Bay Networks (Synoptics) autodiscovery, EtherType is 0x0802 SNAP type is 0x01A1'; |
||
510 | if (mac_between($mac, '01:20:25:00:00:00', '01:20:25:7F:FF:FF')) $app = 'Control Technology Inc\'s Industrial Ctrl Proto., EtherType is 0x873A'; |
||
511 | if (mac_equals($mac, '01:80:24:00:00:00')) $app = 'Kalpana Etherswitch every 60 seconds, EtherType is 0x0802'; |
||
512 | if (mac_equals($mac, '01:DD:00:FF:FF:FF')) $app = 'Ungermann-Bass boot-me requests, EtherType is 0x7002'; |
||
513 | if (mac_equals($mac, '01:DD:01:00:00:00')) $app = 'Ungermann-Bass Spanning Tree, EtherType is 0x7005'; |
||
514 | if (mac_equals($mac, '03:00:00:00:00:10')) $app = 'OS/2 1.3 EE + Communications Manager, EtherType is 0x80D5'; |
||
515 | if (mac_equals($mac, '03:00:00:00:00:40')) $app = 'OS/2 1.3 EE + Communications Manager, EtherType is 0x80D5'; |
||
516 | if (mac_equals($mac, '03:00:00:00:01:00')) $app = 'OSI All-IS Multicast, EtherType is 0x0802'; |
||
517 | if (mac_equals($mac, '03:00:00:00:02:00')) $app = 'OSI All-ES Multicast, EtherType is 0x0802'; |
||
518 | if (mac_equals($mac, '03:00:00:80:00:00')) $app = 'Discovery Client, EtherType is 0x0802'; |
||
519 | if (mac_equals($mac, '03:00:FF:FF:FF:FF')) $app = 'All Stations address, EtherType is 0x0802'; |
||
520 | if (mac_between($mac, '09:00:0D:00:00:00', '09:00:0D:FF:FF:FF')) $app = 'ICL Oslan Multicast, EtherType is 0x0802'; |
||
521 | if (mac_equals($mac, '09:00:0D:02:00:00')) $app = 'ICL Oslan Service discover only on boot'; |
||
522 | if (mac_equals($mac, '09:00:0D:02:0A:3C')) $app = 'ICL Oslan Service discover only on boot'; |
||
523 | if (mac_equals($mac, '09:00:0D:02:0A:38')) $app = 'ICL Oslan Service discover only on boot'; |
||
524 | if (mac_equals($mac, '09:00:0D:02:0A:39')) $app = 'ICL Oslan Service discover only on boot'; |
||
525 | if (mac_equals($mac, '09:00:0D:02:FF:FF')) $app = 'ICL Oslan Service discover only on boot'; |
||
526 | if (mac_equals($mac, '09:00:0D:09:00:00')) $app = 'ICL Oslan Service discover as required'; |
||
527 | if (mac_equals($mac, '09:00:1E:00:00:00')) $app = 'Apollo DOMAIN, EtherType is 0x8019'; |
||
528 | if (mac_equals($mac, '09:00:02:04:00:01')) $app = 'Vitalink printer messages, EtherType is 0x8080'; |
||
529 | if (mac_equals($mac, '09:00:02:04:00:02')) $app = 'Vitalink bridge management, EtherType is 0x8080'; |
||
530 | if (mac_equals($mac, '09:00:4C:00:00:0F')) $app = 'BICC Remote bridge adaptive routing (e.g. to Retix), EtherType is 0x0802'; |
||
531 | if (mac_equals($mac, '09:00:4E:00:00:02')) $app = 'Novell IPX, EtherType is 0x8137'; |
||
532 | if (mac_equals($mac, '09:00:6A:00:01:00')) $app = 'TOP NetBIOS'; |
||
533 | if (mac_equals($mac, '09:00:7C:01:00:01')) $app = 'Vitalink DLS Multicast'; |
||
534 | if (mac_equals($mac, '09:00:7C:01:00:03')) $app = 'Vitalink DLS Inlink'; |
||
535 | if (mac_equals($mac, '09:00:7C:01:00:04')) $app = 'Vitalink DLS and non DLS Multicast'; |
||
536 | if (mac_equals($mac, '09:00:7C:02:00:05')) $app = 'Vitalink diagnostics, EtherType is 0x8080'; |
||
537 | if (mac_equals($mac, '09:00:7C:05:00:01')) $app = 'Vitalink gateway, EtherType is 0x8080'; |
||
538 | if (mac_equals($mac, '09:00:7C:05:00:02')) $app = 'Vitalink Network Validation Message'; |
||
539 | if (mac_equals($mac, '09:00:09:00:00:01')) $app = 'HP Probe, EtherType is 0x8005 or 0x0802'; |
||
540 | if (mac_equals($mac, '09:00:09:00:00:04')) $app = 'HP DTC, EtherType is 0x8005'; |
||
541 | if (mac_equals($mac, '09:00:26:01:00:01')) $app = 'Vitalink TransLAN bridge management, EtherType is 0x8038'; |
||
542 | if (mac_equals($mac, '09:00:39:00:70:00')) $app = 'Spider Systems Bridge'; |
||
543 | if (mac_between($mac, '09:00:56:00:00:00', '09:00:56:FE:FF:FF')) $app = 'Stanford reserved'; |
||
544 | if (mac_between($mac, '09:00:56:FF:00:00', '09:00:56:FF:FF:FF')) $app = 'Stanford V Kernel, version 6.0, EtherType is 0x805C'; |
||
545 | if (mac_equals($mac, '09:00:77:00:00:00')) $app = 'Retix Bridge Local Management System, EtherType is 0x0802'; |
||
546 | if (mac_equals($mac, '09:00:77:00:00:01')) $app = 'Retix spanning tree bridges, EtherType is 0x0802'; |
||
547 | if (mac_equals($mac, '09:00:77:00:00:02')) $app = 'Retix Bridge Adaptive routing, EtherType is 0x0802'; |
||
548 | if (mac_equals($mac, '09:00:87:80:FF:FF')) $app = 'Xyplex Terminal Servers, EtherType is 0x0889'; |
||
549 | if (mac_equals($mac, '09:00:87:90:FF:FF')) $app = 'Xyplex Terminal Servers, EtherType is 0x0889'; |
||
550 | if (mac_between($mac, '44:38:39:FF:00:00', '44:38:39:FF:FF:FF')) $app = 'Multi-Chassis Link Aggregation (Cumulus Linux)'; |
||
551 | if (mac_equals($mac, 'FF:FF:00:40:00:01')) $app = 'LANtastic, EtherType is 0x81D6'; |
||
552 | if (mac_equals($mac, 'FF:FF:00:60:00:04')) $app = 'LANtastic, EtherType is 0x81D6'; |
||
553 | if (mac_equals($mac, 'FF:FF:01:E0:00:04')) $app = 'LANtastic'; |
||
554 | |||
555 | // === FAQ "The "CF" series MAC addresses" === |
||
556 | // https://www.iana.org/assignments/ppp-numbers/ppp-numbers.xhtml |
||
557 | // https://tools.ietf.org/html/rfc2153 |
||
558 | // https://tools.ietf.org/html/rfc7042#section-2.3.2 |
||
559 | if (mac_between($mac, 'CF:00:00:00:00:00', 'CF:00:00:FF:FF:FF')) $app = 'Reserved'; |
||
560 | if (mac_equals($mac, 'CF:00:00:00:00:00')) $app = 'Used for Ethernet loopback tests'; |
||
561 | |||
562 | // === FAQ "How to recognise a Broadcast MAC address application?" === |
||
19 | daniel-mar | 563 | // According to https://standards.ieee.org/wp-content/uploads/import/documents/tutorials/eui.pdf FFFFFFFFFFFF can be used as NULL EUI |
564 | if (mac_equals($mac, 'FF:FF:FF:FF:FF:FF')) echo sprintf("%-32s %s\n", "Special use:", "Broadcast messaging or Null-EUI"); |
||
15 | daniel-mar | 565 | |
566 | // === FAQ "How to recognise a Virtual Router ID by MAC address?" === |
||
567 | // https://tools.ietf.org/html/rfc7042#section-5.1 |
||
568 | // https://tools.ietf.org/html/rfc5798 |
||
569 | if (mac_between($mac, '00:00:5E:00:01:00', '00:00:5E:00:01:FF')) $app = 'IPv4 Virtual Router Redundancy Protocol (VRRP)'; |
||
570 | if (mac_between($mac, '00:00:5E:00:02:00', '00:00:5E:00:02:FF')) $app = 'IPv6 Virtual Router Redundancy Protocol'; |
||
571 | |||
572 | // === FAQ "How to recognise an IP frame by MAC address?" === |
||
573 | // https://tools.ietf.org/html/rfc1060 |
||
574 | // https://en.wikipedia.org/wiki/Multicast_address#cite_note-15 |
||
575 | // https://tools.ietf.org/html/rfc2464 |
||
576 | // https://www.iana.org/go/rfc1112 |
||
577 | // http://www.cavebear.com/archive/cavebear/Ethernet/Ethernet.txt |
||
578 | if (mac_between($mac, '01:00:5E:00:00:00', '01:00:5E:7F:FF:FF')) $app = 'IPv4 Multicast (EtherType is 0x0800)'; |
||
579 | if (mac_between($mac, '33:33:00:00:00:00', '33:33:FF:FF:FF:FF')) $app = 'IPv6 Multicast. IPv6 neighbor discovery (EtherType is 0x86DD)'; // TODO: Dabei werden die untersten 32 Bit der IPv6-Multicast-Adresse in die MAC-Adresse eingebettet. |
||
580 | if (mac_between($mac, '00:00:5E:00:52:13', '00:00:5E:00:52:13')) $app = 'Proxy Mobile IPv6'; |
||
16 | daniel-mar | 581 | if (mac_between($mac, '00:00:5E:FE:C0:00:02:00', '00:00:5E:FE:C0:00:02:FF')) $app = 'IPv4 derived documentation'; |
582 | if (mac_between($mac, '00:00:5E:FE:C6:33:64:00', '00:00:5E:FE:C6:33:64:FF')) $app = 'IPv4 derived documentation'; |
||
583 | if (mac_between($mac, '00:00:5E:FE:CB:00:71:00', '00:00:5E:FE:CB:00:71:FF')) $app = 'IPv4 derived documentation'; |
||
584 | if (mac_equals($mac, '00:00:5E:FE:EA:C0:00:02')) $app = 'IPv4 multicast derived documentation'; |
||
585 | if (mac_equals($mac, '00:00:5E:FE:EA:C6:33:64')) $app = 'IPv4 multicast derived documentation'; |
||
586 | if (mac_equals($mac, '00:00:5E:FE:EA:CB:00:71')) $app = 'IPv4 multicast derived documentation'; |
||
587 | if (mac_between($mac, '01:00:5E:FE:C0:00:02:00', '01:00:5E:FE:C0:00:02:FF')) $app = 'IPv4 derived documentation'; |
||
588 | if (mac_between($mac, '01:00:5E:FE:C6:33:64:00', '01:00:5E:FE:C6:33:64:FF')) $app = 'IPv4 derived documentation'; |
||
589 | if (mac_between($mac, '01:00:5E:FE:CB:00:71:00', '01:00:5E:FE:CB:00:71:FF')) $app = 'IPv4 derived documentation'; |
||
590 | if (mac_equals($mac, '01:00:5E:FE:EA:C0:00:02')) $app = 'IPv4 multicast derived documentation'; |
||
591 | if (mac_equals($mac, '01:00:5E:FE:EA:C6:33:64')) $app = 'IPv4 multicast derived documentation'; |
||
592 | if (mac_equals($mac, '01:00:5E:FE:EA:CB:00:71')) $app = 'IPv4 multicast derived documentation'; |
||
15 | daniel-mar | 593 | if (mac_between($mac, '01:80:C2:00:00:20', '01:80:C2:00:00:2F')) $app = 'Reserved for use by Multiple Registration Protocol (MRP) applications'; |
16 | daniel-mar | 594 | if (mac_between($mac, '02:00:5E:FE:00:00:00:00', '02:00:5E:FE:FF:FF:FF:FF')) $app = 'IPv4 Addr Holders'; |
15 | daniel-mar | 595 | if (mac_equals($mac, '03:00:00:20:00:00')) $app = 'IP multicast address'; |
596 | if (mac_equals($mac, 'C0:00:00:04:00:00')) $app = 'IP multicast address'; |
||
16 | daniel-mar | 597 | if (mac_between($mac, '03:00:5E:FE:00:00:00:00', '03:00:5E:FE:FF:FF:FF:FF')) $app = 'IPv4 Addr Holders'; |
15 | daniel-mar | 598 | |
599 | // === FAQ "How to recognise a MPLS multicast frame by MAC address?" === |
||
600 | // http://www.iana.org/go/rfc5332 |
||
601 | // http://www.iana.org/go/rfc7213 |
||
602 | if (mac_between($mac, '01:00:5E:80:00:00', '01:00:5E:8F:FF:FF')) $app = 'MPLS multicast (EtherType is 0x8847 or 0x8848)'; |
||
603 | if (mac_equals($mac, '01:00:5E:90:00:00')) $app = 'MPLS-TP p2p'; |
||
604 | |||
605 | // === FAQ "How to recognise a Bidirectional Forwarding Detection (BFD) on Link Aggregation Group (LAG) interfaces by MAC address?" === |
||
606 | // http://www.iana.org/go/rfc7130 |
||
607 | if (mac_equals($mac, '01:00:5E:90:00:01')) $app = 'Bidirectional Forwarding Detection (BFD) on Link Aggregation Group (LAG) interfaces'; |
||
608 | |||
609 | // === FAQ "How to recognise Token Ring specific functions by MAC address?" === |
||
610 | // https://tools.ietf.org/html/rfc1060 |
||
611 | // https://tools.ietf.org/html/rfc1469 |
||
612 | // https://standards.ieee.org/products-services/regauth/grpmac/public.html |
||
613 | // https://tools.ietf.org/html/rfc2470 |
||
614 | // http://www.cavebear.com/archive/cavebear/Ethernet/Ethernet.txt |
||
615 | if (mac_equals($mac, '03:00:00:00:00:01')) $app = 'NetBIOS (Token Ring)'; |
||
616 | if (mac_equals($mac, '03:00:00:00:00:02')) $app = 'Locate - Directory Server (Token Ring)'; |
||
617 | if (mac_equals($mac, '03:00:00:00:00:04')) $app = 'Synchronous Bandwidth Manager (Token Ring)'; |
||
618 | if (mac_equals($mac, '03:00:00:00:00:08')) $app = 'Configuration Report Server (Token Ring)'; |
||
619 | if (mac_equals($mac, '03:00:00:00:00:10')) $app = 'Ring Error Monitor (Token Ring)'; |
||
620 | if (mac_equals($mac, '03:00:00:00:00:20')) $app = 'Network Server Heartbeat (Token Ring)'; |
||
621 | if (mac_equals($mac, '03:00:00:00:00:40')) $app = 'Ring Parameter Monitor (Token Ring)'; |
||
622 | if (mac_equals($mac, '03:00:00:00:00:80')) $app = 'Active Monitor (Token Ring)'; |
||
623 | if (mac_equals($mac, '03:00:00:00:04:00')) $app = 'LAN Manager (Token Ring)'; |
||
624 | if (mac_equals($mac, '03:00:00:00:08:00')) $app = 'Ring Wiring Concentrator (Token Ring)'; |
||
625 | if (mac_equals($mac, '03:00:00:00:10:00')) $app = 'LAN Gateway (Token Ring)'; |
||
626 | if (mac_equals($mac, '03:00:00:00:20:00')) $app = 'Ring Authorization Server (Token Ring)'; |
||
627 | if (mac_equals($mac, '03:00:00:00:40:00')) $app = 'IMPL Server (Token Ring)'; |
||
628 | if (mac_equals($mac, '03:00:00:00:80:00')) $app = 'Bridge (Token Ring)'; |
||
629 | if (mac_equals($mac, '03:00:00:20:00:00')) $app = 'Single Token-Ring functional address'; |
||
630 | if (mac_equals($mac, '03:00:00:00:00:08')) $app = 'Configuration Report Server (CRS) MAC Group address'; |
||
631 | if (mac_equals($mac, '03:00:00:00:00:10')) $app = 'Ring Error Monitor (REM) MAC Group address'; |
||
632 | if (mac_equals($mac, '03:00:00:00:00:40')) $app = 'Ring Parameter Server (RPS) MAC group address'; |
||
633 | if (mac_equals($mac, '03:00:00:00:01:00')) $app = 'All Intermediate System Network Entities address'; |
||
634 | if (mac_equals($mac, '03:00:00:00:02:00')) $app = 'All End System Network Entities address, and Lobe Media Test (LMT) MAC group address'; |
||
635 | if (mac_equals($mac, '03:00:00:00:04:00')) $app = 'Generic address for all Manager Stations'; |
||
636 | if (mac_equals($mac, '03:00:00:00:08:00')) $app = 'All CONs SNARES address'; |
||
637 | if (mac_equals($mac, '03:00:00:00:10:00')) $app = 'All CONs End System address'; |
||
638 | if (mac_equals($mac, '03:00:00:00:20:00')) $app = 'Loadable Device Generic address'; |
||
639 | if (mac_equals($mac, '03:00:00:00:40:00')) $app = 'Load Server Generic address'; |
||
640 | if (mac_equals($mac, '03:00:00:40:00:00')) $app = 'Generic address for all Agent Stations'; |
||
641 | if (mac_equals($mac, 'C0:00:00:04:00:00')) $app = 'Single Token-Ring functional address'; |
||
642 | if (mac_equals($mac, '03:00:80:00:00:00')) $app = 'IPv6 multicast over Token Ring: all-Nodes (FF01::1 and FF02::1) and solicited node (FF02:0:0:0:0:1:FFXX:XXXX) addresses'; |
||
643 | if (mac_equals($mac, '03:00:40:00:00:00')) $app = 'IPv6 multicast over Token Ring: all-Routers addresses (FF0X::2)'; |
||
644 | if (mac_equals($mac, '03:00:00:80:00:00')) $app = 'IPv6 multicast over Token Ring: any other multicast address with three least significant bits = 000'; |
||
645 | if (mac_equals($mac, '03:00:00:40:00:00')) $app = 'IPv6 multicast over Token Ring: any other multicast address with three least significant bits = 001'; |
||
646 | if (mac_equals($mac, '03:00:00:20:00:00')) $app = 'IPv6 multicast over Token Ring: any other multicast address with three least significant bits = 010'; |
||
647 | if (mac_equals($mac, '03:00:00:10:00:00')) $app = 'IPv6 multicast over Token Ring: any other multicast address with three least significant bits = 011'; |
||
648 | if (mac_equals($mac, '03:00:00:08:00:00')) $app = 'IPv6 multicast over Token Ring: any other multicast address with three least significant bits = 100'; |
||
649 | if (mac_equals($mac, '03:00:00:04:00:00')) $app = 'IPv6 multicast over Token Ring: any other multicast address with three least significant bits = 101'; |
||
650 | if (mac_equals($mac, '03:00:00:02:00:00')) $app = 'IPv6 multicast over Token Ring: any other multicast address with three least significant bits = 110'; |
||
651 | if (mac_equals($mac, '03:00:00:01:00:00')) $app = 'IPv6 multicast over Token Ring: any other multicast address with three least significant bits = 111'; |
||
652 | |||
653 | // === FAQ "How to recognise an AppleTalk protocols by MAC address?" === |
||
654 | // https://tools.ietf.org/html/rfc1060 |
||
655 | // http://www.cavebear.com/archive/cavebear/Ethernet/Ethernet.txt |
||
656 | if (mac_between($mac, '09:00:07:00:00:00', '09:00:07:00:00:FC')) $app = 'AppleTalk zone multicast addresses (EtherType is 0x0802)'; |
||
657 | if (mac_equals($mac, '09:00:07:FF:FF:FF')) $app = 'AppleTalk broadcast address (EtherType is 0x0802)'; |
||
658 | |||
659 | // === FAQ "How to recognise a TRILL protocols by MAC address?" === |
||
660 | // http://www.iana.org/go/rfc7455 |
||
661 | // https://tools.ietf.org/html/draft-ietf-trill-oam-framework-04 |
||
662 | // https://standards.ieee.org/products-services/regauth/grpmac/public.html |
||
663 | // https://tools.ietf.org/html/rfc7455#appendix-C |
||
664 | if (mac_between($mac, '00:00:5E:90:01:00', '00:00:5E:90:01:00')) $app = 'TRILL OAM'; |
||
665 | if (mac_equals($mac, '01:00:5E:90:01:00')) $app = 'TRILL OAM'; |
||
666 | if (mac_between($mac, '01:80:C2:00:00:40', '01:80:C2:00:00:4F')) $app = 'Group MAC addresses used by the TRILL protocols'; |
||
667 | |||
668 | // === FAQ "How to recognise an IEEE 802.1X MAC address application?" === |
||
669 | if (mac_between($mac, '01:0C:CD:01:00:00', '01:0C:CD:01:01:FF')) $app = 'IEC 61850-8-1 GOOSE Type 1/1A, EtherType is 0x88B8'; |
||
670 | if (mac_between($mac, '01:0C:CD:02:00:00', '01:0C:CD:02:01:FF')) $app = 'GSSE (IEC 61850 8-1), EtherType is 0x88B9'; |
||
671 | if (mac_between($mac, '01:0C:CD:04:00:00', '01:0C:CD:04:01:FF')) $app = 'Multicast sampled values (IEC 61850 8-1), EtherType is 0x88BA'; |
||
672 | if (mac_equals($mac, '01:1B:19:00:00:00')) $app = 'General group address - An 802.1Q VLAN Bridge would forward the frame unchanged.'; |
||
673 | if (mac_equals($mac, '01:1B:19:00:00:00')) $app = 'Precision Time Protocol (PTP) version 2 over Ethernet, EtherType is 0x88F7'; |
||
674 | if (mac_equals($mac, '01:80:C2:00:00:00')) $app = 'Bridge Group address Nearest Customer Bridge group address'; |
||
675 | if (mac_equals($mac, '01:80:C2:00:00:00')) $app = 'Spanning Tree Protocol (for bridges) IEEE 802.1D, EtherType is 0x0802'; |
||
676 | if (mac_equals($mac, '01:80:C2:00:00:00')) $app = 'Link Layer Discovery Protocol, EtherType is 0x88CC'; |
||
677 | if (mac_between($mac, '01:80:C2:00:00:00', '01:80:C2:00:00:0F')) $app = 'The initial bridging/link protocols block'; |
||
678 | if (mac_between($mac, '01:80:C2:00:00:00', '01:80:C2:00:00:0F')) $app = 'IEEE 802.1D MAC Bridge Filtered MAC Group Addresses'; |
||
679 | if (mac_between($mac, '01:80:C2:00:00:00', '01:80:C2:00:00:0F')) $app = 'IEEE Pause, 802.3x'; |
||
680 | if (mac_equals($mac, '01:80:C2:00:00:0A')) $app = 'Reserved for future standardization'; |
||
681 | if (mac_equals($mac, '01:80:C2:00:00:0B')) $app = 'EDE-SS PEP Address'; |
||
682 | if (mac_equals($mac, '01:80:C2:00:00:0C')) $app = 'Reserved for future standardization'; |
||
683 | if (mac_equals($mac, '01:80:C2:00:00:0D')) $app = 'Provider Bridge MVRP address'; |
||
684 | if (mac_equals($mac, '01:80:C2:00:00:0E')) $app = 'Individual LAN Scope group address, It is intended that no IEEE 802.1 relay device will be defined that will forward frames that carry this destination address'; |
||
685 | if (mac_equals($mac, '01:80:C2:00:00:0E')) $app = 'Nearest Bridge group address'; |
||
686 | if (mac_equals($mac, '01:80:C2:00:00:0E')) $app = 'Link Layer Discovery Protocol, EtherType is 0x88CC'; |
||
687 | if (mac_equals($mac, '01:80:C2:00:00:0E')) $app = 'Precision Time Protocol (PTP) version 2 over Ethernet, EtherType is 0x88F7'; |
||
688 | if (mac_equals($mac, '01:80:C2:00:00:01')) $app = 'IEEE MAC-specific Control Protocols group address'; |
||
689 | if (mac_equals($mac, '01:80:C2:00:00:01')) $app = 'Ethernet flow control (Pause frame) IEEE 802.3x, EtherType is 0x8808'; |
||
690 | if (mac_equals($mac, '01:80:C2:00:00:1A')) $app = 'Generic Address for All Agent Stations'; |
||
691 | if (mac_equals($mac, '01:80:C2:00:00:1B')) $app = 'All Multicast Capable End Systems address'; |
||
692 | if (mac_equals($mac, '01:80:C2:00:00:1C')) $app = 'All Multicast Announcements address'; |
||
693 | if (mac_equals($mac, '01:80:C2:00:00:1D')) $app = 'All Multicast Capable Intermediate Systems address'; |
||
694 | if (mac_equals($mac, '01:80:C2:00:00:1E')) $app = 'All DTR Concentrators MAC group address'; |
||
695 | if (mac_equals($mac, '01:80:C2:00:00:1F')) $app = 'EDE-CC PEP Address'; |
||
696 | if (mac_between($mac, '01:80:C2:00:00:01', '01:80:C2:00:00:0F')) $app = '802.1 alternate Spanning multicast, EtherType is 0x0802'; |
||
697 | if (mac_equals($mac, '01:80:C2:00:00:02')) $app = 'Ethernet OAM Protocol IEEE 802.3ah (also known as "slow protocols"), EtherType is 0x8809'; |
||
698 | if (mac_equals($mac, '01:80:C2:00:00:03')) $app = 'Nearest non-TPMR Bridge group address IEEE Std 802.1X PAE address'; |
||
699 | if (mac_equals($mac, '01:80:C2:00:00:03')) $app = 'Link Layer Discovery Protocol, EtherType is 0x88CC'; |
||
700 | if (mac_equals($mac, '01:80:C2:00:00:04')) $app = 'IEEE MAC-specific Control Protocols group address'; |
||
701 | if (mac_equals($mac, '01:80:C2:00:00:05')) $app = 'Reserved for future standardization'; |
||
702 | if (mac_equals($mac, '01:80:C2:00:00:06')) $app = 'Reserved for future standardization'; |
||
703 | if (mac_equals($mac, '01:80:C2:00:00:07')) $app = 'MEF Forum ELMI protocol group address'; |
||
704 | if (mac_equals($mac, '01:80:C2:00:00:08')) $app = 'Provider Bridge group address'; |
||
705 | if (mac_equals($mac, '01:80:C2:00:00:08')) $app = 'Spanning Tree Protocol (for provider bridges) IEEE 802.1ad, EtherType is 0x0802'; |
||
706 | if (mac_equals($mac, '01:80:C2:00:00:09')) $app = 'Reserved for future standardization'; |
||
707 | if (mac_equals($mac, '01:80:C2:00:00:10')) $app = 'All LANs Bridge Management group address (deprecated)'; |
||
708 | if (mac_equals($mac, '01:80:C2:00:00:10')) $app = 'Bridge Management, EtherType is 0x0802'; |
||
709 | if (mac_equals($mac, '01:80:C2:00:00:11')) $app = 'Load Server generic address'; |
||
710 | if (mac_equals($mac, '01:80:C2:00:00:11')) $app = 'Load Server, EtherType is 0x0802'; |
||
711 | if (mac_equals($mac, '01:80:C2:00:00:12')) $app = 'Loadable Device generic address'; |
||
712 | if (mac_equals($mac, '01:80:C2:00:00:12')) $app = 'Loadable Device, EtherType is 0x0802'; |
||
713 | if (mac_equals($mac, '01:80:C2:00:00:13')) $app = 'Transmission of IEEE 1905.1 control packets'; |
||
714 | if (mac_equals($mac, '01:80:C2:00:00:14')) $app = 'All Level 1 Intermediate Systems address'; |
||
715 | if (mac_equals($mac, '01:80:C2:00:00:14')) $app = 'OSI Route level 1 (within area), EtherType is 0x0802'; |
||
716 | if (mac_equals($mac, '01:80:C2:00:00:15')) $app = 'All Level 2 Intermediate Systems address'; |
||
717 | if (mac_equals($mac, '01:80:C2:00:00:15')) $app = 'OSI Route level 2 (between area), EtherType is 0x0802'; |
||
718 | if (mac_equals($mac, '01:80:C2:00:00:16')) $app = 'All CONS End Systems address'; |
||
719 | if (mac_equals($mac, '01:80:C2:00:00:17')) $app = 'All CONS SNARES address'; |
||
720 | if (mac_equals($mac, '01:80:C2:00:00:18')) $app = 'Generic address for All Manager Stations'; |
||
721 | if (mac_equals($mac, '01:80:C2:00:00:19')) $app = 'Groupcast with retries (GCR) MAC group address'; |
||
722 | if (mac_between($mac, '01:80:C2:00:00:20', '01:80:C2:00:00:2F')) $app = 'Reserved for use by Multiple Registration Protocol (MRP) applications'; |
||
723 | if (mac_equals($mac, '01:80:C2:00:00:21')) $app = 'GARP VLAN Registration Protocol (also known as IEEE 802.1q GVRP), EtherType is 0x88f5'; |
||
724 | if (mac_between($mac, '01:80:C2:00:00:30', '01:80:C2:00:00:3F')) $app = 'Destination group MAC addresses for CCM and Linktrace messages'; |
||
725 | if (mac_between($mac, '01:80:C2:00:00:30', '01:80:C2:00:00:3F')) $app = 'Ethernet CFM Protocol IEEE 802.1ag, EtherType is 0x8902'; |
||
726 | if (mac_between($mac, '01:80:C2:00:00:50', '01:80:C2:00:00:FF')) $app = 'Unassigned standard group MAC address'; |
||
727 | if (mac_equals($mac, '01:80:C2:00:01:00')) $app = 'Ring Management Directed Beacon multicast address'; |
||
728 | if (mac_equals($mac, '01:80:C2:00:01:00')) $app = 'FDDI RMT Directed Beacon, EtherType is 0x0802'; |
||
729 | if (mac_between($mac, '01:80:C2:00:01:01', '01:80:C2:00:01:0F')) $app = 'Assigned to ISO/IEC JTC1/SC25 for future use'; |
||
730 | if (mac_equals($mac, '01:80:C2:00:01:10')) $app = 'Status Report Frame Status Report Protocol multicast address'; |
||
731 | if (mac_equals($mac, '01:80:C2:00:01:10')) $app = 'FDDI status report frame, EtherType is 0x0802'; |
||
732 | if (mac_between($mac, '01:80:C2:00:01:11', '01:80:C2:00:01:1F')) $app = 'Assigned to ISO/IEC JTC1/SC25 for future use'; |
||
733 | if (mac_equals($mac, '01:80:C2:00:01:20')) $app = 'All FDDI Concentrator MACs'; |
||
734 | if (mac_between($mac, '01:80:C2:00:01:21', '01:80:C2:00:01:2F')) $app = 'Assigned to ISO/IEC JTC1/SC25 for future use'; |
||
735 | if (mac_equals($mac, '01:80:C2:00:01:30')) $app = 'Synchronous Bandwidth Allocation address'; |
||
736 | if (mac_between($mac, '01:80:C2:00:01:31', '01:80:C2:00:01:FF')) $app = 'Assigned to ISO/IEC JTC1/SC25 for future use'; |
||
737 | if (mac_between($mac, '01:80:C2:00:02:00', '01:80:C2:00:02:FF')) $app = 'Assigned to ETSI for future use'; |
||
738 | if (mac_between($mac, '01:80:C2:00:03:00', '01:80:C2:FF-FF-FF')) $app = 'Unassigned standard group MAC address'; |
||
739 | if (mac_equals($mac, '09:00:4C:00:00:00')) $app = 'BICC 802.1 management, EtherType is 0x0802'; |
||
740 | if (mac_equals($mac, '09:00:4C:00:00:0C')) $app = 'BICC Remote bridge STA 802.1(D) Rev8, EtherType is 0x0802'; |
||
741 | if (mac_equals($mac, '09:00:4C:00:00:02')) $app = 'BICC 802.1 management, EtherType is 0x0802'; |
||
742 | if (mac_equals($mac, '09:00:4C:00:00:06')) $app = 'BICC Local bridge STA 802.1(D) Rev6, EtherType is 0x0802'; |
||
743 | if (mac_between($mac, '33:33:00:00:00:00', '33:33:FF:FF:FF:FF')) $app = 'IPv6 multicast, EtherType is 0x86DD'; |
||
744 | |||
745 | // === FAQ "How to recognise an ISO 9542 ES-IS protocol's MAC address application?" === |
||
746 | // https://standards.ieee.org/products-services/regauth/grpmac/public.html |
||
747 | if (mac_equals($mac, '09:00:2B:00:00:04')) $app = 'All End System Network Entities address'; |
||
748 | if (mac_equals($mac, '09:00:2B:00:00:05')) $app = 'All Intermediate System Network Entities address'; |
||
749 | |||
750 | // === FAQ "How to recognise an IANA MAC address application?" === |
||
751 | // https://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml |
||
752 | // http://www.iana.org/go/rfc7042 |
||
753 | // https://tools.ietf.org/html/rfc1060 |
||
754 | if (mac_between($mac, '00:00:5E:00-52:14', '00:00:5E:00:52:FF')) $app = 'Unassigned (small allocations)'; |
||
755 | if (mac_between($mac, '00:00:5E:00:00:00', '00:00:5E:00:00:FF')) $app = 'Reserved and require IESG Ratification for assignment'; |
||
756 | if (mac_between($mac, '00:00:5E:00:03:00', '00:00:5E:00:51:FF')) $app = 'Unassigned'; |
||
757 | if (mac_between($mac, '00:00:5E:00:52:00', '00:00:5E:00:52:FF')) $app = 'Is used for very small assignments. Currently, 3 out of these 256 values have been assigned.'; |
||
758 | if (mac_between($mac, '00:00:5E:00:52:00', '00:00:5E:00:52:00')) $app = 'PacketPWEthA'; |
||
759 | if (mac_between($mac, '00:00:5E:00:52:01', '00:00:5E:00:52:01')) $app = 'PacketPWEthB'; |
||
760 | if (mac_between($mac, '00:00:5E:00:52:02', '00:00:5E:00:52:12')) $app = 'Unassigned (small allocations)'; |
||
761 | if (mac_between($mac, '00:00:5E:00:53:00', '00:00:5E:00:53:FF')) $app = 'Assigned for use in documentation'; |
||
762 | if (mac_between($mac, '00:00:5E:00:54:00', '00:00:5E:90:00:FF')) $app = 'Unassigned'; |
||
763 | if (mac_between($mac, '00:00:5E:90:01:01', '00:00:5E:90:01:FF')) $app = 'Unassigned (small allocations requiring both unicast and multicast)'; |
||
16 | daniel-mar | 764 | if (mac_between($mac, '00:00:5E:EF:10:00:00:00', '00:00:5E:EF:10:00:00:FF')) $app = 'General documentation'; |
765 | if (mac_between($mac, '00:00:5E:FF:FE:00:53:00', '00:00:5E:FF:FE:00:53:FF')) $app = 'EUI-48 derived documentation'; |
||
15 | daniel-mar | 766 | if (mac_between($mac, '01:00:5E:00:00:00', '01:00:5E:7F:FF:FF')) $app = 'DoD Internet Multicast (EtherType is 0x0800)'; // TODO: IPv4-Multicast (Dabei werden dann die unteren 23 Bit der IP-Multicast-Adresse direkt auf die untersten 23 Bit der MAC-Adresse abgebildet. Der IP-Multicast-Adresse 224.0.0.1 ist somit die Multicast-MAC-Adresse 01-00-5e-00-00-01 fest zugeordnet.) |
767 | if (mac_between($mac, '01:00:5E:80:00:00', '01:00:5E:FF:FF:FF')) $app = 'DoD Internet'; |
||
768 | if (mac_equals($mac, '01:00:5E:90:00:02')) $app = 'AllL1MI-ISs'; |
||
769 | if (mac_equals($mac, '01:00:5E:90:00:03')) $app = 'AllL2MI-ISs'; |
||
770 | if (mac_between($mac, '01:00:5E:90:00:04', '01:00:5E:90:00:FF')) $app = 'Unassigned (small allocations)'; |
||
771 | if (mac_between($mac, '01:00:5E:90:01:01', '01:00:5E:90:01:FF')) $app = 'Unassigned (small allocations requiring both unicast and multicast)'; |
||
772 | if (mac_between($mac, '01:00:5E:90:02:00', '01:00:5E:90:0F:FF')) $app = 'Unassigned'; |
||
773 | if (mac_between($mac, '01:00:5E:90:02:00', '00:00:5E:FF:FF:FF')) $app = 'Unassigned'; |
||
774 | if (mac_between($mac, '01:00:5E:90:10:00', '01:00:5E:90:10:FF')) $app = 'Documentation'; |
||
775 | if (mac_between($mac, '01:00:5E:90:11:00', '01:00:5E:FF:FF:FF')) $app = 'Unassigned'; |
||
16 | daniel-mar | 776 | if (mac_between($mac, '01:00:5E:EF:10:00:00:00', '01:00:5E:EF:10:00:00:FF')) $app = 'General documentation'; |
777 | if (mac_between($mac, '02:00:5E:00:00:00:00:00', '02:00:5E:0F:FF:FF:FF:FF')) $app = 'Reserved'; |
||
778 | if (mac_between($mac, '02:00:5E:10:00:00:00:00', '02:00:5E:10:00:00:00:FF')) $app = 'Documentation'; |
||
779 | if (mac_between($mac, '02:00:5E:10:00:00:01:00', '02:00:5E:EF:FF:FF:FF:FF')) $app = 'Unassigned'; |
||
780 | if (mac_between($mac, '02:00:5E:F0:00:00:00:00', '02:00:5E:FD:FF:FF:FF:FF')) $app = 'Reserved'; |
||
781 | if (mac_between($mac, '02:00:5E:FE:00:00:00:00', '02:00:5E:FE:FF:FF:FF:FF')) $app = 'IPv4 Addr Holders'; |
||
782 | if (mac_between($mac, '02:00:5E:FF:00:00:00:00', '02:00:5E:FF:FD:FF:FF:FF')) $app = 'Reserved'; |
||
783 | if (mac_between($mac, '02:00:5E:FF:FE:00:00:00', '02:00:5E:FF:FE:FF:FF:FF')) $app = 'IANA EUI-48 Holders'; |
||
784 | if (mac_between($mac, '02:00:5E:FF:FF:00:00:00', '02:00:5E:FF:FF:FF:FF:FF')) $app = 'Reserved'; |
||
785 | if (mac_between($mac, '03:00:5E:00:00:00:00:00', '03:00:5E:0F:FF:FF:FF:FF')) $app = 'Reserved'; |
||
786 | if (mac_between($mac, '03:00:5E:10:00:00:00:00', '03:00:5E:10:00:00:00:FF')) $app = 'Documentation'; |
||
787 | if (mac_between($mac, '03:00:5E:10:00:00:01:00', '03:00:5E:EF:FF:FF:FF:FF')) $app = 'Unassigned'; |
||
788 | if (mac_between($mac, '03:00:5E:F0:00:00:00:00', '03:00:5E:FD:FF:FF:FF:FF')) $app = 'Reserved'; |
||
789 | if (mac_between($mac, '03:00:5E:FF:00:00:00:00', '03:00:5E:FF:FD:FF:FF:FF')) $app = 'Reserved'; |
||
790 | if (mac_between($mac, '03:00:5E:FF:FE:00:00:00', '03:00:5E:FF:FE:FF:FF:FF')) $app = 'IANA EUI-48 Holders'; |
||
791 | if (mac_between($mac, '03:00:5E:FF:FF:00:00:00', '03:00:5E:FF:FF:FF:FF:FF')) $app = 'Reserved'; |
||
15 | daniel-mar | 792 | |
793 | // === FAQ "How to recognise a Cisco's MAC address application?" === |
||
794 | // https://www.cisco.com/c/en/us/support/docs/switches/catalyst-4500-series-switches/13414-103.html |
||
795 | // https://tools.ietf.org/html/rfc1060 |
||
796 | // https://en.wikipedia.org/wiki/Multicast_address#cite_note-15 |
||
797 | // http://www.cavebear.com/archive/cavebear/Ethernet/Ethernet.txt |
||
798 | if (mac_equals($mac, '01:00:0C:00:00:00')) $app = 'Inter Switch Link (ISL)'; |
||
799 | if (mac_equals($mac, '01:00:0C:CC:CC:CC')) $app = 'CDP (Cisco Discovery Protocol), VTP (VLAN Trunking Protocol), EtherType is 0x0802'; |
||
800 | if (mac_equals($mac, '01:00:0C:CC:CC:CC')) $app = 'Port Aggregation Protocol (PAgP), SNAP HDLC Protocol Type is 0x0104'; |
||
801 | if (mac_equals($mac, '01:00:0C:CC:CC:CC')) $app = 'Unidirectional Link Detection (UDLD), SNAP HDLC Protocol Type is 0x0111'; |
||
802 | if (mac_equals($mac, '01:00:0C:CC:CC:CC')) $app = 'Dynamic Trunking (DTP), SNAP HDLC Protocol Type is 0x2004'; |
||
803 | if (mac_equals($mac, '01:00:0C:CC:CC:CC')) $app = 'VLAN Trunking (VTP), SNAP HDLC Protocol Type is 0x2003'; |
||
804 | if (mac_equals($mac, '01:00:0C:CC:CC:CD')) $app = 'Cisco Shared Spanning Tree Protocol address, EtherType is 0x0802'; |
||
805 | if (mac_equals($mac, '01:00:0C:CC:CC:CD')) $app = 'Spanning Tree PVSTP+, SNAP HDLC Protocol Type is 0x010B'; |
||
806 | if (mac_equals($mac, '01:00:0C:CD:CD:CD')) $app = 'STP Uplink Fast, SNAP HDLC Protocol Type is 0x200A'; |
||
807 | if (mac_equals($mac, '01:00:0C:CD:CD:CE')) $app = 'VLAN Bridge, SNAP HDLC Protocol Type is 0x010C'; |
||
808 | if (mac_equals($mac, '01:00:0C:DD:DD:DD')) $app = 'CGMP (Cisco Group Management Protocol)'; |
||
809 | |||
810 | // === FAQ "How to recognise an ITU-T's MAC address application?" === |
||
811 | // https://www.itu.int/en/ITU-T/studygroups/2017-2020/15/Documents/IEEE-assigned_OUIs-30-06-2017.docx |
||
812 | if (mac_between($mac, '01:19:A7:00:00:00', '01:19:A7:00:00:FF')) $app = 'R-APS per G.8032'; |
||
813 | if (mac_between($mac, '01:19:A7:52:76:90', '01:19:A7:52:76:9F')) $app = 'Multicast per G.9961'; |
||
814 | |||
815 | // === FAQ "How to recognise Digital Equipment Corporation's MAC address application?" === |
||
816 | if (mac_equals($mac, '09:00:2B:00:00:00')) $app = 'DEC MUMPS, EtherType is 0x6009'; |
||
817 | if (mac_equals($mac, '09:00:2B:00:00:0F')) $app = 'DEC Local Area Transport (LAT), EtherType is 0x6004'; |
||
818 | if (mac_equals($mac, '09:00:2B:00:00:01')) $app = 'DEC DSM/DDP, EtherType is 0x8039'; |
||
819 | if (mac_between($mac, '09:00:2B:00:00:10', '09:00:2B:00:00:1F')) $app = 'DEC Experimental'; |
||
820 | if (mac_equals($mac, '09:00:2B:00:00:02')) $app = 'DEC VAXELN, EtherType is 0x803B'; |
||
821 | if (mac_equals($mac, '09:00:2B:00:00:03')) $app = 'DEC Lanbridge Traffic Monitor (LTM), EtherType is 0x8038'; |
||
822 | if (mac_equals($mac, '09:00:2B:00:00:04')) $app = 'DEC MAP End System'; |
||
823 | if (mac_equals($mac, '09:00:2B:00:00:05')) $app = 'DEC MAP Intermediate System'; |
||
824 | if (mac_equals($mac, '09:00:2B:00:00:06')) $app = 'DEC CSMA/CD Encryption, EtherType is 0x803D'; |
||
825 | if (mac_equals($mac, '09:00:2B:00:00:07')) $app = 'DEC NetBios Emulator, EtherType is 0x8040'; |
||
826 | if (mac_equals($mac, '09:00:2B:01:00:00')) $app = 'DEC LanBridge, EtherType is 0x8038'; |
||
827 | if (mac_equals($mac, '09:00:2B:01:00:01')) $app = 'DEC LanBridge, EtherType is 0x8038'; |
||
828 | if (mac_equals($mac, '09:00:2B:02:00:00')) $app = 'DEC DNA Level 2 Routing'; |
||
829 | if (mac_equals($mac, '09:00:2B:02:01:00')) $app = 'DEC DNA Naming Service Advertisement, EtherType is 0x803C'; |
||
830 | if (mac_equals($mac, '09:00:2B:02:01:01')) $app = 'DEC DNA Naming Service Solicitation, EtherType is 0x803C'; |
||
831 | if (mac_equals($mac, '09:00:2B:02:01:02')) $app = 'DEC Distributed Time Service, EtherType is 0x803E'; |
||
832 | if (mac_equals($mac, '09:00:2B:02:01:09')) $app = 'DEC Availability Manager for Distributed Systems DECamds, EtherType is 0x8048'; |
||
833 | if (mac_between($mac, '09:00:2B:03:00:00', '09:00:2B:03:FF:FF')) $app = 'DEC default filtering by bridges'; |
||
834 | if (mac_equals($mac, '09:00:2B:04:00:00')) $app = 'DEC Local Area System Transport (LAST), EtherType is 0x8041'; |
||
835 | if (mac_equals($mac, '09:00:2B:23:00:00')) $app = 'DEC Argonaut Console, EtherType is 0x803A'; |
||
836 | if (mac_equals($mac, 'AB:00:00:01:00:00')) $app = 'DEC Maintenance Operation Protocol (MOP) Dump/Load Assistance, EtherType is 0x6001'; |
||
837 | if (mac_equals($mac, 'AB:00:00:02:00:00')) $app = 'DEC Maintenance Operation Protocol (MOP), EtherType is 0x6002'; |
||
838 | if (mac_equals($mac, 'AB:00:00:03:00:00')) $app = 'DECNET Phase IV end node, EtherType is 0x6003'; |
||
839 | if (mac_equals($mac, 'AB:00:00:04:00:00')) $app = 'DECNET Phase IV Router, EtherType is 0x6003'; |
||
840 | if (mac_between($mac, 'AB:00:00:05:00:00', 'AB:00:03:FF:FF:FF')) $app = 'Reserved DEC'; |
||
841 | if (mac_equals($mac, 'AB:00:03:00:00:00')) $app = 'DEC Local Area Transport (LAT) - old, EtherType is 0x6004'; |
||
842 | if (mac_between($mac, 'AB:00:04:00:00:00', 'AB:00:04:00:FF:FF')) $app = 'Reserved DEC customer private use'; |
||
16 | daniel-mar | 843 | if (mac_between($mac, 'AB:00:04:01:00:00', 'AB:00:04:01:FF:FF')) $app = 'DEC Local Area VAX Cluster groups System Communication Architecture (SCA), EtherType is 0x6007'; |
15 | daniel-mar | 844 | |
845 | if ($app) { |
||
846 | echo sprintf("%-32s %s\n", "Special use:", $app); |
||
847 | } |
||
848 | |||
2 | daniel-mar | 849 | } |
15 | daniel-mar | 850 | |
851 | /** |
||
852 | * @param string $mac1 |
||
853 | * @param string $mac2 |
||
854 | * @return bool |
||
855 | */ |
||
856 | function mac_equals(string $mac1, string $mac2): bool { |
||
16 | daniel-mar | 857 | $mac1test = eui64_to_eui48($mac1); |
858 | if ($mac1test === false) return false; |
||
859 | $mac2test = eui64_to_eui48($mac2); |
||
860 | if ($mac2test === false) return false; |
||
861 | |||
862 | if (eui_bits($mac1test) != eui_bits($mac2test)) { |
||
863 | $mac1test = eui48_to_eui64($mac1); |
||
864 | $mac2test = eui48_to_eui64($mac2); |
||
865 | } |
||
866 | |||
867 | return mac_canonize($mac1test) == mac_canonize($mac2test); |
||
15 | daniel-mar | 868 | } |
869 | |||
870 | /** |
||
871 | * @param string $mac |
||
872 | * @param string $low |
||
873 | * @param string $high |
||
874 | * @return bool |
||
875 | */ |
||
876 | function mac_between(string $mac, string $low, string $high): bool { |
||
16 | daniel-mar | 877 | $mactest = eui64_to_eui48($mac); |
878 | if ($mactest === false) return false; |
||
879 | $lowtest = eui64_to_eui48($low); |
||
880 | if ($lowtest === false) return false; |
||
881 | $hightest = eui64_to_eui48($high); |
||
882 | if ($hightest === false) return false; |
||
15 | daniel-mar | 883 | |
16 | daniel-mar | 884 | if ((eui_bits($mactest) != eui_bits($lowtest)) || (eui_bits($lowtest) != eui_bits($hightest))) { |
885 | $mactest = eui48_to_eui64($mac); |
||
18 | daniel-mar | 886 | if ($mactest === false) return false; // e.g. trying ELI-48 to ELI-64 |
16 | daniel-mar | 887 | $lowtest = eui48_to_eui64($low); |
18 | daniel-mar | 888 | if ($lowtest === false) return false; // e.g. trying ELI-48 to ELI-64 |
16 | daniel-mar | 889 | $hightest = eui48_to_eui64($high); |
18 | daniel-mar | 890 | if ($hightest === false) return false; // e.g. trying ELI-48 to ELI-64 |
16 | daniel-mar | 891 | } |
15 | daniel-mar | 892 | |
16 | daniel-mar | 893 | $mactest = strtoupper(preg_replace('@[^0-9A-F]@', '', $mactest)); |
894 | $lowtest = strtoupper(preg_replace('@[^0-9A-F]@', '', $lowtest)); |
||
895 | $hightest = strtoupper(preg_replace('@[^0-9A-F]@', '', $hightest)); |
||
15 | daniel-mar | 896 | |
16 | daniel-mar | 897 | $mactest = gmp_init($mactest, 16); |
898 | $lowtest = gmp_init($lowtest, 16); |
||
899 | $hightest = gmp_init($hightest, 16); |
||
15 | daniel-mar | 900 | |
16 | daniel-mar | 901 | return (gmp_cmp($mactest, $lowtest) >= 0) && (gmp_cmp($mactest, $hightest) <= 0); |
17 | daniel-mar | 902 | } |