From: guy Date: Sat, 13 Sep 2003 01:34:42 +0000 (+0000) Subject: The now-expired draft-perkins-aodv6-01 specified a different order for X-Git-Tag: tcpdump-3.8-bp~47 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/f8751069031ea09bb110464c292d23528abad092 The now-expired draft-perkins-aodv6-01 specified a different order for fields in most of the AODV messages when used with V6; print those correctly. Get rid of some "v6" tags that weren't there before my previous checkin. --- diff --git a/aodv.h b/aodv.h index 6b8315b6..456ec8b3 100644 --- a/aodv.h +++ b/aodv.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/aodv.h,v 1.2 2003-09-12 22:05:56 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/aodv.h,v 1.3 2003-09-13 01:34:42 guy Exp $ (LBL) */ /* * Copyright (c) 2003 Bruce M. Simpson * All rights reserved. @@ -56,6 +56,17 @@ struct aodv_rreq6 { struct in6_addr rreq_oa; /* originator IPv6 address */ u_int32_t rreq_os; /* originator sequence number */ }; +struct aodv_rreq6_draft_01 { + u_int8_t rreq_type; /* AODV message type (16) */ + u_int8_t rreq_flags; /* various flags */ + u_int8_t rreq_zero0; /* reserved, set to zero */ + u_int8_t rreq_hops; /* number of hops from originator */ + u_int32_t rreq_id; /* request ID */ + u_int32_t rreq_ds; /* destination sequence number */ + u_int32_t rreq_os; /* originator sequence number */ + struct in6_addr rreq_da; /* destination IPv6 address */ + struct in6_addr rreq_oa; /* originator IPv6 address */ +}; #endif #define RREQ_JOIN 0x80 /* join (reserved for multicast */ @@ -86,6 +97,16 @@ struct aodv_rrep6 { struct in6_addr rrep_oa; /* originator IPv6 address */ u_int32_t rrep_life; /* lifetime of this route */ }; +struct aodv_rrep6_draft_01 { + u_int8_t rrep_type; /* AODV message type (17) */ + u_int8_t rrep_flags; /* various flags */ + u_int8_t rrep_ps; /* prefix size */ + u_int8_t rrep_hops; /* number of hops from o to d */ + u_int32_t rrep_ds; /* destination sequence number */ + struct in6_addr rrep_da; /* destination IPv6 address */ + struct in6_addr rrep_oa; /* originator IPv6 address */ + u_int32_t rrep_life; /* lifetime of this route */ +}; #endif #define RREP_REPAIR 0x80 /* repair (reserved for multicast */ @@ -102,10 +123,14 @@ struct rerr_unreach6 { struct in6_addr u_da; /* IPv6 address */ u_int32_t u_ds; /* sequence number */ }; +struct rerr_unreach6_draft_01 { + struct in6_addr u_da; /* IPv6 address */ + u_int32_t u_ds; /* sequence number */ +}; #endif struct aodv_rerr { - u_int8_t rerr_type; /* AODV message type (3) */ + u_int8_t rerr_type; /* AODV message type (3 or 18) */ u_int8_t rerr_flags; /* various flags */ u_int8_t rerr_zero0; /* reserved, set to zero */ u_int8_t rerr_dc; /* destination count */ @@ -113,6 +138,7 @@ struct aodv_rerr { struct rerr_unreach dest[1]; #ifdef INET6 struct rerr_unreach6 dest6[1]; + struct rerr_unreach6_draft_01 dest6_draft_01[1]; #endif } r; }; @@ -132,7 +158,9 @@ union aodv { struct aodv_rrep_ack rrep_ack; #ifdef INET6 struct aodv_rreq6 rreq6; + struct aodv_rreq6_draft_01 rreq6_draft_01; struct aodv_rrep6 rrep6; + struct aodv_rrep6_draft_01 rrep6_draft_01; #endif }; @@ -141,10 +169,10 @@ union aodv { #define AODV_RERR 3 /* error report */ #define AODV_RREP_ACK 4 /* route response acknowledgement */ -#define AODV_V6_RREQ 16 /* IPv6 route request */ -#define AODV_V6_RREP 17 /* IPv6 route response */ -#define AODV_V6_RERR 18 /* IPv6 error report */ -#define AODV_V6_RREP_ACK 19 /* IPV6 route response acknowledgment */ +#define AODV_V6_DRAFT_01_RREQ 16 /* IPv6 route request */ +#define AODV_V6_DRAFT_01_RREP 17 /* IPv6 route response */ +#define AODV_V6_DRAFT_01_RERR 18 /* IPv6 error report */ +#define AODV_V6_DRAFT_01_RREP_ACK 19 /* IPV6 route response acknowledgment */ struct aodv_ext { u_int8_t type; /* extension type */ diff --git a/print-aodv.c b/print-aodv.c index 253c2e0b..c3d97ae1 100644 --- a/print-aodv.c +++ b/print-aodv.c @@ -32,7 +32,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.7 2003-09-12 22:16:53 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.8 2003-09-13 01:34:42 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -237,7 +237,7 @@ aodv_v6_rrep(const union aodv *ap _U_, const u_char *dat _U_, u_int length) if (i >= sizeof(struct aodv_ext)) aodv_extension((void *)(&ap->rrep6 + 1), i); #else - printf(" v6 rrep %u", length); + printf(" rrep %u", length); #endif } @@ -267,7 +267,116 @@ aodv_v6_rerr(const union aodv *ap _U_, u_int length) if (trunc) printf("[|rerr]"); #else - printf(" v6 rerr %u", length); + printf(" rerr %u", length); +#endif +} + +static void +#ifdef INET6 +aodv_v6_draft_01_rreq(const union aodv *ap, const u_char *dat, u_int length) +#else +aodv_v6_draft_01_rreq(const union aodv *ap _U_, const u_char *dat _U_, + u_int length) +#endif +{ +#ifdef INET6 + u_int i; + + if (snapend < dat) { + printf(" [|aodv]"); + return; + } + i = min(length, (u_int)(snapend - dat)); + if (i < sizeof(ap->rreq6_draft_01)) { + printf(" [|rreq6]"); + return; + } + i -= sizeof(ap->rreq6_draft_01); + printf(" rreq %u %s%s%s%s%shops %u id 0x%08lx\n" + "\tdst %s seq %lu src %s seq %lu", length, + ap->rreq6_draft_01.rreq_type & RREQ_JOIN ? "[J]" : "", + ap->rreq6_draft_01.rreq_type & RREQ_REPAIR ? "[R]" : "", + ap->rreq6_draft_01.rreq_type & RREQ_GRAT ? "[G]" : "", + ap->rreq6_draft_01.rreq_type & RREQ_DEST ? "[D]" : "", + ap->rreq6_draft_01.rreq_type & RREQ_UNKNOWN ? "[U] " : " ", + ap->rreq6_draft_01.rreq_hops, + (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_id), + ip6addr_string(&ap->rreq6_draft_01.rreq_da), + (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_ds), + ip6addr_string(&ap->rreq6_draft_01.rreq_oa), + (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_os)); + if (i >= sizeof(struct aodv_ext)) + aodv_extension((void *)(&ap->rreq6_draft_01 + 1), i); +#else + printf(" rreq %u", length); +#endif +} + +static void +#ifdef INET6 +aodv_v6_draft_01_rrep(const union aodv *ap, const u_char *dat, u_int length) +#else +aodv_v6_draft_01_rrep(const union aodv *ap _U_, const u_char *dat _U_, + u_int length) +#endif +{ +#ifdef INET6 + u_int i; + + if (snapend < dat) { + printf(" [|aodv]"); + return; + } + i = min(length, (u_int)(snapend - dat)); + if (i < sizeof(ap->rrep6_draft_01)) { + printf(" [|rrep6]"); + return; + } + i -= sizeof(ap->rrep6_draft_01); + printf(" rrep %u %s%sprefix %u hops %u\n" + "\tdst %s dseq %lu src %s %lu ms", length, + ap->rrep6_draft_01.rrep_type & RREP_REPAIR ? "[R]" : "", + ap->rrep6_draft_01.rrep_type & RREP_ACK ? "[A] " : " ", + ap->rrep6_draft_01.rrep_ps & RREP_PREFIX_MASK, + ap->rrep6_draft_01.rrep_hops, + ip6addr_string(&ap->rrep6_draft_01.rrep_da), + (unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_ds), + ip6addr_string(&ap->rrep6_draft_01.rrep_oa), + (unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_life)); + if (i >= sizeof(struct aodv_ext)) + aodv_extension((void *)(&ap->rrep6_draft_01 + 1), i); +#else + printf(" rrep %u", length); +#endif +} + +static void +#ifdef INET6 +aodv_v6_draft_01_rerr(const union aodv *ap, u_int length) +#else +aodv_v6_draft_01_rerr(const union aodv *ap _U_, u_int length) +#endif +{ +#ifdef INET6 + const struct rerr_unreach6_draft_01 *dp6 = NULL; + int i, j, n, trunc; + + i = length - offsetof(struct aodv_rerr, r); + j = sizeof(ap->rerr.r.dest6_draft_01[0]); + dp6 = &ap->rerr.r.dest6_draft_01[0]; + n = ap->rerr.rerr_dc * j; + printf(" rerr %s [items %u] [%u]:", + ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "", + ap->rerr.rerr_dc, length); + trunc = n - (i/j); + for (; i -= j >= 0; ++dp6) { + printf(" {%s}(%ld)", ip6addr_string(&dp6->u_da), + (unsigned long)EXTRACT_32BITS(&dp6->u_ds)); + } + if (trunc) + printf("[|rerr]"); +#else + printf(" rerr %u", length); #endif } @@ -314,20 +423,20 @@ aodv_print(const u_char *dat, u_int length, int is_ip6) printf(" rrep-ack %u", length); break; - case AODV_V6_RREQ: - aodv_v6_rreq(ap, dat, length); + case AODV_V6_DRAFT_01_RREQ: + aodv_v6_draft_01_rreq(ap, dat, length); break; - case AODV_V6_RREP: - aodv_v6_rrep(ap, dat, length); + case AODV_V6_DRAFT_01_RREP: + aodv_v6_draft_01_rrep(ap, dat, length); break; - case AODV_V6_RERR: - aodv_v6_rerr(ap, length); + case AODV_V6_DRAFT_01_RERR: + aodv_v6_draft_01_rerr(ap, length); break; - case AODV_V6_RREP_ACK: - printf(" v6 rrep-ack %u", length); + case AODV_V6_DRAFT_01_RREP_ACK: + printf(" rrep-ack %u", length); break; default: