aboutsummaryrefslogtreecommitdiff
path: root/pcap-nit.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-nit.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-nit.c')
-rw-r--r--pcap-nit.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/pcap-nit.c b/pcap-nit.c
index f0bc8f47..1c0117f0 100644
--- a/pcap-nit.c
+++ b/pcap-nit.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.44 2002-12-22 02:36:49 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.45 2003-07-25 03:25:46 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -201,6 +201,15 @@ nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
return (0);
}
+static void
+pcap_close_nit(pcap_t *p)
+{
+ if (p->buffer != NULL)
+ free(p->buffer);
+ if (p->fd >= 0)
+ close(p->fd);
+}
+
pcap_t *
pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
char *ebuf)
@@ -250,6 +259,9 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE);
goto bad;
}
+
+ p->close_op = pcap_close_nit;
+
return (p);
bad:
if (fd >= 0)