etherlyzer 0.9.6__tar.gz → 0.9.7__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 (49) hide show
  1. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/PKG-INFO +89 -28
  2. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/README.md +84 -26
  3. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/pyproject.toml +7 -3
  4. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/etherlyzer.env +10 -7
  5. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/exporter.py +7 -11
  6. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/formatters.py +6 -6
  7. etherlyzer-0.9.6/src/etherlyzer/ieee/analytics.py → etherlyzer-0.9.7/src/etherlyzer/ieee/analytics/allocations.py +4 -4
  8. etherlyzer-0.9.6/src/etherlyzer/ieee/eui48_classifier.py → etherlyzer-0.9.7/src/etherlyzer/ieee/analytics/mac_classification.py +1 -5
  9. etherlyzer-0.9.7/src/etherlyzer/ieee/entry/base.py +14 -0
  10. etherlyzer-0.9.7/src/etherlyzer/ieee/entry/ethertype.py +8 -0
  11. etherlyzer-0.9.7/src/etherlyzer/ieee/entry/mac.py +30 -0
  12. etherlyzer-0.9.7/src/etherlyzer/ieee/registry/cache.py +41 -0
  13. {etherlyzer-0.9.6/src/etherlyzer/ieee → etherlyzer-0.9.7/src/etherlyzer/ieee/registry}/catalog.py +26 -22
  14. etherlyzer-0.9.7/src/etherlyzer/ieee/registry/category.py +7 -0
  15. etherlyzer-0.9.7/src/etherlyzer/ieee/registry/downloader.py +100 -0
  16. etherlyzer-0.9.7/src/etherlyzer/ieee/registry/ieee_registry.py +61 -0
  17. {etherlyzer-0.9.6/src/etherlyzer/ieee → etherlyzer-0.9.7/src/etherlyzer/ieee/registry}/index.py +70 -52
  18. etherlyzer-0.9.6/src/etherlyzer/ieee/csv_parser.py → etherlyzer-0.9.7/src/etherlyzer/ieee/registry/parser.py +14 -7
  19. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/cli.py +2 -1
  20. etherlyzer-0.9.7/src/etherlyzer/terminal/commands/__init__.py +17 -0
  21. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/commands/format.py +3 -6
  22. etherlyzer-0.9.7/src/etherlyzer/terminal/commands/inspect/__init__.py +0 -0
  23. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/commands/inspect/controller.py +17 -13
  24. etherlyzer-0.9.7/src/etherlyzer/terminal/commands/inspect/types/__init__.py +0 -0
  25. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/commands/inspect/types/display.py +51 -26
  26. etherlyzer-0.9.7/src/etherlyzer/terminal/commands/inspect/types/ethertype_inspection.py +12 -0
  27. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/commands/inspect/types/mac_inspection.py +62 -26
  28. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/commands/inspect/validation.py +1 -1
  29. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/commands/registries.py +6 -6
  30. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/commands/sync.py +3 -3
  31. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/commands/validate.py +5 -6
  32. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/commands/whois.py +6 -6
  33. etherlyzer-0.9.7/src/etherlyzer/util/__init__.py +0 -0
  34. etherlyzer-0.9.7/src/etherlyzer/util/conversion.py +0 -0
  35. etherlyzer-0.9.7/src/etherlyzer/util/knobs.py +154 -0
  36. etherlyzer-0.9.6/src/etherlyzer/ieee/ieee_registry.py +0 -199
  37. etherlyzer-0.9.6/src/etherlyzer/terminal/commands/__init__.py +0 -8
  38. etherlyzer-0.9.6/src/etherlyzer/terminal/commands/inspect/types/ethertype_inspection.py +0 -6
  39. etherlyzer-0.9.6/src/etherlyzer/util/knobs.py +0 -105
  40. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/LICENSE +0 -0
  41. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/__init__.py +0 -0
  42. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/ieee/__init__.py +0 -0
  43. {etherlyzer-0.9.6/src/etherlyzer/terminal → etherlyzer-0.9.7/src/etherlyzer/ieee/analytics}/__init__.py +0 -0
  44. {etherlyzer-0.9.6/src/etherlyzer/terminal/commands/inspect → etherlyzer-0.9.7/src/etherlyzer/ieee/entry}/__init__.py +0 -0
  45. {etherlyzer-0.9.6/src/etherlyzer/terminal/commands/inspect/types → etherlyzer-0.9.7/src/etherlyzer/ieee/registry}/__init__.py +0 -0
  46. /etherlyzer-0.9.6/src/etherlyzer/util/__init__.py → /etherlyzer-0.9.7/src/etherlyzer/py.typed +0 -0
  47. /etherlyzer-0.9.6/src/etherlyzer/util/conversion.py → /etherlyzer-0.9.7/src/etherlyzer/terminal/__init__.py +0 -0
  48. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/terminal/utility.py +0 -0
  49. {etherlyzer-0.9.6 → etherlyzer-0.9.7}/src/etherlyzer/util/dirs.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: etherlyzer
3
- Version: 0.9.6
3
+ Version: 0.9.7
4
4
  Summary: Fast offline lookup and classification of Ethernet-related identifiers.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
7
7
  Keywords: ethernet,mac-address,oui,ieee,ethertype,networking,cybersecurity,asset-discovery,network-automation
8
8
  Author: Tobias Andersen
9
- Requires-Python: >=3.14,<4
9
+ Requires-Python: >=3.12,<4
10
10
  Classifier: Development Status :: 3 - Alpha
11
11
  Classifier: Environment :: Console
12
12
  Classifier: Intended Audience :: Information Technology
@@ -14,7 +14,10 @@ Classifier: Intended Audience :: System Administrators
14
14
  Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Operating System :: OS Independent
16
16
  Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
17
19
  Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
18
21
  Classifier: Topic :: System :: Networking
19
22
  Classifier: Topic :: Security
20
23
  Classifier: Typing :: Typed
@@ -40,24 +43,31 @@ Description-Content-Type: text/markdown
40
43
  <strong>Lightweight Ethernet Address Intelligence Engine</strong>
41
44
  </p>
42
45
 
43
- <p>
46
+ <p align="center">
47
+
48
+ <!-- Compatibility -->
44
49
  <a href="https://pypi.org/project/etherlyzer/">
45
- <img src="https://img.shields.io/pypi/v/etherlyzer?label=PyPI" alt="PyPI">
50
+ <img src="https://img.shields.io/pypi/pyversions/etherlyzer" alt="Python Versions">
46
51
  </a>
52
+
53
+ <!-- Distribution -->
47
54
  <a href="https://pypi.org/project/etherlyzer/">
48
- <img src="https://img.shields.io/pypi/pyversions/etherlyzer" alt="Python">
55
+ <img src="https://img.shields.io/pypi/v/etherlyzer?label=PyPI" alt="PyPI Version">
49
56
  </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">
57
+
58
+ <!-- Quality -->
59
+ <a href="https://github.com/blue-hexagon/Etherlyzer/actions/workflows/tests.yml">
60
+ <img src="https://img.shields.io/github/actions/workflow/status/blue-hexagon/Etherlyzer/tests.yml?branch=master&label=tests" alt="Tests">
52
61
  </a>
62
+
63
+ <!-- Project -->
53
64
  <a href="https://etherlyzer.docs.manjana.dev/">
54
65
  <img src="https://img.shields.io/badge/docs-online-6f42c1" alt="Documentation">
55
66
  </a>
56
- <a href="LICENSE">
57
- <img src="https://img.shields.io/github/license/blue-hexagon/etherlyzer" alt="License">
67
+ <a href="https://github.com/blue-hexagon/Etherlyzer/blob/master/LICENSE">
68
+ <img src="https://img.shields.io/github/license/blue-hexagon/Etherlyzer" alt="License">
58
69
  </a>
59
70
  </p>
60
-
61
71
  <p>
62
72
  <a href="https://etherlyzer.docs.manjana.dev/"><strong>Documentation</strong></a>
63
73
  ·
@@ -72,11 +82,16 @@ Description-Content-Type: text/markdown
72
82
 
73
83
  A lightweight, offline-first Python toolkit for analyzing Ethernet identifiers and IEEE EUI-48 address allocations.
74
84
 
75
- Etherlyzer goes beyond conventional MAC vendor lookups by combining IEEE registry data, address classification, allocation analysis, and organizational correlation into a unified command-line interface and Python API.
85
+ Etherlyzer goes beyond conventional MAC vendor lookups by combining IEEE registry data, address classification,
86
+ allocation analysis, and organizational correlation into a unified command-line interface and Python API.
87
+
88
+ Identify the organization behind a MAC address, determine its IEEE-registered allocation, inspect address ranges and
89
+ allocation capacities, correlate related vendor blocks, resolve EtherTypes, and validate or normalize MAC addresses —
90
+ all locally, without relying on third-party lookup APIs.
76
91
 
