From Michael Mann via bug 2794:
[obnox/wireshark/wip.git] / capture-wpcap.c
index 2cda3251365e58e83d4c37e9ea0b16244f6b92c7..5492f972ca51ca0448cfaa097e3ddb13a442f386 100644 (file)
@@ -63,10 +63,15 @@ static int     (*p_pcap_setfilter) (pcap_t *, struct bpf_program *);
 static char*   (*p_pcap_geterr) (pcap_t *);
 static int     (*p_pcap_compile) (pcap_t *, struct bpf_program *, const char *, int,
                        bpf_u_int32);
+static int     (*p_pcap_compile_nopcap) (int, int, struct bpf_program *, const char *, int,
+                       bpf_u_int32);
 static int     (*p_pcap_lookupnet) (const char *, bpf_u_int32 *, bpf_u_int32 *,
                        char *);
 static pcap_t* (*p_pcap_open_live) (const char *, int, int, int, char *);
 static int     (*p_pcap_loop) (pcap_t *, int, pcap_handler, guchar *);
+#ifdef HAVE_PCAP_OPEN_DEAD
+static pcap_t* (*p_pcap_open_dead) (int, int);
+#endif
 static void    (*p_pcap_freecode) (struct bpf_program *);
 #ifdef HAVE_PCAP_FINDALLDEVS
 static int     (*p_pcap_findalldevs) (pcap_if_t **, char *);
@@ -111,6 +116,10 @@ static int (*p_pcap_set_datalink)(pcap_t *, int);
 static int     (*p_pcap_free_datalinks)(int *);
 #endif
 
+#ifdef HAVE_BPF_IMAGE
+static char     *(*p_bpf_image) (const struct bpf_insn *, int);
+#endif
+
 typedef struct {
        const char      *name;
        gpointer        *ptr;
@@ -134,6 +143,7 @@ load_wpcap(void)
                SYM(pcap_setfilter, FALSE),
                SYM(pcap_geterr, FALSE),
                SYM(pcap_compile, FALSE),
+                SYM(pcap_compile_nopcap, FALSE),
                SYM(pcap_lookupnet, FALSE),
 #ifdef HAVE_PCAP_REMOTE
                SYM(pcap_open, FALSE),
@@ -141,6 +151,9 @@ load_wpcap(void)
                SYM(pcap_createsrcstr, FALSE),
 #endif
                SYM(pcap_open_live, FALSE),
+#ifdef HAVE_PCAP_OPEN_DEAD
+               SYM(pcap_open_dead, FALSE),
+#endif
 #ifdef HAVE_PCAP_SETSAMPLING
                SYM(pcap_setsampling, TRUE),
 #endif
@@ -178,6 +191,9 @@ load_wpcap(void)
 #endif
 #ifdef HAVE_PCAP_FREE_DATALINKS
                SYM(pcap_free_datalinks, TRUE),
+#endif
+#ifdef HAVE_BPF_IMAGE
+                SYM(bpf_image, FALSE),
 #endif
                { NULL, NULL, FALSE }
        };
@@ -289,6 +305,14 @@ pcap_compile(pcap_t *a, struct bpf_program *b, const char *c, int d,
        return p_pcap_compile(a, b, c, d, e);
 }
 
+int
+pcap_compile_nopcap(int a, int b, struct bpf_program *c, const char *d, int e,
+            bpf_u_int32 f)
+{
+       g_assert(has_wpcap);
+       return p_pcap_compile_nopcap(a, b, c, d, e, f);
+}
+
 int
 pcap_lookupnet(const char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *d)
 {
@@ -305,6 +329,28 @@ pcap_open_live(const char *a, int b, int c, int d, char *e)
     return p_pcap_open_live(a, b, c, d, e);
 }
 
+#ifdef HAVE_PCAP_OPEN_DEAD
+pcap_t*
+pcap_open_dead(int a, int b)
+{
+    if (!has_wpcap) {
+       return NULL;
+    }
+    return p_pcap_open_dead(a, b);
+}
+#endif
+
+#ifdef HAVE_BPF_IMAGE
+char *
+bpf_image(const struct bpf_insn *a, int b)
+{
+    if (!has_wpcap) {
+       return NULL;
+    }
+    return p_bpf_image(a, b);
+}
+#endif
+
 #ifdef HAVE_PCAP_REMOTE
 pcap_t*
 pcap_open(const char *a, int b, int c, int d, struct pcap_rmtauth *e, char *f)
@@ -827,7 +873,7 @@ get_runtime_pcap_version(GString *str)
         * not and, if we have it and we have "pcap_lib_version()",
         * what version we have.
         */
-       GModule *handle;                /* handle returned by dlopen */
+       GModule *handle;                /* handle returned by ws_module_open */
        static gchar *packetVer;
        gchar *blankp;