Subversion Repositories uuid_mac_utils

Rev

Rev 17 | Rev 19 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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