etherlyzer 0.9.3__tar.gz → 0.9.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. etherlyzer-0.9.4/PKG-INFO +236 -0
  2. etherlyzer-0.9.4/README.md +205 -0
  3. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/pyproject.toml +37 -12
  4. etherlyzer-0.9.4/src/etherlyzer/ieee/eui48_classifier.py +63 -0
  5. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/terminal/commands/inspect.py +103 -26
  6. etherlyzer-0.9.3/PKG-INFO +0 -548
  7. etherlyzer-0.9.3/README.md +0 -517
  8. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/LICENSE +0 -0
  9. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/__init__.py +0 -0
  10. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/etherlyzer.env +0 -0
  11. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/exporter.py +0 -0
  12. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/formatters.py +0 -0
  13. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/ieee/__init__.py +0 -0
  14. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/ieee/catalog.py +0 -0
  15. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/ieee/csv_parser.py +0 -0
  16. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/ieee/ieee_registry.py +0 -0
  17. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/ieee/index.py +0 -0
  18. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/terminal/__init__.py +0 -0
  19. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/terminal/cli.py +0 -0
  20. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/terminal/commands/__init__.py +0 -0
  21. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/terminal/commands/format.py +0 -0
  22. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/terminal/commands/registries.py +0 -0
  23. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/terminal/commands/sync.py +0 -0
  24. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/terminal/commands/validate.py +0 -0
  25. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/terminal/commands/whois.py +0 -0
  26. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/terminal/utility.py +0 -0
  27. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/util/__init__.py +0 -0
  28. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/util/dirs.py +0 -0
  29. {etherlyzer-0.9.3 → etherlyzer-0.9.4}/src/etherlyzer/util/knobs.py +0 -0
