Skip to content

Commit 30e3b29

Browse files
committed
feat(transport): add a DCCP dissector with its pseudo-header checksum (#2489)
- DCCP dissects the RFC 4340 generic header with short and long sequence numbers, the fields of every packet type, DCCP-Listen (RFC 5596) and the options, and rebuilds each packet byte for byte; an option length under 2 is refused, and an over-long NDP Count keeps its width. - The enclosing IP layer verifies its checksum under CHECKSUM_VERIFY and computes it under CHECKSUM_COMPUTE, over the part CsCov gives; a CsCov reaching the end is written as 0 when computed, as Linux did. - IP protocol 33 dispatches to it; register_dccp and register_dccp_option write its port and option maps. - The IANA DCCP registries get crawlers and generated const modules. - Docs pages, the dispatch and option round-trip generators and the guard tables follow; the NotImplemented stub goes.
1 parent a25eb0e commit 30e3b29

58 files changed

Lines changed: 4365 additions & 35 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/source/contributing/pep.rst‎

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ the ones outstanding are,
4242

4343
* Link Layer: DSL, EAPOL, FDDI, ISDN, NDP, PPP
4444
* Internet Layer: ECN, Shim6
45-
* Transport Layer: DCCP, RSVP
45+
* Transport Layer: RSVP
4646
* Application Layer: BGP, DHCP, DHCPv6, DNS, IMAP, LDAP, MQTT, NNTP,
4747
NTP, ONC/RPC, POP, QUIC, RIP, RTP, SIP, SMTP, SNMP, SSH, Telnet,
4848
XMPP
@@ -818,12 +818,13 @@ These protocols parse a checksum or CRC field —
818818
:class:`~pcapkit.protocols.internet.ipx.IPX`,
819819
:class:`~pcapkit.protocols.internet.mh.MH`,
820820
:class:`~pcapkit.protocols.application.ospf.OSPF`,
821+
:class:`~pcapkit.protocols.transport.dccp.DCCP`,
821822
:class:`~pcapkit.protocols.transport.sctp.SCTP`,
822823
:class:`~pcapkit.protocols.transport.tcp.TCP` and
823824
:class:`~pcapkit.protocols.transport.udp.UDP` — and SCTP was the first to
824825
check whether the value is *right*, through
825826
:attr:`SCTP.checksum_valid <pcapkit.protocols.transport.sctp.SCTP.checksum_valid>`.
826-
IPv4, OSPF, TCP and UDP check it too, as do ICMP and ICMPv6, as the
827+
IPv4, OSPF, TCP, UDP and DCCP check it too, as do ICMP and ICMPv6, as the
827828
one's-complement half below describes. For HIP, HOPOPT, IPv6-Opts, IPX and MH the
828829
field is recorded and never questioned, so a corrupted capture parses as cleanly
829830
as an intact one.
@@ -832,9 +833,9 @@ as an intact one.
832833
of them is cryptographic and the distinction decides what is actually hard.
833834

834835
**The one's-complement Internet checksum**, which covers IPv4's header, TCP, UDP,
835-
ICMP/ICMPv6 and OSPF, needs no cryptography at all — it is sixteen-bit addition
836+
DCCP, ICMP/ICMPv6 and OSPF, needs no cryptography at all — it is sixteen-bit addition
836837
with end-around carry, and implementing it is an afternoon. What blocks it is the
837-
**IP pseudo-header**: the TCP, UDP and ICMPv6 checksums are computed over source
838+
**IP pseudo-header**: the TCP, UDP, DCCP and ICMPv6 checksums are computed over source
838839
and destination addresses, the protocol number and the payload length, all of
839840
which live in the *enclosing* layer. So verification needs a parsed protocol to
840841
reach back to its parent, which is a structural question about
@@ -924,6 +925,20 @@ offload heuristic on :issue:`2470`.
924925
checksum covers, so it is verified when the fragment holds that much, and
925926
:attr:`~pcapkit.corekit.checksum.internet.ChecksumStatus.TRUNCATED`
926927
otherwise.
928+
* **DCCP covers what its Checksum Coverage gives** (:rfc:`4340#section-9.2`), over
929+
a pseudo-header that carries the whole packet's length, as TCP's does, so a
930+
fragment is
931+
:attr:`~pcapkit.corekit.checksum.internet.ChecksumStatus.NO_PSEUDO_HEADER`
932+
too. A coverage running past the packet, which the RFC forbids and has the
933+
receiver ignore, is
934+
:attr:`~pcapkit.corekit.checksum.internet.ChecksumStatus.INVALID` and
935+
warns. Linux, until it dropped DCCP in 6.16, never sent one: its
936+
``dccp_csum_outgoing`` wrote a CsCov of 0 wherever the coverage reached the
937+
end of the packet, and ``make()`` does the same when it computes the
938+
checksum. No value is
939+
:attr:`~pcapkit.corekit.checksum.internet.ChecksumStatus.NOT_COMPUTED`:
940+
DCCP has no checksum to leave out, and Linux computed it in software rather
941+
than offloading it. Settled at implementation (:issue:`2489`).
927942

928943
The cryptographic half is sequenced for **wave 2 or 3**, and could be done sooner
929944
since ESP has already laid the groundwork.
@@ -1123,9 +1138,15 @@ Steps`_ above.
11231138
**Wave 2 — the protocol pairs that want a shared abstract base**, per `More
11241139
Protocols, More!!!`_ above: **TLS/SSL with DTLS** and **IGMP** and **DCCP** on
11251140
their own. These are grouped because the shared-base question is the design work
1126-
and doing either half of a pair alone would answer it twice. **DCCP** is the
1127-
transport-layer implementation, tracked by :issue:`2489`, and blocked on
1128-
:issue:`2479` for its pseudo-header checksum.
1141+
and doing either half of a pair alone would answer it twice.
1142+
1143+
**DCCP — done within wave 2** (:issue:`2489`).
1144+
:class:`~pcapkit.protocols.transport.dccp.DCCP` dissects every :rfc:`4340` packet
1145+
type and DCCP-Listen (:rfc:`5596`), with short and long sequence numbers, and the
1146+
options :rfc:`4340` defines; its checksum is verified and computed over
1147+
:class:`~pcapkit.protocols.misc.checksum.ip_pseudo.IP_Pseudo`, as `Checksum and
1148+
Integrity Verification`_ above describes. The Data Checksum option's CRC-32c is
1149+
recorded and not checked.
11291150

11301151
**Done within wave 2 — ICMP/ICMPv6 shared base.** :class:`~pcapkit.protocols.internet.icmp.ICMP`
11311152
is the abstract base :class:`~pcapkit.protocols.internet.icmpv4.ICMPv4` and
@@ -1311,7 +1332,7 @@ and its signature parameters could start whenever, since
13111332
:class:`~pcapkit.protocols.internet.esp.ESP` has already established both the
13121333
keying-context channel and the report-rather-than-raise policy. The
13131334
one's-complement half (IPv4, TCP, UDP, ICMP/ICMPv6, OSPF) is **done**
1314-
(:issue:`2470`, :issue:`2472` to :issue:`2475`).
1335+
(:issue:`2470`, :issue:`2472` to :issue:`2475`), and DCCP's with it (:issue:`2489`).
13151336

13161337
**IP pseudo-header — done** (:issue:`2471`).
13171338
:class:`~pcapkit.protocols.misc.checksum.ip_pseudo.IP_Pseudo` is the

‎docs/source/ext.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ The protocol classes :mod:`pcapkit` ships:
9191
| subclasses) | :class:`pcapkit.protocols.transport.udp.UDP` |
9292
+ +----------------+-----------------------+-------------------------------------------------------------+
9393
| | :class:`pcapkit.protocols.transport.sctp.SCTP` |
94+
+ +----------------+-----------------------+-------------------------------------------------------------+
95+
| | :class:`pcapkit.protocols.transport.dccp.DCCP` |
9496
+------------------------------------------------------------------+----------------+-----------------------+-------------------------------------------------------------+
9597
| | | :class:`pcapkit.protocols.application.ftp.FTP` |
9698
+ + FTP Family +-----------------------+-------------------------------------------------------------+
@@ -194,6 +196,8 @@ The registry function per protocol type:
194196
| | | :func:`~pcapkit.foundation.registry.protocols.register_udp` | new protocols. |
195197
+ +-------------------------------------------------------------------+----------------------------------------------------------------+ +
196198
| | | :func:`~pcapkit.foundation.registry.protocols.register_sctp` | |
199+
+ +-------------------------------------------------------------------+----------------------------------------------------------------+ +
200+
| | | :func:`~pcapkit.foundation.registry.protocols.register_dccp` | |
197201
+-------------------+-------------------------------------------------------------------+----------------------------------------------------------------+--------------------+
198202

199203
A protocol carried over IPX is keyed by IPX Packet Type rather than by IP protocol
@@ -405,6 +409,8 @@ writes them:
405409
| | :class:`~pcapkit.protocols.transport.sctp.SCTP` | :attr:`SCTP.__parameter__ <pcapkit.protocols.transport.sctp.SCTP.__parameter__>` | :func:`~pcapkit.foundation.registry.protocols.register_sctp_parameter` |
406410
+ + +-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
407411
| | | :attr:`SCTP.__cause__ <pcapkit.protocols.transport.sctp.SCTP.__cause__>` | :func:`~pcapkit.foundation.registry.protocols.register_sctp_cause` |
412+
+ +------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
413+
| | :class:`~pcapkit.protocols.transport.dccp.DCCP` | :attr:`DCCP.__option__ <pcapkit.protocols.transport.dccp.DCCP.__option__>` | :func:`~pcapkit.foundation.registry.protocols.register_dccp_option` |
408414
+-------------------+------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
409415
| Application Layer | :class:`~pcapkit.protocols.application.httpv2.HTTPv2` | :attr:`HTTPv2.__frame__ <pcapkit.protocols.application.httpv2.HTTPv2.__frame__>` | :func:`~pcapkit.foundation.registry.protocols.register_http_frame` |
410416
+-------------------+------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+

‎docs/source/pcapkit/const/dccp.rst‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
=====================================================================
2+
:class:`~pcapkit.protocols.transport.dccp.DCCP` Constant Enumerations
3+
=====================================================================
4+
5+
.. module:: pcapkit.const.dccp
6+
7+
This module contains all constant enumerations of
8+
:class:`~pcapkit.protocols.transport.dccp.DCCP` implementations. Available
9+
enumerations include:
10+
11+
.. list-table::
12+
13+
* - :class:`DCCP_PacketType <pcapkit.const.dccp.packet_type.PacketType>`
14+
- DCCP Packet Types [*]_
15+
* - :class:`DCCP_ResetCode <pcapkit.const.dccp.reset_code.ResetCode>`
16+
- DCCP Reset Codes [*]_
17+
* - :class:`DCCP_Option <pcapkit.const.dccp.option.Option>`
18+
- DCCP Option Types [*]_
19+
* - :class:`DCCP_Feature <pcapkit.const.dccp.feature.Feature>`
20+
- DCCP Feature Numbers [*]_
21+
* - :class:`DCCP_AckVectorState <pcapkit.const.dccp.ack_vector_state.AckVectorState>`
22+
- DCCP Ack Vector States [*]_
23+
* - :class:`DCCP_DropCode <pcapkit.const.dccp.drop_code.DropCode>`
24+
- DCCP Drop Codes [*]_
25+
26+
DCCP Packet Types
27+
=================
28+
29+
.. module:: pcapkit.const.dccp.packet_type
30+
31+
This module contains the constant enumeration for **DCCP Packet Types**,
32+
which is automatically generated from :class:`pcapkit.vendor.dccp.packet_type.PacketType`.
33+
34+
.. autoclass:: pcapkit.const.dccp.packet_type.PacketType
35+
:members:
36+
:undoc-members:
37+
:show-inheritance:
38+
39+
DCCP Reset Codes
40+
================
41+
42+
.. module:: pcapkit.const.dccp.reset_code
43+
44+
This module contains the constant enumeration for **DCCP Reset Codes**,
45+
which is automatically generated from :class:`pcapkit.vendor.dccp.reset_code.ResetCode`.
46+
47+
.. autoclass:: pcapkit.const.dccp.reset_code.ResetCode
48+
:members:
49+
:undoc-members:
50+
:show-inheritance:
51+
52+
DCCP Option Types
53+
=================
54+
55+
.. module:: pcapkit.const.dccp.option
56+
57+
This module contains the constant enumeration for **DCCP Option Types**,
58+
which is automatically generated from :class:`pcapkit.vendor.dccp.option.Option`.
59+
60+
.. autoclass:: pcapkit.const.dccp.option.Option
61+
:members:
62+
:undoc-members:
63+
:show-inheritance:
64+
65+
DCCP Feature Numbers
66+
====================
67+
68+
.. module:: pcapkit.const.dccp.feature
69+
70+
This module contains the constant enumeration for **DCCP Feature Numbers**,
71+
which is automatically generated from :class:`pcapkit.vendor.dccp.feature.Feature`.
72+
73+
.. autoclass:: pcapkit.const.dccp.feature.Feature
74+
:members:
75+
:undoc-members:
76+
:show-inheritance:
77+
78+
DCCP Ack Vector States
79+
======================
80+
81+
.. module:: pcapkit.const.dccp.ack_vector_state
82+
83+
This module contains the constant enumeration for **DCCP Ack Vector States**,
84+
which is automatically generated from :class:`pcapkit.vendor.dccp.ack_vector_state.AckVectorState`.
85+
86+
.. autoclass:: pcapkit.const.dccp.ack_vector_state.AckVectorState
87+
:members:
88+
:undoc-members:
89+
:show-inheritance:
90+
91+
DCCP Drop Codes
92+
===============
93+
94+
.. module:: pcapkit.const.dccp.drop_code
95+
96+
This module contains the constant enumeration for **DCCP Drop Codes**,
97+
which is automatically generated from :class:`pcapkit.vendor.dccp.drop_code.DropCode`.
98+
99+
.. autoclass:: pcapkit.const.dccp.drop_code.DropCode
100+
:members:
101+
:undoc-members:
102+
:show-inheritance:
103+
104+
.. rubric:: Footnotes
105+
106+
.. [*] https://www.iana.org/assignments/dccp-parameters/dccp-parameters.xhtml#dccp-parameters-1
107+
.. [*] https://www.iana.org/assignments/dccp-parameters/dccp-parameters.xhtml#dccp-parameters-3
108+
.. [*] https://www.iana.org/assignments/dccp-parameters/dccp-parameters.xhtml#dccp-parameters-5
109+
.. [*] https://www.iana.org/assignments/dccp-parameters/dccp-parameters.xhtml#dccp-parameters-7
110+
.. [*] https://www.iana.org/assignments/dccp-parameters/dccp-parameters.xhtml#dccp-parameters-10
111+
.. [*] https://www.iana.org/assignments/dccp-parameters/dccp-parameters.xhtml#dccp-parameters-11

‎docs/source/pcapkit/const/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Transport Layer
9595
.. toctree::
9696
:maxdepth: 2
9797

98+
dccp
9899
sctp
99100
tcp
100101

‎docs/source/pcapkit/foundation/registry.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ Transport Layer Registries
137137

138138
.. autofunction:: pcapkit.foundation.registry.protocols.register_sctp_cause
139139

140+
.. autofunction:: pcapkit.foundation.registry.protocols.register_dccp
141+
142+
.. autofunction:: pcapkit.foundation.registry.protocols.register_dccp_option
143+
140144
Application Layer Registries
141145
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142146

‎docs/source/pcapkit/protocols/index.rst‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ from given information. The class hierarchy of :mod:`pcapkit.protocols`:
111111
end
112112

113113
subgraph transport [Transport Layer]
114-
Transport --> TCP & UDP & SCTP
114+
Transport --> TCP & UDP & SCTP & DCCP
115115
end
116116

117117
B --> Link & Internet & Transport & Application
@@ -171,6 +171,7 @@ from given information. The class hierarchy of :mod:`pcapkit.protocols`:
171171
click TCP "transport/tcp.html#pcapkit.protocols.transport.tcp.TCP"
172172
click UDP "transport/udp.html#pcapkit.protocols.transport.udp.UDP"
173173
click SCTP "transport/sctp.html#pcapkit.protocols.transport.sctp.SCTP"
174+
click DCCP "transport/dccp.html#pcapkit.protocols.transport.dccp.DCCP"
174175

175176
click Application "application/application.html#pcapkit.protocols.application.application.Application"
176177
click HTTP "application/http.html#pcapkit.protocols.application.http.HTTP"

0 commit comments

Comments
 (0)