77
- Identify the organization behind a MAC address, determine its IEEE-registered allocation, inspect address ranges and allocation capacities, correlate related vendor blocks, resolve EtherTypes, and validate or normalize MAC addresses — all locally, without relying on third-party lookup APIs.
92
+ Built for network engineers, security researchers, and developers who need fast, reliable, standards-aware insight into
93
+ Ethernet addressing.
78
94
 
79
- Built for network engineers, security researchers, and developers who need fast, reliable, standards-aware insight into Ethernet addressing.
80
95
  ## Why Etherlyzer?
81
96
 
82
97
  Most MAC lookup tools stop at:
@@ -132,24 +147,68 @@ etherlyzer --version
132
147
  ## See what a MAC address really belongs to
133
148
 
134
149
  ```console
135
- etherlyzer inspect 00:00:0c:12:34:56
150
+ etherlyzer inspect -xsb 00000f
136
151
  ```
137
152
 
138
153
  ```text
154
+ MAC Address Autopsy
155
+ Input
156
+ Value : 00000f
157
+ Length : 24 bits
158
+ Representations
159
+ Canonical : 00-00-0F
160
+ Bit-Reversed : 00:00:F0
161
+ To Hex : 00000F
162
+ To Integer : 15
163
+ To Decimals : 0 0 15
164
+ To Octal : 00000017
165
+ To Binary : 0000.0000.0000.0000.0000.1111
166
+ To Bytes : 00 00 0F
167
+ Address Properties
168
+ Null Address : False
169
+ Broadcast : False
170
+ Special Bits
171
+ U/L : 0 Universal / Universally Administered
172
+ I/G : 0 Individual / Unicast
173
+
174
+ IEEE Identifier
175
+ Type : Universal Individual Prefix (Registered Block)
176
+ SLAP Quadrant : None
177
+
178
+ IEEE Registry
179
+ IEEE Type : MA-L [MAC Address Block Large]
180
+ Assignment : 00-00-0f
181
+ Range : 00-00-0f-00-00-00 - 00-00-0f-ff-ff-ff
182
+ Prefix Bits : 24 bits
183
+ Address Bits : 24 bits
184
+ Legacy : False
185
+ Legacy Name : OUI
186
+ Address Capacity : 16,777,216
187
+
188
+ Associated Allocations
189
+ Total
190
+ Blocks : 1
191
+ Capacity : 16,777,216
192
+ MA-L
193
+ Blocks : 1
194
+ Capacity : 16,777,216
195
+ MA-M
196
+ Blocks : 0
197
+ Capacity : 0
198
+ MA-S
199
+ Blocks : 0
200
+ Capacity : 0
201
+ IAB
202
+ Blocks : 0
203
+ Capacity : 0
204
+ Registered Blocks (B=IAB, S=MA-S, M=MA-M, L=MA-L)
205
+ [L] 00-00-0f
206
+
139
207
  Organization
140
- Name : Cisco Systems
141
- Full Name : Cisco Systems, Inc
208
+ Name : NEXT
209
+ Full Name : NEXT, INC.
142
210
  Address
143
- 170 WEST TASMAN DRIVE SAN JOSE CA US 95134-1706
144
-
145
- Registry
146
- IEEE Type : MA-L [MAC Address Block Large]
147
- Assignment : 00-00-0c
148
- Range : 00-00-0c-00-00-00 - 00-00-0c-ff-ff-ff
149
- Legacy : False
150
- Prefix Bits : 24 bits
151
- Address Bits : 24 bits
152
- Addresses : 16,777,216
211
+ 3475 DEER CREEK ROAD PALO ALTO CA US 94304
153
212
  ```
154
213
 
155
214
  Etherlyzer can also correlate the organization against its other known IEEE MAC allocations.
@@ -190,7 +249,8 @@ etherlyzer sync
190
249
 
191
250
  Etherlyzer maintains synchronized copies of the supported IEEE datasets on the local system.
192
251
 
193
- That means routine lookups do **not** require sending MAC addresses or internal asset data to an external lookup service.
252
+ That means routine lookups do **not** require sending MAC addresses or internal asset data to an external lookup
253
+ service.
194
254
 
195
255
  This makes Etherlyzer particularly useful for:
