]> The Tcpdump Group git mirrors - libpcap/commitdiff
Use <pcap-stdinc.h> only on Windows; on UNIX, selectively include, in
authorguy <guy>
Fri, 2 Aug 2002 03:44:19 +0000 (03:44 +0000)
committerguy <guy>
Fri, 2 Aug 2002 03:44:19 +0000 (03:44 +0000)
each source file, only the headers that file needs, and all the headers
it needs in order to compile on various platforms and not to get any
avoidable compiler warnings on those platforms (as well as any
incomplete structure definitions needed to avoid those warnings).

That also means that <pcap.h> doesn't include <pcap-stdinc.h> on UNIX;
we don't want it to include <pcap-stdinc.h>, at least on UNIX, as doing
so

1) would mean we'd have to install that, so that programs can
   build with libpcap

and

2) would mean that programs including <pcap.h> would drag in a
   bunch of header files that they don't need.

Put a newline at the end of "inet.c" - the Sun C compiler doesn't like
it if the last line doesn't end with a newline.

bpf/net/bpf_filter.c
gencode.c
grammar.y
inet.c
nametoaddr.c
pcap-stdinc.h
pcap.c
pcap.h
scanner.l

index d0bc68c0023f546b13bd80ec98532ba86bf487e1..0a32230d4194d4be5bdaefe7d0394f529f9a694c 100644 (file)
 
 #if !(defined(lint) || defined(KERNEL) || defined(_KERNEL))
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/bpf/net/bpf_filter.c,v 1.37 2002-08-01 08:33:12 risso Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/bpf/net/bpf_filter.c,v 1.38 2002-08-02 03:44:22 guy Exp $ (LBL)";
 #endif
 
+#ifdef WIN32
+
 #include <pcap-stdinc.h>
 
+#else /* WIN32 */
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
 #define        SOLARIS (defined(sun) && (defined(__SVR4) || defined(__svr4__)))
 #if defined(__hpux) || SOLARIS
 # include <sys/sysmacros.h>
@@ -57,6 +65,8 @@ static const char rcsid[] =
 # define       MLEN(m) ((m)->m_len)
 #endif
 
+#endif /* WIN32 */
+
 #include <net/bpf.h>
 
 #if !defined(KERNEL) && !defined(_KERNEL)
@@ -74,6 +84,9 @@ static const char rcsid[] =
 #endif
 
 #ifndef LBL_ALIGN
+#ifndef WIN32
+#include <netinet/in.h>
+#endif
 
 #define EXTRACT_SHORT(p)       ((u_short)ntohs(*(u_short *)p))
 #define EXTRACT_LONG(p)                (ntohl(*(u_int32 *)p))
index 1a00fc457d5cb72ef9d5cf3d0fe109ea9aad36ca..4ada21b29b37ce2d7f95eda0a30d53adbad19088 100644 (file)
--- a/gencode.c
+++ b/gencode.c
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.170 2002-08-01 08:33:01 risso Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.171 2002-08-02 03:44:19 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#ifdef WIN32
 #include <pcap-stdinc.h>
 
 #ifdef __MINGW32__
 #include "IP6_misc.h"
 #endif
 
+#else /* WIN32 */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
 #ifdef __NetBSD__
 #include <sys/param.h>
 #endif
@@ -42,6 +48,10 @@ struct mbuf;         /* Squelch compiler warnings on some platforms for */
 struct rtentry;                /* declarations in <net/if.h> */
 #include <net/if.h>
 
+#include <netinet/in.h>
+
+#endif /* WIN32 */
+
 #include <stdlib.h>
 #include <string.h>
 #include <memory.h>
@@ -59,8 +69,11 @@ struct rtentry;              /* declarations in <net/if.h> */
 #include "ppp.h"
 #include "sll.h"
 #include "arcnet.h"
+#ifndef WIN32
 #ifdef INET6
+#include <netdb.h>     /* for "struct addrinfo" */
 #endif /*INET6*/
+#endif /* WIN32 */
 #include <pcap-namedb.h>
 
 #define ETHERMTU       1500
index d2dace847af50b621edc86eaf04d16006a6f2b3b..fe908f45c209349445c5f309c5003a7a57bb79b0 100644 (file)
--- a/grammar.y
+++ b/grammar.y
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.73 2002-08-01 08:33:02 risso Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.74 2002-08-02 03:44:20 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#ifdef WIN32
 #include <pcap-stdinc.h>
+#else /* WIN32 */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#endif
 
 #include <stdlib.h>
 
+#ifndef WIN32
 #if __STDC__
 struct mbuf;
 struct rtentry;
 #endif
 
+#include <net/if.h>
+
+#include <netinet/in.h>
+#endif /* WIN32 */
+
 #include <stdio.h>
 
 #include "pcap-int.h"
diff --git a/inet.c b/inet.c
index 088cfdcdba919accccddcc40ee1d6ca8cddf6fde..2623341ad3ca12e01c5b65443443ed6f32b49d43 100644 (file)
--- a/inet.c
+++ b/inet.c
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.51 2002-08-01 08:33:02 risso Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.52 2002-08-02 03:44:20 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#ifdef WIN32
 #include <pcap-stdinc.h>
