__pragma(warning(disable:4242)) \
__pragma(warning(disable:4244)) \
__pragma(warning(disable:4702))
- #define DIAG_ON_FLEX __pragma(warning(pop))
+ #define DIAG_ON_FLEX \
+ __pragma(warning(pop))
/*
* Suppress narrowing warnings.
#define DIAG_OFF_NARROWING \
__pragma(warning(push)) \
__pragma(warning(disable:4242))
- #define DIAG_ON_NARROWING __pragma(warning(pop))
+ #define DIAG_ON_NARROWING \
+ __pragma(warning(pop))
+
+ /*
+ * Suppress deprecation warnings.
+ */
+ #define DIAG_OFF_DEPRECATION \
+ __pragma(warning(push)) \
+ __pragma(warning(disable:4996))
+ #define DIAG_ON_DEPRECATION \
+ __pragma(warning(pop))
#elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
/*
* This is Clang 2.8 or later; we can use "clang diagnostic
#define DIAG_ON_NARROWING \
PCAP_DO_PRAGMA(clang diagnostic pop)
+
+ /*
+ * Suppress deprecation warnings.
+ */
+ #define DIAG_OFF_DEPRECATION \
+ PCAP_DO_PRAGMA(clang diagnostic push) \
+ PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdeprecated-declarations")
+ #define DIAG_ON_DEPRECATION \
+ PCAP_DO_PRAGMA(clang diagnostic pop)
#elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
/*
* This is GCC 4.6 or later, or a compiler claiming to be that.
*/
#define DIAG_OFF_NARROWING
#define DIAG_ON_NARROWING
+
+ /*
+ * Suppress deprecation warnings.
+ */
+ #define DIAG_OFF_DEPRECATION \
+ PCAP_DO_PRAGMA(GCC diagnostic push) \
+ PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
+ #define DIAG_ON_DEPRECATION \
+ PCAP_DO_PRAGMA(GCC diagnostic pop)
#else
/*
* Neither Visual Studio, nor Clang 2.8 or later, nor GCC 4.6 or later
#define DIAG_ON_FLEX
#define DIAG_OFF_NARROWING
#define DIAG_ON_NARROWING
+ #define DIAG_OFF_DEPRECATION
+ #define DIAG_ON_DEPRECATION
#endif
#ifdef YYBYACC
#include "pcap-int.h"
+#include "diag-control.h"
+
#include "gencode.h"
#include <pcap/namedb.h>
#include "nametoaddr.h"
bpf_u_int32 **p;
struct hostent *hp;
+ /*
+ * gethostbyname() is deprecated on Windows, perhaps because
+ * it's not thread-safe, or because it doesn't support IPv6,
+ * or both.
+ *
+ * We deprecate pcap_nametoaddr() on all platforms because
+ * it's not thread-safe; we supply it for backwards compatibility,
+ * so suppress the deprecation warning. We could, I guess,
+ * use getaddrinfo() and construct the array ourselves, but
+ * that's probably not worth the effort, as that wouldn't make
+ * this thread-safe - we can't change the API to require that
+ * our caller free the address array, so we still have to reuse
+ * a local array.
+ */
+DIAG_OFF_DEPRECATION
if ((hp = gethostbyname(name)) != NULL) {
+DIAG_ON_DEPRECATION
#ifndef h_addr
hlist[0] = (bpf_u_int32 *)hp->h_addr;
NTOHL(hp->h_addr);
PCAP_API u_char *pcap_ether_hostton(const char*);
PCAP_API u_char *pcap_ether_aton(const char *);
-PCAP_API bpf_u_int32 **pcap_nametoaddr(const char *);
+PCAP_API bpf_u_int32 **pcap_nametoaddr(const char *)
+PCAP_DEPRECATED(pcap_nametoaddr, "this is not reentrant; use 'pcap_nametoaddrinfo' instead");
PCAP_API struct addrinfo *pcap_nametoaddrinfo(const char *);
PCAP_API bpf_u_int32 pcap_nametonetaddr(const char *);