summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-01-07 22:53:30 -0800
committerGuy Harris <guy@alum.mit.edu>2019-01-07 22:53:30 -0800
commit83c8c0b38dfdfd992bdfc2e6a370c5472d55c3d4 (patch)
treefe8c07c058dee92a5a7c7f30a1085099214a5953
parent9225ae2eca86dc75ee9d4c8a626e0c9c1d5a7831 (diff)
downloadlibpcap-83c8c0b38dfdfd992bdfc2e6a370c5472d55c3d4.tar.gz
Don't include pcap/pcap.h just to get SOCKET defined.
Put it in portability.h as well, with redefinition protections.
-rw-r--r--pcap/pcap.h11
-rw-r--r--portability.h28
-rw-r--r--sslutils.c2
-rw-r--r--sslutils.h2
4 files changed, 38 insertions, 5 deletions
diff --git a/pcap/pcap.h b/pcap/pcap.h
index 8a69a2f3..848ebbe6 100644
--- a/pcap/pcap.h
+++ b/pcap/pcap.h
@@ -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,
diff --git a/portability.h b/portability.h
index beec43cc..c2b8f8e2 100644
--- a/portability.h
+++ b/portability.h
@@ -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
diff --git a/sslutils.c b/sslutils.c
index d09ed6c9..c1aac9e4 100644
--- a/sslutils.c
+++ b/sslutils.c
@@ -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
diff --git a/sslutils.h b/sslutils.h
index 63810538..ac9496da 100644
--- a/sslutils.h
+++ b/sslutils.h
@@ -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