]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-igmp.c
don't pass on src & dst MAC adresses to the isoclns decoder as MAC adresses
[tcpdump] / print-igmp.c
index 76d176ccbb9d01f472ca6064f4e430519f7113eb..84fc76217fa354adacf49b92e4c1d9885d70e4a8 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.8 2002-08-01 08:53:09 risso Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.11 2002-12-11 07:14:02 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -47,10 +47,10 @@ static const char rcsid[] =
  * The packet format for a traceroute request.
  */
 struct tr_query {
-    u_int  tr_src;          /* traceroute source */
-    u_int  tr_dst;          /* traceroute destination */
-    u_int  tr_raddr;        /* traceroute response address */
-    u_int  tr_rttlqid;      /* response ttl and qid */
+    u_int32_t  tr_src;          /* traceroute source */
+    u_int32_t  tr_dst;          /* traceroute destination */
+    u_int32_t  tr_raddr;        /* traceroute response address */
+    u_int32_t  tr_rttlqid;      /* response ttl and qid */
 };
 
 #define TR_GETTTL(x)        (int)(((x) >> 24) & 0xff)
@@ -61,17 +61,17 @@ struct tr_query {
  * beginning, followed by one tr_resp for each hop taken.
  */
 struct tr_resp {
-    u_int tr_qarr;          /* query arrival time */
-    u_int tr_inaddr;        /* incoming interface address */
-    u_int tr_outaddr;       /* outgoing interface address */
-    u_int tr_rmtaddr;       /* parent address in source tree */
-    u_int tr_vifin;         /* input packet count on interface */
-    u_int tr_vifout;        /* output packet count on interface */
-    u_int tr_pktcnt;        /* total incoming packets for src-grp */
-    u_char  tr_rproto;      /* routing proto deployed on router */
-    u_char  tr_fttl;        /* ttl required to forward on outvif */
-    u_char  tr_smask;       /* subnet mask for src addr */
-    u_char  tr_rflags;      /* forwarding error codes */
+    u_int32_t tr_qarr;          /* query arrival time */
+    u_int32_t tr_inaddr;        /* incoming interface address */
+    u_int32_t tr_outaddr;       /* outgoing interface address */
+    u_int32_t tr_rmtaddr;       /* parent address in source tree */
+    u_int32_t tr_vifin;         /* input packet count on interface */
+    u_int32_t tr_vifout;        /* output packet count on interface */
+    u_int32_t tr_pktcnt;        /* total incoming packets for src-grp */
+    u_int8_t  tr_rproto;      /* routing proto deployed on router */
+    u_int8_t  tr_fttl;        /* ttl required to forward on outvif */
+    u_int8_t  tr_smask;       /* subnet mask for src addr */
+    u_int8_t  tr_rflags;      /* forwarding error codes */
 };
 
 /* defs within mtrace */
@@ -111,12 +111,21 @@ print_mtrace(register const u_char *bp, register u_int len)
 {
     register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
 
-    printf("mtrace %lu: %s to %s reply-to %s",
-        (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
+    TCHECK(*tr);
+    if (len < 8 + sizeof (struct tr_query)) {
+       (void)printf(" [invalid len %d]", len);
+       return;
+    }
+    printf("mtrace %u: %s to %s reply-to %s",
+        TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)),
         ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
         ipaddr_string(&tr->tr_raddr));
-    if (IN_CLASSD(ntohl(tr->tr_raddr)))
-        printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
+    if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr)))
+        printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
+    return;
+trunc:
+    (void)printf("[|igmp]");
+    return;
 }
 
 static void
@@ -124,12 +133,21 @@ print_mresp(register const u_char *bp, register u_int len)
 {
     register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
 
+    TCHECK(*tr);
+    if (len < 8 + sizeof (struct tr_query)) {
+       (void)printf(" [invalid len %d]", len);
+       return;
+    }
     printf("mresp %lu: %s to %s reply-to %s",
-        (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
+        (u_long)TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)),
         ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
         ipaddr_string(&tr->tr_raddr));
-    if (IN_CLASSD(ntohl(tr->tr_raddr)))
-        printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
+    if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr)))
+        printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
+    return;
+trunc:
+    (void)printf("[|igmp]");
+    return;
 }
 
 static void