- 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);
-#ifdef INET6
- if (ip6 != NULL) {
- for (; i -= j >= 0; ++dp6) {
- printf(" {%s}(%d)", ip6addr_string(&dp6->u_da),
- EXTRACT_32BITS(dp6->u_ds));
- }
- } else
-#endif
- {
- for (; i -= j >= 0; ++dp) {
- printf(" {%s}(%d)", ipaddr_string(dp->u_da),
- EXTRACT_32BITS(dp->u_ds));
- }
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|rerr]"));
+}
+
+static void
+aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
+{
+ u_int i;
+ const struct aodv_rreq6_draft_01 *ap = (const struct aodv_rreq6_draft_01 *)dat;
+
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
+ "\tdst %s seq %lu src %s seq %lu", length,
+ ap->rreq_type & RREQ_JOIN ? "[J]" : "",
+ ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
+ ap->rreq_type & RREQ_GRAT ? "[G]" : "",
+ ap->rreq_type & RREQ_DEST ? "[D]" : "",
+ ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
+ ap->rreq_hops,
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_id),
+ ip6addr_string(ndo, &ap->rreq_da),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
+ ip6addr_string(ndo, &ap->rreq_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
+ i = length - sizeof(*ap);
+ if (i >= sizeof(struct aodv_ext))
+ aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|rreq"));
+}
+
+static void
+aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
+{
+ u_int i;
+ const struct aodv_rrep6_draft_01 *ap = (const struct aodv_rrep6_draft_01 *)dat;
+
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " 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(ndo, &ap->rrep_da),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
+ ip6addr_string(ndo, &ap->rrep_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
+ i = length - sizeof(*ap);
+ if (i >= sizeof(struct aodv_ext))
+ aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|rreq"));
+}
+
+static void
+aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
+{
+ u_int i, dc;
+ const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
+ const struct rerr_unreach6_draft_01 *dp6;
+
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
+ ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
+ ap->rerr_dc, length));
+ dp6 = (const struct rerr_unreach6_draft_01 *)(const void *)(ap + 1);
+ i = length - sizeof(*ap);
+ for (dc = ap->rerr_dc; dc != 0; dc--) {
+ ND_TCHECK(*dp6);
+ if (i < sizeof(*dp6))
+ goto trunc;
+ ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
+ (unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
+ dp6++;
+ i -= sizeof(*dp6);