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