]> The Tcpdump Group git mirrors - tcpdump/blob - print-babel.c
Babel: address a couple compiler warnings
[tcpdump] / print-babel.c
1 /*
2 * Copyright (c) 2007-2011 Grégoire Henry, Juliusz Chroboczek
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of the project nor the names of its contributors
13 * may be used to endorse or promote products derived from this software
14 * without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include <tcpdump-stdinc.h>
34
35 #include <stdio.h>
36 #include <string.h>
37
38 #include "interface.h"
39 #include "addrtoname.h"
40 #include "extract.h"
41
42 static const char tstr[] = "[|babel]";
43
44 static void babel_print_v2(netdissect_options *, const u_char *cp, u_int length);
45
46 void
47 babel_print(netdissect_options *ndo,
48 const u_char *cp, u_int length)
49 {
50 ND_PRINT((ndo, "babel"));
51
52 ND_TCHECK2(*cp, 4);
53
54 if(cp[0] != 42) {
55 ND_PRINT((ndo, " malformed header"));
56 return;
57 } else {
58 ND_PRINT((ndo, " %d", cp[1]));
59 }
60
61 switch(cp[1]) {
62 case 2:
63 babel_print_v2(ndo, cp, length);
64 break;
65 default:
66 ND_PRINT((ndo, " unknown version"));
67 break;
68 }
69
70 return;
71
72 trunc:
73 ND_PRINT((ndo, " %s", tstr));
74 return;
75 }
76
77 /* TLVs */
78 #define MESSAGE_PAD1 0
79 #define MESSAGE_PADN 1
80 #define MESSAGE_ACK_REQ 2
81 #define MESSAGE_ACK 3
82 #define MESSAGE_HELLO 4
83 #define MESSAGE_IHU 5
84 #define MESSAGE_ROUTER_ID 6
85 #define MESSAGE_NH 7
86 #define MESSAGE_UPDATE 8
87 #define MESSAGE_REQUEST 9
88 #define MESSAGE_MH_REQUEST 10
89 #define MESSAGE_TSPC 11
90 #define MESSAGE_HMAC 12
91 #define MESSAGE_UPDATE_SRC_SPECIFIC 13
92 #define MESSAGE_REQUEST_SRC_SPECIFIC 14
93 #define MESSAGE_MH_REQUEST_SRC_SPECIFIC 15
94
95 /* sub-TLVs */
96 #define MESSAGE_SUB_PAD1 0
97 #define MESSAGE_SUB_PADN 1
98 #define MESSAGE_SUB_DIVERSITY 2
99 #define MESSAGE_SUB_TIMESTAMP 3
100
101 /* Diversity sub-TLV channel codes */
102 static const struct tok diversity_str[] = {
103 { 0, "reserved" },
104 { 255, "all" },
105 { 0, NULL }
106 };
107
108 static const char *
109 format_id(const u_char *id)
110 {
111 static char buf[25];
112 snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
113 id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]);
114 buf[24] = '\0';
115 return buf;
116 }
117
118 static const unsigned char v4prefix[16] =
119 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
120
121 static const char *
122 format_prefix(netdissect_options *ndo, const u_char *prefix, unsigned char plen)
123 {
124 static char buf[50];
125 if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0)
126 snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
127 else
128 #ifdef INET6
129 snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
130 #else
131 snprintf(buf, 50, "IPv6 addresses not supported");
132 #endif
133 buf[49] = '\0';
134 return buf;
135 }
136
137 static const char *
138 format_address(netdissect_options *ndo, const u_char *prefix)
139 {
140 if(memcmp(prefix, v4prefix, 12) == 0)
141 return ipaddr_string(ndo, prefix + 12);
142 else
143 #ifdef INET6
144 return ip6addr_string(ndo, prefix);
145 #else
146 return "IPv6 addresses not supported";
147 #endif
148 }
149
150 static const char *
151 format_interval(const uint16_t i)
152 {
153 static char buf[sizeof("000.00s")];
154
155 if (i == 0)
156 return "0.0s (bogus)";
157 snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100);
158 return buf;
159 }
160
161 static const char *
162 format_interval_update(const uint16_t i)
163 {
164 return i == 0xFFFF ? "infinity" : format_interval(i);
165 }
166
167 static const char *
168 format_timestamp(const uint32_t i)
169 {
170 static char buf[sizeof("0000.000000s")];
171 snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000);
172 return buf;
173 }
174
175 /* Return number of octets consumed from the input buffer (not the prefix length
176 * in bytes), or -1 for encoding error. */
177 static int
178 network_prefix(int ae, int plen, unsigned int omitted,
179 const unsigned char *p, const unsigned char *dp,
180 unsigned int len, unsigned char *p_r)
181 {
182 unsigned pb;
183 unsigned char prefix[16];
184 int consumed = 0;
185
186 if(plen >= 0)
187 pb = (plen + 7) / 8;
188 else if(ae == 1)
189 pb = 4;
190 else
191 pb = 16;
192
193 if(pb > 16)
194 return -1;
195
196 memset(prefix, 0, 16);
197
198 switch(ae) {
199 case 0: break;
200 case 1:
201 if(omitted > 4 || pb > 4 || (pb > omitted && len < pb - omitted))
202 return -1;
203 memcpy(prefix, v4prefix, 12);
204 if(omitted) {
205 if (dp == NULL) return -1;
206 memcpy(prefix, dp, 12 + omitted);
207 }
208 if(pb > omitted) {
209 memcpy(prefix + 12 + omitted, p, pb - omitted);
210 consumed = pb - omitted;
211 }
212 break;
213 case 2:
214 if(omitted > 16 || (pb > omitted && len < pb - omitted))
215 return -1;
216 if(omitted) {
217 if (dp == NULL) return -1;
218 memcpy(prefix, dp, omitted);
219 }
220 if(pb > omitted) {
221 memcpy(prefix + omitted, p, pb - omitted);
222 consumed = pb - omitted;
223 }
224 break;
225 case 3:
226 if(pb > 8 && len < pb - 8) return -1;
227 prefix[0] = 0xfe;
228 prefix[1] = 0x80;
229 if(pb > 8) {
230 memcpy(prefix + 8, p, pb - 8);
231 consumed = pb - 8;
232 }
233 break;
234 default:
235 return -1;
236 }
237
238 memcpy(p_r, prefix, 16);
239 return consumed;
240 }
241
242 static int
243 network_address(int ae, const unsigned char *a, unsigned int len,
244 unsigned char *a_r)
245 {
246 return network_prefix(ae, -1, 0, a, NULL, len, a_r);
247 }
248
249 /*
250 * Sub-TLVs consume the "extra data" of Babel TLVs (see Section 4.3 of RFC6126),
251 * their encoding is similar to the encoding of TLVs, but the type namespace is
252 * different:
253 *
254 * o Type 0 stands for Pad1 sub-TLV with the same encoding as the Pad1 TLV.
255 * o Type 1 stands for PadN sub-TLV with the same encoding as the PadN TLV.
256 * o Type 2 stands for Diversity sub-TLV, which propagates diversity routing
257 * data. Its body is a variable-length sequence of 8-bit unsigned integers,
258 * each representing per-hop number of interferring radio channel for the
259 * prefix. Channel 0 is invalid and must not be used in the sub-TLV, channel
260 * 255 interferes with any other channel.
261 * o Type 3 stands for Timestamp sub-TLV, used to compute RTT between
262 * neighbours. In the case of a Hello TLV, the body stores a 32-bits
263 * timestamp, while in the case of a IHU TLV, two 32-bits timestamps are
264 * stored.
265 *
266 * Sub-TLV types 0 and 1 are valid for any TLV type, whether sub-TLV type 2 is
267 * only valid for TLV type 8 (Update). Note that within an Update TLV a missing
268 * Diversity sub-TLV is not the same as a Diversity sub-TLV with an empty body.
269 * The former would mean a lack of any claims about the interference, and the
270 * latter would state that interference is definitely absent.
271 * A type 3 sub-TLV is valid both for Hello and IHU TLVs, though the exact
272 * semantic of the sub-TLV is different in each case.
273 */
274 static void
275 subtlvs_print(netdissect_options *ndo,
276 const u_char *cp, const u_char *ep, const uint8_t tlv_type)
277 {
278 uint8_t subtype, sublen;
279 const char *sep;
280 uint32_t t1, t2;
281
282 while (cp < ep) {
283 subtype = *cp++;
284 if(subtype == MESSAGE_SUB_PAD1) {
285 ND_PRINT((ndo, " sub-pad1"));
286 continue;
287 }
288 if(cp == ep)
289 goto corrupt;
290 sublen = *cp++;
291 if(cp + sublen > ep)
292 goto corrupt;
293
294 switch(subtype) {
295 case MESSAGE_SUB_PADN:
296 ND_PRINT((ndo, " sub-padn"));
297 cp += sublen;
298 break;
299 case MESSAGE_SUB_DIVERSITY:
300 ND_PRINT((ndo, " sub-diversity"));
301 if (sublen == 0) {
302 ND_PRINT((ndo, " empty"));
303 break;
304 }
305 sep = " ";
306 while(sublen--) {
307 ND_PRINT((ndo, "%s%s", sep, tok2str(diversity_str, "%u", *cp++)));
308 sep = "-";
309 }
310 if(tlv_type != MESSAGE_UPDATE &&
311 tlv_type != MESSAGE_UPDATE_SRC_SPECIFIC)
312 ND_PRINT((ndo, " (bogus)"));
313 break;
314 case MESSAGE_SUB_TIMESTAMP:
315 ND_PRINT((ndo, " sub-timestamp"));
316 if(tlv_type == MESSAGE_HELLO) {
317 if(sublen < 4)
318 goto corrupt;
319 t1 = EXTRACT_32BITS(cp);
320 ND_PRINT((ndo, " %s", format_timestamp(t1)));
321 } else if(tlv_type == MESSAGE_IHU) {
322 if(sublen < 8)
323 goto corrupt;
324 t1 = EXTRACT_32BITS(cp);
325 ND_PRINT((ndo, " %s", format_timestamp(t1)));
326 t2 = EXTRACT_32BITS(cp + 4);
327 ND_PRINT((ndo, "|%s", format_timestamp(t2)));
328 } else
329 ND_PRINT((ndo, " (bogus)"));
330 cp += sublen;
331 break;
332 default:
333 ND_PRINT((ndo, " sub-unknown-0x%02x", subtype));
334 cp += sublen;
335 } /* switch */
336 } /* while */
337 return;
338
339 corrupt:
340 ND_PRINT((ndo, " (corrupt)"));
341 }
342
343 #define ICHECK(i, l) \
344 if ((i) + (l) > bodylen || (i) + (l) > length) goto corrupt;
345
346 static void
347 babel_print_v2(netdissect_options *ndo,
348 const u_char *cp, u_int length)
349 {
350 u_int i;
351 u_short bodylen;
352 u_char v4_prefix[16] =
353 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
354 u_char v6_prefix[16] = {0};
355
356 ND_TCHECK2(*cp, 4);
357 if (length < 4)
358 goto corrupt;
359 bodylen = EXTRACT_16BITS(cp + 2);
360 ND_PRINT((ndo, " (%u)", bodylen));
361
362 /* Process the TLVs in the body */
363 i = 0;
364 while(i < bodylen) {
365 const u_char *message;
366 u_int type, len;
367
368 message = cp + 4 + i;
369
370 ND_TCHECK2(*message, 1);
371 if((type = message[0]) == MESSAGE_PAD1) {
372 ND_PRINT((ndo, ndo->ndo_vflag ? "\n\tPad 1" : " pad1"));
373 i += 1;
374 continue;
375 }
376
377 ND_TCHECK2(*message, 2);
378 ICHECK(i, 2);
379 len = message[1];
380
381 ND_TCHECK2(*message, 2 + len);
382 ICHECK(i, 2 + len);
383
384 switch(type) {
385 case MESSAGE_PADN: {
386 if (!ndo->ndo_vflag)
387 ND_PRINT((ndo, " padN"));
388 else
389 ND_PRINT((ndo, "\n\tPad %d", len + 2));
390 }
391 break;
392
393 case MESSAGE_ACK_REQ: {
394 u_short nonce, interval;
395 if (!ndo->ndo_vflag)
396 ND_PRINT((ndo, " ack-req"));
397 else {
398 ND_PRINT((ndo, "\n\tAcknowledgment Request "));
399 if(len < 6) goto corrupt;
400 nonce = EXTRACT_16BITS(message + 4);
401 interval = EXTRACT_16BITS(message + 6);
402 ND_PRINT((ndo, "%04x %s", nonce, format_interval(interval)));
403 }
404 }
405 break;
406
407 case MESSAGE_ACK: {
408 u_short nonce;
409 if (!ndo->ndo_vflag)
410 ND_PRINT((ndo, " ack"));
411 else {
412 ND_PRINT((ndo, "\n\tAcknowledgment "));
413 if(len < 2) goto corrupt;
414 nonce = EXTRACT_16BITS(message + 2);
415 ND_PRINT((ndo, "%04x", nonce));
416 }
417 }
418 break;
419
420 case MESSAGE_HELLO: {
421 u_short seqno, interval;
422 if (!ndo->ndo_vflag)
423 ND_PRINT((ndo, " hello"));
424 else {
425 ND_PRINT((ndo, "\n\tHello "));
426 if(len < 6) goto corrupt;
427 seqno = EXTRACT_16BITS(message + 4);
428 interval = EXTRACT_16BITS(message + 6);
429 ND_PRINT((ndo, "seqno %u interval %s", seqno, format_interval(interval)));
430 /* Extra data. */
431 if(len > 6)
432 subtlvs_print(ndo, message + 8, message + 2 + len, type);
433 }
434 }
435 break;
436
437 case MESSAGE_IHU: {
438 unsigned short txcost, interval;
439 if (!ndo->ndo_vflag)
440 ND_PRINT((ndo, " ihu"));
441 else {
442 u_char address[16];
443 int rc;
444 ND_PRINT((ndo, "\n\tIHU "));
445 if(len < 6) goto corrupt;
446 txcost = EXTRACT_16BITS(message + 4);
447 interval = EXTRACT_16BITS(message + 6);
448 rc = network_address(message[2], message + 8, len - 6, address);
449 if(rc < 0) { ND_PRINT((ndo, "%s", tstr)); break; }
450 ND_PRINT((ndo, "%s txcost %u interval %s",
451 format_address(ndo, address), txcost, format_interval(interval)));
452 /* Extra data. */
453 if((u_int)rc < len - 6)
454 subtlvs_print(ndo, message + 8 + rc, message + 2 + len,
455 type);
456 }
457 }
458 break;
459
460 case MESSAGE_ROUTER_ID: {
461 if (!ndo->ndo_vflag)
462 ND_PRINT((ndo, " router-id"));
463 else {
464 ND_PRINT((ndo, "\n\tRouter Id"));
465 if(len < 10) goto corrupt;
466 ND_PRINT((ndo, " %s", format_id(message + 4)));
467 }
468 }
469 break;
470
471 case MESSAGE_NH: {
472 if (!ndo->ndo_vflag)
473 ND_PRINT((ndo, " nh"));
474 else {
475 int rc;
476 u_char nh[16];
477 ND_PRINT((ndo, "\n\tNext Hop"));
478 if(len < 2) goto corrupt;
479 rc = network_address(message[2], message + 4, len - 2, nh);
480 if(rc < 0) goto corrupt;
481 ND_PRINT((ndo, " %s", format_address(ndo, nh)));
482 }
483 }
484 break;
485
486 case MESSAGE_UPDATE: {
487 if (!ndo->ndo_vflag) {
488 ND_PRINT((ndo, " update"));
489 if(len < 1)
490 ND_PRINT((ndo, "/truncated"));
491 else
492 ND_PRINT((ndo, "%s%s%s",
493 (message[3] & 0x80) ? "/prefix": "",
494 (message[3] & 0x40) ? "/id" : "",
495 (message[3] & 0x3f) ? "/unknown" : ""));
496 } else {
497 u_short interval, seqno, metric;
498 u_char plen;
499 int rc;
500 u_char prefix[16];
501 ND_PRINT((ndo, "\n\tUpdate"));
502 if(len < 10) goto corrupt;
503 plen = message[4] + (message[2] == 1 ? 96 : 0);
504 rc = network_prefix(message[2], message[4], message[5],
505 message + 12,
506 message[2] == 1 ? v4_prefix : v6_prefix,
507 len - 10, prefix);
508 if(rc < 0) goto corrupt;
509 interval = EXTRACT_16BITS(message + 6);
510 seqno = EXTRACT_16BITS(message + 8);
511 metric = EXTRACT_16BITS(message + 10);
512 ND_PRINT((ndo, "%s%s%s %s metric %u seqno %u interval %s",
513 (message[3] & 0x80) ? "/prefix": "",
514 (message[3] & 0x40) ? "/id" : "",
515 (message[3] & 0x3f) ? "/unknown" : "",
516 format_prefix(ndo, prefix, plen),
517 metric, seqno, format_interval_update(interval)));
518 if(message[3] & 0x80) {
519 if(message[2] == 1)
520 memcpy(v4_prefix, prefix, 16);
521 else
522 memcpy(v6_prefix, prefix, 16);
523 }
524 /* extra data? */
525 if((u_int)rc < len - 10)
526 subtlvs_print(ndo, message + 12 + rc, message + 2 + len, type);
527 }
528 }
529 break;
530
531 case MESSAGE_REQUEST: {
532 if (!ndo->ndo_vflag)
533 ND_PRINT((ndo, " request"));
534 else {
535 int rc;
536 u_char prefix[16], plen;
537 ND_PRINT((ndo, "\n\tRequest "));
538 if(len < 2) goto corrupt;
539 plen = message[3] + (message[2] == 1 ? 96 : 0);
540 rc = network_prefix(message[2], message[3], 0,
541 message + 4, NULL, len - 2, prefix);
542 if(rc < 0) goto corrupt;
543 ND_PRINT((ndo, "for %s",
544 message[2] == 0 ? "any" : format_prefix(ndo, prefix, plen)));
545 }
546 }
547 break;
548
549 case MESSAGE_MH_REQUEST : {
550 if (!ndo->ndo_vflag)
551 ND_PRINT((ndo, " mh-request"));
552 else {
553 int rc;
554 u_short seqno;
555 u_char prefix[16], plen;
556 ND_PRINT((ndo, "\n\tMH-Request "));
557 if(len < 14) goto corrupt;
558 seqno = EXTRACT_16BITS(message + 4);
559 rc = network_prefix(message[2], message[3], 0,
560 message + 16, NULL, len - 14, prefix);
561 if(rc < 0) goto corrupt;
562 plen = message[3] + (message[2] == 1 ? 96 : 0);
563 ND_PRINT((ndo, "(%u hops) for %s seqno %u id %s",
564 message[6], format_prefix(ndo, prefix, plen),
565 seqno, format_id(message + 8)));
566 }
567 }
568 break;
569 case MESSAGE_TSPC :
570 if (!ndo->ndo_vflag)
571 ND_PRINT((ndo, " tspc"));
572 else {
573 ND_PRINT((ndo, "\n\tTS/PC "));
574 if(len < 6) goto corrupt;
575 ND_PRINT((ndo, "timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4),
576 EXTRACT_16BITS(message + 2)));
577 }
578 break;
579 case MESSAGE_HMAC : {
580 if (!ndo->ndo_vflag)
581 ND_PRINT((ndo, " hmac"));
582 else {
583 unsigned j;
584 ND_PRINT((ndo, "\n\tHMAC "));
585 if(len < 18) goto corrupt;
586 ND_PRINT((ndo, "key-id %u digest-%u ", EXTRACT_16BITS(message + 2), len - 2));
587 for (j = 0; j < len - 2; j++)
588 ND_PRINT((ndo, "%02X", message[4 + j]));
589 }
590 }
591 break;
592
593 case MESSAGE_UPDATE_SRC_SPECIFIC : {
594 if(!ndo->ndo_vflag) {
595 ND_PRINT((ndo, " ss-update"));
596 } else {
597 u_char prefix[16], src_prefix[16];
598 u_short interval, seqno, metric;
599 u_char ae, plen, src_plen, omitted;
600 int rc;
601 int parsed_len = 10;
602 ND_PRINT((ndo, "\n\tSS-Update"));
603 if(len < 10) goto corrupt;
604 ae = message[2];
605 src_plen = message[3];
606 plen = message[4];
607 omitted = message[5];
608 interval = EXTRACT_16BITS(message + 6);
609 seqno = EXTRACT_16BITS(message + 8);
610 metric = EXTRACT_16BITS(message + 10);
611 rc = network_prefix(ae, plen, omitted, message + 2 + parsed_len,
612 ae == 1 ? v4_prefix : v6_prefix,
613 len - parsed_len, prefix);
614 if(rc < 0) goto corrupt;
615 if(ae == 1)
616 plen += 96;
617 parsed_len += rc;
618 rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
619 NULL, len - parsed_len, src_prefix);
620 if(rc < 0) goto corrupt;
621 if(ae == 1)
622 src_plen += 96;
623 parsed_len += rc;
624
625 ND_PRINT((ndo, " %s from", format_prefix(ndo, prefix, plen)));
626 ND_PRINT((ndo, " %s metric %u seqno %u interval %s",
627 format_prefix(ndo, src_prefix, src_plen),
628 metric, seqno, format_interval_update(interval)));
629 /* extra data? */
630 if((u_int)parsed_len < len)
631 subtlvs_print(ndo, message + 2 + parsed_len,
632 message + 2 + len, type);
633 }
634 }
635 break;
636
637 case MESSAGE_REQUEST_SRC_SPECIFIC : {
638 if(!ndo->ndo_vflag)
639 ND_PRINT((ndo, " ss-request"));
640 else {
641 int rc, parsed_len = 3;
642 u_char ae, plen, src_plen, prefix[16], src_prefix[16];
643 ND_PRINT((ndo, "\n\tSS-Request "));
644 if(len < 3) goto corrupt;
645 ae = message[2];
646 plen = message[3];
647 src_plen = message[4];
648 rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
649 NULL, len - parsed_len, prefix);
650 if(rc < 0) goto corrupt;
651 if(ae == 1)
652 plen += 96;
653 parsed_len += rc;
654 rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
655 NULL, len - parsed_len, src_prefix);
656 if(rc < 0) goto corrupt;
657 if(ae == 1)
658 src_plen += 96;
659 parsed_len += rc;
660 if(ae == 0) {
661 ND_PRINT((ndo, "for any"));
662 } else {
663 ND_PRINT((ndo, "for (%s, ", format_prefix(ndo, prefix, plen)));
664 ND_PRINT((ndo, "%s)", format_prefix(ndo, src_prefix, src_plen)));
665 }
666 }
667 }
668 break;
669
670 case MESSAGE_MH_REQUEST_SRC_SPECIFIC : {
671 if(!ndo->ndo_vflag)
672 ND_PRINT((ndo, " ss-mh-request"));
673 else {
674 int rc, parsed_len = 14;
675 u_short seqno;
676 u_char ae, plen, src_plen, prefix[16], src_prefix[16], hopc;
677 const u_char *router_id = NULL;
678 ND_PRINT((ndo, "\n\tSS-MH-Request "));
679 if(len < 14) goto corrupt;
680 ae = message[2];
681 plen = message[3];
682 seqno = EXTRACT_16BITS(message + 4);
683 hopc = message[6];
684 src_plen = message[7];
685 router_id = message + 8;
686 rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
687 NULL, len - parsed_len, prefix);
688 if(rc < 0) goto corrupt;
689 if(ae == 1)
690 plen += 96;
691 parsed_len += rc;
692 rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
693 NULL, len - parsed_len, src_prefix);
694 if(rc < 0) goto corrupt;
695 if(ae == 1)
696 src_plen += 96;
697 ND_PRINT((ndo, "(%u hops) for (%s, ",
698 hopc, format_prefix(ndo, prefix, plen)));
699 ND_PRINT((ndo, "%s) seqno %u id %s",
700 format_prefix(ndo, src_prefix, src_plen),
701 seqno, format_id(router_id)));
702 }
703 }
704 break;
705
706 default:
707 if (!ndo->ndo_vflag)
708 ND_PRINT((ndo, " unknown"));
709 else
710 ND_PRINT((ndo, "\n\tUnknown message type %d", type));
711 }
712 i += len + 2;
713 }
714 return;
715
716 trunc:
717 ND_PRINT((ndo, " %s", tstr));
718 return;
719
720 corrupt:
721 ND_PRINT((ndo, " (corrupt)"));
722 return;
723 }