xref: /freebsd/contrib/tcpdump/print-dccp.c (revision 0a7e5f1f02aad2ff5fff1c60f44c6975fd07e1d9)
1 /*
2  * Copyright (C) Arnaldo Carvalho de Melo 2004
3  * Copyright (C) Ian McDonald 2005
4  * Copyright (C) Yoshifumi Nishida 2005
5  *
6  * This software may be distributed either under the terms of the
7  * BSD-style license that accompanies tcpdump or the GNU GPL version 2
8  */
9 
10 /* \summary: Datagram Congestion Control Protocol (DCCP) printer */
11 
12 /* specification: RFC 4340 */
13 
14 #include <config.h>
15 
16 #include "netdissect-stdinc.h"
17 
18 #include "netdissect.h"
19 #include "addrtoname.h"
20 #include "extract.h"
21 #include "ip.h"
22 #include "ip6.h"
23 #include "ipproto.h"
24 
25 /* RFC4340: Datagram Congestion Control Protocol (DCCP) */
26 
27 /**
28  * struct dccp_hdr - generic part of DCCP packet header, with a 24-bit
29  * sequence number
30  *
31  * @dccph_sport - Relevant port on the endpoint that sent this packet
32  * @dccph_dport - Relevant port on the other endpoint
33  * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
34  * @dccph_ccval - Used by the HC-Sender CCID
35  * @dccph_cscov - Parts of the packet that are covered by the Checksum field
36  * @dccph_checksum - Internet checksum, depends on dccph_cscov
37  * @dccph_x - 0 = 24 bit sequence number, 1 = 48
38  * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
39  * @dccph_seq - 24-bit sequence number
40  */
41 struct dccp_hdr {
42 	nd_uint16_t	dccph_sport,
43 			dccph_dport;
44 	nd_uint8_t	dccph_doff;
45 	nd_uint8_t	dccph_ccval_cscov;
46 	nd_uint16_t	dccph_checksum;
47 	nd_uint8_t	dccph_xtr;
48 	nd_uint24_t	dccph_seq;
49 };
50 
51 /**
52  * struct dccp_hdr_ext - generic part of DCCP packet header, with a 48-bit
53  * sequence number
54  *
55  * @dccph_sport - Relevant port on the endpoint that sent this packet
56  * @dccph_dport - Relevant port on the other endpoint
57  * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
58  * @dccph_ccval - Used by the HC-Sender CCID
59  * @dccph_cscov - Parts of the packet that are covered by the Checksum field
60  * @dccph_checksum - Internet checksum, depends on dccph_cscov
61  * @dccph_x - 0 = 24 bit sequence number, 1 = 48
62  * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
63  * @dccph_seq - 48-bit sequence number
64  */
65 struct dccp_hdr_ext {
66 	nd_uint16_t	dccph_sport,
67 			dccph_dport;
68 	nd_uint8_t	dccph_doff;
69 	nd_uint8_t	dccph_ccval_cscov;
70 	nd_uint16_t	dccph_checksum;
71 	nd_uint8_t	dccph_xtr;
72 	nd_uint8_t	reserved;
73 	nd_uint48_t	dccph_seq;
74 };
75 
76 #define DCCPH_CCVAL(dh)	((GET_U_1((dh)->dccph_ccval_cscov) >> 4) & 0xF)
77 #define DCCPH_CSCOV(dh)	(GET_U_1((dh)->dccph_ccval_cscov) & 0xF)
78 
79 #define DCCPH_X(dh)	(GET_U_1((dh)->dccph_xtr) & 1)
80 #define DCCPH_TYPE(dh)	((GET_U_1((dh)->dccph_xtr) >> 1) & 0xF)
81 
82 /**
83  * struct dccp_hdr_request - Connection initiation request header
84  *
85  * @dccph_req_service - Service to which the client app wants to connect
86  */
87 struct dccp_hdr_request {
88 	nd_uint32_t	dccph_req_service;
89 };
90 
91 /**
92  * struct dccp_hdr_response - Connection initiation response header
93  *
94  * @dccph_resp_ack - 48 bit ack number, contains GSR
95  * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request
96  */
97 struct dccp_hdr_response {
98 	nd_uint64_t	dccph_resp_ack;	/* always 8 bytes, first 2 reserved */
99 	nd_uint32_t	dccph_resp_service;
100 };
101 
102 /**
103  * struct dccp_hdr_reset - Unconditionally shut down a connection
104  *
105  * @dccph_resp_ack - 48 bit ack number
106  * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request
107  */
108 struct dccp_hdr_reset {
109 	nd_uint64_t	dccph_reset_ack;	/* always 8 bytes, first 2 reserved */
110 	nd_uint8_t	dccph_reset_code;
111 	nd_uint8_t	dccph_reset_data1;
112 	nd_uint8_t	dccph_reset_data2;
113 	nd_uint8_t	dccph_reset_data3;
114 };
115 
116 enum dccp_pkt_type {
117 	DCCP_PKT_REQUEST = 0,
118 	DCCP_PKT_RESPONSE,
119 	DCCP_PKT_DATA,
120 	DCCP_PKT_ACK,
121 	DCCP_PKT_DATAACK,
122 	DCCP_PKT_CLOSEREQ,
123 	DCCP_PKT_CLOSE,
124 	DCCP_PKT_RESET,
125 	DCCP_PKT_SYNC,
126 	DCCP_PKT_SYNCACK
127 };
128 
129 static const struct tok dccp_pkt_type_str[] = {
130 	{ DCCP_PKT_REQUEST, "DCCP-Request" },
131 	{ DCCP_PKT_RESPONSE, "DCCP-Response" },
132 	{ DCCP_PKT_DATA, "DCCP-Data" },
133 	{ DCCP_PKT_ACK, "DCCP-Ack" },
134 	{ DCCP_PKT_DATAACK, "DCCP-DataAck" },
135 	{ DCCP_PKT_CLOSEREQ, "DCCP-CloseReq" },
136 	{ DCCP_PKT_CLOSE, "DCCP-Close" },
137 	{ DCCP_PKT_RESET, "DCCP-Reset" },
138 	{ DCCP_PKT_SYNC, "DCCP-Sync" },
139 	{ DCCP_PKT_SYNCACK, "DCCP-SyncAck" },
140 	{ 0, NULL}
141 };
142 
143 enum dccp_reset_codes {
144 	DCCP_RESET_CODE_UNSPECIFIED = 0,
145 	DCCP_RESET_CODE_CLOSED,
146 	DCCP_RESET_CODE_ABORTED,
147 	DCCP_RESET_CODE_NO_CONNECTION,
148 	DCCP_RESET_CODE_PACKET_ERROR,
149 	DCCP_RESET_CODE_OPTION_ERROR,
150 	DCCP_RESET_CODE_MANDATORY_ERROR,
151 	DCCP_RESET_CODE_CONNECTION_REFUSED,
152 	DCCP_RESET_CODE_BAD_SERVICE_CODE,
153 	DCCP_RESET_CODE_TOO_BUSY,
154 	DCCP_RESET_CODE_BAD_INIT_COOKIE,
155 	DCCP_RESET_CODE_AGGRESSION_PENALTY,
156 	__DCCP_RESET_CODE_LAST
157 };
158 
159 
160 static const char *dccp_reset_codes[] = {
161 	"unspecified",
162 	"closed",
163 	"aborted",
164 	"no_connection",
165 	"packet_error",
166 	"option_error",
167 	"mandatory_error",
168 	"connection_refused",
169 	"bad_service_code",
170 	"too_busy",
171 	"bad_init_cookie",
172 	"aggression_penalty",
173 };
174 
175 static const char *dccp_feature_nums[] = {
176 	"reserved",
177 	"ccid",
178 	"allow_short_seqno",
179 	"sequence_window",
180 	"ecn_incapable",
181 	"ack_ratio",
182 	"send_ack_vector",
183 	"send_ndp_count",
184 	"minimum checksum coverage",
185 	"check data checksum",
186 };
187 
188 static u_int
dccp_csum_coverage(netdissect_options * ndo,const struct dccp_hdr * dh,u_int len)189 dccp_csum_coverage(netdissect_options *ndo,
190 		   const struct dccp_hdr *dh, u_int len)
191 {
192 	u_int cov;
193 
194 	if (DCCPH_CSCOV(dh) == 0)
195 		return len;
196 	cov = (GET_U_1(dh->dccph_doff) + DCCPH_CSCOV(dh) - 1) * sizeof(uint32_t);
197 	return (cov > len)? len : cov;
198 }
199 
dccp_cksum(netdissect_options * ndo,const struct ip * ip,const struct dccp_hdr * dh,u_int len)200 static uint16_t dccp_cksum(netdissect_options *ndo, const struct ip *ip,
201 	const struct dccp_hdr *dh, u_int len)
202 {
203 	return nextproto4_cksum(ndo, ip, (const uint8_t *)(const void *)dh, len,
204 				dccp_csum_coverage(ndo, dh, len), IPPROTO_DCCP);
205 }
206 
dccp6_cksum(netdissect_options * ndo,const struct ip6_hdr * ip6,const struct dccp_hdr * dh,u_int len)207 static uint16_t dccp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6,
208 	const struct dccp_hdr *dh, u_int len)
209 {
210 	return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)dh, len,
211 				dccp_csum_coverage(ndo, dh, len), IPPROTO_DCCP);
212 }
213 
dccp_reset_code(uint8_t code)214 static const char *dccp_reset_code(uint8_t code)
215 {
216 	if (code >= __DCCP_RESET_CODE_LAST)
217 		return "invalid";
218 	return dccp_reset_codes[code];
219 }
220 
221 static uint64_t
dccp_seqno(netdissect_options * ndo,const u_char * bp)222 dccp_seqno(netdissect_options *ndo, const u_char *bp)
223 {
224 	const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
225 	uint64_t seqno;
226 
227 	if (DCCPH_X(dh) != 0) {
228 		const struct dccp_hdr_ext *dhx = (const struct dccp_hdr_ext *)bp;
229 		seqno = GET_BE_U_6(dhx->dccph_seq);
230 	} else {
231 		seqno = GET_BE_U_3(dh->dccph_seq);
232 	}
233 
234 	return seqno;
235 }
236 
237 static unsigned int
dccp_basic_hdr_len(netdissect_options * ndo,const struct dccp_hdr * dh)238 dccp_basic_hdr_len(netdissect_options *ndo, const struct dccp_hdr *dh)
239 {
240 	return DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : sizeof(struct dccp_hdr);
241 }
242 
dccp_print_ack_no(netdissect_options * ndo,const u_char * bp)243 static void dccp_print_ack_no(netdissect_options *ndo, const u_char *bp)
244 {
245 	const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
246 	const u_char *ackp = bp + dccp_basic_hdr_len(ndo, dh);
247 	uint64_t ackno;
248 
249 	if (DCCPH_X(dh) != 0) {
250 		ackno = GET_BE_U_6(ackp + 2);
251 	} else {
252 		ackno = GET_BE_U_3(ackp + 1);
253 	}
254 
255 	ND_PRINT("(ack=%" PRIu64 ") ", ackno);
256 }
257 
258 static u_int dccp_print_option(netdissect_options *, const u_char *, u_int);
259 
260 /**
261  * dccp_print - show dccp packet
262  * @bp - beginning of dccp packet
263  * @data2 - beginning of enclosing
264  * @len - length of ip packet
265  */
266 void
dccp_print(netdissect_options * ndo,const u_char * bp,const u_char * data2,u_int len)267 dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
268 	   u_int len)
269 {
270 	const struct dccp_hdr *dh;
271 	const struct ip *ip;
272 	const struct ip6_hdr *ip6;
273 	const u_char *cp;
274 	u_short sport, dport;
275 	u_int hlen;
276 	u_int fixed_hdrlen;
277 	uint8_t	dccph_type;
278 
279 	ndo->ndo_protocol = "dccp";
280 	dh = (const struct dccp_hdr *)bp;
281 
282 	ip = (const struct ip *)data2;
283 	if (IP_V(ip) == 6)
284 		ip6 = (const struct ip6_hdr *)data2;
285 	else
286 		ip6 = NULL;
287 
288 	/* make sure we have enough data to look at the X bit */
289 	cp = (const u_char *)(dh + 1);
290 	if (cp > ndo->ndo_snapend)
291 		goto trunc;
292 	if (len < sizeof(struct dccp_hdr)) {
293 		ND_PRINT("truncated-dccp - %zu bytes missing!",
294 			 sizeof(struct dccp_hdr) - len);
295 		return;
296 	}
297 
298 	/* get the length of the generic header */
299 	fixed_hdrlen = dccp_basic_hdr_len(ndo, dh);
300 	if (len < fixed_hdrlen) {
301 		ND_PRINT("truncated-dccp - %u bytes missing!",
302 			  fixed_hdrlen - len);
303 		return;
304 	}
305 	ND_TCHECK_LEN(dh, fixed_hdrlen);
306 
307 	sport = GET_BE_U_2(dh->dccph_sport);
308 	dport = GET_BE_U_2(dh->dccph_dport);
309 	hlen = GET_U_1(dh->dccph_doff) * 4;
310 
311 	if (ip6) {
312 		ND_PRINT("%s.%u > %s.%u: ",
313 			  GET_IP6ADDR_STRING(ip6->ip6_src), sport,
314 			  GET_IP6ADDR_STRING(ip6->ip6_dst), dport);
315 	} else {
316 		ND_PRINT("%s.%u > %s.%u: ",
317 			  GET_IPADDR_STRING(ip->ip_src), sport,
318 			  GET_IPADDR_STRING(ip->ip_dst), dport);
319 	}
320 
321 	nd_print_protocol_caps(ndo);
322 
323 	if (ndo->ndo_qflag) {
324 		ND_PRINT(" %u", len - hlen);
325 		if (hlen > len) {
326 			ND_PRINT(" [bad hdr length %u - too long, > %u]",
327 				  hlen, len);
328 		}
329 		return;
330 	}
331 
332 	/* other variables in generic header */
333 	if (ndo->ndo_vflag) {
334 		ND_PRINT(" (CCVal %u, CsCov %u", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh));
335 	}
336 
337 	/* checksum calculation */
338 	if (ndo->ndo_vflag && ND_TTEST_LEN(bp, len)) {
339 		uint16_t sum = 0, dccp_sum;
340 
341 		dccp_sum = GET_BE_U_2(dh->dccph_checksum);
342 		ND_PRINT(", cksum 0x%04x ", dccp_sum);
343 		if (IP_V(ip) == 4)
344 			sum = dccp_cksum(ndo, ip, dh, len);
345 		else if (IP_V(ip) == 6)
346 			sum = dccp6_cksum(ndo, ip6, dh, len);
347 		if (sum != 0)
348 			ND_PRINT("(incorrect -> 0x%04x)",in_cksum_shouldbe(dccp_sum, sum));
349 		else
350 			ND_PRINT("(correct)");
351 	}
352 
353 	if (ndo->ndo_vflag)
354 		ND_PRINT(")");
355 	ND_PRINT(" ");
356 
357 	dccph_type = DCCPH_TYPE(dh);
358 	switch (dccph_type) {
359 	case DCCP_PKT_REQUEST: {
360 		const struct dccp_hdr_request *dhr =
361 			(const struct dccp_hdr_request *)(bp + fixed_hdrlen);
362 		fixed_hdrlen += 4;
363 		if (len < fixed_hdrlen) {
364 			ND_PRINT("truncated-%s - %u bytes missing!",
365 				  tok2str(dccp_pkt_type_str, "", dccph_type),
366 				  fixed_hdrlen - len);
367 			return;
368 		}
369 		ND_TCHECK_SIZE(dhr);
370 		ND_PRINT("%s (service=%u) ",
371 			  tok2str(dccp_pkt_type_str, "", dccph_type),
372 			  GET_BE_U_4(dhr->dccph_req_service));
373 		break;
374 	}
375 	case DCCP_PKT_RESPONSE: {
376 		const struct dccp_hdr_response *dhr =
377 			(const struct dccp_hdr_response *)(bp + fixed_hdrlen);
378 		fixed_hdrlen += 12;
379 		if (len < fixed_hdrlen) {
380 			ND_PRINT("truncated-%s - %u bytes missing!",
381 				  tok2str(dccp_pkt_type_str, "", dccph_type),
382 				  fixed_hdrlen - len);
383 			return;
384 		}
385 		ND_TCHECK_SIZE(dhr);
386 		ND_PRINT("%s (service=%u) ",
387 			  tok2str(dccp_pkt_type_str, "", dccph_type),
388 			  GET_BE_U_4(dhr->dccph_resp_service));
389 		break;
390 	}
391 	case DCCP_PKT_DATA:
392 		ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
393 		break;
394 	case DCCP_PKT_ACK: {
395 		fixed_hdrlen += 8;
396 		if (len < fixed_hdrlen) {
397 			ND_PRINT("truncated-%s - %u bytes missing!",
398 				  tok2str(dccp_pkt_type_str, "", dccph_type),
399 				  fixed_hdrlen - len);
400 			return;
401 		}
402 		ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
403 		break;
404 	}
405 	case DCCP_PKT_DATAACK: {
406 		fixed_hdrlen += 8;
407 		if (len < fixed_hdrlen) {
408 			ND_PRINT("truncated-%s - %u bytes missing!",
409 				  tok2str(dccp_pkt_type_str, "", dccph_type),
410 				  fixed_hdrlen - len);
411 			return;
412 		}
413 		ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
414 		break;
415 	}
416 	case DCCP_PKT_CLOSEREQ:
417 		fixed_hdrlen += 8;
418 		if (len < fixed_hdrlen) {
419 			ND_PRINT("truncated-%s - %u bytes missing!",
420 				  tok2str(dccp_pkt_type_str, "", dccph_type),
421 				  fixed_hdrlen - len);
422 			return;
423 		}
424 		ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
425 		break;
426 	case DCCP_PKT_CLOSE:
427 		fixed_hdrlen += 8;
428 		if (len < fixed_hdrlen) {
429 			ND_PRINT("truncated-%s - %u bytes missing!",
430 				  tok2str(dccp_pkt_type_str, "", dccph_type),
431 				  fixed_hdrlen - len);
432 			return;
433 		}
434 		ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
435 		break;
436 	case DCCP_PKT_RESET: {
437 		const struct dccp_hdr_reset *dhr =
438 			(const struct dccp_hdr_reset *)(bp + fixed_hdrlen);
439 		fixed_hdrlen += 12;
440 		if (len < fixed_hdrlen) {
441 			ND_PRINT("truncated-%s - %u bytes missing!",
442 				  tok2str(dccp_pkt_type_str, "", dccph_type),
443 				  fixed_hdrlen - len);
444 			return;
445 		}
446 		ND_TCHECK_SIZE(dhr);
447 		ND_PRINT("%s (code=%s) ",
448 			  tok2str(dccp_pkt_type_str, "", dccph_type),
449 			  dccp_reset_code(GET_U_1(dhr->dccph_reset_code)));
450 		break;
451 	}
452 	case DCCP_PKT_SYNC:
453 		fixed_hdrlen += 8;
454 		if (len < fixed_hdrlen) {
455 			ND_PRINT("truncated-%s - %u bytes missing!",
456 				  tok2str(dccp_pkt_type_str, "", dccph_type),
457 				  fixed_hdrlen - len);
458 			return;
459 		}
460 		ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
461 		break;
462 	case DCCP_PKT_SYNCACK:
463 		fixed_hdrlen += 8;
464 		if (len < fixed_hdrlen) {
465 			ND_PRINT("truncated-%s - %u bytes missing!",
466 				  tok2str(dccp_pkt_type_str, "", dccph_type),
467 				  fixed_hdrlen - len);
468 			return;
469 		}
470 		ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
471 		break;
472 	default:
473 		ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "unknown-type-%u", dccph_type));
474 		break;
475 	}
476 
477 	if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) &&
478 			(DCCPH_TYPE(dh) != DCCP_PKT_REQUEST))
479 		dccp_print_ack_no(ndo, bp);
480 
481 	if (ndo->ndo_vflag < 2)
482 		return;
483 
484 	ND_PRINT("seq %" PRIu64, dccp_seqno(ndo, bp));
485 
486 	/* process options */
487 	if (hlen > fixed_hdrlen){
488 		u_int optlen;
489 		cp = bp + fixed_hdrlen;
490 		ND_PRINT(" <");
491 
492 		hlen -= fixed_hdrlen;
493 		while(1){
494 			optlen = dccp_print_option(ndo, cp, hlen);
495 			if (!optlen)
496 				break;
497 			if (hlen <= optlen)
498 				break;
499 			hlen -= optlen;
500 			cp += optlen;
501 			ND_PRINT(", ");
502 		}
503 		ND_PRINT(">");
504 	}
505 	return;
506 trunc:
507 	nd_print_trunc(ndo);
508 }
509 
510 static const struct tok dccp_option_values[] = {
511 	{ 0, "nop" },
512 	{ 1, "mandatory" },
513 	{ 2, "slowreceiver" },
514 	{ 32, "change_l" },
515 	{ 33, "confirm_l" },
516 	{ 34, "change_r" },
517 	{ 35, "confirm_r" },
518 	{ 36, "initcookie" },
519 	{ 37, "ndp_count" },
520 	{ 38, "ack_vector0" },
521 	{ 39, "ack_vector1" },
522 	{ 40, "data_dropped" },
523 	{ 41, "timestamp" },
524 	{ 42, "timestamp_echo" },
525 	{ 43, "elapsed_time" },
526 	{ 44, "data_checksum" },
527 	{ 0, NULL }
528 };
529 
530 static u_int
dccp_print_option(netdissect_options * ndo,const u_char * option,u_int hlen)531 dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen)
532 {
533 	uint8_t optlen, i;
534 
535 	if (GET_U_1(option) >= 32) {
536 		optlen = GET_U_1(option + 1);
537 		if (optlen < 2) {
538 			if (GET_U_1(option) >= 128)
539 				ND_PRINT("CCID option %u optlen too short",
540 					 GET_U_1(option));
541 			else
542 				ND_PRINT("%s optlen too short",
543 					  tok2str(dccp_option_values, "Option %u", GET_U_1(option)));
544 			return 0;
545 		}
546 	} else
547 		optlen = 1;
548 
549 	if (hlen < optlen) {
550 		if (GET_U_1(option) >= 128)
551 			ND_PRINT("CCID option %u optlen goes past header length",
552 				  GET_U_1(option));
553 		else
554 			ND_PRINT("%s optlen goes past header length",
555 				  tok2str(dccp_option_values, "Option %u", GET_U_1(option)));
556 		return 0;
557 	}
558 	ND_TCHECK_LEN(option, optlen);
559 
560 	if (GET_U_1(option) >= 128) {
561 		ND_PRINT("CCID option %u", GET_U_1(option));
562 		switch (optlen) {
563 			case 4:
564 				ND_PRINT(" %u", GET_BE_U_2(option + 2));
565 				break;
566 			case 6:
567 				ND_PRINT(" %u", GET_BE_U_4(option + 2));
568 				break;
569 			default:
570 				break;
571 		}
572 	} else {
573 		ND_PRINT("%s",
574 			 tok2str(dccp_option_values, "Option %u", GET_U_1(option)));
575 		switch (GET_U_1(option)) {
576 		case 32:
577 		case 33:
578 		case 34:
579 		case 35:
580 			if (optlen < 3) {
581 				ND_PRINT(" optlen too short");
582 				return optlen;
583 			}
584 			if (GET_U_1(option + 2) < 10){
585 				ND_PRINT(" %s",
586 					 dccp_feature_nums[GET_U_1(option + 2)]);
587 				for (i = 0; i < optlen - 3; i++)
588 					ND_PRINT(" %u",
589 						 GET_U_1(option + 3 + i));
590 			}
591 			break;
592 		case 36:
593 			if (optlen > 2) {
594 				ND_PRINT(" 0x");
595 				for (i = 0; i < optlen - 2; i++)
596 					ND_PRINT("%02x",
597 						 GET_U_1(option + 2 + i));
598 			}
599 			break;
600 		case 37:
601 			for (i = 0; i < optlen - 2; i++)
602 				ND_PRINT(" %u", GET_U_1(option + 2 + i));
603 			break;
604 		case 38:
605 			if (optlen > 2) {
606 				ND_PRINT(" 0x");
607 				for (i = 0; i < optlen - 2; i++)
608 					ND_PRINT("%02x",
609 						 GET_U_1(option + 2 + i));
610 			}
611 			break;
612 		case 39:
613 			if (optlen > 2) {
614 				ND_PRINT(" 0x");
615 				for (i = 0; i < optlen - 2; i++)
616 					ND_PRINT("%02x",
617 						 GET_U_1(option + 2 + i));
618 			}
619 			break;
620 		case 40:
621 			if (optlen > 2) {
622 				ND_PRINT(" 0x");
623 				for (i = 0; i < optlen - 2; i++)
624 					ND_PRINT("%02x",
625 						 GET_U_1(option + 2 + i));
626 			}
627 			break;
628 		case 41:
629 		/*
630 		 * 13.1.  Timestamp Option
631 		 *
632 		 *  +--------+--------+--------+--------+--------+--------+
633 		 *  |00101001|00000110|          Timestamp Value          |
634 		 *  +--------+--------+--------+--------+--------+--------+
635 		 *   Type=41  Length=6
636 		 */
637 			if (optlen == 6)
638 				ND_PRINT(" %u", GET_BE_U_4(option + 2));
639 			else
640 				ND_PRINT(" [optlen != 6]");
641 			break;
642 		case 42:
643 		/*
644 		 * 13.3.  Timestamp Echo Option
645 		 *
646 		 *  +--------+--------+--------+--------+--------+--------+
647 		 *  |00101010|00000110|           Timestamp Echo          |
648 		 *  +--------+--------+--------+--------+--------+--------+
649 		 *   Type=42    Len=6
650 		 *
651 		 *  +--------+--------+------- ... -------+--------+--------+
652 		 *  |00101010|00001000|  Timestamp Echo   |   Elapsed Time  |
653 		 *  +--------+--------+------- ... -------+--------+--------+
654 		 *   Type=42    Len=8       (4 bytes)
655 		 *
656 		 *  +--------+--------+------- ... -------+------- ... -------+
657 		 *  |00101010|00001010|  Timestamp Echo   |    Elapsed Time   |
658 		 *  +--------+--------+------- ... -------+------- ... -------+
659 		 *   Type=42   Len=10       (4 bytes)           (4 bytes)
660 		 */
661 			switch (optlen) {
662 			case 6:
663 				ND_PRINT(" %u", GET_BE_U_4(option + 2));
664 				break;
665 			case 8:
666 				ND_PRINT(" %u", GET_BE_U_4(option + 2));
667 				ND_PRINT(" (elapsed time %u)",
668 					 GET_BE_U_2(option + 6));
669 				break;
670 			case 10:
671 				ND_PRINT(" %u", GET_BE_U_4(option + 2));
672 				ND_PRINT(" (elapsed time %u)",
673 					 GET_BE_U_4(option + 6));
674 				break;
675 			default:
676 				ND_PRINT(" [optlen != 6 or 8 or 10]");
677 				break;
678 			}
679 			break;
680 		case 43:
681 			if (optlen == 6)
682 				ND_PRINT(" %u", GET_BE_U_4(option + 2));
683 			else if (optlen == 4)
684 				ND_PRINT(" %u", GET_BE_U_2(option + 2));
685 			else
686 				ND_PRINT(" [optlen != 4 or 6]");
687 			break;
688 		case 44:
689 			if (optlen > 2) {
690 				ND_PRINT(" ");
691 				for (i = 0; i < optlen - 2; i++)
692 					ND_PRINT("%02x",
693 						 GET_U_1(option + 2 + i));
694 			}
695 			break;
696 		}
697 	}
698 
699 	return optlen;
700 trunc:
701 	nd_print_trunc(ndo);
702 	return 0;
703 }
704