aboutsummaryrefslogtreecommitdiff
path: root/pcap-win32.c
diff options
context:
space:
mode:
authorguy <guy>2003-07-25 03:25:45 +0000
committerguy <guy>2003-07-25 03:25:45 +0000
commite648c9e593e7a7f0c3d031eb2e2c146de9efc67e (patch)
treeb630ce04c2f5a47e774b93c07f7a771a7a0bb690 /pcap-win32.c
parent04177dcda41385c87b483853ae4e206d3768714e (diff)
Add a "close" function pointer to the pcap_t structure, which handles
the platform-dependent part of closing a pcap_t (and the live-vs-savefile part as well, so that function must close the file descriptor and free up any buffers allocated). In the Digital UNIX support, add in a check for a memory allocation failure.
Diffstat (limited to 'pcap-win32.c')
-rw-r--r--pcap-win32.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/pcap-win32.c b/pcap-win32.c
index 1b15eec8..8722517f 100644
--- a/pcap-win32.c
+++ b/pcap-win32.c
@@ -32,7 +32,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.8 2003-05-15 14:30:30 risso Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.9 2003-07-25 03:25:47 guy Exp $ (LBL)";
#endif
#include <pcap-int.h>
@@ -137,6 +137,17 @@ pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
}
+static void
+pcap_close_win32(pcap_t *p)
+{
+ if (p->buffer != NULL)
+ free(p->buffer);
+ if (p->adapter != NULL) {
+ PacketCloseAdapter(p->adapter);
+ p->adapter = NULL;
+ }
+}
+
pcap_t *
pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
char *ebuf)
@@ -243,6 +254,8 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
PacketSetReadTimeout(p->adapter, to_ms);
+ p->close_op = pcap_close_win32;
+
return (p);
bad:
if (p->adapter)