Skip to content

Commit 71e8624

Browse files
committed
docs(conventions): measure the family grouping page against main
- HTTP selector example replaced by VLAN: 'S_Tag' in a C-Tag frame. - ARP row: only RARP is bound to 0x8035; DRARP is its operation-5 alias. - Drop the unsourced inferences and the InARP construction claim. - State both canonical-name rulings with their sources (#2444, #2446). - Cite the _Family rule (#2446, 17:14Z); define registry key.
1 parent 80a11f9 commit 71e8624

1 file changed

Lines changed: 59 additions & 54 deletions

File tree

‎docs/source/contributing/conventions/protocol-family-grouping.rst‎

Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ Protocol Family Grouping
44
------------------------
55

66
A protocol family is a base class named after the family plus its member classes.
7-
What the base and each member return from
8-
:meth:`~pcapkit.protocols.protocol.Protocol.id` is what the selectors on
9-
:class:`~pcapkit.protocols.protocol.Protocol` match against, so the tuples are
10-
settled here rather than re-derived per family. Set on :pr:`2441`, :pr:`2443`,
11-
:pr:`2446` and :issue:`2462`.
7+
What each class returns from :meth:`~pcapkit.protocols.protocol.Protocol.id` is what
8+
the selectors on :class:`~pcapkit.protocols.protocol.Protocol` match against. The
9+
rulings were set on :pr:`2441`, :pr:`2443`, :pr:`2446` and :issue:`2462`.
1210

1311
The ``id()`` Criterion
1412
~~~~~~~~~~~~~~~~~~~~~~
@@ -37,29 +35,28 @@ The member list takes either of these forms:
3735
Abstract Family Names
3836
~~~~~~~~~~~~~~~~~~~~~
3937

40-
**An abstract family name composes its members.**
41-
:class:`~pcapkit.protocols.internet.ipv6_ext.IPv6_Ext` carries the family's name, so
42-
its ``id()`` is to list its direct concrete members, and each member narrows its own
43-
``id()`` to itself. :issue:`2462`.
38+
**An abstract family name composes its members.** The ruling on :issue:`2462` is that
39+
:class:`~pcapkit.protocols.internet.ipv6_ext.IPv6_Ext` lists its direct concrete
40+
members in its ``id()``, and that each member narrows its own ``id()`` to itself.
41+
On main, ``IPv6_Ext.id()`` is ``('IPv6_Ext',)`` alone.
4442

4543
Grouping by Name
4644
~~~~~~~~~~~~~~~~
4745

4846
**Members share a base because they share a name, not a wire format.** HTTP/1 and
4947
HTTP/2 share :class:`~pcapkit.protocols.application.http.HTTP`, IPv4 and IPv6 share
5048
:class:`~pcapkit.protocols.internet.ip.IP`, and AH and ESP share
51-
:class:`~pcapkit.protocols.internet.ipsec.IPsec`. A family base needs no dispatcher
52-
logic: :class:`~pcapkit.protocols.internet.ip.IP` and
53-
:class:`~pcapkit.protocols.internet.ipsec.IPsec` have none, and each member is bound
54-
directly. :pr:`2441`.
49+
:class:`~pcapkit.protocols.internet.ipsec.IPsec`. :pr:`2441`.
50+
51+
:class:`~pcapkit.protocols.internet.ip.IP` and
52+
:class:`~pcapkit.protocols.internet.ipsec.IPsec` define no ``read()``. The HTTP class
53+
does, and a parsed HTTP/1.1 or HTTP/2 layer is the HTTP class itself.
5554

5655
.. _protocol-family-shapes:
5756

5857
Member Shapes
5958
~~~~~~~~~~~~~
6059

61-
Pick a member's shape by how far a sibling's selector should reach.
62-
6360
.. list-table::
6461
:header-rows: 1
6562
:widths: 22 38 40
@@ -73,65 +70,76 @@ Pick a member's shape by how far a sibling's selector should reach.
7370
:class:`~pcapkit.protocols.internet.esp.ESP` ``('ESP',)``
7471
* - Family-inclusive
7572
- the member's label plus the family name
76-
- :class:`~pcapkit.protocols.link.c_tag.C_Tag` ``('C_Tag', 'VLAN')`` and
77-
:class:`~pcapkit.protocols.link.s_tag.S_Tag`;
73+
- :class:`~pcapkit.protocols.link.c_tag.C_Tag` ``('C_Tag', 'VLAN')``,
74+
:class:`~pcapkit.protocols.link.s_tag.S_Tag` ``('S_Tag', 'VLAN')``;
7875
:class:`HTTPv1 <pcapkit.protocols.application.httpv1.HTTP>`
7976
``('HTTP', 'HTTPv1')`` and
80-
:class:`HTTPv2 <pcapkit.protocols.application.httpv2.HTTP>`;
77+
:class:`HTTPv2 <pcapkit.protocols.application.httpv2.HTTP>`
78+
``('HTTP', 'HTTPv2')``;
8179
:class:`~pcapkit.protocols.link.l2tpv2.L2TPv2` ``('L2TP', 'L2TPv2')``
8280
* - One parser, dynamic alias
8381
- fixed, whichever protocol was read
8482
- :class:`~pcapkit.protocols.link.arp.ARP` ``('ARP',)`` reads the operation
85-
code and reports ARP, InARP, RARP or DRARP through
86-
:attr:`~pcapkit.protocols.protocol.Protocol.alias`;
87-
:class:`~pcapkit.protocols.link.arp.InARP` ``('InARP',)`` is a thin
88-
subclass that exists for explicit construction.
89-
:class:`~pcapkit.protocols.application.rarp.RARP` ``('RARP', 'DRARP')`` and
90-
:class:`~pcapkit.protocols.application.rarp.DRARP` ``('DRARP',)`` are
91-
separate classes, bound to EtherType ``0x8035``
92-
(:attr:`~pcapkit.const.reg.ethertype.EtherType.Reverse_Address_Resolution_Protocol`)
93-
94-
A family-inclusive member is selected by any sibling's registry key, because both
95-
expand to the shared family name (see :ref:`below <protocol-family-selectors>`). A
96-
narrow member is selected only by its own name and its family's key.
83+
code and reports ARP, RARP, DRARP or InARP through
84+
:attr:`~pcapkit.protocols.protocol.Protocol.alias`
85+
86+
Nothing dispatches to :class:`~pcapkit.protocols.link.arp.InARP` ``('InARP',)``:
87+
under EtherType ``0x0806``, operation 8 parses as ARP with alias ``InARP``.
88+
Only :class:`~pcapkit.protocols.application.rarp.RARP` ``('RARP', 'DRARP')`` is bound
89+
to EtherType ``0x8035``
90+
(:attr:`~pcapkit.const.reg.ethertype.EtherType.Reverse_Address_Resolution_Protocol`).
91+
A parsed RARP takes ``DRARP`` as its alias for operation 5, and
92+
:class:`~pcapkit.protocols.application.rarp.DRARP` ``('DRARP',)`` inherits the
93+
``__index__`` of RARP.
94+
95+
A family-inclusive member is selected by any sibling's registry key (a key of
96+
``pcapkit.protocols.__proto__``), because each expands to the shared family name
97+
(:ref:`below <protocol-family-selectors>`). A narrow member is selected only by its
98+
own name and its family's key.
9799

