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