Rev 17 | Rev 19 | 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 |
17 | daniel-mar | 6 | * Version 2023-05-01 |
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 | /** |
18 | daniel-mar | 29 | * Checks if a MAC, EUI, ELI, or IPv6-LinkLocal address is valid |
17 | daniel-mar | 30 | * @param string $mac MAC, EUI, or IPv6-LinkLocal Address |
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 | /** |
18 | daniel-mar | 48 | * Returns the amount of bits of a MAC, EUI, or ELI |
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 | /** |
||
18 | daniel-mar | 59 | * Canonizes a MAC, EUI, ELI, or IPv6-LinkLocal address |
60 | * @param string $mac MAC, EUI, ELI, or IPv6-LinkLocal Address |
||
17 | daniel-mar | 61 | * @param string $delimiter Desired delimiter for inserting between each octet |
62 | * @return string|false The canonized address (Note: IPv6-Linklocal becomes EUI-64) |
||
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 | // TODO: also print the date of last update of the OUI files |
||
125 | |||
126 | return $out; |
||
127 | } |
||
128 | |||
129 | return false; |
||
130 | } |
||
131 | |||
15 | daniel-mar | 132 | /** |
17 | daniel-mar | 133 | * Try to Decapsulate EUI-64 into MAC-48 or EUI-48 |
16 | daniel-mar | 134 | * @param string $eui64 |
17 | daniel-mar | 135 | * @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 | 136 | */ |
137 | function eui64_to_eui48(string $eui64) { |
||
138 | if (!mac_valid($eui64)) return false; |
||
139 | $eui64 = mac_canonize($eui64, ''); |
||
140 | if (eui_bits($eui64) == 48) return mac_canonize($eui64); |
||
18 | daniel-mar | 141 | if ($eui64[1] == 'A') return false; // do not allow ELI-64 |
16 | daniel-mar | 142 | |
17 | daniel-mar | 143 | if (substr($eui64, 6, 4) == 'FFFF') { |
144 | // EUI-64 to MAC-48 |
||
16 | daniel-mar | 145 | return mac_canonize(substr($eui64, 0, 6).substr($eui64, 10, 6)); |
17 | daniel-mar | 146 | } else if (substr($eui64, 6, 4) == 'FFFE') { |
147 | if ((hexdec($eui64[1])&2) == 2) { |
||
148 | // Modified EUI-64 to MAC/EUI-48 |
||
149 | $eui64[1] = dechex(hexdec($eui64[1])&253); // remove bit |
||
150 | return mac_canonize(substr($eui64, 0, 6).substr($eui64, 10, 6)); |
||
151 | } else { |
||
152 | // EUI-64 to EUI-48 |
||
153 | return mac_canonize(substr($eui64, 0, 6).substr($eui64, 10, 6)); |
||
154 | } |
||
16 | daniel-mar | 155 | } else { |
156 | return mac_canonize($eui64); |
||
157 | } |
||
158 | } |
||
159 | |||
160 | /** |
||
17 | daniel-mar | 161 | * MAC-48 to EUI-64 Encapsulation |
162 | * @param string $mac48 MAC-48 address |
||
163 | * @return false|string EUI-64 address |
||
16 | daniel-mar | 164 | */ |
17 | daniel-mar | 165 | function mac48_to_eui64(string $mac48) { |
166 | // Note: MAC-48 is used for network hardware; EUI-48 is used to identify other devices and software. |
||
167 | // MAC48-to-EUI64 Encapsulation uses 0xFFFF middle part |
||
168 | if (!mac_valid($mac48)) return false; |
||
169 | $mac48 = mac_canonize($mac48, ''); |
||
170 | if (eui_bits($mac48) == 64) return mac_canonize($mac48); |
||
18 | daniel-mar | 171 | if ($mac48[1] == 'A') return false; // do not allow ELI-48 |
17 | daniel-mar | 172 | |
173 | $eui64 = substr($mac48, 0, 6).'FFFF'.substr($mac48, 6, 6); |
||
174 | return mac_canonize($eui64); |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * EUI-48 to EUI-64 Encapsulation |
||
179 | * @param string $eui48 EUI-48 address |
||
180 | * @return false|string EUI-64 address |
||
181 | */ |
||
16 | daniel-mar | 182 | function eui48_to_eui64(string $eui48) { |
17 | daniel-mar | 183 | // Note: MAC-48 is used for network hardware; EUI-48 is used to identify other devices and software. |
184 | // EUI48-to-EUI64 Encapsulation uses 0xFFFF middle part |
||
16 | daniel-mar | 185 | if (!mac_valid($eui48)) return false; |
186 | $eui48 = mac_canonize($eui48, ''); |
||
187 | if (eui_bits($eui48) == 64) return mac_canonize($eui48); |
||
18 | daniel-mar | 188 | if ($eui48[1] == 'A') return false; // do not allow ELI-48 |
16 | daniel-mar | 189 | |
190 | $eui64 = substr($eui48, 0, 6).'FFFE'.substr($eui48, 6, 6); |
||
191 | return mac_canonize($eui64); |
||
192 | } |
||
193 | |||
194 | /** |
||
17 | daniel-mar | 195 | * MAC/EUI-48 to Modified EUI-64 Encapsulation |
196 | * @param string $eui48 MAC-48 or EUI-48 address |
||
197 | * @return false|string Modified EUI-64 address |
||
16 | daniel-mar | 198 | */ |
17 | daniel-mar | 199 | function maceui48_to_modeui64(string $eui48) { |
200 | // Note: MAC-48 is used for network hardware; EUI-48 is used to identify other devices and software. |
||
201 | // EUI48-to-ModifiedEUI64 Encapsulation uses 0xFFFE middle part (SIC! This was a mistake by IETF, since it should actually be 0xFFFF!) |
||
202 | if (!mac_valid($eui48)) return false; |
||
203 | $eui48 = mac_canonize($eui48, ''); |
||
204 | if (eui_bits($eui48) == 64) return mac_canonize($eui48); |
||
18 | daniel-mar | 205 | if ($eui48[1] == 'A') return false; // do not allow ELI-48 |
17 | daniel-mar | 206 | |
207 | $eui64 = substr($eui48, 0, 6).'FFFE'.substr($eui48, 6, 6); |
||
208 | |||
209 | $eui64[1] = dechex(hexdec($eui64[1]) | 2); // flip seventh bit |
||
210 | |||
211 | return mac_canonize($eui64); |
||
212 | } |
||
213 | |||
214 | /** |
||
215 | * Try to convert IPv6-LinkLocal address to MAC-48 |
||
216 | * @param string $ipv6 IPv6-LinkLocal address |
||
217 | * @return false|string MAC-48 (or IPv6 if it was no LinkLocal address, or Modified EUI-64 if it decapsulation failed) |
||
218 | */ |
||
219 | function ipv6linklocal_to_mac48(string $ipv6) { |
||
16 | daniel-mar | 220 | // https://stackoverflow.com/questions/12095835/quick-way-of-expanding-ipv6-addresses-with-php (modified) |
221 | $tmp = inet_pton($ipv6); |
||
222 | if ($tmp === false) return false; |
||
223 | $hex = unpack("H*hex", $tmp); |
||
224 | $ipv6 = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1); |
||
225 | |||
226 | // Remove "fe80::" to convert IPv6 Link Local address back to EUI-64 |
||
227 | // see https://support.lenovo.com/de/de/solutions/ht509925-how-to-convert-a-mac-address-into-an-ipv6-link-local-address-eui-64 |
||
228 | $cnt = 0; |
||
229 | $mac = preg_replace('@^fe80:0000:0000:0000:@i', '', $ipv6, -1, $cnt); |
||
230 | if ($cnt == 0) return false; |
||
231 | |||
232 | // Set LAA to UAA again |
||
17 | daniel-mar | 233 | $mac_uaa_64 = $mac; |
234 | $mac_uaa_64[1] = dechex(hexdec($mac_uaa_64[1]) & 253); |
||
16 | daniel-mar | 235 | |
17 | daniel-mar | 236 | $mac_uaa_48 = eui64_to_eui48($mac_uaa_64); |
237 | if (eui_bits($mac_uaa_48) == 48) { |
||
238 | return $mac_uaa_48; // Output MAC-48 (UAA) |
||
239 | } else { |
||
240 | return $mac; // Failed decapsulation; output Modified EUI-64 instead |
||
241 | } |
||
16 | daniel-mar | 242 | } |
243 | |||
244 | /** |
||
17 | daniel-mar | 245 | * Converts MAC-48 or EUI-48 to IPv6-LinkLocal (based on Modified EUI-64) |
15 | daniel-mar | 246 | * @param string $mac |
16 | daniel-mar | 247 | * @return false|string |
248 | */ |
||
17 | daniel-mar | 249 | function maceui_to_ipv6linklocal(string $mac) { |
16 | daniel-mar | 250 | if (!mac_valid($mac)) return false; |
251 | if (eui_bits($mac) == 48) { |
||
17 | daniel-mar | 252 | $mac = maceui48_to_modeui64($mac); |
16 | daniel-mar | 253 | } |
254 | $mac = mac_canonize($mac, ''); |
||
255 | $mac = str_pad($mac, 16, '0', STR_PAD_LEFT); |
||
256 | return strtolower('fe80::'.substr($mac,0, 4).':'.substr($mac,4, 4).':'.substr($mac,8, 4).':'.substr($mac,12, 4)); |
||
257 | } |
||
258 | |||
259 | /** |
||
18 | daniel-mar | 260 | * Prints information about an IPv6-LinkLocal address, MAC, EUI, or ELI. |
261 | * @param string $mac IPv6-LinkLocal address, MAC, EUI, or ELI |
||
15 | daniel-mar | 262 | * @return void |
263 | * @throws Exception |
||
264 | */ |
||
265 | function decode_mac(string $mac) { |
||
16 | daniel-mar | 266 | echo sprintf("%-32s %s\n", "Input:", $mac); |
267 | |||
17 | daniel-mar | 268 | // Format MAC for machine readability |
269 | $mac = mac_canonize($mac, ''); |
||
270 | |||
16 | daniel-mar | 271 | $type = ''; |
18 | daniel-mar | 272 | if ($mac[1] == 'A') { |
273 | // An ELI is based on a CID-24 |
||
274 | // A CID has ZYXM bits set to 1010 (0b1010 = 0xA) |
||
275 | // Since X=1 (U/L=1), the CID cannot be used to form a universal UAA MAC (only a local LAA MAC) |
||
276 | $type = 'ELI-'.eui_bits($mac);; |
||
277 | } else { |
||
278 | $tmp = ipv6linklocal_to_mac48($mac); |
||
279 | if ($tmp !== false) { |
||
280 | $mac = $tmp; |
||
281 | $type = 'IPv6-Link-Local'; |
||
282 | } |
||
283 | if (!mac_valid($mac)) throw new Exception("Invalid MAC address"); |
||
284 | if ($tmp === false) { |
||
285 | if (eui_bits($mac) == 48) { |
||
286 | $type = 'MAC-48 (network hardware) or EUI-48 (other devices and software)'; |
||
287 | } else if (eui_bits($mac) == 64) { |
||
288 | if (substr($mac,6,4) == 'FFFE') { |
||
289 | if ((hexdec($mac[1])&2) == 2) { |
||
290 | $type = 'EUI-64 (MAC/EUI-48 to Modified EUI-64 Encapsulation)'; |
||
291 | } else { |
||
292 | $type = 'EUI-64 (EUI-48 to EUI-64 Encapsulation)'; |
||
293 | } |
||
294 | } else if (substr($mac,6,4) == 'FFFF') { |
||
295 | $type = 'EUI-64 (MAC-48 to EUI-64 Encapsulation)'; |
||
17 | daniel-mar | 296 | } else { |
18 | daniel-mar | 297 | $type = 'EUI-64 (Regular)'; |
17 | daniel-mar | 298 | } |
299 | } else { |
||
18 | daniel-mar | 300 | assert(false); /** @phpstan-ignore-line */ |
17 | daniel-mar | 301 | } |
302 | } |
||
16 | daniel-mar | 303 | } |
304 | echo sprintf("%-32s %s\n", "Type:", $type); |
||
15 | daniel-mar | 305 | |
16 | daniel-mar | 306 | echo "\n"; |
307 | |||
308 | // Show various representations |
||
18 | daniel-mar | 309 | if ($mac[1] == 'A') { |
310 | // Note: There does not seem to exist an algorithm for converting ELI-48 <=> ELI-64 |
||
311 | echo sprintf("%-32s %s\n", "ELI-".eui_bits($mac).":", mac_canonize($mac)); |
||
17 | daniel-mar | 312 | } else { |
18 | daniel-mar | 313 | $eui48 = eui64_to_eui48($mac); |
314 | echo sprintf("%-32s %s\n", "EUI-48:", (eui_bits($eui48) != 48) ? 'Not available' : $eui48); |
||
315 | if (eui_bits($mac) == 48) { |
||
316 | $eui64 = mac48_to_eui64($mac); |
||
317 | echo sprintf("%-32s %s\n", "EUI-64:", ((eui_bits($eui64) != 64) ? 'Not available' : $eui64).' (MAC-48 to EUI-64 Encapsulation)'); |
||
318 | $eui64 = eui48_to_eui64($mac); |
||
319 | echo sprintf("%-32s %s\n", "", ((eui_bits($eui64) != 64) ? 'Not available' : $eui64).' (EUI-48 to EUI-64 Encapsulation)'); |
||
320 | $eui64 = maceui48_to_modeui64($mac); |
||
321 | echo sprintf("%-32s %s\n", "", ((eui_bits($eui64) != 64) ? 'Not available' : $eui64).' (MAC/EUI-48 to Modified EUI-64 Encapsulation)'); |
||
322 | $ipv6 = maceui_to_ipv6linklocal($mac); |
||
323 | echo sprintf("%-32s %s\n", "IPv6 link local address:", $ipv6); |
||
324 | } else { |
||
325 | $eui64 = mac_canonize($mac); |
||
326 | echo sprintf("%-32s %s\n", "EUI-64:", $eui64); |
||
327 | } |
||
17 | daniel-mar | 328 | } |
2 | daniel-mar | 329 | |
330 | // Vergabestelle |
||
331 | $ul = hexdec($mac[1]) & 2; // Bit #LSB+1 of Byte 1 |
||
332 | $ul_ = ($ul == 0) ? '[0] Universally Administered Address (UAA)' : '[1] Locally Administered Address (LAA)'; |
||
15 | daniel-mar | 333 | echo sprintf("%-32s %s\n", "Administration type (U/L flag):", $ul_); |
2 | daniel-mar | 334 | |
16 | daniel-mar | 335 | // Empfaengergruppe |
336 | $ig = hexdec($mac[1]) & 1; // Bit #LSB+0 of Byte 1 |
||
18 | daniel-mar | 337 | $ig_ = ($ig == 0) ? '[0] Unicast (Individual)' : '[1] Multicast (Group)'; |
16 | daniel-mar | 338 | echo sprintf("%-32s %s\n", "Transmission type (I/G flag):", $ig_); |
339 | |||
2 | daniel-mar | 340 | // Query IEEE registries |
17 | daniel-mar | 341 | if (count(glob(IEEE_MAC_REGISTRY.DIRECTORY_SEPARATOR.'*.txt')) > 0) { |
18 | daniel-mar | 342 | if ($mac[1] == 'A') { |
343 | // Query the CID registry |
||
344 | if ( |
||
345 | ($x = _lookup_ieee_registry(IEEE_MAC_REGISTRY . DIRECTORY_SEPARATOR . 'cid.txt', 'CID', $mac)) |
||
346 | ) { |
||
347 | echo $x; |
||
348 | } |
||
349 | } else { |
||
350 | // Query the OUI registries |
||
351 | // TODO: Should we try to convert Unicast<=>Multicast if one of them can't be found? |
||
352 | if ( |
||
353 | # 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] |
||
354 | # 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. |
||
355 | ($x = _lookup_ieee_registry(IEEE_MAC_REGISTRY . DIRECTORY_SEPARATOR . 'iab.txt', 'IAB', $mac)) || |
||
356 | ($x = _lookup_ieee_registry(IEEE_MAC_REGISTRY . DIRECTORY_SEPARATOR . 'oui36.txt', 'OUI-36 (MA-S)', $mac)) || |
||
357 | ($x = _lookup_ieee_registry(IEEE_MAC_REGISTRY . DIRECTORY_SEPARATOR . 'mam.txt', 'OUI-28 (MA-M)', $mac)) || |
||
358 | ($x = _lookup_ieee_registry(IEEE_MAC_REGISTRY . DIRECTORY_SEPARATOR . 'oui.txt', 'OUI-24 (MA-L)', $mac)) |
||
359 | ) { |
||
360 | echo $x; |
||
361 | } |
||
15 | daniel-mar | 362 | } |
2 | daniel-mar | 363 | } |
364 | |||
15 | daniel-mar | 365 | $vm = ''; |
366 | // === FAQ "Detection rules which don't have their dedicated page yet" === |
||
367 | // https://wiki.xenproject.org/wiki/Xen_Networking |
||
368 | // https://mcpmag.com/articles/2007/11/27/hey-vm-whats-your-hypervisor.aspx |
||
369 | // https://www.techrepublic.com/blog/data-center/mac-address-scorecard-for-common-virtual-machine-platforms |
||
370 | if (mac_between($mac, '00:16:3E:00:00:00', '00:16:3E:FF:FF:FF')) $vm = "Red Hat Xen, XenSource, Novell Xen"; |
||
371 | // http://techgenix.com/mac-address-pool-duplication-hyper-v/ |
||
372 | // https://docs.microsoft.com/en-us/system-center/vmm/network-mac?view=sc-vmm-1807 |
||
373 | // https://blogs.technet.microsoft.com/gbanin/2014/08/27/how-to-solve-mac-address-conflict-on-hyper-v/ |
||
374 | if (mac_between($mac, '00:1D:D8:B7:1C:00', '00:1D:D8:F4:1F:FF')) $vm = "Microsoft SCVMM (System Center Virtual Machine Manager)"; |
||
375 | // https://mcpmag.com/articles/2007/11/27/hey-vm-whats-your-hypervisor.aspx |
||
376 | // https://www.techrepublic.com/blog/data-center/mac-address-scorecard-for-common-virtual-machine-platforms/ |
||
377 | // https://blogs.technet.microsoft.com/medv/2011/01/24/how-to-manage-vm-mac-addresses-with-the-globalimagedata-xml-file-in-med-v-v1/ |
||
378 | if (mac_between($mac, '00:03:FF:00:00:00', '00:03:FF:FF:FF:FF')) $vm = "Microsoft Virtual PC / Virtual Server"; |
||
379 | // https://mcpmag.com/articles/2007/11/27/hey-vm-whats-your-hypervisor.aspx |
||
380 | if (mac_between($mac, '00:18:51:00:00:00', '00:18:51:FF:FF:FF')) $vm = "SWsoft"; |
||
381 | // https://macaddress.io/statistics/company/17619 |
||
382 | if (mac_between($mac, '58:9C:FC:00:00:00', '58:9C:FC:FF:FF:FF')) $vm = "bhyve by FreebsdF"; |
||
383 | // https://macaddress.io/statistics/company/17388 |
||
384 | if (mac_between($mac, '50:6B:8D:00:00:00', '50:6B:8D:FF:FF:FF')) $vm = "Nutanix AHV"; |
||
385 | // https://www.centos.org/forums/viewtopic.php?t=26739 |
||
386 | if (mac_between($mac, '54:52:00:00:00:00', '54:52:FF:FF:FF:FF')) $vm = "KVM (proxmox)"; |
||
387 | // Self tested (alldatafeeds.com) |
||
388 | if (mac_between($mac, '96:00:00:00:00:00', '96:00:FF:FF:FF:FF')) $vm = "Hetzner vServer (based on KVM and libvirt)"; |
||
389 | // === FAQ "How to recognise a VMware's virtual machine by its MAC address?" === |
||
390 | if (mac_between($mac, '00:50:56:00:00:00', '00:50:56:FF:FF:FF')) $vm = "VMware vSphere, VMware Workstation, VMware ESX Server"; |
||
391 | if (mac_between($mac, '00:50:56:80:00:00', '00:50:56:BF:FF:FF')) $vm = "VMware vSphere managed by vCenter Server"; |
||
392 | 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"; |
||
393 | if (mac_between($mac, '00:05:69:00:00:00', '00:05:69:FF:FF:FF')) $vm = "VMware ESX, VMware GSX Server"; |
||
394 | if (mac_between($mac, '00:1C:14:00:00:00', '00:1C:14:FF:FF:FF')) $vm = "VMWare"; |
||
395 | // === FAQ "machine by its MAC address?" === |
||
396 | if (mac_between($mac, '00:1C:42:00:00:00', '00:1C:42:FF:FF:FF')) $vm = "Parallels Virtual Machine"; |
||
397 | // === FAQ "How to recognise a Docker container by its MAC address?" === |
||
398 | if (mac_between($mac, '02:42:00:00:00:00', '02:42:FF:FF:FF:FF')) $vm = "Docker container"; |
||
399 | // === FAQ =How to recognise a Microsoft Hyper-V's virtual machine by its MAC address?" === |
||
400 | if (mac_between($mac, '00:15:5D:00:00:00', '00:15:5D:FF:FF:FF')) $vm = "Microsoft Hyper-V"; |
||
401 | // === FAQ "How to recognise an Oracle Virtual machine by its MAC address?" === |
||
402 | if (mac_between($mac, '08:00:27:00:00:00', '08:00:27:FF:FF:FF')) $vm = "Oracle VirtualBox 5.2"; // Pcs Systemtechnik GmbH |
||
403 | 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) |
||
404 | if (mac_between($mac, '00:21:F6:00:00:00', '00:21:F6:FF:FF:FF')) $vm = "Oracle VirtualBox 3.3"; |
||
405 | if (mac_between($mac, '00:14:4F:00:00:00', '00:14:4F:FF:FF:FF')) $vm = "Oracle VM Server for SPARC"; |
||
406 | if (mac_between($mac, '00:0F:4B:00:00:00', '00:0F:4B:FF:FF:FF')) $vm = "Oracle Virtual Iron 4"; |
||
2 | daniel-mar | 407 | |
15 | daniel-mar | 408 | if ($vm) { |
409 | echo sprintf("%-32s %s\n", "Special use:", "Virtual machine $vm"); |
||
410 | } |
||
2 | daniel-mar | 411 | |
15 | daniel-mar | 412 | $app = ''; |
413 | |||
414 | // === FAQ "Other MAC address applications" |
||
415 | // http://www.cavebear.com/archive/cavebear/Ethernet/Ethernet.txt |
||
416 | // https://tools.ietf.org/html/rfc1060 |
||
417 | 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'; |
||
418 | if (mac_equals($mac, '01:00:1D:00:00:00')) $app = 'Cabletron PC-OV PC discover (on demand), EtherType is 0x0802'; |
||
419 | if (mac_equals($mac, '01:00:1D:42:00:00')) $app = 'Cabletron PC-OV Bridge discover (on demand), EtherType is 0x0802'; |
||
420 | if (mac_equals($mac, '01:00:1D:52:00:00')) $app = 'Cabletron PC-OV MMAC discover (on demand), EtherType is 0x0802'; |
||
421 | if (mac_between($mac, '01:00:3C:00:00:00' , '01:00:3C:FF:FF:FF')) $app = 'Auspex Systems (Serverguard)'; |
||
422 | if (mac_equals($mac, '01:00:10:00:00:20')) $app = 'Hughes Lan Systems Terminal Server S/W download, EtherType is 0x0802'; |
||
423 | if (mac_equals($mac, '01:00:10:FF:FF:20')) $app = 'Hughes Lan Systems Terminal Server S/W request, EtherType is 0x0802'; |
||
424 | if (mac_equals($mac, '01:00:81:00:00:00')) $app = 'Synoptics Network Management'; |
||
425 | if (mac_equals($mac, '01:00:81:00:00:02')) $app = 'Synoptics Network Management'; |
||
426 | if (mac_equals($mac, '01:00:81:00:01:00')) $app = 'Bay Networks (Synoptics) autodiscovery, EtherType is 0x0802 SNAP type is 0x01A2'; |
||
427 | if (mac_equals($mac, '01:00:81:00:01:01')) $app = 'Bay Networks (Synoptics) autodiscovery, EtherType is 0x0802 SNAP type is 0x01A1'; |
||
428 | 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'; |
||
429 | if (mac_equals($mac, '01:80:24:00:00:00')) $app = 'Kalpana Etherswitch every 60 seconds, EtherType is 0x0802'; |
||
430 | if (mac_equals($mac, '01:DD:00:FF:FF:FF')) $app = 'Ungermann-Bass boot-me requests, EtherType is 0x7002'; |
||
431 | if (mac_equals($mac, '01:DD:01:00:00:00')) $app = 'Ungermann-Bass Spanning Tree, EtherType is 0x7005'; |
||
432 | if (mac_equals($mac, '03:00:00:00:00:10')) $app = 'OS/2 1.3 EE + Communications Manager, EtherType is 0x80D5'; |
||
433 | if (mac_equals($mac, '03:00:00:00:00:40')) $app = 'OS/2 1.3 EE + Communications Manager, EtherType is 0x80D5'; |
||
434 | if (mac_equals($mac, '03:00:00:00:01:00')) $app = 'OSI All-IS Multicast, EtherType is 0x0802'; |
||
435 | if (mac_equals($mac, '03:00:00:00:02:00')) $app = 'OSI All-ES Multicast, EtherType is 0x0802'; |
||
436 | if (mac_equals($mac, '03:00:00:80:00:00')) $app = 'Discovery Client, EtherType is 0x0802'; |
||
437 | if (mac_equals($mac, '03:00:FF:FF:FF:FF')) $app = 'All Stations address, EtherType is 0x0802'; |
||
438 | if (mac_between($mac, '09:00:0D:00:00:00', '09:00:0D:FF:FF:FF')) $app = 'ICL Oslan Multicast, EtherType is 0x0802'; |
||
439 | if (mac_equals($mac, '09:00:0D:02:00:00')) $app = 'ICL Oslan Service discover only on boot'; |
||
440 | if (mac_equals($mac, '09:00:0D:02:0A:3C')) $app = 'ICL Oslan Service discover only on boot'; |
||
441 | if (mac_equals($mac, '09:00:0D:02:0A:38')) $app = 'ICL Oslan Service discover only on boot'; |
||
442 | if (mac_equals($mac, '09:00:0D:02:0A:39')) $app = 'ICL Oslan Service discover only on boot'; |
||
443 | if (mac_equals($mac, '09:00:0D:02:FF:FF')) $app = 'ICL Oslan Service discover only on boot'; |
||
444 | if (mac_equals($mac, '09:00:0D:09:00:00')) $app = 'ICL Oslan Service discover as required'; |
||
445 | if (mac_equals($mac, '09:00:1E:00:00:00')) $app = 'Apollo DOMAIN, EtherType is 0x8019'; |
||
446 | if (mac_equals($mac, '09:00:02:04:00:01')) $app = 'Vitalink printer messages, EtherType is 0x8080'; |
||
447 | if (mac_equals($mac, '09:00:02:04:00:02')) $app = 'Vitalink bridge management, EtherType is 0x8080'; |
||
448 | if (mac_equals($mac, '09:00:4C:00:00:0F')) $app = 'BICC Remote bridge adaptive routing (e.g. to Retix), EtherType is 0x0802'; |
||
449 | if (mac_equals($mac, '09:00:4E:00:00:02')) $app = 'Novell IPX, EtherType is 0x8137'; |
||
450 | if (mac_equals($mac, '09:00:6A:00:01:00')) $app = 'TOP NetBIOS'; |
||
451 | if (mac_equals($mac, '09:00:7C:01:00:01')) $app = 'Vitalink DLS Multicast'; |
||
452 | if (mac_equals($mac, '09:00:7C:01:00:03')) $app = 'Vitalink DLS Inlink'; |
||
453 | if (mac_equals($mac, '09:00:7C:01:00:04')) $app = 'Vitalink DLS and non DLS Multicast'; |
||
454 | if (mac_equals($mac, '09:00:7C:02:00:05')) $app = 'Vitalink diagnostics, EtherType is 0x8080'; |
||
455 | if (mac_equals($mac, '09:00:7C:05:00:01')) $app = 'Vitalink gateway, EtherType is 0x8080'; |
||
456 | if (mac_equals($mac, '09:00:7C:05:00:02')) $app = 'Vitalink Network Validation Message'; |
||
457 | if (mac_equals($mac, '09:00:09:00:00:01')) $app = 'HP Probe, EtherType is 0x8005 or 0x0802'; |
||
458 | if (mac_equals($mac, '09:00:09:00:00:04')) $app = 'HP DTC, EtherType is 0x8005'; |
||
459 | if (mac_equals($mac, '09:00:26:01:00:01')) $app = 'Vitalink TransLAN bridge management, EtherType is 0x8038'; |
||
460 | if (mac_equals($mac, '09:00:39:00:70:00')) $app = 'Spider Systems Bridge'; |
||
461 | if (mac_between($mac, '09:00:56:00:00:00', '09:00:56:FE:FF:FF')) $app = 'Stanford reserved'; |
||
462 | 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'; |
||
463 | if (mac_equals($mac, '09:00:77:00:00:00')) $app = 'Retix Bridge Local Management System, EtherType is 0x0802'; |
||
464 | if (mac_equals($mac, '09:00:77:00:00:01')) $app = 'Retix spanning tree bridges, EtherType is 0x0802'; |
||
465 | if (mac_equals($mac, '09:00:77:00:00:02')) $app = 'Retix Bridge Adaptive routing, EtherType is 0x0802'; |
||
466 | if (mac_equals($mac, '09:00:87:80:FF:FF')) $app = 'Xyplex Terminal Servers, EtherType is 0x0889'; |
||
467 | if (mac_equals($mac, '09:00:87:90:FF:FF')) $app = 'Xyplex Terminal Servers, EtherType is 0x0889'; |
||
468 | if (mac_between($mac, '44:38:39:FF:00:00', '44:38:39:FF:FF:FF')) $app = 'Multi-Chassis Link Aggregation (Cumulus Linux)'; |
||
469 | if (mac_equals($mac, 'FF:FF:00:40:00:01')) $app = 'LANtastic, EtherType is 0x81D6'; |
||
470 | if (mac_equals($mac, 'FF:FF:00:60:00:04')) $app = 'LANtastic, EtherType is 0x81D6'; |
||
471 | if (mac_equals($mac, 'FF:FF:01:E0:00:04')) $app = 'LANtastic'; |
||
472 | |||
473 | // === FAQ "The "CF" series MAC addresses" === |
||
474 | // https://www.iana.org/assignments/ppp-numbers/ppp-numbers.xhtml |
||
475 | // https://tools.ietf.org/html/rfc2153 |
||
476 | // https://tools.ietf.org/html/rfc7042#section-2.3.2 |
||
477 | if (mac_between($mac, 'CF:00:00:00:00:00', 'CF:00:00:FF:FF:FF')) $app = 'Reserved'; |
||
478 | if (mac_equals($mac, 'CF:00:00:00:00:00')) $app = 'Used for Ethernet loopback tests'; |
||
479 | |||
480 | // === FAQ "How to recognise a Broadcast MAC address application?" === |
||
481 | if (mac_equals($mac, 'FF:FF:FF:FF:FF:FF')) echo sprintf("%-32s %s\n", "Special use:", "Broadcast messaging"); |
||
482 | |||
483 | // === FAQ "How to recognise a Virtual Router ID by MAC address?" === |
||
484 | // https://tools.ietf.org/html/rfc7042#section-5.1 |
||
485 | // https://tools.ietf.org/html/rfc5798 |
||
486 | if (mac_between($mac, '00:00:5E:00:01:00', '00:00:5E:00:01:FF')) $app = 'IPv4 Virtual Router Redundancy Protocol (VRRP)'; |
||
487 | if (mac_between($mac, '00:00:5E:00:02:00', '00:00:5E:00:02:FF')) $app = 'IPv6 Virtual Router Redundancy Protocol'; |
||
488 | |||
489 | // === FAQ "How to recognise an IP frame by MAC address?" === |
||
490 | // https://tools.ietf.org/html/rfc1060 |
||
491 | // https://en.wikipedia.org/wiki/Multicast_address#cite_note-15 |
||
492 | // https://tools.ietf.org/html/rfc2464 |
||
493 | // https://www.iana.org/go/rfc1112 |
||
494 | // http://www.cavebear.com/archive/cavebear/Ethernet/Ethernet.txt |
||
495 | if (mac_between($mac, '01:00:5E:00:00:00', '01:00:5E:7F:FF:FF')) $app = 'IPv4 Multicast (EtherType is 0x0800)'; |
||
496 | 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. |
||
497 | if (mac_between($mac, '00:00:5E:00:52:13', '00:00:5E:00:52:13')) $app = 'Proxy Mobile IPv6'; |
||
16 | daniel-mar | 498 | if (mac_between($mac, '00:00:5E:FE:C0:00:02:00', '00:00:5E:FE:C0:00:02:FF')) $app = 'IPv4 derived documentation'; |
499 | if (mac_between($mac, '00:00:5E:FE:C6:33:64:00', '00:00:5E:FE:C6:33:64:FF')) $app = 'IPv4 derived documentation'; |
||
500 | if (mac_between($mac, '00:00:5E:FE:CB:00:71:00', '00:00:5E:FE:CB:00:71:FF')) $app = 'IPv4 derived documentation'; |
||
501 | if (mac_equals($mac, '00:00:5E:FE:EA:C0:00:02')) $app = 'IPv4 multicast derived documentation'; |
||
502 | if (mac_equals($mac, '00:00:5E:FE:EA:C6:33:64')) $app = 'IPv4 multicast derived documentation'; |
||
503 | if (mac_equals($mac, '00:00:5E:FE:EA:CB:00:71')) $app = 'IPv4 multicast derived documentation'; |
||
504 | if (mac_between($mac, '01:00:5E:FE:C0:00:02:00', '01:00:5E:FE:C0:00:02:FF')) $app = 'IPv4 derived documentation'; |
||
505 | if (mac_between($mac, '01:00:5E:FE:C6:33:64:00', '01:00:5E:FE:C6:33:64:FF')) $app = 'IPv4 derived documentation'; |
||
506 | if (mac_between($mac, '01:00:5E:FE:CB:00:71:00', '01:00:5E:FE:CB:00:71:FF')) $app = 'IPv4 derived documentation'; |
||
507 | if (mac_equals($mac, '01:00:5E:FE:EA:C0:00:02')) $app = 'IPv4 multicast derived documentation'; |
||
508 | if (mac_equals($mac, '01:00:5E:FE:EA:C6:33:64')) $app = 'IPv4 multicast derived documentation'; |
||
509 | if (mac_equals($mac, '01:00:5E:FE:EA:CB:00:71')) $app = 'IPv4 multicast derived documentation'; |
||
15 | daniel-mar | 510 | 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 | 511 | 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 | 512 | if (mac_equals($mac, '03:00:00:20:00:00')) $app = 'IP multicast address'; |
513 | if (mac_equals($mac, 'C0:00:00:04:00:00')) $app = 'IP multicast address'; |
||
16 | daniel-mar | 514 | 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 | 515 | |
516 | // === FAQ "How to recognise a MPLS multicast frame by MAC address?" === |
||
517 | // http://www.iana.org/go/rfc5332 |
||
518 | // http://www.iana.org/go/rfc7213 |
||
519 | if (mac_between($mac, '01:00:5E:80:00:00', '01:00:5E:8F:FF:FF')) $app = 'MPLS multicast (EtherType is 0x8847 or 0x8848)'; |
||
520 | if (mac_equals($mac, '01:00:5E:90:00:00')) $app = 'MPLS-TP p2p'; |
||
521 | |||
522 | // === FAQ "How to recognise a Bidirectional Forwarding Detection (BFD) on Link Aggregation Group (LAG) interfaces by MAC address?" === |
||
523 | // http://www.iana.org/go/rfc7130 |
||
524 | if (mac_equals($mac, '01:00:5E:90:00:01')) $app = 'Bidirectional Forwarding Detection (BFD) on Link Aggregation Group (LAG) interfaces'; |
||
525 | |||
526 | // === FAQ "How to recognise Token Ring specific functions by MAC address?" === |
||
527 | // https://tools.ietf.org/html/rfc1060 |
||
528 | // https://tools.ietf.org/html/rfc1469 |
||
529 | // https://standards.ieee.org/products-services/regauth/grpmac/public.html |
||
530 | // https://tools.ietf.org/html/rfc2470 |
||
531 | // http://www.cavebear.com/archive/cavebear/Ethernet/Ethernet.txt |
||
532 | if (mac_equals($mac, '03:00:00:00:00:01')) $app = 'NetBIOS (Token Ring)'; |
||
533 | if (mac_equals($mac, '03:00:00:00:00:02')) $app = 'Locate - Directory Server (Token Ring)'; |
||
534 | if (mac_equals($mac, '03:00:00:00:00:04')) $app = 'Synchronous Bandwidth Manager (Token Ring)'; |
||
535 | if (mac_equals($mac, '03:00:00:00:00:08')) $app = 'Configuration Report Server (Token Ring)'; |
||
536 | if (mac_equals($mac, '03:00:00:00:00:10')) $app = 'Ring Error Monitor (Token Ring)'; |
||
537 | if (mac_equals($mac, '03:00:00:00:00:20')) $app = 'Network Server Heartbeat (Token Ring)'; |
||
538 | if (mac_equals($mac, '03:00:00:00:00:40')) $app = 'Ring Parameter Monitor (Token Ring)'; |
||
539 | if (mac_equals($mac, '03:00:00:00:00:80')) $app = 'Active Monitor (Token Ring)'; |
||
540 | if (mac_equals($mac, '03:00:00:00:04:00')) $app = 'LAN Manager (Token Ring)'; |
||
541 | if (mac_equals($mac, '03:00:00:00:08:00')) $app = 'Ring Wiring Concentrator (Token Ring)'; |
||
542 | if (mac_equals($mac, '03:00:00:00:10:00')) $app = 'LAN Gateway (Token Ring)'; |
||
543 | if (mac_equals($mac, '03:00:00:00:20:00')) $app = 'Ring Authorization Server (Token Ring)'; |
||
544 | if (mac_equals($mac, '03:00:00:00:40:00')) $app = 'IMPL Server (Token Ring)'; |
||
545 | if (mac_equals($mac, '03:00:00:00:80:00')) $app = 'Bridge (Token Ring)'; |
||
546 | if (mac_equals($mac, '03:00:00:20:00:00')) $app = 'Single Token-Ring functional address'; |
||
547 | if (mac_equals($mac, '03:00:00:00:00:08')) $app = 'Configuration Report Server (CRS) MAC Group address'; |
||
548 | if (mac_equals($mac, '03:00:00:00:00:10')) $app = 'Ring Error Monitor (REM) MAC Group address'; |
||
549 | if (mac_equals($mac, '03:00:00:00:00:40')) $app = 'Ring Parameter Server (RPS) MAC group address'; |
||
550 | if (mac_equals($mac, '03:00:00:00:01:00')) $app = 'All Intermediate System Network Entities address'; |
||
551 | 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'; |
||
552 | if (mac_equals($mac, '03:00:00:00:04:00')) $app = 'Generic address for all Manager Stations'; |
||
553 | if (mac_equals($mac, '03:00:00:00:08:00')) $app = 'All CONs SNARES address'; |
||
554 | if (mac_equals($mac, '03:00:00:00:10:00')) $app = 'All CONs End System address'; |
||
555 | if (mac_equals($mac, '03:00:00:00:20:00')) $app = 'Loadable Device Generic address'; |
||
556 | if (mac_equals($mac, '03:00:00:00:40:00')) $app = 'Load Server Generic address'; |
||
557 | if (mac_equals($mac, '03:00:00:40:00:00')) $app = 'Generic address for all Agent Stations'; |
||
558 | if (mac_equals($mac, 'C0:00:00:04:00:00')) $app = 'Single Token-Ring functional address'; |
||
559 | 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'; |
||
560 | if (mac_equals($mac, '03:00:40:00:00:00')) $app = 'IPv6 multicast over Token Ring: all-Routers addresses (FF0X::2)'; |
||
561 | 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'; |
||
562 | 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'; |
||
563 | 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'; |
||
564 | 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'; |
||
565 | 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'; |
||
566 | 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'; |
||
567 | 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'; |
||
568 | 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'; |
||
569 | |||
570 | // === FAQ "How to recognise an AppleTalk protocols by MAC address?" === |
||
571 | // https://tools.ietf.org/html/rfc1060 |
||
572 | // http://www.cavebear.com/archive/cavebear/Ethernet/Ethernet.txt |
||
573 | if (mac_between($mac, '09:00:07:00:00:00', '09:00:07:00:00:FC')) $app = 'AppleTalk zone multicast addresses (EtherType is 0x0802)'; |
||
574 | if (mac_equals($mac, '09:00:07:FF:FF:FF')) $app = 'AppleTalk broadcast address (EtherType is 0x0802)'; |
||
575 | |||
576 | // === FAQ "How to recognise a TRILL protocols by MAC address?" === |
||
577 | // http://www.iana.org/go/rfc7455 |
||
578 | // https://tools.ietf.org/html/draft-ietf-trill-oam-framework-04 |
||
579 | // https://standards.ieee.org/products-services/regauth/grpmac/public.html |
||
580 | // https://tools.ietf.org/html/rfc7455#appendix-C |
||
581 | if (mac_between($mac, '00:00:5E:90:01:00', '00:00:5E:90:01:00')) $app = 'TRILL OAM'; |
||
582 | if (mac_equals($mac, '01:00:5E:90:01:00')) $app = 'TRILL OAM'; |
||
583 | 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'; |
||
584 | |||
585 | // === FAQ "How to recognise an IEEE 802.1X MAC address application?" === |
||
586 | 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'; |
||
587 | 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'; |
||
588 | 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'; |
||
589 | if (mac_equals($mac, '01:1B:19:00:00:00')) $app = 'General group address - An 802.1Q VLAN Bridge would forward the frame unchanged.'; |
||
590 | if (mac_equals($mac, '01:1B:19:00:00:00')) $app = 'Precision Time Protocol (PTP) version 2 over Ethernet, EtherType is 0x88F7'; |
||
591 | if (mac_equals($mac, '01:80:C2:00:00:00')) $app = 'Bridge Group address Nearest Customer Bridge group address'; |
||
592 | if (mac_equals($mac, '01:80:C2:00:00:00')) $app = 'Spanning Tree Protocol (for bridges) IEEE 802.1D, EtherType is 0x0802'; |
||
593 | if (mac_equals($mac, '01:80:C2:00:00:00')) $app = 'Link Layer Discovery Protocol, EtherType is 0x88CC'; |
||
594 | if (mac_between($mac, '01:80:C2:00:00:00', '01:80:C2:00:00:0F')) $app = 'The initial bridging/link protocols block'; |
||
595 | 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'; |
||
596 | if (mac_between($mac, '01:80:C2:00:00:00', '01:80:C2:00:00:0F')) $app = 'IEEE Pause, 802.3x'; |
||
597 | if (mac_equals($mac, '01:80:C2:00:00:0A')) $app = 'Reserved for future standardization'; |
||
598 | if (mac_equals($mac, '01:80:C2:00:00:0B')) $app = 'EDE-SS PEP Address'; |
||
599 | if (mac_equals($mac, '01:80:C2:00:00:0C')) $app = 'Reserved for future standardization'; |
||
600 | if (mac_equals($mac, '01:80:C2:00:00:0D')) $app = 'Provider Bridge MVRP address'; |
||
601 | 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'; |
||
602 | if (mac_equals($mac, '01:80:C2:00:00:0E')) $app = 'Nearest Bridge group address'; |
||
603 | if (mac_equals($mac, '01:80:C2:00:00:0E')) $app = 'Link Layer Discovery Protocol, EtherType is 0x88CC'; |
||
604 | if (mac_equals($mac, '01:80:C2:00:00:0E')) $app = 'Precision Time Protocol (PTP) version 2 over Ethernet, EtherType is 0x88F7'; |
||
605 | if (mac_equals($mac, '01:80:C2:00:00:01')) $app = 'IEEE MAC-specific Control Protocols group address'; |
||
606 | if (mac_equals($mac, '01:80:C2:00:00:01')) $app = 'Ethernet flow control (Pause frame) IEEE 802.3x, EtherType is 0x8808'; |
||
607 | if (mac_equals($mac, '01:80:C2:00:00:1A')) $app = 'Generic Address for All Agent Stations'; |
||
608 | if (mac_equals($mac, '01:80:C2:00:00:1B')) $app = 'All Multicast Capable End Systems address'; |
||
609 | if (mac_equals($mac, '01:80:C2:00:00:1C')) $app = 'All Multicast Announcements address'; |
||
610 | if (mac_equals($mac, '01:80:C2:00:00:1D')) $app = 'All Multicast Capable Intermediate Systems address'; |
||
611 | if (mac_equals($mac, '01:80:C2:00:00:1E')) $app = 'All DTR Concentrators MAC group address'; |
||
612 | if (mac_equals($mac, '01:80:C2:00:00:1F')) $app = 'EDE-CC PEP Address'; |
||
613 | 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'; |
||
614 | 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'; |
||
615 | if (mac_equals($mac, '01:80:C2:00:00:03')) $app = 'Nearest non-TPMR Bridge group address IEEE Std 802.1X PAE address'; |
||
616 | if (mac_equals($mac, '01:80:C2:00:00:03')) $app = 'Link Layer Discovery Protocol, EtherType is 0x88CC'; |
||
617 | if (mac_equals($mac, '01:80:C2:00:00:04')) $app = 'IEEE MAC-specific Control Protocols group address'; |
||
618 | if (mac_equals($mac, '01:80:C2:00:00:05')) $app = 'Reserved for future standardization'; |
||
619 | if (mac_equals($mac, '01:80:C2:00:00:06')) $app = 'Reserved for future standardization'; |
||
620 | if (mac_equals($mac, '01:80:C2:00:00:07')) $app = 'MEF Forum ELMI protocol group address'; |
||
621 | if (mac_equals($mac, '01:80:C2:00:00:08')) $app = 'Provider Bridge group address'; |
||
622 | if (mac_equals($mac, '01:80:C2:00:00:08')) $app = 'Spanning Tree Protocol (for provider bridges) IEEE 802.1ad, EtherType is 0x0802'; |
||
623 | if (mac_equals($mac, '01:80:C2:00:00:09')) $app = 'Reserved for future standardization'; |
||
624 | if (mac_equals($mac, '01:80:C2:00:00:10')) $app = 'All LANs Bridge Management group address (deprecated)'; |
||
625 | if (mac_equals($mac, '01:80:C2:00:00:10')) $app = 'Bridge Management, EtherType is 0x0802'; |
||
626 | if (mac_equals($mac, '01:80:C2:00:00:11')) $app = 'Load Server generic address'; |
||
627 | if (mac_equals($mac, '01:80:C2:00:00:11')) $app = 'Load Server, EtherType is 0x0802'; |
||
628 | if (mac_equals($mac, '01:80:C2:00:00:12')) $app = 'Loadable Device generic address'; |
||
629 | if (mac_equals($mac, '01:80:C2:00:00:12')) $app = 'Loadable Device, EtherType is 0x0802'; |
||
630 | if (mac_equals($mac, '01:80:C2:00:00:13')) $app = 'Transmission of IEEE 1905.1 control packets'; |
||
631 | if (mac_equals($mac, '01:80:C2:00:00:14')) $app = 'All Level 1 Intermediate Systems address'; |
||
632 | if (mac_equals($mac, '01:80:C2:00:00:14')) $app = 'OSI Route level 1 (within area), EtherType is 0x0802'; |
||
633 | if (mac_equals($mac, '01:80:C2:00:00:15')) $app = 'All Level 2 Intermediate Systems address'; |
||
634 | if (mac_equals($mac, '01:80:C2:00:00:15')) $app = 'OSI Route level 2 (between area), EtherType is 0x0802'; |
||
635 | if (mac_equals($mac, '01:80:C2:00:00:16')) $app = 'All CONS End Systems address'; |
||
636 | if (mac_equals($mac, '01:80:C2:00:00:17')) $app = 'All CONS SNARES address'; |
||
637 | if (mac_equals($mac, '01:80:C2:00:00:18')) $app = 'Generic address for All Manager Stations'; |
||
638 | if (mac_equals($mac, '01:80:C2:00:00:19')) $app = 'Groupcast with retries (GCR) MAC group address'; |
||
639 | 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'; |
||
640 | 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'; |
||
641 | 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'; |
||
642 | 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'; |
||
643 | if (mac_between($mac, '01:80:C2:00:00:50', '01:80:C2:00:00:FF')) $app = 'Unassigned standard group MAC address'; |
||
644 | if (mac_equals($mac, '01:80:C2:00:01:00')) $app = 'Ring Management Directed Beacon multicast address'; |
||
645 | if (mac_equals($mac, '01:80:C2:00:01:00')) $app = 'FDDI RMT Directed Beacon, EtherType is 0x0802'; |
||
646 | 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'; |
||
647 | if (mac_equals($mac, '01:80:C2:00:01:10')) $app = 'Status Report Frame Status Report Protocol multicast address'; |
||
648 | if (mac_equals($mac, '01:80:C2:00:01:10')) $app = 'FDDI status report frame, EtherType is 0x0802'; |
||
649 | 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'; |
||
650 | if (mac_equals($mac, '01:80:C2:00:01:20')) $app = 'All FDDI Concentrator MACs'; |
||
651 | 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'; |
||
652 | if (mac_equals($mac, '01:80:C2:00:01:30')) $app = 'Synchronous Bandwidth Allocation address'; |
||
653 | 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'; |
||
654 | if (mac_between($mac, '01:80:C2:00:02:00', '01:80:C2:00:02:FF')) $app = 'Assigned to ETSI for future use'; |
||
655 | if (mac_between($mac, '01:80:C2:00:03:00', '01:80:C2:FF-FF-FF')) $app = 'Unassigned standard group MAC address'; |
||
656 | if (mac_equals($mac, '09:00:4C:00:00:00')) $app = 'BICC 802.1 management, EtherType is 0x0802'; |
||
657 | if (mac_equals($mac, '09:00:4C:00:00:0C')) $app = 'BICC Remote bridge STA 802.1(D) Rev8, EtherType is 0x0802'; |
||
658 | if (mac_equals($mac, '09:00:4C:00:00:02')) $app = 'BICC 802.1 management, EtherType is 0x0802'; |
||
659 | if (mac_equals($mac, '09:00:4C:00:00:06')) $app = 'BICC Local bridge STA 802.1(D) Rev6, EtherType is 0x0802'; |
||
660 | if (mac_between($mac, '33:33:00:00:00:00', '33:33:FF:FF:FF:FF')) $app = 'IPv6 multicast, EtherType is 0x86DD'; |
||
661 | |||
662 | // === FAQ "How to recognise an ISO 9542 ES-IS protocol's MAC address application?" === |
||
663 | // https://standards.ieee.org/products-services/regauth/grpmac/public.html |
||
664 | if (mac_equals($mac, '09:00:2B:00:00:04')) $app = 'All End System Network Entities address'; |
||
665 | if (mac_equals($mac, '09:00:2B:00:00:05')) $app = 'All Intermediate System Network Entities address'; |
||
666 | |||
667 | // === FAQ "How to recognise an IANA MAC address application?" === |
||
668 | // https://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml |
||
669 | // http://www.iana.org/go/rfc7042 |
||
670 | // https://tools.ietf.org/html/rfc1060 |
||
671 | if (mac_between($mac, '00:00:5E:00-52:14', '00:00:5E:00:52:FF')) $app = 'Unassigned (small allocations)'; |
||
672 | if (mac_between($mac, '00:00:5E:00:00:00', '00:00:5E:00:00:FF')) $app = 'Reserved and require IESG Ratification for assignment'; |
||
673 | if (mac_between($mac, '00:00:5E:00:03:00', '00:00:5E:00:51:FF')) $app = 'Unassigned'; |
||
674 | 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.'; |
||
675 | if (mac_between($mac, '00:00:5E:00:52:00', '00:00:5E:00:52:00')) $app = 'PacketPWEthA'; |
||
676 | if (mac_between($mac, '00:00:5E:00:52:01', '00:00:5E:00:52:01')) $app = 'PacketPWEthB'; |
||
677 | if (mac_between($mac, '00:00:5E:00:52:02', '00:00:5E:00:52:12')) $app = 'Unassigned (small allocations)'; |
||
678 | if (mac_between($mac, '00:00:5E:00:53:00', '00:00:5E:00:53:FF')) $app = 'Assigned for use in documentation'; |
||
679 | if (mac_between($mac, '00:00:5E:00:54:00', '00:00:5E:90:00:FF')) $app = 'Unassigned'; |
||
680 | 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 | 681 | if (mac_between($mac, '00:00:5E:EF:10:00:00:00', '00:00:5E:EF:10:00:00:FF')) $app = 'General documentation'; |
682 | 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 | 683 | 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.) |
684 | if (mac_between($mac, '01:00:5E:80:00:00', '01:00:5E:FF:FF:FF')) $app = 'DoD Internet'; |
||
685 | if (mac_equals($mac, '01:00:5E:90:00:02')) $app = 'AllL1MI-ISs'; |
||
686 | if (mac_equals($mac, '01:00:5E:90:00:03')) $app = 'AllL2MI-ISs'; |
||
687 | if (mac_between($mac, '01:00:5E:90:00:04', '01:00:5E:90:00:FF')) $app = 'Unassigned (small allocations)'; |
||
688 | 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)'; |
||
689 | if (mac_between($mac, '01:00:5E:90:02:00', '01:00:5E:90:0F:FF')) $app = 'Unassigned'; |
||
690 | if (mac_between($mac, '01:00:5E:90:02:00', '00:00:5E:FF:FF:FF')) $app = 'Unassigned'; |
||
691 | if (mac_between($mac, '01:00:5E:90:10:00', '01:00:5E:90:10:FF')) $app = 'Documentation'; |
||
692 | if (mac_between($mac, '01:00:5E:90:11:00', '01:00:5E:FF:FF:FF')) $app = 'Unassigned'; |
||
16 | daniel-mar | 693 | if (mac_between($mac, '01:00:5E:EF:10:00:00:00', '01:00:5E:EF:10:00:00:FF')) $app = 'General documentation'; |
694 | if (mac_between($mac, '02:00:5E:00:00:00:00:00', '02:00:5E:0F:FF:FF:FF:FF')) $app = 'Reserved'; |
||
695 | if (mac_between($mac, '02:00:5E:10:00:00:00:00', '02:00:5E:10:00:00:00:FF')) $app = 'Documentation'; |
||
696 | if (mac_between($mac, '02:00:5E:10:00:00:01:00', '02:00:5E:EF:FF:FF:FF:FF')) $app = 'Unassigned'; |
||
697 | if (mac_between($mac, '02:00:5E:F0:00:00:00:00', '02:00:5E:FD:FF:FF:FF:FF')) $app = 'Reserved'; |
||
698 | if (mac_between($mac, '02:00:5E:FE:00:00:00:00', '02:00:5E:FE:FF:FF:FF:FF')) $app = 'IPv4 Addr Holders'; |
||
699 | if (mac_between($mac, '02:00:5E:FF:00:00:00:00', '02:00:5E:FF:FD:FF:FF:FF')) $app = 'Reserved'; |
||
700 | 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'; |
||
701 | if (mac_between($mac, '02:00:5E:FF:FF:00:00:00', '02:00:5E:FF:FF:FF:FF:FF')) $app = 'Reserved'; |
||
702 | if (mac_between($mac, '03:00:5E:00:00:00:00:00', '03:00:5E:0F:FF:FF:FF:FF')) $app = 'Reserved'; |
||
703 | if (mac_between($mac, '03:00:5E:10:00:00:00:00', '03:00:5E:10:00:00:00:FF')) $app = 'Documentation'; |
||
704 | if (mac_between($mac, '03:00:5E:10:00:00:01:00', '03:00:5E:EF:FF:FF:FF:FF')) $app = 'Unassigned'; |
||
705 | if (mac_between($mac, '03:00:5E:F0:00:00:00:00', '03:00:5E:FD:FF:FF:FF:FF')) $app = 'Reserved'; |
||
706 | if (mac_between($mac, '03:00:5E:FF:00:00:00:00', '03:00:5E:FF:FD:FF:FF:FF')) $app = 'Reserved'; |
||
707 | 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'; |
||
708 | 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 | 709 | |
710 | // === FAQ "How to recognise a Cisco's MAC address application?" === |
||
711 | // https://www.cisco.com/c/en/us/support/docs/switches/catalyst-4500-series-switches/13414-103.html |
||
712 | // https://tools.ietf.org/html/rfc1060 |
||
713 | // https://en.wikipedia.org/wiki/Multicast_address#cite_note-15 |
||
714 | // http://www.cavebear.com/archive/cavebear/Ethernet/Ethernet.txt |
||
715 | if (mac_equals($mac, '01:00:0C:00:00:00')) $app = 'Inter Switch Link (ISL)'; |
||
716 | if (mac_equals($mac, '01:00:0C:CC:CC:CC')) $app = 'CDP (Cisco Discovery Protocol), VTP (VLAN Trunking Protocol), EtherType is 0x0802'; |
||
717 | if (mac_equals($mac, '01:00:0C:CC:CC:CC')) $app = 'Port Aggregation Protocol (PAgP), SNAP HDLC Protocol Type is 0x0104'; |
||
718 | if (mac_equals($mac, '01:00:0C:CC:CC:CC')) $app = 'Unidirectional Link Detection (UDLD), SNAP HDLC Protocol Type is 0x0111'; |
||
719 | if (mac_equals($mac, '01:00:0C:CC:CC:CC')) $app = 'Dynamic Trunking (DTP), SNAP HDLC Protocol Type is 0x2004'; |
||
720 | if (mac_equals($mac, '01:00:0C:CC:CC:CC')) $app = 'VLAN Trunking (VTP), SNAP HDLC Protocol Type is 0x2003'; |
||
721 | if (mac_equals($mac, '01:00:0C:CC:CC:CD')) $app = 'Cisco Shared Spanning Tree Protocol address, EtherType is 0x0802'; |
||
722 | if (mac_equals($mac, '01:00:0C:CC:CC:CD')) $app = 'Spanning Tree PVSTP+, SNAP HDLC Protocol Type is 0x010B'; |
||
723 | if (mac_equals($mac, '01:00:0C:CD:CD:CD')) $app = 'STP Uplink Fast, SNAP HDLC Protocol Type is 0x200A'; |
||
724 | if (mac_equals($mac, '01:00:0C:CD:CD:CE')) $app = 'VLAN Bridge, SNAP HDLC Protocol Type is 0x010C'; |
||
725 | if (mac_equals($mac, '01:00:0C:DD:DD:DD')) $app = 'CGMP (Cisco Group Management Protocol)'; |
||
726 | |||
727 | // === FAQ "How to recognise an ITU-T's MAC address application?" === |
||
728 | // https://www.itu.int/en/ITU-T/studygroups/2017-2020/15/Documents/IEEE-assigned_OUIs-30-06-2017.docx |
||
729 | if (mac_between($mac, '01:19:A7:00:00:00', '01:19:A7:00:00:FF')) $app = 'R-APS per G.8032'; |
||
730 | if (mac_between($mac, '01:19:A7:52:76:90', '01:19:A7:52:76:9F')) $app = 'Multicast per G.9961'; |
||
731 | |||
732 | // === FAQ "How to recognise Digital Equipment Corporation's MAC address application?" === |
||
733 | if (mac_equals($mac, '09:00:2B:00:00:00')) $app = 'DEC MUMPS, EtherType is 0x6009'; |
||
734 | if (mac_equals($mac, '09:00:2B:00:00:0F')) $app = 'DEC Local Area Transport (LAT), EtherType is 0x6004'; |
||
735 | if (mac_equals($mac, '09:00:2B:00:00:01')) $app = 'DEC DSM/DDP, EtherType is 0x8039'; |
||
736 | if (mac_between($mac, '09:00:2B:00:00:10', '09:00:2B:00:00:1F')) $app = 'DEC Experimental'; |
||
737 | if (mac_equals($mac, '09:00:2B:00:00:02')) $app = 'DEC VAXELN, EtherType is 0x803B'; |
||
738 | if (mac_equals($mac, '09:00:2B:00:00:03')) $app = 'DEC Lanbridge Traffic Monitor (LTM), EtherType is 0x8038'; |
||
739 | if (mac_equals($mac, '09:00:2B:00:00:04')) $app = 'DEC MAP End System'; |
||
740 | if (mac_equals($mac, '09:00:2B:00:00:05')) $app = 'DEC MAP Intermediate System'; |
||
741 | if (mac_equals($mac, '09:00:2B:00:00:06')) $app = 'DEC CSMA/CD Encryption, EtherType is 0x803D'; |
||
742 | if (mac_equals($mac, '09:00:2B:00:00:07')) $app = 'DEC NetBios Emulator, EtherType is 0x8040'; |
||
743 | if (mac_equals($mac, '09:00:2B:01:00:00')) $app = 'DEC LanBridge, EtherType is 0x8038'; |
||
744 | if (mac_equals($mac, '09:00:2B:01:00:01')) $app = 'DEC LanBridge, EtherType is 0x8038'; |
||
745 | if (mac_equals($mac, '09:00:2B:02:00:00')) $app = 'DEC DNA Level 2 Routing'; |
||
746 | if (mac_equals($mac, '09:00:2B:02:01:00')) $app = 'DEC DNA Naming Service Advertisement, EtherType is 0x803C'; |
||
747 | if (mac_equals($mac, '09:00:2B:02:01:01')) $app = 'DEC DNA Naming Service Solicitation, EtherType is 0x803C'; |
||
748 | if (mac_equals($mac, '09:00:2B:02:01:02')) $app = 'DEC Distributed Time Service, EtherType is 0x803E'; |
||
749 | if (mac_equals($mac, '09:00:2B:02:01:09')) $app = 'DEC Availability Manager for Distributed Systems DECamds, EtherType is 0x8048'; |
||
750 | if (mac_between($mac, '09:00:2B:03:00:00', '09:00:2B:03:FF:FF')) $app = 'DEC default filtering by bridges'; |
||
751 | if (mac_equals($mac, '09:00:2B:04:00:00')) $app = 'DEC Local Area System Transport (LAST), EtherType is 0x8041'; |
||
752 | if (mac_equals($mac, '09:00:2B:23:00:00')) $app = 'DEC Argonaut Console, EtherType is 0x803A'; |
||
753 | if (mac_equals($mac, 'AB:00:00:01:00:00')) $app = 'DEC Maintenance Operation Protocol (MOP) Dump/Load Assistance, EtherType is 0x6001'; |
||
754 | if (mac_equals($mac, 'AB:00:00:02:00:00')) $app = 'DEC Maintenance Operation Protocol (MOP), EtherType is 0x6002'; |
||
755 | if (mac_equals($mac, 'AB:00:00:03:00:00')) $app = 'DECNET Phase IV end node, EtherType is 0x6003'; |
||
756 | if (mac_equals($mac, 'AB:00:00:04:00:00')) $app = 'DECNET Phase IV Router, EtherType is 0x6003'; |
||
757 | if (mac_between($mac, 'AB:00:00:05:00:00', 'AB:00:03:FF:FF:FF')) $app = 'Reserved DEC'; |
||
758 | if (mac_equals($mac, 'AB:00:03:00:00:00')) $app = 'DEC Local Area Transport (LAT) - old, EtherType is 0x6004'; |
||
759 | 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 | 760 | 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 | 761 | |
762 | if ($app) { |
||
763 | echo sprintf("%-32s %s\n", "Special use:", $app); |
||
764 | } |
||
765 | |||
2 | daniel-mar | 766 | } |
15 | daniel-mar | 767 | |
768 | /** |
||
769 | * @param string $mac1 |
||
770 | * @param string $mac2 |
||
771 | * @return bool |
||
772 | */ |
||
773 | function mac_equals(string $mac1, string $mac2): bool { |
||
16 | daniel-mar | 774 | $mac1test = eui64_to_eui48($mac1); |
775 | if ($mac1test === false) return false; |
||
776 | $mac2test = eui64_to_eui48($mac2); |
||
777 | if ($mac2test === false) return false; |
||
778 | |||
779 | if (eui_bits($mac1test) != eui_bits($mac2test)) { |
||
780 | $mac1test = eui48_to_eui64($mac1); |
||
781 | $mac2test = eui48_to_eui64($mac2); |
||
782 | } |
||
783 | |||
784 | return mac_canonize($mac1test) == mac_canonize($mac2test); |
||
15 | daniel-mar | 785 | } |
786 | |||
787 | /** |
||
788 | * @param string $mac |
||
789 | * @param string $low |
||
790 | * @param string $high |
||
791 | * @return bool |
||
792 | */ |
||
793 | function mac_between(string $mac, string $low, string $high): bool { |
||
16 | daniel-mar | 794 | $mactest = eui64_to_eui48($mac); |
795 | if ($mactest === false) return false; |
||
796 | $lowtest = eui64_to_eui48($low); |
||
797 | if ($lowtest === false) return false; |
||
798 | $hightest = eui64_to_eui48($high); |
||
799 | if ($hightest === false) return false; |
||
15 | daniel-mar | 800 | |
16 | daniel-mar | 801 | if ((eui_bits($mactest) != eui_bits($lowtest)) || (eui_bits($lowtest) != eui_bits($hightest))) { |
802 | $mactest = eui48_to_eui64($mac); |
||
18 | daniel-mar | 803 | if ($mactest === false) return false; // e.g. trying ELI-48 to ELI-64 |
16 | daniel-mar | 804 | $lowtest = eui48_to_eui64($low); |
18 | daniel-mar | 805 | if ($lowtest === false) return false; // e.g. trying ELI-48 to ELI-64 |
16 | daniel-mar | 806 | $hightest = eui48_to_eui64($high); |
18 | daniel-mar | 807 | if ($hightest === false) return false; // e.g. trying ELI-48 to ELI-64 |
16 | daniel-mar | 808 | } |
15 | daniel-mar | 809 | |
16 | daniel-mar | 810 | $mactest = strtoupper(preg_replace('@[^0-9A-F]@', '', $mactest)); |
811 | $lowtest = strtoupper(preg_replace('@[^0-9A-F]@', '', $lowtest)); |
||
812 | $hightest = strtoupper(preg_replace('@[^0-9A-F]@', '', $hightest)); |
||
15 | daniel-mar | 813 | |
16 | daniel-mar | 814 | $mactest = gmp_init($mactest, 16); |
815 | $lowtest = gmp_init($lowtest, 16); |
||
816 | $hightest = gmp_init($hightest, 16); |
||
15 | daniel-mar | 817 | |
16 | daniel-mar | 818 | return (gmp_cmp($mactest, $lowtest) >= 0) && (gmp_cmp($mactest, $hightest) <= 0); |
17 | daniel-mar | 819 | } |