+#else /* WIN32 */
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
 #ifdef HAVE_SYS_SOCKIO_H
 #include <sys/sockio.h>
 #endif
+#include <sys/time.h>                          /* concession to AIX */
 
 struct mbuf;           /* Squelch compiler warnings on some platforms for */
 struct rtentry;                /* declarations in <net/if.h> */
 #include <net/if.h>
+#include <netinet/in.h>
+#endif /* WIN32 */
 
 #include <ctype.h>
 #include <errno.h>
@@ -56,6 +66,9 @@ struct rtentry;               /* declarations in <net/if.h> */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifndef WIN32
+#include <unistd.h>
+#endif /* WIN32 */
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #else
@@ -646,4 +659,4 @@ pcap_lookupnet(device, netp, maskp, errbuf)
        return (0);
 }
 
-#endif /* WIN32 */
\ No newline at end of file
+#endif /* WIN32 */
index b220f8b79a864bea007f62e8fdb0ca3b31626a1b..61286662adb5ccd8a0e4e1e15a229fb24b0b7cb1 100644 (file)
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.65 2002-08-01 08:33:03 risso Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.66 2002-08-02 03:44:20 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#ifdef WIN32
 #include <pcap-stdinc.h>
 
 #ifdef __MINGW32__
 #include "IP6_misc.h"
 #endif
+#else /* WIN32 */
 
+#include <sys/param.h>
+#include <sys/types.h>                         /* concession to AIX */
+#include <sys/socket.h>
+#include <sys/time.h>
+
+#include <netinet/in.h>
 #ifdef HAVE_ETHER_HOSTTON
 #ifdef HAVE_NETINET_IF_ETHER_H
 struct mbuf;           /* Squelch compiler warnings on some platforms for */
@@ -45,6 +53,9 @@ struct rtentry;               /* declarations in <net/if.h> */
 #include <netinet/if_ether.h>
 #endif /* HAVE_NETINET_IF_ETHER_H */
 #endif /* HAVE_ETHER_HOSTTON */
+#include <arpa/inet.h>
+#include <netdb.h>
+#endif /* WIN32 */
 
 #include <ctype.h>
 #include <errno.h>
index 502ecdd5cdd611e19bead7b400892d3df3a828a3..f41f5a19713f25f0fce09c8ff0cc0c5e37016009 100644 (file)
@@ -18,7 +18,6 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
-#ifdef WIN32
 
 #define SIZEOF_CHAR 1
 #define SIZEOF_SHORT 2
 #define vsnprintf _vsnprintf
 #define inline __inline 
 
-#else
-
-#include <unistd.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/timeb.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#ifdef HAVE_SYS_SOCKIO_H
-#include <sys/sockio.h>
-#include <arpa/inet.h>
-#endif
-
 #endif
diff --git a/pcap.c b/pcap.c
index baf8f1ea164539e69911194b6bb154bd04c67718..042687ab5fb50e9127b54726b4bc73c9cf9945d0 100644 (file)
--- a/pcap.c
+++ b/pcap.c
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.40 2002-08-01 08:33:04 risso Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.41 2002-08-02 03:44:21 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#ifdef WIN32
 #include <pcap-stdinc.h>
+#else /* WIN32 */
+#include <sys/types.h>
+#endif /* WIN32 */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifndef WIN32
+#include <unistd.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 
@@ -347,7 +354,7 @@ pcap_close(pcap_t *p)
 #endif
                close(p->fd);
        }
-#else
+#else /* WIN32 */
        if (p->adapter != NULL) {
                PacketCloseAdapter(p->adapter);
                p->adapter = NULL;
diff --git a/pcap.h b/pcap.h
index c2855b062490ef46a9b224dfa5b52cd7fa22ee0f..8e8e6238d2070628da2fcbcacee07cea17e22f98 100644 (file)
--- a/pcap.h
+++ b/pcap.h
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.36 2002-08-01 08:33:04 risso Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.37 2002-08-02 03:44:21 guy Exp $ (LBL)
  */
 
 #ifndef lib_pcap_h
 #define lib_pcap_h
 
+#ifdef WIN32
 #include <pcap-stdinc.h>
+#else /* WIN32 */
+#include <sys/types.h>
+#include <sys/time.h>
+#endif /* WIN32 */
 
 #include <net/bpf.h>
 
index 0eb78c852c67d6581ad73bc889898713887b38b5..73eadf7ebfda47262b4aa9e407965bb1fdd64646 100644 (file)
--- a/scanner.l
+++ b/scanner.l
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.88 2002-08-01 08:33:05 risso Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.89 2002-08-02 03:44:21 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -36,11 +36,16 @@ static const char rcsid[] =
 
 #include "gencode.h"
 #ifdef INET6
+#ifdef WIN32
 #include <pcap-stdinc.h>
 
 #ifdef __MINGW32__
 #include "IP6_misc.h"
 #endif
+#else /* WIN32 */
+#include <sys/socket.h>        /* for "struct sockaddr" in "struct addrinfo" */
+#include <netdb.h>     /* for "struct addrinfo" */
+#endif /* WIN32 */
 
 /* Workaround for AIX 4.3 */
 #if !defined(AI_NUMERICHOST)