@@ -0,0 +1,236 @@
1
+ Metadata-Version: 2.4
2
+ Name: etherlyzer
3
+ Version: 0.9.4
4
+ Summary: Fast offline lookup and classification of Ethernet-related identifiers.
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Keywords: ethernet,mac-address,oui,ieee,ethertype,networking,cybersecurity,asset-discovery,network-automation
8
+ Author: Tobias Andersen
9
+ Requires-Python: >=3.14,<4
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Information Technology
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: System :: Networking
19
+ Classifier: Topic :: Security
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: pandas (>=3.0.6,<4.0.0)
22
+ Requires-Dist: platformdirs (>=4.12.2,<5.0.0)
23
+ Requires-Dist: python-dotenv (>=1.2.4,<2.0.0)
24
+ Requires-Dist: requests (>=2.34.2,<3.0.0)
25
+ Requires-Dist: tqdm (>=4.70.1,<5.0.0)
26
+ Project-URL: Homepage, https://github.com/blue-hexagon/EtherLyzer
27
+ Project-URL: Issues, https://github.com/blue-hexagon/EtherLyzer/issues
28
+ Project-URL: Repository, https://github.com/blue-hexagon/EtherLyzer
29
+ Description-Content-Type: text/markdown
30
+
31
+ <div align="center">
32
+
33
+ <picture>
34
+ <source media="(prefers-color-scheme: dark)" srcset="docs/source/_static/logo_dark.png">
35
+ <source media="(prefers-color-scheme: light)" srcset="docs/source/_static/logo_light.png">
36
+ <img alt="Etherlyzer" src="docs/source/_static/logo_light.png" width="460">
37
+ </picture>
38
+
39
+ <p>
40
+ <strong>Local Ethernet intelligence for engineers, security tooling, and automation.</strong>
41
+ </p>
42
+
43
+ <p>
44
+ <a href="https://pypi.org/project/etherlyzer/">
45
+ <img src="https://img.shields.io/pypi/v/etherlyzer?label=PyPI" alt="PyPI">
46
+ </a>
47
+ <a href="https://pypi.org/project/etherlyzer/">
48
+ <img src="https://img.shields.io/pypi/pyversions/etherlyzer" alt="Python">
49
+ </a>
50
+ <a href="https://github.com/blue-hexagon/etherlyzer/actions">
51
+ <img src="https://img.shields.io/github/actions/workflow/status/blue-hexagon/etherlyzer/tests.yml?branch=main&label=build" alt="Build">
52
+ </a>
53
+ <a href="https://etherlyzer.docs.manjana.dev/">
54
+ <img src="https://img.shields.io/badge/docs-online-6f42c1" alt="Documentation">
55
+ </a>
56
+ <a href="LICENSE">
57
+ <img src="https://img.shields.io/github/license/blue-hexagon/etherlyzer" alt="License">
58
+ </a>
59
+ </p>
60
+
61
+ <p>
62
+ <a href="https://etherlyzer.docs.manjana.dev/"><strong>Documentation</strong></a>
63
+ ·
64
+ <a href="https://pypi.org/project/etherlyzer/"><strong>PyPI</strong></a>
65
+ ·
66
+ <a href="https://github.com/blue-hexagon/etherlyzer"><strong>Source</strong></a>
67
+ </p>
68
+
69
+ </div>
70
+
71
+ ---
72
+
73
+ Etherlyzer turns IEEE registry data into a fast, local CLI and Python API for identifying, inspecting, validating, and normalizing Ethernet identifiers.
74
+
75
+ Identify the organization behind a MAC address, determine the exact IEEE allocation it belongs to, inspect its address range and assignment size, correlate related vendor allocations, resolve EtherTypes, and clean up MAC input — without relying on a third-party lookup API.
76
+
77
+ ## Why Etherlyzer?
78
+
79
+ Most MAC lookup tools stop at:
80
+
81
+ > `00:00:0c → Cisco`
82
+
83
+ Etherlyzer goes further.
84
+
85
+ It understands the IEEE allocation behind the address:
86
+
87
+ - **MA-L / OUI-24**
88
+ - **MA-M / OUI-28**
89
+ - **MA-S / OUI-36**
90
+ - **Legacy IAB allocations**
91
+ - **Company Identifiers (CID)**
92
+ - **EtherType protocol identifiers**
93
+
94
+ And exposes details such as:
95
+
96
+ - organization and vendor identity,
97
+ - assignment prefix,
98
+ - registry type,
99
+ - address range,
100
+ - prefix and host bit lengths,
101
+ - allocation capacity,
102
+ - legacy status,
103
+ - related IEEE allocations belonging to the same organization.
104
+
105
+ All registry data is synchronized locally, so normal lookups stay local too.
106
+
107
+ ### Built for real workflows
108
+
109
+ Etherlyzer is useful anywhere Ethernet identifiers become data rather than something you inspect manually:
110
+
111
+ - network automation,
112
+ - asset discovery,
113
+ - NAC and inventory systems,
114
+ - NOC/SOC workflows,
115
+ - packet-analysis tooling,
116
+ - security investigations,
117
+ - bulk dataset enrichment,
118
+ - Python applications and scripts.
119
+
120
+ ## Install
121
+
122
+ Requires Python 3.14+.
123
+
124
+ ```console
125
+ pip install etherlyzer
126
+ etherlyzer --version
127
+ ```
128
+
129
+ ## See what a MAC address really belongs to
130
+
131
+ ```console
132
+ etherlyzer inspect 00:00:0c:12:34:56
133
+ ```
134
+
135
+ ```text
136
+ Organization
137
+ Name : Cisco Systems
138
+ Full Name : Cisco Systems, Inc
139
+ Address
140
+ 170 WEST TASMAN DRIVE SAN JOSE CA US 95134-1706
141
+
142
+ Registry
143
+ IEEE Type : MA-L [MAC Address Block Large]
144
+ Assignment : 00-00-0c
145
+ Range : 00-00-0c-00-00-00 - 00-00-0c-ff-ff-ff
146
+ Legacy : False
147
+ Prefix Bits : 24 bits
148
+ Address Bits : 24 bits
149
+ Addresses : 16,777,216
150
+ ```
151
+
152
+ Etherlyzer can also correlate the organization against its other known IEEE MAC allocations.
153
+
154
+ ## One toolkit, multiple jobs
155
+
156
+ ```console
157
+ # Identify a vendor
158
+ etherlyzer whois 00:11:22:33:44:55
159
+
160
+ # Inspect the exact IEEE allocation
161
+ etherlyzer inspect 00:00:0c:12:34:56
162
+
163
+ # Inspect an Ethernet protocol identifier
164
+ etherlyzer inspect -t protocol 0800
165
+
166
+ # Validate and diagnose malformed input
167
+ etherlyzer validate 00-11-22-33-44-55
168
+
169
+ # Normalize MAC representation
170
+ etherlyzer format 001122334455
171
+
172
+ # Cisco-style formatting
173
+ etherlyzer format 001122334455 -p . -s 4
174
+
175
+ # Process multiple values
176
+ etherlyzer whois -f macs.txt
177
+ etherlyzer validate -b
178
+
179
+ # Inspect local registry state
180
+ etherlyzer registries
181
+
182
+ # Refresh IEEE registry data
183
+ etherlyzer sync
184
+ ```
185
+
186
+ ## Local by design
187
+
188
+ Etherlyzer maintains synchronized copies of the supported IEEE datasets on the local system.
189
+
190
+ That means routine lookups do **not** require sending MAC addresses or internal asset data to an external lookup service.
191
+
192
+ This makes Etherlyzer particularly useful for:
193
+
194
+ - internal infrastructure inventories,
195
+ - restricted environments,
196
+ - sensitive network datasets,
197
+ - high-volume lookups,
198
+ - offline analysis,
199
+ - automated enrichment pipelines.
200
+
201
+ Internet access is only required when the IEEE registry datasets need to be refreshed.
202
+
203
+ ## CLI and Python API
204
+
205
+ The command-line interface is built on the same underlying Python library.
206
+
207
+ Use Etherlyzer interactively from a terminal, compose it into shell workflows, or integrate its registry, lookup, validation, and formatting capabilities directly into Python applications.
208
+
209
+ ## Documentation
210
+
211
+ Full documentation is available at:
212
+
213
+ ### **https://etherlyzer.docs.manjana.dev/**
214
+
215
+ It includes:
216
+
217
+ - CLI reference
218
+ - Python API
219
+ - IEEE registry concepts
220
+ - MAC address concepts
221
+ - validation masks
222
+ - configuration
223
+ - registry synchronization
224
+ - examples and guides
225
+
226
+ For quick CLI help:
227
+
228
+ ```console
229
+ etherlyzer --help
230
+ etherlyzer <command> --help
231
+ ```
232
+
233
+ ## License
234
+
235
+ Etherlyzer is released under the [MIT License](LICENSE).
236
+
@@ -0,0 +1,205 @@
1
+ <div align="center">
2
+
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="docs/source/_static/logo_dark.png">
5
+ <source media="(prefers-color-scheme: light)" srcset="docs/source/_static/logo_light.png">
6
+ <img alt="Etherlyzer" src="docs/source/_static/logo_light.png" width="460">
7
+ </picture>
8
+
9
+ <p>
10
+ <strong>Local Ethernet intelligence for engineers, security tooling, and automation.</strong>
11
+ </p>
12
+
13
+ <p>
14
+ <a href="https://pypi.org/project/etherlyzer/">
15
+ <img src="https://img.shields.io/pypi/v/etherlyzer?label=PyPI" alt="PyPI">
16
+ </a>
17
+ <a href="https://pypi.org/project/etherlyzer/">
18
+ <img src="https://img.shields.io/pypi/pyversions/etherlyzer" alt="Python">
19
+ </a>
20
+ <a href="https://github.com/blue-hexagon/etherlyzer/actions">
21
+ <img src="https://img.shields.io/github/actions/workflow/status/blue-hexagon/etherlyzer/tests.yml?branch=main&label=build" alt="Build">
22
+ </a>
23
+ <a href="https://etherlyzer.docs.manjana.dev/">
24
+ <img src="https://img.shields.io/badge/docs-online-6f42c1" alt="Documentation">
25
+ </a>
26
+ <a href="LICENSE">
27
+ <img src="https://img.shields.io/github/license/blue-hexagon/etherlyzer" alt="License">
28
+ </a>
29
+ </p>
30
+
31
+ <p>
32
+ <a href="https://etherlyzer.docs.manjana.dev/"><strong>Documentation</strong></a>
33
+ ·
34
+ <a href="https://pypi.org/project/etherlyzer/"><strong>PyPI</strong></a>
35
+ ·
36
+ <a href="https://github.com/blue-hexagon/etherlyzer"><strong>Source</strong></a>
37
+ </p>
38
+
39
+ </div>
40
+
41
+ ---
42
+
43
+ Etherlyzer turns IEEE registry data into a fast, local CLI and Python API for identifying, inspecting, validating, and normalizing Ethernet identifiers.
44
+
45
+ Identify the organization behind a MAC address, determine the exact IEEE allocation it belongs to, inspect its address range and assignment size, correlate related vendor allocations, resolve EtherTypes, and clean up MAC input — without relying on a third-party lookup API.
46
+
47
+ ## Why Etherlyzer?
48
+
49
+ Most MAC lookup tools stop at:
50
+
51
+ > `00:00:0c → Cisco`
52
+
53
+ Etherlyzer goes further.
54
+
55
+ It understands the IEEE allocation behind the address:
56
+
57
+ - **MA-L / OUI-24**
58
+ - **MA-M / OUI-28**
59
+ - **MA-S / OUI-36**
60
+ - **Legacy IAB allocations**
61
+ - **Company Identifiers (CID)**
62
+ - **EtherType protocol identifiers**
63
+
64
+ And exposes details such as:
65
+
66
+ - organization and vendor identity,
67
+ - assignment prefix,
68
+ - registry type,
69
+ - address range,
70
+ - prefix and host bit lengths,
71
+ - allocation capacity,
72
+ - legacy status,
73
+ - related IEEE allocations belonging to the same organization.
74
+
75
+ All registry data is synchronized locally, so normal lookups stay local too.
76
+
77
+ ### Built for real workflows
78
+
79
+ Etherlyzer is useful anywhere Ethernet identifiers become data rather than something you inspect manually:
80
+
81
+ - network automation,
82
+ - asset discovery,
83
+ - NAC and inventory systems,
84
+ - NOC/SOC workflows,
85
+ - packet-analysis tooling,
86
+ - security investigations,
87
+ - bulk dataset enrichment,
88
+ - Python applications and scripts.
89
+
90
+ ## Install
91
+
92
+ Requires Python 3.14+.
93
+
94
+ ```console
95
+ pip install etherlyzer
96
+ etherlyzer --version
97
+ ```
98
+
99
+ ## See what a MAC address really belongs to
100
+
101
+ ```console
102
+ etherlyzer inspect 00:00:0c:12:34:56
103
+ ```
104
+
105
+ ```text
106
+ Organization
107
+ Name : Cisco Systems
108
+ Full Name : Cisco Systems, Inc
109
+ Address
110
+ 170 WEST TASMAN DRIVE SAN JOSE CA US 95134-1706
111
+
112
+ Registry
113
+ IEEE Type : MA-L [MAC Address Block Large]
114
+ Assignment : 00-00-0c
115
+ Range : 00-00-0c-00-00-00 - 00-00-0c-ff-ff-ff
116
+ Legacy : False
117
+ Prefix Bits : 24 bits
118
+ Address Bits : 24 bits
119
+ Addresses : 16,777,216
120
+ ```
121
+
122
+ Etherlyzer can also correlate the organization against its other known IEEE MAC allocations.
123
+
124
+ ## One toolkit, multiple jobs
125
+
126
+ ```console
127
+ # Identify a vendor
128
+ etherlyzer whois 00:11:22:33:44:55
129
+
130
+ # Inspect the exact IEEE allocation
131
+ etherlyzer inspect 00:00:0c:12:34:56
132
+
133
+ # Inspect an Ethernet protocol identifier
134
+ etherlyzer inspect -t protocol 0800
135
+
136
+ # Validate and diagnose malformed input
137
+ etherlyzer validate 00-11-22-33-44-55
138
+
139
+ # Normalize MAC representation
140
+ etherlyzer format 001122334455
141
+
142
+ # Cisco-style formatting
143
+ etherlyzer format 001122334455 -p . -s 4
144
+
145
+ # Process multiple values
146
+ etherlyzer whois -f macs.txt
147
+ etherlyzer validate -b
148
+
149
+ # Inspect local registry state
150
+ etherlyzer registries
151
+
152
+ # Refresh IEEE registry data
153
+ etherlyzer sync
154
+ ```
155
+
156
+ ## Local by design
157
+
158
+ Etherlyzer maintains synchronized copies of the supported IEEE datasets on the local system.
159
+
160
+ That means routine lookups do **not** require sending MAC addresses or internal asset data to an external lookup service.
161
+
162
+ This makes Etherlyzer particularly useful for:
163
+
164
+ - internal infrastructure inventories,
165
+ - restricted environments,
166
+ - sensitive network datasets,
167
+ - high-volume lookups,
168
+ - offline analysis,
169
+ - automated enrichment pipelines.
170
+
171
+ Internet access is only required when the IEEE registry datasets need to be refreshed.
172
+
173
+ ## CLI and Python API
174
+
175
+ The command-line interface is built on the same underlying Python library.
176
+
177
+ Use Etherlyzer interactively from a terminal, compose it into shell workflows, or integrate its registry, lookup, validation, and formatting capabilities directly into Python applications.
178
+
179
+ ## Documentation
180
+
181
+ Full documentation is available at:
182
+
183
+ ### **https://etherlyzer.docs.manjana.dev/**
184
+
185
+ It includes:
186
+
187
+ - CLI reference
188
+ - Python API
189
+ - IEEE registry concepts
190
+ - MAC address concepts
191
+ - validation masks
192
+ - configuration
193
+ - registry synchronization
194
+ - examples and guides
195
+
196
+ For quick CLI help:
197
+
198
+ ```console
199
+ etherlyzer --help
200
+ etherlyzer <command> --help
201
+ ```
202
+
203
+ ## License
204
+
205
+ Etherlyzer is released under the [MIT License](LICENSE).
@@ -1,9 +1,9 @@
1
1
  [project]
