diff options
author | Guy Harris <gharris@sonic.net> | 2020-05-30 20:08:14 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2020-05-30 20:08:14 -0700 |
commit | c8645aa7f3d31863d51dad32ca5c8c63dddb9e5b (patch) | |
tree | 0b9f03325e91741debe9fde9ff1e76dfc8433f85 /pcap/pcap.h | |
parent | 19e1676ca47ddb11385b771f477e181e3a442e3b (diff) | |
download | libpcap-c8645aa7f3d31863d51dad32ca5c8c63dddb9e5b.tar.gz |
Add pcap_handle(), and deprecate pcap_fileno(), on Windows.
I don't know whether a Windows HANDLE can be expected to survive
conversion to an int - and there's no need for it to have to be
converted. If a caller needs to do something with a HANDLE associated
with a pcap_t, it should call the new pcap_handle() routine and get a
HANDLE; code for UN*X that uses the result of pcap_fileno() is unlikely
to work on Windows anyway.
Squelch the "pointer truncation from 'HANDLE' to 'DWORD'" warning, as,
if that truncation causes an issue, callers should use pcap_handle(),
and if it *doesn't* cause an issue, it's, well, not an issue.
Diffstat (limited to 'pcap/pcap.h')
-rw-r--r-- | pcap/pcap.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/pcap/pcap.h b/pcap/pcap.h index ee2221fa..9385e4e9 100644 --- a/pcap/pcap.h +++ b/pcap/pcap.h @@ -548,7 +548,19 @@ PCAP_API int pcap_bufsize(pcap_t *); /* XXX */ PCAP_API FILE *pcap_file(pcap_t *); +#ifdef _WIN32 +/* + * This returns a HANDLE, cast to an int; UN*X code that uses the + * result of pcap_fileno() will probably not work on Windows. + * We keep it around for backwards compatibility, but also provide + * pcap_handle(), which returns a HANDLE. + */ +PCAP_API HANDLE pcap_handle(pcap_t *); +PCAP_API int pcap_fileno(pcap_t *) +PCAP_DEPRECATED(pcap_fileno, "use 'pcap_handle'"); +#else /* _WIN32 */ PCAP_API int pcap_fileno(pcap_t *); +#endif /* _WIN32 */ #ifdef _WIN32 PCAP_API int pcap_wsockinit(void); |