]> The Tcpdump Group git mirrors - tcpdump/blob - print-babel.c
Merge branch 'master' of https://github.com/kivinen/tcpdump into kivinen-master
[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(EXTRACT_U_1(cp) != 42) {
57 ND_PRINT(" invalid header");
58 return;
59 } else {
60 ND_PRINT(" %u", EXTRACT_U_1(cp + 1));
61 }
62
63 switch(EXTRACT_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(const u_char *id)
112 {
113 static char buf[25];
114 nd_snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
115 EXTRACT_U_1(id), EXTRACT_U_1(id + 1), EXTRACT_U_1(id + 2),
116 EXTRACT_U_1(id + 3), EXTRACT_U_1(id + 4), EXTRACT_U_1(id + 5),
117 EXTRACT_U_1(id + 6), EXTRACT_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 nd_snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
131 else
132 nd_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 nd_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 nd_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 = EXTRACT_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 = EXTRACT_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, tok2str(diversity_str, "%u", EXTRACT_U_1(cp)));
306 cp++;
307 sep = "-";
308 sublen--;
309 }
310 if(tlv_type != MESSAGE_UPDATE &&
311 tlv_type != MESSAGE_UPDATE_SRC_SPECIFIC)
312 ND_PRINT(" (bogus)");
313 break;
314 case MESSAGE_SUB_TIMESTAMP:
315 ND_PRINT(" sub-timestamp");
316 if(tlv_type == MESSAGE_HELLO) {
317 if(sublen < 4)
318 goto invalid;
319 t1 = EXTRACT_BE_U_4(cp);
320 ND_PRINT(" %s", format_timestamp(t1));
321 } else if(tlv_type == MESSAGE_IHU) {
322 if(sublen < 8)
323 goto invalid;
324 t1 = EXTRACT_BE_U_4(cp);
325 ND_PRINT(" %s", format_timestamp(t1));
326 t2 = EXTRACT_BE_U_4(cp + 4);
327 ND_PRINT("|%s", format_timestamp(t2));
328 } else
329 ND_PRINT(" (bogus)");
330 cp += sublen;
331 break;
332 default:
333 ND_PRINT(" sub-unknown-0x%02x", subtype);
334 cp += sublen;
335 } /* switch */
336 } /* while */
337 return;
338
339 invalid:
340 nd_print_invalid(ndo);
341 }
342
343 #define ICHECK(i, l) \
344 if ((i) + (l) > bodylen || (i) + (l) > length) goto invalid;
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_TCHECK_4(cp);
357 if (length < 4)
358 goto invalid;
359 bodylen = EXTRACT_BE_U_2(cp + 2);
360 ND_PRINT(" (%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_TCHECK_1(message);
371 if((type = EXTRACT_U_1(message)) == MESSAGE_PAD1) {
372 ND_PRINT(ndo->ndo_vflag ? "\n\tPad 1" : " pad1");
373 i += 1;
374 continue;
375 }
376
377 ND_TCHECK_2(message);
378 ICHECK(i, 2);
379 len = EXTRACT_U_1(message + 1);
380
381 ND_TCHECK_LEN(message, 2 + len);
382 ICHECK(i, 2 + len);
383
384 switch(type) {
385 case MESSAGE_PADN: {
386 if (!ndo->ndo_vflag)
387 ND_PRINT(" padN");
388 else
389 ND_PRINT("\n\tPad %u", len + 2);
390 }
391 break;
392
393 case MESSAGE_ACK_REQ: {
394 u_short nonce, interval;
395 if (!ndo->ndo_vflag)
396 ND_PRINT(" ack-req");
397 else {
398 ND_PRINT("\n\tAcknowledgment Request ");
399 if(len < 6) goto invalid;
400 nonce = EXTRACT_BE_U_2(message + 4);
401 interval = EXTRACT_BE_U_2(message + 6);
402 ND_PRINT("%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(" ack");
411 else {
412 ND_PRINT("\n\tAcknowledgment ");
413 if(len < 2) goto invalid;
414 nonce = EXTRACT_BE_U_2(message + 2);
415 ND_PRINT("%04x", nonce);
416 }
417 }
418 break;
419
420 case MESSAGE_HELLO: {
421 u_short seqno, interval;
422 if (!ndo->ndo_vflag)
423 ND_PRINT(" hello");
424 else {
425 ND_PRINT("\n\tHello ");
426 if(len < 6) goto invalid;
427 seqno = EXTRACT_BE_U_2(message + 4);
428 interval = EXTRACT_BE_U_2(message + 6);
429 ND_PRINT("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 rxcost, interval;
439 if (!ndo->ndo_vflag)
440 ND_PRINT(" ihu");
441 else {
442 u_char address[16];
443 u_char ae;
444 int rc;
445 ND_PRINT("\n\tIHU ");
446 if(len < 6) goto invalid;
447 rxcost = EXTRACT_BE_U_2(message + 4);
448 interval = EXTRACT_BE_U_2(message + 6);
449 ae = EXTRACT_U_1(message + 2);
450 rc = network_address(ae, message + 8,
451 len - 6, address);
452 if(rc < 0) { nd_print_trunc(ndo); break; }
453 ND_PRINT("%s rxcost %u interval %s",
454 ae == 0 ? "any" : format_address(ndo, address),
455 rxcost, format_interval(interval));
456 /* Extra data. */
457 if((u_int)rc < len - 6)
458 subtlvs_print(ndo, message + 8 + rc, message + 2 + len,
459 type);
460 }
461 }
462 break;
463
464 case MESSAGE_ROUTER_ID: {
465 if (!ndo->ndo_vflag)
466 ND_PRINT(" router-id");
467 else {
468 ND_PRINT("\n\tRouter Id");
469 if(len < 10) goto invalid;
470 ND_PRINT(" %s", format_id(message + 4));
471 }
472 }
473 break;
474
475 case MESSAGE_NH: {
476 if (!ndo->ndo_vflag)
477 ND_PRINT(" nh");
478 else {
479 int rc;
480 u_char ae;
481 u_char nh[16];
482 ND_PRINT("\n\tNext Hop");
483 if(len < 2) goto invalid;
484 ae = EXTRACT_U_1(message + 2);
485 rc = network_address(ae, message + 4,
486 len - 2, nh);
487 if(rc < 0) goto invalid;
488 ND_PRINT(" %s", ae == 0 ? "invalid AE 0" : format_address(ndo, nh));
489 }
490 }
491 break;
492
493 case MESSAGE_UPDATE: {
494 if (!ndo->ndo_vflag) {
495 ND_PRINT(" update");
496 if(len < 1)
497 ND_PRINT("/truncated");
498 else
499 ND_PRINT("%s%s%s",
500 (EXTRACT_U_1(message + 3) & 0x80) ? "/prefix": "",
501 (EXTRACT_U_1(message + 3) & 0x40) ? "/id" : "",
502 (EXTRACT_U_1(message + 3) & 0x3f) ? "/unknown" : "");
503 } else {
504 u_short interval, seqno, metric;
505 u_char ae, plen;
506 int rc;
507 u_char prefix[16];
508 ND_PRINT("\n\tUpdate");
509 if(len < 10) goto invalid;
510 ae = EXTRACT_U_1(message + 2);
511 plen = EXTRACT_U_1(message + 4) + (EXTRACT_U_1(message + 2) == 1 ? 96 : 0);
512 rc = network_prefix(ae,
513 EXTRACT_U_1(message + 4),
514 EXTRACT_U_1(message + 5),
515 message + 12,
516 EXTRACT_U_1(message + 2) == 1 ? v4_prefix : v6_prefix,
517 len - 10, prefix);
518 if(rc < 0) goto invalid;
519 interval = EXTRACT_BE_U_2(message + 6);
520 seqno = EXTRACT_BE_U_2(message + 8);
521 metric = EXTRACT_BE_U_2(message + 10);
522 ND_PRINT("%s%s%s %s metric %u seqno %u interval %s",
523 (EXTRACT_U_1(message + 3) & 0x80) ? "/prefix": "",
524 (EXTRACT_U_1(message + 3) & 0x40) ? "/id" : "",
525 (EXTRACT_U_1(message + 3) & 0x3f) ? "/unknown" : "",
526 ae == 0 ? "any" : format_prefix(ndo, prefix, plen),
527 metric, seqno, format_interval_update(interval));
528 if(EXTRACT_U_1(message + 3) & 0x80) {
529 if(EXTRACT_U_1(message + 2) == 1)
530 memcpy(v4_prefix, prefix, 16);
531 else
532 memcpy(v6_prefix, prefix, 16);
533 }
534 /* extra data? */
535 if((u_int)rc < len - 10)
536 subtlvs_print(ndo, message + 12 + rc, message + 2 + len, type);
537 }
538 }
539 break;
540
541 case MESSAGE_ROUTE_REQUEST: {
542 if (!ndo->ndo_vflag)
543 ND_PRINT(" route-request");
544 else {
545 int rc;
546 u_char prefix[16], ae, plen;
547 ND_PRINT("\n\tRoute Request ");
548 if(len < 2) goto invalid;
549 ae = EXTRACT_U_1(message + 2);
550 plen = EXTRACT_U_1(message + 3) + (EXTRACT_U_1(message + 2) == 1 ? 96 : 0);
551 rc = network_prefix(ae,
552 EXTRACT_U_1(message + 3), 0,
553 message + 4, NULL, len - 2, prefix);
554 if(rc < 0) goto invalid;
555 ND_PRINT("for %s",
556 ae == 0 ? "any" : format_prefix(ndo, prefix, plen));
557 }
558 }
559 break;
560
561 case MESSAGE_SEQNO_REQUEST : {
562 if (!ndo->ndo_vflag)
563 ND_PRINT(" seqno-request");
564 else {
565 int rc;
566 u_short seqno;
567 u_char prefix[16], ae, plen;
568 ND_PRINT("\n\tSeqno Request ");
569 if(len < 14) goto invalid;
570 ae = EXTRACT_U_1(message + 2);
571 seqno = EXTRACT_BE_U_2(message + 4);
572 rc = network_prefix(ae,
573 EXTRACT_U_1(message + 3), 0,
574 message + 16, NULL, len - 14, prefix);
575 if(rc < 0) goto invalid;
576 plen = EXTRACT_U_1(message + 3) + (EXTRACT_U_1(message + 2) == 1 ? 96 : 0);
577 ND_PRINT("(%u hops) for %s seqno %u id %s",
578 EXTRACT_U_1(message + 6),
579 ae == 0 ? "invalid AE 0" : format_prefix(ndo, prefix, plen),
580 seqno, format_id(message + 8));
581 }
582 }
583 break;
584 case MESSAGE_TSPC :
585 if (!ndo->ndo_vflag)
586 ND_PRINT(" tspc");
587 else {
588 ND_PRINT("\n\tTS/PC ");
589 if(len < 6) goto invalid;
590 ND_PRINT("timestamp %u packetcounter %u", EXTRACT_BE_U_4(message + 4),
591 EXTRACT_BE_U_2(message + 2));
592 }
593 break;
594 case MESSAGE_HMAC : {
595 if (!ndo->ndo_vflag)
596 ND_PRINT(" hmac");
597 else {
598 unsigned j;
599 ND_PRINT("\n\tHMAC ");
600 if(len < 18) goto invalid;
601 ND_PRINT("key-id %u digest-%u ", EXTRACT_BE_U_2(message + 2), len - 2);
602 for (j = 0; j < len - 2; j++)
603 ND_PRINT("%02X", EXTRACT_U_1(message + j + 4));
604 }
605 }
606 break;
607
608 case MESSAGE_UPDATE_SRC_SPECIFIC : {
609 if(!ndo->ndo_vflag) {
610 ND_PRINT(" ss-update");
611 } else {
612 u_char prefix[16], src_prefix[16];
613 u_short interval, seqno, metric;
614 u_char ae, plen, src_plen, omitted;
615 int rc;
616 int parsed_len = 10;
617 ND_PRINT("\n\tSS-Update");
618 if(len < 10) goto invalid;
619 ae = EXTRACT_U_1(message + 2);
620 src_plen = EXTRACT_U_1(message + 3);
621 plen = EXTRACT_U_1(message + 4);
622 omitted = EXTRACT_U_1(message + 5);
623 interval = EXTRACT_BE_U_2(message + 6);
624 seqno = EXTRACT_BE_U_2(message + 8);
625 metric = EXTRACT_BE_U_2(message + 10);
626 rc = network_prefix(ae, plen, omitted, message + 2 + parsed_len,
627 ae == 1 ? v4_prefix : v6_prefix,
628 len - parsed_len, prefix);
629 if(rc < 0) goto invalid;
630 if(ae == 1)
631 plen += 96;
632 parsed_len += rc;
633 rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
634 NULL, len - parsed_len, src_prefix);
635 if(rc < 0) goto invalid;
636 if(ae == 1)
637 src_plen += 96;
638 parsed_len += rc;
639
640 ND_PRINT(" %s from", format_prefix(ndo, prefix, plen));
641 ND_PRINT(" %s metric %u seqno %u interval %s",
642 format_prefix(ndo, src_prefix, src_plen),
643 metric, seqno, format_interval_update(interval));
644 /* extra data? */
645 if((u_int)parsed_len < len)
646 subtlvs_print(ndo, message + 2 + parsed_len,
647 message + 2 + len, type);
648 }
649 }
650 break;
651
652 case MESSAGE_REQUEST_SRC_SPECIFIC : {
653 if(!ndo->ndo_vflag)
654 ND_PRINT(" ss-request");
655 else {
656 int rc, parsed_len = 3;
657 u_char ae, plen, src_plen, prefix[16], src_prefix[16];
658 ND_PRINT("\n\tSS-Request ");
659 if(len < 3) goto invalid;
660 ae = EXTRACT_U_1(message + 2);
661 plen = EXTRACT_U_1(message + 3);
662 src_plen = EXTRACT_U_1(message + 4);
663 rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
664 NULL, len - parsed_len, prefix);
665 if(rc < 0) goto invalid;
666 if(ae == 1)
667 plen += 96;
668 parsed_len += rc;
669 rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
670 NULL, len - parsed_len, src_prefix);
671 if(rc < 0) goto invalid;
672 if(ae == 1)
673 src_plen += 96;
674 parsed_len += rc;
675 if(ae == 0) {
676 ND_PRINT("for any");
677 } else {
678 ND_PRINT("for (%s, ", format_prefix(ndo, prefix, plen));
679 ND_PRINT("%s)", format_prefix(ndo, src_prefix, src_plen));
680 }
681 }
682 }
683 break;
684
685 case MESSAGE_MH_REQUEST_SRC_SPECIFIC : {
686 if(!ndo->ndo_vflag)
687 ND_PRINT(" ss-mh-request");
688 else {
689 int rc, parsed_len = 14;
690 u_short seqno;
691 u_char ae, plen, src_plen, prefix[16], src_prefix[16], hopc;
692 const u_char *router_id = NULL;
693 ND_PRINT("\n\tSS-MH-Request ");
694 if(len < 14) goto invalid;
695 ae = EXTRACT_U_1(message + 2);
696 plen = EXTRACT_U_1(message + 3);
697 seqno = EXTRACT_BE_U_2(message + 4);
698 hopc = EXTRACT_U_1(message + 6);
699 src_plen = EXTRACT_U_1(message + 7);
700 router_id = message + 8;
701 rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
702 NULL, len - parsed_len, prefix);
703 if(rc < 0) goto invalid;
704 if(ae == 1)
705 plen += 96;
706 parsed_len += rc;
707 rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
708 NULL, len - parsed_len, src_prefix);
709 if(rc < 0) goto invalid;
710 if(ae == 1)
711 src_plen += 96;
712 ND_PRINT("(%u hops) for (%s, ",
713 hopc, format_prefix(ndo, prefix, plen));
714 ND_PRINT("%s) seqno %u id %s",
715 format_prefix(ndo, src_prefix, src_plen),
716 seqno, format_id(router_id));
717 }
718 }
719 break;
720
721 default:
722 if (!ndo->ndo_vflag)
723 ND_PRINT(" unknown");
724 else
725 ND_PRINT("\n\tUnknown message type %u", type);
726 }
727 i += len + 2;
728 }
729 return;
730
731 trunc:
732 nd_print_trunc(ndo);
733 return;
734
735 invalid:
736 nd_print_invalid(ndo);
737 return;
738 }