]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-dvmrp.c
Handle very large -f files by rejecting them.
[tcpdump] / print-dvmrp.c
index 76a86445674edb125989eb1cc238411312fbffce..36a8d5ba8ec6417cd745b82c49cb6db362e5991a 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
+/* \summary: Distance Vector Multicast Routing Protocol printer */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
 
 /*
+ * See: RFC 1075 and draft-ietf-idmr-dvmrp-v3
+ *
  * DVMRP message types and flag values shamelessly stolen from
  * mrouted/dvmrp.h.
  */
 static int print_probe(netdissect_options *, const u_char *, const u_char *, u_int);
 static int print_report(netdissect_options *, const u_char *, const u_char *, u_int);
 static int print_neighbors(netdissect_options *, const u_char *, const u_char *, u_int);
-static int print_neighbors2(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_neighbors2(netdissect_options *, const u_char *, const u_char *, u_int, uint8_t, uint8_t);
 static int print_prune(netdissect_options *, const u_char *);
 static int print_graft(netdissect_options *, const u_char *);
 static int print_graft_ack(netdissect_options *, const u_char *);
 
-static u_int32_t target_level;
-
 void
 dvmrp_print(netdissect_options *ndo,
             register const u_char *bp, register u_int len)
 {
        register const u_char *ep;
        register u_char type;
+       uint8_t major_version, minor_version;
 
        ep = (const u_char *)ndo->ndo_snapend;
        if (bp >= ep)
@@ -117,15 +119,15 @@ dvmrp_print(netdissect_options *ndo,
        case DVMRP_NEIGHBORS2:
                ND_PRINT((ndo, " Neighbors2"));
                /*
-                * extract version and capabilities from IGMP group
-                * address field
+                * extract version from IGMP group address field
                 */
                bp -= 4;
                ND_TCHECK2(bp[0], 4);
-               target_level = (bp[0] << 24) | (bp[1] << 16) |
-                   (bp[2] << 8) | bp[3];
+               major_version = *(bp + 3);
+               minor_version = *(bp + 2);
                bp += 4;
-               if (print_neighbors2(ndo, bp, ep, len) < 0)
+               if (print_neighbors2(ndo, bp, ep, len, major_version,
+                   minor_version) < 0)
                        goto trunc;
                break;
 
@@ -163,7 +165,7 @@ print_report(netdissect_options *ndo,
              register const u_char *bp, register const u_char *ep,
              register u_int len)
 {
-       register u_int32_t mask, origin;
+       register uint32_t mask, origin;
        register int metric, done;
        register u_int i, width;
 
@@ -173,7 +175,7 @@ print_report(netdissect_options *ndo,
                        return (0);
                }
                ND_TCHECK2(bp[0], 3);
-               mask = (u_int32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
+               mask = (uint32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
                width = 1;
                if (bp[0])
                        width = 2;
@@ -221,7 +223,7 @@ print_probe(netdissect_options *ndo,
             register const u_char *bp, register const u_char *ep,
             register u_int len)
 {
-       register u_int32_t genid;
+       register uint32_t genid;
 
        ND_TCHECK2(bp[0], 4);
        if ((len < 4) || ((bp + 4) > ep)) {
@@ -229,7 +231,7 @@ print_probe(netdissect_options *ndo,
                ND_PRINT((ndo, " [|}"));
                return (0);
        }
-       genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3];
+       genid = EXTRACT_32BITS(bp);
        bp += 4;
        len -= 4;
        ND_PRINT((ndo, ndo->ndo_vflag > 1 ? "\n\t" : " "));
@@ -282,15 +284,14 @@ trunc:
 static int
 print_neighbors2(netdissect_options *ndo,
                  register const u_char *bp, register const u_char *ep,
-                 register u_int len)
+                 register u_int len, uint8_t major_version,
+                 uint8_t minor_version)
 {
        const u_char *laddr;
        register u_char metric, thresh, flags;
        register int ncount;
 
-       ND_PRINT((ndo, " (v %d.%d):",
-              (int)target_level & 0xff,
-              (int)(target_level >> 8) & 0xff));
+       ND_PRINT((ndo, " (v %d.%d):", major_version, minor_version));
 
        while (len > 0 && bp < ep) {
                ND_TCHECK2(bp[0], 8);
@@ -337,7 +338,7 @@ print_prune(netdissect_options *ndo,
        ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
        bp += 8;
        ND_PRINT((ndo, " timer "));
-       relts_print(ndo, EXTRACT_32BITS(bp));
+       unsigned_relts_print(ndo, EXTRACT_32BITS(bp));
        return (0);
 trunc:
        return (-1);