summaryrefslogtreecommitdiff
path: root/caputils
diff options
context:
space:
mode:
authorAndersBroman <anders.broman@ericsson.com>2016-01-04 13:22:40 +0100
committerAnders Broman <a.broman58@gmail.com>2016-01-06 09:34:42 +0000
commit1658a3520f79d63217b47015b244a82bd55d3f34 (patch)
tree8511d7f63630604f42f4a03138ff65e9d1a9b818 /caputils
parent0e7b7dc8839899e7cbfa4ff65788d84a1af1e4b5 (diff)
downloadwireshark-1658a3520f79d63217b47015b244a82bd55d3f34.tar.gz
[WINPCAP] First step to be able to use pcap_create()
Change-Id: Id95640db0e647a696b39ccbfabc8cf2922df1407 Reviewed-on: https://code.wireshark.org/review/13051 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'caputils')
-rw-r--r--caputils/capture-wpcap.c100
1 files changed, 100 insertions, 0 deletions
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;
@@ -194,6 +206,17 @@ load_wpcap(void)
#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