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