2 * Routines for Datagram Congestion Control Protocol, "DCCP" dissection:
3 * it should conform to RFC 4340
7 * Francesco Fondelli <francesco dot fondelli, gmail dot com>
9 * Copyright 2020-2021 by Thomas Dreibholz <dreibh [AT] simula.no>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * Copied from packet-udp.c
17 * SPDX-License-Identifier: GPL-2.0-or-later
22 * Nov 13, 2006: makes checksum computation dependent
23 * upon the header CsCov field (cf. RFC 4340, 5.1)
26 * Nov 13, 2006: removes the case where checksums are zero
27 * (unlike UDP/packet-udp, from which the code stems,
28 * zero checksums are illegal in DCCP (as in TCP))
31 * Jan 29, 2007: updates the offsets of the timestamps to be
32 * compliant to (cf. RFC 4342, sec. 13).
35 * Mar 11, 2012: add support for RFC 5596 (DCCP-Listen Packet)
36 * (Francesco Fondelli)
38 * Feb 19, 2021: added service code types
41 * Nov 16, 2022: added MP-DCCP support
48 #include <epan/packet.h>
49 #include <epan/addr_resolv.h>
50 #include <epan/dccpservicecodes.h>
51 #include <epan/ipproto.h>
52 #include <epan/in_cksum.h>
53 #include <epan/prefs.h>
54 #include <epan/follow.h>
55 #include <epan/expert.h>
56 #include <epan/conversation.h>
57 #include <epan/conversation_table.h>
58 #include <epan/conversation_filter.h>
60 #include <epan/unit_strings.h>
62 #include <wsutil/str_util.h>
64 #include "packet-dccp.h"
67 * Some definitions and the dissect_options() logic have been taken
68 * from Arnaldo Carvalho de Melo's DCCP implementation, thanks!
70 #define DCCP_GEN_HDR_LEN_NO_X 12 /* generic header length, without extended sequence numbers */
71 #define DCCP_GEN_HDR_LEN_X 16 /* generic header length, with extended sequence numbers */
72 #define DCCP_HDR_LEN 16 /* base DCCP header length, with 48 bits seqnums */
73 #define DCCP_HDR_LEN_MIN 12 /* with 24 bits seqnum */
74 #define DCCP_HDR_PKT_TYPES_LEN_MAX 12 /* max per packet type extra
77 #define DCCP_OPT_LEN_MAX 1008
78 #define DCCP_HDR_LEN_MAX (DCCP_HDR_LEN + DCCP_HDR_PKT_TYPES_LEN_MAX + \
81 /* Static DCCP flags. Set in dccp_flow_t:static_flags */
82 #define DCCP_S_BASE_SEQ_SET 0x01
84 void proto_register_dccp(void);
85 void proto_reg_handoff_dccp(void);
87 static dissector_handle_t dccp_handle
;
90 * FF: please keep this list in sync with
91 * http://www.iana.org/assignments/dccp-parameters/dccp-parameters.xml
92 * Registry Name: 'Packet Types'
94 static const value_string dccp_packet_type_vals
[] = {
115 * Based on https://www.iana.org/assignments/service-codes/service-codes.xhtml
116 * as of February 19th, 2021
118 static const value_string dccp_service_code_vals
[] = {
119 { NOT_SPECIFIED_SERVICE_CODE
, "not specified" },
120 { LTP_SERVICE_CODE
, "LTP: Licklider Transmission Protocol" },
121 { DISC_SERVICE_CODE
, "DISC: Discard" },
122 { RTCP_SERVICE_CODE
, "RTCP: RTCP connection, separate from the corresponding RTP" },
123 { RTPA_SERVICE_CODE
, "RTPA: RTP session conveying audio data (and associated RTCP)" },
124 { RTPO_SERVICE_CODE
, "RTPO: RTP session conveying other media (and associated RTCP)" },
125 { RTPT_SERVICE_CODE
, "RTPT: RTP session conveying text media (and associated RTCP)" },
126 { RTPV_SERVICE_CODE
, "RTPV: RTP session conveying video data (and associated RTCP)" },
127 { SYLG_SERVICE_CODE
, "SYLG: Syslog Protocol" },
128 { BUNDLES_SERVICE_CODE
, "Bundle Protocol" },
129 { NPMP_SERVICE_CODE
, "NPMP: NetPerfMeter Data" },
130 { RESERVED_SERVICE_CODE
, "Reserved (Invalid)" },
134 static const value_string dccp_reset_code_vals
[] = {
135 {0x00, "Unspecified" },
138 {0x03, "No Connection" },
139 {0x04, "Packet Error" },
140 {0x05, "Option Error" },
141 {0x06, "Mandatory Error" },
142 {0x07, "Connection Refused"},
143 {0x08, "Bad Service Code" },
145 {0x0A, "Bad Init Cookie" },
146 {0x0B, "Aggression Penalty"},
151 static const range_string dccp_options_rvals
[] = {
152 {0x00, 0x00, "Padding" },
153 {0x01, 0x01, "Mandatory" },
154 {0x02, 0x02, "Slow Receiver" },
155 {0x03, 0x1F, "Reserved"},
156 {0x20, 0x20, "Change L" },
157 {0x21, 0x21, "Confirm L"},
158 {0x22, 0x22, "Change R" },
159 {0x23, 0x23, "Confirm R"},
160 {0x24, 0x24, "Init Cookie"},
161 {0x25, 0x25, "NDP Count"},
162 {0x26, 0x26, "Ack Vector [Nonce 0]"},
163 {0x27, 0x27, "Ack Vector [Nonce 1]"},
164 {0x28, 0x28, "Data Dropped"},
165 {0x29, 0x29, "Timestamp"},
166 {0x2A, 0x2A, "Timestamp Echo"},
167 {0x2B, 0x2B, "Elapsed Time"},
168 {0x2C, 0x2C, "Data checksum"},
169 {0x2D, 0x2D, "Quick-Start Response"},
170 {0x2E, 0x2E, "Multipath"},
171 {0x2F, 0x7F, "Reserved"},
172 {0x80, 0xBF, "CCID option"},
173 {0xC0, 0xC0, "CCID3 Loss Event Rate"},
174 {0xC1, 0xC1, "CCID3 Loss Intervals"},
175 {0xC2, 0xC2, "CCID3 Receive Rate"},
176 {0xC3, 0xFF, "CCID option"},
180 static const range_string dccp_feature_numbers_rvals
[] = {
181 {0x00, 0x00, "Reserved" },
182 {0x01, 0x01, "Congestion Control ID (CCID)" },
183 {0x02, 0x02, "Allow Short Seqnums" },
184 {0x03, 0x03, "Sequence Window" },
185 {0x04, 0x04, "ECN Incapable" },
186 {0x05, 0x05, "Ack Ratio" },
187 {0x06, 0x06, "Send Ack Vector" },
188 {0x07, 0x07, "Send NDP Count" },
189 {0x08, 0x08, "Minimum Checksum Coverage" },
190 {0x09, 0x09, "Check Data Checksum" },
191 {0x0A, 0x0A, "MP_CAPABLE" },
192 {0x03, 0x7F, "Reserved"},
193 {0xC0, 0xC0, "Send Loss Event Rate"}, /* CCID3, RFC 4342, 8.5 */
194 {0xC1, 0xFF, "CCID-specific feature"},
198 static const unit_name_string units_bytes_sec
= { "bytes/sec", NULL
};
200 static int proto_dccp
;
202 static int dccp_follow_tap
;
204 static int hf_dccp_srcport
;
205 static int hf_dccp_dstport
;
206 static int hf_dccp_port
;
207 static int hf_dccp_stream
;
208 static int hf_dccp_data_offset
;
209 static int hf_dccp_ccval
;
210 static int hf_dccp_cscov
;
211 static int hf_dccp_checksum
;
212 static int hf_dccp_checksum_status
;
213 static int hf_dccp_res1
;
214 static int hf_dccp_type
;
215 static int hf_dccp_x
;
216 static int hf_dccp_res2
;
217 static int hf_dccp_seq
;
218 static int hf_dccp_seq_abs
;
220 static int hf_dccp_ack_res
;
221 static int hf_dccp_ack
;
222 static int hf_dccp_ack_abs
;
224 static int hf_dccp_service_code
;
225 static int hf_dccp_reset_code
;
226 static int hf_dccp_data1
;
227 static int hf_dccp_data2
;
228 static int hf_dccp_data3
;
230 static int hf_dccp_options
;
231 static int hf_dccp_option_type
;
232 static int hf_dccp_feature_number
;
233 static int hf_dccp_ndp_count
;
234 static int hf_dccp_timestamp
;
235 static int hf_dccp_timestamp_echo
;
236 static int hf_dccp_elapsed_time
;
237 static int hf_dccp_data_checksum
;
239 /* MP-DCCP Option fields */
240 static int hf_mpdccp_confirm
;
242 static int hf_mpdccp_version
;
244 static int hf_mpdccp_join
;
245 static int hf_mpdccp_join_id
;
246 static int hf_mpdccp_join_token
;
247 static int hf_mpdccp_join_nonce
;
249 static int hf_mpdccp_fast_close
;
251 static int hf_mpdccp_key
;
252 static int hf_mpdccp_key_type
;
253 static int hf_mpdccp_key_key
;
255 static int hf_mpdccp_seq
;
257 static int hf_mpdccp_hmac
;
258 static int hf_mpdccp_hmac_sha
;
260 static int hf_mpdccp_rtt
;
261 static int hf_mpdccp_rtt_type
;
262 static int hf_mpdccp_rtt_value
;
263 static int hf_mpdccp_rtt_age
;
265 static int hf_mpdccp_addaddr
;
266 static int hf_mpdccp_addrid
;
267 //static int hf_mpdccp_addr;
268 static int hf_mpdccp_addr_dec
;
269 static int hf_mpdccp_addr_hex
;
270 static int hf_mpdccp_addrport
;
272 static int hf_mpdccp_removeaddr
;
274 static int hf_mpdccp_prio
;
275 static int hf_mpdccp_prio_value
;
277 static int hf_mpdccp_close
;
278 static int hf_mpdccp_close_key
;
280 static int hf_mpdccp_exp
;
282 static int hf_dccp_option_data
;
284 /* Generated from convert_proto_tree_add_text.pl */
285 static int hf_dccp_padding
;
286 static int hf_dccp_mandatory
;
287 static int hf_dccp_slow_receiver
;
288 static int hf_dccp_init_cookie
;
289 static int hf_dccp_ack_vector_nonce_0
;
290 static int hf_dccp_ack_vector_nonce_1
;
291 static int hf_dccp_data_dropped
;
292 static int hf_dccp_ccid3_loss_event_rate
;
293 static int hf_dccp_ccid3_loss_intervals
;
294 static int hf_dccp_ccid3_receive_rate
;
295 static int hf_dccp_option_reserved
;
296 static int hf_dccp_ccid_option_data
;
297 static int hf_dccp_option_unknown
;
300 static int ett_dccp_options
;
301 static int ett_dccp_options_item
;
302 static int ett_dccp_feature
;
304 static expert_field ei_dccp_option_len_bad
;
305 static expert_field ei_dccp_advertised_header_length_bad
;
306 static expert_field ei_dccp_packet_type_reserved
;
307 static expert_field ei_dccp_checksum
;
309 static dissector_table_t dccp_subdissector_table
;
310 static heur_dissector_list_t heur_subdissector_list
;
313 static bool dccp_summary_in_tree
= true;
314 static bool try_heuristic_first
;
315 static bool dccp_check_checksum
= true;
316 static bool dccp_relative_seq
= true;
317 static uint32_t dccp_stream_count
;
320 decode_dccp_ports(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo
,
321 proto_tree
*tree
, int sport
, int dport
)
324 int low_port
, high_port
;
325 heur_dtbl_entry_t
*hdtbl_entry
;
327 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
329 /* If the user has a "Follow DCCP Stream" window loading, pass a pointer
330 to the payload tvb through the tap system. */
331 if (have_tap_listener(dccp_follow_tap
))
332 tap_queue_packet(dccp_follow_tap
, pinfo
, next_tvb
);
335 * determine if this packet is part of a conversation and call dissector
336 * for the conversation if available
338 if (try_conversation_dissector(&pinfo
->src
, &pinfo
->dst
, CONVERSATION_DCCP
, sport
,
339 dport
, next_tvb
, pinfo
, tree
, NULL
, 0)) {
343 if (try_heuristic_first
) {
344 /* do lookup with the heuristic subdissector table */
345 if (dissector_try_heuristic(heur_subdissector_list
, next_tvb
, pinfo
,
346 tree
, &hdtbl_entry
, NULL
)) {
352 * Do lookups with the subdissector table.
353 * We try the port number with the lower value first, followed by the
354 * port number with the higher value. This means that, for packets
355 * where a dissector is registered for *both* port numbers:
357 * 1) we pick the same dissector for traffic going in both directions;
359 * 2) we prefer the port number that's more likely to be the right
360 * one (as that prefers well-known ports to reserved ports);
362 * although there is, of course, no guarantee that any such strategy
363 * will always pick the right port number.
364 * XXX - we ignore port numbers of 0, as some dissectors use a port
365 * number of 0 to disable the port.
376 dissector_try_uint(dccp_subdissector_table
, low_port
,
377 next_tvb
, pinfo
, tree
)) {
381 if (high_port
!= 0 &&
382 dissector_try_uint(dccp_subdissector_table
, high_port
,
383 next_tvb
, pinfo
, tree
)) {
387 if (!try_heuristic_first
) {
388 /* do lookup with the heuristic subdissector table */
389 if (dissector_try_heuristic(heur_subdissector_list
, next_tvb
,
390 pinfo
, tree
, &hdtbl_entry
, NULL
)) {
395 /* Oh, well, we don't know this; dissect it as data. */
396 call_data_dissector(next_tvb
, pinfo
, tree
);
399 /* Conversation and process code originally copied from packet-udp.c */
400 static struct dccp_analysis
*
401 init_dccp_conversation_data(packet_info
*pinfo
)
403 struct dccp_analysis
*dccpd
;
405 /* Initialize the dccp protocol data structure to add to the dccp conversation */
406 dccpd
= wmem_new0(wmem_file_scope(), struct dccp_analysis
);
407 dccpd
->flow1
.static_flags
= 0;
408 dccpd
->flow1
.base_seq
= 0;
409 dccpd
->flow2
.static_flags
= 0;
410 dccpd
->flow2
.base_seq
= 0;
412 dccpd
->stream
= dccp_stream_count
++;
413 dccpd
->ts_first
= pinfo
->abs_ts
;
414 dccpd
->ts_prev
= pinfo
->abs_ts
;
419 static struct dccp_analysis
*
420 get_dccp_conversation_data(conversation_t
*conv
, packet_info
*pinfo
)
423 struct dccp_analysis
*dccpd
;
425 /* Get the data for this conversation */
426 dccpd
=(struct dccp_analysis
*)conversation_get_proto_data(conv
, proto_dccp
);
428 /* If the conversation was just created or it matched a
429 * conversation with template options, dccpd will not
430 * have been initialized. So, initialize
431 * a new dccpd structure for the conversation.
434 dccpd
= init_dccp_conversation_data(pinfo
);
435 conversation_add_proto_data(conv
, proto_dccp
, dccpd
);
438 /* check direction and get ua lists */
439 direction
=cmp_address(&pinfo
->src
, &pinfo
->dst
);
440 /* if the addresses are equal, match the ports instead */
441 if (direction
== 0) {
442 direction
= (pinfo
->srcport
> pinfo
->destport
) ? 1 : -1;
444 if (direction
>= 0) {
445 dccpd
->fwd
=&(dccpd
->flow1
);
446 dccpd
->rev
=&(dccpd
->flow2
);
448 dccpd
->fwd
=&(dccpd
->flow2
);
449 dccpd
->rev
=&(dccpd
->flow1
);
455 static const char* dccp_conv_get_filter_type(conv_item_t
* conv
, conv_filter_type_e filter
)
457 if (filter
== CONV_FT_SRC_PORT
)
458 return "dccp.srcport";
460 if (filter
== CONV_FT_DST_PORT
)
461 return "dccp.dstport";
463 if (filter
== CONV_FT_ANY_PORT
)
467 return CONV_FILTER_INVALID
;
470 if (filter
== CONV_FT_SRC_ADDRESS
) {
471 if (conv
->src_address
.type
== AT_IPv4
)
473 if (conv
->src_address
.type
== AT_IPv6
)
477 if (filter
== CONV_FT_DST_ADDRESS
) {
478 if (conv
->dst_address
.type
== AT_IPv4
)
480 if (conv
->dst_address
.type
== AT_IPv6
)
484 if (filter
== CONV_FT_ANY_ADDRESS
) {
485 if (conv
->src_address
.type
== AT_IPv4
)
487 if (conv
->src_address
.type
== AT_IPv6
)
491 return CONV_FILTER_INVALID
;
494 static ct_dissector_info_t dccp_ct_dissector_info
= {&dccp_conv_get_filter_type
};
496 static tap_packet_status
497 dccpip_conversation_packet(void *pct
, packet_info
*pinfo
, epan_dissect_t
*edt _U_
, const void *vip
, tap_flags_t flags
)
499 conv_hash_t
*hash
= (conv_hash_t
*) pct
;
501 const e_dccphdr
*dccphdr
=(const e_dccphdr
*)vip
;
503 add_conversation_table_data_with_conv_id(hash
, &dccphdr
->ip_src
, &dccphdr
->ip_dst
, dccphdr
->sport
, dccphdr
->dport
, (conv_id_t
) dccphdr
->stream
, 1, pinfo
->fd
->pkt_len
, &pinfo
->rel_ts
, &pinfo
->abs_ts
, &dccp_ct_dissector_info
, CONVERSATION_DCCP
);
505 return TAP_PACKET_REDRAW
;
508 static const char* dccp_endpoint_get_filter_type(endpoint_item_t
* endpoint
, conv_filter_type_e filter
)
511 if (filter
== CONV_FT_SRC_PORT
)
512 return "dccp.srcport";
514 if (filter
== CONV_FT_DST_PORT
)
515 return "dccp.dstport";
517 if (filter
== CONV_FT_ANY_PORT
)
521 return CONV_FILTER_INVALID
;
525 if (filter
== CONV_FT_SRC_ADDRESS
) {
526 if (endpoint
->myaddress
.type
== AT_IPv4
)
528 if (endpoint
->myaddress
.type
== AT_IPv6
)
532 if (filter
== CONV_FT_DST_ADDRESS
) {
533 if (endpoint
->myaddress
.type
== AT_IPv4
)
535 if (endpoint
->myaddress
.type
== AT_IPv6
)
539 if (filter
== CONV_FT_ANY_ADDRESS
) {
540 if (endpoint
->myaddress
.type
== AT_IPv4
)
542 if (endpoint
->myaddress
.type
== AT_IPv6
)
546 return CONV_FILTER_INVALID
;
549 static et_dissector_info_t dccp_endpoint_dissector_info
= {&dccp_endpoint_get_filter_type
};
551 static tap_packet_status
552 dccpip_endpoint_packet(void *pit
, packet_info
*pinfo
, epan_dissect_t
*edt _U_
, const void *vip
, tap_flags_t flags
)
554 conv_hash_t
*hash
= (conv_hash_t
*) pit
;
556 const e_dccphdr
*dccphdr
=(const e_dccphdr
*)vip
;
558 /* Take two "add" passes per packet, adding for each direction, ensures that all
559 packets are counted properly (even if address is sending to itself)
560 XXX - this could probably be done more efficiently inside endpoint_table */
561 add_endpoint_table_data(hash
, &dccphdr
->ip_src
, dccphdr
->sport
, true, 1, pinfo
->fd
->pkt_len
, &dccp_endpoint_dissector_info
, ENDPOINT_DCCP
);
562 add_endpoint_table_data(hash
, &dccphdr
->ip_dst
, dccphdr
->dport
, false, 1, pinfo
->fd
->pkt_len
, &dccp_endpoint_dissector_info
, ENDPOINT_DCCP
);
564 return TAP_PACKET_REDRAW
;
567 /* Return the current stream count */
568 uint32_t get_dccp_stream_count(void)
570 return dccp_stream_count
;
574 dccp_filter_valid(packet_info
*pinfo
, void *user_data _U_
)
576 return proto_is_frame_protocol(pinfo
->layers
, "dccp");
580 dccp_build_filter(packet_info
*pinfo
, void *user_data _U_
)
582 if( pinfo
->net_src
.type
== AT_IPv4
&& pinfo
->net_dst
.type
== AT_IPv4
) {
584 return ws_strdup_printf("(ip.addr eq %s and ip.addr eq %s) and (dccp.port eq %d and dccp.port eq %d)",
585 address_to_str(pinfo
->pool
, &pinfo
->net_src
),
586 address_to_str(pinfo
->pool
, &pinfo
->net_dst
),
587 pinfo
->srcport
, pinfo
->destport
);
590 if( pinfo
->net_src
.type
== AT_IPv6
&& pinfo
->net_dst
.type
== AT_IPv6
) {
592 return ws_strdup_printf("(ipv6.addr eq %s and ipv6.addr eq %s) and (dccp.port eq %d and dccp.port eq %d)",
593 address_to_str(pinfo
->pool
, &pinfo
->net_src
),
594 address_to_str(pinfo
->pool
, &pinfo
->net_dst
),
595 pinfo
->srcport
, pinfo
->destport
);
601 static char *dccp_follow_conv_filter(epan_dissect_t
*edt _U_
, packet_info
*pinfo
, unsigned *stream
, unsigned *sub_stream _U_
)
603 conversation_t
*conv
;
604 struct dccp_analysis
*dccpd
;
606 /* XXX: Since DCCP doesn't use the endpoint API, we can only look
607 * up using the current pinfo addresses and ports. We don't want
608 * to create a new conversation or stream.
609 * Eventually the endpoint API should support storing multiple
610 * endpoints and DCCP should be changed to use the endpoint API.
612 if (((pinfo
->net_src
.type
== AT_IPv4
&& pinfo
->net_dst
.type
== AT_IPv4
) ||
613 (pinfo
->net_src
.type
== AT_IPv6
&& pinfo
->net_dst
.type
== AT_IPv6
))
614 && (pinfo
->ptype
== PT_DCCP
) &&
615 (conv
=find_conversation(pinfo
->num
, &pinfo
->net_src
, &pinfo
->net_dst
, CONVERSATION_DCCP
, pinfo
->srcport
, pinfo
->destport
, 0)) != NULL
)
617 /* DCCP over IPv4/6 */
618 dccpd
= get_dccp_conversation_data(conv
, pinfo
);
619 *stream
= dccpd
->stream
;
620 return ws_strdup_printf("dccp.stream eq %u", dccpd
->stream
);
626 static char *dccp_follow_index_filter(unsigned stream
, unsigned sub_stream _U_
)
628 return ws_strdup_printf("dccp.stream eq %u", stream
);
631 static char *dccp_follow_address_filter(address
*src_addr
, address
*dst_addr
, int src_port
, int dst_port
)
633 const char *ip_version
= src_addr
->type
== AT_IPv6
? "v6" : "";
634 char src_addr_str
[WS_INET6_ADDRSTRLEN
];
635 char dst_addr_str
[WS_INET6_ADDRSTRLEN
];
637 address_to_str_buf(src_addr
, src_addr_str
, sizeof(src_addr_str
));
638 address_to_str_buf(dst_addr
, dst_addr_str
, sizeof(dst_addr_str
));
640 return ws_strdup_printf("((ip%s.src eq %s and dccp.srcport eq %d) and "
641 "(ip%s.dst eq %s and dccp.dstport eq %d))"
643 "((ip%s.src eq %s and dccp.srcport eq %d) and "
644 "(ip%s.dst eq %s and dccp.dstport eq %d))",
645 ip_version
, src_addr_str
, src_port
,
646 ip_version
, dst_addr_str
, dst_port
,
647 ip_version
, dst_addr_str
, dst_port
,
648 ip_version
, src_addr_str
, src_port
);
652 * decode a variable-length number of nbytes starting at offset. Based on
653 * a concept by Arnaldo de Melo
656 dccp_ntoh_var(tvbuff_t
*tvb
, int offset
, unsigned nbytes
)
663 value
= tvb_get_ntoh40(tvb
, offset
);
666 value
= tvb_get_ntohl(tvb
, offset
);
669 value
= tvb_get_ntoh24(tvb
, offset
);
672 value
= tvb_get_ntohs(tvb
, offset
);
675 value
= tvb_get_uint8(tvb
, offset
);
682 value
= tvb_get_ntoh48(tvb
, offset
);
690 dissect_feature_options(proto_tree
*dccp_options_tree
, tvbuff_t
*tvb
,
691 int offset
, uint8_t option_len
)
693 uint8_t feature_number
= tvb_get_uint8(tvb
, offset
);
694 proto_item
*dccp_item
;
695 proto_tree
*feature_tree
;
699 proto_tree_add_subtree_format(dccp_options_tree
, tvb
, offset
, option_len
,
700 ett_dccp_feature
, &dccp_item
, "%s(",
701 rval_to_str_const(feature_number
, dccp_feature_numbers_rvals
, "Unknown feature number"));
702 if (feature_number
!= 10)
703 proto_tree_add_uint(feature_tree
, hf_dccp_feature_number
, tvb
,
704 offset
, 1, feature_number
);
706 proto_tree_add_item(feature_tree
, hf_mpdccp_version
, tvb
,
707 offset
, option_len
, ENC_BIG_ENDIAN
);
712 * decode the feature according to whether it is server-priority (list)
713 * or NN (single number)
715 switch (feature_number
) {
717 /* Server Priority features (RFC 4340, 6.3.1) */
718 case 1: /* Congestion Control ID (CCID); fall through */
719 case 2: /* Allow Short Seqnums; fall through */
720 case 4: /* ECN Incapable; fall through */
721 case 6: /* Send Ack Vector; fall through */
722 case 7: /* Send NDP Count; fall through */
723 case 8: /* Minimum Checksum Coverage; fall through */
724 case 9: /* Check Data Checksum; fall through */
725 case 192: /* Send Loss Event Rate, RFC 4342, section 8.4 */
726 for (i
= 0; i
< option_len
; i
++)
727 proto_item_append_text(dccp_item
, "%s %d", i
? "," : "",
732 /* Non-negotiable features (RFC 4340, 6.3.2) */
734 case 3: /* Sequence Window; fall through */
735 case 5: /* Ack Ratio */
737 if (option_len
> 0) /* could be empty Confirm */
738 proto_item_append_text(dccp_item
, " %" PRIu64
,
739 dccp_ntoh_var(tvb
, offset
, option_len
));
742 /* Reserved, specific, or unknown features */
743 case 10: /* MP_CAPABLE; fall through */
744 for (i
= 0; i
< option_len
; i
++)
745 proto_item_append_text(dccp_item
, "%s %d", i
? "," : "", feature_number
);
748 proto_item_append_text(dccp_item
, "%d", feature_number
);
751 proto_item_append_text(dccp_item
, ")");
755 * This function dissects DCCP options
758 // NOLINTNEXTLINE(misc-no-recursion)
759 dissect_options(tvbuff_t
*tvb
, packet_info
*pinfo
,
760 proto_tree
*dccp_options_tree
, proto_tree
*tree _U_
,
761 e_dccphdr
*dccph _U_
,
766 * if here I'm sure there is at least offset_end - offset_start bytes
767 * in tvb and it should be options
769 int offset
= offset_start
;
770 uint8_t option_type
= 0;
771 uint8_t option_len
= 0;
773 uint8_t mp_option_type
= 0;
775 proto_item
*option_item
;
776 proto_tree
*option_tree
;
777 proto_item
*mp_option_sub_item
;
778 proto_tree
*mp_option_sub_tree
;
780 while (offset
< offset_end
) {
781 /* first byte is the option type */
782 option_type
= tvb_get_uint8(tvb
, offset
);
784 proto_tree_add_uint(dccp_options_tree
, hf_dccp_option_type
, tvb
,
788 if (option_type
>= 32) { /* variable length options */
789 option_len
= tvb_get_uint8(tvb
, offset
+1);
791 if (option_len
< 2) {
792 expert_add_info_format(pinfo
, option_item
, &ei_dccp_option_len_bad
,
793 "Option length incorrect, must be >= 2");
797 proto_item_set_len(option_item
, option_len
);
798 /* Remove the type and length fields out of length */
801 } else { /* 1byte options */
805 option_tree
= proto_item_add_subtree(option_item
, ett_dccp_options_item
);
806 switch (option_type
) {
808 proto_tree_add_item(option_tree
, hf_dccp_padding
, tvb
, offset
, option_len
, ENC_NA
);
811 proto_tree_add_item(option_tree
, hf_dccp_mandatory
, tvb
, offset
, option_len
, ENC_NA
);
814 proto_tree_add_item(option_tree
, hf_dccp_slow_receiver
, tvb
, offset
, option_len
, ENC_NA
);
820 dissect_feature_options(option_tree
, tvb
, offset
, option_len
);
823 proto_tree_add_item(option_tree
, hf_dccp_init_cookie
, tvb
, offset
, option_len
, ENC_NA
);
827 expert_add_info_format(pinfo
, option_item
, &ei_dccp_option_len_bad
,
828 "NDP Count too long (max 6 bytes)");
830 proto_tree_add_item(option_tree
, hf_dccp_ndp_count
, tvb
, offset
, option_len
, ENC_BIG_ENDIAN
);
833 proto_tree_add_item(option_tree
, hf_dccp_ack_vector_nonce_0
, tvb
, offset
, option_len
, ENC_NA
);
836 proto_tree_add_item(option_tree
, hf_dccp_ack_vector_nonce_1
, tvb
, offset
, option_len
, ENC_NA
);
839 proto_tree_add_item(option_tree
, hf_dccp_data_dropped
, tvb
, offset
, option_len
, ENC_NA
);
843 proto_tree_add_item(option_tree
, hf_dccp_timestamp
, tvb
,
844 offset
, 4, ENC_BIG_ENDIAN
);
846 expert_add_info_format(pinfo
, option_item
, &ei_dccp_option_len_bad
,
847 "Timestamp too long [%u != 4]", option_len
);
851 proto_tree_add_item(option_tree
, hf_dccp_timestamp_echo
,
852 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
853 else if (option_len
== 6) {
854 proto_tree_add_item(option_tree
, hf_dccp_timestamp_echo
,
855 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
856 proto_tree_add_item(option_tree
, hf_dccp_elapsed_time
,
857 tvb
, offset
+ 4, 2, ENC_BIG_ENDIAN
);
858 } else if (option_len
== 8) {
859 proto_tree_add_item(option_tree
, hf_dccp_timestamp_echo
,
860 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
861 proto_tree_add_item(option_tree
, hf_dccp_elapsed_time
,
862 tvb
, offset
+ 4, 4, ENC_BIG_ENDIAN
);
864 expert_add_info_format(pinfo
, option_item
, &ei_dccp_option_len_bad
,
865 "Wrong Timestamp Echo length");
869 proto_tree_add_item(option_tree
, hf_dccp_elapsed_time
,
870 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
871 else if (option_len
== 4)
872 proto_tree_add_item(option_tree
, hf_dccp_elapsed_time
,
873 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
875 expert_add_info_format(pinfo
, option_item
, &ei_dccp_option_len_bad
,
876 "Wrong Elapsed Time length");
879 if (option_len
== 4) {
880 proto_tree_add_item(option_tree
, hf_dccp_data_checksum
,
881 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
883 expert_add_info_format(pinfo
, option_item
, &ei_dccp_option_len_bad
,
884 "Wrong Data checksum length");
887 mp_option_type
= tvb_get_uint8(tvb
, offset
);
889 switch (mp_option_type
) {
891 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_mpdccp_confirm
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
892 mp_option_sub_tree
= proto_item_add_subtree(mp_option_sub_item
, ett_dccp_options_item
);
894 // We recurse here, but we'll run out of packet before we run out of stack.
895 dissect_options(tvb
, pinfo
, mp_option_sub_tree
, tree
, dccph
, offset
, offset
+ option_len
);
898 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_mpdccp_join
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
899 mp_option_sub_tree
= proto_item_add_subtree(mp_option_sub_item
, ett_dccp_options_item
);
901 if (option_len
== 9) {
902 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_join_id
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
903 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_join_token
, tvb
, offset
+1, 4, ENC_BIG_ENDIAN
);
904 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_join_nonce
, tvb
, offset
+5, 4, ENC_BIG_ENDIAN
);
906 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_dccp_option_data
, tvb
, offset
, option_len
, ENC_NA
);
907 expert_add_info_format(pinfo
, mp_option_sub_item
, &ei_dccp_option_len_bad
,
908 "Wrong Data checksum length, [%u != 9]", option_len
);
912 proto_tree_add_item(option_tree
, hf_mpdccp_fast_close
, tvb
, offset
, option_len
, ENC_NA
);
915 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_mpdccp_key
, tvb
, offset
, 1, ENC_NA
);
916 mp_option_sub_tree
= proto_item_add_subtree(mp_option_sub_item
, ett_dccp_options_item
);
918 if (option_len
> 8 && option_len
< 69) {
919 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_key_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
920 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_key_key
, tvb
, offset
+1, option_len
-1, ENC_NA
);
922 mp_option_sub_item
= proto_tree_add_item(mp_option_sub_tree
, hf_dccp_option_data
, tvb
, offset
, option_len
, ENC_NA
);
923 expert_add_info_format(pinfo
, mp_option_sub_item
, &ei_dccp_option_len_bad
,
924 "Wrong Data checksum length, [8 < %u < 69]", option_len
);
928 if (option_len
== 6) {
930 proto_tree_add_item(option_tree
, hf_mpdccp_seq
, tvb
, offset
, 6, ENC_BIG_ENDIAN
);
932 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_mpdccp_seq
, tvb
, offset
, option_len
, ENC_BIG_ENDIAN
);
933 expert_add_info_format(pinfo
, mp_option_sub_item
, &ei_dccp_option_len_bad
,
934 "Wrong Data checksum length, [%u != 6]", option_len
);
938 if (option_len
== 20) {
939 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_mpdccp_hmac
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
940 mp_option_sub_tree
= proto_item_add_subtree(mp_option_sub_item
, ett_dccp_options_item
);
942 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_hmac_sha
, tvb
, offset
, 20, ENC_NA
);
944 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_mpdccp_hmac
, tvb
, offset
, option_len
, ENC_BIG_ENDIAN
);
945 expert_add_info_format(pinfo
, mp_option_sub_item
, &ei_dccp_option_len_bad
,
946 "Wrong Data checksum length, [%u != 20]", option_len
);
950 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_mpdccp_rtt
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
951 mp_option_sub_tree
= proto_item_add_subtree(mp_option_sub_item
, ett_dccp_options_item
);
953 if (option_len
== 9) {
954 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_rtt_type
,tvb
, offset
, 1, ENC_BIG_ENDIAN
);
955 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_rtt_value
,tvb
, offset
+1, 4, ENC_BIG_ENDIAN
);
956 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_rtt_age
,tvb
, offset
+5, 4, ENC_BIG_ENDIAN
);
958 mp_option_sub_item
= proto_tree_add_item(mp_option_sub_tree
, hf_dccp_option_data
, tvb
, offset
, option_len
, ENC_NA
);
959 expert_add_info_format(pinfo
, mp_option_sub_item
, &ei_dccp_option_len_bad
,
960 "Wrong Data checksum length, [%u != 9]", option_len
);
964 mp_option_sub_item
=proto_tree_add_item(option_tree
,hf_mpdccp_addaddr
,tvb
,offset
,1,ENC_BIG_ENDIAN
);
965 mp_option_sub_tree
= proto_item_add_subtree(mp_option_sub_item
, ett_dccp_options_item
);
967 switch (option_len
) {
969 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addrid
,tvb
,offset
,1,ENC_BIG_ENDIAN
);
970 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addr_dec
,tvb
,offset
+1,4,ENC_LITTLE_ENDIAN
);
973 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addrid
,tvb
,offset
,1,ENC_BIG_ENDIAN
);
974 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addr_dec
,tvb
,offset
+1,4,ENC_LITTLE_ENDIAN
);
975 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addrport
,tvb
,offset
+5,2,ENC_BIG_ENDIAN
);
977 case 17:// Check endianness for ipv6
978 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addrid
,tvb
,offset
,1,ENC_BIG_ENDIAN
);
979 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addr_hex
,tvb
,offset
+1,16,ENC_NA
);
982 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addrid
,tvb
,offset
,1,ENC_BIG_ENDIAN
);
983 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addr_hex
,tvb
,offset
+1,16,ENC_NA
);
984 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addrport
,tvb
,offset
+17,2,ENC_BIG_ENDIAN
);
987 mp_option_sub_item
= proto_tree_add_item(mp_option_sub_tree
, hf_dccp_option_data
, tvb
, offset
, option_len
, ENC_NA
);
988 expert_add_info_format(pinfo
, mp_option_sub_item
, &ei_dccp_option_len_bad
,
989 "Wrong Data checksum length, [%u != 5 || 7 || 17 || 19]", option_len
);
994 if (option_len
== 1) {
995 mp_option_sub_item
=proto_tree_add_item(option_tree
,hf_mpdccp_removeaddr
,tvb
,offset
,1,ENC_BIG_ENDIAN
);
996 mp_option_sub_tree
= proto_item_add_subtree(mp_option_sub_item
, ett_dccp_options_item
);
998 proto_tree_add_item(mp_option_sub_tree
,hf_mpdccp_addrid
,tvb
,offset
,1,ENC_BIG_ENDIAN
);
1001 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_mpdccp_removeaddr
, tvb
, offset
, option_len
, ENC_BIG_ENDIAN
);
1002 expert_add_info_format(pinfo
, mp_option_sub_item
, &ei_dccp_option_len_bad
,
1003 "Wrong Data checksum length, [%u != 1]", option_len
);
1007 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_mpdccp_prio
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1008 mp_option_sub_tree
= proto_item_add_subtree(mp_option_sub_item
, ett_dccp_options_item
);
1010 if (option_len
== 1) {
1011 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_prio_value
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1013 mp_option_sub_item
= proto_tree_add_item(mp_option_sub_tree
, hf_dccp_option_data
, tvb
, offset
, option_len
, ENC_NA
);
1014 expert_add_info_format(pinfo
, mp_option_sub_item
, &ei_dccp_option_len_bad
,
1015 "Wrong Data checksum length, [%u != 1]", option_len
);
1019 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_mpdccp_close
,
1020 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1021 mp_option_sub_tree
= proto_item_add_subtree(mp_option_sub_item
, ett_dccp_options_item
);
1023 proto_tree_add_item(mp_option_sub_tree
, hf_mpdccp_close_key
, tvb
, offset
, option_len
, ENC_BIG_ENDIAN
);
1026 proto_tree_add_item(option_tree
, hf_mpdccp_exp
, tvb
, offset
, option_len
, ENC_NA
);
1029 mp_option_sub_item
= proto_tree_add_item(option_tree
, hf_dccp_option_data
, tvb
, offset
, option_len
, ENC_NA
);
1030 expert_add_info_format(pinfo
, mp_option_sub_item
, &ei_dccp_option_len_bad
,
1031 "MP-DCCP option [%u] not defined, [len: %u ]", mp_option_type
, option_len
);
1037 case 192: /* RFC 4342, 8.5 */
1038 if (option_len
== 4) {
1039 p
= tvb_get_ntohl(tvb
, offset
);
1041 * According to the comment in section 8.5 of RFC 4342,
1042 * 0xffffffff can mean zero
1044 if (p
== 0xFFFFFFFF)
1045 proto_tree_add_uint_format_value(option_tree
, hf_dccp_ccid3_loss_event_rate
, tvb
, offset
,
1046 option_len
, p
, "0 (or max)");
1048 proto_tree_add_uint(option_tree
, hf_dccp_ccid3_loss_event_rate
, tvb
, offset
, option_len
, p
);
1050 expert_add_info_format(pinfo
, option_item
, &ei_dccp_option_len_bad
,
1051 "Wrong CCID3 Loss Event Rate length");
1053 case 193: /* RFC 4342, 8.6 */
1054 proto_tree_add_item(dccp_options_tree
, hf_dccp_ccid3_loss_intervals
, tvb
, offset
, option_len
, ENC_NA
);
1056 * FIXME: not implemented and apparently not used by any
1057 * implementation so far
1060 case 194: /* RFC 4342, 8.3 */
1061 if (option_len
== 4)
1062 proto_tree_add_uint_format_value(option_tree
, hf_dccp_ccid3_receive_rate
, tvb
, offset
, option_len
,
1063 tvb_get_ntohl(tvb
, offset
), "%u bytes/sec",
1064 tvb_get_ntohl(tvb
, offset
));
1066 expert_add_info_format(pinfo
, option_item
, &ei_dccp_option_len_bad
,
1067 "Wrong CCID3 Receive Rate length");
1070 if (((option_type
>= 47) && (option_type
<= 127)) ||
1071 ((option_type
>= 3) && (option_type
<= 31))) {
1072 proto_tree_add_item(option_tree
, hf_dccp_option_reserved
, tvb
, offset
, option_len
, ENC_NA
);
1076 if (option_type
>= 128) {
1077 proto_tree_add_bytes_format(option_tree
, hf_dccp_ccid_option_data
, tvb
, offset
, option_len
,
1078 NULL
, "CCID option %d", option_type
);
1082 /* if here we don't know this option */
1083 proto_tree_add_item(option_tree
, hf_dccp_option_unknown
, tvb
, offset
, option_len
, ENC_NA
);
1085 } /* end switch() */
1086 offset
+= option_len
; /* move offset past the dissected option */
1091 * compute DCCP checksum coverage according to RFC 4340, section 9
1093 static inline unsigned
1094 dccp_csum_coverage(const e_dccphdr
*dccph
, unsigned len
)
1098 if (dccph
->cscov
== 0)
1101 cov
= (dccph
->data_offset
+ dccph
->cscov
- 1) * (unsigned)sizeof (uint32_t);
1102 return (cov
> len
) ? len
: cov
;
1106 dissect_dccp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
1108 proto_tree
*dccp_tree
;
1110 proto_tree
*dccp_options_tree
= NULL
;
1111 proto_item
*dccp_item
= NULL
;
1112 proto_item
*hidden_item
, *offset_item
;
1115 unsigned offset
= 0;
1117 unsigned reported_len
= 0;
1118 unsigned csum_coverage_len
;
1119 unsigned advertised_dccp_header_len
= 0;
1120 unsigned options_len
= 0;
1121 uint64_t seq
; /* Absolute or relative seq number (depending on DCCP_S_BASE_SEQ_SET) */
1122 uint64_t ack
; /* Absolute or relative ack number (depending on DCCP_S_BASE_SEQ_SET) */
1124 conversation_t
*conv
= NULL
;
1125 struct dccp_analysis
*dccpd
;
1127 dccph
= wmem_new0(pinfo
->pool
, e_dccphdr
);
1128 dccph
->sport
= tvb_get_ntohs(tvb
, offset
);
1129 dccph
->dport
= tvb_get_ntohs(tvb
, offset
+ 2);
1130 copy_address_shallow(&dccph
->ip_src
, &pinfo
->src
);
1131 copy_address_shallow(&dccph
->ip_dst
, &pinfo
->dst
);
1133 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "DCCP");
1134 col_clear(pinfo
->cinfo
, COL_INFO
);
1135 col_append_ports(pinfo
->cinfo
, COL_INFO
, PT_DCCP
, dccph
->sport
, dccph
->dport
);
1137 dccp_item
= proto_tree_add_item(tree
, proto_dccp
, tvb
, offset
, -1, ENC_NA
);
1138 if (dccp_summary_in_tree
&& tree
) {
1139 proto_item_append_text(dccp_item
, ", Src Port: %s, Dst Port: %s",
1140 port_with_resolution_to_str(pinfo
->pool
, PT_DCCP
, dccph
->sport
),
1141 port_with_resolution_to_str(pinfo
->pool
, PT_DCCP
, dccph
->dport
));
1143 dccp_tree
= proto_item_add_subtree(dccp_item
, ett_dccp
);
1145 proto_tree_add_item(dccp_tree
, hf_dccp_srcport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1146 hidden_item
= proto_tree_add_item(dccp_tree
, hf_dccp_port
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1147 proto_item_set_hidden(hidden_item
);
1150 proto_tree_add_item(dccp_tree
, hf_dccp_dstport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1151 hidden_item
= proto_tree_add_item(dccp_tree
, hf_dccp_port
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1152 proto_item_set_hidden(hidden_item
);
1156 * update pinfo structure. I guess I have to do it, because this
1157 * is a transport protocol dissector.
1159 pinfo
->ptype
= PT_DCCP
;
1160 pinfo
->srcport
= dccph
->sport
;
1161 pinfo
->destport
= dccph
->dport
;
1163 /* find (or create if needed) the conversation for this DCCP session */
1164 conv
= find_or_create_conversation(pinfo
);
1165 dccpd
= get_dccp_conversation_data(conv
, pinfo
);
1166 item
= proto_tree_add_uint(dccp_tree
, hf_dccp_stream
, tvb
, offset
, 0, dccpd
->stream
);
1167 proto_item_set_generated(item
);
1169 /* Copy the stream index into the header as well to make it available
1172 dccph
->stream
= dccpd
->stream
;
1174 dccph
->data_offset
= tvb_get_uint8(tvb
, offset
);
1175 advertised_dccp_header_len
= dccph
->data_offset
* 4;
1176 offset_item
= proto_tree_add_uint(dccp_tree
, hf_dccp_data_offset
, tvb
, offset
, 1,
1177 dccph
->data_offset
);
1180 dccph
->cscov
= tvb_get_uint8(tvb
, offset
) & 0x0F;
1181 dccph
->ccval
= tvb_get_uint8(tvb
, offset
) & 0xF0;
1183 proto_tree_add_uint(dccp_tree
, hf_dccp_ccval
, tvb
, offset
, 1,
1185 proto_tree_add_uint(dccp_tree
, hf_dccp_cscov
, tvb
, offset
, 1,
1189 dccph
->checksum
= tvb_get_ntohs(tvb
, offset
);
1192 * checksum analysis taken from packet-udp (difference: mandatory
1193 * checksums in DCCP)
1195 reported_len
= tvb_reported_length(tvb
);
1196 len
= tvb_captured_length(tvb
);
1197 csum_coverage_len
= dccp_csum_coverage(dccph
, reported_len
);
1199 if (dccp_check_checksum
&& !pinfo
->fragmented
&& len
>= csum_coverage_len
) {
1200 /* We're supposed to check the checksum, and the packet isn't part
1201 * of a fragmented datagram and isn't truncated, so we can checksum it.
1202 * XXX - make a bigger scatter-gather list once we do fragment
1204 /* Set up the fields of the pseudo-header. */
1205 SET_CKSUM_VEC_PTR(cksum_vec
[0], (const uint8_t *)pinfo
->src
.data
, pinfo
->src
.len
);
1206 SET_CKSUM_VEC_PTR(cksum_vec
[1], (const uint8_t *)pinfo
->dst
.data
, pinfo
->dst
.len
);
1207 switch (pinfo
->src
.type
) {
1209 phdr
[0] = g_htonl((IP_PROTO_DCCP
<< 16) + reported_len
);
1210 SET_CKSUM_VEC_PTR(cksum_vec
[2], (const uint8_t *) &phdr
, 4);
1213 phdr
[0] = g_htonl(reported_len
);
1214 phdr
[1] = g_htonl(IP_PROTO_DCCP
);
1215 SET_CKSUM_VEC_PTR(cksum_vec
[2], (const uint8_t *) &phdr
, 8);
1219 /* DCCP runs only atop IPv4 and IPv6... */
1220 DISSECTOR_ASSERT_NOT_REACHED();
1223 SET_CKSUM_VEC_TVB(cksum_vec
[3], tvb
, 0, csum_coverage_len
);
1224 proto_tree_add_checksum(dccp_tree
, tvb
, offset
, hf_dccp_checksum
, hf_dccp_checksum_status
, &ei_dccp_checksum
, pinfo
, in_cksum(&cksum_vec
[0], 4),
1225 ENC_BIG_ENDIAN
, PROTO_CHECKSUM_VERIFY
|PROTO_CHECKSUM_IN_CKSUM
);
1227 proto_tree_add_checksum(dccp_tree
, tvb
, offset
, hf_dccp_checksum
, hf_dccp_checksum_status
, &ei_dccp_checksum
, pinfo
, 0,
1228 ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
1232 dccph
->reserved1
= tvb_get_uint8(tvb
, offset
) & 0xE0;
1233 dccph
->reserved1
>>= 5;
1235 proto_tree_add_uint(dccp_tree
, hf_dccp_res1
, tvb
, offset
, 1,
1237 proto_item_set_hidden(hidden_item
);
1239 dccph
->type
= tvb_get_uint8(tvb
, offset
) & 0x1E;
1241 proto_tree_add_uint(dccp_tree
, hf_dccp_type
, tvb
, offset
, 1,
1243 if (dccp_summary_in_tree
) {
1244 proto_item_append_text(dccp_item
, " [%s]",
1245 val_to_str_const(dccph
->type
, dccp_packet_type_vals
,
1248 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " [%s]",
1249 val_to_str_const(dccph
->type
, dccp_packet_type_vals
,
1252 dccph
->x
= tvb_get_uint8(tvb
, offset
) & 0x01;
1253 proto_tree_add_boolean(dccp_tree
, hf_dccp_x
, tvb
, offset
, 1,
1258 if (advertised_dccp_header_len
< DCCP_GEN_HDR_LEN_X
) {
1259 expert_add_info_format(pinfo
, offset_item
, &ei_dccp_advertised_header_length_bad
,
1260 "Advertised header length (%u) is smaller than the minimum (%u)",
1261 advertised_dccp_header_len
, DCCP_GEN_HDR_LEN_X
);
1262 return tvb_reported_length(tvb
);
1264 dccph
->reserved2
= tvb_get_uint8(tvb
, offset
);
1266 proto_tree_add_uint(dccp_tree
, hf_dccp_res2
, tvb
, offset
, 1,
1268 proto_item_set_hidden(hidden_item
);
1271 dccph
->seq
= tvb_get_ntoh48(tvb
, offset
);
1272 if((dccp_relative_seq
) && (dccpd
->fwd
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1273 seq
= dccph
->seq
- dccpd
->fwd
->base_seq
;
1274 proto_tree_add_uint64_format_value(dccp_tree
, hf_dccp_seq
, tvb
, offset
, 6,
1275 seq
, "%" PRIu64
" (relative sequence number)", seq
);
1280 proto_tree_add_uint64(dccp_tree
, hf_dccp_seq_abs
, tvb
, offset
, 6, dccph
->seq
);
1284 if (advertised_dccp_header_len
< DCCP_GEN_HDR_LEN_NO_X
) {
1285 expert_add_info_format(pinfo
, offset_item
, &ei_dccp_advertised_header_length_bad
,
1286 "Advertised header length (%u) is smaller than the minimum (%u)",
1287 advertised_dccp_header_len
, DCCP_GEN_HDR_LEN_NO_X
);
1288 return tvb_reported_length(tvb
);
1290 dccph
->seq
= tvb_get_ntoh24(tvb
, offset
);
1291 proto_tree_add_uint64(dccp_tree
, hf_dccp_seq
, tvb
, offset
, 3, dccph
->seq
);
1292 if((dccp_relative_seq
) && (dccpd
->fwd
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1293 seq
= (dccph
->seq
- dccpd
->fwd
->base_seq
) & 0xffffff;
1294 proto_tree_add_uint64_format_value(dccp_tree
, hf_dccp_seq
, tvb
, offset
, 3,
1295 seq
, "%" PRIu64
" (relative sequence number)", seq
);
1302 if (dccp_summary_in_tree
) {
1303 proto_item_append_text(dccp_item
, " Seq=%" PRIu64
, seq
);
1305 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " Seq=%" PRIu64
, seq
);
1307 /* dissecting type dependent additional fields */
1308 switch (dccph
->type
) {
1309 case 0x0: /* DCCP-Request */
1310 case 0xA: /* DCCP-Listen */
1311 if (advertised_dccp_header_len
< offset
+ 4) {
1312 expert_add_info_format(pinfo
, offset_item
, &ei_dccp_advertised_header_length_bad
,
1313 "Advertised header length (%u) is smaller than the minimum (%u) for %s",
1314 advertised_dccp_header_len
, offset
+ 4,
1315 val_to_str(dccph
->type
, dccp_packet_type_vals
, "Unknown (%u)"));
1316 return tvb_reported_length(tvb
);
1318 dccph
->service_code
= tvb_get_ntohl(tvb
, offset
);
1320 proto_tree_add_uint(dccp_tree
, hf_dccp_service_code
, tvb
, offset
, 4,
1321 dccph
->service_code
);
1322 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (service=%s)",
1323 val_to_str(dccph
->service_code
, dccp_service_code_vals
, "Unknown (%u)"));
1324 offset
+= 4; /* move offset past the service code */
1326 if( !(dccpd
->fwd
->static_flags
& DCCP_S_BASE_SEQ_SET
) ) {
1327 dccpd
->fwd
->base_seq
= dccph
->seq
;
1328 dccpd
->fwd
->static_flags
|= DCCP_S_BASE_SEQ_SET
;
1332 case 0x1: /* DCCP-Response */
1333 if (advertised_dccp_header_len
< offset
+ 12) {
1334 expert_add_info_format(pinfo
, offset_item
, &ei_dccp_advertised_header_length_bad
,
1335 "Advertised header length (%u) is smaller than the minimum (%u) for Response",
1336 advertised_dccp_header_len
, offset
+ 12);
1337 return tvb_reported_length(tvb
);
1339 dccph
->ack_reserved
= tvb_get_ntohs(tvb
, offset
);
1342 proto_tree_add_uint(dccp_tree
, hf_dccp_ack_res
, tvb
, offset
, 2,
1343 dccph
->ack_reserved
);
1344 proto_item_set_hidden(hidden_item
);
1346 dccph
->ack
= tvb_get_ntohs(tvb
, offset
+ 2);
1348 dccph
->ack
+= tvb_get_ntohl(tvb
, offset
+ 4);
1350 if((dccp_relative_seq
) && (dccpd
->rev
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1351 ack
= dccph
->ack
- dccpd
->rev
->base_seq
;
1358 if((dccp_relative_seq
) && (dccpd
->rev
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1359 proto_tree_add_uint64(dccp_tree
, hf_dccp_ack
, tvb
, offset
+ 2, 6, ack
);
1361 proto_tree_add_uint64(dccp_tree
, hf_dccp_ack_abs
, tvb
, offset
+ 2, 6, dccph
->ack
);
1363 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (Ack=%" PRIu64
")", ack
);
1364 offset
+= 8; /* move offset past the Acknowledgement Number Subheader */
1366 dccph
->service_code
= tvb_get_ntohl(tvb
, offset
);
1368 proto_tree_add_uint(dccp_tree
, hf_dccp_service_code
, tvb
, offset
, 4,
1369 dccph
->service_code
);
1370 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (service=%s)",
1371 val_to_str(dccph
->service_code
, dccp_service_code_vals
, "Unknown (%u)"));
1373 offset
+= 4; /* move offset past the service code */
1375 if( !(dccpd
->fwd
->static_flags
& DCCP_S_BASE_SEQ_SET
) ) {
1376 dccpd
->fwd
->base_seq
= dccph
->seq
;
1377 dccpd
->fwd
->static_flags
|= DCCP_S_BASE_SEQ_SET
;
1381 case 0x2: /* DCCP-Data */
1382 /* nothing to dissect */
1384 case 0x3: /* DCCP-Ack */
1385 case 0x4: /* DCCP-DataAck */
1387 if (advertised_dccp_header_len
< offset
+ 8) {
1388 expert_add_info_format(pinfo
, offset_item
, &ei_dccp_advertised_header_length_bad
,
1389 "Advertised header length (%u) is smaller than the minimum (%u) for %s",
1390 advertised_dccp_header_len
, offset
+ 8,
1391 val_to_str(dccph
->type
, dccp_packet_type_vals
, "Unknown (%u)"));
1392 return tvb_reported_length(tvb
);
1394 dccph
->ack_reserved
= tvb_get_ntohs(tvb
, offset
);
1397 proto_tree_add_uint(dccp_tree
, hf_dccp_ack_res
, tvb
, offset
,
1398 2, dccph
->ack_reserved
);
1399 proto_item_set_hidden(hidden_item
);
1401 dccph
->ack
= tvb_get_ntohs(tvb
, offset
+ 2);
1403 dccph
->ack
+= tvb_get_ntohl(tvb
, offset
+ 4);
1405 if((dccp_relative_seq
) && (dccpd
->rev
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1406 ack
= dccph
->ack
- dccpd
->rev
->base_seq
;
1413 if((dccp_relative_seq
) && (dccpd
->rev
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1414 proto_tree_add_uint64_format_value(dccp_tree
, hf_dccp_ack
, tvb
, offset
+ 2, 6,
1415 ack
, "%" PRIu64
" (relative acknowledgement number)", ack
);
1417 proto_tree_add_uint64(dccp_tree
, hf_dccp_ack_abs
, tvb
, offset
+ 2, 6, dccph
->ack
);
1419 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (Ack=%" PRIu64
")", ack
);
1420 offset
+= 8; /* move offset past the Ack Number Subheader */
1422 if (advertised_dccp_header_len
< offset
+ 4) {
1423 expert_add_info_format(pinfo
, offset_item
, &ei_dccp_advertised_header_length_bad
,
1424 "Advertised header length (%u) is smaller than the minimum (%u) for %s",
1425 advertised_dccp_header_len
, offset
+ 4,
1426 val_to_str(dccph
->type
, dccp_packet_type_vals
, "Unknown (%u)"));
1427 return tvb_reported_length(tvb
);
1429 dccph
->ack_reserved
= tvb_get_uint8(tvb
, offset
);
1432 proto_tree_add_uint(dccp_tree
, hf_dccp_ack_res
, tvb
, offset
,
1433 1, dccph
->ack_reserved
);
1434 proto_item_set_hidden(hidden_item
);
1436 dccph
->ack
= tvb_get_uint8(tvb
, offset
+ 1);
1438 dccph
->ack
+= tvb_get_ntohs(tvb
, offset
+ 2);
1440 if((dccp_relative_seq
) && (dccpd
->rev
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1441 ack
= (dccph
->ack
- dccpd
->rev
->base_seq
) & 0xffffff;
1448 if((dccp_relative_seq
) && (dccpd
->rev
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1449 proto_tree_add_uint64_format_value(dccp_tree
, hf_dccp_ack
, tvb
, offset
+ 1, 3,
1450 ack
, "%" PRIu64
" (relative acknowledgement number)", ack
);
1452 proto_tree_add_uint64(dccp_tree
, hf_dccp_ack_abs
, tvb
, offset
+ 1, 3, dccph
->ack
);
1454 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (Ack=%" PRIu64
")", ack
);
1455 offset
+= 4; /* move offset past the Ack. Number Subheader */
1458 case 0x7: /* DCCP-Reset */
1459 if (advertised_dccp_header_len
< offset
+ 4) {
1460 expert_add_info_format(pinfo
, offset_item
, &ei_dccp_advertised_header_length_bad
,
1461 "Advertised header length (%u) is smaller than the minimum (%u) for Reset",
1462 advertised_dccp_header_len
, offset
+ 4);
1463 return tvb_reported_length(tvb
);
1465 dccph
->ack_reserved
= tvb_get_ntohs(tvb
, offset
);
1469 proto_tree_add_uint(dccp_tree
, hf_dccp_ack_res
, tvb
, offset
, 2,
1470 dccph
->ack_reserved
);
1471 proto_item_set_hidden(hidden_item
);
1474 dccph
->ack
= tvb_get_ntohs(tvb
, offset
+ 2);
1476 dccph
->ack
+= tvb_get_ntohl(tvb
, offset
+ 4);
1478 if((dccp_relative_seq
) && (dccpd
->rev
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1479 ack
= (dccph
->ack
- dccpd
->rev
->base_seq
) & 0xffffff;
1486 if((dccp_relative_seq
) && (dccpd
->rev
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1487 proto_tree_add_uint64_format_value(dccp_tree
, hf_dccp_ack
, tvb
, offset
+ 1, 3,
1488 ack
, "%" PRIu64
" (relative acknowledgement number)", ack
);
1490 proto_tree_add_uint64(dccp_tree
, hf_dccp_ack_abs
, tvb
, offset
+ 1, 3, dccph
->ack
);
1492 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (Ack=%" PRIu64
")", ack
);
1493 offset
+= 8; /* move offset past the Ack. Number Subheader */
1495 dccph
->reset_code
= tvb_get_uint8(tvb
, offset
);
1496 dccph
->data1
= tvb_get_uint8(tvb
, offset
+ 1);
1497 dccph
->data2
= tvb_get_uint8(tvb
, offset
+ 2);
1498 dccph
->data3
= tvb_get_uint8(tvb
, offset
+ 3);
1501 proto_tree_add_uint(dccp_tree
, hf_dccp_reset_code
, tvb
, offset
, 1,
1503 proto_tree_add_uint(dccp_tree
, hf_dccp_data1
, tvb
, offset
+ 1, 1,
1505 proto_tree_add_uint(dccp_tree
, hf_dccp_data2
, tvb
, offset
+ 2, 1,
1507 proto_tree_add_uint(dccp_tree
, hf_dccp_data3
, tvb
, offset
+ 3, 1,
1510 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (code=%s)",
1511 val_to_str_const(dccph
->reset_code
, dccp_reset_code_vals
,
1514 offset
+= 4; /* move offset past the Reset Code and data123 */
1516 case 0x5: /* DCCP-CloseReq */
1517 case 0x6: /* DCCP-Close */
1518 case 0x8: /* DCCP-Sync */
1519 case 0x9: /* DCCP-SyncAck */
1520 if (advertised_dccp_header_len
< offset
+ 8) {
1521 expert_add_info_format(pinfo
, offset_item
, &ei_dccp_advertised_header_length_bad
,
1522 "Advertised header length (%u) is smaller than the minimum (%u) for %s",
1523 advertised_dccp_header_len
, offset
+ 8,
1524 val_to_str(dccph
->type
, dccp_packet_type_vals
, "Unknown (%u)"));
1525 return tvb_reported_length(tvb
);
1527 dccph
->ack_reserved
= tvb_get_ntohs(tvb
, offset
);
1530 proto_tree_add_uint(dccp_tree
, hf_dccp_ack_res
, tvb
, offset
, 2,
1531 dccph
->ack_reserved
);
1532 proto_item_set_hidden(hidden_item
);
1534 dccph
->ack
= tvb_get_ntohs(tvb
, offset
+ 2);
1536 dccph
->ack
+= tvb_get_ntohl(tvb
, offset
+ 4);
1538 if((dccp_relative_seq
) && (dccpd
->rev
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1539 ack
= (dccph
->ack
- dccpd
->rev
->base_seq
) & 0xffffff;
1546 if((dccp_relative_seq
) && (dccpd
->rev
->static_flags
& DCCP_S_BASE_SEQ_SET
)) {
1547 proto_tree_add_uint64_format_value(dccp_tree
, hf_dccp_ack
, tvb
, offset
+ 1, 3,
1548 ack
, "%" PRIu64
" (relative acknowledgement number)", ack
);
1550 proto_tree_add_uint64(dccp_tree
, hf_dccp_ack_abs
, tvb
, offset
+ 1, 3, dccph
->ack
);
1552 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (Ack=%" PRIu64
")", ack
);
1553 offset
+= 8; /* move offset past the Ack. Number Subheader */
1556 expert_add_info(pinfo
, dccp_item
, &ei_dccp_packet_type_reserved
);
1557 return tvb_reported_length(tvb
);
1561 * note: data_offset is the offset from the start of the packet's
1562 * DCCP header to the start of its application data area, in 32-bit words.
1564 if (advertised_dccp_header_len
> DCCP_HDR_LEN_MAX
) {
1565 expert_add_info_format(pinfo
, offset_item
, &ei_dccp_advertised_header_length_bad
,
1566 "Advertised header length (%u) is larger than the maximum (%u)",
1567 advertised_dccp_header_len
, DCCP_HDR_LEN_MAX
);
1568 return tvb_reported_length(tvb
);
1572 * The checks done above ensure that
1573 * advertised_dccp_header_len >= offset.
1575 * advertised_dccp_header_len - offset is the number of bytes of
1578 if (advertised_dccp_header_len
> offset
) {
1579 options_len
= advertised_dccp_header_len
- offset
;
1582 proto_tree_add_none_format(dccp_tree
, hf_dccp_options
, tvb
,
1584 options_len
, "Options: (%u byte%s)",
1586 plurality(options_len
, "", "s"));
1587 dccp_options_tree
= proto_item_add_subtree(dccp_item
,
1590 dissect_options(tvb
, pinfo
, dccp_options_tree
, tree
, dccph
, offset
,
1591 offset
+ options_len
);
1594 offset
+= options_len
; /* move offset past the Options */
1595 proto_item_set_end(dccp_item
, tvb
, offset
);
1597 /* queuing tap data */
1598 tap_queue_packet(dccp_tap
, pinfo
, dccph
);
1600 /* call sub-dissectors */
1601 if (!pinfo
->flags
.in_error_pkt
|| tvb_reported_length_remaining(tvb
, offset
) > 0)
1602 decode_dccp_ports(tvb
, offset
, pinfo
, tree
, dccph
->sport
, dccph
->dport
);
1604 return tvb_reported_length(tvb
);
1610 dccp_stream_count
= 0;
1614 proto_register_dccp(void)
1616 module_t
*dccp_module
;
1618 static hf_register_info hf
[] = {
1622 "Source Port", "dccp.srcport",
1623 FT_UINT16
, BASE_PT_DCCP
, NULL
, 0x0,
1630 "Destination Port", "dccp.dstport",
1631 FT_UINT16
, BASE_PT_DCCP
, NULL
, 0x0,
1638 "Source or Destination Port", "dccp.port",
1639 FT_UINT16
, BASE_PT_DCCP
, NULL
, 0x0,
1646 "Stream index", "dccp.stream",
1647 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1652 &hf_dccp_data_offset
,
1654 "Data Offset", "dccp.data_offset",
1655 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1662 "CCVal", "dccp.ccval",
1663 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1670 "Checksum Coverage", "dccp.cscov",
1671 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1676 &hf_dccp_checksum_status
,
1678 "Checksum Status", "dccp.checksum.status",
1679 FT_UINT8
, BASE_NONE
, VALS(proto_checksum_vals
), 0x0,
1686 "Checksum", "dccp.checksum",
1687 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
1694 "Reserved", "dccp.res1",
1695 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1702 "Reserved", "dccp.res2",
1703 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1710 "Type", "dccp.type",
1711 FT_UINT8
, BASE_DEC
, VALS(dccp_packet_type_vals
), 0x0,
1718 "Extended Sequence Numbers", "dccp.x",
1719 FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0,
1726 "Sequence Number", "dccp.seq",
1727 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
1734 "Sequence Number (raw)", "dccp.seq_raw",
1735 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
1742 "Reserved", "dccp.ack_res",
1743 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
1750 "Acknowledgement Number", "dccp.ack",
1751 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
1758 "Acknowledgement Number (raw)", "dccp.ack_raw",
1759 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
1764 &hf_dccp_service_code
,
1766 "Service Code", "dccp.service_code",
1767 FT_UINT32
, BASE_DEC
, VALS(dccp_service_code_vals
), 0x0,
1772 &hf_dccp_reset_code
,
1774 "Reset Code", "dccp.reset_code",
1775 FT_UINT8
, BASE_DEC
, VALS(dccp_reset_code_vals
), 0x0,
1782 "Data 1", "dccp.data1",
1783 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1790 "Data 2", "dccp.data2",
1791 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1798 "Data 3", "dccp.data3",
1799 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1804 &hf_dccp_option_type
,
1806 "Option Type", "dccp.option_type",
1807 FT_UINT8
, BASE_DEC
|BASE_RANGE_STRING
, RVALS(dccp_options_rvals
), 0x0,
1812 &hf_dccp_feature_number
,
1814 "Feature Number", "dccp.feature_number",
1815 FT_UINT8
, BASE_DEC
|BASE_RANGE_STRING
, RVALS(dccp_feature_numbers_rvals
), 0x0,
1822 "NDP Count", "dccp.ndp_count",
1823 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
1830 "Timestamp", "dccp.timestamp",
1831 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1836 &hf_dccp_timestamp_echo
,
1838 "Timestamp Echo", "dccp.timestamp_echo",
1839 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1844 &hf_dccp_elapsed_time
,
1846 "Elapsed Time", "dccp.elapsed_time",
1847 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1852 &hf_dccp_data_checksum
,
1854 "Data Checksum", "dccp.checksum_data",
1855 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
1861 /* MP-DCCP related option fields */
1862 {&hf_mpdccp_confirm
,{"MP_CONFIRM", "dccp.mp_confirm",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1863 {&hf_mpdccp_version
,{"version", "dccp.mp_version",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1865 {&hf_mpdccp_join
,{"MP_JOIN", "dccp.mp_join",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1866 {&hf_mpdccp_join_id
,{"Address ID", "dccp.mp_joinid",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1867 {&hf_mpdccp_join_token
,{"Path Token", "dccp.mp_path_token",FT_UINT32
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
1868 {&hf_mpdccp_join_nonce
,{"Nonce", "dccp.mp_nonce",FT_UINT32
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
1870 {&hf_mpdccp_fast_close
,{"MP_FAST_CLOSE", "dccp.mp_fast_close",FT_NONE
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1872 {&hf_mpdccp_key
,{"MP_KEY", "dccp.mp_key",FT_NONE
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1873 {&hf_mpdccp_key_type
,{"Key Type", "dccp.mp_key_type",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1874 {&hf_mpdccp_key_key
,{"Key Data", "dccp.mp_key_hash",FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1876 {&hf_mpdccp_seq
,{"Sequence Number", "dccp.mp_seq",FT_UINT64
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1878 {&hf_mpdccp_hmac
,{"MP_HMAC", "dccp.mp_hmac",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1879 {&hf_mpdccp_hmac_sha
,{"HMAC-SHA256", "dccp.mp_hmac_sha",FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1881 {&hf_mpdccp_rtt
,{"MP_RTT", "dccp.mp_rtt",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1882 {&hf_mpdccp_rtt_type
,{"RTT_Type", "dccp.mp_rtt_type",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1883 {&hf_mpdccp_rtt_value
,{"RTT", "dccp.mp_rtt_value",FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1884 {&hf_mpdccp_rtt_age
,{"Age", "dccp.mp_rtt_age",FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1886 {&hf_mpdccp_addaddr
,{"MP_ADDADDR", "dccp.mp_addaddr",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1887 {&hf_mpdccp_addrid
,{"Address ID", "dccp.mp_addrid",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1888 {&hf_mpdccp_addr_dec
,{"Address", "dccp.mp_ipv4addr",FT_IPv4
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1889 {&hf_mpdccp_addr_hex
,{"Address", "dccp.mp_ipv6addr",FT_IPv6
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1890 {&hf_mpdccp_addrport
,{"Port", "dccp.mp_addrport",FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1892 {&hf_mpdccp_removeaddr
,{"MP_REMOVEADDR", "dccp.mp_removeaddr",FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1894 {&hf_mpdccp_prio
,{"MP_PRIO", "dccp.mp_prio",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1895 {&hf_mpdccp_prio_value
,{"Priority", "dccp.mp_prioval",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1897 {&hf_mpdccp_close
,{"MP_CLOSE", "dccp.mp_close",FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1899 {&hf_mpdccp_close_key
,{"Key Data", "dccp.mp_close_key",FT_UINT64
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
1901 {&hf_mpdccp_exp
,{"MP_EXP", "dccp.mp_exp",FT_NONE
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1903 {&hf_dccp_option_data
,{"Option data", "dccp.mp_option",FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1909 "Options", "dccp.options",
1910 FT_NONE
, BASE_NONE
, NULL
, 0x0,
1911 "DCCP Options fields", HFILL
1915 /* Generated from convert_proto_tree_add_text.pl */
1916 { &hf_dccp_padding
, { "Padding", "dccp.padding", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1917 { &hf_dccp_mandatory
, { "Mandatory", "dccp.mandatory", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1918 { &hf_dccp_slow_receiver
, { "Slow Receiver", "dccp.slow_receiver", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1919 { &hf_dccp_init_cookie
, { "Init Cookie", "dccp.init_cookie", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1920 { &hf_dccp_ack_vector_nonce_0
, { "Ack Vector [Nonce 0]", "dccp.ack_vector.nonce_0", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1921 { &hf_dccp_ack_vector_nonce_1
, { "Ack Vector [Nonce 1]", "dccp.ack_vector.nonce_1", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1922 { &hf_dccp_data_dropped
, { "Data Dropped", "dccp.data_dropped", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1923 { &hf_dccp_ccid3_loss_event_rate
, { "CCID3 Loss Event Rate", "dccp.ccid3_loss_event_rate", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
1924 { &hf_dccp_ccid3_loss_intervals
, { "CCID3 Loss Intervals", "dccp.ccid3_loss_intervals", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1925 { &hf_dccp_ccid3_receive_rate
, { "CCID3 Receive Rate", "dccp.ccid3_receive_rate", FT_UINT32
, BASE_DEC
|BASE_UNIT_STRING
, UNS(&units_bytes_sec
), 0x0, NULL
, HFILL
}},
1926 { &hf_dccp_option_reserved
, { "Reserved", "dccp.option_reserved", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1927 { &hf_dccp_ccid_option_data
, { "CCID option", "dccp.ccid_option_data", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1928 { &hf_dccp_option_unknown
, { "Unknown", "dccp.option_unknown", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
1931 static int *ett
[] = {
1934 &ett_dccp_options_item
,
1938 static ei_register_info ei
[] = {
1939 { &ei_dccp_option_len_bad
, { "dccp.option.len.bad", PI_PROTOCOL
, PI_WARN
, "Bad option length", EXPFILL
}},
1940 { &ei_dccp_advertised_header_length_bad
, { "dccp.advertised_header_length.bad", PI_MALFORMED
, PI_ERROR
, "Advertised header length bad", EXPFILL
}},
1941 { &ei_dccp_packet_type_reserved
, { "dccp.packet_type.reserved", PI_PROTOCOL
, PI_WARN
, "Reserved packet type: unable to dissect further", EXPFILL
}},
1942 { &ei_dccp_checksum
, { "dccp.bad_checksum", PI_CHECKSUM
, PI_ERROR
, "Bad checksum", EXPFILL
}},
1945 expert_module_t
* expert_dccp
;
1948 proto_register_protocol("Datagram Congestion Control Protocol", "DCCP", "dccp");
1949 dccp_handle
= register_dissector("dccp", dissect_dccp
, proto_dccp
);
1950 proto_register_field_array(proto_dccp
, hf
, array_length(hf
));
1951 proto_register_subtree_array(ett
, array_length(ett
));
1952 expert_dccp
= expert_register_protocol(proto_dccp
);
1953 expert_register_field_array(expert_dccp
, ei
, array_length(ei
));
1956 dccp_subdissector_table
=
1957 register_dissector_table("dccp.port", "DCCP port", proto_dccp
, FT_UINT16
,
1959 heur_subdissector_list
= register_heur_dissector_list_with_description("dccp", "DCCP heuristic", proto_dccp
);
1961 /* reg preferences */
1962 dccp_module
= prefs_register_protocol(proto_dccp
, NULL
);
1963 /* For reading older preference files with "dcp." preferences */
1964 prefs_register_module_alias("dcp", dccp_module
);
1965 prefs_register_bool_preference(
1966 dccp_module
, "summary_in_tree",
1967 "Show DCCP summary in protocol tree",
1968 "Whether the DCCP summary line should be shown in the protocol tree",
1969 &dccp_summary_in_tree
);
1971 prefs_register_bool_preference(
1972 dccp_module
, "try_heuristic_first",
1973 "Try heuristic sub-dissectors first",
1974 "Try to decode a packet using an heuristic sub-dissector before "
1975 "using a sub-dissector "
1976 "registered to a specific port",
1977 &try_heuristic_first
);
1979 prefs_register_bool_preference(
1980 dccp_module
, "check_checksum",
1981 "Check the validity of the DCCP checksum when possible",
1982 "Whether to check the validity of the DCCP checksum",
1983 &dccp_check_checksum
);
1985 prefs_register_bool_preference(
1986 dccp_module
, "relative_sequence_numbers",
1987 "Relative sequence numbers",
1988 "Make the DCCP dissector use relative sequence numbers instead of absolute ones.",
1989 &dccp_relative_seq
);
1991 register_conversation_table(proto_dccp
, false, dccpip_conversation_packet
, dccpip_endpoint_packet
);
1992 register_conversation_filter("dccp", "DCCP", dccp_filter_valid
, dccp_build_filter
, NULL
);
1993 register_follow_stream(proto_dccp
, "dccp_follow", dccp_follow_conv_filter
, dccp_follow_index_filter
, dccp_follow_address_filter
,
1994 dccp_port_to_display
, follow_tvb_tap_listener
, get_dccp_stream_count
, NULL
);
1996 register_init_routine(dccp_init
);
1998 dccp_tap
= register_tap("dccp");
1999 dccp_follow_tap
= register_tap("dccp_follow");
2003 proto_reg_handoff_dccp(void)
2005 dissector_add_uint("ip.proto", IP_PROTO_DCCP
, dccp_handle
);
2009 * Editor modelines - https://www.wireshark.org/tools/modelines.html
2014 * indent-tabs-mode: nil
2017 * vi: set shiftwidth=4 tabstop=8 expandtab:
2018 * :indentSize=4:tabSize=8:noTabs=true: