as suggested by Loris: add wpcap_packet_get_version() and check the packet.dll versio...
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 21 May 2005 09:41:57 +0000 (09:41 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 21 May 2005 09:41:57 +0000 (09:41 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@14411 f5534014-38df-0310-8fa8-9805f1628bb7

capture_wpcap_packet.c
capture_wpcap_packet.h
gtk/capture_if_details_dlg.c

index c208f99..d1ffcf2 100644 (file)
@@ -79,6 +79,7 @@ gboolean has_wpacket = FALSE;
 /******************************************************************************************************************************/
 /* stuff to load WinPcap's packet.dll and the functions required from it */
 
+static PCHAR     (*p_PacketGetVersion) (void);
 static LPADAPTER (*p_PacketOpenAdapter) (char *adaptername);
 static void      (*p_PacketCloseAdapter) (LPADAPTER);
 static int       (*p_PacketRequest) (LPADAPTER, int, void *);
@@ -97,9 +98,10 @@ wpcap_packet_load(void)
 
        /* These are the symbols I need or want from packet.dll */
        static const symbol_table_t     symbols[] = {
+               SYM(PacketGetVersion, FALSE),
                SYM(PacketOpenAdapter, FALSE),
                SYM(PacketCloseAdapter, FALSE),
-               SYM(PacketRequest, TRUE),
+               SYM(PacketRequest, FALSE),
                { NULL, NULL, FALSE }
        };
 
@@ -131,7 +133,6 @@ wpcap_packet_load(void)
                sym++;
        }
 
-
        has_wpacket = TRUE;
 }
 
@@ -141,12 +142,22 @@ wpcap_packet_load(void)
 /* functions to access the NDIS driver values */
 
 
+/* get dll version */
+char *
+wpcap_packet_get_version(void)
+{
+       g_assert(has_wpacket);
+    return p_PacketGetVersion();
+}
+
+
 /* open the interface */
 void *
 wpcap_packet_open(char *if_name)
 {
-    LPADAPTER adapter;
+    LPADAPTER   adapter;
 
+       g_assert(has_wpacket);
     adapter = p_PacketOpenAdapter(if_name);
 
     return adapter;
@@ -158,6 +169,7 @@ void
 wpcap_packet_close(void *adapter)
 {
 
+       g_assert(has_wpacket);
     p_PacketCloseAdapter(adapter);
 }
 
index 090c1b2..5e700e9 100644 (file)
@@ -28,6 +28,9 @@
 
 extern void wpcap_packet_load(void);
 
+/* get the packet.dll version info */
+extern char *wpcap_packet_get_version(void);
+
 /* open the interface */
 extern void * wpcap_packet_open(char *if_name);
 
index 4252d48..b52462d 100644 (file)
@@ -57,6 +57,7 @@
 #include "capture_wpcap_packet.h"
 #include "capture_if_details_dlg.h"
 
+#include "simple_dialog.h"
 
 #define DETAILS_STR_MAX     1024
 
@@ -1141,8 +1142,8 @@ capture_if_details_page_new(GtkWidget **table)
 }
 
 
-void
-capture_if_details_open(char *iface)
+static void
+capture_if_details_open_win(char *iface)
 {
     GtkWidget   *details_open_w,
                 *main_vb, *bbox, *close_bt, *help_bt;
@@ -1154,6 +1155,10 @@ capture_if_details_open(char *iface)
     int         entries;
 
 
+    /* open the network adapter */
+    adapter = wpcap_packet_open(iface);
+
+    /* open a new window */
     details_open_w = window_new(GTK_WINDOW_TOPLEVEL, "Ethereal: Interface Details");
 
     /* Container for the window contents */
@@ -1165,9 +1170,6 @@ capture_if_details_open(char *iface)
     notebook = gtk_notebook_new();
     gtk_container_add(GTK_CONTAINER(main_vb), notebook);
 
-    /* open the network adapter */
-    adapter = wpcap_packet_open(iface);
-
     /* General page */
     page_general = capture_if_details_page_new(&table);
     page_lb = gtk_label_new("General");
@@ -1224,4 +1226,53 @@ capture_if_details_open(char *iface)
     window_present(details_open_w);
 }
 
+
+static void capture_if_details_open_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
+{
+    switch(btn) {
+    case(ESD_BTN_OK):
+        capture_if_details_open_win(data);
+        break;
+    case(ESD_BTN_CANCEL):
+        break;
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+void
+capture_if_details_open(char *iface)
+{
+    char        *version;
+    gboolean    version_ok = FALSE;
+    gpointer    dialog;
+
+
+    /* check packet.dll version */
+    version = wpcap_packet_get_version();
+
+    /* XXX - we have to add more known DLL versions here */
+    if( strcmp(version, "3, 1, 0, 24") == 0 ||       /* 3.1 beta 4 */
+        strcmp(version, "3.0 alpha3" ) == 0          /* 3.0 release */
+        ) {   
+           version_ok = TRUE;
+    }
+
+    if(!version_ok) {
+        /* dll version unknown, warn user */
+        dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK | ESD_BTN_CANCEL, 
+            PRIMARY_TEXT_START "Unknown WinPcap version might crash or fail!" PRIMARY_TEXT_END
+            "\n\nThe WinPcap packet.dll version \"%s\" is unknown if it supports required functions!"
+            "\n\nOnly WinPcap versions 3.0 and 3.1 are known to work with this feature."
+            "\n\nCrashes or unexpected behaviour might occur, you have been warned!"
+            "\n\nContinue anyway?",
+            version);
+        simple_dialog_set_cb(dialog, capture_if_details_open_answered_cb, iface);
+    } else {
+        capture_if_details_open_win(iface);
+    }
+}
+
+
 #endif /* HAVE_LIBPCAP && _WIN32 */