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