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