Try to fix some of the build problems, it still bumms out on:
[obnox/wireshark/wip.git] / capture-wpcap.c
index 5492f972ca51ca0448cfaa097e3ddb13a442f386..876cd980d60d9bdc644282f9484692acf737e2f5 100644 (file)
 #include <glib.h>
 #include <gmodule.h>
 
+#include <epan/strutil.h>
+
 #include "capture_ifinfo.h"
 #include "capture-pcap-util.h"
 #include "capture-pcap-util-int.h"
+#include "capture-wpcap.h"
 
 #include <wsutil/file_util.h>
 
@@ -230,6 +233,34 @@ load_wpcap(void)
        has_wpcap = TRUE;
 }
 
+/*
+ * The official list of WinPcap mirrors is at
+ * http://www.winpcap.org/misc/mirrors.htm
+ */
+char *
+cant_load_winpcap_err(const char *app_name)
+{
+       return g_strdup_printf(
+"Unable to load WinPcap (wpcap.dll); %s will not be able to capture\n"
+"packets.\n"
+"\n"
+"In order to capture packets, WinPcap must be installed; see\n"
+"\n"
+"        http://www.winpcap.org/\n"
+"\n"
+"or the mirror at\n"
+"\n"
+"        http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/\n"
+"\n"
+"or the mirror at\n"
+"\n"
+"        http://winpcap.cs.pu.edu.tw/\n"
+"\n"
+"for a downloadable version of WinPcap and for instructions on how to install\n"
+"WinPcap.",
+           app_name);
+}
+
 char*
 pcap_lookupdev (char *a)
 {
@@ -324,6 +355,9 @@ pcap_t*
 pcap_open_live(const char *a, int b, int c, int d, char *e)
 {
     if (!has_wpcap) {
+       g_snprintf(e, PCAP_ERRBUF_SIZE,
+                  "unable to load WinPcap (wpcap.dll); can't open %s to capture",
+                  a);
        return NULL;
     }
     return p_pcap_open_live(a, b, c, d, e);
@@ -356,6 +390,9 @@ pcap_t*
 pcap_open(const char *a, int b, int c, int d, struct pcap_rmtauth *e, char *f)
 {
     if (!has_wpcap) {
+       g_snprintf(f, PCAP_ERRBUF_SIZE,
+                  "unable to load WinPcap (wpcap.dll); can't open %s to capture",
+                  a);
        return NULL;
     }
     return p_pcap_open(a, b, c, d, e, f);
@@ -688,6 +725,16 @@ get_interface_list(int *err, char **err_str)
        int i, j;
        char errbuf[PCAP_ERRBUF_SIZE];
 
+       if (!has_wpcap) {
+               /*
+                * We don't have WinPcap, so we can't get a list of
+                * interfaces.
+                */
+               *err = DONT_HAVE_PCAP;
+               *err_str = cant_load_winpcap_err("you");
+               return NULL;
+       }
+
 #ifdef HAVE_PCAP_FINDALLDEVS
        if (p_pcap_findalldevs != NULL)
                return get_interface_list_findalldevs(err, err_str);
@@ -858,7 +905,7 @@ cant_get_if_list_error_message(const char *err_str)
 void
 get_compiled_pcap_version(GString *str)
 {
-       g_string_append(str, "with WinPcap (version unknown)");
+       g_string_append(str, "with WinPcap (" STRINGIFY(PCAP_VERSION) ")");
 }
 
 /*