2
2
  name = "etherlyzer"
3
- version = "0.9.3"
3
+ version = "0.9.4"
4
4
  description = "Fast offline lookup and classification of Ethernet-related identifiers."
5
5
  readme = "README.md"
6
- requires-python = ">=3.14"
6
+ requires-python = ">=3.14,<4"
7
7
  license = "MIT"
8
8
 
9
9
  authors = [
@@ -37,11 +37,11 @@ classifiers = [
37
37
  ]
38
38
 
39
39
  dependencies = [
40
- "requests (>=2.34.2,<3.0.0)",
40
+ "requests>=2.34.2,<3.0.0",
41
41
  "python-dotenv>=1.2.4,<2.0.0",
42
- "platformdirs (>=4.12.2,<5.0.0)",
43
- "pandas (>=3.0.6,<4.0.0)",
44
- "tqdm (>=4.70.1,<5.0.0)",
42
+ "platformdirs>=4.12.2,<5.0.0",
43
+ "pandas>=3.0.6,<4.0.0",
44
+ "tqdm>=4.70.1,<5.0.0",
45
45
  ]
46
46
 
47
47
  [project.urls]
@@ -62,21 +62,46 @@ include = [
62
62
  ]
63
63
 
64
64
 
65
- [tool.poetry.group.dev.dependencies]
66
- pytest = "^9.1.1"
67
- pytest-cov = "^7.1.0"
68
- mypy = "^2.4.0"
69
- ruff = "^0.16.10"
65
+ [dependency-groups]
66
+ dev = [
67
+ "pytest>=9",
68
+ "pytest-cov>=7",
69
+ "ruff>=0.16",
70
+ "mypy>=2.4",
71
+ "pre-commit>=4",
72
+ "bandit>=1.9",
73
+ "pip-audit>=2.10.0",
74
+ "vulture>=2.14",
75
+ "types-toml>=0.10.8.20260518,<0.11.0.0"
76
+ ]
77
+ docs = [
78
+ "sphinx (>=9.1.0,<10.0.0)",
79
+ "furo (>=2025.12.19,<2026.0.0)",
80
+ "myst-parser (>=5.1.0,<6.0.0)",
81
+ "sphinx-copybutton (>=0.5.2,<0.6.0)",
82
+ "sphinx-autobuild (>=2025.8.25,<2026.0.0)",
83
+ "sphinx-design (>=0.7.0,<0.8.0)",
84
+ "sphinxcontrib-mermaid (>=2.1.0,<3.0.0)",
85
+ "sphinx-autodoc-typehints (>=3.13.0,<4.0.0)",
86
+ "sphinx-sitemap (>=2.9.0,<3.0.0)"
87
+ ]
70
88
 
71
89
 
72
90
  [tool.pytest.ini_options]
91
+ minversion = "8.0"
73
92
  testpaths = ["tests"]
74
- pythonpath = ["src"]
93
+ python_files = ["test_*.py"]
94
+ python_classes = ["Test*"]
95
+ python_functions = ["test_*"]
75
96
  addopts = [
76
97
  "-ra",
77
98
  "--strict-markers",
78
99
  "--strict-config",
79
100
  ]
101
+ markers = [
102
+ "integration: tests involving multiple Etherlyzer components",
103
+ "network: tests requiring external network access",
104
+ ]
80
105
 
81
106
 
82
107
  [tool.coverage.run]
@@ -0,0 +1,63 @@
1
+ from dataclasses import dataclass
2
+ from enum import StrEnum
3
+
4
+
5
+ class Administration(StrEnum):
6
+ UNIVERSAL = "universal"
7
+ LOCAL = "local"
8
+
9
+
10
+ class DeliveryType(StrEnum):
11
+ INDIVIDUAL = "individual"
12
+ GROUP = "group"
13
+
14
+
15
+ class SLAPQuadrant(StrEnum):
16
+ AAI = "administratively_assigned"
17
+ ELI = "extended_local"
18
+ RESERVED = "reserved"
19
+ SAI = "standard_assigned"
20
+
21
+
22
+ @dataclass(frozen=True, slots=True)
23
+ class MACClassification:
24
+ administration: Administration
25
+ delivery: DeliveryType
26
+ is_broadcast: bool
27
+ is_zero: bool
28
+ slap_quadrant: SLAPQuadrant | None
29
+
30
+
31
+ def classify_mac(mac: str) -> MACClassification:
32
+ mac = int(mac.replace(":", "").replace("-", ""), 16)
33
+ if not 0 <= mac < (1 << 48):
34
+ raise ValueError("Expected a 48-bit MAC address")
35
+
36
+ first = mac >> 40
37
+
38
+ is_local = bool(first & 0x02)
39
+ is_group = bool(first & 0x01)
40
+
41
+ quadrant = None
42
+
43
+ if is_local:
44
+ quadrant = {
45
+ 0x00: SLAPQuadrant.AAI,
46
+ 0x08: SLAPQuadrant.ELI,
47
+ 0x04: SLAPQuadrant.RESERVED,
48
+ 0x0C: SLAPQuadrant.SAI,
49
+ }[first & 0x0C]
50
+
51
+ return MACClassification(
52
+ administration=(
53
+ Administration.LOCAL
54
+ if is_local else Administration.UNIVERSAL
55
+ ),
56
+ delivery=(
57
+ DeliveryType.GROUP
58
+ if is_group else DeliveryType.INDIVIDUAL
59
+ ),
60
+ is_broadcast=mac == (1 << 48) - 1,
61
+ is_zero=mac == 0,
62
+ slap_quadrant=quadrant,
63
+ )