merge_all_tap_menus() has been moved to menus.c.
[obnox/wireshark/wip.git] / airpcap_loader.c
index 90abe336b1c06d0dd6aeffed6a799cbf87c7d440..b41f51b86b9e088326f7c5ce5efca63b670918f8 100644 (file)
@@ -47,6 +47,7 @@
 #include <epan/strutil.h>
 #include <epan/frequency-utils.h>
 #include "capture_ui_utils.h"
+#include <wsutil/file_util.h>
 
 #include "simple_dialog.h"
 
@@ -148,7 +149,8 @@ static guint num_legacy_channels = 14;
 static guint
 get_wep_key(pref_t *pref, gpointer ud)
 {
-    gchar *my_string = NULL;
+    gchar *key_string = NULL;
+    guint8 key_type = AIRPDCAP_KEY_TYPE_WEP;
     keys_cb_data_t* user_data;
 
     decryption_key_t* new_key;
@@ -158,18 +160,33 @@ get_wep_key(pref_t *pref, gpointer ud)
 
     if (g_ascii_strncasecmp(pref->name, "wep_key", 7) == 0 && pref->type == PREF_STRING)
     {
-       my_string = g_strdup(*pref->varp.string);
+        /* strip out key type */
+        if (g_ascii_strncasecmp(*pref->varp.string, STRING_KEY_TYPE_WEP ":", 4) == 0) {
+              key_string = (gchar*)(*pref->varp.string)+4;
+        }
+        else if (g_ascii_strncasecmp(*pref->varp.string, STRING_KEY_TYPE_WPA_PWD ":", 8) == 0) {
+              key_string = (gchar*)(*pref->varp.string)+8;
+          key_type = AIRPDCAP_KEY_TYPE_WPA_PWD;
+        }
+        else if (g_ascii_strncasecmp(*pref->varp.string, STRING_KEY_TYPE_WPA_PSK ":", 8) == 0) {
+              key_string = (gchar*)(*pref->varp.string)+8;
+          key_type = AIRPDCAP_KEY_TYPE_WPA_PSK;
+        }
+        else {
+          key_type = AIRPDCAP_KEY_TYPE_WEP;
+              key_string = (gchar*)*pref->varp.string;
+        }
 
            /* Here we have the string describing the key... */
-           new_key = parse_key_string(my_string);
+           new_key = parse_key_string(key_string, key_type);
 
-       if( new_key != NULL)
-       {
-           /* Key is added only if not null ... */
-           user_data->list = g_list_append(user_data->list,new_key);
-           user_data->number_of_keys++;
-           user_data->current_index++;
-       }
+           if( new_key != NULL)
+           {
+              /* Key is added only if not null ... */
+              user_data->list = g_list_append(user_data->list,new_key);
+              user_data->number_of_keys++;
+              user_data->current_index++;
+           }
     }
     return 0;
 }
@@ -2249,6 +2266,7 @@ test_if_on(pref_t *pref, gpointer ud)
 
 /*
  * Returns TRUE if the Wireshark decryption is active, false otherwise
+ * XXX - Should we just add a routine to packet-ieee80211.c to grab this directly?
  */
 gboolean
 wireshark_decryption_on(void)
@@ -2336,7 +2354,6 @@ set_on_off(pref_t *pref, gpointer ud)
     {
        number = *pref->varp.boolp;
 
-       g_free((void *)*pref->varp.boolp);
        if(*is_on)
            *pref->varp.boolp = TRUE;
        else
@@ -2451,7 +2468,7 @@ int load_airpcap(void)
     gboolean base_functions = TRUE;
     gboolean eleven_n_functions = TRUE;
 
-    if((AirpcapLib =  LoadLibrary(TEXT("airpcap.dll"))) == NULL)
+    if((AirpcapLib = ws_load_library("airpcap.dll")) == NULL)
     {
                /* Report the error but go on */
                AirpcapVersion = AIRPCAP_DLL_NOT_FOUND;