Const-Vendor Pairing¶
Every module under pcapkit.const is generated by a matching crawler
under pcapkit.vendor, with no exception. A registry copied from an IANA,
IETF or similar web-published table is never hand-maintained – the crawler
re-scrapes the source and regenerates the module, so a hand edit to the generated
file is silently discarded on the next run. Ruled on #2495, which points a
hand-maintained registry at the DATA attribute below.
The DATA Attribute, for a Registry With No Web Source¶
A source that is not a web-crawlable table does not excuse a module from this
pairing – it changes what the crawler fetches. Vendor
reads its registry two ways: _request() either
GETs LINK, or, when a subclass overrides
request() to take no arguments, returns a
module-level DATA literal instead and never touches the network.
pcapkit.vendor.ipx.packet and pcapkit.vendor.ipx.socket are the
precedent: both read a hand-transcribed DATA dict because their source,
Novell’s and Xerox’s own IPX socket/packet-type tables, went offline (#507,
#518).
ARPHRD follows this pattern: its source is the
Linux kernel header <linux/if_arp.h>, C source under the kernel’s own versioning
rather than an IANA page, so pcapkit.vendor.linux.arphrd reads a DATA dict
of {code: (name, description)} transcribed from the header. The crawler’s
process() renders that dict into the members, the
FLAG bound and the _missing_ body the committed pcapkit.const.linux.arphrd
carries, so running it is a no-op against the tree, as a web-scraped crawler’s run is.
The explanatory prose – which values are listed and why, the cross-reference to
Hardware – lives in the crawler’s module
docstring and comments, beside the DATA literal it documents; the generated
const module carries only the templated docstring every generated module does.
Where the primary source is paywalled, a pinned secondary revision is an acceptable
DATA source once its values are cross-checked against independent implementations,
ruled in review of #2607 (#2575). pcapkit.vendor.ipx is the earlier
example, and the pcapkit.vendor.ieee802_11 crawlers check theirs against the
Linux kernel’s header and Wireshark.
LINK-and-Scrape Pairing: TLS Content Types and HandshakeType¶
ContentType and
HandshakeType have matching crawlers,
pcapkit.vendor.tls.content_type and pcapkit.vendor.tls.handshake_type,
exported as TLS_ContentType and TLS_HandshakeType (#2495). Both take
the normal LINK-and-scrape shape against IANA’s tls-parameters-5.csv and
tls-parameters-7.csv: unlike ARPHRD’s, TLS’s source is a live, web-published
table, so neither reads a DATA literal. Running either reproduces its committed
const module byte-for-byte. As for ARPHRD, the protocol-specific prose – the
record-layer header citations, the Unassigned/Reserved band rationale, the
_RESERVED-suffix handling – lives in the crawlers’ module docstrings and
comments.
Lazy Package Imports¶
A pcapkit.const package imports its enumerations on first use, not with
itself. Ruled by the owner in session and recorded on #2729. Its
__init__.py names each export in an import under if TYPE_CHECKING:, for
the type checkers, and binds the __getattr__ and __dir__ that
lazy_exports() returns; pcapkit.const re-exports
its subpackages’ __all__ the same way. The one real import is of
AppType and
TransportProtocol, which
pcapkit.const.reg.apptype builds
AppType.__registries__
on. A crawler writes the enumeration module and never a package’s
__init__.py, so regenerating keeps the laziness, and a module a crawler adds
takes its export there by hand, in both places.
tests/const/test_const_lazy_exports_2729_unit.py fails on an export imported
outside TYPE_CHECKING, or one that does not resolve to what its import names, and
tests/const/test_const_apptype_lazy_1538_unit.py on a package that loads an
enumeration with itself.