Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions pcapkit/const/reg/apptype/apptype.py
Original file line number Diff line number Diff line change
Expand Up @@ -2263,7 +2263,8 @@ class AppType(StrEnum):
svc: 'str'
#: Port number.
port: 'int'
#: Transport protocol.
#: Transport protocol carrying the service, i.e. the single transport
#: protocol of the registry this member lives in.
proto: 'TransportProtocol'

#: Transport protocol whose assignments this registry holds. The base
Expand Down Expand Up @@ -2378,16 +2379,17 @@ def _dispatch(cls, key: 'int', proto: 'TransportProtocol | str') -> 'Type[AppTyp

if isinstance(proto, str):
proto = TransportProtocol.get(proto.lower())
# NOTE: ``TransportProtocol`` is an :class:`~aenum.IntFlag` and a member
# carries the *whole* transport protocol set IANA assigned the service, so
# ``tcp | udp`` is an ordinary value to read off one and therefore an
# ordinary thing to pass back in. It names two registries, though, holding
# two different services for the same port -- and a lookup answers with one
# member, so there is no answer to which of them the composite meant.
# Resolving it picked the lowest set bit: :func:`~enum.show_flag_values`
# iterates LSB-first and ``tcp`` is the lowest, so every composite
# containing it dispatched into the TCP registry whatever else it named.
# Measured on fe80b8525, that answered 46 of the 10,625 multi-transport
# NOTE: ``TransportProtocol`` is an :class:`~aenum.IntFlag`, so ``tcp |
# udp`` stays constructible by hand even though no member carries one any
# more -- every member's ``proto`` is the single transport of the registry
# it lives in, GitHub issue #806. A composite names two registries,
# though, holding two different services for the same port -- and a lookup
# answers with one member, so there is no answer to which of them the
# composite meant. Resolving it picked the lowest set bit:
# :func:`~enum.show_flag_values` iterates LSB-first and ``tcp`` is the
# lowest, so every composite containing it dispatched into the TCP
# registry whatever else it named. Measured on fe80b8525, when members
# still carried the whole set, that answered 46 of the 10,625 multi-transport
# members' own ``get(m.port, proto=m.proto)`` with a service other than the
# member's own, of which 23 -- the UDP-declared half -- came back as a
# member of the *TCP* registry, carrying the wrong type and a narrower
Expand Down Expand Up @@ -2432,9 +2434,9 @@ def get(cls, key: 'int', *,
members; ignored when called on one of those registries, each of
which already knows its own transport. **One** transport protocol
when it does select, since one registry is what a port lookup can
answer from -- a member's own ``proto`` is often a composite such
as ``tcp | udp`` and passing that back in is refused rather than
resolved to a guess.
answer from -- a member's own ``proto`` names exactly one, so
passing it straight back in always resolves, while a composite
built by hand is refused rather than resolved to a guess.

Returns:
The **canonical** service for ``key``. IANA assigns several services
Expand Down
31 changes: 16 additions & 15 deletions pcapkit/const/reg/apptype/dccp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# pylint: disable=line-too-long,consider-using-f-string
# pylint: disable=line-too-long
"""Application Layer Protocol Numbers (DCCP)
===============================================

Expand All @@ -18,10 +18,11 @@
class DCCP(AppType):
"""[DCCP] Application Layer Protocol Numbers (DCCP)

Members carry the **whole** transport protocol set IANA assigned the service,
not just ``dccp``, so a service registered on several transports appears in
each of their registries with its
:attr:`~pcapkit.const.reg.apptype.apptype.AppType.proto` intact.
Every member's :attr:`~pcapkit.const.reg.apptype.apptype.AppType.proto` is
``dccp`` and nothing else, so it labels the registry the member lives in
rather than restating the whole set IANA assigned the service. A service
registered on several transports is a separate member of each of their
registries, which is where that set is read off.

Note:
The rows below are this transport's registry entries with **no port
Expand Down Expand Up @@ -61,51 +62,51 @@ class DCCP(AppType):
#: - [UDP] Discard
#: - [SCTP] Discard [:rfc:`9260`]
#: - [DCCP] Discard [:rfc:`4340`]
discard = 9, 'discard', TransportProtocol.tcp | TransportProtocol.udp | TransportProtocol.sctp | TransportProtocol.dccp
discard = 9, 'discard', TransportProtocol.dccp

#: - [TCP] RFC3692-style Experiment 1 [1][:rfc:`4727`][:rfc:`6335`]
#: - [UDP] RFC3692-style Experiment 1 [1][:rfc:`4727`][:rfc:`6335`]
#: - [SCTP] RFC3692-style Experiment 1 [1][:rfc:`4727`][:rfc:`6335`]
#: - [DCCP] RFC3692-style Experiment 1 [1][:rfc:`4727`][:rfc:`6335`]
exp1 = 1021, 'exp1', TransportProtocol.tcp | TransportProtocol.udp | TransportProtocol.sctp | TransportProtocol.dccp
exp1 = 1021, 'exp1', TransportProtocol.dccp

#: - [TCP] RFC3692-style Experiment 2 [1][:rfc:`4727`][:rfc:`6335`]
#: - [UDP] RFC3692-style Experiment 2 [1][:rfc:`4727`][:rfc:`6335`]
#: - [SCTP] RFC3692-style Experiment 2 [1][:rfc:`4727`][:rfc:`6335`]
#: - [DCCP] RFC3692-style Experiment 2 [1][:rfc:`4727`][:rfc:`6335`]
exp2 = 1022, 'exp2', TransportProtocol.tcp | TransportProtocol.udp | TransportProtocol.sctp | TransportProtocol.dccp
exp2 = 1022, 'exp2', TransportProtocol.dccp

#: - [TCP] Licklider Transmission Protocol [:rfc:`5326`]
#: - [UDP] Licklider Transmission Protocol [:rfc:`5326`][:rfc:`7122`]
#: - [DCCP] Licklider Transmission Protocol [:rfc:`7122`]
ltp_deepspace = 1113, 'ltp-deepspace', TransportProtocol.tcp | TransportProtocol.udp | TransportProtocol.dccp
ltp_deepspace = 1113, 'ltp-deepspace', TransportProtocol.dccp

#: - [TCP] AWS protocol for cloud remoting solution
#: - [UDP] AWS protocol for cloud remoting solution
#: - [SCTP] AWS protocol for cloud remoting solution
#: - [DCCP] AWS protocol for cloud remoting solution
aws_wsp = 4195, 'aws-wsp', TransportProtocol.tcp | TransportProtocol.udp | TransportProtocol.sctp | TransportProtocol.dccp
aws_wsp = 4195, 'aws-wsp', TransportProtocol.dccp

#: - [TCP] DTN Bundle TCP CL Protocol [:rfc:`9174`]
#: - [UDP] DTN Bundle UDP CL Protocol [:rfc:`7122`]
#: - [DCCP] DTN Bundle DCCP CL Protocol [:rfc:`7122`]
dtn_bundle = 4556, 'dtn-bundle', TransportProtocol.tcp | TransportProtocol.udp | TransportProtocol.dccp
dtn_bundle = 4556, 'dtn-bundle', TransportProtocol.dccp

#: - [TCP] RTP media data [:rfc:`3551`][:rfc:`4571`]
#: - [UDP] RTP media data [:rfc:`3551`]
#: - [DCCP] RTP media data [:rfc:`3551`][:rfc:`5762`]
avt_profile_1 = 5004, 'avt-profile-1', TransportProtocol.tcp | TransportProtocol.udp | TransportProtocol.dccp
avt_profile_1 = 5004, 'avt-profile-1', TransportProtocol.dccp

#: - [TCP] RTP control protocol [:rfc:`3551`][:rfc:`4571`]
#: - [UDP] RTP control protocol [:rfc:`3551`]
#: - [DCCP] RTP control protocol [:rfc:`3551`][:rfc:`5762`]
avt_profile_2 = 5005, 'avt-profile-2', TransportProtocol.tcp | TransportProtocol.udp | TransportProtocol.dccp
avt_profile_2 = 5005, 'avt-profile-2', TransportProtocol.dccp

#: - [TCP] Syslog over TLS [:rfc:`5425`]
#: - [UDP] syslog over DTLS [:rfc:`6012`]
#: - [DCCP] syslog over DTLS [:rfc:`6012`]
syslog_tls = 6514, 'syslog-tls', TransportProtocol.tcp | TransportProtocol.udp | TransportProtocol.dccp
syslog_tls = 6514, 'syslog-tls', TransportProtocol.dccp

#: - [SCTP] Reserved
#: - [DCCP] Reserved
reserved_8282 = 8282, 'reserved', TransportProtocol.sctp | TransportProtocol.dccp
reserved_8282 = 8282, 'reserved', TransportProtocol.dccp
Loading
Loading