]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-igmp.c
CMake: Fix the comment about versions. [skip ci]
[tcpdump] / print-igmp.c
index 4bdcba5deb4e0d904bca90731adf4eb209e2eb02..68bb5d77cf8046a5ee10dde5694a52756d32fd64 100644 (file)
@@ -29,9 +29,7 @@
  *     draft-asaeda-mboned-mtrace-v2 for the mtrace message
  */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
@@ -109,46 +107,22 @@ static const struct tok igmpv3report2str[] = {
 
 static void
 print_mtrace(netdissect_options *ndo,
+             const char *typename,
              const u_char *bp, u_int len)
 {
     const struct tr_query *tr = (const struct tr_query *)(bp + 8);
 
-    ND_TCHECK_SIZE(tr);
-    if (len < 8 + sizeof (struct tr_query)) {
-       ND_PRINT(" [invalid len %u]", len);
-       return;
-    }
-    ND_PRINT("mtrace %u: %s to %s reply-to %s",
-        GET_BE_U_3(tr->tr_qid),
-        GET_IPADDR_STRING(tr->tr_src), GET_IPADDR_STRING(tr->tr_dst),
-        GET_IPADDR_STRING(tr->tr_raddr));
-    if (IN_CLASSD(GET_BE_U_4(tr->tr_raddr)))
-        ND_PRINT(" with-ttl %u", GET_U_1(tr->tr_rttl));
-    return;
-trunc:
-    nd_print_trunc(ndo);
-}
-
-static void
-print_mresp(netdissect_options *ndo,
-            const u_char *bp, u_int len)
-{
-    const struct tr_query *tr = (const struct tr_query *)(bp + 8);
-
-    ND_TCHECK_SIZE(tr);
     if (len < 8 + sizeof (struct tr_query)) {
        ND_PRINT(" [invalid len %u]", len);
        return;
     }
-    ND_PRINT("mresp %u: %s to %s reply-to %s",
+    ND_PRINT("%s %u: %s to %s reply-to %s",
+        typename,
         GET_BE_U_3(tr->tr_qid),
         GET_IPADDR_STRING(tr->tr_src), GET_IPADDR_STRING(tr->tr_dst),
         GET_IPADDR_STRING(tr->tr_raddr));
     if (IN_CLASSD(GET_BE_U_4(tr->tr_raddr)))
         ND_PRINT(" with-ttl %u", GET_U_1(tr->tr_rttl));
-    return;
-trunc:
-    nd_print_trunc(ndo);
 }
 
 static void
@@ -163,7 +137,6 @@ print_igmpv3_report(netdissect_options *ndo,
        ND_PRINT(" [invalid len %u]", len);
        return;
     }
-    ND_TCHECK_2(bp + 6);
     ngroups = GET_BE_U_2(bp + 6);
     ND_PRINT(", %u group record(s)", ngroups);
     if (ndo->ndo_vflag > 0) {
@@ -174,7 +147,6 @@ print_igmpv3_report(netdissect_options *ndo,
                ND_PRINT(" [invalid number of groups]");
                return;
            }
-           ND_TCHECK_4(bp + (group + 4));
             ND_PRINT(" [gaddr %s", GET_IPADDR_STRING(bp + group + 4));
            ND_PRINT(" %s", tok2str(igmpv3report2str, " [v3-report-#%u]",
                                                                GET_U_1(bp + group)));
@@ -190,7 +162,6 @@ print_igmpv3_report(netdissect_options *ndo,
                /* Print the sources */
                 ND_PRINT(" {");
                 for (j=0; j<nsrcs; j++) {
-                   ND_TCHECK_4(bp + (group + 8 + (j << 2)));
                    ND_PRINT(" %s", GET_IPADDR_STRING(bp + group + 8 + (j << 2)));
                }
                 ND_PRINT(" }");
@@ -200,9 +171,6 @@ print_igmpv3_report(netdissect_options *ndo,
            ND_PRINT("]");
         }
     }
-    return;
-trunc:
-    nd_print_trunc(ndo);
 }
 
 static void
@@ -220,7 +188,6 @@ print_igmpv3_query(netdissect_options *ndo,
        ND_PRINT(" [invalid len %u]", len);
        return;
     }
-    ND_TCHECK_1(bp + 1);
     mrc = GET_U_1(bp + 1);
     if (mrc < 128) {
        mrt = mrc;
@@ -236,11 +203,9 @@ print_igmpv3_query(netdissect_options *ndo,
         }
        ND_PRINT("]");
     }
-    ND_TCHECK_4(bp + 4);
     if (GET_BE_U_4(bp + 4) == 0)
        return;
     ND_PRINT(" [gaddr %s", GET_IPADDR_STRING(bp + 4));
-    ND_TCHECK_2(bp + 10);
     nsrcs = GET_BE_U_2(bp + 10);
     if (nsrcs > 0) {
        if (len < 12 + (nsrcs << 2))
@@ -248,7 +213,6 @@ print_igmpv3_query(netdissect_options *ndo,
        else if (ndo->ndo_vflag > 1) {
            ND_PRINT(" {");
            for (i=0; i<nsrcs; i++) {
-               ND_TCHECK_4(bp + (12 + (i << 2)));
                ND_PRINT(" %s", GET_IPADDR_STRING(bp + 12 + (i << 2)));
            }
            ND_PRINT(" }");
@@ -256,9 +220,6 @@ print_igmpv3_query(netdissect_options *ndo,
            ND_PRINT(", %u source(s)", nsrcs);
     }
     ND_PRINT("]");
-    return;
-trunc:
-    nd_print_trunc(ndo);
 }
 
 void
@@ -273,21 +234,18 @@ igmp_print(netdissect_options *ndo,
         return;
     }
 
-    ND_TCHECK_1(bp);
     switch (GET_U_1(bp)) {
     case 0x11:
         ND_PRINT("igmp query");
        if (len >= 12)
            print_igmpv3_query(ndo, bp, len);
        else {
-            ND_TCHECK_1(bp + 1);
            if (GET_U_1(bp + 1)) {
                ND_PRINT(" v2");
                if (GET_U_1(bp + 1) != 100)
                    ND_PRINT(" [max resp time %u]", GET_U_1(bp + 1));
            } else
                ND_PRINT(" v1");
-            ND_TCHECK_4(bp + 4);
            if (GET_BE_U_4(bp + 4))
                 ND_PRINT(" [gaddr %s]", GET_IPADDR_STRING(bp + 4));
             if (len != 8)
@@ -295,13 +253,11 @@ igmp_print(netdissect_options *ndo,
        }
         break;
     case 0x12:
-        ND_TCHECK_4(bp + 4);
         ND_PRINT("igmp v1 report %s", GET_IPADDR_STRING(bp + 4));
         if (len != 8)
             ND_PRINT(" [len %u]", len);
         break;
     case 0x16:
-        ND_TCHECK_4(bp + 4);
         ND_PRINT("igmp v2 report %s", GET_IPADDR_STRING(bp + 4));
         break;
     case 0x22:
@@ -309,7 +265,6 @@ igmp_print(netdissect_options *ndo,
        print_igmpv3_report(ndo, bp, len);
         break;
     case 0x17:
-        ND_TCHECK_4(bp + 4);
         ND_PRINT("igmp leave %s", GET_IPADDR_STRING(bp + 4));
         break;
     case 0x13:
@@ -324,10 +279,10 @@ igmp_print(netdissect_options *ndo,
         pimv1_print(ndo, bp, len);
         break;
     case 0x1e:
-        print_mresp(ndo, bp, len);
+        print_mtrace(ndo, "mresp", bp, len);
         break;
     case 0x1f:
-        print_mtrace(ndo, bp, len);
+        print_mtrace(ndo, "mtrace", bp, len);
         break;
     default:
         ND_PRINT("igmp-%u", GET_U_1(bp));
@@ -341,7 +296,4 @@ igmp_print(netdissect_options *ndo,
         if (in_cksum(vec, 1))
             ND_PRINT(" bad igmp cksum %x!", GET_BE_U_2(bp + 2));
     }
-    return;
-trunc:
-    nd_print_trunc(ndo);
 }