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