]> The Tcpdump Group git mirrors - libpcap/commitdiff
Don't include pcap/pcap.h just to get SOCKET defined.
authorGuy Harris <[email protected]>
Tue, 8 Jan 2019 06:53:30 +0000 (22:53 -0800)
committerGuy Harris <[email protected]>
Tue, 8 Jan 2019 06:53:30 +0000 (22:53 -0800)
Put it in portability.h as well, with redefinition protections.

pcap/pcap.h
portability.h
sslutils.c
sslutils.h

index 8a69a2f334301f751fe33f7a00b0cf0d36e711de..848ebbe66a14048a4d1ceb9852ca8136350f5db9 100644 (file)
@@ -929,6 +929,9 @@ PCAP_API struct pcap_samp *pcap_setsampling(pcap_t *p);
 
 /*
  * Some minor differences between UN*X sockets and and Winsock sockets.
+ * These are also defined by pcap/pcap.h, due to some APIs from WinPcap
+ * for active-mode remote captures returning sockets, so we check to
+ * make sure they aren't already defined.
  */
 #ifndef _WIN32
   /*!
@@ -937,7 +940,9 @@ PCAP_API struct pcap_samp *pcap_setsampling(pcap_t *p);
    * We define SOCKET to be a signed integer on UN*X, so that it can
    * be used on both platforms.
    */
-  #define SOCKET int
+  #ifndef SOCKET
+    #define SOCKET int
+  #endif
 
   /*!
    * \brief In Winsock, the error return if socket() fails is INVALID_SOCKET;
@@ -945,7 +950,9 @@ PCAP_API struct pcap_samp *pcap_setsampling(pcap_t *p);
    * We define INVALID_SOCKET to be -1 on UN*X, so that it can be used on
    * both platforms.
    */
-  #define INVALID_SOCKET -1
+  #ifndef INVALID_SOCKET
+    #define INVALID_SOCKET -1
+  #endif
 #endif
 
 PCAP_API SOCKET        pcap_remoteact_accept(const char *address, const char *port,
index beec43cc922eb85d82a8429e335d1a29eaa2c6cb..c2b8f8e2036d4357275cb6e66fc6748131439d19 100644 (file)
@@ -152,6 +152,34 @@ extern int pcap_vsnprintf(char *, size_t, const char *, va_list ap);
   #endif
 #endif /* _WIN32 */
 
+/*
+ * Some minor differences between UN*X sockets and and Winsock sockets.
+ * These are also defined by pcap/pcap.h, due to some APIs from WinPcap
+ * for active-mode remote captures returning sockets, so we check to
+ * make sure they aren't already defined.
+ */
+#ifndef _WIN32
+  /*!
+   * \brief In Winsock, a socket handle is of type SOCKET; in UN*X, it's
+   * a file descriptor, and therefore a signed integer.
+   * We define SOCKET to be a signed integer on UN*X, so that it can
+   * be used on both platforms.
+   */
+  #ifndef SOCKET
+    #define SOCKET int
+  #endif
+
+  /*!
+   * \brief In Winsock, the error return if socket() fails is INVALID_SOCKET;
+   * in UN*X, it's -1.
+   * We define INVALID_SOCKET to be -1 on UN*X, so that it can be used on
+   * both platforms.
+   */
+  #ifndef INVALID_SOCKET
+    #define INVALID_SOCKET -1
+  #endif
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index d09ed6c966a407193d53df14b8034b3452520c12..c1aac9e4d0f039c2dfd835a7d23c1a9a9a2f0602 100644 (file)
@@ -37,9 +37,7 @@
 #ifdef HAVE_OPENSSL
 #include <stdlib.h>
 
-#include "portability.h"
 #include "sslutils.h"
-#include "pcap/pcap.h"
 
 static const char *ssl_keyfile = "";   //!< file containing the private key in PEM format
 static const char *ssl_certfile = "";  //!< file containing the server's certificate in PEM format
index 63810538ddd52312fe401799c88a9a00bb3f4885..ac9496da13e5967aafdf209b212303b96ef19cde 100644 (file)
@@ -36,7 +36,7 @@
 #ifdef HAVE_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
-#include "pcap/pcap.h"  // for SOCKET
+#include "portability.h"  // for SOCKET
 
 /*
  * Utility functions