Skip to content

Commit 261fd46

Browse files
committed
fix(const): answer unassigned on the registry's transport where IANA lists nothing (#2048)
Per the owner's ruling on #2052, every port in 0-65535 is `unassigned` on a transport, carrying that transport, unless IANA lists an entry for it there. IANA assigned 8011 on TCP and UDP only, so DCCP and SCTP had read `unknown`; they now read `unassigned [dccp]` / `[sctp]`. - AppType.get (template and generated module, identically): the fallback for a port `_missing_` holds no span for answers `unassigned` with the registry's own transport instead of `unknown`. Still unregistered (#860); out-of-range ports still raise. - AppType._missing_: spans naming no transport answer with `cls.__transport__` instead of `TransportProtocol.undefined`; spans naming a transport (#760) are unchanged. The generated module renders byte-identically from the template and the current IANA CSV. - PortEnumField.post_process: its miss member reads `unassigned` too. - Tests pinning `unknown` or `undefined` for AppType holes and spans move to `unassigned [<registry>]`; new rule and template-agreement tests. - Changelog entry; CHANGELOG.md regenerated.
1 parent c98541f commit 261fd46

14 files changed

Lines changed: 1091 additions & 845 deletions

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Preceded by `1.5.0a1` (2026-09-15), `1.5.0b1` to `1.5.0b3` (all 2026-09-19) and
3535
- **a breaking change to** more const registries' `_missing_`: applies the owner's mint/unmint ruling (settled on [#847](https://github.com/JarryShaw/PyPCAPKit/pull/847), confirmed on [#775](https://github.com/JarryShaw/PyPCAPKit/issues/775): a final, concrete assigned name mints, and a notation for readers does not) across the `_missing_` files still calling `extend_enum`. Most convert wholly, each minting a bare status word (`Unassigned`, `Reserved [...]`, `Reserved for Private/Experimental Use`, `Unspecified in the IANA registry`, `Deprecated`), which the ruling treats as a notation rather than an assignment. Some are mixed: `EtherType`'s `DEC Unassigned` and "Old Xerox Experimental values. Invalid as an Ethertype since 1983." branches convert, while vendor-company names (Xyplex, Motorola, Walker Richer & Quinn and others) keep minting, since a proprietary protocol has no public name beyond the company's; `IEEE802_3_Length_Field` and `Berkeley_Trailer_encap_IP` also keep minting but are not company names. `Socket` (ipx)'s allocation-policy names (`Experimental`, `Dynamically Assigned Socket Numbers`, `Statically Assigned Socket Numbers`, `Dynamically Assigned`) convert, while `Registered by Xerox` keeps minting, a real ownership fact. Left alone are `CGAType`, whose `Tag_<hex>` mint is not an IANA-style range, and the files holding the classes [#860](https://github.com/JarryShaw/PyPCAPKit/issues/860) moves onto `EnumRegistry` (the `AppType`, `StatusCode`, `ftp.return_code`, `ftp.command`, `Method` and `OptionType` modules; [#869](https://github.com/JarryShaw/PyPCAPKit/pull/869) and [#874](https://github.com/JarryShaw/PyPCAPKit/pull/874), below). Each conversion changes both the vendor crawler and the generated file, per [#838](https://github.com/JarryShaw/PyPCAPKit/pull/838)'s and [#858](https://github.com/JarryShaw/PyPCAPKit/pull/858)'s precedent. The worked examples in `docs/source/contributing/conventions/mint-criterion.rst` keep `Registered by Xerox` under Mint ([#861](https://github.com/JarryShaw/PyPCAPKit/pull/861)).
3636
- **a breaking change to** `EtherType`'s `_missing_` ordering: values `0x0101`-`0x01FF` now resolve to their Old Xerox Experimental name instead of an `IEEE802_3_Length_Field_0x0101`-style one. The generated method tested `0x0000 <= value <= 0x05DC` (IEEE802.3 Length Field) first, and the Old Xerox range sits wholly inside it, so that branch was unreachable. Unlike [#841](https://github.com/JarryShaw/PyPCAPKit/issues/841)'s IPX fix, these bounds come from the live IANA CSV, so the fix is general: `pcapkit/vendor/reg/ethertype.py`'s `process()` collects range rows and a new `EtherType._insert_range` places each ahead of the first already-placed range that fully contains it, leaving non-overlapping pairs in CSV order; this pair is the only containment among the CSV's ranges. Closes [#862](https://github.com/JarryShaw/PyPCAPKit/issues/862) ([#865](https://github.com/JarryShaw/PyPCAPKit/pull/865)).
3737
- **a breaking change to** `Method`: `__new__` called `str.__new__(cls)` with no argument, so every registered member's `str` payload was empty regardless of value -- `str(Method.GET) == ''` and `Method.GET == 'GET'` was `False`; `.value` was always correct. [#869](https://github.com/JarryShaw/PyPCAPKit/pull/869) (above) had fixed the *unregistered* path only, leaving `str(Method('frob')) == 'frob'` beside `str(Method.GET) == ''`. Fixed to `str.__new__(cls, value)`, mirroring `Command.__new__`, in the generator (`pcapkit/vendor/http/method.py`) and the generated module. No sibling hand-rolled `__new__` has the defect (`OptionType`/`AppType` deliberately store a display string). Consequences, all corrections: `Method.GET == 'GET'` is `True`; `bool(Method.GET)` flips `False` to `True`; `json.dumps(Method.GET)` emits `"GET"` not `""`; `sorted()` is lexicographic rather than input-order-stable; and `{m: ... for m in Method}` gains an entry per member where it had one, because every member previously hashed as `''` and compared equal. Nothing under `pcapkit/protocols` relied on the old behaviour. Closes [#870](https://github.com/JarryShaw/PyPCAPKit/issues/870) ([#871](https://github.com/JarryShaw/PyPCAPKit/pull/871)).
38-
- **a breaking change to** `TransportProtocol` and `AppType`: step 2 of [#860](https://github.com/JarryShaw/PyPCAPKit/issues/860), the `AppType` half (the other bespoke registries were [#869](https://github.com/JarryShaw/PyPCAPKit/pull/869), above). `AppType` and its transport subclasses move onto `EnumRegistry` and both mint sites -- `_missing_`'s range branches and `get()`'s own mint (`PORT_{port}_{transport}` -> `'unknown'`) -- now build through a new `_unregistered_member` override that reconstructs `svc`/`port`/`proto`, per the owner's ruling that only IANA-registered values are legitimate and that `get()` lacks the information to create new ones. Every branch converts, including those naming a real service assigned to a whole port span (`x11`, `active-net`, `satvid-datalnk`, `vrml-multi-use`, `ircu`, `swx`, `flex-lm`); unlike `FEATCode`'s fix ([#869](https://github.com/JarryShaw/PyPCAPKit/pull/869), above) there is no import-time self-mutation to cure by declaring members statically, so these stay deliberately unregistered lookups. `AppType` gains a working `register()`; the base's would have built a member with `svc='<null>'`. **The breaking part**: `TransportProtocol` moves from power-of-two values (`tcp=1, udp=2, sctp=4, dccp=8`) to sequential `auto()` (`sctp=3, dccp=4`), per the owner's follow-up ruling once `|`-joined composites stopped being parsed. `AppType.get()` treats whatever `int` it is given as a whole, so the renumbering changes what specific integers *mean*: on `AppType.get(80, proto=...)`, a bare `4` resolved to `SCTP.http` on `main` and now **silently** resolves to `DCCP.unknown`, because a real member sits at `4` under both numberings; a bare `8` used to mint `DCCP.PORT_80_dccp` and now raises `ValueError`. The composed-value case is deliberately untested, per the owner's ruling that a breaking change already retired that path ([#874](https://github.com/JarryShaw/PyPCAPKit/pull/874)).
38+
- **a breaking change to** `TransportProtocol` and `AppType`: step 2 of [#860](https://github.com/JarryShaw/PyPCAPKit/issues/860), the `AppType` half (the other bespoke registries were [#869](https://github.com/JarryShaw/PyPCAPKit/pull/869), above). `AppType` and its transport subclasses move onto `EnumRegistry` and both mint sites -- `_missing_`'s range branches and `get()`'s own mint (`PORT_{port}_{transport}` -> `'unknown'`, `'unassigned'` since [#2048](https://github.com/JarryShaw/PyPCAPKit/issues/2048), below) -- now build through a new `_unregistered_member` override that reconstructs `svc`/`port`/`proto`, per the owner's ruling that only IANA-registered values are legitimate and that `get()` lacks the information to create new ones. Every branch converts, including those naming a real service assigned to a whole port span (`x11`, `active-net`, `satvid-datalnk`, `vrml-multi-use`, `ircu`, `swx`, `flex-lm`); unlike `FEATCode`'s fix ([#869](https://github.com/JarryShaw/PyPCAPKit/pull/869), above) there is no import-time self-mutation to cure by declaring members statically, so these stay deliberately unregistered lookups. `AppType` gains a working `register()`; the base's would have built a member with `svc='<null>'`. **The breaking part**: `TransportProtocol` moves from power-of-two values (`tcp=1, udp=2, sctp=4, dccp=8`) to sequential `auto()` (`sctp=3, dccp=4`), per the owner's follow-up ruling once `|`-joined composites stopped being parsed. `AppType.get()` treats whatever `int` it is given as a whole, so the renumbering changes what specific integers *mean*: on `AppType.get(80, proto=...)`, a bare `4` resolved to `SCTP.http` on `main` and now **silently** resolves to `DCCP.unassigned`, because a real member sits at `4` under both numberings; a bare `8` used to mint `DCCP.PORT_80_dccp` and now raises `ValueError`. The composed-value case is deliberately untested, per the owner's ruling that a breaking change already retired that path ([#874](https://github.com/JarryShaw/PyPCAPKit/pull/874)).
3939
- closes the remaining scope of [#775](https://github.com/JarryShaw/PyPCAPKit/issues/775): `EtherType` and `Socket`, the last registries whose `_missing_` minted a permanent member, now return a non-registering `cls._unregistered_member(value, name)`. The issue's AST census of `extend_enum` in `_missing_`/`get` is down to the single `CGAType` carve-out (its mint is not an IANA-style range). `EtherType(0x0888)` used to add a member to `__members__` and return the identical object on a repeat; it now returns `<EtherType.Xyplex_0x0888: 2184>` with `__members__` unchanged, absent from `_value2member_map_`, equal but not identical across lookups -- likewise `Socket(0x0010)`. The regenerated `EtherType` was not checked against the live IANA CSV, only against the committed fixture. Keeping each branch's hex-suffixed name reintroduces the value-derived shape `test_const_enum_no_mint.py`'s `is_manufactured()` sweep forbids; rather than weaken the predicate, a narrow exemption covers exactly these files, since the collision the check guards against cannot occur once `_unregistered_member` never registers ([#878](https://github.com/JarryShaw/PyPCAPKit/pull/878)).
4040
- `OptionType.register()` and `Command.register()` built members that `get()` could not find again, and `OptionType.register_alias()` raised `not a registered OptionType` for every argument. Both registries now round-trip through `get()`, in the generated files and the vendor templates ([#1311](https://github.com/JarryShaw/PyPCAPKit/pull/1311), [#1330](https://github.com/JarryShaw/PyPCAPKit/issues/1330), [#1369](https://github.com/JarryShaw/PyPCAPKit/pull/1369)).
4141
- the Quick-Start function registries rejected 9 to 15, though [RFC 4782](https://datatracker.ietf.org/doc/html/rfc4782) gives the Function field four bits; the whole 4-bit range now resolves ([#1350](https://github.com/JarryShaw/PyPCAPKit/issues/1350), [#1353](https://github.com/JarryShaw/PyPCAPKit/pull/1353)).
@@ -45,6 +45,7 @@ Preceded by `1.5.0a1` (2026-09-15), `1.5.0b1` to `1.5.0b3` (all 2026-09-19) and
4545
- `FEATCode.get()` matches case-insensitively, as [RFC 5797 Section 2](https://datatracker.ietf.org/doc/html/rfc5797#section-2) defines FEAT codes; the registry-wide case-sensitivity audit found no other registry that needed to fold ([#903](https://github.com/JarryShaw/PyPCAPKit/issues/903), [#913](https://github.com/JarryShaw/PyPCAPKit/pull/913)).
4646
- `register` refuses what `get` refuses. `TCP.register(70000, 'x')` and `Hardware.register(70000, 'x')` minted a member that `get` then returned, because no registry overrode the `_validate_value` hook `register` calls. Each generated registry, `AppType` included, now overrides it with the check its `_missing_` makes, raising `EnumValueError`. `get(value, default)` on a value the hook refuses still returns `default` and logs nothing ([#1792](https://github.com/JarryShaw/PyPCAPKit/issues/1792), [#1818](https://github.com/JarryShaw/PyPCAPKit/pull/1818), [#1816](https://github.com/JarryShaw/PyPCAPKit/issues/1816), [#1823](https://github.com/JarryShaw/PyPCAPKit/pull/1823); the quiet miss is [#1845](https://github.com/JarryShaw/PyPCAPKit/issues/1845), [#1873](https://github.com/JarryShaw/PyPCAPKit/pull/1873), under `pcapkit.corekit`).
4747
- `Command.get()` refuses a key that is not a `str` with `EnumValueError`, as `Method.get()` does. `get(b'\x01')` minted a member keyed by `bytes`, and `get(-1)` raised `AttributeError` whatever its `default` ([#1824](https://github.com/JarryShaw/PyPCAPKit/issues/1824), [#1826](https://github.com/JarryShaw/PyPCAPKit/pull/1826)).
48+
- a port an `AppType` registry has no IANA entry for answers `unassigned` with that registry's transport, from `AppType.get()` and from `PortEnumField` parsing, rather than `unknown`; an entry for that transport overrides it. So once IANA assigned 8011 on TCP and UDP only, `DCCP.get(8011)` reads `unassigned [dccp]` rather than `unknown`, and `TCP.get(8011)` still reads `reserved [tcp]`. IANA's spans that name no transport also answer with the asking registry's transport rather than `TransportProtocol.undefined`: `TCP.get(8012)` is `unassigned [tcp]`. Lookups still mint nothing ([#860](https://github.com/JarryShaw/PyPCAPKit/issues/860)) and an out-of-range port still raises ([#2048](https://github.com/JarryShaw/PyPCAPKit/issues/2048), [#2052](https://github.com/JarryShaw/PyPCAPKit/pull/2052)).
4849

4950
### pcapkit.corekit
5051

‎docs/source/changelog/1.5.0.rst‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ Fixed
297297
were :pr:`869`, above). :class:`~pcapkit.const.reg.apptype.apptype.AppType` and its
298298
transport subclasses move onto :class:`.EnumRegistry` and both mint sites --
299299
``_missing_``'s range branches and ``get()``'s own mint (``PORT_{port}_{transport}``
300-
-> ``'unknown'``) -- now build through a new ``_unregistered_member`` override that
300+
-> ``'unknown'``, ``'unassigned'`` since :issue:`2048`, below) -- now build through a
301+
new ``_unregistered_member`` override that
301302
reconstructs ``svc``/``port``/``proto``, per the owner's ruling that only
302303
IANA-registered values are legitimate and that ``get()`` lacks the information to
303304
create new ones. Every branch converts, including those naming a real service assigned
@@ -313,7 +314,7 @@ Fixed
313314
:meth:`.AppType.get` treats whatever ``int`` it is given as a whole, so the
314315
renumbering changes what specific integers *mean*: on ``AppType.get(80, proto=...)``,
315316
a bare ``4`` resolved to :attr:`.SCTP.http` on ``main`` and now **silently** resolves
316-
to ``DCCP.unknown``, because a real member sits at ``4`` under both numberings; a bare
317+
to ``DCCP.unassigned``, because a real member sits at ``4`` under both numberings; a bare
317318
``8`` used to mint ``DCCP.PORT_80_dccp`` and now raises ``ValueError``. The
318319
composed-value case is deliberately untested, per the owner's ruling that a breaking
319320
change already retired that path (:pr:`874`).
@@ -367,6 +368,16 @@ Fixed
367368
as :meth:`.Method.get` does. ``get(b'\x01')`` minted a member keyed by ``bytes``, and
368369
``get(-1)`` raised ``AttributeError`` whatever its ``default`` (:issue:`1824`,
369370
:pr:`1826`).
371+
* a port an :class:`~pcapkit.const.reg.apptype.apptype.AppType` registry has no IANA
372+
entry for answers ``unassigned`` with that registry's transport, from
373+
:meth:`.AppType.get` and from :class:`.PortEnumField` parsing, rather than
374+
``unknown``; an entry for that transport overrides it. So once IANA assigned 8011
375+
on TCP and UDP only, ``DCCP.get(8011)`` reads ``unassigned [dccp]`` rather than
376+
``unknown``, and ``TCP.get(8011)`` still reads ``reserved [tcp]``. IANA's spans that
377+
name no transport also answer with the asking registry's transport rather than
378+
``TransportProtocol.undefined``: ``TCP.get(8012)`` is ``unassigned [tcp]``. Lookups
379+
still mint nothing (:issue:`860`) and an out-of-range port still raises
380+
(:issue:`2048`, :pr:`2052`).
370381

371382
pcapkit.corekit
372383
---------------

0 commit comments

Comments
 (0)