98100
.. _protocol-family-canonical-names:
99101

100102
Canonical Names
101103
~~~~~~~~~~~~~~~
102104

103-
**A class name may carry a version that the protocol's own name does not.** Where
104-
the defining RFC names the protocol without a version, a versioned class and module
105-
name may tell the members apart in code; ``id()`` is then expected to drop the
106-
version for the RFC's canonical name, and
107-
:attr:`~pcapkit.protocols.protocol.Protocol.name` to follow the RFC's title with no
108-
version string. :pr:`2446`.
105+
**A versioned protocol's display name includes its version.** :pr:`2444` (14:27Z).
106+
On main, :class:`~pcapkit.protocols.link.l2tpv2.L2TPv2`'s ``name`` is
107+
``Layer 2 Tunnelling Protocol version 2``. The HTTP/1.1 and HTTP/2 classes define no
108+
``name`` of their own, so they report ``Hypertext Transfer Protocol``, which carries
109+
no version.
110+
111+
**ICMPv4 is the case where the RFC's own name carries no version.** :pr:`2446`
112+
(19:13Z) rules that ``ICMPv4`` keeps its versioned class and module name, that its
113+
``id()`` drops the version, and that its ``name`` has no "version 4", following
114+
RFC 792. ICMP is not on main.
109115

110116
.. _protocol-family-selectors:
111117

112118
Selector Matching
113119
~~~~~~~~~~~~~~~~~
114120

