]> The Tcpdump Group git mirrors - libpcap/blobdiff - gencode.c
Define ffs() in optimize.c; that's all that uses it.
[libpcap] / gencode.c
index 090a8ed3ddece9efa7319df919aa2c4666b6cc78..73b95c625800e41573a766fd82922f8ce57316a8 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -24,9 +24,9 @@
 #include "config.h"
 #endif
 
-#ifdef WIN32
+#ifdef _WIN32
 #include <pcap-stdinc.h>
-#else /* WIN32 */
+#else /* _WIN32 */
 #if HAVE_INTTYPES_H
 #include <inttypes.h>
 #elif HAVE_STDINT_H
 #endif
 #include <sys/types.h>
 #include <sys/socket.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
 
-/*
- * XXX - why was this included even on UNIX?
- */
-#ifdef __MINGW32__
-#include "ip6_misc.h"
-#endif
-
-#ifndef WIN32
+#ifndef _WIN32
 
 #ifdef __NetBSD__
 #include <sys/param.h>
@@ -55,7 +48,7 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
-#endif /* WIN32 */
+#endif /* _WIN32 */
 
 #include <stdlib.h>
 #include <string.h>
@@ -95,9 +88,9 @@
 #define offsetof(s, e) ((size_t)&((s *)0)->e)
 #endif
 #ifdef INET6
-#ifndef WIN32
+#ifndef _WIN32
 #include <netdb.h>     /* for "struct addrinfo" */
-#endif /* WIN32 */
+#endif /* _WIN32 */
 #endif /*INET6*/
 #include <pcap/namedb.h>
 
@@ -136,7 +129,7 @@ static jmp_buf top_ctx;
 static pcap_t *bpf_pcap;
 
 /* Hack for handling VLAN and MPLS stacks. */
-#ifdef WIN32
+#ifdef _WIN32
 static u_int   label_stack_depth = (u_int)-1, vlan_stack_depth = (u_int)-1;
 #else
 static u_int   label_stack_depth = -1U, vlan_stack_depth = -1U;
@@ -440,12 +433,11 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
         * UN*X, if the platform supports pthreads?  If that requires
         * a separate -lpthread, we might not want to do that.
         */
-#ifdef WIN32
-       extern int wsockinit (void);
+#ifdef _WIN32
        static int done = 0;
 
        if (!done)
-               wsockinit();
+               pcap_wsockinit();
        done = 1;
        EnterCriticalSection(&g_PcapCompileCriticalSection);
 #endif
@@ -515,7 +507,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
 
 quit:
 
-#ifdef WIN32
+#ifdef _WIN32
        LeaveCriticalSection(&g_PcapCompileCriticalSection);
 #endif
 
@@ -628,6 +620,15 @@ finish_parse(p)
        /*
         * For DLT_PPI captures, generate a check of the per-packet
         * DLT value to make sure it's DLT_IEEE802_11.
+        *
+        * XXX - TurboCap cards use DLT_PPI for Ethernet.
+        * Can we just define some DLT_ETHERNET_WITH_PHDR pseudo-header
+        * with appropriate Ethernet information and use that rather
+        * than using something such as DLT_PPI where you don't know
+        * the link-layer header type until runtime, which, in the
+        * general case, would force us to generate both Ethernet *and*
+        * 802.11 code (*and* anything else for which PPI is used)
+        * and choose between them early in the BPF program?
         */
        ppi_dlt_check = gen_ppi_dlt_check();
        if (ppi_dlt_check != NULL)
@@ -5561,7 +5562,7 @@ gen_protochain(v, proto, dir)
        int reg2 = alloc_reg();
 
        memset(s, 0, sizeof(s));
-       fix2 = fix3 = fix4 = fix5 = 0;
+       fix3 = fix4 = fix5 = 0;
 
        switch (proto) {
        case Q_IP:
@@ -7915,6 +7916,9 @@ gen_vlan_no_bpf_extensions(int vlan_num)
 
         /* check for VLAN, including QinQ */
         b0 = gen_linktype(ETHERTYPE_8021Q);
+        b1 = gen_linktype(ETHERTYPE_8021AD);
+        gen_or(b0,b1);
+        b0 = b1;
         b1 = gen_linktype(ETHERTYPE_8021QINQ);
         gen_or(b0,b1);
         b0 = b1;