196
256
 
@@ -207,7 +267,8 @@ Internet access is only required when the IEEE registry datasets need to be refr
207
267
 
208
268
  The command-line interface is built on the same underlying Python library.
209
269
 
210
- Use Etherlyzer interactively from a terminal, compose it into shell workflows, or integrate its registry, lookup, validation, and formatting capabilities directly into Python applications.
270
+ Use Etherlyzer interactively from a terminal, compose it into shell workflows, or integrate its registry, lookup,
271
+ validation, and formatting capabilities directly into Python applications.
211
272
 
212
273
  ## Documentation
213
274
 
@@ -10,24 +10,31 @@
10
10
  <strong>Lightweight Ethernet Address Intelligence Engine</strong>
11
11
  </p>
12
12
 
13
- <p>
13
+ <p align="center">
14
+
15
+ <!-- Compatibility -->
14
16
  <a href="https://pypi.org/project/etherlyzer/">
15
- <img src="https://img.shields.io/pypi/v/etherlyzer?label=PyPI" alt="PyPI">
17
+ <img src="https://img.shields.io/pypi/pyversions/etherlyzer" alt="Python Versions">
16
18
  </a>
19
+
20
+ <!-- Distribution -->
17
21
  <a href="https://pypi.org/project/etherlyzer/">
18
- <img src="https://img.shields.io/pypi/pyversions/etherlyzer" alt="Python">
22
+ <img src="https://img.shields.io/pypi/v/etherlyzer?label=PyPI" alt="PyPI Version">
19
23
  </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">
24
+
25
+ <!-- Quality -->
26
+ <a href="https://github.com/blue-hexagon/Etherlyzer/actions/workflows/tests.yml">
27
+ <img src="https://img.shields.io/github/actions/workflow/status/blue-hexagon/Etherlyzer/tests.yml?branch=master&label=tests" alt="Tests">
22
28
  </a>
29
+
30
+ <!-- Project -->
23
31
  <a href="https://etherlyzer.docs.manjana.dev/">
24
32
  <img src="https://img.shields.io/badge/docs-online-6f42c1" alt="Documentation">
25
33
  </a>
26
- <a href="LICENSE">
27
- <img src="https://img.shields.io/github/license/blue-hexagon/etherlyzer" alt="License">
34
+ <a href="https://github.com/blue-hexagon/Etherlyzer/blob/master/LICENSE">
35
+ <img src="https://img.shields.io/github/license/blue-hexagon/Etherlyzer" alt="License">
28
36
  </a>
29
37
  </p>
30
-
31
38
  <p>
32
39
  <a href="https://etherlyzer.docs.manjana.dev/"><strong>Documentation</strong></a>
33
40
  ·
@@ -42,11 +49,16 @@
42
49
 
43
50
  A lightweight, offline-first Python toolkit for analyzing Ethernet identifiers and IEEE EUI-48 address allocations.
44
51
 
45
- Etherlyzer goes beyond conventional MAC vendor lookups by combining IEEE registry data, address classification, allocation analysis, and organizational correlation into a unified command-line interface and Python API.
52
+ Etherlyzer goes beyond conventional MAC vendor lookups by combining IEEE registry data, address classification,
53
+ allocation analysis, and organizational correlation into a unified command-line interface and Python API.
54
+
55
+ Identify the organization behind a MAC address, determine its IEEE-registered allocation, inspect address ranges and
56
+ allocation capacities, correlate related vendor blocks, resolve EtherTypes, and validate or normalize MAC addresses —
57
+ all locally, without relying on third-party lookup APIs.
46
58
 
47
- Identify the organization behind a MAC address, determine its IEEE-registered allocation, inspect address ranges and allocation capacities, correlate related vendor blocks, resolve EtherTypes, and validate or normalize MAC addresses — all locally, without relying on third-party lookup APIs.
59
+ Built for network engineers, security researchers, and developers who need fast, reliable, standards-aware insight into
60
+ Ethernet addressing.
48
61
 
49
- Built for network engineers, security researchers, and developers who need fast, reliable, standards-aware insight into Ethernet addressing.
50
62
  ## Why Etherlyzer?
51
63
 
52
64
  Most MAC lookup tools stop at:
@@ -102,24 +114,68 @@ etherlyzer --version
102
114
  ## See what a MAC address really belongs to
103
115
 
104
116
  ```console
105
- etherlyzer inspect 00:00:0c:12:34:56
117
+ etherlyzer inspect -xsb 00000f
106
118
  ```
107
119
 
108
120
  ```text
121
+ MAC Address Autopsy
122
+ Input
123
+ Value : 00000f
124
+ Length : 24 bits
125
+ Representations
126
+ Canonical : 00-00-0F
127
+ Bit-Reversed : 00:00:F0
128
+ To Hex : 00000F
129
+ To Integer : 15
130
+ To Decimals : 0 0 15
131
+ To Octal : 00000017
132
+ To Binary : 0000.0000.0000.0000.0000.1111
133
+ To Bytes : 00 00 0F
134
+ Address Properties
135
+ Null Address : False
136
+ Broadcast : False
137
+ Special Bits
138
+ U/L : 0 Universal / Universally Administered
139
+ I/G : 0 Individual / Unicast
140
+
141
+ IEEE Identifier
142
+ Type : Universal Individual Prefix (Registered Block)
143
+ SLAP Quadrant : None
144
+
145
+ IEEE Registry
146
+ IEEE Type : MA-L [MAC Address Block Large]
147
+ Assignment : 00-00-0f
148
+ Range : 00-00-0f-00-00-00 - 00-00-0f-ff-ff-ff
149
+ Prefix Bits : 24 bits
150
+ Address Bits : 24 bits
151
+ Legacy : False
152
+ Legacy Name : OUI
153
+ Address Capacity : 16,777,216
154
+
155
+ Associated Allocations
156
+ Total
157
+ Blocks : 1
158
+ Capacity : 16,777,216
159
+ MA-L
160
+ Blocks : 1
161
+ Capacity : 16,777,216
162
+ MA-M
163
+ Blocks : 0
164
+ Capacity : 0
165
+ MA-S
166
+ Blocks : 0
167
+ Capacity : 0
168
+ IAB
169
+ Blocks : 0
170
+ Capacity : 0
171
+ Registered Blocks (B=IAB, S=MA-S, M=MA-M, L=MA-L)
172
+ [L] 00-00-0f
173
+
109
174
  Organization
110
- Name : Cisco Systems
111
- Full Name : Cisco Systems, Inc
175
+ Name : NEXT
176
+ Full Name : NEXT, INC.
112
177
  Address
113
- 170 WEST TASMAN DRIVE SAN JOSE CA US 95134-1706
114
-
115
- Registry
116
- IEEE Type : MA-L [MAC Address Block Large]
117
- Assignment : 00-00-0c
118
- Range : 00-00-0c-00-00-00 - 00-00-0c-ff-ff-ff
119
- Legacy : False
120
- Prefix Bits : 24 bits
121
- Address Bits : 24 bits
122
- Addresses : 16,777,216
178
+ 3475 DEER CREEK ROAD PALO ALTO CA US 94304
123
179
  ```
124
180
 
125
181
  Etherlyzer can also correlate the organization against its other known IEEE MAC allocations.
@@ -160,7 +216,8 @@ etherlyzer sync
160
216
 
161
217
  Etherlyzer maintains synchronized copies of the supported IEEE datasets on the local system.
162
218
 
163
- That means routine lookups do **not** require sending MAC addresses or internal asset data to an external lookup service.
219
+ That means routine lookups do **not** require sending MAC addresses or internal asset data to an external lookup
220
+ service.
164
221
 
165
222
  This makes Etherlyzer particularly useful for:
166
223
 
@@ -177,7 +234,8 @@ Internet access is only required when the IEEE registry datasets need to be refr
177
234
 
178
235
  The command-line interface is built on the same underlying Python library.
179
236
 
180
- Use Etherlyzer interactively from a terminal, compose it into shell workflows, or integrate its registry, lookup, validation, and formatting capabilities directly into Python applications.
237
+ Use Etherlyzer interactively from a terminal, compose it into shell workflows, or integrate its registry, lookup,
238
+ validation, and formatting capabilities directly into Python applications.
181
239
 
182
240
  ## Documentation
183
241
 
@@ -1,9 +1,9 @@
1
1
  [project]
2
2
  name = "etherlyzer"
3
- version = "0.9.6"
3
+ version = "0.9.7"
4
4
  description = "Fast offline lookup and classification of Ethernet-related identifiers."
5
5
  readme = "README.md"
6
- requires-python = ">=3.14,<4"
6
+ requires-python = ">=3.12,<4"
7
7
  license = "MIT"