115121
**A family name selects every version, and each version name selects its own.**
116-
:pr:`2443`. The narrow-to-self shape gives exactly that: ``'IP' in frame`` is
117-
``True`` for an IPv4 frame and an IPv6 frame alike, and ``'IPv6' in frame`` is
118-
``False`` for an IPv4 frame. Under the family-inclusive shape a version name also
119-
selects its siblings, as the second bullet below shows for HTTP.
122+
:pr:`2443`. On an IPv4 frame, ``'IP' in`` is ``True`` and ``'IPv6' in`` is ``False``.
123+
On an IPv6 frame, ``'IP' in`` is ``True`` and ``'IPv4' in`` is ``False``. Under the
124+
family-inclusive shape, a member's name also selects its siblings; the *in and []*
125+
bullet below gives the VLAN case.
120126

121127
What a selector on a frame or a layer reaches is defined by
122128
:meth:`~pcapkit.protocols.protocol.Protocol.expand_comp`,
123129
:meth:`~pcapkit.protocols.protocol.Protocol.__contains__`,
124130
:meth:`~pcapkit.protocols.protocol.Protocol.__getitem__` and ``Protocol.__eq__``.
125-
All comparisons are case-insensitive.
131+
Selectors are case-insensitive: ``'ipv4' in`` an IPv4 frame is ``True``.
126132

127-
* **String** ``==`` compares against the class and its own ``id()`` only; the
128-
selector is not expanded. On a parsed IPv4 layer, ``ipv4 == 'IPv4'`` is ``True``
129-
and ``ipv4 == 'IP'`` is ``False``.
133+
* **String** ``==`` compares against the class and its own ``id()`` only; the selector
134+
is not expanded. On a parsed IPv4 layer, ``ipv4 == 'IPv4'`` is ``True`` and
135+
``ipv4 == 'IP'`` is ``False``. On a parsed C-Tag layer, ``== 'VLAN'`` is ``True``,
136+
since ``VLAN`` is in its ``id()``, and ``== 'S_Tag'`` is ``False``, though
137+
``'S_Tag' in`` the layer is ``True``.
130138
* ``in`` **and** ``[]`` expand the selector first. A registry key becomes its class
131-
plus that class's ``id()``, as does a class object, and a layer matches when any
132-
of those appears among its own class and ``id()``. So ``'IP' in frame`` is
133-
``True`` for an IPv4 frame, and ``'HTTPv2' in frame`` is ``True`` for an HTTP/1.1
134-
frame, since both sides carry ``'HTTP'``.
139+
plus that class's ``id()``, as does a class object, and a layer matches when any of
140+
those appears among its own class and ``id()``. So ``'S_Tag' in`` a C-Tag frame is
141+
``True``: ``S_Tag`` expands to ``S_Tag`` and ``VLAN``, and the C-Tag layer's
142+
``id()`` carries ``VLAN``.
135143
* A string that is **not** a registry key is matched by name alone against each
136144
layer's class and ``id()``, so an alias such as ``'HTTP/1.1'`` selects no layer:
137145
``'HTTP/1.1' in frame`` is ``False``.
@@ -141,9 +149,6 @@ All comparisons are case-insensitive.
141149
:meth:`~pcapkit.corekit.protochain.ProtoChain.count` and ``in`` also compare each
142150
layer's alias, so ``'HTTP/1.1' in frame.protochain`` is ``True``.
143151

144-
So adding a name to an ``id()`` tuple widens every ``in`` and ``[]`` selector that
145-
can reach it; check the reach before choosing a shape.
146-
147152
No Invented Suffixes
148153
~~~~~~~~~~~~~~~~~~~~
149154

@@ -152,6 +157,6 @@ No Invented Suffixes
152157
:class:`~pcapkit.protocols.internet.ipsec.IPsec`,
153158
:class:`~pcapkit.protocols.application.http.HTTP`,
154159
:class:`~pcapkit.protocols.link.vlan.VLAN` and
155-
:class:`~pcapkit.protocols.link.l2tp.L2TP` are the precedent. No ``_Family`` base is
156-
to be minted. A member that shares the family's protocol name may take a versioned
157-
class name, as :ref:`above <protocol-family-canonical-names>`. :pr:`2446`.
160+
:class:`~pcapkit.protocols.link.l2tp.L2TP` are the precedent. No ``_Family`` suffix is
161+
added (:pr:`2446`, 17:14Z). A member may take a versioned class name, as
162+
:ref:`above <protocol-family-canonical-names>` describes.

0 commit comments

Comments
 (0)