Skip to content

const: generalise register_alias from AppType to every pcapkit.const enum #842

Description

@JarryShaw

Split out of #838 at the maintainer's direction. His framing, verbatim:

register_alias is an API on each Enum, and it only touches the concrete Enum
class it serves; AppType is the exception where it must goes to the underlying
transport protocol registry Enum class.

In this case, ETH will become an alias to IANA's default ETHERNET name and is
only register_alias'ed when PyShark being used. We might also check other PDML
attributes to extend other Wireshark's display-filter names as well.

Today it is bespoke to one registry. register_alias exists only on
AppType (pcapkit/const/reg/apptype/apptype.py, from #807). Its docstring scopes
itself deliberately to the per-transport port registry: TCP.register_alias(...) must
never touch UDP, so an alias registered on one transport cannot leak onto a transport
IANA never assigned it. It mints through extend_enum, which is the caller-named path
#775 deliberately preserves.

The design questions this has to answer:

  1. What does "this registry alone" mean for an enum that is not per-transport? On
    AppType the boundary is the transport class; elsewhere there is no analogue, so
    the generalised contract needs stating rather than inheriting.
  2. Does a generalised register_alias belong in the shared template
    (pcapkit/vendor/default.py), giving all 105 generated registries the method, or
    only where a caller needs it? The shared template reaches 26 registries directly;
    the other 79 carry their own process() or template — see Registries mint a permanent member for every unrecognised value: 1,169 extend_enum sites across 113 registries #775's census.
  3. AppType's override routes to the underlying transport registry. What is the hook
    that lets one registry opt into different routing without the template knowing
    about it?
  4. Lazy registration: ETH should only exist while pyshark is in use. What registers
    it, when, and does anything unregister it — a process-wide alias that outlives the
    engine that wanted it is the same class of surprise Registries mint a permanent member for every unrecognised value: 1,169 extend_enum sites across 113 registries #775 removed.
  5. Which other Wireshark display-filter names are worth aliasing, and from which PDML
    attribute are they read? pyshark/packet/layers/xml_layer.py takes the layer name
    from <proto name=…>; the maintainer suggests other attributes may carry more.

Not blocking #838, which carries a trivial local fix for the eth case per the
same ruling.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    designA design or decision issue: a pattern being decided rather than a defect or a requestenhancementIssues requesting a new capability (set by the feature request template)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions