3 * RFC 7242: https://tools.ietf.org/html/rfc7242
4 * RFC 9174: https://www.rfc-editor.org/rfc/rfc9174.html
6 * TCPCLv4 portions copyright 2019-2021, Brian Sipos <brian.sipos@gmail.com>
7 * Copyright 2006-2007 The MITRE Corporation.
9 * Approved for Public Release; Distribution Unlimited.
10 * Tracking Number 07-0090.
12 * The US Government will not be charged any license fee and/or royalties
13 * related to this software. Neither name of The MITRE Corporation; nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * Wireshark - Network traffic analyzer
18 * By Gerald Combs <gerald@wireshark.org>
19 * Copyright 1998 Gerald Combs
21 * SPDX-License-Identifier: GPL-2.0-or-later
23 #ifndef PACKET_TCPCL_H
24 #define PACKET_TCPCL_H
26 #include <ws_symbol_export.h>
27 #include <epan/tvbuff.h>
28 #include <epan/proto.h>
34 /** Extension points for TCPCLv4 are available as:
35 * For session extension item dissectors, the dissector table
36 * "tcpcl.v4.sess_ext" has a FT_UINT16 key for registering.
37 * For transfer extension item dissectors, the dissector table
38 * "tcpcl.v4.xfer_ext" has a FT_UINT16 key for registering.
39 * Both have user data dissection context which is obtained with the
40 * tcpcl_dissect_ctx_get() function.
43 /* TCP Convergence Layer v3 - Message Types */
45 TCPCLV3_TYPE_MASK
= 0xf0,
46 TCPCLV3_DATA_SEGMENT
= 0x10,
47 TCPCLV3_ACK_SEGMENT
= 0x20,
48 TCPCLV3_REFUSE_BUNDLE
= 0x30,
49 TCPCLV3_KEEP_ALIVE
= 0x40,
50 TCPCLV3_SHUTDOWN
= 0x50,
51 TCPCLV3_LENGTH
= 0x60,
54 /* TCP Convergence Layer - Contact Header Flags */
56 TCPCLV3_BUNDLE_ACK_FLAG
= 0x01,
57 TCPCLV3_REACTIVE_FRAG_FLAG
= 0x02,
58 TCPCLV3_CONNECTOR_RCVR_FLAG
= 0x04,
61 /* TCP Convergence Layer - Data Segment Flags */
63 TCPCLV3_DATA_FLAGS
= 0x03,
64 TCPCLV3_DATA_END_FLAG
= 0x01,
65 TCPCLV3_DATA_START_FLAG
= 0x02,
66 } Tcpclv3DataSegmentFlag
;
68 /* TCP Convergence Layer - Shutdown Segment Flags */
70 TCPCLV3_SHUTDOWN_FLAGS
= 0x03,
71 TCPCLV3_SHUTDOWN_REASON
= 0x02,
72 TCPCLV3_SHUTDOWN_DELAY
= 0x01,
73 } Tcpclv3ShutdownFlag
;
75 /* REFUSE-BUNDLE Reason-Codes */
77 TCPCLV3_REFUSE_REASON_UNKNOWN
= 0x00,
78 TCPCLV3_REFUSE_REASON_RX_COMPLETE
= 0x01,
79 TCPCLV3_REFUSE_REASON_RX_EXHAUSTED
= 0x02,
80 TCPCLV3_REFUSE_REASON_RX_RETRANSMIT
= 0x03,
81 /* 0x4-0x7 - Unassigned
82 * 0x8-0xf - Reserved for future Use */
86 TCPCLV4_MSGTYPE_INVALID
= 0x00,
87 TCPCLV4_MSGTYPE_XFER_SEGMENT
= 0x01,
88 TCPCLV4_MSGTYPE_XFER_ACK
= 0x02,
89 TCPCLV4_MSGTYPE_XFER_REFUSE
= 0x03,
90 TCPCLV4_MSGTYPE_KEEPALIVE
= 0x04,
91 TCPCLV4_MSGTYPE_SESS_TERM
= 0x05,
92 TCPCLV4_MSGTYPE_MSG_REJECT
= 0x06,
93 TCPCLV4_MSGTYPE_SESS_INIT
= 0x07,
97 TCPCLV4_SESSEXT_INVALID
= 0x00,
98 } Tcpclv4SessExtenionType
;
101 TCPCLV4_XFEREXT_INVALID
= 0x00,
102 TCPCLV4_XFEREXT_TRANSFER_LEN
= 0x01,
103 } Tcpclv4XferExtenionType
;
106 TCPCLV4_CONTACT_FLAG_CANTLS
= 0x01,
107 } Tcpclv4ContactFlag
;
110 TCPCLV4_SESS_TERM_FLAG_REPLY
= 0x01,
111 } Tcpclv4SessTermFlag
;
114 TCPCLV4_TRANSFER_FLAG_START
= 0x02,
115 TCPCLV4_TRANSFER_FLAG_END
= 0x01,
116 } Tcpclv4TransferFlag
;
119 TCPCLV4_EXTENSION_FLAG_CRITICAL
= 0x01,
120 } Tcpclv4ExtensionFlag
;
122 /// Finer grained locating than just the frame number
124 /// Index of the frame
126 /// Source index within the frame
128 /// Offset within the source TVB
133 /// Ordered list of seg_meta_t* for XFER_SEGMENT as seen in the first scan.
134 wmem_list_t
*seg_list
;
136 /// Ordered list of ack_meta_t* for XFER_ACK as seen in the first scan.
137 wmem_list_t
*ack_list
;
139 /// Optional Transfer Length extension
140 uint64_t *total_length
;
144 /// Address for this peer
146 /// Port for the this peer
149 /// True if a contact header was not seen at the start of connection
151 /// Frame number in which the contact header starts
152 tcpcl_frame_loc_t
*chdr_seen
;
153 /// TCPCL version seen from this peer
155 /// CAN_TLS flag from the contact header
158 /// Frame number in which the v4 SESS_INIT message starts
159 tcpcl_frame_loc_t
*sess_init_seen
;
160 /// Keepalive duration (s) from v4 SESS_INIT
163 uint64_t segment_mru
;
165 uint64_t transfer_mru
;
167 /// Frame number in which the SESS_TERM message starts
168 tcpcl_frame_loc_t
*sess_term_seen
;
170 uint8_t sess_term_reason
;
172 /// Map from tcpcl_frame_loc_t* to possible associated transfer ID uint64_t*
173 wmem_map_t
*frame_loc_to_transfer
;
175 /// Map from transfer ID uint64_t* to tcpcl_transfer_t* sent from this peer
176 wmem_map_t
*transfers
;
179 /// Persistent state associated with a TCP conversation
181 /// Information for the active side of the session
182 tcpcl_peer_t
*active
;
183 /// Information for the passive side of the session
184 tcpcl_peer_t
*passive
;
186 /// Set to the first TCPCL version seen.
187 /// Used later for validity check.
189 /// True when contact negotiation is finished
190 bool contact_negotiated
;
191 /// Negotiated use of TLS from @c can_tls of the peers
192 bool session_use_tls
;
193 /// The last frame before TLS handshake
194 tcpcl_frame_loc_t
*session_tls_start
;
196 /// True when session negotiation is finished
197 bool sess_negotiated
;
198 /// Negotiated session keepalive
199 uint16_t sess_keepalive
;
200 } tcpcl_conversation_t
;
202 /// Context for a single packet dissection
204 tcpcl_conversation_t
*convo
;
205 /// Dissection cursor
206 tcpcl_frame_loc_t
*cur_loc
;
207 /// True if the dissection is on a contact header
210 tcpcl_peer_t
*tx_peer
;
211 /// The receiving peer
212 tcpcl_peer_t
*rx_peer
;
213 /// Possible transfer payload
215 } tcpcl_dissect_ctx_t
;
217 /** Initialize members of the dissection context.
219 * @param pinfo Packet info for the frame.
220 * @param tvb The buffer dissected.
221 * @param offset The start offset.
222 * @return ctx The new packet context.
225 tcpcl_dissect_ctx_t
* tcpcl_dissect_ctx_get(tvbuff_t
*tvb
, packet_info
*pinfo
, const int offset
);
231 #endif /* PACKET_TCPCL_H */
234 * Editor modelines - https://www.wireshark.org/tools/modelines.html
239 * indent-tabs-mode: nil
242 * vi: set shiftwidth=4 tabstop=8 expandtab:
243 * :indentSize=4:tabSize=8:noTabs=true: