]> The Tcpdump Group git mirrors - libpcap/commitdiff
From Peter Fales <[email protected]>: support for Linux ARCNET,
authorguy <guy>
Thu, 23 Jan 2003 07:24:51 +0000 (07:24 +0000)
committerguy <guy>
Thu, 23 Jan 2003 07:24:51 +0000 (07:24 +0000)
which supplies different headers from BSD ARCNET, and fixes to the
ARCNET code generator (the protocol ID field is 1 byte, so the values
for it shouldn't be byte-swapped).

Whitespace cleanups.

The "NetBSD-style" ARCNET headers are used in other BSDs as well, so
just call them "BSD-style".

CREDITS
bpf/net/bpf.h
gencode.c
pcap-linux.c
pcap.c
savefile.c

diff --git a/CREDITS b/CREDITS
index 2adfeafb8cc2e96edc1064e514bc0f7507e661b1..a701f411728493eea0e37dfb2ac9f8bddeb0230f 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -52,6 +52,7 @@ Additional people who have contributed patches:
        Olaf Kirch                      <[email protected]>
        Onno van der Linden             <[email protected]>
        Pavel Kankovsky                 <[email protected]>
        Olaf Kirch                      <[email protected]>
        Onno van der Linden             <[email protected]>
        Pavel Kankovsky                 <[email protected]>
+       Peter Fales                     <[email protected]>
        Peter Jeremy                    <[email protected]>
        Phil Wood                       <[email protected]>
        Rafal Maszkowski                <[email protected]>
        Peter Jeremy                    <[email protected]>
        Phil Wood                       <[email protected]>
        Rafal Maszkowski                <[email protected]>
index 62a5300759d462ad910d1f79f94707a78f864bd2..6d7adcb57cbf2881d2b75ff0f8bcb0b8bcfaa242 100644 (file)
@@ -37,7 +37,7 @@
  *
  *      @(#)bpf.h       7.1 (Berkeley) 5/7/91
  *
  *
  *      @(#)bpf.h       7.1 (Berkeley) 5/7/91
  *
- * @(#) $Header: /tcpdump/master/libpcap/bpf/net/Attic/bpf.h,v 1.66 2003-01-21 04:39:05 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/bpf/net/Attic/bpf.h,v 1.67 2003-01-23 07:24:53 guy Exp $ (LBL)
  */
 
 #ifndef BPF_MAJOR_VERSION
  */
 
 #ifndef BPF_MAJOR_VERSION
@@ -183,7 +183,7 @@ struct bpf_hdr {
 #define DLT_PRONET     4       /* Proteon ProNET Token Ring */
 #define DLT_CHAOS      5       /* Chaos */
 #define DLT_IEEE802    6       /* IEEE 802 Networks */
 #define DLT_PRONET     4       /* Proteon ProNET Token Ring */
 #define DLT_CHAOS      5       /* Chaos */
 #define DLT_IEEE802    6       /* IEEE 802 Networks */
-#define DLT_ARCNET     7       /* ARCNET, with NetBSD-style header */
+#define DLT_ARCNET     7       /* ARCNET, with BSD-style header */
 #define DLT_SLIP       8       /* Serial Line IP */
 #define DLT_PPP                9       /* Point-to-point Protocol */
 #define DLT_FDDI       10      /* FDDI */
 #define DLT_SLIP       8       /* Serial Line IP */
 #define DLT_PPP                9       /* Point-to-point Protocol */
 #define DLT_FDDI       10      /* FDDI */
@@ -395,7 +395,7 @@ struct bpf_hdr {
 #define DLT_TZSP                128     /* Tazmen Sniffer Protocol */
 
 /*
 #define DLT_TZSP                128     /* Tazmen Sniffer Protocol */
 
 /*
- * NetBSD's ARCNET headers have the source host, destination host,
+ * BSD's ARCNET headers have the source host, destination host,
  * and type at the beginning of the packet; that's what's handed
  * up to userland via BPF.
  *
  * and type at the beginning of the packet; that's what's handed
  * up to userland via BPF.
  *
index 915e5b48ba2a86a930ead871f19fafef23edcb80..e8840ef58e289dc66a98ea7b0af60ce89d88522c 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -21,7 +21,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.183 2002-12-12 07:04:17 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.184 2003-01-23 07:24:51 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -695,10 +695,16 @@ init_linktype(type)
 
        case DLT_ARCNET:
                off_linktype = 2;
 
        case DLT_ARCNET:
                off_linktype = 2;
-               off_nl = 6;     /* XXX in reality, variable! */
+               off_nl = 6;             /* XXX in reality, variable! */
                off_nl_nosnap = 6;      /* no 802.2 LLC */
                return;
 
                off_nl_nosnap = 6;      /* no 802.2 LLC */
                return;
 
+       case DLT_ARCNET_LINUX:
+               off_linktype = 4;
+               off_nl = 8;             /* XXX in reality, variable! */
+               off_nl_nosnap = 8;      /* no 802.2 LLC */
+               return;
+
        case DLT_EN10MB:
                off_linktype = 12;
                off_nl = 14;            /* Ethernet II */
        case DLT_EN10MB:
                off_linktype = 12;
                off_nl = 14;            /* Ethernet II */
@@ -1166,15 +1172,19 @@ gen_linktype(proto)
                return gen_ether_linktype(proto);
                break;
 
                return gen_ether_linktype(proto);
                break;
 
-        case DLT_C_HDLC:
-            switch (proto) {
-            case LLCSAP_ISONS:
-                proto = (proto << 8 | LLCSAP_ISONS);
-                /* fall through */
-            default:
-                return gen_cmp(off_linktype, BPF_H, (bpf_int32)proto);
-                break;
-            }
+       case DLT_C_HDLC:
+               switch (proto) {
+
+               case LLCSAP_ISONS:
+                       proto = (proto << 8 | LLCSAP_ISONS);
+                       /* fall through */
+
+               default:
+                       return gen_cmp(off_linktype, BPF_H, (bpf_int32)proto);
+                       break;
+               }
+               break;
+
        case DLT_IEEE802_11:
        case DLT_PRISM_HEADER:
        case DLT_IEEE802_11_RADIO:
        case DLT_IEEE802_11:
        case DLT_PRISM_HEADER:
        case DLT_IEEE802_11_RADIO:
@@ -1567,36 +1577,45 @@ gen_linktype(proto)
                return (gen_cmp(0, BPF_W, (bpf_int32)proto));
 
        case DLT_ARCNET:
                return (gen_cmp(0, BPF_W, (bpf_int32)proto));
 
        case DLT_ARCNET:
+       case DLT_ARCNET_LINUX:
                /*
                 * XXX should we check for first fragment if the protocol
                 * uses PHDS?
                 */
                /*
                 * XXX should we check for first fragment if the protocol
                 * uses PHDS?
                 */
-               switch(proto) {
+               switch (proto) {
+
                default:
                        return gen_false();
                default:
                        return gen_false();
+
 #ifdef INET6
                case ETHERTYPE_IPV6:
 #ifdef INET6
                case ETHERTYPE_IPV6:
-                       return(gen_cmp(2, BPF_B,
-                                       (bpf_int32)htonl(ARCTYPE_INET6)));
+                       return (gen_cmp(off_linktype, BPF_B,
+                               (bpf_int32)ARCTYPE_INET6));
 #endif /* INET6 */
 #endif /* INET6 */
+
                case ETHERTYPE_IP:
                case ETHERTYPE_IP:
-                       b0 = gen_cmp(2, BPF_B, (bpf_int32)htonl(ARCTYPE_IP));
-                       b1 = gen_cmp(2, BPF_B,
-                                       (bpf_int32)htonl(ARCTYPE_IP_OLD));
+                       b0 = gen_cmp(off_linktype, BPF_B, 
+                                    (bpf_int32)ARCTYPE_IP);
+                       b1 = gen_cmp(off_linktype, BPF_B,
+                                    (bpf_int32)ARCTYPE_IP_OLD);
                        gen_or(b0, b1);
                        gen_or(b0, b1);
-                       return(b1);
+                       return (b1);
+
                case ETHERTYPE_ARP:
                case ETHERTYPE_ARP:
-                       b0 = gen_cmp(2, BPF_B, (bpf_int32)htonl(ARCTYPE_ARP));
-                       b1 = gen_cmp(2, BPF_B,
-                                       (bpf_int32)htonl(ARCTYPE_ARP_OLD));
+                       b0 = gen_cmp(off_linktype, BPF_B,
+                                    (bpf_int32)ARCTYPE_ARP);
+                       b1 = gen_cmp(off_linktype, BPF_B, 
+                                    (bpf_int32)ARCTYPE_ARP_OLD);
                        gen_or(b0, b1);
                        gen_or(b0, b1);
-                       return(b1);
+                       return (b1);
+
                case ETHERTYPE_REVARP:
                case ETHERTYPE_REVARP:
-                       return(gen_cmp(2, BPF_B,
-                                       (bpf_int32)htonl(ARCTYPE_REVARP)));
+                       return (gen_cmp(off_linktype, BPF_B,
+                                       (bpf_int32)ARCTYPE_REVARP));
+
                case ETHERTYPE_ATALK:
                case ETHERTYPE_ATALK:
-                       return(gen_cmp(2, BPF_B,
-                                       (bpf_int32)htonl(ARCTYPE_ATALK)));
+                       return (gen_cmp(off_linktype, BPF_B,
+                                       (bpf_int32)ARCTYPE_ATALK));
                }
                break;
 
                }
                break;
 
@@ -4598,7 +4617,7 @@ gen_broadcast(proto)
 
        case Q_DEFAULT:
        case Q_LINK:
 
        case Q_DEFAULT:
        case Q_LINK:
-               if (linktype == DLT_ARCNET)
+               if (linktype == DLT_ARCNET || linktype == DLT_ARCNET_LINUX)
                        return gen_ahostop(abroadcast, Q_DST);
                if (linktype == DLT_EN10MB)
                        return gen_ehostop(ebroadcast, Q_DST);
                        return gen_ahostop(abroadcast, Q_DST);
                if (linktype == DLT_EN10MB)
                        return gen_ehostop(ebroadcast, Q_DST);
@@ -4671,7 +4690,7 @@ gen_multicast(proto)
 
        case Q_DEFAULT:
        case Q_LINK:
 
        case Q_DEFAULT:
        case Q_LINK:
-               if (linktype == DLT_ARCNET)
+               if (linktype == DLT_ARCNET || linktype == DLT_ARCNET_LINUX)
                        /* all ARCnet multicasts use the same address */
                        return gen_ahostop(abroadcast, Q_DST);
 
                        /* all ARCnet multicasts use the same address */
                        return gen_ahostop(abroadcast, Q_DST);
 
@@ -4910,7 +4929,7 @@ gen_acode(eaddr, q)
        struct qual q;
 {
        if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) && q.proto == Q_LINK) {
        struct qual q;
 {
        if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) && q.proto == Q_LINK) {
-               if (linktype == DLT_ARCNET)
+               if (linktype == DLT_ARCNET || linktype == DLT_ARCNET_LINUX)
                        return gen_ahostop(eaddr, (int)q.dir);
        }
        bpf_error("ARCnet address used in non-arc expression");
                        return gen_ahostop(eaddr, (int)q.dir);
        }
        bpf_error("ARCnet address used in non-arc expression");
index ee95513b92b374c968d3aacba3d550d1bf128283..deb9ae6591f4aa53b0be8e3cb5cd17785975a469 100644 (file)
@@ -26,7 +26,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.87 2002-12-22 02:36:49 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.88 2003-01-23 07:24:52 guy Exp $ (LBL)";
 #endif
 
 /*
 #endif
 
 /*
@@ -949,7 +949,7 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok)
                break;
 
        case ARPHRD_ARCNET:
                break;
 
        case ARPHRD_ARCNET:
-               handle->linktype = DLT_ARCNET;
+               handle->linktype = DLT_ARCNET_LINUX;
                break;
 
 #ifndef ARPHRD_FDDI    /* From Linux 2.2.13 */
                break;
 
 #ifndef ARPHRD_FDDI    /* From Linux 2.2.13 */
diff --git a/pcap.c b/pcap.c
index 281639cdf0c013a97b00be9246a1377502ec600b..cfcccf0c5c8f93a0602ea974913855afc4b816c9 100644 (file)
--- a/pcap.c
+++ b/pcap.c
@@ -33,7 +33,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.44 2003-01-16 07:44:27 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.45 2003-01-23 07:24:52 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -214,6 +214,7 @@ struct dlt_choice {
 
 static struct dlt_choice dlt_choices[] = {
        DLT_CHOICE(DLT_ARCNET),
 
 static struct dlt_choice dlt_choices[] = {
        DLT_CHOICE(DLT_ARCNET),
+       DLT_CHOICE(DLT_ARCNET_LINUX),
        DLT_CHOICE(DLT_EN10MB),
        DLT_CHOICE(DLT_SLIP),
        DLT_CHOICE(DLT_SLIP_BSDOS),
        DLT_CHOICE(DLT_EN10MB),
        DLT_CHOICE(DLT_SLIP),
        DLT_CHOICE(DLT_SLIP_BSDOS),
index 5d7bff706a4edf3fc989a8fc792e6cd9732de7d7..c703d1e39dc5d8634811683da74b65c7ab6c08c4 100644 (file)
@@ -30,7 +30,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.74 2003-01-21 04:39:05 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.75 2003-01-23 07:24:53 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -123,7 +123,7 @@ static const char rcsid[] =
 #define LINKTYPE_PRONET                DLT_PRONET
 #define LINKTYPE_CHAOS         DLT_CHAOS
 #define LINKTYPE_TOKEN_RING    DLT_IEEE802     /* DLT_IEEE802 is used for Token Ring */
 #define LINKTYPE_PRONET                DLT_PRONET
 #define LINKTYPE_CHAOS         DLT_CHAOS
 #define LINKTYPE_TOKEN_RING    DLT_IEEE802     /* DLT_IEEE802 is used for Token Ring */
-#define LINKTYPE_ARCNET                DLT_ARCNET      /* NetBSD-style headers */
+#define LINKTYPE_ARCNET                DLT_ARCNET      /* BSD-style headers */
 #define LINKTYPE_SLIP          DLT_SLIP
 #define LINKTYPE_PPP           DLT_PPP
 #define LINKTYPE_FDDI          DLT_FDDI
 #define LINKTYPE_SLIP          DLT_SLIP
 #define LINKTYPE_PPP           DLT_PPP
 #define LINKTYPE_FDDI          DLT_FDDI