]> The Tcpdump Group git mirrors - tcpdump/blob - print-dccp.c
Use the non-power-of-2 nd_ types.
[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 } UNALIGNED;
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 } UNALIGNED;
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 } UNALIGNED;
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 } UNALIGNED;
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 } UNALIGNED;
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 inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
195 {
196 u_int cov;
197
198 if (DCCPH_CSCOV(dh) == 0)
199 return len;
200 cov = (EXTRACT_U_1(dh->dccph_doff) + DCCPH_CSCOV(dh) - 1) * sizeof(uint32_t);
201 return (cov > len)? len : cov;
202 }
203
204 static int dccp_cksum(netdissect_options *ndo, const struct ip *ip,
205 const struct dccp_hdr *dh, u_int len)
206 {
207 return nextproto4_cksum(ndo, ip, (const uint8_t *)(const void *)dh, len,
208 dccp_csum_coverage(dh, len), IPPROTO_DCCP);
209 }
210
211 static int dccp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6,
212 const struct dccp_hdr *dh, u_int len)
213 {
214 return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)dh, len,
215 dccp_csum_coverage(dh, len), IPPROTO_DCCP);
216 }
217
218 static const char *dccp_reset_code(uint8_t code)
219 {
220 if (code >= __DCCP_RESET_CODE_LAST)
221 return "invalid";
222 return dccp_reset_codes[code];
223 }
224
225 static uint64_t dccp_seqno(const u_char *bp)
226 {
227 const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
228 uint64_t seqno;
229
230 if (DCCPH_X(dh) != 0) {
231 const struct dccp_hdr_ext *dhx = (const struct dccp_hdr_ext *)bp;
232 seqno = EXTRACT_BE_U_6(dhx->dccph_seq);
233 } else {
234 seqno = EXTRACT_BE_U_3(dh->dccph_seq);
235 }
236
237 return seqno;
238 }
239
240 static inline unsigned int dccp_basic_hdr_len(const struct dccp_hdr *dh)
241 {
242 return DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : sizeof(struct dccp_hdr);
243 }
244
245 static void dccp_print_ack_no(netdissect_options *ndo, const u_char *bp)
246 {
247 const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
248 const u_char *ackp = bp + dccp_basic_hdr_len(dh);
249 uint64_t ackno;
250
251 if (DCCPH_X(dh) != 0) {
252 ND_TCHECK_8(ackp);
253 ackno = EXTRACT_BE_U_6(ackp + 2);
254 } else {
255 ND_TCHECK_4(ackp);
256 ackno = EXTRACT_BE_U_3(ackp + 1);
257 }
258
259 ND_PRINT((ndo, "(ack=%" PRIu64 ") ", ackno));
260 trunc:
261 return;
262 }
263
264 static int dccp_print_option(netdissect_options *, const u_char *, u_int);
265
266 /**
267 * dccp_print - show dccp packet
268 * @bp - beginning of dccp packet
269 * @data2 - beginning of enclosing
270 * @len - lenght of ip packet
271 */
272 void
273 dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
274 u_int len)
275 {
276 const struct dccp_hdr *dh;
277 const struct ip *ip;
278 const struct ip6_hdr *ip6;
279 const u_char *cp;
280 u_short sport, dport;
281 u_int hlen;
282 u_int fixed_hdrlen;
283 uint8_t dccph_type;
284
285 dh = (const struct dccp_hdr *)bp;
286
287 ip = (const struct ip *)data2;
288 if (IP_V(ip) == 6)
289 ip6 = (const struct ip6_hdr *)data2;
290 else
291 ip6 = NULL;
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_TCHECK_LEN(dh, fixed_hdrlen);
313
314 sport = EXTRACT_BE_U_2(dh->dccph_sport);
315 dport = EXTRACT_BE_U_2(dh->dccph_dport);
316 hlen = EXTRACT_U_1(dh->dccph_doff) * 4;
317
318 if (ip6) {
319 ND_PRINT((ndo, "%s.%d > %s.%d: ",
320 ip6addr_string(ndo, &ip6->ip6_src), sport,
321 ip6addr_string(ndo, &ip6->ip6_dst), dport));
322 } else {
323 ND_PRINT((ndo, "%s.%d > %s.%d: ",
324 ipaddr_string(ndo, &ip->ip_src), sport,
325 ipaddr_string(ndo, &ip->ip_dst), dport));
326 }
327
328 ND_PRINT((ndo, "DCCP"));
329
330 if (ndo->ndo_qflag) {
331 ND_PRINT((ndo, " %d", len - hlen));
332 if (hlen > len) {
333 ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
334 hlen, len));
335 }
336 return;
337 }
338
339 /* other variables in generic header */
340 if (ndo->ndo_vflag) {
341 ND_PRINT((ndo, " (CCVal %d, CsCov %d, ", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh)));
342 }
343
344 /* checksum calculation */
345 if (ndo->ndo_vflag && ND_TTEST_LEN(bp, len)) {
346 uint16_t sum = 0, dccp_sum;
347
348 dccp_sum = EXTRACT_BE_U_2(dh->dccph_checksum);
349 ND_PRINT((ndo, "cksum 0x%04x ", dccp_sum));
350 if (IP_V(ip) == 4)
351 sum = dccp_cksum(ndo, ip, dh, len);
352 else if (IP_V(ip) == 6)
353 sum = dccp6_cksum(ndo, ip6, dh, len);
354 if (sum != 0)
355 ND_PRINT((ndo, "(incorrect -> 0x%04x)",in_cksum_shouldbe(dccp_sum, sum)));
356 else
357 ND_PRINT((ndo, "(correct)"));
358 }
359
360 if (ndo->ndo_vflag)
361 ND_PRINT((ndo, ")"));
362 ND_PRINT((ndo, " "));
363
364 dccph_type = DCCPH_TYPE(dh);
365 switch (dccph_type) {
366 case DCCP_PKT_REQUEST: {
367 const struct dccp_hdr_request *dhr =
368 (const struct dccp_hdr_request *)(bp + fixed_hdrlen);
369 fixed_hdrlen += 4;
370 if (len < fixed_hdrlen) {
371 ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
372 tok2str(dccp_pkt_type_str, "", dccph_type),
373 len - fixed_hdrlen));
374 return;
375 }
376 ND_TCHECK(*dhr);
377 ND_PRINT((ndo, "%s (service=%d) ",
378 tok2str(dccp_pkt_type_str, "", dccph_type),
379 EXTRACT_BE_U_4(dhr->dccph_req_service)));
380 break;
381 }
382 case DCCP_PKT_RESPONSE: {
383 const struct dccp_hdr_response *dhr =
384 (const struct dccp_hdr_response *)(bp + fixed_hdrlen);
385 fixed_hdrlen += 12;
386 if (len < fixed_hdrlen) {
387 ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
388 tok2str(dccp_pkt_type_str, "", dccph_type),
389 len - fixed_hdrlen));
390 return;
391 }
392 ND_TCHECK(*dhr);
393 ND_PRINT((ndo, "%s (service=%d) ",
394 tok2str(dccp_pkt_type_str, "", dccph_type),
395 EXTRACT_BE_U_4(dhr->dccph_resp_service)));
396 break;
397 }
398 case DCCP_PKT_DATA:
399 ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
400 break;
401 case DCCP_PKT_ACK: {
402 fixed_hdrlen += 8;
403 if (len < fixed_hdrlen) {
404 ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
405 tok2str(dccp_pkt_type_str, "", dccph_type),
406 len - fixed_hdrlen));
407 return;
408 }
409 ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
410 break;
411 }
412 case DCCP_PKT_DATAACK: {
413 fixed_hdrlen += 8;
414 if (len < fixed_hdrlen) {
415 ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
416 tok2str(dccp_pkt_type_str, "", dccph_type),
417 len - fixed_hdrlen));
418 return;
419 }
420 ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
421 break;
422 }
423 case DCCP_PKT_CLOSEREQ:
424 fixed_hdrlen += 8;
425 if (len < fixed_hdrlen) {
426 ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
427 tok2str(dccp_pkt_type_str, "", dccph_type),
428 len - fixed_hdrlen));
429 return;
430 }
431 ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
432 break;
433 case DCCP_PKT_CLOSE:
434 fixed_hdrlen += 8;
435 if (len < fixed_hdrlen) {
436 ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
437 tok2str(dccp_pkt_type_str, "", dccph_type),
438 len - fixed_hdrlen));
439 return;
440 }
441 ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
442 break;
443 case DCCP_PKT_RESET: {
444 const struct dccp_hdr_reset *dhr =
445 (const struct dccp_hdr_reset *)(bp + fixed_hdrlen);
446 fixed_hdrlen += 12;
447 if (len < fixed_hdrlen) {
448 ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
449 tok2str(dccp_pkt_type_str, "", dccph_type),
450 len - fixed_hdrlen));
451 return;
452 }
453 ND_TCHECK(*dhr);
454 ND_PRINT((ndo, "%s (code=%s) ",
455 tok2str(dccp_pkt_type_str, "", dccph_type),
456 dccp_reset_code(EXTRACT_U_1(dhr->dccph_reset_code))));
457 break;
458 }
459 case DCCP_PKT_SYNC:
460 fixed_hdrlen += 8;
461 if (len < fixed_hdrlen) {
462 ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
463 tok2str(dccp_pkt_type_str, "", dccph_type),
464 len - fixed_hdrlen));
465 return;
466 }
467 ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
468 break;
469 case DCCP_PKT_SYNCACK:
470 fixed_hdrlen += 8;
471 if (len < fixed_hdrlen) {
472 ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
473 tok2str(dccp_pkt_type_str, "", dccph_type),
474 len - fixed_hdrlen));
475 return;
476 }
477 ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
478 break;
479 default:
480 ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "unknown-type-%u", dccph_type)));
481 break;
482 }
483
484 if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) &&
485 (DCCPH_TYPE(dh) != DCCP_PKT_REQUEST))
486 dccp_print_ack_no(ndo, bp);
487
488 if (ndo->ndo_vflag < 2)
489 return;
490
491 ND_PRINT((ndo, "seq %" PRIu64, dccp_seqno(bp)));
492
493 /* process options */
494 if (hlen > fixed_hdrlen){
495 u_int optlen;
496 cp = bp + fixed_hdrlen;
497 ND_PRINT((ndo, " <"));
498
499 hlen -= fixed_hdrlen;
500 while(1){
501 optlen = dccp_print_option(ndo, cp, hlen);
502 if (!optlen)
503 break;
504 if (hlen <= optlen)
505 break;
506 hlen -= optlen;
507 cp += optlen;
508 ND_PRINT((ndo, ", "));
509 }
510 ND_PRINT((ndo, ">"));
511 }
512 return;
513 trunc:
514 ND_PRINT((ndo, "%s", tstr));
515 return;
516 }
517
518 static const struct tok dccp_option_values[] = {
519 { 0, "nop" },
520 { 1, "mandatory" },
521 { 2, "slowreceiver" },
522 { 32, "change_l" },
523 { 33, "confirm_l" },
524 { 34, "change_r" },
525 { 35, "confirm_r" },
526 { 36, "initcookie" },
527 { 37, "ndp_count" },
528 { 38, "ack_vector0" },
529 { 39, "ack_vector1" },
530 { 40, "data_dropped" },
531 { 41, "timestamp" },
532 { 42, "timestamp_echo" },
533 { 43, "elapsed_time" },
534 { 44, "data_checksum" },
535 { 0, NULL }
536 };
537
538 static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen)
539 {
540 uint8_t optlen, i;
541
542 ND_TCHECK_1(option);
543
544 if (EXTRACT_U_1(option) >= 32) {
545 ND_TCHECK_1(option + 1);
546 optlen = EXTRACT_U_1(option + 1);
547 if (optlen < 2) {
548 if (EXTRACT_U_1(option) >= 128)
549 ND_PRINT((ndo, "CCID option %u optlen too short", EXTRACT_U_1(option)));
550 else
551 ND_PRINT((ndo, "%s optlen too short",
552 tok2str(dccp_option_values, "Option %u", EXTRACT_U_1(option))));
553 return 0;
554 }
555 } else
556 optlen = 1;
557
558 if (hlen < optlen) {
559 if (EXTRACT_U_1(option) >= 128)
560 ND_PRINT((ndo, "CCID option %u optlen goes past header length",
561 EXTRACT_U_1(option)));
562 else
563 ND_PRINT((ndo, "%s optlen goes past header length",
564 tok2str(dccp_option_values, "Option %u", EXTRACT_U_1(option))));
565 return 0;
566 }
567 ND_TCHECK_LEN(option, optlen);
568
569 if (EXTRACT_U_1(option) >= 128) {
570 ND_PRINT((ndo, "CCID option %d", EXTRACT_U_1(option)));
571 switch (optlen) {
572 case 4:
573 ND_PRINT((ndo, " %u", EXTRACT_BE_U_2(option + 2)));
574 break;
575 case 6:
576 ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(option + 2)));
577 break;
578 default:
579 break;
580 }
581 } else {
582 ND_PRINT((ndo, "%s", tok2str(dccp_option_values, "Option %u", EXTRACT_U_1(option))));
583 switch (EXTRACT_U_1(option)) {
584 case 32:
585 case 33:
586 case 34:
587 case 35:
588 if (optlen < 3) {
589 ND_PRINT((ndo, " optlen too short"));
590 return optlen;
591 }
592 if (EXTRACT_U_1(option + 2) < 10){
593 ND_PRINT((ndo, " %s", dccp_feature_nums[EXTRACT_U_1(option + 2)]));
594 for (i = 0; i < optlen - 3; i++)
595 ND_PRINT((ndo, " %d", EXTRACT_U_1(option + 3 + i)));
596 }
597 break;
598 case 36:
599 if (optlen > 2) {
600 ND_PRINT((ndo, " 0x"));
601 for (i = 0; i < optlen - 2; i++)
602 ND_PRINT((ndo, "%02x", EXTRACT_U_1(option + 2 + i)));
603 }
604 break;
605 case 37:
606 for (i = 0; i < optlen - 2; i++)
607 ND_PRINT((ndo, " %d", EXTRACT_U_1(option + 2 + i)));
608 break;
609 case 38:
610 if (optlen > 2) {
611 ND_PRINT((ndo, " 0x"));
612 for (i = 0; i < optlen - 2; i++)
613 ND_PRINT((ndo, "%02x", EXTRACT_U_1(option + 2 + i)));
614 }
615 break;
616 case 39:
617 if (optlen > 2) {
618 ND_PRINT((ndo, " 0x"));
619 for (i = 0; i < optlen - 2; i++)
620 ND_PRINT((ndo, "%02x", EXTRACT_U_1(option + 2 + i)));
621 }
622 break;
623 case 40:
624 if (optlen > 2) {
625 ND_PRINT((ndo, " 0x"));
626 for (i = 0; i < optlen - 2; i++)
627 ND_PRINT((ndo, "%02x", EXTRACT_U_1(option + 2 + i)));
628 }
629 break;
630 case 41:
631 if (optlen == 4)
632 ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(option + 2)));
633 else
634 ND_PRINT((ndo, " optlen != 4"));
635 break;
636 case 42:
637 if (optlen == 4)
638 ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(option + 2)));
639 else
640 ND_PRINT((ndo, " optlen != 4"));
641 break;
642 case 43:
643 if (optlen == 6)
644 ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(option + 2)));
645 else if (optlen == 4)
646 ND_PRINT((ndo, " %u", EXTRACT_BE_U_2(option + 2)));
647 else
648 ND_PRINT((ndo, " optlen != 4 or 6"));
649 break;
650 case 44:
651 if (optlen > 2) {
652 ND_PRINT((ndo, " "));
653 for (i = 0; i < optlen - 2; i++)
654 ND_PRINT((ndo, "%02x", EXTRACT_U_1(option + 2 + i)));
655 }
656 break;
657 }
658 }
659
660 return optlen;
661 trunc:
662 ND_PRINT((ndo, "%s", tstr));
663 return 0;
664 }