Modification of version resource.
[obnox/wireshark/wip.git] / capture-wpcap.c
index b61b6c0e239366e62caa46bd0fa532b1e4affc44..7b1ecb3429c1fbfd3ac269d1f8fa1fad7870efb9 100644 (file)
@@ -1,12 +1,12 @@
 /* capture-wpcap.c
  * WinPcap-specific interfaces for capturing.  We load WinPcap at run
- * time, so that we only need one Ethereal binary and one Tethereal binary
+ * time, so that we only need one Wireshark binary and one TShark binary
  * for Windows, regardless of whether WinPcap is installed or not.
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 2001 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
@@ -49,6 +49,11 @@ gboolean has_wpcap = FALSE;
 
 #ifdef HAVE_LIBPCAP
 
+/*
+ * XXX - should we require at least WinPcap 3.1 both for building an
+ * for using Wireshark?
+ */
+
 static char*   (*p_pcap_lookupdev) (char *);
 static void    (*p_pcap_close) (pcap_t *);
 static int     (*p_pcap_stats) (pcap_t *, struct pcap_stat *);
@@ -80,6 +85,9 @@ static int (*p_pcap_datalink_name_to_val) (const char *);
 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
 static const char *(*p_pcap_datalink_val_to_name) (int);
 #endif
+#ifdef HAVE_PCAP_BREAKLOOP
+static void    (*p_pcap_breakloop) (pcap_t *);
+#endif
 static const char *(*p_pcap_lib_version) (void);
 static int     (*p_pcap_setbuff) (pcap_t *, int dim);
 static int     (*p_pcap_next_ex) (pcap_t *, struct pcap_pkthdr **pkt_header, const u_char **pkt_data);
@@ -120,6 +128,14 @@ load_wpcap(void)
 #endif
 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
                SYM(pcap_datalink_val_to_name, TRUE),
+#endif
+#ifdef HAVE_PCAP_BREAKLOOP
+               /*
+                * We don't try to work around the lack of this at
+                * run time; it's present in WinPcap 3.1, which is
+                * the version we build with and ship with.
+                */
+               SYM(pcap_breakloop, FALSE),
 #endif
                SYM(pcap_lib_version, TRUE),
                SYM(pcap_setbuff, TRUE),
@@ -359,6 +375,9 @@ static struct dlt_choice dlt_choices[] = {
 #ifdef DLT_LINUX_IRDA
        DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
 #endif
+#ifdef DLT_LINUX_LAPD
+       DLT_CHOICE(DLT_LINUX_LAPD, "Linux vISDN LAPD"),
+#endif
 #ifdef DLT_LANE8023
        DLT_CHOICE(DLT_LANE8023, "Linux 802.3 LANE"),
 #endif
@@ -419,6 +438,13 @@ pcap_datalink_val_to_name(int dlt)
 }
 #endif
 
+#ifdef HAVE_PCAP_BREAKLOOP
+void pcap_breakloop(pcap_t *a)
+{
+       p_pcap_breakloop(a);
+}
+#endif
+
 /* setbuff is win32 specific! */
 int pcap_setbuff(pcap_t *a, int b)
 {
@@ -439,7 +465,7 @@ int pcap_next_ex (pcap_t *a, struct pcap_pkthdr **b, const u_char **c)
  * fall back on "pcap_lookupdev()".
  */
 GList *
-get_interface_list(int *err, char *err_str)
+get_interface_list(int *err, char **err_str)
 {
        GList  *il = NULL;
        wchar_t *names;
@@ -447,6 +473,7 @@ get_interface_list(int *err, char *err_str)
        char ascii_name[MAX_WIN_IF_NAME_LEN + 1];
        char ascii_desc[MAX_WIN_IF_NAME_LEN + 1];
        int i, j;
+       char errbuf[PCAP_ERRBUF_SIZE];
 
 #ifdef HAVE_PCAP_FINDALLDEVS
        if (p_pcap_findalldevs != NULL)
@@ -496,7 +523,7 @@ get_interface_list(int *err, char *err_str)
         * description of the Nth adapter.
         */
 
-       names = (wchar_t *)pcap_lookupdev(err_str);
+       names = (wchar_t *)pcap_lookupdev(errbuf);
        i = 0;
 
        if (names) {
@@ -583,6 +610,8 @@ get_interface_list(int *err, char *err_str)
                 * No interfaces found.
                 */
                *err = NO_INTERFACES_FOUND;
+               if (err_str != NULL)
+                       *err_str = NULL;
        }
 
        return il;
@@ -674,7 +703,6 @@ get_runtime_pcap_version(GString *str)
                }
        } else
                g_string_append(str, "without WinPcap");
-       g_string_append(str, " ");
 }
 
 #else /* HAVE_LIBPCAP */