]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-arcnet.c
Don't do IPv6 stuff if INET6 isn't defined.
[tcpdump] / print-arcnet.c
index 4f32dce465ba546dbbd465a245707e0ac11e2ede..0ffb9220709b6253b372d3ccb59b0284dbffa7f7 100644 (file)
@@ -21,6 +21,7 @@
  * From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
  * as given to interface code.
  */
 struct arc_header {
-       u_int8_t  arc_shost;
-       u_int8_t  arc_dhost;
-       u_int8_t  arc_type;
+       uint8_t  arc_shost;
+       uint8_t  arc_dhost;
+       uint8_t  arc_type;
        /*
         * only present for newstyle encoding with LL fragmentation.
         * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
         */
-       u_int8_t  arc_flag;
-       u_int16_t arc_seqid;
+       uint8_t  arc_flag;
+       uint16_t arc_seqid;
 
        /*
         * only present in exception packets (arc_flag == 0xff)
         */
-       u_int8_t  arc_type2;    /* same as arc_type */
-       u_int8_t  arc_flag2;    /* real flag value */
-       u_int16_t arc_seqid2;   /* real seqid value */
+       uint8_t  arc_type2;     /* same as arc_type */
+       uint8_t  arc_flag2;     /* real flag value */
+       uint16_t arc_seqid2;    /* real seqid value */
 };
 
 #define        ARC_HDRLEN              3
@@ -83,17 +84,17 @@ struct      arc_header {
  * never presents packets that look like exception frames.
  */
 struct arc_linux_header {
-       u_int8_t  arc_shost;
-       u_int8_t  arc_dhost;
-       u_int16_t arc_offset;
-       u_int8_t  arc_type;
+       uint8_t  arc_shost;
+       uint8_t  arc_dhost;
+       uint16_t arc_offset;
+       uint8_t  arc_type;
        /*
         * only present for newstyle encoding with LL fragmentation.
         * Don't use sizeof(anything), use ARC_LINUX_HDR{,NEW}LEN
         * instead.
         */
-       u_int8_t  arc_flag;
-       u_int16_t arc_seqid;
+       uint8_t  arc_flag;
+       uint16_t arc_seqid;
 };
 
 #define        ARC_LINUX_HDRLEN        5
@@ -180,7 +181,7 @@ arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
        u_int seqid = 0;
        u_char arc_type;
 
-       if (caplen < ARC_HDRLEN) {
+       if (caplen < ARC_HDRLEN || length < ARC_HDRLEN) {
                ND_PRINT((ndo, "[|arcnet]"));
                return (caplen);
        }
@@ -201,14 +202,14 @@ arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
        }
 
        if (phds) {
-               if (caplen < ARC_HDRNEWLEN) {
+               if (caplen < ARC_HDRNEWLEN || length < ARC_HDRNEWLEN) {
                        arcnet_print(ndo, p, length, 0, 0, 0);
                        ND_PRINT((ndo, "[|phds]"));
                        return (caplen);
                }
 
                if (ap->arc_flag == 0xff) {
-                       if (caplen < ARC_HDRNEWLEN_EXC) {
+                       if (caplen < ARC_HDRNEWLEN_EXC || length < ARC_HDRNEWLEN_EXC) {
                                arcnet_print(ndo, p, length, 0, 0, 0);
                                ND_PRINT((ndo, "[|phds extended]"));
                                return (caplen);
@@ -242,7 +243,7 @@ arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
        }
 
        if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
-               ndo->ndo_default_print(ndo, p, caplen);
+               ND_DEFAULTPRINT(p, caplen);
 
        return (archdrlen);
 }
@@ -267,7 +268,7 @@ arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, cons
        int archdrlen = 0;
        u_char arc_type;
 
-       if (caplen < ARC_LINUX_HDRLEN) {
+       if (caplen < ARC_LINUX_HDRLEN || length < ARC_LINUX_HDRLEN) {
                ND_PRINT((ndo, "[|arcnet]"));
                return (caplen);
        }
@@ -278,7 +279,7 @@ arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, cons
        switch (arc_type) {
        default:
                archdrlen = ARC_LINUX_HDRNEWLEN;
-               if (caplen < ARC_LINUX_HDRNEWLEN) {
+               if (caplen < ARC_LINUX_HDRNEWLEN || length < ARC_LINUX_HDRNEWLEN) {
                        ND_PRINT((ndo, "[|arcnet]"));
                        return (caplen);
                }
@@ -301,7 +302,7 @@ arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, cons
        p += archdrlen;
 
        if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
-               ndo->ndo_default_print(ndo, p, caplen);
+               ND_DEFAULTPRINT(p, caplen);
 
        return (archdrlen);
 }
@@ -325,11 +326,9 @@ arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
                ip_print(ndo, p, length);
                return (1);
 
-#ifdef INET6
        case ARCTYPE_INET6:
                ip6_print(ndo, p, length);
                return (1);
-#endif /*INET6*/
 
        case ARCTYPE_ARP_OLD:
        case ARCTYPE_ARP:
@@ -339,12 +338,12 @@ arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
 
        case ARCTYPE_ATALK:     /* XXX was this ever used? */
                if (ndo->ndo_vflag)
-                       fputs("et1 ", stdout);
-               atalk_print(p, length);
+                       ND_PRINT((ndo, "et1 "));
+               atalk_print(ndo, p, length);
                return (1);
 
        case ARCTYPE_IPX:
-               ipx_print(p, length);
+               ipx_print(ndo, p, length);
                return (1);
 
        default: