diff --git a/caputils/capture-wpcap.c b/caputils/capture-wpcap.c index 87262dcfa9..26a64a92f1 100644 --- a/caputils/capture-wpcap.c +++ b/caputils/capture-wpcap.c @@ -119,6 +119,18 @@ static int (*p_pcap_free_datalinks)(int *); static char *(*p_bpf_image) (const struct bpf_insn *, int); #endif +#ifdef HAVE_PCAP_CREATE +static pcap_t* (*p_pcap_create) (const char *, char *); +static int (*p_pcap_set_snaplen) (pcap_t *, int); +static int (*p_pcap_set_promisc) (pcap_t *, int); +static int (*p_pcap_can_set_rfmon) (pcap_t *); +static int (*p_pcap_set_rfmon) (pcap_t *, int); +static int (*p_pcap_set_timeout) (pcap_t *, int); +static int (*p_pcap_set_buffer_size) (pcap_t *, int); +static int (*p_pcap_activate) (pcap_t *); +static const char* (*p_pcap_statustostr)(int); +#endif + typedef struct { const char *name; gpointer *ptr; @@ -193,6 +205,17 @@ load_wpcap(void) #endif #ifdef HAVE_BPF_IMAGE SYM(bpf_image, FALSE), +#endif +#ifdef HAVE_PCAP_CREATE + SYM(pcap_create, FALSE), + SYM(pcap_set_snaplen, FALSE), + SYM(pcap_set_promisc, FALSE), + SYM(pcap_can_set_rfmon, TRUE), + SYM(pcap_set_rfmon, TRUE), + SYM(pcap_set_timeout, FALSE), + SYM(pcap_set_buffer_size, FALSE), + SYM(pcap_activate, FALSE), + SYM(pcap_statustostr, TRUE), #endif { NULL, NULL, FALSE } }; @@ -446,6 +469,83 @@ pcap_freealldevs(pcap_if_t *a) } #endif +#ifdef HAVE_PCAP_CREATE +pcap_t * +pcap_create(const char *a, char *b) +{ + g_assert(has_wpcap && p_pcap_create != NULL); + return p_pcap_create(a, b); +} + +int +pcap_set_snaplen(pcap_t *a, int b) +{ + g_assert(has_wpcap && p_pcap_set_snaplen != NULL); + return p_pcap_set_snaplen(a, b); +} + +int +pcap_set_promisc(pcap_t *a, int b) +{ + g_assert(has_wpcap && p_pcap_set_promisc != NULL); + return p_pcap_set_promisc(a, b); +} + +int +pcap_can_set_rfmon(pcap_t *a) +{ + g_assert(has_wpcap); + if (p_pcap_can_set_rfmon != NULL) { + return p_pcap_can_set_rfmon(a); + } + return 0; +} + +int +pcap_set_rfmon(pcap_t *a, int b) +{ + g_assert(has_wpcap && p_pcap_set_rfmon != NULL); + return p_pcap_set_rfmon(a, b); +} + +int +pcap_set_timeout(pcap_t *a, int b) +{ + g_assert(has_wpcap && pcap_set_timeout != NULL); + return p_pcap_set_timeout(a, b); +} +int +pcap_set_buffer_size(pcap_t *a, int b) +{ + g_assert(has_wpcap && pcap_set_timeout != NULL); + return p_pcap_set_buffer_size(a, b); +} + +int +pcap_activate(pcap_t *a) +{ + g_assert(has_wpcap && pcap_activate != NULL); + return p_pcap_activate(a); + +} + +const char * +pcap_statustostr(int a) +{ + static char ebuf[15 + 10 + 1]; + + g_assert(has_wpcap); + if (pcap_statustostr != NULL) { + return pcap_statustostr(a); + } + + /* XXX copy routine from pcap.c ??? */ + (void)g_snprintf(ebuf, sizeof ebuf, "Don't have pcap_statustostr(), can't translate error: %d", a); + return(ebuf); + +} +#endif + #if defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) || defined(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION) /* * Table of DLT_ types, names, and descriptions, for use if the version diff --git a/config.nmake b/config.nmake index b69a2da453..fb57a78854 100644 --- a/config.nmake +++ b/config.nmake @@ -1603,9 +1603,9 @@ BPF_IMAGE_CONFIG= !IF DEFINED(PCAP_DIR) && DEFINED(PCAP_REMOTE) PCAP_HAVE_REMOTE_CONFIG=^#define HAVE_REMOTE 1 PCAP_REMOTE_CONFIG=^#define HAVE_PCAP_REMOTE 1 -PCAP_OPEN_CONFIG=^#define HAVE_PCAP_OPEN 1 -#Do not set, experimental -#PCAP_CREATE_CONFIG=^#define HAVE_PCAP_CREATE 1 +#PCAP_OPEN_CONFIG=^#define HAVE_PCAP_OPEN 1 +#Do not set, experimental. No interfaces shown if set. dumpcap.c needs changes. +PCAP_CREATE_CONFIG=^#define HAVE_PCAP_CREATE 1 PCAP_SETSAMPLING_CONFIG=^#define HAVE_PCAP_SETSAMPLING 1 !ELSE PCAP_HAVE_REMOTE_CONFIG=