- const struct rerr_unreach6 *dp6 = NULL;
- int i, j, n, trunc;
-
- i = length - offsetof(struct aodv_rerr, r);
- j = sizeof(ap->rerr.r.dest6[0]);
- dp6 = &ap->rerr.r.dest6[0];
- n = ap->rerr.rerr_dc * j;
- printf(" rerr %s [items %d] [%d]:",
- ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
- ap->rerr.rerr_dc, length);
- trunc = n - (i/j);
- for (; i -= j >= 0; ++dp6) {
- printf(" {%s}(%d)", ip6addr_string(&dp6->u_da),
- EXTRACT_32BITS(&dp6->u_ds));
+ u_int i;
+ const struct aodv_rrep6_draft_01 *ap = (const struct aodv_rrep6_draft_01 *)dat;
+
+ TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ printf(" rrep %u %s%sprefix %u hops %u\n"
+ "\tdst %s dseq %lu src %s %lu ms", length,
+ ap->rrep_type & RREP_REPAIR ? "[R]" : "",
+ ap->rrep_type & RREP_ACK ? "[A] " : " ",
+ ap->rrep_ps & RREP_PREFIX_MASK,
+ ap->rrep_hops,
+ ip6addr_string(&ap->rrep_da),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
+ ip6addr_string(&ap->rrep_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep_life));
+ i = length - sizeof(*ap);
+ if (i >= sizeof(struct aodv_ext))
+ aodv_extension((const struct aodv_ext *)(dat + sizeof(*ap)), i);
+ return;
+
+trunc:
+ printf(" [|rreq");
+#else
+ printf(" rrep %u", length);
+#endif
+}
+
+static void
+#ifdef INET6
+aodv_v6_draft_01_rerr(const u_char *dat, u_int length)
+#else
+aodv_v6_draft_01_rerr(const u_char *dat _U_, u_int length)
+#endif
+{
+#ifdef INET6
+ u_int i, dc;
+ const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
+ const struct rerr_unreach6_draft_01 *dp6;
+
+ TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ printf(" rerr %s [items %u] [%u]:",
+ ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
+ ap->rerr_dc, length);
+ dp6 = (struct rerr_unreach6_draft_01 *)(void *)(ap + 1);
+ i = length - sizeof(*ap);
+ for (dc = ap->rerr_dc; dc != 0; dc--) {
+ TCHECK(*dp6);
+ if (i < sizeof(*dp6))
+ goto trunc;
+ printf(" {%s}(%ld)", ip6addr_string(&dp6->u_da),
+ (unsigned long)EXTRACT_32BITS(&dp6->u_ds));
+ dp6++;
+ i -= sizeof(*dp6);