Add a "stats" function pointer to the pcap_t structure, which handles
getting statistics for a pcap_t. Have "pcap_stats()" call it, rather than being a per-platform function; have stats routines for non-live pcap_t's that return an error.
This commit is contained in:
parent
e648c9e593
commit
9792990eb8
13
pcap-bpf.c
13
pcap-bpf.c
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.62 2003-07-25 03:25:45 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.63 2003-07-25 04:04:56 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -103,17 +103,11 @@ static int odmlockid = 0;
|
||||||
|
|
||||||
#include "gencode.h"
|
#include "gencode.h"
|
||||||
|
|
||||||
int
|
static int
|
||||||
pcap_stats(pcap_t *p, struct pcap_stat *ps)
|
pcap_stats_bpf(pcap_t *p, struct pcap_stat *ps)
|
||||||
{
|
{
|
||||||
struct bpf_stat s;
|
struct bpf_stat s;
|
||||||
|
|
||||||
#ifdef HAVE_DAG_API
|
|
||||||
if (p->md.is_dag) {
|
|
||||||
return dag_stats(p, ps);
|
|
||||||
}
|
|
||||||
#endif /* HAVE_DAG_API */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "ps_recv" counts packets handed to the filter, not packets
|
* "ps_recv" counts packets handed to the filter, not packets
|
||||||
* that passed the filter. This includes packets later dropped
|
* that passed the filter. This includes packets later dropped
|
||||||
|
@ -736,6 +730,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
|
||||||
memset(p->buffer, 0x0, p->bufsize);
|
memset(p->buffer, 0x0, p->bufsize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
p->stats_op = pcap_stats_bpf;
|
||||||
p->close_op = pcap_close_bpf;
|
p->close_op = pcap_close_bpf;
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.2 2003-07-25 03:25:45 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.3 2003-07-25 04:04:57 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -67,6 +67,8 @@ static int atexit_handler_installed = 0;
|
||||||
#define dag_set_datalink_platform pcap_set_datalink_platform
|
#define dag_set_datalink_platform pcap_set_datalink_platform
|
||||||
#endif /* DAG_ONLY */
|
#endif /* DAG_ONLY */
|
||||||
|
|
||||||
|
static int dag_stats(pcap_t *p, struct pcap_stat *ps);
|
||||||
|
|
||||||
static void delete_pcap_dag(pcap_t *p) {
|
static void delete_pcap_dag(pcap_t *p) {
|
||||||
pcap_dag_node_t *curr = NULL, *prev = NULL;
|
pcap_dag_node_t *curr = NULL, *prev = NULL;
|
||||||
|
|
||||||
|
@ -385,12 +387,13 @@ pcap_t *dag_open_live(const char *device, int snaplen, int promisc, int to_ms, c
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle->stats_op = dag_stats;
|
||||||
handle->close_op = dag_platform_close;
|
handle->close_op = dag_platform_close;
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dag_stats(pcap_t *p, struct pcap_stat *ps) {
|
static int dag_stats(pcap_t *p, struct pcap_stat *ps) {
|
||||||
/* This needs to be filled out correctly. Hopefully a dagapi call will
|
/* This needs to be filled out correctly. Hopefully a dagapi call will
|
||||||
provide all necessary information.
|
provide all necessary information.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,12 +7,10 @@
|
||||||
*
|
*
|
||||||
* Author: Richard Littin, Sean Irvine ({richard,sean}@reeltwo.com)
|
* Author: Richard Littin, Sean Irvine ({richard,sean}@reeltwo.com)
|
||||||
*
|
*
|
||||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-dag.h,v 1.1 2003-07-23 05:29:21 guy Exp $ (LBL)
|
* @(#) $Header: /tcpdump/master/libpcap/pcap-dag.h,v 1.2 2003-07-25 04:04:57 guy Exp $ (LBL)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int dag_stats(pcap_t *p, struct pcap_stat *ps);
|
|
||||||
int dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
|
int dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
|
||||||
pcap_t *dag_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebuf);
|
pcap_t *dag_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebuf);
|
||||||
int dag_setfilter(pcap_t *p, struct bpf_program *fp);
|
int dag_setfilter(pcap_t *p, struct bpf_program *fp);
|
||||||
void dag_platform_close(pcap_t *p);
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.86 2003-07-25 03:25:45 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.87 2003-07-25 04:04:57 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -151,8 +151,8 @@ static int dlpi_kread(int, off_t, void *, u_int, char *);
|
||||||
static int get_dlpi_ppa(int, const char *, int, char *);
|
static int get_dlpi_ppa(int, const char *, int, char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
static int
|
||||||
pcap_stats(pcap_t *p, struct pcap_stat *ps)
|
pcap_stats_dlpi(pcap_t *p, struct pcap_stat *ps)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -672,6 +672,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->stats_op = pcap_stats_dlpi;
|
||||||
p->close_op = pcap_close_dlpi;
|
p->close_op = pcap_close_dlpi;
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.48 2003-07-25 03:25:46 guy Exp $ (LBL)
|
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.49 2003-07-25 04:04:57 guy Exp $ (LBL)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pcap_int_h
|
#ifndef pcap_int_h
|
||||||
|
@ -118,6 +118,7 @@ struct pcap {
|
||||||
/*
|
/*
|
||||||
* Methods.
|
* Methods.
|
||||||
*/
|
*/
|
||||||
|
int (*stats_op)(pcap_t *, struct pcap_stat *);
|
||||||
void (*close_op)(pcap_t *);
|
void (*close_op)(pcap_t *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
16
pcap-linux.c
16
pcap-linux.c
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.91 2003-07-25 03:25:46 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.92 2003-07-25 04:04:58 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -187,7 +187,8 @@ static void map_arphrd_to_dlt(pcap_t *, int, int);
|
||||||
static int live_open_old(pcap_t *, const char *, int, int, char *);
|
static int live_open_old(pcap_t *, const char *, int, int, char *);
|
||||||
static int live_open_new(pcap_t *, const char *, int, int, char *);
|
static int live_open_new(pcap_t *, const char *, int, int, char *);
|
||||||
static int pcap_read_packet(pcap_t *, pcap_handler, u_char *);
|
static int pcap_read_packet(pcap_t *, pcap_handler, u_char *);
|
||||||
static void pcap_close_linux(pcap_t *handle);
|
static int pcap_stats_linux(pcap_t *, struct pcap_stat *);
|
||||||
|
static void pcap_close_linux(pcap_t *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wrap some ioctl calls
|
* Wrap some ioctl calls
|
||||||
|
@ -394,6 +395,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle->stats_op = pcap_stats_linux;
|
||||||
handle->close_op = pcap_close_linux;
|
handle->close_op = pcap_close_linux;
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
|
@ -659,20 +661,14 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
|
||||||
* patches); otherwise, that information isn't available, and we lie
|
* patches); otherwise, that information isn't available, and we lie
|
||||||
* and report 0 as the count of dropped packets.
|
* and report 0 as the count of dropped packets.
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
pcap_stats(pcap_t *handle, struct pcap_stat *stats)
|
pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_TPACKET_STATS
|
#ifdef HAVE_TPACKET_STATS
|
||||||
struct tpacket_stats kstats;
|
struct tpacket_stats kstats;
|
||||||
socklen_t len = sizeof (struct tpacket_stats);
|
socklen_t len = sizeof (struct tpacket_stats);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DAG_API
|
|
||||||
if (handle->md.is_dag) {
|
|
||||||
return dag_stats(handle, stats);
|
|
||||||
}
|
|
||||||
#endif /* HAVE_DAG_API */
|
|
||||||
|
|
||||||
#ifdef HAVE_TPACKET_STATS
|
#ifdef HAVE_TPACKET_STATS
|
||||||
/*
|
/*
|
||||||
* Try to get the packet counts from the kernel.
|
* Try to get the packet counts from the kernel.
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.45 2003-07-25 03:25:46 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.46 2003-07-25 04:04:58 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -71,8 +71,8 @@ static const char rcsid[] =
|
||||||
/* Forwards */
|
/* Forwards */
|
||||||
static int nit_setflags(int, int, int, char *);
|
static int nit_setflags(int, int, int, char *);
|
||||||
|
|
||||||
int
|
static int
|
||||||
pcap_stats(pcap_t *p, struct pcap_stat *ps)
|
pcap_stats_nit(pcap_t *p, struct pcap_stat *ps)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -260,6 +260,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->stats_op = pcap_stats_nit;
|
||||||
p->close_op = pcap_close_nit;
|
p->close_op = pcap_close_nit;
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.16 2002-12-22 02:36:49 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.17 2003-07-25 04:04:58 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -39,13 +39,6 @@ static const char rcsid[] =
|
||||||
|
|
||||||
static char nosup[] = "live packet capture not supported on this system";
|
static char nosup[] = "live packet capture not supported on this system";
|
||||||
|
|
||||||
int
|
|
||||||
pcap_stats(pcap_t *p, struct pcap_stat *ps)
|
|
||||||
{
|
|
||||||
(void)snprintf(p->errbuf, sizeof(p->errbuf), "pcap_stats: %s", nosup);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.74 2003-07-25 03:25:47 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.75 2003-07-25 04:04:59 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -198,8 +198,8 @@ pcap_read(pcap_t *pc, int cnt, pcap_handler callback, u_char *user)
|
||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
pcap_stats(pcap_t *p, struct pcap_stat *ps)
|
pcap_stats_pf(pcap_t *p, struct pcap_stat *ps)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -413,6 +413,7 @@ your system may not be properly configured; see the packetfilter(4) man page\n",
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->stats_op = pcap_stats_pf;
|
||||||
p->close_op = pcap_close_pf;
|
p->close_op = pcap_close_pf;
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.61 2003-07-25 03:25:47 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.62 2003-07-25 04:04:59 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -84,8 +84,8 @@ static const char rcsid[] =
|
||||||
/* Forwards */
|
/* Forwards */
|
||||||
static int nit_setflags(int, int, int, char *);
|
static int nit_setflags(int, int, int, char *);
|
||||||
|
|
||||||
int
|
static int
|
||||||
pcap_stats(pcap_t *p, struct pcap_stat *ps)
|
pcap_stats_snit(pcap_t *p, struct pcap_stat *ps)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -318,6 +318,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->stats_op = pcap_stats_snit;
|
||||||
p->close_op = pcap_close_snit;
|
p->close_op = pcap_close_snit;
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.40 2003-07-25 03:25:47 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.41 2003-07-25 04:04:59 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -102,8 +102,8 @@ again:
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
pcap_stats(pcap_t *p, struct pcap_stat *ps)
|
pcap_stats_snoop(pcap_t *p, struct pcap_stat *ps)
|
||||||
{
|
{
|
||||||
register struct rawstats *rs;
|
register struct rawstats *rs;
|
||||||
struct rawstats rawstats;
|
struct rawstats rawstats;
|
||||||
|
@ -294,6 +294,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->stats_op = pcap_stats_snoop;
|
||||||
p->close_op = pcap_close_snoop;
|
p->close_op = pcap_close_snoop;
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.9 2003-07-25 03:25:47 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.10 2003-07-25 04:04:59 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <pcap-int.h>
|
#include <pcap-int.h>
|
||||||
|
@ -75,8 +75,8 @@ wsockinit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
pcap_stats(pcap_t *p, struct pcap_stat *ps)
|
pcap_stats_win32(pcap_t *p, struct pcap_stat *ps)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(PacketGetStats(p->adapter, (struct bpf_stat*)ps) != TRUE){
|
if(PacketGetStats(p->adapter, (struct bpf_stat*)ps) != TRUE){
|
||||||
|
@ -254,6 +254,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
|
||||||
|
|
||||||
PacketSetReadTimeout(p->adapter, to_ms);
|
PacketSetReadTimeout(p->adapter, to_ms);
|
||||||
|
|
||||||
|
p->stats_op = pcap_stats_win32;
|
||||||
p->close_op = pcap_close_win32;
|
p->close_op = pcap_close_win32;
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
|
|
17
pcap.c
17
pcap.c
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.57 2003-07-25 03:25:48 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.58 2003-07-25 04:05:00 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -610,6 +610,20 @@ pcap_strerror(int errnum)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_stats(pcap_t *p, struct pcap_stat *ps)
|
||||||
|
{
|
||||||
|
return p->stats_op(p, ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
pcap_stats_dead(pcap_t *p, struct pcap_stat *ps)
|
||||||
|
{
|
||||||
|
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"Statistics aren't available from a pcap_open_dead pcap_t");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pcap_close_dead(pcap_t *p)
|
pcap_close_dead(pcap_t *p)
|
||||||
{
|
{
|
||||||
|
@ -627,6 +641,7 @@ pcap_open_dead(int linktype, int snaplen)
|
||||||
memset (p, 0, sizeof(*p));
|
memset (p, 0, sizeof(*p));
|
||||||
p->snapshot = snaplen;
|
p->snapshot = snaplen;
|
||||||
p->linktype = linktype;
|
p->linktype = linktype;
|
||||||
|
p->stats_op = pcap_stats_dead;
|
||||||
p->close_op = pcap_close_dead;
|
p->close_op = pcap_close_dead;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
11
savefile.c
11
savefile.c
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.82 2003-07-25 03:25:48 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.83 2003-07-25 04:05:00 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -410,6 +410,14 @@ swap_hdr(struct pcap_file_header *hp)
|
||||||
hp->linktype = SWAPLONG(hp->linktype);
|
hp->linktype = SWAPLONG(hp->linktype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
sf_stats(pcap_t *p, struct pcap_stat *ps)
|
||||||
|
{
|
||||||
|
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||||
|
"Statistics aren't available from savefiles");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sf_close(pcap_t *p)
|
sf_close(pcap_t *p)
|
||||||
{
|
{
|
||||||
|
@ -524,6 +532,7 @@ pcap_open_offline(const char *fname, char *errbuf)
|
||||||
pcap_fddipad = 0;
|
pcap_fddipad = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
p->stats_op = sf_stats;
|
||||||
p->close_op = sf_close;
|
p->close_op = sf_close;
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
|
|
Reference in New Issue