aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2006-10-02 23:44:10 +0000
committerGerald Combs <gerald@wireshark.org>2006-10-02 23:44:10 +0000
commit2649d2614545278344fee1ce36196e3771101f42 (patch)
treee10aa1fa027e374ffc33803ece9d48513a9f221b /gtk
parent6cde05da1bfb6e43365a3d2fc6f7ca03d49be65e (diff)
downloadwireshark-2649d2614545278344fee1ce36196e3771101f42.tar.gz
wireshark-2649d2614545278344fee1ce36196e3771101f42.tar.bz2
wireshark-2649d2614545278344fee1ce36196e3771101f42.zip
Fix WEP key bug in the AirPcap code that could cause a crash. Enable
AirPcap by default. Add initial support for the "Any" device in AirPcap (more to come). svn path=/trunk/; revision=19401
Diffstat (limited to 'gtk')
-rw-r--r--gtk/airpcap_dlg.c59
-rwxr-xr-xgtk/airpcap_gui_utils.c44
-rwxr-xr-xgtk/airpcap_gui_utils.h12
-rw-r--r--gtk/capture_dlg.c4
-rw-r--r--gtk/keys.h4
5 files changed, 95 insertions, 28 deletions
diff --git a/gtk/airpcap_dlg.c b/gtk/airpcap_dlg.c
index aed0fc7389..41737d47a9 100644
--- a/gtk/airpcap_dlg.c
+++ b/gtk/airpcap_dlg.c
@@ -32,11 +32,14 @@
#include <gtk/gtk.h>
#include <glib.h>
+#include <glib/gprintf.h>
#include <string.h>
#include <epan/filesystem.h>
+#include <pcap.h>
+
#include "gtk/main.h"
#include "dlg_utils.h"
#include "gui_utils.h"
@@ -264,7 +267,6 @@ if(keys_in_list > 0)
/*
* Allocate the collection
- * We use malloc so it's easier to reuse the code in C programs
*/
KeysCollection = (PAirpcapKeysCollection)malloc(KeysCollectionSize);
if(!KeysCollection)
@@ -304,7 +306,7 @@ if(keys_in_list > 0)
}
/*
- * XXX - Free the old adapter key collection!
+ * Free the old adapter key collection!
*/
if(airpcap_if_selected->keysCollection != NULL)
g_free(airpcap_if_selected->keysCollection);
@@ -315,6 +317,8 @@ if(keys_in_list > 0)
airpcap_if_selected->keysCollection = KeysCollection;
airpcap_if_selected->keysCollectionSize = KeysCollectionSize;
}
+
+return;
}
@@ -528,7 +532,7 @@ void update_blink(gpointer data _U_)
{
airpcap_if_info_t* sel;
PAirpcapHandle ad;
-char* ebuf = NULL;
+gchar ebuf[AIRPCAP_ERRBUF_SIZE];
sel = (airpcap_if_info_t*)data;
@@ -556,7 +560,7 @@ void
blink_cb( GtkWidget *blink_bt _U_, gpointer if_data )
{
PAirpcapHandle ad = NULL;
-char* ebuf = NULL;
+gchar ebuf[AIRPCAP_ERRBUF_SIZE];
if(airpcap_if_selected != NULL)
if(!(airpcap_if_selected->blinking))
@@ -596,7 +600,7 @@ static void
airpcap_if_destroy_cb(GtkWidget *w _U_, gpointer user_data _U_)
{
PAirpcapHandle ad = NULL;
- char* ebuf = NULL;
+ gchar ebuf[AIRPCAP_ERRBUF_SIZE];
/* Retrieve object data */
GtkWidget *main_w;
@@ -706,8 +710,10 @@ airpcap_if_destroy_cb(GtkWidget *w _U_, gpointer user_data _U_)
if( g_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
{
gtk_label_set_text(GTK_LABEL(toolbar_if_lb), g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(airpcap_if_selected)));
- airpcap_channel_combo_set_by_number(toolbar_channel_cm,airpcap_if_selected->channel);
- airpcap_validation_type_combo_set_by_type(toolbar_wrong_crc_cm,airpcap_if_selected->CrcValidationOn);
+
+ airpcap_update_channel_combo(GTK_WIDGET(toolbar_channel_cm),airpcap_if_selected);
+
+ airpcap_validation_type_combo_set_by_type(toolbar_wrong_crc_cm,airpcap_if_selected->CrcValidationOn);
gtk_signal_handler_block_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
if(airpcap_if_active->DecryptionOn == AIRPCAP_DECRYPTION_ON)
@@ -791,7 +797,7 @@ airpcap_advanced_apply_cb(GtkWidget *button, gpointer data _U_)
if( g_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
{
gtk_label_set_text(GTK_LABEL(toolbar_if_lb), g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(airpcap_if_selected)));
- airpcap_channel_combo_set_by_number(toolbar_channel_cm,airpcap_if_selected->channel);
+ airpcap_update_channel_combo(GTK_WIDGET(toolbar_channel_cm),airpcap_if_selected);
airpcap_validation_type_combo_set_by_type(toolbar_wrong_crc_cm,airpcap_if_selected->CrcValidationOn);
gtk_signal_handler_block_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
@@ -844,7 +850,7 @@ airpcap_advanced_ok_cb(GtkWidget *w, gpointer data _U_)
if( g_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
{
gtk_label_set_text(GTK_LABEL(toolbar_if_lb), g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(airpcap_if_selected)));
- airpcap_channel_combo_set_by_number(toolbar_channel_cm,airpcap_if_selected->channel);
+ airpcap_update_channel_combo(GTK_WIDGET(toolbar_channel_cm),airpcap_if_selected);
airpcap_validation_type_combo_set_by_type(toolbar_wrong_crc_cm,airpcap_if_selected->CrcValidationOn);
gtk_signal_handler_block_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
@@ -911,9 +917,15 @@ new_key = g_string_new(text_entered);
g_strchug(new_key->str);
g_strchomp(new_key->str);
+if((new_key->len) > WEP_KEY_MAX_CHAR_SIZE)
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WEP key size out of range!\nValid key size range is 2-%d characters (8-%d bits).",WEP_KEY_MAX_CHAR_SIZE,WEP_KEY_MAX_SIZE*8);
+ return;
+ }
+
if((new_key->len % 2) != 0)
{
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","1) A Wep key must is an arbitrary length hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.\nThe number of characters must be even.");
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Wrong WEP key!\nThe number of characters must be even.");
return;
}
@@ -921,7 +933,7 @@ for(i = 0; i < new_key->len; i++)
{
if(!g_ascii_isxdigit(new_key->str[i]))
{
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","2) A Wep key must is an arbitrary length hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.\nThe number of characters must be even.");
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Wrong WEP key!\nA WEP key must be an hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
return;
}
}
@@ -935,6 +947,7 @@ g_string_free(new_key,TRUE);
g_free(text_entered);
window_destroy(GTK_WIDGET(data));
+
return;
}
@@ -972,9 +985,15 @@ new_key = g_string_new(text_entered);
g_strchug(new_key->str);
g_strchomp(new_key->str);
+if((new_key->len) > WEP_KEY_MAX_CHAR_SIZE)
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WEP key size out of range!\nValid key size range is 2-%d characters (8-%d bits).",WEP_KEY_MAX_CHAR_SIZE,WEP_KEY_MAX_SIZE*8);
+ return;
+ }
+
if((new_key->len % 2) != 0)
{
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","1) A Wep key must is an arbitrary length hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.\nThe number of characters must be even.");
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Wrong WEP key!\nThe number of characters must be even.");
return;
}
@@ -982,7 +1001,7 @@ for(i = 0; i < new_key->len; i++)
{
if(!g_ascii_isxdigit(new_key->str[i]))
{
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","2) A Wep key must is an arbitrary length hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.\nThe number of characters must be even.");
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Wrong WEP key!\nA WEP key must be an hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
return;
}
}
@@ -1403,7 +1422,7 @@ airpcap_if_selected->saved = FALSE;
/* Turns the decryption on or off */
static void
-encryption_check_cb(GtkWidget *w, gpointer data)
+wep_encryption_check_cb(GtkWidget *w, gpointer data)
{
if( !block_advanced_signals && (airpcap_if_selected != NULL))
{
@@ -1420,14 +1439,13 @@ if( !block_advanced_signals && (airpcap_if_selected != NULL))
}
}
-
/* Called to create the airpcap settings' window */
void
display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
{
/* Main window */
GtkWidget *airpcap_advanced_w;
-
+
/* Blink button */
GtkWidget *blink_bt,
*channel_combo;
@@ -1497,7 +1515,7 @@ display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
/* other stuff */
GList *channel_list,*capture_list;
GList *linktype_list = NULL;
- gchar *channel_s,*capture_s;
+ gchar *capture_s;
/* user data - RETRIEVE pointers of toolbar widgets */
@@ -1659,8 +1677,7 @@ display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
/* Select the first entry */
if(airpcap_if_selected != NULL)
{
- channel_s = g_strdup_printf("%d",airpcap_if_selected->channel);
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_combo)->entry), channel_s);
+ airpcap_update_channel_combo(GTK_WIDGET(channel_combo), airpcap_if_selected);
}
channel_te = GTK_COMBO(channel_combo)->entry;
@@ -1755,7 +1772,7 @@ display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
/* encryption enabled box */
encryption_check = gtk_check_button_new_with_label("Enable WEP Decryption");
- OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_DECRYPTION_KEY,encryption_check);
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_WEP_DECRYPTION_KEY,encryption_check);
/* Fcs Presence check box */
if(airpcap_if_selected != NULL)
@@ -1766,7 +1783,7 @@ display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(encryption_check),FALSE);
}
- SIGNAL_CONNECT(encryption_check,"toggled",encryption_check_cb,NULL);
+ SIGNAL_CONNECT(encryption_check,"toggled",wep_encryption_check_cb,NULL);
gtk_box_pack_start (GTK_BOX (encryption_box), encryption_check, FALSE, FALSE, 0);
gtk_widget_show(encryption_check);
diff --git a/gtk/airpcap_gui_utils.c b/gtk/airpcap_gui_utils.c
index d6bc5bcba3..3c02320ca2 100755
--- a/gtk/airpcap_gui_utils.c
+++ b/gtk/airpcap_gui_utils.c
@@ -82,7 +82,7 @@ if(if_info != NULL)
gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_decryption,FALSE);
airpcap_validation_type_combo_set_by_type(GTK_WIDGET(airpcap_toolbar_crc_filter_combo),if_info->CrcValidationOn);
- airpcap_channel_combo_set_by_number(GTK_WIDGET(airpcap_toolbar_channel),if_info->channel);
+ airpcap_update_channel_combo(GTK_WIDGET(airpcap_toolbar_channel),if_info);
/*decription check box*/
gtk_signal_handler_block_by_func (GTK_OBJECT(airpcap_toolbar_decryption),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), airpcap_tb);
@@ -145,7 +145,7 @@ if(if_info != NULL)
gtk_widget_set_sensitive(airpcap_toolbar_button,TRUE);
gtk_widget_set_sensitive(airpcap_toolbar_decryption,TRUE);
airpcap_validation_type_combo_set_by_type(GTK_WIDGET(airpcap_toolbar_crc_filter_combo),if_info->CrcValidationOn);
- airpcap_channel_combo_set_by_number(GTK_WIDGET(airpcap_toolbar_channel),if_info->channel);
+ airpcap_update_channel_combo(GTK_WIDGET(airpcap_toolbar_channel),if_info);
/*decription check box*/
gtk_signal_handler_block_by_func (GTK_OBJECT(airpcap_toolbar_decryption),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), airpcap_tb);
@@ -205,14 +205,20 @@ airpcap_fill_key_list(GtkWidget *keylist,airpcap_if_info_t* if_info)
{
GtkWidget *nl_item,*nl_lb;
gchar* s;
-unsigned int i;
+unsigned int i,n;
+
+n = 0;
if( (if_info != NULL) && (if_info->keysCollection != NULL))
{
+ n = if_info->keysCollection->nKeys;
for(i = 0; i < if_info->keysCollection->nKeys; i++)
{
- s = airpcap_get_key_string(if_info->keysCollection->Keys[i]);
+ s = airpcap_get_key_string(if_info->keysCollection->Keys[i]); /* g_strdup_printf("1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\0"); */
+
nl_lb = gtk_label_new(s);
+ g_free(s);
+
nl_item = gtk_list_item_new();
gtk_misc_set_alignment (GTK_MISC (nl_lb), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(nl_item), nl_lb);
@@ -398,4 +404,34 @@ airpcap_channel_combo_set_by_number(GtkWidget* w,UINT channel)
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),airpcap_get_channel_name(channel));
}
+/*
+ * Returns '1' if this is the "Any" adapter, '0' otherwise
+ */
+int
+airpcap_if_is_any(airpcap_if_info_t* if_info)
+{
+if(g_strcasecmp(if_info->name,AIRPCAP_DEVICE_ANY_EXTRACT_STRING)==0)
+ return 1;
+else
+ return 0;
+}
+
+/*
+ * Update channel combo box. If the airpcap interface is "Any", the combo box will be disabled.
+ */
+void
+airpcap_update_channel_combo(GtkWidget* w, airpcap_if_info_t* if_info)
+{
+if(airpcap_if_is_any(if_info))
+ {
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry)," ");
+ gtk_widget_set_sensitive(GTK_WIDGET(w),FALSE);
+ }
+else
+ {
+ airpcap_channel_combo_set_by_number(w,if_info->channel);
+ gtk_widget_set_sensitive(GTK_WIDGET(w),TRUE);
+ }
+}
+
#endif /* HAVE_AIRPCAP */
diff --git a/gtk/airpcap_gui_utils.h b/gtk/airpcap_gui_utils.h
index f4c74fe952..0c3048f231 100755
--- a/gtk/airpcap_gui_utils.h
+++ b/gtk/airpcap_gui_utils.h
@@ -127,4 +127,16 @@ airpcap_get_channel_name(UINT n);
void
airpcap_channel_combo_set_by_number(GtkWidget* w,UINT channel);
+/*
+ * Returns '1' if this is the "Any" adapter, '0' otherwise
+ */
+int
+airpcap_if_is_any(airpcap_if_info_t* if_info);
+
+/*
+ * Update channel combo box. If the airpcap interface is "Any", the combo box will be disabled.
+ */
+void
+airpcap_update_channel_combo(GtkWidget* w, airpcap_if_info_t* if_info);
+
#endif
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index fa2d96da0f..12e5029821 100644
--- a/gtk/capture_dlg.c
+++ b/gtk/capture_dlg.c
@@ -850,11 +850,11 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
advanced_hb = gtk_hbox_new(FALSE,5);
gtk_box_pack_start(GTK_BOX(capture_vb), advanced_hb, FALSE, FALSE, 0);
- advanced_bt = gtk_button_new();
+ advanced_bt = gtk_button_new_with_label("Wireless Settings");
/* set the text */
#if GTK_MAJOR_VERSION >= 2
- /* XXX - find a way to set the GtkButton label in GTK 1.x */
+ /* XXX - find a way to set the GtkButton label in GTK 2.x */
gtk_button_set_label(GTK_BUTTON(advanced_bt), "Wireless Settings");
#else
/* Set the GtkButton label in GTK 1.x */
diff --git a/gtk/keys.h b/gtk/keys.h
index 9df70b4214..840b677b21 100644
--- a/gtk/keys.h
+++ b/gtk/keys.h
@@ -72,7 +72,9 @@
#define AIRPCAP_ADVANCED_EDIT_KEY_TEXT_KEY "airpcap_advanced_edit_key_text_key"
#define AIRPCAP_ADVANCED_EDIT_KEY_OK_KEY "airpcap_advanced_edit_key_ok_key"
#define AIRPCAP_ADVANCED_EDIT_KEY_LABEL_KEY "airpcap_advanced_edit_key_label_key"
-#define AIRPCAP_ADVANCED_DECRYPTION_KEY "airpcap_advanced_decryption_key"
+#define AIRPCAP_ADVANCED_WEP_DECRYPTION_KEY "airpcap_advanced_wep_decryption_key"
+#define AIRPCAP_ADVANCED_WPA_DECRYPTION_KEY "airpcap_advanced_wpa_decryption_key"
+#define AIRPCAP_ADVANCED_NOTEBOOK_KEY "airpcap_advanced_notebook_key"
#define AIRPCAP_OPTIONS_ADVANCED_KEY "airpcap_options_advanced_key"