You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(protocols): __index__ returns the protocol's LinkType, EtherType, TransType or AppType value where one exists #2627
Owner ruling, given in session and paraphrased: a protocol's __index__ returns its LinkType, EtherType, TransType or AppType value wherever one exists, ahead of any other registry's code, such as ARPHRD or NLPID.
Today the classes are inconsistent. Radiotap.__index__ returns ARPHRD.IEEE80211_RADIOTAP (803), although LinkType.IEEE802_11_RADIOTAP (127) exists, while #2608 makes IEEE802_11.__index__ return LinkType.IEEE802_11 (105).
Plan:
Audit every protocol's __index__: what it returns or raises, which standard registry value exists for it, and which code relies on it.
Switch each one to the standard value where one exists. Any registration that keyed a secondary registry, such as LinuxSLL's ARPHRD map, by __index__ names its key explicitly instead.
The __index__ migration is done locally (352f6894c) and passed a Sonnet review. These now return their standard value:
Class
Value
Radiotap
LinkType.IEEE802_11_RADIOTAP (127)
FRAD
LinkType.FRELAY (107)
Netlink
LinkType.NETLINK (253)
GRE
TransType.GRE (47)
L2TPv2
UDP.l2tp
FTP / FTP_DATA
TCP.ftp / TCP.ftp_data
HTTP
TCP.http
NGAP
SCTP.ng_control
All 1,367 dispatch maps dump identically, every capture parses identically, and the rule is written onto registry-protocol.rst.
Being fixed now: an AppType member is a StrEnum, so returning it from __index__ makes int(FTP(...)) raise TypeError: __index__ returned non-int. AppType-valued classes will return the member's port number as an int.
Needs deciding. The branch proceeds on these recommendations unless you choose otherwise.
TLS and DTLS still raise, although TCP 443 and UDP 5684 bind them. Should they return TCP.https and UDP.coaps, the port they are dispatched under, as HTTP returns TCP.http? Recommend yes.
Netlink → LinkType.NETLINK (253). A LINKTYPE_NETLINK record opens with an SLL-style header that Netlink itself does not parse. (a) Keep 253 per the rule. (b) Keep ARPHRD.NETLINK, because 253 names the SLL-framed form rather than this class. Recommend (b).
Bindings. FRAD (107), Netlink (253) and GRE (IP protocol 47) now name values that no table dispatches on. A reachability test lists them as unbound. Binding them changes parse output from Raw to the dissector, so I recommend a follow-up issue, not this PR.
Label. Seven shipped classes go from raising to returning a value: L2TPv2, FTP, FTP_DATA, HTTP, HTTPv1, HTTPv2 and NGAP. No shipped value changes. Recommend not labelling it breaking.
No breaking label: the seven shipped classes go from raising to returning a value, and no shipped value changes.
This settles every open question, so needs: decision comes off. The branch (3a9f9047e, with the AppType values returning int) is being updated for 1 and 2. A cross-review follows before the PR opens.
The decision watch missed this answer for about two and a half hours. It arrived seconds before one of my posts, and I moved the watch's marker past it. The marker logic is fixed.
Activity
JarryShaw commentedon Nov 2, 2026
The
__index__migration is done locally (352f6894c) and passed a Sonnet review. These now return their standard value:LinkType.IEEE802_11_RADIOTAP(127)LinkType.FRELAY(107)LinkType.NETLINK(253)TransType.GRE(47)UDP.l2tpTCP.ftp/TCP.ftp_dataTCP.httpSCTP.ng_controlAll 1,367 dispatch maps dump identically, every capture parses identically, and the rule is written onto registry-protocol.rst.
Being fixed now: an
AppTypemember is aStrEnum, so returning it from__index__makesint(FTP(...))raiseTypeError: __index__ returned non-int. AppType-valued classes will return the member's port number as an int.Needs deciding. The branch proceeds on these recommendations unless you choose otherwise.
TCP.httpsandUDP.coaps, the port they are dispatched under, as HTTP returnsTCP.http? Recommend yes.LinkType.NETLINK(253). A LINKTYPE_NETLINK record opens with an SLL-style header thatNetlinkitself does not parse. (a) Keep 253 per the rule. (b) KeepARPHRD.NETLINK, because 253 names the SLL-framed form rather than this class. Recommend (b).Rawto the dissector, so I recommend a follow-up issue, not this PR.breaking.JarryShaw commentedon Nov 2, 2026
JarryShaw commentedon Nov 2, 2026
The owner answered all four, paraphrased:
TCP.https(443) andUDP.coaps(5684), as anint, as HTTP returnsTCP.http.ARPHRD.NETLINK, because LINKTYPE_NETLINK (253) names the SLL-framed form, not this class.breakinglabel: the seven shipped classes go from raising to returning a value, and no shipped value changes.This settles every open question, so
needs: decisioncomes off. The branch (3a9f9047e, with the AppType values returningint) is being updated for 1 and 2. A cross-review follows before the PR opens.The decision watch missed this answer for about two and a half hours. It arrived seconds before one of my posts, and I moved the watch's marker past it. The marker logic is fixed.
JarryShaw commentedon Nov 2, 2026
The PR is #2652.
refactor(protocols): index each protocol by its LinkType, EtherType, …
refactor(protocols): index each protocol by its LinkType, EtherType, …