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