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