X-Git-Url: https://git.tcpdump.org/libpcap/blobdiff_plain/2b2e917274ff5846247423219d0568a9dba63628..c82a08e93128e63ae1ca843fd6fd08e76e7eda40:/gencode.c diff --git a/gencode.c b/gencode.c index 090a8ed3..73b95c62 100644 --- a/gencode.c +++ b/gencode.c @@ -24,9 +24,9 @@ #include "config.h" #endif -#ifdef WIN32 +#ifdef _WIN32 #include -#else /* WIN32 */ +#else /* _WIN32 */ #if HAVE_INTTYPES_H #include #elif HAVE_STDINT_H @@ -37,16 +37,9 @@ #endif #include #include -#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 @@ -55,7 +48,7 @@ #include #include -#endif /* WIN32 */ +#endif /* _WIN32 */ #include #include @@ -95,9 +88,9 @@ #define offsetof(s, e) ((size_t)&((s *)0)->e) #endif #ifdef INET6 -#ifndef WIN32 +#ifndef _WIN32 #include /* for "struct addrinfo" */ -#endif /* WIN32 */ +#endif /* _WIN32 */ #endif /*INET6*/ #include @@ -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;