aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2006-08-16 18:01:25 +0000
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2006-08-16 18:01:25 +0000
commit5bafc75327ccd20a8496ba042d81651aa0f8dd2f (patch)
treed147d42347f9f0c1696934f807b64856060b2f20 /gtk
parente5b27a7bd3532abda25060b89b0a5b1d693be476 (diff)
Add support for AirPcap, an upcoming wireless product from CACE. Support
is disabled by default, and can be enabled by setting AIRPCAP_CONFIG in config.nmake. The code is currently limited to Windows, but should be adaptable to other platforms. The official announcement won't come until next week, so you'll have to read the source for details. :) git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@18928 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk')
-rw-r--r--gtk/Makefile.am4
-rw-r--r--gtk/Makefile.common2
-rw-r--r--gtk/airpcap_dlg.c1872
-rw-r--r--gtk/airpcap_dlg.h148
-rwxr-xr-xgtk/airpcap_gui_utils.c400
-rwxr-xr-xgtk/airpcap_gui_utils.h127
-rw-r--r--gtk/capture_dlg.c131
-rw-r--r--gtk/capture_dlg.h10
-rw-r--r--gtk/capture_if_dlg.c190
-rw-r--r--gtk/capture_info_dlg.c11
-rw-r--r--gtk/compat_macros.h3
-rw-r--r--gtk/gui_utils.c20
-rw-r--r--gtk/gui_utils.h8
-rw-r--r--gtk/keys.h66
-rw-r--r--gtk/main.c419
-rw-r--r--gtk/main.h5
-rw-r--r--gtk/menu.c20
-rw-r--r--gtk/recent.c20
-rw-r--r--gtk/recent.h1
19 files changed, 3401 insertions, 56 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 61143660ed..7e46784e19 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -39,6 +39,8 @@ wireshark-tap-register.c: $(WIRESHARK_TAP_SRC) $(top_srcdir)/make-tapreg-dotc
noinst_HEADERS = \
about_dlg.h \
+ airpcap_dlg.h \
+ airpcap_gui_utils.h \
capture_dlg.h \
capture_file_dlg.h \
capture_if_details_dlg.h \
@@ -124,6 +126,8 @@ endif
libui_a_DEPENDENCIES =
EXTRA_DIST = \
+ airpcap_dlg.c \
+ airpcap_gui_utils.c \
capture_if_details_dlg.c \
doxygen.cfg.in \
ethclist.c \
diff --git a/gtk/Makefile.common b/gtk/Makefile.common
index b1e7fbe24a..89477b0d50 100644
--- a/gtk/Makefile.common
+++ b/gtk/Makefile.common
@@ -40,6 +40,8 @@ GENERATED_FILES = $(GENERATED_HEADER_FILES) $(GENERATED_C_FILES)
#
WIRESHARK_GTK_SRC = \
about_dlg.c \
+ airpcap_dlg.c \
+ airpcap_gui_utils.c \
capture_dlg.c \
capture_file_dlg.c \
capture_if_dlg.c \
diff --git a/gtk/airpcap_dlg.c b/gtk/airpcap_dlg.c
new file mode 100644
index 0000000000..e177956870
--- /dev/null
+++ b/gtk/airpcap_dlg.c
@@ -0,0 +1,1872 @@
+/* airpcap_dlg.c
+ *
+ * $Id$
+ *
+ * Ulf Lamping <ulf.lamping@web.de>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 2000 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_AIRPCAP
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <string.h>
+
+#include <epan/filesystem.h>
+
+#include "gtk/main.h"
+#include "dlg_utils.h"
+#include "gui_utils.h"
+#include "simple_dialog.h"
+#include "dfilter_expr_dlg.h"
+#include "compat_macros.h"
+#include "gtkglobals.h"
+#include "help_dlg.h"
+
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_gui_utils.h"
+#include "airpcap_dlg.h"
+
+#include "keys.h"
+
+/* temporary block signals to widgets */
+BOOL block_advanced_signals;
+
+/*
+ * This struct will contain useful data for the selected (actual) airpcap device
+ */
+void
+airpcap_fill_if_combo(GtkWidget *combo, GList* if_list)
+{
+int ifn = 0;
+GList* popdown_if_list = NULL;
+GList* curr = NULL;
+airpcap_if_info_t* if_info = NULL;
+
+ curr = g_list_nth(if_list, ifn);
+ if_info = NULL;
+ if(curr != NULL) if_info = curr->data;
+
+ popdown_if_list = NULL;
+ ifn = g_list_length(if_list) - 1;
+ while(ifn >= 0) /* reverse order */
+ {
+ curr = g_list_nth(if_list, ifn);
+ if_info = NULL;
+ if(curr != NULL)
+ if_info = curr->data;
+ if(if_info != NULL)
+ popdown_if_list = g_list_append( popdown_if_list , if_info->description) ;
+ ifn--;
+ }
+ gtk_combo_set_popdown_strings( GTK_COMBO(combo), popdown_if_list) ;
+
+ if(airpcap_if_selected != NULL)
+ {
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), airpcap_if_selected->description);
+ }
+ else
+ {
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), "No Wireless Interfaces Found");
+ }
+}
+
+/*
+ * Callback for the crc chackbox
+ */
+static void
+crc_check_cb(GtkWidget *w, gpointer user_data)
+{
+if( !block_advanced_signals && (airpcap_if_selected != NULL))
+ {
+ if(airpcap_if_selected->IsFcsPresent)
+ {
+ airpcap_if_selected->IsFcsPresent = FALSE;
+ airpcap_if_selected->saved = FALSE;
+ }
+ else
+ {
+ airpcap_if_selected->IsFcsPresent = TRUE;
+ airpcap_if_selected->saved = FALSE;
+ }
+ }
+}
+
+/*
+ * Callback for the wrong crc combo
+ */
+static void
+wrong_crc_combo_cb(GtkWidget *w, gpointer data)
+{
+const gchar *s;
+
+s = gtk_entry_get_text(GTK_ENTRY(data));
+
+if( !block_advanced_signals && (data != NULL) && (w != NULL) )
+ {
+ if((g_strcasecmp("",s)))
+ {
+ airpcap_if_selected->CrcValidationOn = airpcap_get_validation_type(s);
+ airpcap_if_selected->saved = FALSE;
+ }
+ }
+}
+
+/*
+ * Changed callback for the channel combobox
+ */
+static void
+channel_changed_cb(GtkWidget *w _U_, gpointer data)
+{
+const gchar *s;
+
+ s = gtk_entry_get_text(GTK_ENTRY(data));
+
+if( !block_advanced_signals && (data != NULL) && (w != NULL) )
+ {
+ s = gtk_entry_get_text(GTK_ENTRY(data));
+ if((g_strcasecmp("",s)))
+ {
+ if(airpcap_if_selected != NULL)
+ {
+ airpcap_if_selected->channel = airpcap_get_channel_number(s);
+ airpcap_if_selected->saved = FALSE;
+ }
+ }
+ }
+}
+
+/*
+ * Changed callback for the link layer combobox
+ */
+static void
+link_type_changed_cb(GtkWidget *w _U_, gpointer data)
+{
+const gchar *s;
+
+s = gtk_entry_get_text(GTK_ENTRY(data));
+
+if( !block_advanced_signals && (data != NULL) && (w != NULL) )
+ {
+ if((g_strcasecmp("",s)))
+ {
+ airpcap_if_selected->linkType = airpcap_get_link_type(s);
+ airpcap_if_selected->saved = FALSE;
+ }
+ }
+}
+
+/*
+ * Activate callback for the adapter combobox
+ */
+static void
+combo_if_activate_cb(GtkWidget *entry _U_, gpointer data)
+{
+}
+
+/*
+ * Changed callback for the adapter combobox
+ */
+static void
+airpcap_advanced_combo_if_changed_cb(GtkWidget *w _U_, gpointer data)
+{
+const gchar* s = NULL;
+
+s = gtk_entry_get_text(GTK_ENTRY(w));
+
+if((g_strcasecmp("",s)))
+ {
+ /* We are trying to change the interface to set up...*/
+ /* Check if the current interface settings need to be SAVED! */
+ if( (airpcap_if_selected != NULL) && !block_advanced_signals)
+ {
+ if( (airpcap_if_selected->saved) ) /* Just change interface */
+ {
+ /* No changes for this interface, no need to save anything */
+ airpcap_change_if(w,data);
+ }
+ else
+ {
+ /* Popup a dialog to ask if user wants to save settings for selected
+ * interface before changing it...
+ */
+ airpcap_ask_for_save(w,data);
+ }
+ }
+ }
+}
+
+/*
+ * Takes the keys from the GtkList widget, and add them to the interface list
+ */
+void
+airpcap_add_keys_from_list(GtkWidget *keylist, airpcap_if_info_t *if_info)
+{
+GtkWidget *key_ls;
+
+GString *new_key;
+
+gchar *text_entered = NULL;
+
+GtkWidget *nl_item,*nl_lb;
+
+GList *list,
+ *children;
+
+/* airpcap stuff */
+UINT i, j;
+gchar s[3];
+PAirpcapKeysCollection KeysCollection;
+ULONG KeysCollectionSize;
+UCHAR KeyByte;
+
+UINT keys_in_list = 0;
+
+key_ls = keylist;
+
+keys_in_list = (UINT)g_list_length(GTK_LIST(key_ls)->children);
+
+if(keys_in_list > 0)
+{
+ /*
+ * Save the encryption keys, if we have any of them
+ */
+ KeysCollectionSize = 0;
+
+ /*
+ * Calculate the size of the keys collection
+ */
+ KeysCollectionSize = sizeof(AirpcapKeysCollection) + keys_in_list * sizeof(AirpcapKey);
+
+ /*
+ * Allocate the collection
+ * We use malloc so it's easier to reuse the code in C programs
+ */
+ KeysCollection = (PAirpcapKeysCollection)malloc(KeysCollectionSize);
+ if(!KeysCollection)
+ {
+ /* Simple dialog ERROR */
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","Failed mamory allocation for KeysCollection!");
+ return;
+ }
+
+ /*
+ * Populate the key collection
+ */
+ list = GTK_LIST(key_ls)->children;
+ KeysCollection->nKeys = keys_in_list;
+
+ for(i = 0; i < keys_in_list; i++)
+ {
+ KeysCollection->Keys[i].KeyType = AIRPCAP_KEYTYPE_WEP;
+
+ /* Retrieve the Item corresponding to the i-th key */
+ nl_item = g_list_nth_data(list, i);
+ children = gtk_container_children(GTK_CONTAINER(nl_item));
+ nl_lb = g_list_nth_data(children,0);
+ new_key = g_string_new(GTK_LABEL(nl_lb)->label);
+
+ KeysCollection->Keys[i].KeyLen = new_key->len / 2;
+ memset(&KeysCollection->Keys[i].KeyData, 0, sizeof(KeysCollection->Keys[i].KeyData));
+
+ for(j = 0 ; j < new_key->len; j += 2)
+ {
+ s[0] = new_key->str[j];
+ s[1] = new_key->str[j+1];
+ s[2] = '\0';
+ KeyByte = (UCHAR)strtol(s, NULL, 16);
+ KeysCollection->Keys[i].KeyData[j / 2] = KeyByte;
+ }
+ }
+
+ /*
+ * XXX - Free the old adapter key collection!
+ */
+ if(airpcap_if_selected->keysCollection != NULL)
+ g_free(airpcap_if_selected->keysCollection);
+
+ /*
+ * Set this collection ad the new one
+ */
+ airpcap_if_selected->keysCollection = KeysCollection;
+ airpcap_if_selected->keysCollectionSize = KeysCollectionSize;
+}
+}
+
+
+/*
+ * Pop-up window, used to ask the user if he wants to save the selected interface settings
+ * when closing the window.
+ */
+void
+airpcap_ask_for_save_before_closing(GtkWidget *w _U_, gpointer data)
+{
+ GtkWidget* dialog;
+
+ dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
+ PRIMARY_TEXT_START "Save settings before closing?" PRIMARY_TEXT_END "\n\n"
+ "If you close the window without saving, changes you made will\nbe discarded.");
+ simple_dialog_set_cb(dialog, airpcap_dialog_save_before_closing_cb, data);
+}
+
+/* user confirmed the "Save settings..." dialog */
+void
+airpcap_dialog_save_before_closing_cb(gpointer dialog _U_, gint btn, gpointer data)
+{
+GtkWidget* interface_combo;
+GtkWidget* key_ls;
+
+/* I need the combo box entry */
+interface_combo = GTK_WIDGET(OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_INTERFACE_KEY));
+key_ls = GTK_WIDGET(OBJECT_GET_DATA(data,AIRPCAP_ADVANCED_KEYLIST_KEY));
+
+ switch(btn) {
+ case(ESD_BTN_SAVE):
+ /* save interface and exit */
+ airpcap_add_keys_from_list(key_ls,airpcap_if_selected);
+ airpcap_save_selected_if_configuration(airpcap_if_selected);
+ /* Remove gtk timeout */
+ gtk_timeout_remove(airpcap_if_selected->tag);
+ break;
+ case(ESD_BTN_DONT_SAVE):
+ /* exit without saving */
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*
+ * Pop-up window, used to ask the user if he wants to save the selected interface settings
+ * when changing the interface in the advanced dialog box
+ */
+void
+airpcap_ask_for_save(GtkWidget *entry _U_, gpointer data)
+{
+ GtkWidget* dialog;
+
+ dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
+ PRIMARY_TEXT_START "Save settings before changing interface?" PRIMARY_TEXT_END "\n\n"
+ "If you change interface without saving, changes you made will\nbe discarded.");
+ simple_dialog_set_cb(dialog, airpcap_dialog_save_cb, data);
+
+}
+
+/* user confirmed the "Save settings..." dialog */
+void
+airpcap_dialog_save_cb(GtkWidget* dialog _U_, gint btn, gpointer data)
+{
+GtkWidget* interface_combo;
+GtkWidget* key_ls;
+
+/* I need the combo box entry */
+interface_combo = GTK_WIDGET(OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_INTERFACE_KEY));
+key_ls = GTK_WIDGET(OBJECT_GET_DATA(data,AIRPCAP_ADVANCED_KEYLIST_KEY));
+
+ switch(btn) {
+ case(ESD_BTN_SAVE):
+ /* save interface and change */
+ airpcap_add_keys_from_list(key_ls,airpcap_if_selected);
+ airpcap_save_selected_if_configuration(airpcap_if_selected);
+ /* Remove gtk timeout */
+ gtk_timeout_remove(airpcap_if_selected->tag);
+ airpcap_change_if(GTK_COMBO(interface_combo)->entry,data);
+ break;
+ case(ESD_BTN_DONT_SAVE):
+ /* change interface without saving */
+ airpcap_change_if(GTK_COMBO(interface_combo)->entry,data);
+ break;
+ case(ESD_BTN_CANCEL):
+ /* don't change interface and don't save */
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ * Function used to change the selected interface and advanced dialog box
+ */
+void
+airpcap_change_if(GtkWidget *entry _U_, gpointer data)
+{
+ const gchar *s;
+ gchar *channel_s;
+ gchar *capture_s;
+ GtkWidget *main_w;
+
+ GtkWidget *interface_combo;
+ GtkWidget *channel_combo;
+ GtkWidget *capture_combo;
+ GtkWidget *crc_check;
+ GtkWidget *wrong_crc_combo;
+ GtkWidget *blink_bt;
+ GtkWidget *key_ls;
+
+ airpcap_if_info_t *new_if;
+
+ /* Retrieve the GUI object pointers */
+ main_w = GTK_WIDGET(data);
+ interface_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_INTERFACE_KEY));
+ channel_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_CHANNEL_KEY));
+ capture_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_LINK_TYPE_KEY));
+ crc_check = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_CRC_KEY));
+ wrong_crc_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_WRONG_CRC_KEY));
+ blink_bt = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_BLINK_KEY));
+ key_ls = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_KEYLIST_KEY));
+
+ s = gtk_entry_get_text(GTK_ENTRY(entry));
+
+ /* Select actual interface*/
+ new_if = get_airpcap_if_from_description(airpcap_if_list, s);
+
+ /* And change the GUI according to it... */
+ /* This should always happen, but it seems that the callback is
+ * called twice, the first time with an 'empty' text... so it
+ * will return NULL!
+ */
+ if(new_if != NULL)
+ {
+ airpcap_if_selected = new_if;
+
+ new_if = NULL;
+ /* I need to 'block' signals to widgets or they will receive a signal now
+ and will change twice */
+ block_advanced_signals = TRUE;
+
+ /* Blink button */
+ if(airpcap_if_selected->blinking)
+ {
+ #if GTK_MAJOR_VERSION >= 2
+ gtk_button_set_label(GTK_BUTTON(blink_bt),"Stop Blinking");
+ #else
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(blink_bt)->child),"Stop Blinking");
+ #endif
+ }
+ else
+ {
+ #if GTK_MAJOR_VERSION >= 2
+ gtk_button_set_label(GTK_BUTTON(blink_bt)," Blink Led ");
+ #else
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(blink_bt)->child)," Blink Led ");
+ #endif
+ }
+
+ /* Channel combo */
+ channel_s = g_strdup_printf("%d",airpcap_if_selected->channel);
+ if(channel_combo != NULL) /* this event seems to happen when combo is still NULL */
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_combo)->entry), channel_s);
+
+ /* Link Layer combo */
+ capture_s = NULL;
+ if(airpcap_if_selected->linkType == AIRPCAP_LT_802_11)
+ {
+ capture_s = g_strdup_printf(AIRPCAP_LINK_TYPE_NAME_802_11_ONLY);
+ if(capture_combo != NULL) /* this event seems to happen when combo is still NULL */
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(capture_combo)->entry), capture_s);
+ }
+ else if(airpcap_if_selected->linkType == AIRPCAP_LT_802_11_PLUS_RADIO)
+ {
+ capture_s = g_strdup_printf(AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO);
+ if(capture_combo != NULL) /* this event seems to happen when combo is still NULL */
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(capture_combo)->entry), capture_s);
+ }
+
+ /* Fcs Presence check box */
+ if(airpcap_if_selected->IsFcsPresent)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(crc_check),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(crc_check),FALSE);
+
+ /* Wrong Crc combo box */
+ if(airpcap_if_selected->CrcValidationOn == AIRPCAP_VT_ACCEPT_EVERYTHING)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_combo)->entry),AIRPCAP_VALIDATION_TYPE_NAME_ALL);
+ else if(airpcap_if_selected->CrcValidationOn == AIRPCAP_VT_ACCEPT_CORRECT_FRAMES)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_combo)->entry),AIRPCAP_VALIDATION_TYPE_NAME_CORRECT);
+ else if(airpcap_if_selected->CrcValidationOn == AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_combo)->entry),AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT);
+
+ /* Remove old keys */
+ gtk_list_remove_items(GTK_LIST(key_ls),GTK_LIST(key_ls)->children);
+ /* Add new keys */
+ airpcap_fill_key_list(key_ls,airpcap_if_selected);
+
+ /* Enable the signals again */
+ block_advanced_signals = FALSE;
+ }
+}
+
+/*
+ * Thread function used to blink the led
+ */
+void update_blink(gpointer data _U_)
+{
+airpcap_if_info_t* sel;
+PAirpcapHandle ad;
+char* ebuf = NULL;
+
+sel = (airpcap_if_info_t*)data;
+
+ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list, sel->description), ebuf);
+if(ad)
+ {
+ if(sel->led)
+ {
+ airpcap_if_turn_led_off(ad, 0);
+ sel->led = FALSE;
+ }
+ else
+ {
+ airpcap_if_turn_led_on(ad, 0);
+ sel->led = TRUE;
+ }
+ airpcap_if_close(ad);
+ }
+}
+
+/*
+ * Blink button callback
+ */
+void
+blink_cb( GtkWidget *blink_bt _U_, gpointer if_data )
+{
+PAirpcapHandle ad = NULL;
+char* ebuf = NULL;
+
+if(airpcap_if_selected != NULL)
+ if(!(airpcap_if_selected->blinking))
+ {
+ #if GTK_MAJOR_VERSION >= 2
+ gtk_button_set_label(GTK_BUTTON(blink_bt),"Stop Blinking");
+ #else
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(blink_bt)->child),"Stop Blinking");
+ #endif
+ airpcap_if_selected->tag = gtk_timeout_add(500, (GtkFunction)update_blink,airpcap_if_selected);
+ airpcap_if_selected->blinking = TRUE;
+ }
+ else
+ {
+ #if GTK_MAJOR_VERSION >= 2
+ gtk_button_set_label(GTK_BUTTON(blink_bt)," Blink Led ");
+ #else
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(blink_bt)->child)," Blink Led ");
+ #endif
+ gtk_timeout_remove(airpcap_if_selected->tag);
+ airpcap_if_selected->blinking = FALSE;
+ /* Switch on the led! */
+ ad = airpcap_if_open(airpcap_if_selected->name, ebuf);
+ if(ad)
+ {
+ gtk_timeout_remove(airpcap_if_selected->tag);
+ airpcap_if_turn_led_on(ad, 0);
+ airpcap_if_selected->blinking = FALSE;
+ airpcap_if_selected->led = TRUE;
+ airpcap_if_close(ad);
+ }
+ }
+}
+
+/* the window was closed, cleanup things */
+static void
+airpcap_if_destroy_cb(GtkWidget *w _U_, gpointer user_data _U_)
+{
+ PAirpcapHandle ad = NULL;
+ char* ebuf = NULL;
+
+ /* Retrieve object data */
+ GtkWidget *main_w;
+ GtkWidget *channel_combo;
+ GtkWidget *capture_combo;
+ GtkWidget *crc_check;
+ GtkWidget *wrong_crc_combo;
+ GtkWidget *blink_bt;
+ GtkWidget *interface_combo;
+ GtkWidget *cancel_bt;
+ GtkWidget *ok_bt;
+ GtkWidget *key_ls;
+
+ /* widgets in the toolbar */
+ GtkWidget *toolbar,
+ *toolbar_if_lb,
+ *toolbar_channel_cm,
+ *toolbar_wrong_crc_cm,
+ *toolbar_decryption_ck,
+ *advanced_bt;
+
+ gint *from_widget = NULL;
+
+ /* Retrieve the GUI object pointers */
+ main_w = GTK_WIDGET(user_data);
+ interface_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_INTERFACE_KEY));
+ channel_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_CHANNEL_KEY));
+ capture_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_LINK_TYPE_KEY));
+ crc_check = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_CRC_KEY));
+ wrong_crc_combo = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_WRONG_CRC_KEY));
+ blink_bt = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_BLINK_KEY));
+ cancel_bt = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_CANCEL_KEY));
+ ok_bt = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_OK_KEY));
+ key_ls = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_KEYLIST_KEY));
+ advanced_bt = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_KEY));
+
+ toolbar = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_TOOLBAR_KEY));
+
+ /* retrieve toolbar info */
+ toolbar_if_lb = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_INTERFACE_KEY));
+ toolbar_channel_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_CHANNEL_KEY));
+ toolbar_wrong_crc_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_WRONG_CRC_KEY));
+ toolbar_decryption_ck = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_DECRYPTION_KEY));
+
+ from_widget = (gint*)OBJECT_GET_DATA(toolbar,AIRPCAP_ADVANCED_FROM_KEY);
+
+ /* ... */
+ /* gray out the toolbar (if we came here from the toolbar advanced button)*/
+ if( *from_widget == AIRPCAP_ADVANCED_FROM_TOOLBAR)
+ gtk_widget_set_sensitive(toolbar,TRUE);
+
+ /* Stop blinking ALL leds (go through the airpcap_if_list) */
+ if(airpcap_if_selected != NULL)
+ {
+ ad = airpcap_if_open(airpcap_if_selected->name, ebuf);
+ if(ad)
+ {
+ gtk_timeout_remove(airpcap_if_selected->tag);
+ airpcap_if_turn_led_on(ad, 0);
+ airpcap_if_selected->blinking = FALSE;
+ airpcap_if_selected->led = TRUE;
+ airpcap_if_close(ad);
+ }
+ }
+
+ /* See if the 'Cancel' button was pressed or not
+ * if button is pressed, don't save configuration!
+ */
+ if(GTK_BUTTON(cancel_bt)->in_button)
+ {
+ /* reload the configuration!!! Configuration has not been saved but
+ the corresponding structure has been modified probably...*/
+ if(!airpcap_if_selected->saved)
+ {
+ airpcap_load_selected_if_configuration(airpcap_if_selected);
+ }
+
+ /* NULL to everything */
+ main_w = NULL;
+ blink_bt = NULL;
+ channel_combo = NULL;
+ interface_combo = NULL;
+ capture_combo = NULL;
+ crc_check = NULL;
+ wrong_crc_combo = NULL;
+
+ /* ... */
+ /* gray out the toolbar (if we came here from the toolbar advanced button)*/
+ if( *from_widget == AIRPCAP_ADVANCED_FROM_TOOLBAR)
+ gtk_widget_set_sensitive(toolbar,TRUE);
+
+ g_free(from_widget);
+ return;
+ }
+ else if(GTK_BUTTON(ok_bt)->in_button)
+ {
+
+ /* ??? - Ask if want to save configuration */
+
+ /* Save the configuration */
+ airpcap_add_keys_from_list(key_ls,airpcap_if_selected);
+ airpcap_save_selected_if_configuration(airpcap_if_selected);
+ /* Remove gtk timeout */
+ gtk_timeout_remove(airpcap_if_selected->tag);
+
+ /* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
+ 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);
+
+ 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)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),FALSE);
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
+ }
+
+ /* If interface active is airpcap, set sensitive TRUE for airpcap toolbar */
+ if( get_airpcap_if_by_name(airpcap_if_list,airpcap_if_active->description) != NULL)
+ {
+ airpcap_set_toolbar_start_capture(airpcap_if_active);
+ }
+ else
+ {
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+ }
+
+ /* NULL to everything */
+ main_w = NULL;
+ blink_bt = NULL;
+ channel_combo = NULL;
+ interface_combo = NULL;
+ capture_combo = NULL;
+ crc_check = NULL;
+ wrong_crc_combo = NULL;
+
+ /* ... */
+ /* gray out the toolbar (if we came here from the toolbar advanced button)*/
+ if( *from_widget == AIRPCAP_ADVANCED_FROM_OPTIONS)
+ gtk_widget_set_sensitive(toolbar,FALSE);
+
+ g_free(from_widget);
+ return;
+ }
+
+ /* reload the configuration!!! Configuration has not been saved but
+ the corresponding structure has been modified probably...*/
+ if(!airpcap_if_selected->saved)
+ {
+ airpcap_load_selected_if_configuration(airpcap_if_selected);
+ }
+}
+
+/*
+ * Callback for the 'Apply' button.
+ */
+static void
+airpcap_advanced_apply_cb(GtkWidget *button, gpointer data _U_)
+{
+ /* advenced window */
+ GtkWidget *main_w;
+
+ /* widgets in the toolbar */
+ GtkWidget *toolbar,
+ *toolbar_if_lb,
+ *toolbar_channel_cm,
+ *toolbar_wrong_crc_cm,
+ *toolbar_decryption_ck;
+
+ GtkWidget *key_ls;
+
+ /* retrieve main window */
+ main_w = GTK_WIDGET(data);
+ key_ls = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_KEYLIST_KEY));
+
+ toolbar = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_TOOLBAR_KEY));
+
+ /* retrieve toolbar info */
+ toolbar_if_lb = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_INTERFACE_KEY));
+ toolbar_channel_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_CHANNEL_KEY));
+ toolbar_wrong_crc_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_WRONG_CRC_KEY));
+ toolbar_decryption_ck = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_DECRYPTION_KEY));
+
+ /* Save the configuration */
+ airpcap_add_keys_from_list(key_ls,airpcap_if_selected);
+ airpcap_save_selected_if_configuration(airpcap_if_selected);
+
+ /* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
+ 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);
+
+ 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)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),FALSE);
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
+ }
+}
+
+/*
+ * Callback for the 'Ok' button.
+ */
+static void
+airpcap_advanced_ok_cb(GtkWidget *w, gpointer data _U_)
+{
+ /* advenced window */
+ GtkWidget *main_w;
+
+ /* widgets in the toolbar */
+ GtkWidget *toolbar,
+ *toolbar_if_lb,
+ *toolbar_channel_cm,
+ *toolbar_wrong_crc_cm,
+ *toolbar_decryption_ck;
+
+ GtkWidget *key_ls;
+
+ /* retrieve main window */
+ main_w = GTK_WIDGET(data);
+
+ toolbar = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_TOOLBAR_KEY));
+
+ key_ls = GTK_WIDGET(OBJECT_GET_DATA(main_w,AIRPCAP_ADVANCED_KEYLIST_KEY));
+
+ /* retrieve toolbar info */
+ toolbar_if_lb = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_INTERFACE_KEY));
+ toolbar_channel_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_CHANNEL_KEY));
+ toolbar_wrong_crc_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_WRONG_CRC_KEY));
+ toolbar_decryption_ck = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_DECRYPTION_KEY));
+
+ /* Save the configuration */
+ airpcap_add_keys_from_list(key_ls,airpcap_if_selected);
+ airpcap_save_selected_if_configuration(airpcap_if_selected);
+ /* Remove gtk timeout */
+ gtk_timeout_remove(airpcap_if_selected->tag);
+
+ /* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
+ 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);
+
+ 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)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar_decryption_ck),FALSE);
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT(toolbar_decryption_ck),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), toolbar);
+ }
+}
+
+/*
+ * Callback for the 'Reset Configuration' button.
+ */
+static void
+airpcap_advanced_reset_configuration_cb(GtkWidget *button, gpointer data _U_)
+{
+
+}
+
+/*
+ * Callback for the 'About' button.
+ */
+static void
+airpcap_advanced_about_cb(GtkWidget *button, gpointer data _U_)
+{
+ /* retrieve toolbar info */
+}
+
+/*
+ * Callback used to add a WEP key in the add new key box;
+ */
+static void
+add_key(GtkWidget *widget, gpointer data _U_)
+{
+GtkWidget *text,
+ *key_ls,
+ *ok_bt;
+
+GString *new_key;
+
+gchar *text_entered = NULL;
+
+int keys_in_list = 0;
+unsigned int i;
+
+text = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_ADD_KEY_TEXT_KEY);
+ok_bt = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_ADD_KEY_OK_KEY);
+key_ls = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_KEYLIST_KEY);
+
+keys_in_list = g_list_length(GTK_LIST(key_ls)->children);
+text_entered = g_strdup(gtk_entry_get_text(GTK_ENTRY(text)));
+
+/* Too many keys? */
+if(keys_in_list == MAX_ENCRYPTION_KEYS)
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","Reached the Wep Keys Limit for this Interface.");
+ return;
+ }
+
+/* Check if key is correct */
+new_key = g_string_new(text_entered);
+
+g_strchug(new_key->str);
+g_strchomp(new_key->str);
+
+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.");
+ return;
+ }
+
+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.");
+ return;
+ }
+ }
+
+/* If so... Add key */
+airpcap_add_key_to_list(key_ls,new_key->str);
+
+airpcap_if_selected->saved = FALSE;
+
+g_string_free(new_key,TRUE);
+g_free(text_entered);
+
+window_destroy(GTK_WIDGET(data));
+return;
+}
+
+/*
+ * Callback used to add a WEP key in the edit key box;
+ */
+static void
+edit_key(GtkWidget *widget, gpointer data _U_)
+{
+GtkWidget *text,
+ *key_ls,
+ *ok_bt;
+
+GString *new_key;
+
+gchar *text_entered = NULL;
+
+GtkWidget *label;
+
+
+int keys_in_list = 0;
+unsigned int i;
+
+text = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_EDIT_KEY_TEXT_KEY);
+ok_bt = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_EDIT_KEY_OK_KEY);
+key_ls = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_KEYLIST_KEY);
+label = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_EDIT_KEY_LABEL_KEY);
+
+keys_in_list = g_list_length(GTK_LIST(key_ls)->children);
+text_entered = g_strdup(gtk_entry_get_text(GTK_ENTRY(text)));
+
+/* Check if key is correct */
+new_key = g_string_new(text_entered);
+
+g_strchug(new_key->str);
+g_strchomp(new_key->str);
+
+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.");
+ return;
+ }
+
+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.");
+ return;
+ }
+ }
+
+/* If so... modify key */
+gtk_label_set_text(GTK_LABEL(label),new_key->str);
+
+airpcap_if_selected->saved = FALSE;
+
+g_string_free(new_key,TRUE);
+g_free(text_entered);
+
+window_destroy(GTK_WIDGET(data));
+return;
+}
+
+/*
+ * Callback for the 'Add Key' button.
+ */
+static void
+airpcap_advanced_add_key_cb(GtkWidget *button, gpointer data _U_)
+{
+/* Window */
+GtkWidget *add_key_w;
+
+/* Frame */
+GtkWidget *add_key_frame;
+
+/* Boxes */
+GtkWidget *main_box, /* vertical */
+ *key_box, /* orizontal */
+ *text_box, /* orizontal */
+ *button_box;/* orizontal (packed to end)*/
+
+/* Text Entry */
+GtkWidget *key_text_entry;
+
+/* Buttons */
+GtkWidget *key_ok_bt,
+ *key_cancel_bt;
+
+/* Key List Widget */
+GtkWidget *key_ls;
+
+ /* Pop-up a new window */
+ add_key_w = window_new (GTK_WINDOW_TOPLEVEL,"Add a WEP Key");
+
+ /* Connect events */
+ SIGNAL_CONNECT(add_key_w, "delete_event",window_delete_event_cb, add_key_w);
+ SIGNAL_CONNECT(add_key_w, "destroy",add_key_w_destroy_cb, add_key_w);
+
+ /* Sets the border width of the window. */
+ gtk_container_set_border_width (GTK_CONTAINER (add_key_w), 5);
+
+ /* Retrieve the key list widget pointer, and add it to the add_key_w */
+ key_ls = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_KEYLIST_KEY);
+ OBJECT_SET_DATA(GTK_WIDGET(add_key_w),AIRPCAP_ADVANCED_KEYLIST_KEY,key_ls);
+ OBJECT_SET_DATA(GTK_WIDGET(add_key_w),AIRPCAP_ADVANCED_KEY,data);
+
+ /* Create boxes */
+ main_box = gtk_vbox_new(FALSE,1);
+ key_box = gtk_hbox_new(FALSE,1);
+ button_box = gtk_hbox_new(FALSE,1);
+ text_box = gtk_hbox_new(TRUE,1);
+
+ /* Add the two sub boxes to the main box */
+ gtk_box_pack_start(GTK_BOX(main_box), key_box, FALSE, FALSE, 1);
+ gtk_box_pack_start(GTK_BOX(main_box), button_box, FALSE, FALSE, 1);
+
+ /* Add the main box to the main window */
+ gtk_container_add(GTK_CONTAINER(add_key_w),main_box);
+
+ /* Crete key frame */
+ add_key_frame = gtk_frame_new("");
+ gtk_frame_set_label(GTK_FRAME(add_key_frame),"Key");
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(add_key_frame),
+ 200,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(add_key_frame),
+ 200,
+ -1 );
+ #endif
+
+ gtk_box_pack_start(GTK_BOX(key_box), add_key_frame, FALSE, FALSE, 1);
+
+ /* Create and Add text entry*/
+ key_text_entry = gtk_entry_new();
+ OBJECT_SET_DATA(add_key_w, AIRPCAP_ADVANCED_ADD_KEY_TEXT_KEY, key_text_entry);
+ SIGNAL_CONNECT(key_text_entry, "activate", add_key, add_key_w );
+ gtk_box_pack_start(GTK_BOX(text_box), key_text_entry, FALSE, FALSE, 1);
+ gtk_container_add(GTK_CONTAINER(add_key_frame),text_box);
+ gtk_container_set_border_width (GTK_CONTAINER (text_box), 5);
+
+ /* Create and add buttons */
+ key_ok_bt = gtk_button_new_with_label("OK");
+ SIGNAL_CONNECT(key_ok_bt, "clicked", add_key, add_key_w );
+ OBJECT_SET_DATA(add_key_w, AIRPCAP_ADVANCED_ADD_KEY_OK_KEY, key_ok_bt);
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(key_ok_bt),
+ 50,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(key_ok_bt),
+ 50,
+ -1 );
+ #endif
+ key_cancel_bt = gtk_button_new_with_label("Cancel");
+ SIGNAL_CONNECT(key_cancel_bt, "clicked", window_cancel_button_cb, add_key_w );
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(key_cancel_bt),
+ 50,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(key_cancel_bt),
+ 50,
+ -1 );
+ #endif
+
+ gtk_box_pack_end(GTK_BOX(button_box), key_cancel_bt, FALSE, FALSE, 1);
+ gtk_box_pack_end(GTK_BOX(button_box), key_ok_bt, FALSE, FALSE, 1);
+
+ /* Show all */
+ gtk_widget_show(key_ok_bt);
+ gtk_widget_show(key_cancel_bt);
+ gtk_widget_show(key_text_entry);
+ gtk_widget_show(add_key_frame);
+ gtk_widget_show(text_box);
+ gtk_widget_show(button_box);
+ gtk_widget_show(key_box);
+ gtk_widget_show(main_box);
+ gtk_widget_show(add_key_w);
+}
+
+/*
+ * Add key window destroy callback
+ */
+static void
+add_key_w_destroy_cb(GtkWidget *button, gpointer data _U_)
+{
+return;
+}
+
+/*
+ * Edit key window destroy callback
+ */
+static void
+edit_key_w_destroy_cb(GtkWidget *button, gpointer data _U_)
+{
+return;
+}
+
+/*
+ * Callback for the 'Remove Key' button.
+ */
+static void
+airpcap_advanced_remove_key_cb(GtkWidget *button, gpointer data _U_)
+{
+GtkList *key_ls;
+GtkWidget *label;
+GList *item = NULL;
+gint n;
+
+/* retrieve key list */
+key_ls = GTK_LIST(data);
+
+/* Remove selected keys*/
+if(key_ls->selection != NULL)
+ {
+ item = g_list_nth(key_ls->selection,0);
+ if(item != NULL)
+ {
+ n = gtk_list_child_position(key_ls,item->data);
+ label = GTK_BIN(item->data)->child;
+ gtk_list_clear_items(key_ls,n,n+1);
+ }
+ }
+
+/* Need to save config... */
+airpcap_if_selected->saved = FALSE;
+}
+
+/*
+ * Callback for the 'Edit Key' button.
+ */
+static void
+airpcap_advanced_edit_key_cb(GtkWidget *button, gpointer data _U_)
+{
+/* Window */
+GtkWidget *edit_key_w;
+
+/* Frame */
+GtkWidget *edit_key_frame;
+
+/* Boxes */
+GtkWidget *main_box, /* vertical */
+ *key_box, /* orizontal */
+ *text_box, /* orizontal */
+ *button_box;/* orizontal (packed to end)*/
+
+/* Text Entry */
+GtkWidget *key_text_entry;
+
+/* Buttons */
+GtkWidget *key_ok_bt,
+ *key_cancel_bt;
+
+/* Key List Widget */
+GtkWidget *key_ls;
+
+GtkWidget *label;
+GList *item = NULL;
+gint n;
+
+/* Retrieve the key list widget pointer, and add it to the edit_key_w */
+key_ls = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_KEYLIST_KEY);
+
+/*
+ * Check if a key has been selected. If not, just do nothing.
+ */
+if(GTK_LIST(key_ls)->selection != NULL)
+ {
+ item = g_list_nth(GTK_LIST(key_ls)->selection,0);
+ if(item != NULL)
+ {
+ /* Pop-up a new window */
+ edit_key_w = window_new (GTK_WINDOW_TOPLEVEL,"Edit a WEP Key");
+
+ /* Connect events */
+ SIGNAL_CONNECT(edit_key_w, "delete_event",window_delete_event_cb, edit_key_w);
+ SIGNAL_CONNECT(edit_key_w, "destroy",edit_key_w_destroy_cb, edit_key_w);
+
+ /* Sets the border width of the window. */
+ gtk_container_set_border_width (GTK_CONTAINER (edit_key_w), 5);
+
+ OBJECT_SET_DATA(GTK_WIDGET(edit_key_w),AIRPCAP_ADVANCED_KEYLIST_KEY,key_ls);
+ OBJECT_SET_DATA(GTK_WIDGET(edit_key_w),AIRPCAP_ADVANCED_KEY,data);
+
+ /* Create boxes */
+ main_box = gtk_vbox_new(FALSE,1);
+ key_box = gtk_hbox_new(FALSE,1);
+ button_box = gtk_hbox_new(FALSE,1);
+ text_box = gtk_hbox_new(TRUE,1);
+
+ /* Add the two sub boxes to the main box */
+ gtk_box_pack_start(GTK_BOX(main_box), key_box, FALSE, FALSE, 1);
+ gtk_box_pack_start(GTK_BOX(main_box), button_box, FALSE, FALSE, 1);
+
+ /* Add the main box to the main window */
+ gtk_container_add(GTK_CONTAINER(edit_key_w),main_box);
+
+ /* Crete key frame */
+ edit_key_frame = gtk_frame_new("");
+ gtk_frame_set_label(GTK_FRAME(edit_key_frame),"Key");
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(edit_key_frame),
+ 200,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(edit_key_frame),
+ 200,
+ -1 );
+ #endif
+
+ gtk_box_pack_start(GTK_BOX(key_box), edit_key_frame, FALSE, FALSE, 1);
+
+ /* Create and Add text entry*/
+ key_text_entry = gtk_entry_new();
+ /* Retrieve the currently selected entry */
+ if(GTK_LIST(key_ls)->selection != NULL)
+ {
+ item = g_list_nth(GTK_LIST(key_ls)->selection,0);
+ if(item != NULL)
+ {
+ n = gtk_list_child_position(GTK_LIST(key_ls),item->data);
+ label = GTK_BIN(item->data)->child;
+ /* Pass the pointer as data */
+ OBJECT_SET_DATA(edit_key_w,AIRPCAP_ADVANCED_EDIT_KEY_LABEL_KEY,label);
+ }
+ }
+ gtk_entry_set_text(GTK_ENTRY(key_text_entry),GTK_LABEL(label)->label);
+ OBJECT_SET_DATA(edit_key_w, AIRPCAP_ADVANCED_EDIT_KEY_TEXT_KEY, key_text_entry);
+ SIGNAL_CONNECT(key_text_entry, "activate", edit_key, edit_key_w );
+ gtk_box_pack_start(GTK_BOX(text_box), key_text_entry, FALSE, FALSE, 1);
+ gtk_container_add(GTK_CONTAINER(edit_key_frame),text_box);
+ gtk_container_set_border_width (GTK_CONTAINER (text_box), 5);
+
+ /* Create and add buttons */
+ key_ok_bt = gtk_button_new_with_label("OK");
+ SIGNAL_CONNECT(key_ok_bt, "clicked", edit_key, edit_key_w );
+ OBJECT_SET_DATA(edit_key_w, AIRPCAP_ADVANCED_EDIT_KEY_OK_KEY, key_ok_bt);
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(key_ok_bt),
+ 50,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(key_ok_bt),
+ 50,
+ -1 );
+ #endif
+ key_cancel_bt = gtk_button_new_with_label("Cancel");
+ SIGNAL_CONNECT(key_cancel_bt, "clicked", window_cancel_button_cb, edit_key_w );
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(key_cancel_bt),
+ 50,
+ -1 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(key_cancel_bt),
+ 50,
+ -1 );
+ #endif
+
+ gtk_box_pack_end(GTK_BOX(button_box), key_cancel_bt, FALSE, FALSE, 1);
+ gtk_box_pack_end(GTK_BOX(button_box), key_ok_bt, FALSE, FALSE, 1);
+
+ /* Show all */
+ gtk_widget_show(key_ok_bt);
+ gtk_widget_show(key_cancel_bt);
+ gtk_widget_show(key_text_entry);
+ gtk_widget_show(edit_key_frame);
+ gtk_widget_show(text_box);
+ gtk_widget_show(button_box);
+ gtk_widget_show(key_box);
+ gtk_widget_show(main_box);
+ gtk_widget_show(edit_key_w);
+ }
+ }
+}
+
+/*
+ * Callback for the 'Move Key Up' button.
+ */
+static void
+airpcap_advanced_move_key_up_cb(GtkWidget *button, gpointer data _U_)
+{
+GtkList *key_ls;
+GtkWidget *label,*nl_lb,*nl_item;
+GList *new_list = NULL;
+GList *item = NULL;
+gint n;
+
+/* retrieve key list */
+key_ls = GTK_LIST(data);
+
+/* Remove selected keys*/
+if(key_ls->selection != NULL)
+ {
+ item = g_list_nth(key_ls->selection,0);
+ if(item != NULL)
+ {
+ n = gtk_list_child_position(key_ls,item->data);
+ if(n>0)
+ {
+ label = GTK_BIN(item->data)->child;
+ nl_lb = gtk_label_new(GTK_LABEL(label)->label);
+ gtk_list_clear_items(key_ls,n,n+1);
+ 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);
+ gtk_widget_show(nl_lb);
+ gtk_widget_show(nl_item);
+ new_list = g_list_append(new_list,nl_item);
+ gtk_list_insert_items(key_ls,new_list,n-1);
+ gtk_list_select_item(key_ls,n-1);
+ }
+ }
+ }
+
+/* Need to save config... */
+airpcap_if_selected->saved = FALSE;
+}
+
+/*
+ * Callback for the 'Move Key Down' button.
+ */
+static void
+airpcap_advanced_move_key_down_cb(GtkWidget *button, gpointer data _U_)
+{
+GtkList *key_ls;
+GtkWidget *label,*nl_lb,*nl_item;
+GList *new_list = NULL;
+GList *item = NULL;
+unsigned int n;
+
+/* retrieve key list */
+key_ls = GTK_LIST(data);
+
+/* Remove selected keys*/
+if(key_ls->selection != NULL)
+ {
+ item = g_list_nth(key_ls->selection,0);
+ if(item != NULL)
+ {
+ n = gtk_list_child_position(key_ls,item->data);
+ if(n< (g_list_length(key_ls->children)-1))
+ {
+ label = GTK_BIN(item->data)->child;
+ nl_lb = gtk_label_new(GTK_LABEL(label)->label);
+ gtk_list_clear_items(key_ls,n,n+1);
+
+ 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);
+ gtk_widget_show(nl_lb);
+ gtk_widget_show(nl_item);
+
+ new_list = g_list_append(new_list,nl_item);
+ gtk_list_insert_items(key_ls,new_list,n+1);
+ gtk_list_select_item(key_ls,n+1);
+ }
+ }
+ }
+
+/* Need to save config... */
+airpcap_if_selected->saved = FALSE;
+}
+
+/* Turns the decryption on or off */
+static void
+encryption_check_cb(GtkWidget *w, gpointer data)
+{
+if( !block_advanced_signals && (airpcap_if_selected != NULL))
+ {
+ if(airpcap_if_selected->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ {
+ airpcap_if_selected->DecryptionOn = AIRPCAP_DECRYPTION_OFF;
+ airpcap_if_selected->saved = FALSE;
+ }
+ else
+ {
+ airpcap_if_selected->DecryptionOn = AIRPCAP_DECRYPTION_ON;
+ airpcap_if_selected->saved = FALSE;
+ }
+ }
+}
+
+
+/* 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;
+ /* Combos */
+ GtkWidget *interface_combo,
+ *capture_combo;
+
+ /* check */
+ GtkWidget *wrong_crc_combo;
+
+ /* key list*/
+ GtkWidget *key_ls;
+
+ /* frames */
+ GtkWidget *interface_frame,
+ *basic_frame,
+ *wep_frame;
+ /* boxes */
+ GtkWidget *main_box,
+ *buttons_box_1,
+ *buttons_box_2,
+ *interface_box,
+ *basic_box,
+ *basic_combo_box,
+ *basic_check_box,
+ *basic_label_box,
+ *basic_wrong_box,
+ *wep_box,
+ *wep_sub_box,
+ *encryption_box,
+ *wep_buttons_box;
+ /* buttons */
+ /* blink button is global */
+ GtkWidget *add_new_key_bt,
+ *remove_key_bt,
+ *edit_key_bt,
+ *move_key_up_bt,
+ *move_key_down_bt,
+ *reset_configuration_bt,
+ *about_bt,
+ *apply_bt,
+ *ok_bt,
+ *cancel_bt;
+ /* combo */
+
+ /* shortcut to combo entry */
+ GtkWidget *link_type_te,
+ *wrong_crc_te,
+ *channel_te;
+ /* check */
+ /* global check buttons */
+ GtkWidget *crc_check,
+ *encryption_check;
+ /* label */
+ GtkWidget *channel_lb,
+ *wrong_lb,
+ *capture_lb;
+ /* text field */
+ GtkWidget *key_text;
+
+ /* widgets in the toolbar */
+ GtkWidget *toolbar,
+ *toolbar_if_lb,
+ *toolbar_channel_cm,
+ *toolbar_wrong_crc_cm;
+
+ /* other stuff */
+ GList *channel_list,*capture_list;
+ GList *linktype_list = NULL;
+ gchar *channel_s,*capture_s;
+
+
+ /* user data - RETRIEVE pointers of toolbar widgets */
+ toolbar = GTK_WIDGET(data);
+ toolbar_if_lb = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_INTERFACE_KEY));
+ toolbar_channel_cm = GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_CHANNEL_KEY));
+ toolbar_wrong_crc_cm= GTK_WIDGET(OBJECT_GET_DATA(toolbar,AIRPCAP_TOOLBAR_WRONG_CRC_KEY));
+
+ /* gray out the toolbar */
+ gtk_widget_set_sensitive(toolbar,FALSE);
+
+ /* main window */
+ /* global */
+
+ /* NULL to global widgets */
+ blink_bt = NULL;
+ channel_combo = NULL;
+ block_advanced_signals = FALSE;
+
+ /* the selected is the active, for now */
+ airpcap_if_selected = airpcap_if_active;
+
+ /* Create the new window */
+ airpcap_advanced_w = window_new(GTK_WINDOW_TOPLEVEL, "Advanced Wireless Settings");
+
+ /*
+ * I will need the toolbar and the main widget in some callback,
+ * so I will add the toolbar pointer to the airpcap_advanced_w
+ */
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_TOOLBAR_KEY,toolbar);
+
+ /* Connect the callbacks */
+ SIGNAL_CONNECT(airpcap_advanced_w, "delete_event", window_delete_event_cb, airpcap_advanced_w);
+ SIGNAL_CONNECT(airpcap_advanced_w, "destroy", airpcap_if_destroy_cb, airpcap_advanced_w);
+
+ /* Set the size */
+ /* Sets the border width of the window. */
+ gtk_container_set_border_width (GTK_CONTAINER (airpcap_advanced_w), 10);
+
+ /* Create the main box */
+ main_box = gtk_vbox_new(FALSE,0);
+
+ /* Create the button boxes */
+ buttons_box_1 = gtk_hbox_new(FALSE,0);
+ buttons_box_2 = gtk_hbox_new(FALSE,0);
+
+ /* Create the buttons for box 1 */
+ reset_configuration_bt = gtk_button_new_with_label("Reset Configuration");
+ SIGNAL_CONNECT(reset_configuration_bt, "clicked", airpcap_advanced_reset_configuration_cb, toolbar);
+ gtk_widget_show(reset_configuration_bt);
+
+ about_bt = gtk_button_new_with_label("About");
+ SIGNAL_CONNECT(about_bt, "clicked", airpcap_advanced_about_cb, toolbar);
+ gtk_widget_show(about_bt);
+
+ /* Add them to box 1 */
+ gtk_box_pack_start (GTK_BOX (buttons_box_1), reset_configuration_bt, FALSE, FALSE, 1);
+ gtk_box_pack_start (GTK_BOX (buttons_box_1), about_bt, FALSE, FALSE, 1);
+
+ /* Create the buttons for box 2 */
+ apply_bt = gtk_button_new_with_label("Apply");
+ SIGNAL_CONNECT(apply_bt, "clicked", airpcap_advanced_apply_cb, airpcap_advanced_w);
+ gtk_widget_show(apply_bt);
+
+ ok_bt = gtk_button_new_with_label("Ok");
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_OK_KEY,ok_bt);
+ window_set_cancel_button(airpcap_advanced_w, ok_bt, window_cancel_button_cb);
+ gtk_widget_show(ok_bt);
+
+ cancel_bt = gtk_button_new_with_label("Cancel");
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_CANCEL_KEY,cancel_bt);
+ window_set_cancel_button(airpcap_advanced_w, cancel_bt, window_cancel_button_cb);
+ gtk_widget_show(cancel_bt);
+
+ /* Add them to box 2 */
+ gtk_box_pack_end (GTK_BOX (buttons_box_2), cancel_bt, FALSE, FALSE, 1);
+ gtk_box_pack_end (GTK_BOX (buttons_box_2), apply_bt, FALSE, FALSE, 1);
+ gtk_box_pack_end (GTK_BOX (buttons_box_2), ok_bt, FALSE, FALSE, 1);
+
+ /* Create the three main frames */
+ interface_frame = gtk_frame_new("");
+ gtk_frame_set_label(GTK_FRAME(interface_frame),"Interface");
+
+ basic_frame = gtk_frame_new("");
+ gtk_frame_set_label(GTK_FRAME(basic_frame),"Basic Parameters");
+
+ wep_frame = gtk_frame_new("");
+ gtk_frame_set_label(GTK_FRAME(wep_frame),"WEP Keys");
+
+ /* Create the three sub boxes */
+ interface_box = gtk_hbox_new(FALSE,0);
+ basic_box = gtk_hbox_new(FALSE,0);
+ wep_box = gtk_vbox_new(FALSE,0);
+
+ /* Fill the interface_box */
+ if(airpcap_if_active != NULL)
+ {
+ interface_combo = gtk_label_new(airpcap_if_active->description);
+ }
+ else
+ {
+ interface_combo = gtk_label_new("No airpcap interface found!");
+ gtk_widget_set_sensitive(main_box,FALSE);
+ }
+
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_INTERFACE_KEY,interface_combo);
+ gtk_box_pack_start (GTK_BOX (interface_box), interface_combo, TRUE, TRUE, 0);
+ gtk_widget_show(interface_combo);
+
+ /* blink led button (BEFORE interface_combo, 'cause its callback will need blink_bt)*/
+ blink_bt = gtk_button_new_with_label(" Blink Led ");
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_BLINK_KEY,blink_bt);
+ gtk_box_pack_end (GTK_BOX (interface_box), blink_bt, FALSE, FALSE, 0);
+ SIGNAL_CONNECT(blink_bt, "clicked", blink_cb, NULL);
+ gtk_widget_show(blink_bt);
+
+ gtk_container_set_border_width (GTK_CONTAINER (interface_box), 10);
+
+ /* Fill the basic_box */
+ /* Create the two vertical boxes for combo and check */
+ basic_combo_box = gtk_vbox_new(TRUE,0);
+ basic_check_box = gtk_vbox_new(TRUE,0);
+ basic_label_box = gtk_vbox_new(TRUE,0);
+
+ /* Create the Wrong CRC horiziontal box */
+ basic_wrong_box = gtk_hbox_new(FALSE,0);
+
+ /* Fill the label vbox */
+ channel_lb = gtk_label_new("Channel: ");
+ gtk_label_set_justify(GTK_LABEL(channel_lb),GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start (GTK_BOX (basic_label_box), channel_lb, TRUE, TRUE, 0);
+ gtk_widget_show(channel_lb);
+ capture_lb = gtk_label_new("Capture Type:");
+ gtk_label_set_justify(GTK_LABEL(capture_lb),GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start (GTK_BOX (basic_label_box), capture_lb, TRUE, TRUE, 0);
+ gtk_widget_show(capture_lb);
+
+ /* Create the two combo boxes */
+ channel_combo = gtk_combo_new();
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_CHANNEL_KEY,channel_combo);
+
+ channel_list = NULL;
+ channel_list = g_list_append(channel_list, "1");
+ channel_list = g_list_append(channel_list, "2");
+ channel_list = g_list_append(channel_list, "3");
+ channel_list = g_list_append(channel_list, "4");
+ channel_list = g_list_append(channel_list, "5");
+ channel_list = g_list_append(channel_list, "6");
+ channel_list = g_list_append(channel_list, "7");
+ channel_list = g_list_append(channel_list, "8");
+ channel_list = g_list_append(channel_list, "9");
+ channel_list = g_list_append(channel_list, "10");
+ channel_list = g_list_append(channel_list, "11");
+ channel_list = g_list_append(channel_list, "12");
+ channel_list = g_list_append(channel_list, "13");
+ channel_list = g_list_append(channel_list, "14");
+ gtk_combo_set_popdown_strings( GTK_COMBO(channel_combo), channel_list) ;
+
+ /* 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);
+ }
+
+ channel_te = GTK_COMBO(channel_combo)->entry;
+ gtk_editable_set_editable(GTK_EDITABLE(channel_te),FALSE);
+ SIGNAL_CONNECT(channel_te, "changed", channel_changed_cb, channel_te);
+ gtk_box_pack_start (GTK_BOX (basic_combo_box), channel_combo, FALSE, FALSE, 0);
+ gtk_widget_show(channel_combo);
+
+ capture_combo = gtk_combo_new();
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_LINK_TYPE_KEY,capture_combo);
+ capture_list = NULL;
+ capture_list = g_list_append(capture_list, AIRPCAP_LINK_TYPE_NAME_802_11_ONLY);
+ capture_list = g_list_append(capture_list, AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO);
+ gtk_combo_set_popdown_strings( GTK_COMBO(capture_combo), capture_list) ;
+
+ capture_s = NULL;
+ if(airpcap_if_selected != NULL)
+ {
+ if(airpcap_if_selected->linkType == AIRPCAP_LT_802_11)
+ capture_s = g_strdup_printf("%s",AIRPCAP_LINK_TYPE_NAME_802_11_ONLY);
+ else if(airpcap_if_selected->linkType == AIRPCAP_LT_802_11_PLUS_RADIO)
+ capture_s = g_strdup_printf("%s",AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO);
+ if(capture_s != NULL) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(capture_combo)->entry), capture_s);
+ }
+ g_free(capture_s);
+
+ link_type_te = GTK_COMBO(capture_combo)->entry;
+ gtk_editable_set_editable(GTK_EDITABLE(link_type_te),FALSE);
+ SIGNAL_CONNECT(link_type_te, "changed", link_type_changed_cb, link_type_te);
+ gtk_box_pack_start (GTK_BOX (basic_combo_box), capture_combo, FALSE, FALSE, 1);
+ gtk_widget_show(capture_combo);
+
+ /* Create the two check boxes */
+ crc_check = gtk_check_button_new_with_label("Include 802.11 FCS in Frames");
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_CRC_KEY,crc_check);
+
+ /* Fcs Presence check box */
+ if(airpcap_if_selected != NULL)
+ {
+ if(airpcap_if_selected->IsFcsPresent)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(crc_check),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(crc_check),FALSE);
+ }
+
+ SIGNAL_CONNECT(crc_check,"toggled",crc_check_cb,NULL);
+ gtk_box_pack_start (GTK_BOX (basic_check_box), crc_check, FALSE, FALSE, 0);
+ gtk_widget_show(crc_check);
+
+ /* CRC Filter label */
+ wrong_lb = gtk_label_new("FCS Filter:");
+ gtk_box_pack_start (GTK_BOX (basic_wrong_box), wrong_lb, FALSE, FALSE, 0);
+ gtk_widget_show(wrong_lb);
+
+ /* CRC Filter combo */
+ wrong_crc_combo = gtk_combo_new();
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_WRONG_CRC_KEY,wrong_crc_combo);
+
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_ALL);
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_CORRECT);
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT);
+
+ gtk_combo_set_popdown_strings( GTK_COMBO(wrong_crc_combo), linktype_list) ;
+
+ wrong_crc_te = GTK_COMBO(wrong_crc_combo)->entry;
+
+ if(airpcap_if_selected != NULL)
+ {
+ airpcap_validation_type_combo_set_by_type(wrong_crc_combo,airpcap_if_selected->CrcValidationOn);
+ }
+
+ gtk_editable_set_editable(GTK_EDITABLE(wrong_crc_te),FALSE);
+ SIGNAL_CONNECT(wrong_crc_te,"changed",wrong_crc_combo_cb,wrong_crc_te);
+ gtk_box_pack_start (GTK_BOX (basic_wrong_box), wrong_crc_combo, FALSE, FALSE, 0);
+ gtk_widget_show(wrong_crc_combo);
+
+ gtk_box_pack_start(GTK_BOX(basic_check_box), basic_wrong_box, FALSE, FALSE, 0);
+ gtk_widget_show(basic_wrong_box);
+
+ /* Add the vertical inner boxes to the basic_box */
+ gtk_box_pack_start (GTK_BOX (basic_box), basic_label_box, FALSE, FALSE, 10);
+ gtk_box_pack_start (GTK_BOX (basic_box), basic_combo_box, FALSE, FALSE, 10);
+ gtk_box_pack_start (GTK_BOX (basic_box), basic_check_box, FALSE, FALSE, 10);
+
+ gtk_container_set_border_width (GTK_CONTAINER (basic_box), 10);
+
+ /* Fill the wep_box */
+ wep_sub_box = gtk_hbox_new(FALSE,1);
+ gtk_widget_show(wep_sub_box);
+ encryption_box = gtk_hbox_new(FALSE,1);
+ gtk_widget_show(encryption_box);
+
+ /* 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);
+
+ /* Fcs Presence check box */
+ if(airpcap_if_selected != NULL)
+ {
+ if(airpcap_if_selected->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(encryption_check),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(encryption_check),FALSE);
+ }
+
+ SIGNAL_CONNECT(encryption_check,"toggled",encryption_check_cb,NULL);
+ gtk_box_pack_start (GTK_BOX (encryption_box), encryption_check, FALSE, FALSE, 0);
+ gtk_widget_show(encryption_check);
+
+ /* WEP text box */
+ key_text = scrolled_window_new(NULL, NULL);
+ /* never use a scrollbar in x direction, show the complete relation string */
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(key_text),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ #if GTK_MAJOR_VERSION >= 2
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(key_text),
+ GTK_SHADOW_IN);
+ #endif
+
+ /* add WEP keys if present... */
+ key_ls = gtk_list_new();
+ gtk_list_set_selection_mode(GTK_LIST(key_ls), GTK_SELECTION_SINGLE);
+ OBJECT_SET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_KEYLIST_KEY,key_ls);
+
+ airpcap_fill_key_list(key_ls,airpcap_if_selected);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(key_text),key_ls);
+ gtk_widget_show(key_ls);
+ gtk_box_pack_start (GTK_BOX (wep_sub_box), key_text, TRUE, TRUE, 0);
+ gtk_widget_show(key_text);
+
+ /* WEP buttons */
+ wep_buttons_box = gtk_vbox_new(FALSE,0);
+
+ /* Create and add buttons */
+ add_new_key_bt = gtk_button_new_with_label("Add New Key");
+ SIGNAL_CONNECT(add_new_key_bt, "clicked", airpcap_advanced_add_key_cb, airpcap_advanced_w);
+ gtk_box_pack_start (GTK_BOX (wep_buttons_box), add_new_key_bt, FALSE, FALSE, 0);
+ gtk_widget_show(add_new_key_bt);
+ remove_key_bt = gtk_button_new_with_label("Remove Key");
+ SIGNAL_CONNECT(remove_key_bt, "clicked", airpcap_advanced_remove_key_cb, key_ls);
+ gtk_box_pack_start (GTK_BOX (wep_buttons_box), remove_key_bt, FALSE, FALSE, 0);
+ gtk_widget_show(remove_key_bt);
+ edit_key_bt = gtk_button_new_with_label("Edit Key");
+ SIGNAL_CONNECT(edit_key_bt, "clicked", airpcap_advanced_edit_key_cb, airpcap_advanced_w);
+ gtk_box_pack_start (GTK_BOX (wep_buttons_box), edit_key_bt, FALSE, FALSE, 0);
+ gtk_widget_show(edit_key_bt);
+ move_key_up_bt = gtk_button_new_with_label("Move Key Up");
+ SIGNAL_CONNECT(move_key_up_bt, "clicked", airpcap_advanced_move_key_up_cb, key_ls);
+ gtk_box_pack_start (GTK_BOX (wep_buttons_box), move_key_up_bt, FALSE, FALSE, 0);
+ gtk_widget_show(move_key_up_bt);
+ move_key_down_bt = gtk_button_new_with_label("Move Key Down");
+ SIGNAL_CONNECT(move_key_down_bt, "clicked", airpcap_advanced_move_key_down_cb, key_ls);
+ gtk_box_pack_start (GTK_BOX (wep_buttons_box), move_key_down_bt, FALSE, FALSE, 0);
+ gtk_widget_show(move_key_down_bt);
+
+ gtk_box_pack_end (GTK_BOX (wep_sub_box), wep_buttons_box, FALSE, FALSE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (wep_sub_box), 10);
+
+ gtk_box_pack_start (GTK_BOX (wep_box), encryption_box, FALSE, FALSE,0);
+ gtk_box_pack_start (GTK_BOX (wep_box), wep_sub_box, FALSE, FALSE,0);
+ gtk_widget_show(wep_sub_box);
+
+ /* Add them to the frames */
+ gtk_container_add(GTK_CONTAINER(interface_frame),interface_box);
+ gtk_container_add(GTK_CONTAINER(basic_frame),basic_box);
+ gtk_container_add(GTK_CONTAINER(wep_frame),wep_box);
+
+ /* Add frames to the main box */
+ gtk_box_pack_start (GTK_BOX (main_box), interface_frame, FALSE, FALSE, 1);
+ gtk_box_pack_start (GTK_BOX (main_box), basic_frame, FALSE, FALSE, 1);
+ gtk_box_pack_start (GTK_BOX (main_box), wep_frame, FALSE, FALSE, 1);
+
+ /* Add buttons' boxes to the main box */
+ gtk_box_pack_start (GTK_BOX (main_box), buttons_box_2, FALSE, FALSE, 1);
+
+ /* Add the main box to the main window */
+ gtk_container_add(GTK_CONTAINER(airpcap_advanced_w),main_box);
+
+ /* SHOW EVERYTHING */
+ /* Show the WEP key buttons */
+ gtk_widget_show (wep_buttons_box);
+
+ /* Show the combo and check boxes */
+ gtk_widget_show (basic_label_box);
+ gtk_widget_show (basic_combo_box);
+ gtk_widget_show (basic_check_box);
+
+ /* Show the button boxes */
+ gtk_widget_show (buttons_box_1);
+ gtk_widget_show (buttons_box_2);
+
+ /* Show the frames */
+ gtk_widget_show (interface_frame);
+ gtk_widget_show (basic_frame);
+ gtk_widget_show (wep_frame);
+
+ /* Show the sub main boxes */
+ gtk_widget_show (interface_box);
+ gtk_widget_show (basic_box);
+ gtk_widget_show (wep_box);
+
+ /* Show the main box */
+ gtk_widget_show (main_box);
+
+ /* Show the window */
+ gtk_widget_show (airpcap_advanced_w);
+}
+
+#endif /* HAVE_AIRPCAP */
diff --git a/gtk/airpcap_dlg.h b/gtk/airpcap_dlg.h
new file mode 100644
index 0000000000..ea4a904481
--- /dev/null
+++ b/gtk/airpcap_dlg.h
@@ -0,0 +1,148 @@
+/* airpcap_dlg.h
+ * Declarations of routines for the "Airpcap" dialog
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __AIRPCAP_DLG_H__
+#define __AIRPCAP_DLG_H__
+
+#define AIRPCAP_ADVANCED_FROM_TOOLBAR 0
+#define AIRPCAP_ADVANCED_FROM_OPTIONS 1
+
+/*
+ * Takes the keys from the GtkList widget, and add them to the interface list
+ */
+void airpcap_add_keys_from_list(GtkWidget *w, airpcap_if_info_t *if_info);
+
+/*
+ * Pop-up window, used to ask the user if he wants to save the selected interface settings
+ * when closing the window.
+ */
+void
+airpcap_ask_for_save_before_closing(GtkWidget *w _U_, gpointer data);
+
+/* user confirmed the "Save settings..." dialog */
+void
+airpcap_dialog_save_before_closing_cb(gpointer dialog _U_, gint btn, gpointer data);
+
+/*
+ * Pop-up window, used to ask the user if he wants to save the selected interface settings
+ */
+void
+airpcap_ask_for_save(GtkWidget *entry _U_, gpointer data);
+
+/*
+ * Function used to change the selected interface and advanced dialog box
+ */
+void
+airpcap_change_if(GtkWidget *entry _U_, gpointer data);
+
+/*
+ * Fill the interface combo box specified
+ */
+void
+airpcap_fill_if_combo(GtkWidget *combo, GList* if_list);
+
+/*
+ * Add key window destroy callback
+ */
+static void
+add_key_w_destroy_cb(GtkWidget *button, gpointer data _U_);
+
+/*
+ * Changed callback for the channel combobox
+ */
+static void
+channel_changed_cb(GtkWidget *w _U_, gpointer data);
+
+/*
+ * Activate callback for the link layer combobox
+ */
+static void
+link_layer_activate_cb(GtkWidget *w _U_, gpointer data);
+
+/*
+ * Changed callback for the link layer combobox
+ */
+static void
+link_layer_changed_cb(GtkWidget *w _U_, gpointer data);
+
+/*
+ * Callback for the crc chackbox
+ */
+static void
+crc_check_cb(GtkWidget *w, gpointer user_data);
+
+/*
+ * Callback for the wrong crc chackbox
+ */
+static void
+wrong_crc_check_cb(GtkWidget *w, gpointer user_data);
+
+/*
+ * Callbackfunction for WEP key list
+ */
+static void
+key_sel_list_cb(GtkWidget *l, gpointer data _U_);
+
+/*
+ * Callback function for WEP key list
+ */
+static gint
+key_sel_list_button_cb(GtkWidget *widget, GdkEventButton *event,gpointer func_data);
+
+/*
+ * Activate callback for the adapter combobox
+ */
+static void
+combo_if_activate_cb(GtkWidget *w _U_, gpointer data);
+
+/*
+ * Changed callback for the adapter combobox
+ */
+static void
+airpcap_advanced_combo_if_changed_cb(GtkWidget *w _U_, gpointer data);
+
+/*
+ * Pop-up window that appears when user confirms the "Save settings..." dialog
+ */
+static void
+airpcap_dialog_save_cb(GtkWidget* dialog _U_, gint btn, gpointer data);
+
+/*
+ * Thread function used to blink the led
+ */
+void update_blink(gpointer data _U_);
+
+/*
+ * Blink button callback
+ */
+void blink_cb(GtkWidget *blink_bt _U_, gpointer if_data);
+
+/** Create a "Airpcap" dialog box caused by a button click.
+ *
+ * @param widget parent widget
+ * @param construct_args_ptr parameters to construct the dialog (construct_args_t)
+ */
+void display_airpcap_advanced_cb(GtkWidget *widget, gpointer construct_args_ptr);
+
+#endif
diff --git a/gtk/airpcap_gui_utils.c b/gtk/airpcap_gui_utils.c
new file mode 100755
index 0000000000..69a61bef44
--- /dev/null
+++ b/gtk/airpcap_gui_utils.c
@@ -0,0 +1,400 @@
+/* airpcap_gui_utils.c
+ *
+ * $Id$
+ *
+ * Ulf Lamping <ulf.lamping@web.de>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 2000 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_AIRPCAP
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <string.h>
+
+#include <epan/filesystem.h>
+
+#include "gtk/main.h"
+#include "dlg_utils.h"
+#include "gui_utils.h"
+#include "simple_dialog.h"
+#include "dfilter_expr_dlg.h"
+#include "compat_macros.h"
+#include "gtkglobals.h"
+#include "help_dlg.h"
+
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_gui_utils.h"
+
+#include "keys.h"
+
+/*
+ * Set up the airpcap toolbar for the new capture interface
+ */
+void
+airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info)
+{
+GtkWidget *airpcap_toolbar_crc_filter_combo;
+GtkWidget *airpcap_toolbar_label;
+GtkWidget *airpcap_toolbar_channel;
+GtkWidget *airpcap_toolbar_button;
+GtkWidget *airpcap_toolbar_decryption;
+
+gchar *if_label_text;
+
+airpcap_toolbar_crc_filter_combo = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_WRONG_CRC_KEY);
+airpcap_toolbar_label = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_INTERFACE_KEY);
+airpcap_toolbar_channel = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_CHANNEL_KEY);
+airpcap_toolbar_button = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_ADVANCED_KEY);
+airpcap_toolbar_decryption = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
+
+/* The current interface is an airpcap interface */
+if(if_info != NULL)
+ {
+ gtk_widget_set_sensitive(airpcap_tb,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_channel,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_crc_filter_combo,FALSE);
+ 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);
+
+ /*decription check box*/
+ gtk_signal_handler_block_by_func (GTK_OBJECT(airpcap_toolbar_decryption),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), airpcap_tb);
+ if(if_info->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),FALSE);
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT(airpcap_toolbar_decryption),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), airpcap_tb);
+
+ if_label_text = g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(if_info));
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),if_label_text);
+ g_free(if_label_text);
+ }
+else
+ {
+ if(airpcap_if_list != NULL)
+ {
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_crc_filter_combo)->entry),"");
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_channel)->entry),"");
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),"Not a valid Wireless Interface");
+ }
+ else
+ {
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_crc_filter_combo)->entry),"");
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_channel)->entry),"");
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),"No Wireless Interface Found");
+ }
+ }
+}
+
+/*
+ * Set up the airpcap toolbar for the new capture interface
+ */
+void
+airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info)
+{
+GtkWidget *airpcap_toolbar_crc_filter_combo;
+GtkWidget *airpcap_toolbar_label;
+GtkWidget *airpcap_toolbar_channel;
+GtkWidget *airpcap_toolbar_button;
+GtkWidget *airpcap_toolbar_decryption;
+
+gchar *if_label_text;
+
+airpcap_toolbar_crc_filter_combo = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_WRONG_CRC_KEY);
+airpcap_toolbar_label = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_INTERFACE_KEY);
+airpcap_toolbar_channel = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_CHANNEL_KEY);
+airpcap_toolbar_button = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_ADVANCED_KEY);
+airpcap_toolbar_decryption = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
+
+/* The current interface is an airpcap interface */
+if(if_info != NULL)
+ {
+ gtk_widget_set_sensitive(airpcap_tb,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_channel,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_button,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_crc_filter_combo,TRUE);
+ 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);
+
+ /*decription check box*/
+ gtk_signal_handler_block_by_func (GTK_OBJECT(airpcap_toolbar_decryption),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), airpcap_tb);
+ if(if_info->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),FALSE);
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT(airpcap_toolbar_decryption),GTK_SIGNAL_FUNC(airpcap_toolbar_encryption_cb), airpcap_tb);
+
+
+ if_label_text = g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(if_info));
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),if_label_text);
+ g_free(if_label_text);
+ }
+else
+ {
+ if(airpcap_if_list != NULL)
+ {
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_crc_filter_combo)->entry),"");
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_channel)->entry),"");
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),"Not a valid Wireless Interface");
+ }
+ else
+ {
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_crc_filter_combo)->entry),"");
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(airpcap_toolbar_channel)->entry),"");
+ gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),"No Wireless Interface Found");
+ }
+ }
+}
+
+/*
+ * Add a key (string) to the given list
+ */
+void
+airpcap_add_key_to_list(GtkWidget *keylist, gchar* s)
+{
+GtkWidget *nl_item,*nl_lb;
+
+nl_lb = gtk_label_new(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);
+gtk_widget_show(nl_lb);
+gtk_container_add(GTK_CONTAINER(keylist), nl_item);
+gtk_widget_show(nl_item);
+}
+
+/*
+ * Fill the list with the keys
+ */
+void
+airpcap_fill_key_list(GtkWidget *keylist,airpcap_if_info_t* if_info)
+{
+GtkWidget *nl_item,*nl_lb;
+gchar* s;
+unsigned int i;
+
+ if( (if_info != NULL) && (if_info->keysCollection != NULL))
+ {
+ for(i = 0; i < if_info->keysCollection->nKeys; i++)
+ {
+ s = airpcap_get_key_string(if_info->keysCollection->Keys[i]);
+ nl_lb = gtk_label_new(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);
+ gtk_widget_show(nl_lb);
+ gtk_container_add(GTK_CONTAINER(keylist), nl_item);
+ gtk_widget_show(nl_item);
+ }
+ }
+}
+
+/*
+ * Function used to retrieve the AirpcapValidationType given the string name.
+ */
+AirpcapValidationType
+airpcap_get_validation_type(const gchar* name)
+{
+ if(!(g_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_ALL,name)))
+ {
+ return AIRPCAP_VT_ACCEPT_EVERYTHING;
+ }
+ else if(!(g_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_CORRECT,name)))
+ {
+ return AIRPCAP_VT_ACCEPT_CORRECT_FRAMES;
+ }
+ else if(!(g_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT,name)))
+ {
+ return AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES;
+ }
+ else
+ {
+ return AIRPCAP_VT_UNKNOWN;
+ }
+}
+
+/*
+ * Function used to retrieve the string name given an AirpcapValidationType,
+ * or NULL in case of error
+ */
+gchar*
+airpcap_get_validation_name(AirpcapValidationType vt)
+{
+ if(vt == AIRPCAP_VT_ACCEPT_EVERYTHING)
+ {
+ return AIRPCAP_VALIDATION_TYPE_NAME_ALL;
+ }
+ else if(vt == AIRPCAP_VT_ACCEPT_CORRECT_FRAMES)
+ {
+ return AIRPCAP_VALIDATION_TYPE_NAME_CORRECT;
+ }
+ else if(vt == AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES)
+ {
+ return AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT;
+ }
+ else if(vt == AIRPCAP_VT_UNKNOWN)
+ {
+ return AIRPCAP_VALIDATION_TYPE_NAME_UNKNOWN;
+ }
+ return NULL;
+}
+
+/*
+ * Returns the AirpcapLinkType corresponding to the given string name.
+ */
+AirpcapLinkType
+airpcap_get_link_type(const gchar* name)
+{
+ if(!(g_strcasecmp(AIRPCAP_LINK_TYPE_NAME_802_11_ONLY,name)))
+ {
+ return AIRPCAP_LT_802_11;
+ }
+ else if(!(g_strcasecmp(AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO,name)))
+ {
+ return AIRPCAP_LT_802_11_PLUS_RADIO;
+ }
+ else
+ {
+ return AIRPCAP_LT_UNKNOWN;
+ }
+}
+
+/*
+ * Returns the string name corresponding to the given AirpcapLinkType, or
+ * NULL in case of error.
+ */
+gchar*
+airpcap_get_link_name(AirpcapLinkType lt)
+{
+ if(lt == AIRPCAP_LT_802_11)
+ {
+ return AIRPCAP_LINK_TYPE_NAME_802_11_ONLY;
+ }
+ else if(lt == AIRPCAP_LT_802_11_PLUS_RADIO)
+ {
+ return AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO;
+ }
+ else if(lt == AIRPCAP_LT_UNKNOWN)
+ {
+ return AIRPCAP_LINK_TYPE_NAME_UNKNOWN;
+ }
+ return NULL;
+}
+
+/*
+ * Sets the entry of the link type combo using the AirpcapLinkType.
+ */
+void
+airpcap_link_type_combo_set_by_type(GtkWidget* c, AirpcapLinkType type)
+{
+gchar* s;
+
+s = airpcap_get_link_name(type);
+gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(c)->entry),s);
+}
+
+/*
+ * Retrieves the name in link type the combo entry.
+ */
+AirpcapLinkType
+airpcap_link_type_combo_get_type(GtkWidget* c)
+{
+const gchar* s;
+
+s = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(c)->entry));
+
+return airpcap_get_link_type(s);
+}
+
+/*
+ * Sets the entry of the validation combo using the AirpcapValidationType.
+ */
+void
+airpcap_validation_type_combo_set_by_type(GtkWidget* c, AirpcapValidationType type)
+{
+const gchar* s;
+
+s = airpcap_get_validation_name(type);
+gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(c)->entry),s);
+}
+
+/*
+ * Retrieves the name in the validation combo entry.
+ */
+AirpcapValidationType
+airpcap_validation_type_combo_get_type(GtkWidget* c)
+{
+const gchar* s;
+
+s = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(c)->entry));
+
+return airpcap_get_validation_type(s);
+}
+
+/*
+ * Retrieve the UINT corresponding to the given string (channel only, handle with care!)
+ */
+UINT
+airpcap_get_channel_number(const gchar* s)
+{
+int ch_num;
+
+sscanf(s,"%d",&ch_num);
+
+/* XXX - check for ch_num btween 1-14, and return -1 otherwise??? */
+
+return ch_num;
+}
+
+/*
+ * Returns the string corresponding to the given UINT (1-14, for channel only)
+ */
+gchar*
+airpcap_get_channel_name(UINT n)
+{
+return g_strdup_printf("%d",n);
+}
+
+/*
+ * Set the combo box entry string given an UINT channel number
+ */
+void
+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));
+}
+
+#endif /* HAVE_AIRPCAP */
diff --git a/gtk/airpcap_gui_utils.h b/gtk/airpcap_gui_utils.h
new file mode 100755
index 0000000000..b69fa48f31
--- /dev/null
+++ b/gtk/airpcap_gui_utils.h
@@ -0,0 +1,127 @@
+/* airpcap_utils.h
+ * Declarations of utility routines for the "Airpcap" dialog widgets
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __AIRPCAP_GUI_UTILS_H__
+#define __AIRPCAP_GUI_UTILS_H__
+
+#define AIRPCAP_VALIDATION_TYPE_NAME_ALL "All Frames"
+#define AIRPCAP_VALIDATION_TYPE_NAME_CORRECT "Valid Frames"
+#define AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT "Invalid Frames"
+#define AIRPCAP_VALIDATION_TYPE_NAME_UNKNOWN "Unknown"
+
+#define AIRPCAP_LINK_TYPE_NAME_802_11_ONLY "802.11 Only"
+#define AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO "802.11 + Radio"
+#define AIRPCAP_LINK_TYPE_NAME_UNKNOWN "Unknown"
+
+/*
+ * set up the airpcap toolbar for the new capture interface
+ */
+void
+airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info);
+
+/*
+ * Set up the airpcap toolbar for the new capture interface
+ */
+void
+airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info);
+
+/*
+ * Add a key (string) to the given list
+ */
+void
+airpcap_add_key_to_list(GtkWidget *keylist, gchar* s);
+
+/*
+ * Fill the list with the keys
+ */
+void
+airpcap_fill_key_list(GtkWidget *keylist,airpcap_if_info_t* if_info);
+
+/*
+ * Function used to retrieve the AirpcapValidationType given the string name.
+ */
+AirpcapValidationType
+airpcap_get_validation_type(const gchar* name);
+
+/*
+ * Function used to retrieve the string name given an AirpcapValidationType.
+ */
+gchar*
+airpcap_get_validation_name(AirpcapValidationType vt);
+
+/*
+ * Returns the AirpcapLinkType corresponding to the given string name.
+ */
+AirpcapLinkType
+airpcap_get_link_type(const gchar* name);
+
+/*
+ * Returns the string name corresponding to the given AirpcapLinkType.
+ */
+gchar*
+airpcap_get_link_name(AirpcapLinkType lt);
+
+/*
+ * Sets the entry of the link type combo using the AirpcapLinkType.
+ */
+void
+airpcap_link_type_combo_set_by_type(GtkWidget* c, AirpcapLinkType type);
+
+/*
+ * Retrieves the name in link type the combo entry.
+ */
+AirpcapLinkType
+airpcap_link_type_combo_get_type(GtkWidget* c);
+
+/*
+ * Sets the entry of the validation combo using the AirpcapValidationType.
+ */
+void
+airpcap_validation_type_combo_set_by_type(GtkWidget* c,AirpcapValidationType type);
+
+/*
+ * Retrieves the name in the validation combo entry.
+ */
+AirpcapValidationType
+airpcap_validation_type_combo_get_type(GtkWidget* c);
+
+/*
+ * Returns the string corresponding to the given UINT (1-14, for channel only)
+ */
+UINT
+airpcap_get_channel_number(const gchar* s);
+
+/*
+ * Retrieve the UINT corresponding to the given string (channel only, handle with care!)
+ */
+gchar*
+airpcap_get_channel_name(UINT n);
+
+/*
+ * Set the combo box entry string given an UINT channel number
+ */
+void
+airpcap_channel_combo_set_by_number(GtkWidget* w,UINT channel);
+
+#endif
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index 1d4c35ce04..d940d2a854 100644
--- a/gtk/capture_dlg.c
+++ b/gtk/capture_dlg.c
@@ -61,6 +61,15 @@
#include "capture-wpcap.h"
#endif
+#include "keys.h"
+
+#ifdef HAVE_AIRPCAP
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_gui_utils.h"
+#include "airpcap_dlg.h"
+#endif
+
/* Capture callback data keys */
#define E_CAP_IFACE_KEY "cap_iface"
#define E_CAP_IFACE_IP_KEY "cap_iface_ip"
@@ -114,7 +123,6 @@
*/
static GtkWidget *cap_open_w;
-
static void
capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te);
@@ -138,6 +146,10 @@ capture_dlg_prep(gpointer parent_w);
void
capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
{
+#ifdef HAVE_AIRPCAP
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+#endif
+
capture_stop(capture_opts);
}
@@ -145,6 +157,10 @@ capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
void
capture_restart_cb(GtkWidget *w _U_, gpointer d _U_)
{
+#ifdef HAVE_AIRPCAP
+ airpcap_set_toolbar_start_capture(airpcap_if_active);
+#endif
+
capture_restart(capture_opts);
}
@@ -173,12 +189,31 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
int ips = 0;
GSList *curr_ip;
if_addr_t *ip_addr;
+#ifdef HAVE_AIRPCAP
+ GtkWidget *advanced_bt;
+#endif
lt_menu = gtk_menu_new();
entry_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
if_text = g_strstrip(entry_text);
if_name = get_if_name(if_text);
+#ifdef HAVE_AIRPCAP
+ /* is it an airpcap interface??? */
+ /* retrieve the advanced button pointer */
+ advanced_bt = OBJECT_GET_DATA(entry,AIRPCAP_OPTIONS_ADVANCED_KEY);
+ airpcap_if_selected = get_airpcap_if_by_name(airpcap_if_list,if_name);
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ if( airpcap_if_selected != NULL)
+ {
+ gtk_widget_set_sensitive(advanced_bt,TRUE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive(advanced_bt,FALSE);
+ }
+#endif
+
/*
* If the interface name is in the list of known interfaces, get
* its list of link-layer types and set the option menu to display it.
@@ -482,6 +517,24 @@ guint32 value)
}
}
+#ifdef HAVE_AIRPCAP
+/*
+ * Sets the toolbar before calling the advanced dialog with for the right interface
+ */
+void
+options_airpcap_advanced_cb(GtkWidget *w _U_, gpointer d _U_)
+{
+int *from_widget;
+
+from_widget = (gint*)g_malloc(sizeof(gint));
+*from_widget = AIRPCAP_ADVANCED_FROM_OPTIONS;
+OBJECT_SET_DATA(airpcap_tb,AIRPCAP_ADVANCED_FROM_KEY,from_widget);
+
+airpcap_if_active = airpcap_if_selected;
+gtk_widget_set_sensitive(airpcap_tb,FALSE);
+display_airpcap_advanced_cb(w,d);
+}
+#endif
/* show capture prepare (options) dialog */
void
@@ -497,6 +550,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
*snap_hb, *snap_cb, *snap_sb, *snap_lb,
*promisc_cb,
*filter_hb, *filter_bt, *filter_te, *filter_cm,
+ *advanced_hb,
*file_fr, *file_vb,
*file_hb, *file_bt, *file_lb, *file_te,
@@ -517,7 +571,8 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
*resolv_fr, *resolv_vb,
*m_resolv_cb, *n_resolv_cb, *t_resolv_cb,
*bbox, *ok_bt, *cancel_bt,
- *help_bt;
+ *help_bt,
+ *advanced_bt;
#if GTK_MAJOR_VERSION < 2
GtkAccelGroup *accel_group;
#endif
@@ -537,6 +592,8 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
gchar *cap_title;
gchar *if_device;
+ gint *from_widget = NULL;
+
if (cap_open_w != NULL) {
/* There's already a "Capture Options" dialog box; reactivate it. */
@@ -564,6 +621,22 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
g_free(cant_get_if_list_errstr);
}
+#ifdef HAVE_AIRPCAP
+ /* update airpcap interface list */
+ /* load the airpcap interfaces */
+ airpcap_if_list = get_airpcap_interface_list(&err, err_str);
+
+ if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
+ cant_get_if_list_errstr = cant_get_airpcap_if_list_error_message(err_str);
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
+ cant_get_if_list_errstr);
+ g_free(cant_get_if_list_errstr);
+ }
+
+ /* select the first ad default (THIS SHOULD BE CHANGED) */
+ airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
+#endif
+
/* use user-defined title if preference is set */
cap_title = create_user_window_title("Wireshark: Capture Options");
@@ -611,6 +684,13 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
capture_opts->iface = g_strdup(get_if_name(if_device));
g_free(if_device);
}
+
+#ifdef HAVE_AIRPCAP
+ /* get the airpcap interface (if it IS an airpcap interface, and update the
+ toolbar... and of course enable the advanced button...)*/
+ airpcap_if_selected = get_airpcap_if_by_name(airpcap_if_list,capture_opts->iface);
+#endif
+
if (capture_opts->iface != NULL) {
if_device = build_capture_combo_name(if_list, capture_opts->iface);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), if_device);
@@ -681,7 +761,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_sb, FALSE, FALSE, 0);
buffer_size_lb = gtk_label_new("megabyte(s)");
- gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(linktype_hb), buffer_size_lb, FALSE, FALSE, 6);
#endif
/* Promiscuous mode row */
@@ -767,6 +847,40 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
/* let an eventually capture filters dialog know the text entry to fill in */
OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_te);
+ /* advanced row */
+ 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();
+
+ /* set the text */
+ #if GTK_MAJOR_VERSION >= 2
+ /* XXX - find a way to set the GtkButton label in GTK 1.x */
+ gtk_button_set_label(GTK_BUTTON(advanced_bt), "Wireless Settings");
+ #else
+ /* Set the GtkButton label in GTK 1.x */
+ gtk_label_set_text(GTK_LABEL(GTK_BIN(advanced_bt)->child), "Wireless Settings");
+ #endif
+
+#ifdef HAVE_AIRPCAP
+ /* Both the callback and the data are global */
+ SIGNAL_CONNECT(advanced_bt,"clicked",options_airpcap_advanced_cb,airpcap_tb);
+ OBJECT_SET_DATA(GTK_ENTRY(GTK_COMBO(if_cb)->entry),AIRPCAP_OPTIONS_ADVANCED_KEY,advanced_bt);
+
+ if(airpcap_if_selected != NULL)
+ {
+ /* It is an airpcap interface */
+ gtk_widget_set_sensitive(advanced_bt,TRUE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive(advanced_bt,FALSE);
+ }
+#endif
+
+ gtk_box_pack_start(GTK_BOX(linktype_hb),advanced_bt,FALSE,FALSE,0);
+ gtk_widget_show(advanced_bt);
+ gtk_widget_show(advanced_hb);
+
/* Capture file-related options frame */
file_fr = gtk_frame_new("Capture File(s)");
gtk_container_add(GTK_CONTAINER(left_vb), file_fr);
@@ -1236,6 +1350,11 @@ capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
{
gpointer dialog;
+#ifdef HAVE_AIRPCAP
+ airpcap_if_active = airpcap_if_selected;
+ airpcap_set_toolbar_start_capture(airpcap_if_active);
+#endif
+
#ifdef _WIN32
/* Is WPcap loaded? */
if (!has_wpcap) {
@@ -1548,6 +1667,11 @@ capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
/* Note that we no longer have a "Capture Options" dialog box. */
cap_open_w = NULL;
+
+#ifdef HAVE_AIRPCAP
+ /* update airpcap toolbar */
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+#endif
}
/* user changed the interface entry */
@@ -1555,7 +1679,6 @@ static void
capture_prep_interface_changed_cb(GtkWidget *entry, gpointer argp)
{
GtkWidget *linktype_om = argp;
-
set_link_type_list(linktype_om, entry);
}
diff --git a/gtk/capture_dlg.h b/gtk/capture_dlg.h
index 3d20ff2993..caf536cea4 100644
--- a/gtk/capture_dlg.h
+++ b/gtk/capture_dlg.h
@@ -26,6 +26,8 @@
#ifndef __CAPTURE_DLG_H__
#define __CAPTURE_DLG_H__
+extern GtkWidget* airpcap_tb;
+
/** @file
* "Capture Options" dialog box.
* @ingroup dialog_group
@@ -70,6 +72,14 @@ void capture_start_confirmed(void);
void
capture_if_cb(GtkWidget *widget, gpointer data);
+/** User requested the "Capture Airpcap" dialog box by menu or toolbar.
+ *
+ * @param widget parent widget (unused)
+ * @param data unused
+ */
+void
+capture_air_cb(GtkWidget *widget, gpointer data);
+
/** User requested the "Capture Interfaces" dialog box by menu or toolbar.
*
* @param capture_in_progress capture is in progress
diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c
index 279b3bb8e5..e4ce712bb2 100644
--- a/gtk/capture_if_dlg.c
+++ b/gtk/capture_if_dlg.c
@@ -48,14 +48,37 @@
#include "capture_dlg.h"
#include "capture_if_details_dlg.h"
#include "capture_errs.h"
+#include "recent.h"
+#include <epan/prefs.h>
#include "gui_utils.h"
#include "dlg_utils.h"
-#include "wtap.h"
#include "main.h"
+#include "wtap.h"
#include "help_dlg.h"
#include "toolbar.h"
+#include "keys.h"
+
+#include "webbrowser.h"
+
+#ifdef HAVE_AIRPCAP
+#include "../image/toolbar/capture_airpcap_16.xpm"
+#endif
+#include "../image/toolbar/capture_ethernet_16.xpm"
+
+/* new buttons to be used instead of labels for 'Capture','Prepare',' */
+#include "../image/toolbar/capture_capture_16.xpm"
+#include "../image/toolbar/capture_prepare_16.xpm"
+#include "../image/toolbar/capture_details_16.xpm"
+
+
+#ifdef HAVE_AIRPCAP
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_gui_utils.h"
+#include "airpcap_dlg.h"
+#endif
/*
* Keep a static pointer to the current "Capture Interfaces" window, if
@@ -63,7 +86,7 @@
* already a "Capture Interfaces" window up, we just pop up the existing
* one, rather than creating a new one.
*/
-static GtkWidget *cap_if_w;
+static GtkWidget *cap_if_w, *cap_air_w;
GList *if_data = NULL;
@@ -103,7 +126,12 @@ void update_if(if_dlg_data_t *if_dlg_data);
static void
capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
{
- if_dlg_data_t *if_dlg_data = if_data;
+if_dlg_data_t *if_dlg_data = if_data;
+
+#ifdef HAVE_AIRPCAP
+airpcap_if_active = get_airpcap_if_from_description(airpcap_if_list, GTK_LABEL(if_dlg_data->descr_lb)->label);
+airpcap_if_selected = airpcap_if_active;
+#endif
if (capture_opts->iface)
g_free(capture_opts->iface);
@@ -219,7 +247,7 @@ update_if(if_dlg_data_t *if_dlg_data)
#else
diff = stats.ps_recv;
if_dlg_data->last_packets = stats.ps_recv + if_dlg_data->last_packets;
-#endif
+#endif
str = g_strdup_printf("%u", if_dlg_data->last_packets);
gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), str);
@@ -277,13 +305,13 @@ set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
if(cap_if_w) {
gtk_widget_set_sensitive(stop_bt, capture_in_progress);
-
+
for(ifs = 0; (curr = g_list_nth(if_data, ifs)); ifs++) {
if_dlg_data_t *if_dlg_data = curr->data;
gtk_widget_set_sensitive(if_dlg_data->capture_bt, !capture_in_progress);
gtk_widget_set_sensitive(if_dlg_data->prepare_bt, !capture_in_progress);
- }
+ }
}
}
@@ -310,14 +338,65 @@ capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
/* Note that we no longer have a "Capture Options" dialog box. */
cap_if_w = NULL;
+
+#ifdef HAVE_AIRPCAP
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+#endif
}
+GtkWidget*
+combo_channel_new(void)
+{
+ GtkWidget* channel_cb;
+ GList* popdown;
+
+
+ channel_cb = gtk_combo_new();
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cb)->entry), "1");
+
+ popdown = NULL;
+
+ popdown = g_list_append(popdown, "1");
+ popdown = g_list_append(popdown, "2");
+ popdown = g_list_append(popdown, "3");
+ popdown = g_list_append(popdown, "4");
+ popdown = g_list_append(popdown, "5");
+ popdown = g_list_append(popdown, "6");
+ popdown = g_list_append(popdown, "7");
+ popdown = g_list_append(popdown, "8");
+ popdown = g_list_append(popdown, "9");
+ popdown = g_list_append(popdown, "10");
+ popdown = g_list_append(popdown, "11");
+ popdown = g_list_append(popdown, "12");
+ popdown = g_list_append(popdown, "13");
+ popdown = g_list_append(popdown, "14");
+
+ gtk_combo_set_popdown_strings( GTK_COMBO(channel_cb), popdown) ;
+
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(channel_cb),
+ 45,
+ 10 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(channel_cb),
+ 45,
+ 10 );
+ #endif
+
+
+ return channel_cb;
+}
/* start getting capture stats from all interfaces */
void
capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
{
- GtkWidget *main_vb, *main_sw, *bbox, *close_bt, *help_bt;
+ GtkWidget *main_vb,
+ *main_sw,
+ *bbox,
+ *close_bt,
+ *help_bt,
+ *icon;
GtkWidget *if_tb;
GtkWidget *if_lb;
@@ -357,6 +436,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
}
#endif
+ /* LOAD THE INTERFACES */
if_list = get_interface_list(&err, err_str);
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
@@ -366,6 +446,37 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
return;
}
+#ifdef HAVE_AIRPCAP
+ /* LOAD AIRPCAP INTERFACES */
+ /* load the airpcap interfaces */
+ airpcap_if_list = get_airpcap_interface_list(&err, err_str);
+
+ if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
+ cant_get_if_list_errstr = cant_get_airpcap_if_list_error_message(err_str);
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
+ cant_get_if_list_errstr);
+ g_free(cant_get_if_list_errstr);
+ }
+
+ /* If no airpcap interface is present, gray everything */
+ if(airpcap_if_active == NULL)
+ {
+ if(airpcap_if_list == NULL)
+ {
+ /*No airpcap device found */
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ }
+ else
+ {
+ /* default adapter is not airpcap... or is airpcap but is not found*/
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ }
+ }
+
+ airpcap_set_toolbar_start_capture(airpcap_if_active);
+#endif
+
cap_if_w = window_new(GTK_WINDOW_TOPLEVEL, "Wireshark: Capture Interfaces");
tooltips = gtk_tooltips_new();
@@ -387,7 +498,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(main_sw), main_vb);
- if_tb = gtk_table_new(6,1, FALSE);
+ if_tb = gtk_table_new(1,9, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(if_tb), 3);
gtk_table_set_col_spacings(GTK_TABLE(if_tb), 3);
gtk_box_pack_start(GTK_BOX(main_vb), if_tb, FALSE, FALSE, 0);
@@ -395,6 +506,10 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
row = 0;
height = 0;
+ /* This is the icon column, used to display which kind of interface we have */
+ if_lb = gtk_label_new("");
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 0, 1, row, row+1);
+
#ifndef _WIN32
/*
* On Windows, device names are generally not meaningful - NT 5
@@ -402,28 +517,28 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
* bother showing them.
*/
if_lb = gtk_label_new("Device");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 0, 1, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 1, 2, row, row+1);
#endif
if_lb = gtk_label_new("Description");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 1, 2, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 2, 3, row, row+1);
if_lb = gtk_label_new(" IP ");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 2, 3, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 3, 4, row, row+1);
if_lb = gtk_label_new("Packets");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 3, 4, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 4, 5, row, row+1);
if_lb = gtk_label_new(" Packets/s ");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 4, 5, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 5, 6, row, row+1);
stop_bt = BUTTON_NEW_FROM_STOCK(GTK_STOCK_STOP);
- gtk_tooltips_set_tip(tooltips, stop_bt,
+ gtk_tooltips_set_tip(tooltips, stop_bt,
"Stop a running capture.", NULL);
#ifdef _WIN32
- gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 5, 8, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 6, 9, row, row+1);
#else
- gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 5, 7, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), stop_bt, 6, 8, row, row+1);
#endif
SIGNAL_CONNECT(stop_bt, "clicked", capture_stop_cb, NULL);
@@ -436,12 +551,25 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
if_info = curr->data;
if_dlg_data = g_malloc0(sizeof(if_dlg_data_t));
+
+ /* Kind of adaptor (icon) */
+#ifdef HAVE_AIRPCAP
+ if(get_airpcap_if_from_description(airpcap_if_list,if_info->description) != NULL)
+ icon = xpm_to_widget(capture_airpcap_16_xpm);
+ else
+ icon = xpm_to_widget(capture_ethernet_16_xpm);
+#else
+ icon = xpm_to_widget(capture_ethernet_16_xpm);
+#endif
+
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), icon, 0, 1, row, row+1);
+
/* device name */
if_dlg_data->device_lb = gtk_label_new(if_info->name);
if_dlg_data->device = if_info->name;
#ifndef _WIN32
gtk_misc_set_alignment(GTK_MISC(if_dlg_data->device_lb), 0.0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->device_lb, 0, 1, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->device_lb, 1, 2, row, row+1);
#endif
g_string_append(if_tool_str, "Device: ");
g_string_append(if_tool_str, if_info->name);
@@ -453,7 +581,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
else
if_dlg_data->descr_lb = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(if_dlg_data->descr_lb), 0.0, 0.5);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->descr_lb, 1, 2, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->descr_lb, 2, 3, row, row+1);
if (if_info->description) {
g_string_append(if_tool_str, "Description: ");
@@ -489,40 +617,41 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_widget_set_sensitive(if_dlg_data->ip_lb, FALSE);
g_string_append(if_tool_str, "unknown");
}
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->ip_lb, 2, 3, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->ip_lb, 3, 4, row, row+1);
g_string_append(if_tool_str, "\n");
/* packets */
if_dlg_data->curr_lb = gtk_label_new("-");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->curr_lb, 3, 4, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->curr_lb, 4, 5, row, row+1);
/* packets/s */
if_dlg_data->last_lb = gtk_label_new("-");
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->last_lb, 4, 5, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->last_lb, 5, 6, row, row+1);
/* capture button */
if_dlg_data->capture_bt = gtk_button_new_with_label("Capture");
- SIGNAL_CONNECT(if_dlg_data->capture_bt, "clicked", capture_do_cb, if_dlg_data);
+ SIGNAL_CONNECT(if_dlg_data->capture_bt, "clicked", capture_do_cb, if_dlg_data);
tmp_str = g_strdup_printf("Immediately start a capture from this interface:\n\n%s", if_tool_str->str);
- gtk_tooltips_set_tip(tooltips, if_dlg_data->capture_bt,
+ gtk_tooltips_set_tip(tooltips, if_dlg_data->capture_bt,
tmp_str, NULL);
g_free(tmp_str);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->capture_bt, 5, 6, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->capture_bt, 6, 7, row, row+1);
/* prepare button */
if_dlg_data->prepare_bt = gtk_button_new_with_label("Prepare");
SIGNAL_CONNECT(if_dlg_data->prepare_bt, "clicked", capture_prepare_cb, if_dlg_data);
- gtk_tooltips_set_tip(tooltips, if_dlg_data->prepare_bt,
+ gtk_tooltips_set_tip(tooltips, if_dlg_data->prepare_bt,
"Open the capture options dialog with this interface selected.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->prepare_bt, 6, 7, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->prepare_bt, 7, 8, row, row+1);
/* details button */
#ifdef _WIN32
if_dlg_data->details_bt = gtk_button_new_with_label("Details");
- SIGNAL_CONNECT(if_dlg_data->details_bt, "clicked", capture_details_cb, if_dlg_data);
- gtk_tooltips_set_tip(tooltips, if_dlg_data->details_bt,
+ gtk_container_add (GTK_CONTAINER (if_dlg_data->details_bt), xpm_box(capture_details_16_xpm));
+ SIGNAL_CONNECT(if_dlg_data->details_bt, "clicked", capture_details_cb, if_dlg_data);
+ gtk_tooltips_set_tip(tooltips, if_dlg_data->details_bt,
"Open the capture details dialog of this interface.", NULL);
- gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->details_bt, 7, 8, row, row+1);
+ gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->details_bt, 8, 9, row, row+1);
#endif
open_if(if_info->name, if_dlg_data);
@@ -558,7 +687,8 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_widget_size_request(GTK_WIDGET(close_bt), &requisition);
/* height + static offset + what GTK-Wimp needs in addition per interface */
- height += requisition.height + 26 + ifs;
+ /* XXX - Modify or the window will become huge with many interfaces! */
+ height += requisition.height + 26 + 16;
gtk_window_set_default_size(GTK_WINDOW(cap_if_w), -1, height);
gtk_widget_grab_default(close_bt);
diff --git a/gtk/capture_info_dlg.c b/gtk/capture_info_dlg.c
index 65628aaf3d..090fc0782a 100644
--- a/gtk/capture_info_dlg.c
+++ b/gtk/capture_info_dlg.c
@@ -45,6 +45,13 @@
#include "main.h"
#include "capture-pcap-util.h"
+#ifdef HAVE_AIRPCAP
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_gui_utils.h"
+#include "airpcap_dlg.h"
+#endif
+
/* a single capture counter value (with title, pointer to value and GtkWidgets) */
/* as the packet_counts is a struct, not an array, keep a pointer to the */
@@ -78,6 +85,10 @@ pct(gint num, gint denom) {
static gboolean
capture_info_delete_cb(GtkWidget *w _U_, GdkEvent *event _U_, gpointer data _U_) {
+#ifdef HAVE_AIRPCAP
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+#endif
+
capture_stop(capture_opts);
return TRUE;
}
diff --git a/gtk/compat_macros.h b/gtk/compat_macros.h
index 29be9359a8..a7fe7ef6b5 100644
--- a/gtk/compat_macros.h
+++ b/gtk/compat_macros.h
@@ -187,6 +187,7 @@ gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), name)
#ifdef HAVE_LIBPCAP
#define WIRESHARK_STOCK_CAPTURE_INTERFACES "Interfaces"
+#define WIRESHARK_STOCK_CAPTURE_AIRPCAP "Airpcap"
#define WIRESHARK_STOCK_CAPTURE_OPTIONS "Options"
#define WIRESHARK_STOCK_CAPTURE_START "Start"
#define WIRESHARK_STOCK_CAPTURE_STOP "Stop"
@@ -320,6 +321,7 @@ g_signal_stop_emission_by_name(G_OBJECT(widget), name)
#ifdef HAVE_LIBPCAP
#define WIRESHARK_STOCK_LABEL_CAPTURE_INTERFACES "_Interfaces"
+#define WIRESHARK_STOCK_LABEL_CAPTURE_AIRPCAP "_Wireless"
#define WIRESHARK_STOCK_LABEL_CAPTURE_OPTIONS "_Options"
#define WIRESHARK_STOCK_LABEL_CAPTURE_START "_Start"
#define WIRESHARK_STOCK_LABEL_CAPTURE_STOP "S_top"
@@ -358,6 +360,7 @@ g_signal_stop_emission_by_name(G_OBJECT(widget), name)
#ifdef HAVE_LIBPCAP
#define WIRESHARK_STOCK_CAPTURE_INTERFACES "Wireshark_Stock_CaptureInterfaces"
+#define WIRESHARK_STOCK_CAPTURE_AIRPCAP "Wireshark_Stock_CaptureAirpcap"
#define WIRESHARK_STOCK_CAPTURE_OPTIONS "Wireshark_Stock_CaptureOptionss"
#define WIRESHARK_STOCK_CAPTURE_START "Wireshark_Stock_CaptureStart"
#define WIRESHARK_STOCK_CAPTURE_STOP "Wireshark_Stock_CaptureStop"
diff --git a/gtk/gui_utils.c b/gtk/gui_utils.c
index e5e3b4a280..891e77f4e3 100644
--- a/gtk/gui_utils.c
+++ b/gtk/gui_utils.c
@@ -573,6 +573,26 @@ GtkWidget *xpm_to_widget(const char ** xpm) {
return xpm_to_widget_from_parent(top_level, xpm);
}
+/* Create a new hbox with an image packed into it
+ * and return the box. */
+GtkWidget *xpm_box( gchar **xpm )
+{
+ GtkWidget *box;
+ GtkWidget *image;
+
+ /* Create box for image */
+ box = gtk_hbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 3);
+
+ /* Now on to the image stuff */
+ image = xpm_to_widget (xpm);
+
+ /* Pack the image into the box */
+ gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3);
+
+ return box;
+}
+
/* Set the name of the top-level window and its icon to the specified
string. */
diff --git a/gtk/gui_utils.h b/gtk/gui_utils.h
index 017c31a2f1..5e413b4433 100644
--- a/gtk/gui_utils.h
+++ b/gtk/gui_utils.h
@@ -291,6 +291,14 @@ extern GtkWidget *xpm_to_widget(const char ** xpm);
*/
extern GtkWidget *xpm_to_widget_from_parent(GtkWidget *parent, const char ** xpm);
+/** Create a new hbox with an image packed into it
+ * and return the box.
+ *
+ * @param xpm the character array containing the picture
+ * @return a newly created GtkHBox containing the picture
+ */
+GtkWidget *xpm_box( gchar **xpm );
+
/** Copy a GString to the clipboard.
*
* @param str GString that is to be copied to the clipboard.
diff --git a/gtk/keys.h b/gtk/keys.h
index 9c150757bf..9df70b4214 100644
--- a/gtk/keys.h
+++ b/gtk/keys.h
@@ -29,22 +29,54 @@
* Various keys for OBJECT_SET_DATA().
*/
-#define E_DFILTER_TE_KEY "display_filter_entry"
-#define E_RFILTER_TE_KEY "read_filter_te"
-#define E_MPACKET_LIST_KEY "menu_packet_list"
-#define E_MPACKET_LIST_ROW_KEY "menu_packet_list_row"
-#define E_MPACKET_LIST_COL_KEY "menu_packet_list_col"
-
-#define PRINT_CMD_LB_KEY "printer_command_label"
-#define PRINT_CMD_TE_KEY "printer_command_entry"
-#define PRINT_FILE_BT_KEY "printer_file_button"
-#define PRINT_FILE_TE_KEY "printer_file_entry"
-
-#define PLUGINS_DFILTER_TE "plugins_dfilter_te"
-
-#define PM_MENU_LIST_KEY "popup_menu_menu_list"
-#define PM_PACKET_LIST_KEY "popup_menu_packet_list"
-#define PM_TREE_VIEW_KEY "popup_menu_tree_view"
-#define PM_HEXDUMP_KEY "popup_menu_hexdump"
+#define E_DFILTER_TE_KEY "display_filter_entry"
+#define E_RFILTER_TE_KEY "read_filter_te"
+#define E_MPACKET_LIST_KEY "menu_packet_list"
+#define E_MPACKET_LIST_ROW_KEY "menu_packet_list_row"
+#define E_MPACKET_LIST_COL_KEY "menu_packet_list_col"
+
+#define PRINT_CMD_LB_KEY "printer_command_label"
+#define PRINT_CMD_TE_KEY "printer_command_entry"
+#define PRINT_FILE_BT_KEY "printer_file_button"
+#define PRINT_FILE_TE_KEY "printer_file_entry"
+
+#define PLUGINS_DFILTER_TE "plugins_dfilter_te"
+
+#define PM_MENU_LIST_KEY "popup_menu_menu_list"
+#define PM_PACKET_LIST_KEY "popup_menu_packet_list"
+#define PM_TREE_VIEW_KEY "popup_menu_tree_view"
+#define PM_HEXDUMP_KEY "popup_menu_hexdump"
+
+#ifdef HAVE_AIRPCAP
+#define AIRPCAP_TOOLBAR_KEY "airpcap_toolbar_key"
+#define AIRPCAP_TOOLBAR_INTERFACE_KEY "airpcap_toolbar_if_key"
+#define AIRPCAP_TOOLBAR_LINK_TYPE_KEY "airpcap_toolbar_lt_key"
+#define AIRPCAP_TOOLBAR_CHANNEL_KEY "airpcap_toolbar_ch_key"
+#define AIRPCAP_TOOLBAR_CRC_KEY "airpcap_toolbar_crc_key"
+#define AIRPCAP_TOOLBAR_WRONG_CRC_KEY "airpcap_toolbar_wcrc_key"
+#define AIRPCAP_TOOLBAR_ADVANCED_KEY "airpcap_toolbar_advanced_key"
+#define AIRPCAP_TOOLBAR_DECRYPTION_KEY "airpcap_toolbar_decryption_key"
+
+#define AIRPCAP_ADVANCED_KEY "airpcap_advanced_key"
+#define AIRPCAP_ADVANCED_INTERFACE_KEY "airpcap_advanced_if_key"
+#define AIRPCAP_ADVANCED_LINK_TYPE_KEY "airpcap_advanced_lt_key"
+#define AIRPCAP_ADVANCED_CHANNEL_KEY "airpcap_advanced_ch_key"
+#define AIRPCAP_ADVANCED_CRC_KEY "airpcap_advanced_crc_key"
+#define AIRPCAP_ADVANCED_WRONG_CRC_KEY "airpcap_advanced_wcrc_key"
+#define AIRPCAP_ADVANCED_BLINK_KEY "airpcap_advanced_blink_key"
+#define AIRPCAP_ADVANCED_CANCEL_KEY "airpcap_advanced_cancel_key"
+#define AIRPCAP_ADVANCED_OK_KEY "airpcap_advanced_ok_key"
+#define AIRPCAP_ADVANCED_KEYLIST_KEY "airpcap_advanced_keylist_key"
+#define AIRPCAP_ADVANCED_ADD_KEY_TEXT_KEY "airpcap_advanced_add_key_text_key"
+#define AIRPCAP_ADVANCED_ADD_KEY_OK_KEY "airpcap_advanced_add_key_ok_key"
+#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_OPTIONS_ADVANCED_KEY "airpcap_options_advanced_key"
+
+#define AIRPCAP_ADVANCED_FROM_KEY "airpcap_advanced_name_key"
+#endif
#endif
diff --git a/gtk/main.c b/gtk/main.c
index 40d6d2bee3..4f63e8b5db 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -153,6 +153,16 @@
#include "../image/wsiconcap32.xpm"
#include "../image/wsiconcap48.xpm"
+#ifdef HAVE_AIRPCAP
+#include <airpcap.h>
+#include "airpcap_loader.h"
+#include "airpcap_dlg.h"
+#include "airpcap_gui_utils.h"
+
+#include "./gtk/toolbar.h"
+
+#include "./image/toolbar/wep_closed_24.xpm"
+#endif
/*
* Files under personal and global preferences directories in which
@@ -173,6 +183,11 @@ static GtkWidget *main_pane_v1, *main_pane_v2, *main_pane_h1, *main_pane_h2;
static GtkWidget *main_first_pane, *main_second_pane;
static GtkWidget *status_pane;
static GtkWidget *menubar, *main_vbox, *main_tb, *pkt_scrollw, *stat_hbox, *filter_tb;
+
+#ifdef HAVE_AIRPCAP
+GtkWidget *airpcap_tb;
+#endif
+
static GtkWidget *info_bar;
static GtkWidget *packets_bar = NULL;
static GtkWidget *welcome_pane;
@@ -195,6 +210,7 @@ capture_options global_capture_opts;
capture_options *capture_opts = &global_capture_opts;
#endif
+gboolean block_toolbar_signals = FALSE;
static void create_main_window(gint, gint, gint, e_prefs*);
static void show_main_window(gboolean);
@@ -204,8 +220,6 @@ static void main_save_window_geometry(GtkWidget *widget);
#define E_DFILTER_CM_KEY "display_filter_combo"
#define E_DFILTER_FL_KEY "display_filter_list"
-
-
/* Match selected byte pattern */
static void
match_selected_cb_do(gpointer data, int action, gchar *text)
@@ -431,7 +445,7 @@ match_selected_plist_cb(GtkWidget *w _U_, gpointer data, MATCH_SELECTED_E action
}
/* This function allows users to right click in the details window and copy the text
- * information to the operating systems clipboard.
+ * information to the operating systems clipboard.
*
* We first check to see if a string representation is setup in the tree and then
* read the string. If not available then we try to grab the value. If all else
@@ -1993,6 +2007,11 @@ main(int argc, char *argv[])
int optind_initial;
int status;
+#ifdef HAVE_AIRPCAP
+ char err_str[AIRPCAP_ERRBUF_SIZE];
+ gchar *cant_get_if_list_errstr;
+#endif
+
#define OPTSTRING_INIT "a:b:c:Df:g:Hhi:klLm:nN:o:pQr:R:Ss:t:vw:X:y:z:"
#if defined HAVE_LIBPCAP && defined _WIN32
@@ -2244,6 +2263,31 @@ main(int argc, char *argv[])
/* Read the preference files. */
prefs = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path,
&pf_open_errno, &pf_read_errno, &pf_path);
+
+#ifdef HAVE_AIRPCAP
+ /* Load the airpcap.dll */
+ if(!load_airpcap())
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"%s","Failed to load airpcap.dll\nMake sure you have the right airpcap.dll installed!");
+ airpcap_if_active = NULL;
+ }
+ else
+ {
+ /* load the airpcap interfaces */
+ airpcap_if_list = get_airpcap_interface_list(&err, err_str);
+
+ if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
+ cant_get_if_list_errstr = cant_get_airpcap_if_list_error_message(err_str);
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
+ cant_get_if_list_errstr);
+ g_free(cant_get_if_list_errstr);
+ }
+
+ /* select the first ad default (THIS SHOULD BE CHANGED) */
+ airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
+ }
+#endif
+
if (gpf_path != NULL) {
if (gpf_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
@@ -3105,6 +3149,11 @@ void main_widgets_rearrange(void) {
gtk_widget_ref(menubar);
gtk_widget_ref(main_tb);
gtk_widget_ref(filter_tb);
+
+#ifdef HAVE_AIRPCAP
+ gtk_widget_ref(airpcap_tb);
+#endif
+
gtk_widget_ref(pkt_scrollw);
gtk_widget_ref(tv_scrollw);
gtk_widget_ref(byte_nb_ptr);
@@ -3138,6 +3187,11 @@ void main_widgets_rearrange(void) {
gtk_box_pack_start(GTK_BOX(main_vbox), filter_tb, FALSE, TRUE, 1);
}
+#ifdef HAVE_AIRPCAP
+ /* airpcap toolbar */
+ gtk_box_pack_start(GTK_BOX(main_vbox), airpcap_tb, FALSE, TRUE, 1);
+#endif
+
/* fill the main layout panes */
switch(prefs.gui_layout_type) {
case(layout_type_5):
@@ -3209,6 +3263,11 @@ void main_widgets_rearrange(void) {
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_tb, FALSE, TRUE, 1);
}
+#ifdef HAVE_AIRPCAP
+ /* airpcap toolbar */
+ gtk_box_pack_start(GTK_BOX(main_vbox), airpcap_tb, FALSE, TRUE, 1);
+#endif
+
/* statusbar */
gtk_box_pack_start(GTK_BOX(stat_hbox), status_pane, TRUE, TRUE, 0);
gtk_paned_pack1(GTK_PANED(status_pane), info_bar, FALSE, FALSE);
@@ -3412,6 +3471,14 @@ main_widgets_show_or_hide(void)
gtk_widget_hide(filter_tb);
}
+#ifdef HAVE_AIRPCAP
+ if (recent.airpcap_toolbar_show) {
+ gtk_widget_show(airpcap_tb);
+ } else {
+ gtk_widget_hide(airpcap_tb);
+ }
+#endif
+
if (recent.packet_list_show && have_capture_file) {
gtk_widget_show(pkt_scrollw);
} else {
@@ -3479,6 +3546,128 @@ window_state_event_cb (GtkWidget *widget _U_,
}
#endif
+#ifdef HAVE_AIRPCAP
+/*
+ * Changed callback for the channel combobox
+ */
+static void
+airpcap_toolbar_channel_changed_cb(GtkWidget *w _U_, gpointer data)
+{
+gchar ebuf[AIRPCAP_ERRBUF_SIZE];
+PAirpcapHandle ad;
+const gchar *s;
+int ch_num;
+
+ s = gtk_entry_get_text(GTK_ENTRY(data));
+
+if((data != NULL) && (w != NULL) )
+ {
+ s = gtk_entry_get_text(GTK_ENTRY(data));
+ if((g_strcasecmp("",s)))
+ {
+ sscanf(s,"%d",&ch_num);
+ if(airpcap_if_active != NULL)
+ {
+ ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list, airpcap_if_active->description), ebuf);
+
+ if(ad)
+ {
+ airpcap_if_set_device_channel(ad,ch_num);
+ airpcap_if_active->channel = ch_num;
+ airpcap_if_close(ad);
+ }
+ }
+ }
+ }
+}
+#endif
+
+
+#ifdef HAVE_AIRPCAP
+/*
+ * Callback for the wrong crc combo
+ */
+static void
+airpcap_toolbar_wrong_crc_combo_cb(GtkWidget *entry, gpointer user_data)
+{
+gchar ebuf[AIRPCAP_ERRBUF_SIZE];
+PAirpcapHandle ad;
+
+if( !block_toolbar_signals && (airpcap_if_active != NULL))
+ {
+ ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list,airpcap_if_active->description), ebuf);
+
+ if(ad)
+ {
+ airpcap_if_active->CrcValidationOn = airpcap_get_validation_type(gtk_entry_get_text(GTK_ENTRY(entry)));
+ airpcap_if_set_fcs_validation(ad,airpcap_if_active->CrcValidationOn);
+ /* Save configuration */
+ if(!airpcap_if_store_cur_config_as_adapter_default(ad))
+ {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Cannot save configuration!!!\nRemember that in order to store the configuration in the registry you have to:\n\n- Close all the airpcap-based applications.\n- Be sure to have administrative privileges.");
+ }
+ airpcap_if_close(ad);
+ }
+ }
+}
+#endif
+
+#ifdef HAVE_AIRPCAP
+void
+airpcap_toolbar_encryption_cb(GtkWidget *entry, gpointer user_data)
+{
+gchar ebuf[AIRPCAP_ERRBUF_SIZE];
+PAirpcapHandle ad;
+
+if( !block_toolbar_signals && (airpcap_if_active != NULL))
+{
+ ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list,airpcap_if_active->description), ebuf);
+
+ if(ad)
+ {
+ if(airpcap_if_active->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ {
+ airpcap_if_active->DecryptionOn = AIRPCAP_DECRYPTION_OFF;
+ airpcap_if_set_decryption_state(ad,airpcap_if_active->DecryptionOn);
+ /* Save configuration */
+ if(!airpcap_if_store_cur_config_as_adapter_default(ad))
+ {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Cannot save configuration!!!\nRemember that in order to store the configuration in the registry you have to:\n\n- Close all the airpcap-based applications.\n- Be sure to have administrative privileges.");
+ }
+ airpcap_if_close(ad);
+ }
+ else
+ {
+ airpcap_if_active->DecryptionOn = AIRPCAP_DECRYPTION_ON;
+ airpcap_if_set_decryption_state(ad,airpcap_if_active->DecryptionOn);
+ /* Save configuration */
+ if(!airpcap_if_store_cur_config_as_adapter_default(ad))
+ {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Cannot save configuration!!!\nRemember that in order to store the configuration in the registry you have to:\n\n- Close all the airpcap-based applications.\n- Be sure to have administrative privileges.");
+ }
+ airpcap_if_close(ad);
+ }
+ }
+ }
+}
+#endif
+
+#ifdef HAVE_AIRPCAP
+/*
+ * Callback for the Advanced Wireless Settings button
+ */
+static void
+toolbar_display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
+{
+int *from_widget;
+
+ from_widget = (gint*)g_malloc(sizeof(gint));
+ *from_widget = AIRPCAP_ADVANCED_FROM_TOOLBAR;
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_ADVANCED_FROM_KEY,from_widget);
+
+ display_airpcap_advanced_cb(w,data);
+}
+#endif
static void
create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
@@ -3490,8 +3679,28 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
*filter_reset;
GList *dfilter_list = NULL;
GtkTooltips *tooltips;
+
GtkAccelGroup *accel;
gchar *title;
+
+#ifdef HAVE_AIRPCAP
+ GtkWidget
+ *advanced_bt,
+ *interface_lb,
+ *channel_lb,
+ *channel_cm,
+ *wrong_crc_lb,
+ *encryption_ck,
+ *wrong_crc_cm,
+ *iconw;
+ GList *channel_list = NULL;
+ GList *linktype_list = NULL;
+ GList *link_list = NULL;
+ GtkTooltips *airpcap_tooltips;
+ gchar *if_label_text;
+ gint *from_widget = NULL;
+#endif
+
/* Display filter construct dialog has an Apply button, and "OK" not
only sets our text widget, it activates it (i.e., it causes us to
filter the capture). */
@@ -3511,6 +3720,10 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
tooltips = gtk_tooltips_new();
+#ifdef HAVE_AIRPCAP
+ airpcap_tooltips = gtk_tooltips_new();
+#endif
+
#ifdef _WIN32
#if GTK_MAJOR_VERSION < 2
/* has to be done, after top_level window is created */
@@ -3584,6 +3797,206 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
main_pane_h2 = gtk_hpaned_new();
gtk_widget_show(main_pane_h2);
+#ifdef HAVE_AIRPCAP
+ /* airpcap toolbar */
+#if GTK_MAJOR_VERSION < 2
+ airpcap_tb = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
+ GTK_TOOLBAR_BOTH);
+#else
+ airpcap_tb = gtk_toolbar_new();
+ gtk_toolbar_set_orientation(GTK_TOOLBAR(airpcap_tb),
+ GTK_ORIENTATION_HORIZONTAL);
+#endif /* GTK_MAJOR_VERSION */
+ gtk_widget_show(airpcap_tb);
+
+ /* Interface Label */
+ if(airpcap_if_active != NULL)
+ {
+ if_label_text = g_strdup_printf("%s %s\t","Current Wireless Interface: #",airpcap_get_if_string_number(airpcap_if_active));
+ interface_lb = gtk_label_new(if_label_text);
+ g_free(if_label_text);
+ }
+ else
+ {
+ interface_lb = gtk_label_new("No Wireless Interface Found ");
+ }
+
+ /* Add the label to the toolbar */
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), interface_lb,
+ "Current Wireless Interface", "Private");
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_INTERFACE_KEY,interface_lb);
+ gtk_widget_show(interface_lb);
+ gtk_toolbar_insert_space(GTK_TOOLBAR(airpcap_tb),1);
+
+
+ /* Create the "802.11 Channel:" label */
+ channel_lb = gtk_label_new(" 802.11 Channel: ");
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), channel_lb,
+ "Current 802.11 Channel", "Private");
+ gtk_widget_show(channel_lb);
+
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(channel_lb),
+ 100,
+ 28 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(channel_lb),
+ 100,
+ 28 );
+ #endif
+
+ /* Create the channel combo box */
+ channel_cm = gtk_combo_new();
+ gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(channel_cm)->entry),FALSE);
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_CHANNEL_KEY,channel_cm);
+
+ channel_list = g_list_append(channel_list, "1");
+ channel_list = g_list_append(channel_list, "2");
+ channel_list = g_list_append(channel_list, "3");
+ channel_list = g_list_append(channel_list, "4");
+ channel_list = g_list_append(channel_list, "5");
+ channel_list = g_list_append(channel_list, "6");
+ channel_list = g_list_append(channel_list, "7");
+ channel_list = g_list_append(channel_list, "8");
+ channel_list = g_list_append(channel_list, "9");
+ channel_list = g_list_append(channel_list, "10");
+ channel_list = g_list_append(channel_list, "11");
+ channel_list = g_list_append(channel_list, "12");
+ channel_list = g_list_append(channel_list, "13");
+ channel_list = g_list_append(channel_list, "14");
+
+ gtk_combo_set_popdown_strings( GTK_COMBO(channel_cm), channel_list) ;
+
+ gtk_tooltips_set_tip(airpcap_tooltips, GTK_WIDGET(GTK_COMBO(channel_cm)->entry),
+ "Change the 802.11 RF channel",
+ NULL);
+
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(channel_cm),
+ 45,
+ 28 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(channel_cm),
+ 45,
+ 28 );
+ #endif
+
+ if(airpcap_if_active != NULL)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cm)->entry), airpcap_get_channel_name(airpcap_if_active->channel));
+ else
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cm)->entry),"");
+
+ /* callback for channel combo box */
+ SIGNAL_CONNECT(GTK_COMBO(channel_cm)->entry,"changed",airpcap_toolbar_channel_changed_cb,GTK_COMBO(channel_cm)->entry);
+ gtk_widget_show(channel_cm);
+
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), channel_cm,
+ "802.11 Channel", "Private");
+
+ gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb));
+
+ /* Wrong CRC Label */
+ wrong_crc_lb = gtk_label_new(" FCS Filter: ");
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), wrong_crc_lb,
+ "", "Private");
+ gtk_widget_show(wrong_crc_lb);
+
+ /* Wrong CRC combo */
+ wrong_crc_cm = gtk_combo_new();
+ gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(wrong_crc_cm)->entry),FALSE);
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_WRONG_CRC_KEY,wrong_crc_cm);
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), wrong_crc_cm,
+ "", "Private");
+
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_ALL);
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_CORRECT);
+ linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT);
+
+ gtk_combo_set_popdown_strings( GTK_COMBO(wrong_crc_cm), linktype_list) ;
+ gtk_tooltips_set_tip(airpcap_tooltips, GTK_WIDGET(GTK_COMBO(wrong_crc_cm)->entry),
+ "Select the 802.11 FCS filter that the wireless adapter will apply.",
+ NULL);
+
+ if(airpcap_if_active != NULL)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_cm)->entry), airpcap_get_validation_name(airpcap_if_active->CrcValidationOn));
+ else
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_cm)->entry),"");
+
+ SIGNAL_CONNECT(GTK_COMBO(wrong_crc_cm)->entry,"changed",airpcap_toolbar_wrong_crc_combo_cb,airpcap_tb);
+ gtk_widget_show(wrong_crc_cm);
+
+ gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb));
+
+ /* encryption enabled box */
+
+ encryption_ck = gtk_toggle_button_new();
+ iconw = xpm_to_widget (wep_closed_24_xpm);
+ gtk_widget_show(iconw);
+ gtk_container_add(GTK_CONTAINER(encryption_ck),iconw);
+
+ #if GTK_MAJOR_VERSION < 2
+ gtk_widget_set_usize( GTK_WIDGET(encryption_ck),
+ 28,
+ 28 );
+ #else
+ gtk_widget_set_size_request( GTK_WIDGET(encryption_ck),
+ 28,
+ 28 );
+ #endif
+
+ OBJECT_SET_DATA(GTK_TOOLBAR(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY,encryption_ck);
+
+ if(airpcap_if_active != NULL)
+ {
+ if(airpcap_if_active->DecryptionOn == AIRPCAP_DECRYPTION_ON)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(encryption_ck),TRUE);
+ else
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(encryption_ck),FALSE);
+ }
+
+ SIGNAL_CONNECT(encryption_ck,"toggled",airpcap_toolbar_encryption_cb,airpcap_tb);
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), encryption_ck,
+ "Enable the WEP decryption in the wireless driver", "Private");
+ gtk_widget_show(encryption_ck);
+
+ gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb));
+
+ /* Advanced button */
+ advanced_bt = gtk_button_new_with_label("Advanced Wireless Settings...");
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_ADVANCED_KEY,advanced_bt);
+
+ SIGNAL_CONNECT(advanced_bt, "clicked", toolbar_display_airpcap_advanced_cb, airpcap_tb);
+ gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), advanced_bt,
+ "Set Advanced Wireless Settings...", "Private");
+ gtk_widget_show(advanced_bt);
+
+ /* select the default interface */
+ airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
+
+ /* If no airpcap interface is present, gray everything */
+ if(airpcap_if_active == NULL)
+ {
+ if(airpcap_if_list == NULL)
+ {
+ /*No airpcap device found */
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ recent.airpcap_toolbar_show = FALSE;
+ }
+ else
+ {
+ /* default adapter is not airpcap... or is airpcap but is not found*/
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+ gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ recent.airpcap_toolbar_show = TRUE;
+ }
+ }
+ else
+ {
+ airpcap_set_toolbar_stop_capture(airpcap_if_active);
+ recent.airpcap_toolbar_show = TRUE;
+ }
+#endif
+
/* filter toolbar */
#if GTK_MAJOR_VERSION < 2
filter_tb = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
diff --git a/gtk/main.h b/gtk/main.h
index cde0803ffc..a02a537925 100644
--- a/gtk/main.h
+++ b/gtk/main.h
@@ -62,6 +62,8 @@ extern GString *comp_info_str;
/** Global runtime version string */
extern GString *runtime_info_str;
+extern GtkWidget* airpcap_tb;
+
/** Global capture options type. */
typedef struct capture_options_tag * p_capture_options_t;
/** Pointer to global capture options. */
@@ -70,6 +72,9 @@ extern p_capture_options_t capture_opts;
extern void protect_thread_critical_region(void);
extern void unprotect_thread_critical_region(void);
+void
+airpcap_toolbar_encryption_cb(GtkWidget *entry, gpointer user_data);
+
/** User requested "Zoom In" by menu or toolbar.
*
* @param widget parent widget (unused)
diff --git a/gtk/menu.c b/gtk/menu.c
index 35d1f52cb0..da2e049451 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -109,6 +109,9 @@ static void menus_init(void);
static void set_menu_sensitivity (GtkItemFactory *, const gchar *, gint);
static void main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
+#ifdef HAVE_AIRPCAP
+static void airpcap_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
+#endif
static void packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
@@ -445,6 +448,9 @@ static GtkItemFactoryEntry menu_items[] =
ITEM_FACTORY_ENTRY("/_View", NULL, NULL, 0, "<Branch>", NULL),
ITEM_FACTORY_ENTRY("/View/_Main Toolbar", NULL, main_toolbar_show_cb, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Filter Toolbar", NULL, filter_toolbar_show_cb, 0, "<CheckItem>", NULL),
+#ifdef HAVE_AIRPCAP
+ ITEM_FACTORY_ENTRY("/View/_Wireless Toolbar", NULL, airpcap_toolbar_show_cb, 0, "<CheckItem>", NULL),
+#endif
ITEM_FACTORY_ENTRY("/View/_Statusbar", NULL, statusbar_show_cb, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
ITEM_FACTORY_ENTRY("/View/Packet _List", NULL, packet_list_show_cb, 0, "<CheckItem>", NULL),
@@ -1504,6 +1510,17 @@ filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
main_widgets_show_or_hide();
}
+#ifdef HAVE_AIRPCAP
+static void
+airpcap_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
+{
+
+ /* save current setting in recent */
+ recent.airpcap_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
+
+ main_widgets_show_or_hide();
+}
+#endif
static void
packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_)
@@ -1775,6 +1792,9 @@ menu_recent_read_finished(void) {
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Filter Toolbar");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
+ menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Wireless Toolbar");
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.airpcap_toolbar_show);
+
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Statusbar");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
diff --git a/gtk/recent.c b/gtk/recent.c
index f4c3c226d9..8e8c19e849 100644
--- a/gtk/recent.c
+++ b/gtk/recent.c
@@ -50,6 +50,7 @@
#define RECENT_KEY_MAIN_TOOLBAR_SHOW "gui.toolbar_main_show"
#define RECENT_KEY_FILTER_TOOLBAR_SHOW "gui.filter_toolbar_show"
+#define RECENT_KEY_AIRPCAP_TOOLBAR_SHOW "gui.airpcap_toolbar_show"
#define RECENT_KEY_PACKET_LIST_SHOW "gui.packet_list_show"
#define RECENT_KEY_TREE_VIEW_SHOW "gui.tree_view_show"
#define RECENT_KEY_BYTE_VIEW_SHOW "gui.byte_view_show"
@@ -165,6 +166,13 @@ write_recent(void)
fprintf(rf, RECENT_KEY_FILTER_TOOLBAR_SHOW ": %s\n",
recent.filter_toolbar_show == TRUE ? "TRUE" : "FALSE");
+#ifdef HAVE_AIRPCAP
+ fprintf(rf, "\n# Wireless Settings Toolbar show (hide).\n");
+ fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
+ fprintf(rf, RECENT_KEY_AIRPCAP_TOOLBAR_SHOW ": %s\n",
+ recent.airpcap_toolbar_show == TRUE ? "TRUE" : "FALSE");
+#endif
+
fprintf(rf, "\n# Packet list show (hide).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_KEY_PACKET_LIST_SHOW ": %s\n",
@@ -213,7 +221,7 @@ write_recent(void)
recent.gui_geometry_main_width);
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_HEIGHT ": %d\n",
recent.gui_geometry_main_height);
-
+
fprintf(rf, "\n# Main window maximized (GTK2 only!).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED ": %s\n",
@@ -259,7 +267,7 @@ write_recent(void)
/* write the geometry values of a window to recent file */
-void
+void
write_recent_geom(gpointer key _U_, gpointer value, gpointer rf)
{
window_geometry_t *geom = value;
@@ -301,6 +309,13 @@ read_set_recent_pair_static(gchar *key, gchar *value)
else {
recent.filter_toolbar_show = FALSE;
}
+ } else if (strcmp(key, RECENT_KEY_AIRPCAP_TOOLBAR_SHOW) == 0) {
+ if (strcasecmp(value, "true") == 0) {
+ recent.airpcap_toolbar_show = TRUE;
+ }
+ else {
+ recent.airpcap_toolbar_show = FALSE;
+ }
} else if (strcmp(key, RECENT_KEY_PACKET_LIST_SHOW) == 0) {
if (strcasecmp(value, "true") == 0) {
recent.packet_list_show = TRUE;
@@ -489,6 +504,7 @@ recent_read_static(char **rf_path_return, int *rf_errno_return)
/* set defaults */
recent.main_toolbar_show = TRUE;
recent.filter_toolbar_show = TRUE;
+ recent.airpcap_toolbar_show = FALSE;
recent.packet_list_show = TRUE;
recent.tree_view_show = TRUE;
recent.byte_view_show = TRUE;
diff --git a/gtk/recent.h b/gtk/recent.h
index 2450aadff1..e1ecb3de95 100644
--- a/gtk/recent.h
+++ b/gtk/recent.h
@@ -43,6 +43,7 @@
typedef struct recent_settings_tag {
gboolean main_toolbar_show;
gboolean filter_toolbar_show;
+ gboolean airpcap_toolbar_show;
gboolean packet_list_show;
gboolean tree_view_show;
gboolean byte_view_show;