diff options
author | guy <guy> | 2003-07-25 03:25:45 +0000 |
---|---|---|
committer | guy <guy> | 2003-07-25 03:25:45 +0000 |
commit | e648c9e593e7a7f0c3d031eb2e2c146de9efc67e (patch) | |
tree | b630ce04c2f5a47e774b93c07f7a771a7a0bb690 /pcap-nit.c | |
parent | 04177dcda41385c87b483853ae4e206d3768714e (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.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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) |