8
8
 
9
9
  authors = [
@@ -30,7 +30,10 @@ classifiers = [
30
30
  "License :: OSI Approved :: MIT License",
31
31
  "Operating System :: OS Independent",
32
32
  "Programming Language :: Python :: 3",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Programming Language :: Python :: 3.13",
33
35
  "Programming Language :: Python :: 3.14",
36
+ "Programming Language :: Python :: 3.15",
34
37
  "Topic :: System :: Networking",
35
38
  "Topic :: Security",
36
39
  "Typing :: Typed",
@@ -120,8 +123,9 @@ exclude_lines = [
120
123
 
121
124
 
122
125
  [tool.mypy]
123
- python_version = "3.14"
126
+ python_version = "3.12"
124
127
  strict = true
128
+ mypy_path = "src"
125
129
  files = ["src", "tests"]
126
130
 
127
131
  warn_unused_configs = true
@@ -1,20 +1,23 @@
1
- #---------------------------------------------------DATASET
2
1
  # Maximum age of the local IEEE database before synchronization, in hours
3
- DB_UPDATE_INTERVAL_HOURS=250
2
+ # Alternatively, the following may be specified:
3
+ # hourly, daily, twice-weekly, weekly, fortnightly, twice-monthly, monthly, quarterly, yearly
4
+ DB_UPDATE_INTERVAL_HOURS=fortnightly
5
+
6
+ # Field delimiter used for CSV export and CLI output
7
+ FIELD_SEPARATOR=;
4
8
 
5
- #---------------------------------------------------EXPORT
6
- # Field delimiter used for CSV and stdout output
7
- FIELD_SEPARATOR="\t"
8
9
  # MAC address formatting
9
- # Supported separators: :, -, ., or an empty value
10
+ # Allowed separators: :, -, ., or an empty value
10
11
  MAC_SEPARATOR=-
12
+
11
13
  # Number of hexadecimal characters per block
12
14
  # 2 -> 00:11:22:33:44:55
13
15
  # 4 -> 0011.2233.4455
14
16
  MAC_BLOCK_SIZE=2
17
+
18
+ # MAC Address Casing
15
19
  # Supported values: upper, lower
16
20
  MAC_CASE=lower
17
21
 
18
- #---------------------------------------------------DISPLAY
19
22
  # Print database synchronization messages
20
23
  SHOW_SYNC_MESSAGES=true
@@ -1,13 +1,15 @@
1
+ import contextlib
2
+
1
3
  from etherlyzer.formatters import MACFormatter
2
- from etherlyzer.ieee.ieee_registry import IEEEEntry
4
+ from etherlyzer.ieee.entry.mac import MACAllocationEntry
3
5
  from etherlyzer.util.knobs import etherlyzer_knobs
4
6
 
5
7
 
6
8
  class RegistryMatchExporter:
7
9
  @staticmethod
8
- def export_csv_to_console(entries: list[IEEEEntry]):
10
+ def export_csv_to_console(entries: list[MACAllocationEntry]) -> None:
9
11
  for entry in entries:
10
- try:
12
+ with contextlib.suppress(AttributeError):
11
13
  print(
12
14
  f"{entry.registry}{etherlyzer_knobs.field_separator}"
13
15
  f"{MACFormatter.format_default(entry.assignment)}{etherlyzer_knobs.field_separator}"
@@ -15,16 +17,10 @@ class RegistryMatchExporter:
15
17
  f"{entry.organization_address}"
16
18
  f""
17
19
  )
18
- except AttributeError():
19
- # Lookup not found.
20
- pass
21
20
 
22
21
  @staticmethod
23
- def export_humanized_to_console(entries: list[IEEEEntry]):
22
+ def export_humanized_to_console(entries: list[MACAllocationEntry]) -> None:
24
23
  for entry in entries:
25
24
  mac = MACFormatter.format_default(entry.assignment)
26
- try:
25
+ with contextlib.suppress(AttributeError):
27
26
  print(f"{entry.registry}: {mac} {entry.organization_name}")
28
- except AttributeError():
29
- # Lookup not found.
30
- pass
@@ -1,6 +1,6 @@
1
1
  from enum import StrEnum
2
2
  from string import punctuation
3
- from typing import Literal
3
+ from typing import ClassVar, Literal
4
4
 
5
5
  from etherlyzer.util.knobs import etherlyzer_knobs
6
6
 
@@ -21,7 +21,7 @@ class MacMaskLetter(StrEnum):
21
21
  class MACFormatter:
22
22
  HEX_DIGITS = frozenset("0123456789ABCDEFabcdef")
23
23
  VALID_SEPERATORS = frozenset(" -.:")
24
- STRICT_TYPOS: dict[str, str] = {" ": "", "\t": ""}
24
+ STRICT_TYPOS: ClassVar[dict[str, str]] = {" ": "", "\t": ""}
25
25
  RELAXED_TYPOS: dict[str, str] = { # noqa: RUF012
26
26
  **STRICT_TYPOS,
27
27
  "o": "0",
@@ -48,7 +48,7 @@ class MACFormatter:
48
48
  for i in range(0, len(mac), etherlyzer_knobs.mac_block_size)
49
49
  )
50
50
 
51
- return getattr(mac, etherlyzer_knobs.mac_case.value)()
51
+ return str(getattr(mac, etherlyzer_knobs.mac_case.value)())
52
52
 
53
53
  @classmethod
54
54
  def format_with_stuffed_hex(cls, mac: str, stuffed_hex: str) -> str:
@@ -79,10 +79,10 @@ class MACFormatter:
79
79
  valid_letter_count = 0
80
80
  typo_count = 0
81
81
 
82
- def valid_norm_mac_check():
82
+ def valid_norm_mac_check() -> bool:
83
83
  return valid_letter_count + typo_count < 12
84
84
 
85
- for idx, ch in enumerate(in_addr):
85
+ for _, ch in enumerate(in_addr):
86
86
  if ch in cls.HEX_DIGITS:
87
87
  if valid_norm_mac_check():
88
88
  normalized_mac += ch.lower()
@@ -122,7 +122,7 @@ class MACFormatter:
122
122
 
123
123
  @classmethod
124
124
  def mask_is_valid(cls, mask: str) -> bool:
125
- return len(mask) == 12 and all([ch == "v" for ch in mask])
125
+ return len(mask) == 12 and all([ch == "v" for ch in mask]) # noqa
126
126
 
127
127
  @classmethod
128
128
  def normalize(cls, mac: str) -> str:
@@ -1,6 +1,6 @@
1
1
  from dataclasses import dataclass
2
2
 
3
- from etherlyzer.ieee.ieee_registry import IEEEEntry
3
+ from etherlyzer.ieee.entry.mac import MACAllocationEntry
4
4
 
5
5
 
6
6
  @dataclass
@@ -9,15 +9,15 @@ class IEEEAllocation:
9
9
  total_addresses: int = 0
10
10
  total_blocks: int = 0
11
11
 
12
- def add_addresses(self, added: int):
12
+ def add_addresses(self, added: int) -> None:
13
13
  self.total_addresses += added
14
14
 
15
- def increment_blocks(self):
15
+ def increment_blocks(self) -> None:
16
16
  self.total_blocks += 1
17
17
 
18
18
 
19
19
  def get_vendor_total_addr_space(
20
- vendors_other_blocks: list[IEEEEntry],
20
+ vendors_other_blocks: list[MACAllocationEntry],
21
21
  ) -> tuple[int, int, IEEEAllocation, IEEEAllocation, IEEEAllocation, IEEEAllocation]:
22
22
  mal = IEEEAllocation("MA-L")
23
23
  mam = IEEEAllocation("MA-M")
@@ -28,15 +28,13 @@ class MACClassification:
28
28
  is_broadcast: bool
29
29
  is_zero: bool
30
30
  slap_quadrant: SLAPQuadrant | None
31
- normalized: str
32
- normalized_pad0: str
33
31
 
34
32
 
35
33
  def classify_mac(mac: str) -> MACClassification:
36
34
  normalized = MACFormatter.normalize(mac)
37
35
 
38
36
  if not normalized or len(normalized) > 12 or len(normalized) < 6:
39
- raise ValueError("Expected a full or partial MAC address of 6–12 hexadecimal digits")
37
+ raise ValueError("Expected a full or partial MAC address of 6-12 hexadecimal digits")
40
38
 
41
39
  normalized_padded = normalized.ljust(12, "0")
42
40
  mac_int = int(normalized_padded, 16)
@@ -62,6 +60,4 @@ def classify_mac(mac: str) -> MACClassification:
62
60
  is_broadcast=mac_int == 0xFFFFFFFFFFFF and len(normalized) == 12,
63
61
  is_zero=mac_int == 0 and len(normalized) == 12,
64
62
  slap_quadrant=quadrant,
65
- normalized=normalized,
66
- normalized_pad0=normalized_padded,
67
63
  )
@@ -0,0 +1,14 @@
1
+ from dataclasses import astuple, dataclass, fields
2
+
3
+
4
+ @dataclass(frozen=True, slots=True)
5
+ class BaseEntry:
6
+ @classmethod
7
+ def get_header(cls) -> list[str]:
8
+ return [f.name for f in fields(cls)]
9
+
10
+ def get_row(self) -> tuple[str, ...]:
11
+ return astuple(self)
12
+
13
+ def __hash__(self) -> int:
14
+ return hash(astuple(self))
@@ -0,0 +1,8 @@
1
+ from dataclasses import dataclass
2
+
3
+ from etherlyzer.ieee.entry.mac import MACAllocationEntry
4
+
5
+
6
+ @dataclass(frozen=True, slots=True)
7
+ class EtherTypeEntry(MACAllocationEntry):
8
+ protocol: str
@@ -0,0 +1,30 @@
1
+ import re
2
+ from dataclasses import dataclass
3
+
4
+ from etherlyzer.ieee.entry.base import BaseEntry
5
+
6
+
7
+ @dataclass(frozen=True, slots=True)
8
+ class MACAllocationEntry(BaseEntry):
9
+ registry: str
10
+ assignment: str
11
+ organization_name: str
12
+ organization_address: str
13
+
14
+ def registry_id(self) -> str:
15
+ """Instead of MA-L, MA-M, then MAL, MAM, IAB"""
16
+ return self.registry.replace("-", "")[2:]
17
+
18
+ def short_name(self) -> str:
19
+ """Get the proper organization name by removing identifiers such as Co, Ltd."""
20
+ return re.sub(r"(,.*|Co.*)$", "", self.organization_name).strip()
21
+
22
+ def format_vendor_address(self) -> list[str]:
23
+ """Format the vendors registered compnay address"""
24
+ addr_representation = []
25
+ for addr_outer in self.organization_address.split(","):
26
+ addr = addr_outer.split(" ")
27
+ for line in addr:
28
+ if line:
29
+ addr_representation.append(line.strip())
30
+ return addr_representation
@@ -0,0 +1,41 @@
1
+ import datetime
2
+ from pathlib import Path
3
+
4
+ from etherlyzer.util.dirs import DATA_PLATFORM_DIR
5
+ from etherlyzer.util.knobs import etherlyzer_knobs
6
+
7
+
8
+ class RegistryCache:
9
+ def __init__(self, name: str):
10
+ self.name = name
11
+ # Check that filepath exists
12
+ # Get file mod ts if, else set to 0.0 (epoch zero)
13
+ # Modify stateful variable that is used later to ensure a (recent) copy exists.
14
+ f_mod_ts = self.filepath.stat().st_mtime if self.filepath.exists() else 0.0
15
+ self.last_retrieved = datetime.datetime.fromtimestamp(
16
+ f_mod_ts,
17
+ tz=datetime.UTC,
18
+ )
19
+ self.update_interval: datetime.timedelta = datetime.timedelta(
20
+ hours=etherlyzer_knobs.db_update_interval_hours
21
+ )
22
+
23
+ @property
24
+ def filepath(self) -> Path:
25
+ return DATA_PLATFORM_DIR / Path("".join([self.name, ".csv"]))
26
+
27
+ def need_updates(self, inform_if_synced_about_expiration: bool = False) -> bool:
28
+ expires = self.last_retrieved + self.update_interval
29
+ expires_humanized = expires.replace(microsecond=0)
30
+ now = datetime.datetime.now(datetime.UTC)
31
+ f_not_exists = not self.filepath.exists()
32
+
33
+ if f_not_exists and etherlyzer_knobs.show_sync_messages:
34
+ print(f"Cache for {self.name} not found.")
35
+ elif expires <= now and etherlyzer_knobs.show_sync_messages:
36
+ print(f"Cache for {self.name} has expired.")
37
+ elif etherlyzer_knobs.show_sync_messages and inform_if_synced_about_expiration:
38
+ namelen = len("EtherType") - len(self.name)
39
+ print(f"Cache for {self.name} expires at: {' ' * namelen} {expires_humanized} UTC")
40
+
41
+ return f_not_exists or expires <= now