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-snoop.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-snoop.c')
-rw-r--r-- | pcap-snoop.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/pcap-snoop.c b/pcap-snoop.c index 0cdddac2..83cb6d21 100644 --- a/pcap-snoop.c +++ b/pcap-snoop.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.39 2002-12-22 02:36:50 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.40 2003-07-25 03:25:47 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -142,6 +142,15 @@ pcap_stats(pcap_t *p, struct pcap_stat *ps) return (0); } +static void +pcap_close_snoop(pcap_t *p) +{ + if (p->buffer != NULL) + free(p->buffer); + if (p->fd >= 0) + close(p->fd); +} + /* XXX can't disable promiscuous */ pcap_t * pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, @@ -285,6 +294,8 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, goto bad; } + p->close_op = pcap_close_snoop; + return (p); bad: (void)close(fd); |