aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2006-12-05 19:24:25 +0000
committerGerald Combs <gerald@wireshark.org>2006-12-05 19:24:25 +0000
commita980d047830755406fc27150978511b407d65829 (patch)
tree523e028d65e71d3531c9e0fdb1da17350e90f91c
parent39c29557c743671b4b09308cdd5a6dc7ba791499 (diff)
From Davide Schiera and Giorgio Tino: Add initial WPA/WPA2 decryption
support. WEP key preferences have been overloaded to allow WPA keys. The decryption code currently uses Windows-specific data types, but can be converted to use glib equivalents. Add a few text and whitespace fixups. svn path=/trunk/; revision=20049
-rw-r--r--AUTHORS26
-rw-r--r--Makefile.nmake2
-rw-r--r--airpcap.h5
-rw-r--r--airpcap_loader.c725
-rw-r--r--airpcap_loader.h84
-rw-r--r--epan/dissectors/Makefile.nmake15
-rw-r--r--epan/dissectors/packet-ieee80211.c678
-rw-r--r--epan/libwireshark.def1
-rw-r--r--gtk/Makefile.nmake4
-rw-r--r--gtk/airpcap_dlg.c635
-rw-r--r--gtk/airpcap_dlg.h6
-rwxr-xr-xgtk/airpcap_gui_utils.c336
-rwxr-xr-xgtk/airpcap_gui_utils.h18
-rw-r--r--gtk/capture_dlg.c11
-rw-r--r--gtk/capture_if_dlg.c10
-rw-r--r--gtk/keys.h7
-rw-r--r--gtk/main.c39
17 files changed, 2038 insertions, 564 deletions
diff --git a/AUTHORS b/AUTHORS
index b40e06cb5a..91c15582b3 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -23,7 +23,7 @@ Gilbert Ramirez <gram[AT]alumni.rice.edu> {
Hannes R. Boehm <hannes[AT]boehm.org> {
http://hannes.boehm.org/
- OSPFv2
+ OSPFv2
RIPv1, RIPv2
CDP (Cisco Discovery Protocol Version 1)
}
@@ -1434,7 +1434,7 @@ Solomon Peachy <pizza[AT]shaftnet.org> {
Jaime Fournier <Jaime.Fournier [AT] hush.com> {
Handle DCE RPC connectionless CANCEL PDUs with no body
- DCE/RPC stub dissectors for RSEC_LOGIN, RS_ACCT, RS_ATTR, RS_MISC,
+ DCE/RPC stub dissectors for RSEC_LOGIN, RS_ACCT, RS_ATTR, RS_MISC,
RS_PGO, RS_REPLIST, RS_UNIX, RPRIV, ROVERRIDE, RS_REPADM,
DTSSTIME_REQ, CDS_SOLICIT, CPRPC_SERVER, DTSPROVIDER,
UBIKDISK, UBIKVOTE, BOSSVR, FTSERVER, CDS_CLERKSERVER,
@@ -2154,7 +2154,7 @@ Duncan Sargeant <dunc-ethereal-dev [AT] rcpt.to> {
}
Love Hörnquist Åstrand <lha [AT] it.su.se> {
- HAVE_HEIMDAL_KERBEROS support to allow Ethereal to use heimdal
+ HAVE_HEIMDAL_KERBEROS support to allow Ethereal to use heimdal
libraries to decrypt kerberos encrypted blobs.
}
@@ -2328,7 +2328,7 @@ Stefano Pettini <spettini [AT] users.sourceforge.net> {
}
Jon Ringle <ml-ethereal [AT] ringle.org> {
- Conversations demarked by setup frame number
+ Conversations demarked by setup frame number
}
Tim Endean <endeant [AT] hotmail.com> {
@@ -2473,7 +2473,7 @@ W. Borgert <debacle [AT] debian.org> {
Frederic Roudaut <frederic.roudaut [AT] irisa.fr> {
IPsec ESP payload decryption
-}
+}
Christoph Scholz <scholz_ch [AT] web.de> {
Bluetooth stack: http://affix.sourceforge.net/archive/ethereal_affix-3.patch
@@ -2542,6 +2542,16 @@ Douglas Pratley <Douglas.pratley [AT] detica.com> {
Epoch timestamps
}
+Giorgio Tino <giorgio.tino [AT] cacetech.com> {
+ AirPcap support
+ WPA UI support
+ Static text preferences
+}
+
+Davide Schiera <davide.schiera@cacetech.com> {
+ WPA and WPA2 decryption
+}
+
and by:
Pavel Roskin <proski [AT] gnu.org>
@@ -2636,7 +2646,7 @@ Vladimir Kondratiev <vladimir.kondratiev [AT] gmail.com>
Jaap Keuter <jaap.keuter [AT] xs4all.nl>
Frederic Peters <fpeters [AT] debian.org>
Anton Ivanov <anthony_johnson [AT] mail.ru>
-Ilya Konstantinov <future [AT] shiny.co.il>
+Ilya Konstantinov <future [AT] shiny.co.il>
Neil Kettle <njk4 [AT] kent.ac.uk>
Steve Karg <skarg [AT] users.sourceforge.net>
Steve Packet <packetsteve [AT] hotmail.com>
@@ -2673,7 +2683,7 @@ Ian Abel <ianabel [AT] mxtelecom.com>
Bryant Eastham <beastham [AT] slc.mew.com>
Taner Kurtulus <taner.kurtulus [AT] tubitak.gov.tr>
Joe Breher <linux [AT] q-music.com>
-Patrick vd Lageweg <patrick [AT] bitwizard.nl>
+Patrick vd Lageweg <patrick [AT] bitwizard.nl>
Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to
give his permission to use his version of snprintf.c.
@@ -2693,7 +2703,7 @@ Henrik Brix Andersen <brix[AT]gimp.org> gave permission for his
webbrowser calling routine to be used.
Christophe Devine <c.devine[at]cr0.net> gave permission for his
-SHA1 routines to be used.
+SHA1 routines to be used.
snax <snax[AT]shmoo.com> gave permission to use his(?) weak key
detection code from Airsnort.
diff --git a/Makefile.nmake b/Makefile.nmake
index 6892e5c02b..d39cf2a471 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -13,7 +13,7 @@ LINK= link
LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386 $(LOCAL_LDFLAGS)
-CFLAGS=-DHAVE_CONFIG_H $(LOCAL_CFLAGS) $(GLIB_CFLAGS) /I. /Iwiretap \
+CFLAGS=-DHAVE_CONFIG_H -DHAVE_AIRPDCAP $(LOCAL_CFLAGS) $(GLIB_CFLAGS) /I. /Iwiretap \
$(ZLIB_CFLAGS) /I$(PCAP_DIR)\include \
$(NET_SNMP_CFLAGS) \
$(ADNS_CFLAGS) $(PCRE_CFLAGS) $(GNUTLS_CFLAGS) $(LUA_CFLAGS) \
diff --git a/airpcap.h b/airpcap.h
index d6df6ca1b0..1a7aeb28d4 100644
--- a/airpcap.h
+++ b/airpcap.h
@@ -88,6 +88,7 @@ typedef struct _AirpcapDeviceDescription
#define WEP_KEY_MAX_SIZE 32 /* Maximum size of a WEP key, in bytes. This is the size of an entry in the */
/* AirpcapWepKeysCollection structure */
+
#ifndef __MINGW32__
#pragma pack(push)
#pragma pack(1)
@@ -95,8 +96,8 @@ typedef struct _AirpcapDeviceDescription
#define AIRPCAP_KEYTYPE_WEP 0 /* Key type: WEP. The key can have an arbitrary length smaller than 32 bytes. */
-#define AIRPCAP_KEYTYPE_TKIP 1 /* Key type: TKIP (WPA). NOT SUPPORTED YET. */
-#define AIRPCAP_KEYTYPE_CCMP 2 /* Key type: CCMP (WPA2). NOT SUPPORTED YET. */
+#define AIRPCAP_KEYTYPE_TKIP 1 /* Key type: TKIP (WPA_PWD). NOT SUPPORTED YET. */
+#define AIRPCAP_KEYTYPE_CCMP 2 /* Key type: CCMP (WPA_BIN). NOT SUPPORTED YET. */
/*!
\brief WEP key container
diff --git a/airpcap_loader.c b/airpcap_loader.c
index a8d41605c8..d0ddf88f9d 100644
--- a/airpcap_loader.c
+++ b/airpcap_loader.c
@@ -49,6 +49,9 @@
#include <airpcap.h>
#include "airpcap_loader.h"
+/* AirPDcap */
+#include "../airpdcap/airpdcap_ws.h"
+
/*
* We load dinamically the dag library in order link it only when
* it's present on the system
@@ -106,7 +109,9 @@ airpcap_if_info_t *airpcap_if_active = NULL;
/* WLAN preferences pointer */
module_t *wlan_prefs = NULL;
-/* Callback used by the load_wlan_keys() routine in order to read a WEP decryption key */
+/*
+ * Callback used by the load_wlan_keys() routine in order to read a WEP decryption key
+ */
static guint
get_wep_key(pref_t *pref, gpointer ud _U_)
{
@@ -122,45 +127,20 @@ if (g_strncasecmp(pref->name, "wep_key", 7) == 0 && pref->type == PREF_STRING)
{
my_string = g_strdup(*pref->varp.string);
- if( my_string != NULL)
+ /* Here we have the string describing the key... */
+ new_key = parse_key_string(my_string);
+
+ if( new_key != NULL)
{
/* Key is added only if not null ... */
- if( (g_strcasecmp(my_string,"") != 0) && (wep_key_is_valid(my_string)))
- {
- new_key = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
-
- new_key->key = g_string_new(my_string);
- g_free(my_string);
-
- new_key->bits = new_key->key->len * 4;
-
- new_key->type = AIRPCAP_KEYTYPE_WEP;
-
- new_key->ssid = NULL;
-
user_data->list = g_list_append(user_data->list,new_key);
user_data->number_of_keys++;
user_data->current_index++;
}
}
- }
return 0;
}
-/* Callback used by the load_wlan_keys() routine in order to read a WPA decryption key */
-static guint
-get_wpa_key(pref_t *pref, gpointer ud _U_)
-{
-return 1;
-}
-
-/* Callback used by the load_wlan_keys() routine in order to read a WPA2 decryption key */
-static guint
-get_wpa2_key(pref_t *pref, gpointer ud _U_)
-{
-return 1;
-}
-
/* Returs TRUE if the WEP key is valid, false otherwise */
gboolean
wep_key_is_valid(char* key)
@@ -204,6 +184,8 @@ gchar *my_string = NULL;
keys_cb_data_t* user_data;
gint wep_key_number = 0;
+decryption_key_t* new_key;
+
/* Retrieve user data info */
user_data = (keys_cb_data_t*)ud;
@@ -216,11 +198,19 @@ if (g_strncasecmp(pref->name, "wep_key", 7) == 0 && pref->type == PREF_STRING)
{
if(wep_key_number == (user_data->current_index+1))
{
- my_string = g_strdup((char*)g_list_nth_data(user_data->list,user_data->current_index));
+ /* Retrieve the nth decryption_key_t structure pointer */
+ new_key = (decryption_key_t*)g_list_nth_data(user_data->list,user_data->current_index);
+ /* Free the old key string */
g_free((void *)*pref->varp.string);
+
+ /* Create the new string describing the decryption key */
+ my_string = get_key_string(new_key);
+
+ /* Duplicate the string, and assign it to the variable pointer */
*pref->varp.string = (void *)g_strdup(my_string);
+ /* Free the previously allocated string */
g_free(my_string);
}
}
@@ -242,63 +232,6 @@ return 0;
* properly into the airpcap adapter.
*/
BOOL
-load_wlan_wep_keys(airpcap_if_info_t* info_if)
-{
-keys_cb_data_t* user_data;
-guint i;
-gchar *tmp = NULL;
-
-if(info_if == NULL) return FALSE;
-
-/* Retrieve the wlan preferences */
-wlan_prefs = prefs_find_module("wlan");
-
-/* Allocate a structure used to keep infos between the callbacks */
-user_data = (keys_cb_data_t*)g_malloc(sizeof(keys_cb_data_t));
-
-/* Fill the structure */
-user_data->list = NULL;
-user_data->current_index = 0;
-user_data->number_of_keys= 0; /* Still unknown */
-
-/* Run the callback on each 802.11 preference */
-prefs_pref_foreach(wlan_prefs, get_wep_key, (gpointer)user_data);
-
-/* Now the key list should be filled */
-
-/*
- * Signal that we've changed things, and run the 802.11 dissector's
- * callback
- */
-wlan_prefs->prefs_changed = TRUE;
-
-prefs_apply(wlan_prefs);
-
-write_wlan_wep_keys_to_regitry(info_if,user_data->list);
-
-/* FREE MEMORY */
-/* free the WEP key string */
-for(i=0;i<g_list_length(user_data->list);i++)
- {
- g_free(g_list_nth(user_data->list,i)->data);
- }
-
-/* free the (empty) list */
-g_list_free(user_data->list);
-
-/* free the user_data structure */
-g_free(user_data);
-
-return TRUE;
-}
-
-
-
-/*
- * Function used to read the Decryption Keys from the preferences and store them
- * properly into the airpcap adapter.
- */
-BOOL
load_wlan_driver_wep_keys()
{
keys_cb_data_t* user_data;
@@ -393,7 +326,7 @@ KeysCollection->nKeys = keys_in_list;
for(i = 0; i < keys_in_list; i++)
{
- KeysCollection->Keys[i].KeyType = AIRPCAP_KEYTYPE_WEP;
+ KeysCollection->Keys[i].KeyType = AIRPDCAP_KEY_TYPE_WEP;
/* Retrieve the Item corresponding to the i-th key */
key_item = (decryption_key_t*)g_list_nth_data(key_list,i);
@@ -446,7 +379,7 @@ return TRUE;
BOOL
write_wlan_driver_wep_keys_to_regitry(GList* key_list)
{
-UINT i,j;
+UINT i,j,k,n,y;
GString *new_key;
gchar s[3];
PAirpcapKeysCollection KeysCollection;
@@ -459,7 +392,17 @@ airpcap_if_info_t* fake_info_if = NULL;
/* Create the fake_info_if from the first adapter of the list */
fake_info_if = airpcap_driver_fake_if_info_new();
-keys_in_list = g_list_length(key_list);
+if(fake_info_if == NULL)
+ return FALSE;
+
+/*
+ * XXX - When WPA will be supported, change this to: keys_in_list = g_list_length(key_list);
+ * but right now we will have to count only the WEP keys (or we will have a malloc-mess :-) )
+ */
+n = g_list_length(key_list);
+for(k = 0; k < n; k++ )
+ if(((decryption_key_t*)g_list_nth_data(key_list,k))->type == AIRPDCAP_KEY_TYPE_WEP)
+ keys_in_list++;
/*
* Save the encryption keys, if we have any of them
@@ -485,16 +428,33 @@ if(!KeysCollection)
*/
KeysCollection->nKeys = keys_in_list;
-for(i = 0; i < keys_in_list; i++)
-{
- KeysCollection->Keys[i].KeyType = AIRPCAP_KEYTYPE_WEP;
+/*
+ * XXX - If we have, let's say, six keys, the first three are WEP, then two are WPA, and the
+ * last is WEP, we have to scroll the whole list (n) but increment the array counter only
+ * when a WEP key is found (y) .. When WPA will be supported by the driver, I'll have to change
+ * this
+ */
+y = 0; /* Current position in the key list */
+for(i = 0; i < n; i++)
+{
/* Retrieve the Item corresponding to the i-th key */
key_item = (decryption_key_t*)g_list_nth_data(key_list,i);
+
+ /*
+ * XXX - The AIRPDCAP_KEY_TYPE_WEP is the only supportd right now!
+ * We will have to modify the AirpcapKey structure in order to
+ * support the other two types! What happens now, is that simply the
+ * not supported keys will just be discarded (they will be saved in wireshark though)
+ */
+ if(key_item->type == AIRPDCAP_KEY_TYPE_WEP)
+ {
+ KeysCollection->Keys[y].KeyType = AIRPDCAP_KEY_TYPE_WEP;
+
new_key = g_string_new(key_item->key->str);
- KeysCollection->Keys[i].KeyLen = new_key->len / 2;
- memset(&KeysCollection->Keys[i].KeyData, 0, sizeof(KeysCollection->Keys[i].KeyData));
+ KeysCollection->Keys[y].KeyLen = new_key->len / 2;
+ memset(&KeysCollection->Keys[y].KeyData, 0, sizeof(KeysCollection->Keys[y].KeyData));
for(j = 0 ; j < new_key->len; j += 2)
{
@@ -502,11 +462,21 @@ for(i = 0; i < keys_in_list; i++)
s[1] = new_key->str[j+1];
s[2] = '\0';
KeyByte = (UCHAR)strtol(s, NULL, 16);
- KeysCollection->Keys[i].KeyData[j / 2] = KeyByte;
+ KeysCollection->Keys[y].KeyData[j / 2] = KeyByte;
}
-
+ /* XXX - Change when WPA will be supported!!! */
+ y++;
g_string_free(new_key,TRUE);
}
+ else if(key_item->type == AIRPDCAP_KEY_TYPE_WPA_PWD)
+ {
+ /* XXX - The driver cannot deal with this kind of key yet... */
+ }
+ else if(key_item->type == AIRPDCAP_KEY_TYPE_WPA_PMK)
+ {
+ /* XXX - The driver cannot deal with this kind of key yet... */
+ }
+}
/*
* Free the old adapter key collection!
@@ -538,80 +508,6 @@ return TRUE;
/*
* Function used to save to the preference file the Decryption Keys.
*/
-gboolean
-save_wlan_wep_keys(airpcap_if_info_t* info_if)
-{
-GList* key_list = NULL;
-char* tmp_key = NULL;
-guint keys_in_list,i;
-keys_cb_data_t* user_data;
-
-if(info_if == NULL) return FALSE;
-
-/* Retrieve the wlan preferences */
-wlan_prefs = prefs_find_module("wlan");
-
-/* Allocate a structure used to keep infos between the callbacks */
-user_data = (keys_cb_data_t*)g_malloc(sizeof(keys_cb_data_t));
-
-/* Number of keys in key list */
-/* Number of keys in key list */
-if(info_if->keysCollectionSize != 0)
- keys_in_list = (guint)(info_if->keysCollectionSize - sizeof(AirpcapKeysCollection))/sizeof(AirpcapKey);
-else
- keys_in_list = 0;
-
-for(i=0; i<keys_in_list; i++)
-{
-/* Only if it is a WEP key... */
-if(info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_WEP)
- {
- tmp_key = airpcap_get_key_string(info_if->keysCollection->Keys[i]);
- key_list = g_list_append(key_list,g_strdup(tmp_key));
- g_free(tmp_key);
- }
-}
-
-/* Now we know the exact number of WEP keys in the list, so store it ... */
-keys_in_list = g_list_length(key_list);
-
-/* Fill the structure */
-user_data->list = key_list;
-user_data->current_index = 0;
-user_data->number_of_keys= keys_in_list;
-
-/* Retrieve the wlan preferences */
-wlan_prefs = prefs_find_module("wlan");
-
-/* Run the callback on each 802.11 preference */
-prefs_pref_foreach(wlan_prefs, set_wep_key, (gpointer)user_data);
-
-/* Signal that we've changed things, and run the 802.11 dissector's
- * callback */
-wlan_prefs->prefs_changed = TRUE;
-
-/* Apply changes for the specified preference */
-prefs_apply(wlan_prefs);
-
-/* FREE MEMORY */
-/* free the WEP key string */
-for(i=0;i<g_list_length(user_data->list);i++)
- {
- g_free(g_list_nth(user_data->list,i)->data);
- }
-
-/* free the (empty) list */
-g_list_free(user_data->list);
-
-/* free the user_data structure */
-g_free(user_data);
-
-return TRUE;
-}
-
-/*
- * Function used to save to the preference file the Decryption Keys.
- */
int
save_wlan_driver_wep_keys()
{
@@ -624,6 +520,9 @@ airpcap_if_info_t* fake_info_if = NULL;
/* Create the fake_info_if from the first adapter of the list */
fake_info_if = airpcap_driver_fake_if_info_new();
+if(fake_info_if == NULL)
+ return FALSE;
+
/* Retrieve the wlan preferences */
wlan_prefs = prefs_find_module("wlan");
@@ -640,7 +539,7 @@ else
for(i=0; i<keys_in_list; i++)
{
/* Only if it is a WEP key... */
-if(fake_info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_WEP)
+if(fake_info_if->keysCollection->Keys[i].KeyType == AIRPDCAP_KEY_TYPE_WEP)
{
tmp_key = airpcap_get_key_string(fake_info_if->keysCollection->Keys[i]);
key_list = g_list_append(key_list,g_strdup(tmp_key));
@@ -698,6 +597,7 @@ char* tmp_key = NULL;
guint keys_in_list,i;
keys_cb_data_t* user_data;
airpcap_if_info_t* fake_info_if = NULL;
+decryption_key_t* tmp_dk;
/* Retrieve the wlan preferences */
wlan_prefs = prefs_find_module("wlan");
@@ -731,7 +631,9 @@ prefs_apply(wlan_prefs);
/* free the WEP key string */
for(i=0;i<g_list_length(user_data->list);i++)
{
- g_free(g_list_nth(user_data->list,i)->data);
+ tmp_dk = (decryption_key_t*)g_list_nth(user_data->list,i)->data;
+ g_string_free(tmp_dk->key,TRUE);
+ if(tmp_dk->ssid != NULL) g_string_free(tmp_dk->ssid,TRUE);
}
/* free the (empty) list */
@@ -770,6 +672,7 @@ PAirpcapHandle
airpcap_if_open(PCHAR name, PCHAR err)
{
if (!AirpcapLoaded) return NULL;
+ if (name == NULL) return NULL;
return g_PAirpcapOpen(name,err);
}
@@ -972,8 +875,12 @@ airpcap_if_info_new(char *name, char *description)
PAirpcapHandle ad;
gchar ebuf[AIRPCAP_ERRBUF_SIZE];
- airpcap_if_info_t *if_info;
+ airpcap_if_info_t *if_info = NULL;
+ /* Probably I have to switch on the leds!!! */
+ ad = airpcap_if_open(name, ebuf);
+ if(ad)
+ {
if_info = g_malloc(sizeof (airpcap_if_info_t));
if_info->name = g_strdup(name);
if (description == NULL)
@@ -982,11 +889,6 @@ gchar ebuf[AIRPCAP_ERRBUF_SIZE];
if_info->description = g_strdup(description);
if_info->ip_addr = NULL;
if_info->loopback = FALSE;
-
- /* Probably I have to switch on the leds!!! */
- ad = airpcap_if_open(if_info->name, ebuf);
- if(ad)
- {
airpcap_if_get_fcs_validation(ad,&(if_info->CrcValidationOn));
airpcap_if_get_fcs_presence(ad,&(if_info->IsFcsPresent));
airpcap_if_get_link_type(ad,&(if_info->linkType));
@@ -1016,6 +918,10 @@ airpcap_driver_fake_if_info_new()
airpcap_if_info_t *if_info = NULL;
airpcap_if_info_t *fake_if_info = NULL;
+ /* Maybe for some reason no airpcap adapter is found */
+ if(airpcap_if_list == NULL)
+ return NULL;
+
/*
* Retrieve the first AirPcap adapter available. If no interface is found,
* it is not possible to retrieve the driver's settings, so return NULL.
@@ -1024,16 +930,15 @@ airpcap_driver_fake_if_info_new()
if(if_info == NULL)
return NULL;
+ /* Open the 'fake' adapter */
+ ad = airpcap_if_open(if_info->name, ebuf);
+ if(ad)
+ {
fake_if_info = g_malloc(sizeof (airpcap_if_info_t));
fake_if_info->name = g_strdup(if_info->name);
fake_if_info->description = g_strdup(if_info->description);
fake_if_info->loopback = FALSE;
fake_if_info->ip_addr = NULL;
-
- /* Open the 'fake' adapter */
- ad = airpcap_if_open(if_info->name, ebuf);
- if(ad)
- {
airpcap_if_get_driver_decryption_state(ad, &(fake_if_info->DecryptionOn));
airpcap_if_get_fcs_validation(ad,&(fake_if_info->CrcValidationOn));
airpcap_if_get_fcs_presence(ad,&(fake_if_info->IsFcsPresent));
@@ -1343,9 +1248,10 @@ unsigned int j = 0;
unsigned int l = 0;
gchar *dst,*src;
+dst = NULL;
src = NULL;
-if(key.KeyType == AIRPCAP_KEYTYPE_WEP)
+if(key.KeyType == AIRPDCAP_KEY_TYPE_WEP)
{
if(key.KeyLen != 0)
{
@@ -1365,11 +1271,11 @@ if(key.KeyType == AIRPCAP_KEYTYPE_WEP)
g_free(src);
}
}
-else if(key.KeyType == AIRPCAP_KEYTYPE_TKIP)
+else if(key.KeyType == AIRPDCAP_KEY_TYPE_WPA_PWD)
{
/* XXX - Add code here */
}
-else if(key.KeyType == AIRPCAP_KEYTYPE_CCMP)
+else if(key.KeyType == AIRPDCAP_KEY_TYPE_WPA_PMK)
{
/* XXX - Add code here */
}
@@ -1656,12 +1562,12 @@ g_print("KEY : %s\n",tmp->key->str);
g_print("BITS: %d\n",tmp->bits);
-if(tmp->type == AIRPCAP_KEYTYPE_WEP)
+if(tmp->type == AIRPDCAP_KEY_TYPE_WEP)
g_print("TYPE: %s\n",AIRPCAP_WEP_KEY_STRING);
-else if(tmp->type == AIRPCAP_KEYTYPE_TKIP)
- g_print("TYPE: %s\n",AIRPCAP_WPA_KEY_STRING);
-else if(tmp->type == AIRPCAP_KEYTYPE_CCMP)
- g_print("TYPE: %s\n",AIRPCAP_WPA2_KEY_STRING);
+else if(tmp->type == AIRPDCAP_KEY_TYPE_WPA_PWD)
+ g_print("TYPE: %s\n",AIRPCAP_WPA_PWD_KEY_STRING);
+else if(tmp->type == AIRPDCAP_KEY_TYPE_WPA_PMK)
+ g_print("TYPE: %s\n",AIRPCAP_WPA_BIN_KEY_STRING);
else
g_print("TYPE: %s\n","???");
@@ -1696,7 +1602,7 @@ else
for(i=0; i<keys_in_list; i++)
{
/* Different things to do depending on the key type */
-if(info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_WEP)
+if(info_if->keysCollection->Keys[i].KeyType == AIRPDCAP_KEY_TYPE_WEP)
{
/* allocate memory for the new key item */
new_key = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
@@ -1719,11 +1625,11 @@ if(info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_WEP)
/* Append the new element in the list */
key_list = g_list_append(key_list,(gpointer)new_key);
}
-else if(info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_TKIP)
+else if(info_if->keysCollection->Keys[i].KeyType == AIRPDCAP_KEY_TYPE_WPA_PWD)
{
/* XXX - Not supported yet */
}
-else if(info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_CCMP)
+else if(info_if->keysCollection->Keys[i].KeyType == AIRPDCAP_KEY_TYPE_WPA_PMK)
{
/* XXX - Not supported yet */
}
@@ -1768,7 +1674,7 @@ else
for(i=0; i<keys_in_list; i++)
{
/* Different things to do depending on the key type */
-if(fake_info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_WEP)
+if(fake_info_if->keysCollection->Keys[i].KeyType == AIRPDCAP_KEY_TYPE_WEP)
{
/* allocate memory for the new key item */
new_key = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
@@ -1777,7 +1683,7 @@ if(fake_info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_WEP)
/* KEY */
tmp_key = airpcap_get_key_string(fake_info_if->keysCollection->Keys[i]);
new_key->key = g_string_new(tmp_key);
- g_free(tmp_key);
+ if(tmp_key != NULL) g_free(tmp_key);
/* BITS */
new_key->bits = new_key->key->len *4; /* every char is 4 bits in WEP keys (it is an exadecimal number) */
@@ -1791,11 +1697,11 @@ if(fake_info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_WEP)
/* Append the new element in the list */
key_list = g_list_append(key_list,(gpointer)new_key);
}
-else if(fake_info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_TKIP)
+else if(fake_info_if->keysCollection->Keys[i].KeyType == AIRPDCAP_KEY_TYPE_WPA_PWD)
{
/* XXX - Not supported yet */
}
-else if(fake_info_if->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_CCMP)
+else if(fake_info_if->keysCollection->Keys[i].KeyType == AIRPDCAP_KEY_TYPE_WPA_PMK)
{
/* XXX - Not supported yet */
}
@@ -1814,15 +1720,11 @@ GList*
get_wireshark_keys()
{
keys_cb_data_t* wep_user_data = NULL;
-keys_cb_data_t* wpa_user_data = NULL;
-keys_cb_data_t* wpa2_user_data= NULL;
gchar *tmp = NULL;
GList* final_list = NULL;
GList* wep_final_list = NULL;
-GList* wpa_final_list = NULL;
-GList* wpa2_final_list = NULL;
/* Retrieve the wlan preferences */
wlan_prefs = prefs_find_module("wlan");
@@ -1838,23 +1740,15 @@ wep_user_data->number_of_keys= 0; /* Still unknown */
/* Run the callback on each 802.11 preference */
/* XXX - Right now, only WEP keys will be loaded */
prefs_pref_foreach(wlan_prefs, get_wep_key, (gpointer)wep_user_data);
-prefs_pref_foreach(wlan_prefs, get_wpa_key, (gpointer)wpa_user_data);
-prefs_pref_foreach(wlan_prefs, get_wpa2_key, (gpointer)wpa2_user_data);
/* Copy the list field in the user data structure pointer into the final_list */
if(wep_user_data != NULL) wep_final_list = wep_user_data->list;
-if(wpa_user_data != NULL) wpa_final_list = wpa_user_data->list;
-if(wpa2_user_data != NULL) wpa2_final_list = wpa2_user_data->list;
/* XXX - Merge the three lists!!!!! */
final_list = wep_final_list;
/* free the wep_user_data structure */
g_free(wep_user_data);
-/* free the wpa_user_data structure */
-g_free(wpa_user_data);
-/* free the wpa2_user_data structure */
-g_free(wpa2_user_data);
return final_list;
}
@@ -2056,6 +1950,10 @@ keys_are_equals(decryption_key_t *k1,decryption_key_t *k2)
if((k1==NULL) || (k2==NULL))
return FALSE;
+/* XXX - Remove this check when we will have the WPA/WPA2 decryption in the Driver! */
+//if( (k1->type == AIRPDCAP_KEY_TYPE_WPA_PWD) || (k2->type == AIRPDCAP_KEY_TYPE_WPA_PWD) || (k1->type == AIRPDCAP_KEY_TYPE_WPA_PMK) || (k2->type == AIRPDCAP_KEY_TYPE_WPA_PMK) )
+// return TRUE;
+
if( g_string_equal(k1->key,k2->key) &&
(k1->bits == k2->bits) && /* If the previous is TRUE, this must be TRUE as well */
k1->type == k2->type)
@@ -2085,26 +1983,68 @@ gboolean
key_lists_are_equal(GList* list1, GList* list2)
{
guint n1=0,n2=0;
-guint i;
+/* XXX - Remove */
+guint wep_n1=0,wep_n2=0;
+GList *wep_list1=NULL;
+GList *wep_list2=NULL;
+/* XXX - END*/
+guint i,j;
decryption_key_t *dk1=NULL,*dk2=NULL;
n1 = g_list_length(list1);
n2 = g_list_length(list2);
/*
+ * XXX - START : Retrieve the aublists of WEP keys!!! This is needed only 'till Driver WPA decryption
+ * is not implemented.
+ */
+for(i=0;i<n1;i++)
+ {
+ dk1=(decryption_key_t*)g_list_nth_data(list1,i);
+ if(dk1->type == AIRPDCAP_KEY_TYPE_WEP)
+ {
+ wep_list1 = g_list_append(wep_list1,(gpointer)dk1);
+ wep_n1++;
+ }
+ }
+for(i=0;i<n2;i++)
+ {
+ dk2=(decryption_key_t*)g_list_nth_data(list2,i);
+ if(dk2->type == AIRPDCAP_KEY_TYPE_WEP)
+ {
+ wep_list2 = g_list_append(wep_list2,(gpointer)dk2);
+ wep_n2++;
+ }
+ }
+
+/*
+ * XXX - END : Remove from START to END when the WPA/WPA2 decryption will be implemented in
+ * the Driver
+ */
+
+/*
* Commented, because in the new AirPcap version all the keys will be saved
* into the driver, and all the keys for every specific adapter will be
* removed. This means that this check will always fail... and the user will
* always be asked what to do... and it doesn't make much sense.
*/
-if(n1 != n2) return FALSE;
+/* if(n1 != n2) return FALSE; */
+if(wep_n1 != wep_n2) return FALSE;
-for(i=0;i<n1;i++)
+n1 = wep_n1;
+n2 = wep_n2;
+
+/*for(i=0;i<n1;i++)
{
dk1=(decryption_key_t*)g_list_nth_data(list1,i);
dk2=(decryption_key_t*)g_list_nth_data(list2,i);
if(!g_string_equal(dk1->key,dk2->key)) return FALSE;
+}*/
+for(i=0;i<n2;i++)
+{
+dk2=(decryption_key_t*)g_list_nth_data(wep_list2,i);
+if(!key_is_in_list(dk2,wep_list1)) return FALSE;
}
return TRUE;
@@ -2426,4 +2366,359 @@ get_runtime_airpcap_version(GString *str)
vrev, build);
}
+/*
+ * Returns the decryption_key_t struct given a string describing the key.
+ * Returns NULL if the key_string cannot be parsed.
+ */
+decryption_key_t*
+parse_key_string(gchar* input_string)
+{
+gchar *type;
+gchar *key;
+gchar *ssid;
+
+GString *key_string,
+ *ssid_string;
+
+gchar **tokens;
+guint n = 0;
+guint i;
+
+decryption_key_t *dk;
+
+if(input_string == NULL)
+ return NULL;
+
+/*
+* Parse the input_string. It should be in the form <key type>:<key data>[:<ssid>]
+* XXX - For backward compatibility, the a WEP key can be just a string of hexadecimal
+* characters (if WEP key is wrong, null will be returned...).
+*/
+tokens = g_strsplit(input_string,":",0);
+
+/* Tokens is a null termiated array of strings ... */
+while(tokens[n] != NULL)
+ n++;
+
+if(n == 0)
+{
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+}
+
+/*
+* 'n' contains the number of tokens. If the key string is correct, we should have
+* 2 or 3 tokens... If we have 1 token, it can be an 'old style' WEP key... check for it...
+*/
+if(n == 1)
+{
+ /* Maybe it is an 'old style' WEP key */
+ key = g_strdup(tokens[0]);
+
+ /* Create a new string */
+ key_string = g_string_new(key);
+
+ /* Check if it is a correct WEP key */
+ if( ((key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((key_string->len) < WEP_KEY_MIN_CHAR_SIZE))
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ if((key_string->len % 2) != 0)
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ for(i = 0; i < key_string->len; i++)
+ {
+ if(!g_ascii_isxdigit(key_string->str[i]))
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+ }
+
+ /* Key is correct! It was probably an 'old style' WEP key */
+ /* Create the decryption_key_t structure, fill it and return it*/
+ dk = g_malloc(sizeof(decryption_key_t));
+
+ dk->type = AIRPDCAP_KEY_TYPE_WEP;
+ dk->key = g_string_new(key);
+ dk->bits = dk->key->len * 4;
+ dk->ssid = NULL;
+
+ g_string_free(key_string, TRUE);
+ g_free(key);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+
+ return dk;
+}
+
+/* There were at least 2 tokens... copy the type value */
+type = g_strdup(tokens[0]);
+
+/*
+* The second token is the key (right now it doesn't matter
+* if it is a passphrase or an hexadecimal one)
+*/
+key = g_strdup(tokens[1]);
+
+/* Lower case... */
+g_strdown(type);
+g_strdown(key);
+
+/* Maybe there is a third token (an ssid, if everything else is ok) */
+if(n >= 3)
+{
+ ssid = g_strdup(tokens[2]);
+ g_strdown(ssid);
+}
+else
+{
+ ssid = NULL;
+}
+
+/*
+* Now the initial key string has been divided in two/three tokens... let's see
+* which kind of key it is, and if it is the correct form
+*/
+if(g_strcasecmp(type,STRING_KEY_TYPE_WEP) == 0) /* WEP key */
+{
+ /* Create a new string */
+ key_string = g_string_new(key);
+
+ /* Check if it is a correct WEP key */
+ if( ((key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((key_string->len) < WEP_KEY_MIN_CHAR_SIZE))
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ if((key_string->len % 2) != 0)
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ for(i = 0; i < key_string->len; i++)
+ {
+ if(!g_ascii_isxdigit(key_string->str[i]))
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+ }
+
+ dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+
+ dk->type = AIRPDCAP_KEY_TYPE_WEP;
+ dk->key = g_string_new(key);
+ dk->bits = dk->key->len * 4;
+ dk->ssid = NULL;
+
+ g_string_free(key_string, TRUE);
+ g_free(key);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return dk;
+}
+else if(g_strcasecmp(type,STRING_KEY_TYPE_WPA_PSK) == 0) /* WPA key */
+{
+ /* Create a new string */
+ key_string = g_string_new(key);
+
+ /* Two tokens means that the user should have entered a WPA-BIN key ... */
+ if( ((key_string->len) != WPA_PSK_KEY_CHAR_SIZE))
+ {
+ g_string_free(key_string, TRUE);
+
+ g_free(type);
+ g_free(key);
+ /* No ssid has been created ... */
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ for(i = 0; i < key_string->len; i++)
+ {
+ if(!g_ascii_isxdigit(key_string->str[i]))
+ {
+ g_string_free(key_string, TRUE);
+ /* No ssid_string has been created ... */
+
+ g_free(type);
+ g_free(key);
+ /* No ssid has been created ... */
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+ }
+
+ /* Key was correct!!! Create the new decryption_key_t ... */
+ dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+
+ dk->type = AIRPDCAP_KEY_TYPE_WPA_PMK;
+ dk->key = g_string_new(key);
+ dk->bits = dk->key->len * 4;
+ dk->ssid = NULL;
+
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ g_free(type);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return dk;
+}
+else if(g_strcasecmp(type,STRING_KEY_TYPE_WPA_PWD) == 0) /* WPA key *//* If the number of tokens is more than three, we accept the string... if the first three tokens are correct... */
+{
+ /* Create a new string */
+ key_string = g_string_new(key);
+ ssid_string = NULL;
+
+
+ /* Three (or more) tokens mean that the user entered a WPA-PWD key ... */
+ if( ((key_string->len) > WPA_KEY_MAX_CHAR_SIZE) || ((key_string->len) < WPA_KEY_MIN_CHAR_SIZE))
+ {
+ g_string_free(key_string, TRUE);
+
+ g_free(type);
+ g_free(key);
+ g_free(ssid);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ if(ssid != NULL) /* more than three tokens found, means that the user specified the ssid */
+ {
+ ssid_string = g_string_new(ssid);
+
+ /*
+ * XXX - Maybe we need some check on the characters? I'm not sure if only standard ASCII are ok...
+ */
+ if( ((ssid_string->len) > WPA_SSID_MAX_CHAR_SIZE) || ((ssid_string->len) < WPA_SSID_MIN_CHAR_SIZE))
+ {
+ g_string_free(key_string, TRUE);
+ g_string_free(ssid_string, TRUE);
+
+ g_free(type);
+ g_free(key);
+ g_free(ssid);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+ }
+
+ /* Key was correct!!! Create the new decryption_key_t ... */
+ dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+
+ dk->type = AIRPDCAP_KEY_TYPE_WPA_PWD;
+ dk->key = g_string_new(key);
+ dk->bits = 256; /* This is the lenght of the array pf bytes that will be generated using key+ssid ...*/
+ if(ssid != NULL)
+ dk->ssid = g_string_new(ssid);
+ else
+ dk->ssid = NULL;
+
+ g_string_free(key_string, TRUE);
+ if(ssid_string != NULL) g_string_free(ssid_string, TRUE);
+
+ g_free(type);
+ g_free(key);
+ if(ssid != NULL) g_free(ssid);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return dk;
+}
+
+/* Something was wrong ... free everything */
+
+g_free(type);
+g_free(key);
+if(ssid != NULL) g_free(ssid); /* It is not always present */
+/* Free the array of strings */
+g_strfreev(tokens);
+
+return NULL;
+}
+
+/*
+ * Returns a newly allocated string representing the given decryption_key_t struct, or NULL if
+ * something is wrong...
+ */
+gchar*
+get_key_string(decryption_key_t* dk)
+{
+gchar* output_string = NULL;
+
+ if(dk == NULL)
+ return NULL;
+
+#ifdef HAVE_AIRPDCAP
+ if(dk->type == AIRPDCAP_KEY_TYPE_WEP)
+ {
+ if(dk->key == NULL) /* Should NOT happen at all... */
+ return NULL;
+
+ output_string = g_strdup_printf("%s:%s",STRING_KEY_TYPE_WEP,dk->key->str);
+ }
+ else if(dk->type == AIRPDCAP_KEY_TYPE_WPA_PWD)
+ {
+ if(dk->key == NULL) /* Should NOT happen at all... */
+ return NULL;
+
+ if(dk->ssid == NULL)
+ output_string = g_strdup_printf("%s:%s",STRING_KEY_TYPE_WPA_PWD,dk->key->str);
+ else
+ output_string = g_strdup_printf("%s:%s:%s",STRING_KEY_TYPE_WPA_PWD,dk->key->str,dk->ssid->str);
+ }
+ else if(dk->type == AIRPDCAP_KEY_TYPE_WPA_PMK)
+ {
+ if(dk->key == NULL) /* Should NOT happen at all... */
+ return NULL;
+
+ output_string = g_strdup_printf("%s:%s",STRING_KEY_TYPE_WPA_PSK,dk->key->str);
+ }
+ else
+ {
+ return NULL;
+ }
+#else /* not HAVE_AIRPDCAP*/
+output_string = g_strdup(dk->key->str);
+#endif
+
+return output_string;
+}
+
#endif /* _WIN32 */
diff --git a/airpcap_loader.h b/airpcap_loader.h
index 5260fe0403..70a28465dc 100644
--- a/airpcap_loader.h
+++ b/airpcap_loader.h
@@ -45,9 +45,51 @@
*/
#define WEP_KEY_MAX_BIT_SIZE (WEP_KEY_MAX_SIZE*8)
+#define WEP_KEY_MIN_CHAR_SIZE 2
+#define WEP_KEY_MIN_BIT_SIZE 8
+
+/*
+ * XXX - The next #define should probably be moved in airpcap.h,
+ * near WEP_KEY_MAX_SIZE ...
+ */
+#define WPA_KEY_MAX_SIZE 63 /* 63 chars followed by a '\0' */
+
+#define WPA_KEY_MAX_CHAR_SIZE (WPA_KEY_MAX_SIZE*1)
+#define WPA_KEY_MAX_BIT_SIZE (WPA_KEY_MAX_SIZE*8)
+#define WPA_KEY_MIN_CHAR_SIZE 8
+#define WPA_KEY_MIN_BIT_SIZE (WPA_KEY_MIN_CHAR_SIZE*8)
+
+/*
+ * XXX - The next #define should probably be moved in airpcap.h,
+ * near WEP_KEY_MAX_SIZE ...
+ */
+#define WPA_SSID_MAX_SIZE 32
+
+#define WPA_SSID_MAX_CHAR_SIZE (WPA_SSID_MAX_SIZE*1)
+#define WPA_SSID_MAX_BIT_SIZE (WPA_SSID_MAX_SIZE*8)
+#define WPA_SSID_MIN_CHAR_SIZE 0
+#define WPA_SSID_MIN_BIT_SIZE (WPA_SSID_MIN_CHAR_SIZE*8)
+
+/*
+ * User can enter the binary PSK, instead of the passphrase+ssid...
+ */
+#define WPA_PSK_KEY_SIZE 32 /* Fixed size, 32 bytes (256bit) */
+#define WPA_PSK_KEY_CHAR_SIZE (WPA_PSK_KEY_SIZE*2)
+#define WPA_PSK_KEY_BIT_SIZE (WPA_PSK_KEY_SIZE*8)
+
#define AIRPCAP_WEP_KEY_STRING "WEP"
-#define AIRPCAP_WPA_KEY_STRING "WPA"
-#define AIRPCAP_WPA2_KEY_STRING "WPA2"
+/*
+ * XXX - WPA_PWD is the passphrase+ssid and WPA-PSK is the hexadecimal key
+ */
+#define AIRPCAP_WPA_PWD_KEY_STRING "WPA-PWD"
+#define AIRPCAP_WPA_BIN_KEY_STRING "WPA-PSK"
+
+/*
+ * Key string defines
+ */
+#define STRING_KEY_TYPE_WEP "wep"
+#define STRING_KEY_TYPE_WPA_PWD "wpa-pwd"
+#define STRING_KEY_TYPE_WPA_PSK "wpa-psk"
#define AIRPCAP_DLL_OK 0
#define AIRPCAP_DLL_OLD 1
@@ -110,15 +152,6 @@ typedef struct {
} airpcap_if_info_t;
/*
- * Struct used to store infos to pass to the preferences manager callbacks
- */
-typedef struct {
- GList *list;
- int current_index;
- int number_of_keys;
-} keys_cb_data_t;
-
-/*
* Struct to store infos about a specific decryption key.
*/
typedef struct {
@@ -128,6 +161,15 @@ typedef struct {
guint type;
} decryption_key_t;
+/*
+ * Struct used to store infos to pass to the preferences manager callbacks
+ */
+typedef struct {
+ GList *list;
+ int current_index;
+ int number_of_keys;
+} keys_cb_data_t;
+
/* Airpcap interface list */
extern GList *airpcap_if_list;
@@ -145,13 +187,6 @@ extern airpcap_if_info_t *airpcap_if_active;
* properly into the airpcap adapter.
*/
BOOL
-load_wlan_wep_keys(airpcap_if_info_t* info_if);
-
-/*
- * Function used to read the Decryption Keys from the preferences and store them
- * properly into the airpcap adapter.
- */
-BOOL
load_wlan_driver_wep_keys();
/*
@@ -553,4 +588,17 @@ get_compiled_airpcap_version(GString *str);
void
get_runtime_airpcap_version(GString *str);
+/*
+ * Returns the decryption_key_t struct given a string describing the key.
+ * Returns NULL if the key_string cannot be parsed.
+ */
+decryption_key_t*
+parse_key_string(gchar* key_string);
+
+/*
+ * Returns a newly allocated string representing the given decryption_key_t struct
+ */
+gchar*
+get_key_string(decryption_key_t* dk);
+
#endif
diff --git a/epan/dissectors/Makefile.nmake b/epan/dissectors/Makefile.nmake
index 4fc827e860..93ffda6289 100644
--- a/epan/dissectors/Makefile.nmake
+++ b/epan/dissectors/Makefile.nmake
@@ -9,7 +9,7 @@ include ..\..\config.nmake
include Makefile.common
-CFLAGS=-DHAVE_CONFIG_H /I. /I.. /I../.. $(GLIB_CFLAGS) \
+CFLAGS=-DHAVE_CONFIG_H -DHAVE_AIRPDCAP /I. /I.. /I../.. $(GLIB_CFLAGS) \
$(NET_SNMP_CFLAGS) \
$(PCRE_CFLAGS) $(GNUTLS_CFLAGS) $(NETTLE_CFLAGS) \
$(KFW_CFLAGS) \
@@ -24,9 +24,9 @@ DISSECTOR_OBJECTS = $(DISSECTOR_SRC:.c=.obj)
DISSECTOR_SUPPORT_OBJECTS = $(DISSECTOR_SUPPORT_SRC:.c=.obj)
-dissectors.lib: register.obj packet-ncp2222.c $(GENERATED_HEADER_FILES) ../../config.h $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS)
+dissectors.lib: airpdcap.lib register.obj packet-ncp2222.c $(GENERATED_HEADER_FILES) ../../config.h $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS)
@echo Linking dissectors.lib
- link /lib /out:dissectors.lib $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS)
+ link /lib /out:dissectors.lib $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS) ..\..\airpdcap\airpdcap.lib
#
# The header files listed here are built from x11-fields using Perl;
@@ -73,6 +73,12 @@ x11-declarations.h x11-register-info.h: x11-fields process-x11-fields.pl
# a register.c file for libwireshark.
# All subsequent arguments are the files to scan.
#
+
+airpdcap.lib:
+ cd ..\..\airpdcap
+ $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
+ cd ..\epan\dissectors
+
register.c: $(DISSECTOR_SRC)
!IFDEF PYTHON
@echo Making register.c (using python)
@@ -95,6 +101,9 @@ packet-ncp2222.c : ncp2222.py
!ENDIF
clean:
+ cd ..\..\airpdcap
+ $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
+ cd ..\epan\dissectors
rm -f dissectors.lib $(PDB_FILE) \
$(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS)
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index 32ad7b7d8e..3cb04b54c4 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -76,6 +76,7 @@
#ifdef HAVE_AIRPCAP
#include <airpcap.h>
+#include <airpcap_loader.h>
#else
/* XXX - This is probably a bit much */
#define MAX_ENCRYPTION_KEYS 64
@@ -107,6 +108,10 @@ static int *wep_keylens = NULL;
static void init_wepkeys(void);
static int wep_decrypt(guint8 *buf, guint32 len, int key_override);
static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len);
+#ifdef HAVE_AIRPDCAP
+/* Davide Schiera (2006-11-26): created function to decrypt WEP and WPA/WPA2 */
+static tvbuff_t *try_decrypt(tvbuff_t *tvb, guint32 offset, guint32 len, guint8 *algorithm, guint32 *sec_header, guint32 *sec_trailer);
+#endif
static int weak_iv(guchar *iv);
#define SSWAP(a,b) {guint8 tmp = s[a]; s[a] = s[b]; s[b] = tmp;}
@@ -786,6 +791,15 @@ static dissector_handle_t data_handle;
static int wlan_tap = -1;
+/* Davide Schiera (2006-11-22): including AirPDcap project */
+#ifdef HAVE_AIRPDCAP
+#include "..\..\airpdcap\airpdcap_ws.h"
+AIRPDCAP_CONTEXT airpdcap_ctx;
+#else
+int airpdcap_ctx;
+#endif
+/* Davide Schiera (2006-11-22) ---------------------------------------------- */
+
/* ************************************************************************* */
/* Return the length of the current header (in bytes) */
/* ************************************************************************* */
@@ -3286,6 +3300,17 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
} /* end of qos control field */
+#ifdef HAVE_AIRPDCAP
+ /* Davide Schiera (2006-11-21): process handshake packet with AirPDcap */
+ /* the processing will take care of 4-way handshake sessions for WPA */
+ /* and WPA2 decryption */
+ if (enable_decryption && !pinfo->fd->flags.visited) {
+ const guint8 *enc_data = tvb_get_ptr(tvb, 0, hdr_len+reported_len);
+ AirPDcapPacketProcess(&airpdcap_ctx, enc_data, hdr_len+reported_len, NULL, 0, NULL, FALSE, FALSE, TRUE, FALSE);
+ }
+ /* Davide Schiera -------------------------------------------------------- */
+#endif
+
/*
* No-data frames don't have a body.
*/
@@ -3303,37 +3328,92 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
if (IS_PROTECTED(FCF_FLAGS(fcf))) {
/*
- * It's a WEP-encrypted frame; dissect the WEP parameters and decrypt
- * the data, if we have a matching key. Otherwise display it as data.
+ * It's a WEP or WPA encrypted frame; dissect the protections parameters
+ * and decrypt the data, if we have a matching key. Otherwise display it as data.
*/
+
gboolean can_decrypt = FALSE;
proto_tree *wep_tree = NULL;
guint32 iv;
guint8 key, keybyte;
+ /* Davide Schiera (2006-11-27): define algorithms constants and macros */
+#ifdef HAVE_AIRPDCAP
+#define PROTECTION_ALG_TKIP AIRPDCAP_KEY_TYPE_TKIP
+#define PROTECTION_ALG_CCMP AIRPDCAP_KEY_TYPE_CCMP
+#define PROTECTION_ALG_WEP AIRPDCAP_KEY_TYPE_WEP
+#define PROTECTION_ALG_RSNA PROTECTION_ALG_CCMP | PROTECTION_ALG_TKIP
+#else
+#define PROTECTION_ALG_WEP 0
+#define PROTECTION_ALG_TKIP 1
+#define PROTECTION_ALG_CCMP 2
+#define PROTECTION_ALG_RSNA PROTECTION_ALG_CCMP | PROTECTION_ALG_TKIP
+#endif
+ guint8 algorithm=-1;
+ /* Davide Schiera (2006-11-27): added macros to check the algorithm */
+ /* used could be TKIP or CCMP */
+#define IS_TKIP(tvb, hdr_len) (tvb_get_guint8(tvb, hdr_len + 1) & 0x20)
+#define IS_CCMP(tvb, hdr_len) (tvb_get_guint8(tvb, hdr_len + 2) == 0)
+ /* Davide Schiera ----------------------------------------------------- */
+
+#ifdef HAVE_AIRPDCAP
+ /* Davide Schiera (2006-11-21): recorded original lengths to pass them */
+ /* to the packets process function */
+ guint32 sec_header=0;
+ guint32 sec_trailer=0;
+
+ next_tvb = try_decrypt(tvb, hdr_len, reported_len, &algorithm, &sec_header, &sec_trailer);
+#endif
+ /* Davide Schiera ----------------------------------------------------- */
+
keybyte = tvb_get_guint8(tvb, hdr_len + 3);
key = KEY_OCTET_WEP_KEY(keybyte);
if ((keybyte & KEY_EXTIV) && (len >= EXTIV_LEN)) {
/* Extended IV; this frame is likely encrypted with TKIP or CCMP */
+
+
if (tree) {
proto_item *extiv_fields;
+#ifdef HAVE_AIRPDCAP
+ /* Davide Schiera (2006-11-27): differentiated CCMP and TKIP if */
+ /* it's possible */
+ if (algorithm==PROTECTION_ALG_TKIP)
+ extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
+ "TKIP parameters");
+ else if (algorithm==PROTECTION_ALG_CCMP)
+ extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
+ "CCMP parameters");
+ else {
+ /* Davide Schiera -------------------------------------------- */
+#endif
+ /* Davide Schiera (2006-11-27): differentiated CCMP and TKIP if*/
+ /* it's possible */
+ if (IS_TKIP(tvb, hdr_len)) {
+ algorithm=PROTECTION_ALG_TKIP;
+ extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
+ "TKIP parameters");
+ } else if (IS_CCMP(tvb, hdr_len)) {
+ algorithm=PROTECTION_ALG_CCMP;
+ extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
+ "CCMP parameters");
+ } else
extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
"TKIP/CCMP parameters");
+#ifdef HAVE_AIRPDCAP
+ }
+#endif
+
wep_tree = proto_item_add_subtree (extiv_fields, ett_wep_parameters);
- /* It is unknown whether this is a TKIP or CCMP encrypted packet, so
- * display both packet number alternatives unless the ExtIV can be
- * determined to be possible only with one of the encryption protocols.
- */
- if (tvb_get_guint8(tvb, hdr_len + 1) & 0x20) {
+
+ if (algorithm==PROTECTION_ALG_TKIP) {
g_snprintf(out_buff, SHORT_STR, "0x%08X%02X%02X",
tvb_get_letohl(tvb, hdr_len + 4),
tvb_get_guint8(tvb, hdr_len),
tvb_get_guint8(tvb, hdr_len + 2));
proto_tree_add_string(wep_tree, hf_tkip_extiv, tvb, hdr_len,
EXTIV_LEN, out_buff);
- }
- if (tvb_get_guint8(tvb, hdr_len + 2) == 0) {
+ } else if (algorithm==PROTECTION_ALG_CCMP) {
g_snprintf(out_buff, SHORT_STR, "0x%08X%02X%02X",
tvb_get_letohl(tvb, hdr_len + 4),
tvb_get_guint8(tvb, hdr_len + 1),
@@ -3341,6 +3421,7 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
proto_tree_add_string(wep_tree, hf_ccmp_extiv, tvb, hdr_len,
EXTIV_LEN, out_buff);
}
+
proto_tree_add_uint(wep_tree, hf_wep_key, tvb, hdr_len + 3, 1, key);
}
@@ -3350,6 +3431,31 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
ivlen = EXTIV_LEN;
/* It is unknown whether this is TKIP or CCMP, so let's not even try to
* parse TKIP Michael MIC+ICV or CCMP MIC. */
+
+#ifdef HAVE_AIRPDCAP
+ /* Davide Schiera (2006-11-21): enable TKIP and CCMP decryption */
+ /* checking for the trailer */
+ if (next_tvb!=NULL) {
+ if (reported_len < sec_trailer) {
+ /* There is no space for a trailer, ignore it and don't decrypt */
+ ;
+ } else if (len < reported_len) {
+ /* There is space for a trailer, but we haven't capture all the */
+ /* packet. Slice off the trailer, but don't try to decrypt */
+ reported_len -= sec_trailer;
+ if (len > reported_len)
+ len = reported_len;
+ } else {
+ /* Ok, we have a trailer and the whole packet. Decrypt it! */
+ /* TODO: At the moment we won't add the trailer to the tree, */
+ /* so don't remove the trailer from the packet */
+ len -= sec_trailer;
+ reported_len -= sec_trailer;
+ can_decrypt = TRUE;
+ }
+ }
+ /* Davide Schiera -------------------------------------------------- */
+#endif
} else {
/* No Ext. IV - WEP packet */
/*
@@ -3386,6 +3492,10 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
reported_len -= 4;
ivlen = 4;
+ /* Davide Schiera (2006-11-27): Even if the decryption was not */
+ /* successful, set the algorithm */
+ algorithm=PROTECTION_ALG_WEP;
+
/*
* Well, this packet should, in theory, have an ICV.
* Do we have the entire packet, and does it have enough data for
@@ -3427,19 +3537,33 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
}
}
- if (!can_decrypt || (next_tvb = try_decrypt_wep(tvb, hdr_len, reported_len + 8)) == NULL) {
+#ifndef HAVE_AIRPDCAP
+ if (can_decrypt)
+ next_tvb = try_decrypt_wep(tvb, hdr_len, reported_len + 8);
+#else
+ /* Davide Schiera (2006-11-26): decrypted before parsing header and */
+ /* protection header */
+#endif
+ if (!can_decrypt || next_tvb == NULL) {
/*
* WEP decode impossible or failed, treat payload as raw data
* and don't attempt fragment reassembly or further dissection.
*/
next_tvb = tvb_new_subset(tvb, hdr_len + ivlen, len, reported_len);
- if (tree && can_decrypt)
+ if (tree) {
+ /* Davide Schiera (2006-11-21): added WEP or WPA separation */
+ if (algorithm==PROTECTION_ALG_WEP) {
+ if (can_decrypt)
proto_tree_add_uint_format (wep_tree, hf_wep_icv, tvb,
hdr_len + ivlen + len, 4,
tvb_get_ntohl(tvb, hdr_len + ivlen + len),
"WEP ICV: 0x%08x (not verified)",
tvb_get_ntohl(tvb, hdr_len + ivlen + len));
+ } else if (algorithm==PROTECTION_ALG_CCMP) {
+ } else if (algorithm==PROTECTION_ALG_TKIP) {
+ }
+ /* Davide Schiera (2006-11-21) ---------------------------------- */
if (pinfo->ethertype != ETHERTYPE_CENTRINO_PROMISC)
{
@@ -3447,8 +3571,10 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
call_dissector(data_handle, next_tvb, pinfo, tree);
goto end_of_wlan;
}
+ }
} else {
-
+ /* Davide Schiera (2006-11-21): added WEP or WPA separation */
+ if (algorithm==PROTECTION_ALG_WEP) {
if (tree)
proto_tree_add_uint_format (wep_tree, hf_wep_icv, tvb,
hdr_len + ivlen + len, 4,
@@ -3457,6 +3583,19 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
tvb_get_ntohl(tvb, hdr_len + ivlen + len));
add_new_data_source(pinfo, next_tvb, "Decrypted WEP data");
+ } else if (algorithm==PROTECTION_ALG_CCMP) {
+ add_new_data_source(pinfo, next_tvb, "Decrypted CCMP data");
+ } else if (algorithm==PROTECTION_ALG_TKIP) {
+ add_new_data_source(pinfo, next_tvb, "Decrypted TKIP data");
+ }
+ /* Davide Schiera (2006-11-21) ------------------------------------- */
+ /* Davide Schiera (2006-11-27): undefine macros and definitions */
+#undef IS_TKIP(tvb, hdr_len)
+#undef IS_CCMP(tvb, hdr_len)
+#undef PROTECTION_ALG_CCMP
+#undef PROTECTION_ALG_TKIP
+#undef PROTECTION_ALG_WEP
+ /* Davide Schiera -------------------------------------------------- */
}
/*
@@ -4805,18 +4944,42 @@ proto_register_ieee80211 (void)
"Some 802.11 cards include the FCS at the end of a packet, others do not.",
&wlan_check_fcs);
+ /* Davide Schiera (2006-11-26): changed "WEP bit" in "Protection bit" */
+ /* (according to the document IEEE Std 802.11i-2004) */
prefs_register_bool_preference(wlan_module, "ignore_wep",
- "Ignore the WEP bit",
- "Some 802.11 cards leave the WEP bit set even though the packet is decrypted.",
+ "Ignore the Protection bit",
+ "Some 802.11 cards leave the Protection bit set even though the packet is decrypted.",
&wlan_ignore_wep);
#ifndef USE_ENV
prefs_register_obsolete_preference(wlan_module, "wep_keys");
+#ifdef HAVE_AIRPDCAP
+ /* Davide Schiera (2006-11-26): added reference to WPA/WPA2 decryption */
+ prefs_register_bool_preference(wlan_module, "enable_decryption",
+ "Enable decryption", "Enable WEP and WPA/WPA2 decryption",
+ &enable_decryption);
+#else
prefs_register_bool_preference(wlan_module, "enable_decryption",
"Enable decryption", "Enable WEP decryption",
&enable_decryption);
+#endif
+
+#ifdef HAVE_AIRPDCAP
+ prefs_register_static_text_preference(wlan_module, "info_decryption_key",
+ "Key examples: 01:02:03:04:05 (40/64-bit WEP),\n"
+ "010203040506070809101111213 (104/128-bit WEP),\n"
+ "wpa-pwd:MyPassword[:MyAP]> (WPA + plaintext password [+ SSID]),\n"
+ "wpa-psk:0102030405...6061626364 (WPA + 256-bit key). "
+ "Invalid keys will be ignored.",
+ "This is just a static text");
+#else
+ prefs_register_static_text_preference(wlan_module, "info_decryption_key",
+ "Key examples: 01:02:03:04:05 (40/64-bit WEP),\n"
+ "010203040506070809101111213 (104/128-bit WEP)"
+ "This is just a static text");
+#endif
for (i = 0; i < MAX_ENCRYPTION_KEYS; i++) {
key_name = g_string_new("");
@@ -4826,11 +4989,23 @@ proto_register_ieee80211 (void)
/* prefs_register_*_preference() expects unique strings, so
* we build them using g_string_sprintf and just leave them
* allocated. */
+#ifdef HAVE_AIRPDCAP
+ g_string_sprintf(key_name, "wep_key%d", i + 1);
+ g_string_sprintf(key_title, "Key #%d", i + 1);
+ /* Davide Schiera (2006-11-26): modified keys input tooltip */
+ g_string_sprintf(key_desc,
+ "Key #%d string can be:"
+ " <wep hexadecimal key>;"
+ " WEP:<wep hexadecimal key>;"
+ " WPA-PWD:<passphrase>[:<ssid>];"
+ " WPA-PSK:<wpa hexadecimal key>", i + 1);
+#else
g_string_sprintf(key_name, "wep_key%d", i + 1);
g_string_sprintf(key_title, "WEP key #%d", i + 1);
g_string_sprintf(key_desc, "WEP key #%d bytes in hexadecimal (A:B:C:D:E) "
"[40bit], (A:B:C:D:E:F:G:H:I:J:K:L:M) [104bit], or whatever key "
"length you're using", i + 1);
+#endif
prefs_register_string_preference(wlan_module, key_name->str,
key_title->str, key_desc->str, &wep_keystr[i]);
@@ -4865,6 +5040,65 @@ proto_reg_handoff_ieee80211(void)
dissector_add("ethertype", ETHERTYPE_CENTRINO_PROMISC, ieee80211_handle);
}
+#ifdef HAVE_AIRPDCAP
+/* Davide Schiera (2006-11-26): this function will try to decrypt with WEP or */
+/* WPA and return a tvb to the caller to add a new tab. It returns the */
+/* algorithm used for decryption (WEP, TKIP, CCMP) and the header and */
+/* trailer lengths. */
+static tvbuff_t *try_decrypt(tvbuff_t *tvb, guint32 offset, guint32 len, guint8 *algorithm, guint32 *sec_header, guint32 *sec_trailer) {
+ const guint8 *enc_data;
+ guint8 *tmp = NULL;
+ tvbuff_t *decr_tvb = NULL;
+ guint32 dec_caplen;
+ guchar dec_data[AIRPDCAP_MAX_CAPLEN];
+ AIRPDCAP_KEY_ITEM used_key;
+
+ if (!enable_decryption)
+ return NULL;
+
+ /* get the entire packet */
+ enc_data = tvb_get_ptr(tvb, 0, len+offset);
+
+ /* process packet with AirPDcap */
+ if (AirPDcapPacketProcess(&airpdcap_ctx, enc_data, len+offset, dec_data, &dec_caplen, &used_key, FALSE, FALSE, FALSE, TRUE)==AIRPDCAP_RET_SUCCESS)
+ {
+ *algorithm=used_key.KeyType;
+ switch (*algorithm) {
+ case AIRPDCAP_KEY_TYPE_WEP:
+ *sec_header=AIRPDCAP_WEP_HEADER;
+ *sec_trailer=AIRPDCAP_WEP_TRAILER;
+ break;
+ case AIRPDCAP_KEY_TYPE_CCMP:
+ *sec_header=AIRPDCAP_RSNA_HEADER;
+ *sec_trailer=AIRPDCAP_CCMP_TRAILER;
+ break;
+ case AIRPDCAP_KEY_TYPE_TKIP:
+ *sec_header=AIRPDCAP_RSNA_HEADER;
+ *sec_trailer=AIRPDCAP_TKIP_TRAILER;
+ break;
+ default:
+ return NULL;
+ }
+
+ /* allocate buffer for decrypted payload */
+ if ((tmp = g_malloc(dec_caplen-offset)) == NULL)
+ return NULL; /* krap! */
+ memcpy(tmp, dec_data+offset, dec_caplen-offset);
+
+ len=dec_caplen-offset;
+
+ /* decrypt successful, let's set up a new data tvb. */
+ decr_tvb = tvb_new_real_data(tmp, len, len);
+ tvb_set_free_cb(decr_tvb, g_free);
+ tvb_set_child_real_data_tvbuff(tvb, decr_tvb);
+ } else
+ g_free(tmp);
+
+ return decr_tvb;
+}
+/* Davide Schiera ----------------------------------------------------------- */
+#endif
+
static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len) {
const guint8 *enc_data;
guint8 *tmp = NULL;
@@ -4907,6 +5141,410 @@ static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len) {
return decr_tvb;
}
+#ifdef HAVE_AIRPDCAP
+/*
+* Returns the decryption_key_t struct given a string describing the key.
+* Returns NULL if the key_string cannot be parsed.
+*/
+static decryption_key_t*
+parse_key(gchar* input_string)
+{
+ gchar *type;
+ gchar *key;
+ gchar *ssid;
+
+ GString *key_string,
+ *ssid_string;
+
+ gchar **tokens;
+ guint n = 0;
+ guint i;
+
+ decryption_key_t *dk;
+
+ if(input_string == NULL)
+ return NULL;
+
+ /*
+ * Parse the input_string. It should be in the form <key type>:<key data>[:<ssid>]
+ * XXX - For backward compatibility, the a WEP key can be just a string of hexadecimal
+ * characters (if WEP key is wrong, null will be returned...).
+ */
+ tokens = g_strsplit(input_string,":",0);
+
+ /* Tokens is a null termiated array of strings ... */
+ while(tokens[n] != NULL)
+ n++;
+
+ if(n == 0)
+ {
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ /*
+ * 'n' contains the number of tokens. If the key string is correct, we should have
+ * 2 or 3 tokens... If we have 1 token, it can be an 'old style' WEP key... check for it...
+ */
+ if(n == 1)
+ {
+ /* Maybe it is an 'old style' WEP key */
+ key = g_strdup(tokens[0]);
+
+ /* Create a new string */
+ key_string = g_string_new(key);
+
+ /* Check if it is a correct WEP key */
+ if( ((key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((key_string->len) < WEP_KEY_MIN_CHAR_SIZE))
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ if((key_string->len % 2) != 0)
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ for(i = 0; i < key_string->len; i++)
+ {
+ if(!g_ascii_isxdigit(key_string->str[i]))
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+ }
+
+ /* Key is correct! It was probably an 'old style' WEP key */
+ /* Create the decryption_key_t structure, fill it and return it*/
+ dk = g_malloc(sizeof(decryption_key_t));
+
+ dk->type = AIRPDCAP_KEY_TYPE_WEP;
+ dk->key = g_string_new(key);
+ dk->bits = dk->key->len * 4;
+ dk->ssid = NULL;
+
+ g_string_free(key_string, TRUE);
+ g_free(key);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+
+ return dk;
+ }
+
+ /* There were at least 2 tokens... copy the type value */
+ type = g_strdup(tokens[0]);
+
+ /*
+ * The second token is the key (right now it doesn't matter
+ * if it is a passphrase or an hexadecimal one)
+ */
+ key = g_strdup(tokens[1]);
+
+ /* Lower case... */
+ g_strdown(type);
+ g_strdown(key);
+
+ /* Maybe there is a third token (an ssid, if everything else is ok) */
+ if(n >= 3)
+ {
+ ssid = g_strdup(tokens[2]);
+ g_strdown(ssid);
+ }
+ else
+ {
+ ssid = NULL;
+ }
+
+ /*
+ * Now the initial key string has been divided in two/three tokens... let's see
+ * which kind of key it is, and if it is the correct form
+ */
+ if(g_strcasecmp(type,STRING_KEY_TYPE_WEP) == 0) /* WEP key */
+ {
+ /* Create a new string */
+ key_string = g_string_new(key);
+
+ /* Check if it is a correct WEP key */
+ if( ((key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((key_string->len) < WEP_KEY_MIN_CHAR_SIZE))
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ if((key_string->len % 2) != 0)
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ for(i = 0; i < key_string->len; i++)
+ {
+ if(!g_ascii_isxdigit(key_string->str[i]))
+ {
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+ }
+
+ dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+
+ dk->type = AIRPDCAP_KEY_TYPE_WEP;
+ dk->key = g_string_new(key);
+ dk->bits = dk->key->len * 4;
+ dk->ssid = NULL;
+
+ g_string_free(key_string, TRUE);
+ g_free(key);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return dk;
+ }
+ else if(g_strcasecmp(type,STRING_KEY_TYPE_WPA_PSK) == 0) /* WPA key */
+ {
+ /* Create a new string */
+ key_string = g_string_new(key);
+
+ /* Two tokens means that the user should have entered a WPA-BIN key ... */
+ if( ((key_string->len) != WPA_PSK_KEY_CHAR_SIZE))
+ {
+ g_string_free(key_string, TRUE);
+
+ g_free(type);
+ g_free(key);
+ /* No ssid has been created ... */
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ for(i = 0; i < key_string->len; i++)
+ {
+ if(!g_ascii_isxdigit(key_string->str[i]))
+ {
+ g_string_free(key_string, TRUE);
+ /* No ssid_string has been created ... */
+
+ g_free(type);
+ g_free(key);
+ /* No ssid has been created ... */
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+ }
+
+ /* Key was correct!!! Create the new decryption_key_t ... */
+ dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+
+ dk->type = AIRPDCAP_KEY_TYPE_WPA_PMK;
+ dk->key = g_string_new(key);
+ dk->bits = dk->key->len * 4;
+ dk->ssid = NULL;
+
+ g_string_free(key_string, TRUE);
+ g_free(key);
+ g_free(type);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return dk;
+ }
+ else if(g_strcasecmp(type,STRING_KEY_TYPE_WPA_PWD) == 0) /* WPA key *//* If the number of tokens is more than three, we accept the string... if the first three tokens are correct... */
+ {
+ /* Create a new string */
+ key_string = g_string_new(key);
+ ssid_string = NULL;
+
+
+ /* Three (or more) tokens mean that the user entered a WPA-PWD key ... */
+ if( ((key_string->len) > WPA_KEY_MAX_CHAR_SIZE) || ((key_string->len) < WPA_KEY_MIN_CHAR_SIZE))
+ {
+ g_string_free(key_string, TRUE);
+
+ g_free(type);
+ g_free(key);
+ g_free(ssid);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+
+ if(ssid != NULL) /* more than three tokens found, means that the user specified the ssid */
+ {
+ ssid_string = g_string_new(ssid);
+
+ /*
+ * XXX - Maybe we need some check on the characters? I'm not sure if only standard ASCII are ok...
+ */
+ if( ((ssid_string->len) > WPA_SSID_MAX_CHAR_SIZE) || ((ssid_string->len) < WPA_SSID_MIN_CHAR_SIZE))
+ {
+ g_string_free(key_string, TRUE);
+ g_string_free(ssid_string, TRUE);
+
+ g_free(type);
+ g_free(key);
+ g_free(ssid);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return NULL;
+ }
+ }
+
+ /* Key was correct!!! Create the new decryption_key_t ... */
+ dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+
+ dk->type = AIRPDCAP_KEY_TYPE_WPA_PWD;
+ dk->key = g_string_new(key);
+ dk->bits = 256; /* This is the lenght of the array pf bytes that will be generated using key+ssid ...*/
+ if(ssid != NULL)
+ dk->ssid = g_string_new(ssid);
+ else
+ dk->ssid = NULL;
+
+ g_string_free(key_string, TRUE);
+ if(ssid_string != NULL) g_string_free(ssid_string, TRUE);
+
+ g_free(type);
+ g_free(key);
+ if(ssid != NULL) g_free(ssid);
+
+ /* Free the array of strings */
+ g_strfreev(tokens);
+ return dk;
+ }
+
+ /* Something was wrong ... free everything */
+
+ g_free(type);
+ g_free(key);
+ if(ssid != NULL) g_free(ssid); /* It is not always present */
+ /* Free the array of strings */
+ g_strfreev(tokens);
+
+ return NULL;
+}
+
+#endif
+
+#ifdef HAVE_AIRPDCAP
+static
+void set_airpdcap_keys()
+{
+ guint n = 0;
+ guint i = 0;
+ guint nKeys = 0;
+ AIRPDCAP_KEY_ITEM key;
+ PAIRPDCAP_KEYS_COLLECTION keys;
+ decryption_key_t* dk = NULL;
+ GByteArray *bytes;
+ gboolean res;
+ gchar* tmpk = NULL;
+
+ keys=(PAIRPDCAP_KEYS_COLLECTION)malloc(sizeof(AIRPDCAP_KEYS_COLLECTION));
+ keys->nKeys = 0;
+
+ for(i = 0; i < MAX_ENCRYPTION_KEYS; i++)
+ {
+ tmpk = g_strdup(wep_keystr[i]);
+
+ dk = parse_key(tmpk);
+
+ if(dk != NULL)
+ {
+ if(dk->type == AIRPDCAP_KEY_TYPE_WEP)
+ {
+ key.KeyType = AIRPDCAP_KEY_TYPE_WEP;
+
+ bytes = g_byte_array_new();
+ res = hex_str_to_bytes(dk->key->str, bytes, FALSE);
+
+ if (dk->key->str && res && bytes->len > 0)
+ {
+ /*
+ * WEP key is correct (well, the can be even or odd, so it is not
+ * a real check, I think... is a check performed somewhere in the
+ * AirPDcap function??? )
+ */
+ memcpy(key.KeyData.Wep.WepKey,bytes->data,bytes->len);
+ key.KeyData.Wep.WepKeyLen = bytes->len;
+ keys->Keys[keys->nKeys] = key;
+ keys->nKeys++;
+ }
+ }
+ else if(dk->type == AIRPDCAP_KEY_TYPE_WPA_PWD)
+ {
+ key.KeyType = AIRPDCAP_KEY_TYPE_WPA_PWD;
+
+ /* XXX - Maybe check the lenght passed... */
+ memcpy(key.KeyData.Wpa.UserPwd.Passphrase,dk->key->str,dk->key->len+1);
+
+ if(dk->ssid != NULL)
+ {
+ if(dk->ssid->len > 0)
+ {
+ memcpy(key.KeyData.Wpa.UserPwd.Ssid,dk->ssid->str,dk->ssid->len+1);
+ key.KeyData.Wpa.UserPwd.SsidLen = dk->ssid->len;
+ }
+ else /* The GString is not NULL, but the 'ssid' name is just "\0" */
+ {
+ key.KeyData.Wpa.UserPwd.SsidLen = 0;
+ }
+ }
+ else
+ {
+ key.KeyData.Wpa.UserPwd.SsidLen = 0;
+ }
+
+ keys->Keys[keys->nKeys] = key;
+ keys->nKeys++;
+ }
+ else if(dk->type == AIRPDCAP_KEY_TYPE_WPA_PMK)
+ {
+ key.KeyType = AIRPDCAP_KEY_TYPE_WPA_PMK;
+
+ bytes = g_byte_array_new();
+ res = hex_str_to_bytes(dk->key->str, bytes, FALSE);
+
+ /* XXX - PAss the correct array of bytes... */
+ memcpy(key.KeyData.Wpa.Pmk,bytes->data,bytes->len);
+
+ keys->Keys[keys->nKeys] = key;
+ keys->nKeys++;
+ }
+ }
+ }
+
+ /* Now set the keys */
+ AirPDcapSetKeys(&airpdcap_ctx,keys->Keys,keys->nKeys);
+
+ if(tmpk != NULL) g_free(tmpk);
+}
+#endif
/* de-weps the block. if successful, buf* will point to the data start. */
static int wep_decrypt(guint8 *buf, guint32 len, int keyidx) {
@@ -5030,6 +5668,18 @@ static void init_wepkeys(void) {
}
}
+#ifdef HAVE_AIRPDCAP
+ /*
+ * XXX - AirPDcap - That God sends it to us beautiful (che dio ce la mandi bona)
+ * The next lines will add a key to the AirPDcap context. The keystring will be added
+ * to the old WEP array too, but we don't care, because the packets will come here
+ * already decrypted... One of these days we will fix this too
+ */
+ set_airpdcap_keys();
+
+ /* END AirPDcap */
+#endif
+
wep_keys = g_malloc0(num_wepkeys * sizeof(guint8*));
wep_keylens = g_malloc(num_wepkeys * sizeof(int));
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index 137959803a..e658bc0117 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -16,6 +16,7 @@ add_new_data_source
add_oid_name
add_oid_str_name
AdmissionRejectReason_vals DATA
+airpdcap_ctx DATA
ansi_a_bsmap_strings DATA
ansi_a_dtap_strings DATA
ansi_a_ios401_bsmap_strings DATA
diff --git a/gtk/Makefile.nmake b/gtk/Makefile.nmake
index 0472fa5a18..457cf24c72 100644
--- a/gtk/Makefile.nmake
+++ b/gtk/Makefile.nmake
@@ -7,7 +7,7 @@ include ..\config.nmake
############### no need to modify below this line #########
-CFLAGS=-DHAVE_CONFIG_H /I.. /I../wiretap $(GTK_CFLAGS) $(GNUTLS_CFLAGS) \
+CFLAGS=-DHAVE_CONFIG_H -DHAVE_AIRPDCAP /I.. /I../wiretap $(GTK_CFLAGS) $(GNUTLS_CFLAGS) \
/I$(PCAP_DIR)\WPCAP\LIBPCAP /I$(PCAP_DIR)\WPCAP\LIBPCAP\bpf \
/I$(PCAP_DIR)\WPCAP\LIBPCAP\lbl \
/I$(PCAP_DIR)\include $(NET_SNMP_CFLAGS) \
@@ -55,7 +55,7 @@ WIRESHARK_WIN32_GTK_OBJECTS = $(WIRESHARK_WIN32_GTK_SRC:.c=.obj)
libui.lib : ..\config.h $(WIRESHARK_WIN32_GTK_OBJECTS) $(WIRESHARK_TAP_OBJECTS)
- link /lib /out:libui.lib $(WIRESHARK_WIN32_GTK_OBJECTS) $(WIRESHARK_TAP_OBJECTS) winmm.lib
+ link /lib /out:libui.lib $(WIRESHARK_WIN32_GTK_OBJECTS) $(WIRESHARK_TAP_OBJECTS) winmm.lib ..\airpdcap\airpdcap.lib
wireshark-tap-register.c: $(WIRESHARK_TAP_SRC) ../make-tapreg-dotc Makefile.common
@echo Making wireshark-tap-register.c
diff --git a/gtk/airpcap_dlg.c b/gtk/airpcap_dlg.c
index ecde5677af..ec1451023c 100644
--- a/gtk/airpcap_dlg.c
+++ b/gtk/airpcap_dlg.c
@@ -135,14 +135,14 @@ airpcap_if_info_t* if_info = NULL;
* Callback for the select row event in the key list widget
*/
void
-on_key_ls_select_row(GtkWidget *widget,
+on_key_ls_select_row(GtkWidget *widget,
gint row,
gint column,
GdkEventButton *event,
gpointer data)
{
airpcap_key_ls_selected_info_t* selected_item;
-
+
selected_item = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_SELECTED_KEY_LIST_ITEM_KEY);
selected_item->row = row;
@@ -160,7 +160,7 @@ on_key_ls_unselect_row(GtkWidget *widget,
gpointer data)
{
airpcap_key_ls_selected_info_t* selected_item;
-
+
selected_item = OBJECT_GET_DATA(GTK_WIDGET(data),AIRPCAP_ADVANCED_SELECTED_KEY_LIST_ITEM_KEY);
selected_item->row = NO_ROW_SELECTED;
@@ -208,6 +208,8 @@ on_edit_type_en_changed(GtkWidget *w, gpointer data)
GtkWidget *edit_key_w;
GtkWidget *edit_ssid_te;
GtkWidget *type_te;
+GtkWidget *key_lb;
+GtkWidget *ssid_lb;
gchar* type_text = NULL;
@@ -215,22 +217,49 @@ edit_key_w = GTK_WIDGET(data);
type_te = w;
edit_ssid_te = OBJECT_GET_DATA(edit_key_w,AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY);
+key_lb = OBJECT_GET_DATA(edit_key_w,AIRPCAP_ADVANCED_EDIT_KEY_KEY_LABEL_KEY);
+ssid_lb = OBJECT_GET_DATA(edit_key_w,AIRPCAP_ADVANCED_EDIT_KEY_SSID_LABEL_KEY);
type_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(type_te)));
if(string_is_not_empty(type_text))
{
- /*
- * If it is a WEP key, no SSID is required! Gray out rhe entry text so
+ /*
+ * If it is a WEP key, no SSID is required! Gray out rhe entry text so
* it doesn't create confusion ...
*/
if(g_strcasecmp(type_text,AIRPCAP_WEP_KEY_STRING) == 0)
{
gtk_widget_set_sensitive(edit_ssid_te,FALSE);
+ /*
+ * Maybe the user has already entered some text into the SSID field
+ * and then switched to WEP...
+ */
+ gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),"");
+ gtk_label_set_text(GTK_LABEL(key_lb),"Key");
+ gtk_label_set_text(GTK_LABEL(ssid_lb),"");
}
- else
+ else if(g_strcasecmp(type_text,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
+ {
+ gtk_widget_set_sensitive(edit_ssid_te,FALSE);
+ /*
+ * Maybe the user has already entered some text into the SSID field
+ * and then switched to WEP...
+ */
+ gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),"");
+ gtk_label_set_text(GTK_LABEL(key_lb),"Key");
+ gtk_label_set_text(GTK_LABEL(ssid_lb),"");
+ }
+ else if(g_strcasecmp(type_text,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
{
gtk_widget_set_sensitive(edit_ssid_te,TRUE);
+ /*
+ * Maybe the user has already entered some text into the SSID field
+ * and then switched to WEP...
+ */
+ gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),"");
+ gtk_label_set_text(GTK_LABEL(key_lb),"Passphrase");
+ gtk_label_set_text(GTK_LABEL(ssid_lb),"SSID");
}
}
gtk_widget_show(edit_ssid_te);
@@ -247,6 +276,8 @@ on_add_type_en_changed(GtkWidget *w, gpointer data)
GtkWidget *add_key_w;
GtkWidget *add_ssid_te;
GtkWidget *type_te;
+GtkWidget *key_lb;
+GtkWidget *ssid_lb;
gchar* type_text = NULL;
@@ -254,22 +285,49 @@ add_key_w = GTK_WIDGET(data);
type_te = w;
add_ssid_te = OBJECT_GET_DATA(add_key_w,AIRPCAP_ADVANCED_ADD_KEY_SSID_KEY);
+key_lb = OBJECT_GET_DATA(add_key_w,AIRPCAP_ADVANCED_ADD_KEY_KEY_LABEL_KEY);
+ssid_lb = OBJECT_GET_DATA(add_key_w,AIRPCAP_ADVANCED_ADD_KEY_SSID_LABEL_KEY);
type_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(type_te)));
if(string_is_not_empty(type_text))
{
- /*
- * If it is a WEP key, no SSID is required! Gray out rhe entry text so
+ /*
+ * If it is a WEP key, no SSID is required! Gray out rhe entry text so
* it doesn't create confusion ...
*/
if(g_strcasecmp(type_text,AIRPCAP_WEP_KEY_STRING) == 0)
{
gtk_widget_set_sensitive(add_ssid_te,FALSE);
+ /*
+ * Maybe the user has already entered some text into the SSID field
+ * and then switched to WEP...
+ */
+ gtk_entry_set_text(GTK_ENTRY(add_ssid_te),"");
+ gtk_label_set_text(GTK_LABEL(key_lb),"Key");
+ gtk_label_set_text(GTK_LABEL(ssid_lb),"");
}
- else
+ else if(g_strcasecmp(type_text,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
+ {
+ gtk_widget_set_sensitive(add_ssid_te,FALSE);
+ /*
+ * Maybe the user has already entered some text into the SSID field
+ * and then switched to WEP...
+ */
+ gtk_entry_set_text(GTK_ENTRY(add_ssid_te),"");
+ gtk_label_set_text(GTK_LABEL(key_lb),"Key");
+ gtk_label_set_text(GTK_LABEL(ssid_lb),"");
+ }
+ else if(g_strcasecmp(type_text,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
{
gtk_widget_set_sensitive(add_ssid_te,TRUE);
+ /*
+ * Maybe the user has already entered some text into the SSID field
+ * and then switched to WEP...
+ */
+ gtk_entry_set_text(GTK_ENTRY(add_ssid_te),"");
+ gtk_label_set_text(GTK_LABEL(key_lb),"Passphrase");
+ gtk_label_set_text(GTK_LABEL(ssid_lb),"SSID");
}
}
gtk_widget_show(add_ssid_te);
@@ -278,7 +336,7 @@ g_free(type_text);
}
/*
- * Returns FALSE if a text string has lenght 0, i.e. the first char
+ * Returns FALSE if a text string has lenght 0, i.e. the first char
* is '\0', TRUE otherwise
*/
gboolean
@@ -650,7 +708,7 @@ on_key_management_destroy(GtkWidget *w _U_, gpointer data _U_)
{
GtkWidget *airpcap_advanced_w,
*toolbar;
-
+
gint *from_widget = NULL;
/* Retrieve the GUI object pointers */
@@ -665,23 +723,28 @@ if( *from_widget == AIRPCAP_ADVANCED_FROM_TOOLBAR)
gtk_widget_set_sensitive(toolbar,TRUE);
else
gtk_widget_set_sensitive(toolbar,FALSE);
+
g_free(from_widget);
/* reload the configuration!!! Configuration has not been saved but
the corresponding structure has been modified probably...*/
+if(airpcap_if_selected != NULL)
+{
if(!airpcap_if_selected->saved)
{
airpcap_load_selected_if_configuration(airpcap_if_selected);
}
}
+}
+
/* the Advenced wireless Settings window was closed, cleanup things */
static void
on_airpcap_advanced_destroy(GtkWidget *w _U_, gpointer data _U_)
{
GtkWidget *airpcap_advanced_w,
*toolbar;
-
+
gint *from_widget = NULL;
/* Retrieve the GUI object pointers */
@@ -696,6 +759,7 @@ if( *from_widget == AIRPCAP_ADVANCED_FROM_TOOLBAR)
gtk_widget_set_sensitive(toolbar,TRUE);
else
gtk_widget_set_sensitive(toolbar,FALSE);
+
g_free(from_widget);
/* reload the configuration!!! Configuration has not been saved but
@@ -754,19 +818,13 @@ else if(g_strcasecmp(gtk_entry_get_text(GTK_ENTRY(decryption_en)),AIRPCAP_DECRYP
}
/* Save the configuration */
-if( (airpcap_if_selected != NULL) )
- {
airpcap_read_and_save_decryption_keys_from_clist(key_ls,airpcap_if_selected,airpcap_if_list); /* This will save the keys for every adapter */
-
- /* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
- if( g_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
- {
+
+/* The update will make redissect al the packets... no need to do it here again */
update_decryption_mode_cm(toolbar_cm);
- }
- }
/* Redissect all the packets, and re-evaluate the display filter. */
-cf_redissect_packets(&cfile);
+//cf_redissect_packets(&cfile);
}
/*
@@ -783,7 +841,7 @@ on_advanced_apply_bt_clicked(GtkWidget *button, gpointer data _U_)
*toolbar_if_lb,
*toolbar_channel_cm,
*toolbar_wrong_crc_cm;
-
+
/* retrieve main window */
main_w = GTK_WIDGET(data);
@@ -807,7 +865,7 @@ on_advanced_apply_bt_clicked(GtkWidget *button, gpointer data _U_)
}
/*
- * Callback for the 'Ok' button.
+ * Callback for the 'OK' button.
*/
static void
airpcap_advanced_ok_cb(GtkWidget *w, gpointer data _U_)
@@ -872,16 +930,16 @@ return;
* Callback used to add a WEP key in the add new key box;
*/
static void
-add_key(GtkWidget *widget, gpointer data _U_)
+on_add_key_ok_bt_clicked(GtkWidget *widget, gpointer data _U_)
{
GtkWidget *type_cm,
*key_en,
*ssid_en;
-
+
GtkWidget *key_ls;
-GString *new_type_string,
- *new_key_string,
+GString *new_type_string,
+ *new_key_string,
*new_ssid_string;
gchar *type_entered = NULL;
@@ -926,15 +984,15 @@ g_strchomp(new_ssid_string->str);
/* Check which type of key the user has entered */
if(g_strcasecmp(new_type_string->str,AIRPCAP_WEP_KEY_STRING) == 0) /* WEP key */
{
-
-if( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < 2))
+
+if( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WEP_KEY_MIN_CHAR_SIZE))
{
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WEP key size out of range!\nValid key size range is 2-%d characters (8-%d bits).",WEP_KEY_MAX_CHAR_SIZE,WEP_KEY_MAX_SIZE*8);
-
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WEP key size out of range!\nValid key size range is %d-%d characters (%d-%d bits).",WEP_KEY_MIN_CHAR_SIZE,WEP_KEY_MAX_CHAR_SIZE,WEP_KEY_MIN_BIT_SIZE,WEP_KEY_MAX_BIT_SIZE);
+
g_string_free(new_type_string,TRUE);
g_string_free(new_key_string, TRUE);
g_string_free(new_ssid_string,TRUE);
-
+
g_free(type_entered);
g_free(key_entered );
g_free(ssid_entered);
@@ -944,11 +1002,11 @@ if( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) <
if((new_key_string->len % 2) != 0)
{
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WEP key!\nThe number of characters must be even.");
-
+
g_string_free(new_type_string,TRUE);
g_string_free(new_key_string, TRUE);
g_string_free(new_ssid_string,TRUE);
-
+
g_free(type_entered);
g_free(key_entered );
g_free(ssid_entered);
@@ -960,11 +1018,11 @@ for(i = 0; i < new_key_string->len; i++)
if(!g_ascii_isxdigit(new_key_string->str[i]))
{
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WEP key!\nA WEP key must be a hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
-
+
g_string_free(new_type_string,TRUE);
g_string_free(new_key_string, TRUE);
g_string_free(new_ssid_string,TRUE);
-
+
g_free(type_entered);
g_free(key_entered );
g_free(ssid_entered);
@@ -972,28 +1030,96 @@ for(i = 0; i < new_key_string->len; i++)
}
}
-/* If so... Modify key */
+/* If so... add key */
airpcap_add_key_to_list(key_ls, new_type_string->str, new_key_string->str, new_ssid_string->str);
-airpcap_if_selected->saved = FALSE;
+if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
}
-else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_KEY_STRING) == 0) /* WPA Key */
+else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_PWD_KEY_STRING) == 0) /* WPA Key */
{
/* XXX - Perform some WPA related input fields check */
/* If everything is ok, modify the entry int he list */
-airpcap_if_selected->saved = FALSE;
+if( ((new_key_string->len) > WPA_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WPA_KEY_MIN_CHAR_SIZE))
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WPA key size out of range!\nValid key size range is %d-%d ASCII characters (%d-%d bits).",WPA_KEY_MIN_CHAR_SIZE,WPA_KEY_MAX_CHAR_SIZE,WPA_KEY_MIN_BIT_SIZE,WPA_KEY_MAX_BIT_SIZE);
+
+ g_string_free(new_type_string,TRUE);
+ g_string_free(new_key_string, TRUE);
+ g_string_free(new_ssid_string,TRUE);
+
+ g_free(type_entered);
+ g_free(key_entered );
+ g_free(ssid_entered);
+ return;
+ }
+
+/*
+ * XXX - Maybe we need some check on the characters? I'm not sure if only stabdard ASCII are ok...
+ */
+if( ((new_ssid_string->len) > WPA_SSID_MAX_CHAR_SIZE) || ((new_ssid_string->len) < WPA_SSID_MIN_CHAR_SIZE))
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"SSID key size out of range!\nValid SSID size range is %d-%d ASCII characters (%d-%d bits).",WPA_SSID_MIN_CHAR_SIZE,WPA_SSID_MAX_CHAR_SIZE,WPA_SSID_MIN_BIT_SIZE,WPA_SSID_MAX_BIT_SIZE);
+
+ g_string_free(new_type_string,TRUE);
+ g_string_free(new_key_string, TRUE);
+ g_string_free(new_ssid_string,TRUE);
+
+ g_free(type_entered);
+ g_free(key_entered );
+ g_free(ssid_entered);
+ return;
+ }
+
+/* If so... add key */
+airpcap_add_key_to_list(key_ls, new_type_string->str, new_key_string->str, new_ssid_string->str);
+
+if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
}
-else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA2_KEY_STRING) == 0) /* WPA2 Key */
+else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_BIN_KEY_STRING) == 0) /* WPA_BIN Key */
{
-/* XXX - Perform some WPA2 related input fields check */
+/* XXX - Perform some WPA_BIN related input fields check */
/* If everything is ok, modify the entry int he list */
-airpcap_if_selected->saved = FALSE;
+if( ((new_key_string->len) != WPA_PSK_KEY_CHAR_SIZE))
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WPA PSK/PMK key size is wrong!\nValid key size is %d characters (%d bits).",WPA_PSK_KEY_CHAR_SIZE,WPA_PSK_KEY_BIT_SIZE);
+
+ g_string_free(new_type_string,TRUE);
+ g_string_free(new_key_string, TRUE);
+ g_string_free(new_ssid_string,TRUE);
+
+ g_free(type_entered);
+ g_free(key_entered );
+ g_free(ssid_entered);
+ return;
+ }
+
+for(i = 0; i < new_key_string->len; i++)
+ {
+ if(!g_ascii_isxdigit(new_key_string->str[i]))
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WPA PSK/PMK key!\nKey must be an hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
+
+ g_string_free(new_type_string,TRUE);
+ g_string_free(new_key_string, TRUE);
+ g_string_free(new_ssid_string,TRUE);
+
+ g_free(type_entered);
+ g_free(key_entered );
+ g_free(ssid_entered);
+ return;
+ }
+ }
+
+/* If so... add key */
+airpcap_add_key_to_list(key_ls, new_type_string->str, new_key_string->str, new_ssid_string->str);
+
+if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
}
else /* Should never happen!!! */
-{
-simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Unknown error in the key \"Type\" field!");
+{
+simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Unknown error in the key \"Type\" field!");
}
g_string_free(new_type_string,TRUE);
@@ -1002,7 +1128,7 @@ g_string_free(new_ssid_string,TRUE);
g_free(type_entered);
g_free(key_entered );
-g_free(ssid_entered);
+g_free(ssid_entered);
window_destroy(GTK_WIDGET(data));
return;
@@ -1017,11 +1143,11 @@ on_edit_key_ok_bt_clicked(GtkWidget *widget, gpointer data _U_)
GtkWidget *type_cm,
*key_en,
*ssid_en;
-
+
GtkWidget *key_ls;
-GString *new_type_string,
- *new_key_string,
+GString *new_type_string,
+ *new_key_string,
*new_ssid_string;
gchar *type_entered = NULL;
@@ -1066,15 +1192,15 @@ g_strchomp(new_ssid_string->str);
/* Check which type of key the user has entered */
if(g_strcasecmp(new_type_string->str,AIRPCAP_WEP_KEY_STRING) == 0) /* WEP key */
{
-
-if( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < 2))
+
+if( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WEP_KEY_MIN_CHAR_SIZE))
{
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WEP key size out of range!\nValid key size range is 2-%d characters (8-%d bits).",WEP_KEY_MAX_CHAR_SIZE,WEP_KEY_MAX_SIZE*8);
-
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WEP key size out of range!\nValid key size range is %d-%d characters (%d-%d bits).",WEP_KEY_MIN_CHAR_SIZE,WEP_KEY_MAX_CHAR_SIZE,WEP_KEY_MIN_BIT_SIZE,WEP_KEY_MAX_BIT_SIZE);
+
g_string_free(new_type_string,TRUE);
g_string_free(new_key_string, TRUE);
g_string_free(new_ssid_string,TRUE);
-
+
g_free(type_entered);
g_free(key_entered );
g_free(ssid_entered);
@@ -1084,11 +1210,11 @@ if( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) <
if((new_key_string->len % 2) != 0)
{
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WEP key!\nThe number of characters must be even.");
-
+
g_string_free(new_type_string,TRUE);
g_string_free(new_key_string, TRUE);
g_string_free(new_ssid_string,TRUE);
-
+
g_free(type_entered);
g_free(key_entered );
g_free(ssid_entered);
@@ -1100,11 +1226,11 @@ for(i = 0; i < new_key_string->len; i++)
if(!g_ascii_isxdigit(new_key_string->str[i]))
{
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WEP key!\nA WEP key must be an hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
-
+
g_string_free(new_type_string,TRUE);
g_string_free(new_key_string, TRUE);
g_string_free(new_ssid_string,TRUE);
-
+
g_free(type_entered);
g_free(key_entered );
g_free(ssid_entered);
@@ -1115,25 +1241,93 @@ for(i = 0; i < new_key_string->len; i++)
/* If so... Modify key */
airpcap_modify_key_in_list(key_ls, r, new_type_string->str, new_key_string->str, new_ssid_string->str);
-airpcap_if_selected->saved = FALSE;
+if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
}
-else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_KEY_STRING) == 0) /* WPA Key */
+else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_PWD_KEY_STRING) == 0) /* WPA Key */
{
/* XXX - Perform some WPA related input fields check */
/* If everything is ok, modify the entry int he list */
-airpcap_if_selected->saved = FALSE;
+if( ((new_key_string->len) > WPA_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WPA_KEY_MIN_CHAR_SIZE))
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WPA key size out of range!\nValid key size range is %d-%d ASCII characters (%d-%d bits).",WPA_KEY_MIN_CHAR_SIZE,WPA_KEY_MAX_CHAR_SIZE,WPA_KEY_MIN_BIT_SIZE,WPA_KEY_MAX_BIT_SIZE);
+
+ g_string_free(new_type_string,TRUE);
+ g_string_free(new_key_string, TRUE);
+ g_string_free(new_ssid_string,TRUE);
+
+ g_free(type_entered);
+ g_free(key_entered );
+ g_free(ssid_entered);
+ return;
+}
+
+/*
+ * XXX - Maybe we need some check on the characters? I'm not sure if only stabdard ASCII are ok...
+ */
+if( ((new_ssid_string->len) > WPA_SSID_MAX_CHAR_SIZE) || ((new_ssid_string->len) < WPA_SSID_MIN_CHAR_SIZE))
+{
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"SSID key size out of range!\nValid SSID size range is %d-%d ASCII characters (%d-%d bits).",WPA_SSID_MIN_CHAR_SIZE,WPA_SSID_MAX_CHAR_SIZE,WPA_SSID_MIN_BIT_SIZE,WPA_SSID_MAX_BIT_SIZE);
+
+ g_string_free(new_type_string,TRUE);
+ g_string_free(new_key_string, TRUE);
+ g_string_free(new_ssid_string,TRUE);
+
+ g_free(type_entered);
+ g_free(key_entered );
+ g_free(ssid_entered);
+ return;
+ }
+
+/* If so... Modify key */
+airpcap_modify_key_in_list(key_ls, r, new_type_string->str, new_key_string->str, new_ssid_string->str);
+
+if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
}
-else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA2_KEY_STRING) == 0) /* WPA2 Key */
+else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_BIN_KEY_STRING) == 0) /* WPA_BIN Key */
{
-/* XXX - Perform some WPA2 related input fields check */
+/* XXX - Perform some WPA_BIN related input fields check */
/* If everything is ok, modify the entry int he list */
-airpcap_if_selected->saved = FALSE;
+if( ((new_key_string->len) != WPA_PSK_KEY_CHAR_SIZE))
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"WPA PSK/PMK key size is wrong!\nValid key size is %d characters (%d bits).",WPA_PSK_KEY_CHAR_SIZE,WPA_PSK_KEY_BIT_SIZE);
+
+ g_string_free(new_type_string,TRUE);
+ g_string_free(new_key_string, TRUE);
+ g_string_free(new_ssid_string,TRUE);
+
+ g_free(type_entered);
+ g_free(key_entered );
+ g_free(ssid_entered);
+ return;
+ }
+
+for(i = 0; i < new_key_string->len; i++)
+ {
+ if(!g_ascii_isxdigit(new_key_string->str[i]))
+ {
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WPA PSK/PMK key!\nKey must be an hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
+
+ g_string_free(new_type_string,TRUE);
+ g_string_free(new_key_string, TRUE);
+ g_string_free(new_ssid_string,TRUE);
+
+ g_free(type_entered);
+ g_free(key_entered );
+ g_free(ssid_entered);
+ return;
+ }
+ }
+
+/* If so... Modify key */
+airpcap_modify_key_in_list(key_ls, r, new_type_string->str, new_key_string->str, new_ssid_string->str);
+
+if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
}
else /* Should never happen!!! */
-{
-simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Unknown error in the key \"Type\" field!");
+{
+simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Unknown error in the key \"Type\" field!");
}
g_string_free(new_type_string,TRUE);
@@ -1142,7 +1336,7 @@ g_string_free(new_ssid_string,TRUE);
g_free(type_entered);
g_free(key_entered );
-g_free(ssid_entered);
+g_free(ssid_entered);
window_destroy(GTK_WIDGET(data));
return;
@@ -1200,14 +1394,14 @@ keys_in_list = GTK_CLIST(key_ls)->rows;
if(keys_in_list >= MAX_ENCRYPTION_KEYS) /* Check if we have already reached the maximum number of allowed keys... */
{
- simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Maximum number (%d) of decryption keys reached! You cannot add another key!\n",MAX_ENCRYPTION_KEYS);
+ simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Maximum number (%d) of decryption keys reached! You cannot add another key!\n",MAX_ENCRYPTION_KEYS);
return;
}
/* Gray out the Advanced Wireless Setting window */
gtk_widget_set_sensitive(airpcap_advanced_w,FALSE);
-/* Pop-up a new window */
+/* Pop-up a new window */
add_key_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_name (add_key_window, "add_key_window");
gtk_container_set_border_width (GTK_CONTAINER (add_key_window), 5);
@@ -1251,16 +1445,17 @@ gtk_table_attach (GTK_TABLE (add_tb), add_type_cm, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
#if GTK_MAJOR_VERSION >= 2
-gtk_widget_set_size_request (add_type_cm, 63, -1);
+gtk_widget_set_size_request (add_type_cm, 83, -1);
#else
-gtk_widget_set_usize (add_type_cm, 63, -1);
+gtk_widget_set_usize (add_type_cm, 83, -1);
#endif
add_type_cm_items = g_list_append (add_type_cm_items, (gpointer) AIRPCAP_WEP_KEY_STRING);
-/* XXX - DEcomment only when WPA and WPA2 will be ready */
-/*
-add_type_cm_items = g_list_append (add_type_cm_items, (gpointer) AIRPCAP_WPA_KEY_STRING);
-add_type_cm_items = g_list_append (add_type_cm_items, (gpointer) AIRPCAP_WPA2_KEY_STRING);*/
+/* XXX - DEcomment only when WPA and WPA_BIN will be ready */
+#ifdef HAVE_AIRPDCAP
+add_type_cm_items = g_list_append (add_type_cm_items, (gpointer) AIRPCAP_WPA_PWD_KEY_STRING);
+add_type_cm_items = g_list_append (add_type_cm_items, (gpointer) AIRPCAP_WPA_BIN_KEY_STRING);
+#endif
gtk_combo_set_popdown_strings (GTK_COMBO (add_type_cm),
add_type_cm_items);
g_list_free (add_type_cm_items);
@@ -1285,8 +1480,8 @@ gtk_widget_set_usize (add_key_te, 178, -1);
add_ssid_te = gtk_entry_new ();
gtk_widget_set_name (add_ssid_te, "add_ssid_te");
gtk_widget_set_sensitive(add_ssid_te,FALSE);
-/* XXX - Decomment only when WPA and WPA2 will be ready */
-/* gtk_widget_show (add_ssid_te); */
+/* XXX - Decomment only when WPA and WPA_BIN will be ready */
+gtk_widget_show (add_ssid_te);
gtk_table_attach (GTK_TABLE (add_tb), add_ssid_te, 2, 3, 1, 2,
(GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0);
@@ -1300,16 +1495,16 @@ gtk_label_set_justify (GTK_LABEL (add_type_lb), GTK_JUSTIFY_CENTER);
add_key_lb = gtk_label_new ("Key");
gtk_widget_set_name (add_key_lb, "add_key_lb");
-gtk_widget_show (add_key_lb);
+gtk_widget_show (add_key_lb);
gtk_table_attach (GTK_TABLE (add_tb), add_key_lb, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_label_set_justify (GTK_LABEL (add_key_lb), GTK_JUSTIFY_CENTER);
-add_ssid_lb = gtk_label_new ("SSID");
+add_ssid_lb = gtk_label_new ("");
gtk_widget_set_name (add_ssid_lb, "add_ssid_lb");
-/* XXX - Decomment only when WPA and WPA2 will be ready */
-/* gtk_widget_show (add_ssid_lb); */
+/* XXX - Decomment only when WPA and WPA_BIN will be ready */
+gtk_widget_show (add_ssid_lb);
gtk_table_attach (GTK_TABLE (add_tb), add_ssid_lb, 2, 3, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
@@ -1324,9 +1519,9 @@ gtk_button_box_set_layout (GTK_BUTTON_BOX (low_h_button_box),
GTK_BUTTONBOX_END);
#if GTK_MAJOR_VERISON >= 2
-ok_bt = gtk_button_new_with_mnemonic ("Ok");
+ok_bt = gtk_button_new_with_mnemonic ("OK");
#else
-ok_bt = gtk_button_new_with_label ("Ok");
+ok_bt = gtk_button_new_with_label ("OK");
#endif
gtk_widget_set_name (ok_bt, "ok_bt");
gtk_widget_show (ok_bt);
@@ -1354,7 +1549,7 @@ gtk_frame_set_label (GTK_FRAME (add_frame), "Modify Selected Key");
#endif
/* Add callbacks */
-SIGNAL_CONNECT(ok_bt, "clicked", add_key, add_key_window );
+SIGNAL_CONNECT(ok_bt, "clicked", on_add_key_ok_bt_clicked, add_key_window );
SIGNAL_CONNECT(cancel_bt, "clicked", window_cancel_button_cb, add_key_window );
SIGNAL_CONNECT(add_type_en, "changed",on_add_type_en_changed, add_key_window);
SIGNAL_CONNECT(add_key_window, "delete_event",window_delete_event_cb, add_key_window);
@@ -1366,6 +1561,8 @@ OBJECT_SET_DATA(add_key_window,AIRPCAP_ADVANCED_SELECTED_KEY_LIST_ITEM_KEY,selec
OBJECT_SET_DATA(add_key_window,AIRPCAP_ADVANCED_ADD_KEY_TYPE_KEY,add_type_cm);
OBJECT_SET_DATA(add_key_window,AIRPCAP_ADVANCED_ADD_KEY_KEY_KEY,add_key_te);
OBJECT_SET_DATA(add_key_window,AIRPCAP_ADVANCED_ADD_KEY_SSID_KEY,add_ssid_te);
+OBJECT_SET_DATA(add_key_window,AIRPCAP_ADVANCED_ADD_KEY_KEY_LABEL_KEY,add_key_lb);
+OBJECT_SET_DATA(add_key_window,AIRPCAP_ADVANCED_ADD_KEY_SSID_LABEL_KEY,add_ssid_lb);
gtk_widget_show(add_key_window);
}
@@ -1431,8 +1628,8 @@ airpcap_advanced_w = GTK_WIDGET(data);
key_ls = OBJECT_GET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_KEYLIST_KEY);
selected_item = OBJECT_GET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_SELECTED_KEY_LIST_ITEM_KEY);
-/*
- * Better to store the selected_item data in two new variables, because maybe some
+/*
+ * Better to store the selected_item data in two new variables, because maybe some
* select_row signal will be emitted somewhere...
*/
r = selected_item->row;
@@ -1450,10 +1647,10 @@ gtk_clist_remove(GTK_CLIST(key_ls),r);
if( r < (keys_in_list-1) )
gtk_clist_select_row(GTK_CLIST(key_ls),r,c);
else
- gtk_clist_select_row(GTK_CLIST(key_ls),r-1,c);
+ gtk_clist_select_row(GTK_CLIST(key_ls),r-1,c);
/* Need to save config... */
-airpcap_if_selected->saved = FALSE;
+if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
}
/*
@@ -1511,11 +1708,11 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
gtk_clist_get_text(GTK_CLIST(key_ls),r,0,&row_type);
gtk_clist_get_text(GTK_CLIST(key_ls),r,1,&row_key);
gtk_clist_get_text(GTK_CLIST(key_ls),r,2,&row_ssid);
-
+
/* Gray out the Advanced Wireless Setting window */
gtk_widget_set_sensitive(airpcap_advanced_w,FALSE);
-
- /* Pop-up a new window */
+
+ /* Pop-up a new window */
edit_key_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_name (edit_key_window, "edit_key_window");
gtk_container_set_border_width (GTK_CONTAINER (edit_key_window), 5);
@@ -1525,17 +1722,17 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
#else
gtk_window_set_policy(GTK_WINDOW(edit_key_window), FALSE, FALSE, TRUE);
#endif
-
+
main_v_box = gtk_vbox_new (FALSE, 0);
gtk_widget_set_name (main_v_box, "main_v_box");
gtk_widget_show (main_v_box);
gtk_container_add (GTK_CONTAINER (edit_key_window), main_v_box);
-
+
edit_frame = gtk_frame_new (NULL);
gtk_widget_set_name (edit_frame, "edit_frame");
gtk_widget_show (edit_frame);
gtk_box_pack_start (GTK_BOX (main_v_box), edit_frame, TRUE, TRUE, 0);
-
+
edit_frame_al = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_set_name (edit_frame_al, "edit_frame_al");
gtk_widget_show (edit_frame_al);
@@ -1545,13 +1742,13 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
#else
gtk_alignment_set (GTK_ALIGNMENT (edit_frame_al), 0, 0, 12, 0);
#endif
-
+
edit_tb = gtk_table_new (2, 3, FALSE);
gtk_widget_set_name (edit_tb, "edit_tb");
gtk_container_set_border_width(GTK_CONTAINER(edit_tb),5);
gtk_widget_show (edit_tb);
gtk_container_add (GTK_CONTAINER (edit_frame_al), edit_tb);
-
+
edit_type_cm = gtk_combo_new ();
gtk_widget_set_name (edit_type_cm, "edit_type_cm");
gtk_widget_show (edit_type_cm);
@@ -1559,25 +1756,27 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
#if GTK_MAJOR_VERSION >= 2
- gtk_widget_set_size_request (edit_type_cm, 63, -1);
+ gtk_widget_set_size_request (edit_type_cm, 83, -1);
#else
- gtk_widget_set_usize (edit_type_cm, 63, -1);
+ gtk_widget_set_usize (edit_type_cm, 83, -1);
#endif
edit_type_cm_items = g_list_append (edit_type_cm_items, (gpointer) AIRPCAP_WEP_KEY_STRING);
- /* XXX - Decomment only when WPA and WPA2 support will be ready!!! */
-/* edit_type_cm_items = g_list_append (edit_type_cm_items, (gpointer) AIRPCAP_WPA_KEY_STRING);
- edit_type_cm_items = g_list_append (edit_type_cm_items, (gpointer) AIRPCAP_WPA2_KEY_STRING);*/
+ /* XXX - Decomment only when WPA and WPA_BIN support will be ready!!! */
+ #ifdef HAVE_AIRPDCAP
+ edit_type_cm_items = g_list_append (edit_type_cm_items, (gpointer) AIRPCAP_WPA_PWD_KEY_STRING);
+ edit_type_cm_items = g_list_append (edit_type_cm_items, (gpointer) AIRPCAP_WPA_BIN_KEY_STRING);
+ #endif
gtk_combo_set_popdown_strings (GTK_COMBO (edit_type_cm),
edit_type_cm_items);
g_list_free (edit_type_cm_items);
-
+
edit_type_en = GTK_COMBO (edit_type_cm)->entry;
gtk_widget_set_name (edit_type_en, "edit_type_en");
/* Set current type */
gtk_entry_set_text(GTK_ENTRY(edit_type_en),row_type);
gtk_editable_set_editable (GTK_EDITABLE (edit_type_en), FALSE);
gtk_widget_show (edit_type_en);
-
+
edit_key_te = gtk_entry_new ();
gtk_widget_set_name (edit_key_te, "edit_key_te");
/* Set current key */
@@ -1590,7 +1789,7 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
#else
gtk_widget_set_usize (edit_key_te, 178, -1);
#endif
-
+
edit_ssid_te = gtk_entry_new ();
gtk_widget_set_name (edit_ssid_te, "edit_ssid_te");
@@ -1604,12 +1803,14 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
gtk_widget_set_sensitive(edit_ssid_te,TRUE);
gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),row_ssid);
}
-
+
/* XXX - Decomment only when WPA and WPA@ will be ready */
- /* gtk_widget_show (edit_ssid_te); */
+#ifdef HAVE_AIRPDCAP
+ gtk_widget_show (edit_ssid_te);
+#endif
gtk_table_attach (GTK_TABLE (edit_tb), edit_ssid_te, 2, 3, 1, 2,
(GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0);
-
+
edit_type_lb = gtk_label_new ("Type");
gtk_widget_set_name (edit_type_lb, "edit_type_lb");
gtk_widget_show (edit_type_lb);
@@ -1617,7 +1818,7 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_label_set_justify (GTK_LABEL (edit_type_lb), GTK_JUSTIFY_CENTER);
-
+
edit_key_lb = gtk_label_new ("Key");
gtk_widget_set_name (edit_key_lb, "edit_key_lb");
gtk_widget_show (edit_key_lb);
@@ -1625,16 +1826,16 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_label_set_justify (GTK_LABEL (edit_key_lb), GTK_JUSTIFY_CENTER);
-
- edit_ssid_lb = gtk_label_new ("SSID");
+
+ edit_ssid_lb = gtk_label_new ("");
gtk_widget_set_name (edit_ssid_lb, "edit_ssid_lb");
- /* XXX - Decomment only when WPA and WPA2 will be ready */
- /* gtk_widget_show (edit_ssid_lb); */
+ /* XXX - Decomment only when WPA and WPA_BIN will be ready */
+ gtk_widget_show (edit_ssid_lb);
gtk_table_attach (GTK_TABLE (edit_tb), edit_ssid_lb, 2, 3, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_label_set_justify (GTK_LABEL (edit_ssid_lb), GTK_JUSTIFY_CENTER);
-
+
low_h_button_box = gtk_hbutton_box_new ();
gtk_widget_set_name (low_h_button_box, "low_h_button_box");
gtk_container_set_border_width (GTK_CONTAINER (low_h_button_box), 5);
@@ -1642,17 +1843,17 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
gtk_box_pack_end (GTK_BOX (main_v_box), low_h_button_box, FALSE, FALSE, 0);
gtk_button_box_set_layout (GTK_BUTTON_BOX (low_h_button_box),
GTK_BUTTONBOX_END);
-
+
#if GTK_MAJOR_VERISON >= 2
- ok_bt = gtk_button_new_with_mnemonic ("Ok");
+ ok_bt = gtk_button_new_with_mnemonic ("OK");
#else
- ok_bt = gtk_button_new_with_label ("Ok");
+ ok_bt = gtk_button_new_with_label ("OK");
#endif
gtk_widget_set_name (ok_bt, "ok_bt");
gtk_widget_show (ok_bt);
gtk_container_add (GTK_CONTAINER (low_h_button_box), ok_bt);
GTK_WIDGET_SET_FLAGS (ok_bt, GTK_CAN_DEFAULT);
-
+
#if GTK_MAJOR_VERISON >= 2
cancel_bt = gtk_button_new_with_mnemonic ("Cancel");
#else
@@ -1662,7 +1863,7 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
gtk_widget_show (cancel_bt);
gtk_container_add (GTK_CONTAINER (low_h_button_box), cancel_bt);
GTK_WIDGET_SET_FLAGS (cancel_bt, GTK_CAN_DEFAULT);
-
+
edit_frame_lb = gtk_label_new ("<b>Modify Selected Key</b>");
gtk_widget_set_name (edit_frame_lb, "edit_frame_lb");
gtk_widget_show (edit_frame_lb);
@@ -1672,21 +1873,23 @@ if((r != NO_ROW_SELECTED) && (c != NO_COLUMN_SELECTED))
#else
gtk_frame_set_label (GTK_FRAME (edit_frame), "Modify Selected Key");
#endif
-
+
/* Add callbacks */
SIGNAL_CONNECT(ok_bt, "clicked", on_edit_key_ok_bt_clicked, edit_key_window );
SIGNAL_CONNECT(cancel_bt, "clicked", window_cancel_button_cb, edit_key_window );
SIGNAL_CONNECT(edit_type_en, "changed",on_edit_type_en_changed, edit_key_window);
SIGNAL_CONNECT(edit_key_window, "delete_event",window_delete_event_cb, edit_key_window);
SIGNAL_CONNECT(edit_key_window, "destroy",on_edit_key_w_destroy, data);
-
+
/* Add widget data */
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_LIST_KEY,key_ls);
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_SELECTED_KEY,selected_item);
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_TYPE_KEY,edit_type_cm);
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_KEY_KEY,edit_key_te);
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY,edit_ssid_te);
-
+ OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_KEY_LABEL_KEY,edit_key_lb);
+ OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_SSID_LABEL_KEY,edit_ssid_lb);
+
gtk_widget_show(edit_key_window);
}
}
@@ -1715,8 +1918,8 @@ airpcap_advanced_w = GTK_WIDGET(data);
key_ls = OBJECT_GET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_KEYLIST_KEY);
selected_item = OBJECT_GET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_SELECTED_KEY_LIST_ITEM_KEY);
-/*
- * Better to store the selected_item data in two new variables, because maybe some
+/*
+ * Better to store the selected_item data in two new variables, because maybe some
* select_row signal will be emitted somewhere...
*/
r = selected_item->row;
@@ -1733,14 +1936,14 @@ if( r == 0 ) /* Cannot move up the first row */
/* Move up selected key */
gtk_clist_swap_rows (GTK_CLIST(key_ls),r-1,r);
-/*
+/*
* Re-select the just moved key... so the user can keep pressing 'Move Key Up'
* without re-select the row...
*/
gtk_clist_select_row (GTK_CLIST(key_ls),r-1,c);
/* Need to save config... */
-airpcap_if_selected->saved = FALSE;
+if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
}
/*
@@ -1767,8 +1970,8 @@ airpcap_advanced_w = GTK_WIDGET(data);
key_ls = OBJECT_GET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_KEYLIST_KEY);
selected_item = OBJECT_GET_DATA(airpcap_advanced_w,AIRPCAP_ADVANCED_SELECTED_KEY_LIST_ITEM_KEY);
-/*
- * Better to store the selected_item data in two new variables, because maybe some
+/*
+ * Better to store the selected_item data in two new variables, because maybe some
* select_row signal will be emitted somewhere...
*/
r = selected_item->row;
@@ -1785,14 +1988,14 @@ if( (r+1) == keys_in_list ) /* Cannot move down the last row */
/* Move down selected key */
gtk_clist_swap_rows (GTK_CLIST(key_ls),r,r+1);
-/*
+/*
* Re-select the just moved key... so the user can keep pressing 'Move Key Down'
* without re-select the row...
*/
gtk_clist_select_row (GTK_CLIST(key_ls),r+1,c);
/* Need to save config... */
-airpcap_if_selected->saved = FALSE;
+if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
}
/* Turns the decryption on or off */
@@ -1805,6 +2008,14 @@ char* decryption_mode_string = NULL;
decryption_en = GTK_ENTRY(w);
+/*
+ * This callback is called twice: when the current text is canceled ("")
+ * and then when the 'new text' is added ("new text"). We don't really
+ * care about the first time, and we just return.
+ */
+if(g_strcasecmp(gtk_entry_get_text(decryption_en),"") == 0)
+ return;
+
if(g_strcasecmp(gtk_entry_get_text(decryption_en),AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK) == 0)
{
set_wireshark_decryption(TRUE);
@@ -1831,7 +2042,13 @@ cf_redissect_packets(&cfile);
void
update_decryption_mode_cm(GtkWidget *w)
{
-/* Wireshark decryption is on */
+/*
+ * This ensures that the entry tet changes... the callback will return immediately, but
+ * at least next time packets will be redissected...
+ */
+gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),"");
+
+/* Wireshark decryption is on */
if(wireshark_decryption_on())
{
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK);
@@ -1848,9 +2065,61 @@ else
{
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
}
+
return;
}
+/*
+ * Creates the list of available decryption modes, depending on the adapters found
+ */
+void
+update_decryption_mode_list(GtkWidget *w)
+{
+GList *enable_decryption_cb_items = NULL;
+GtkWidget *entry;
+gchar *current_text;
+
+if(w == NULL)
+return;
+
+entry = GTK_COMBO(w)->entry;
+current_text = NULL;
+
+/*
+ * XXX - Retrieve the current 'decryption mode'. It would be better just block the
+ * signal handler, but it doesn't work... one of these days I'll try to figure otu why...
+ */
+current_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
+
+enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
+enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK);
+
+if(airpcap_if_list != NULL)
+{
+enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP);
+}
+else
+{
+ /* The last decryption mode was 'Driver', but no more AirPcap adapter are found */
+ if(g_strcasecmp(current_text,AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP) == 0)
+ {
+ if(current_text != NULL) g_free(current_text);
+
+ current_text = g_strdup(AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
+ }
+}
+
+gtk_signal_handler_block_by_data(GTK_OBJECT(entry),(gpointer)airpcap_tb);
+gtk_combo_set_popdown_strings (GTK_COMBO (w), enable_decryption_cb_items);
+/* The 'changed' callback will be called twice */
+gtk_entry_set_text(GTK_ENTRY(entry),current_text);
+gtk_signal_handler_unblock_by_data(GTK_OBJECT(entry),(gpointer)airpcap_tb);
+
+if(current_text != NULL) g_free(current_text);
+
+g_list_free (enable_decryption_cb_items);
+}
+
/* Called to create the airpcap settings' window */
void
display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
@@ -1927,7 +2196,7 @@ gtk_window_set_title (GTK_WINDOW (airpcap_advanced_w),
"Advanced Wireless Settings");
gtk_window_set_position (GTK_WINDOW (airpcap_advanced_w),
GTK_WIN_POS_CENTER);
-
+
#if GTK_MAJOR_VERSION >= 2
gtk_window_set_resizable (GTK_WINDOW (airpcap_advanced_w), FALSE);
gtk_window_set_type_hint (GTK_WINDOW (airpcap_advanced_w), GDK_WINDOW_TYPE_HINT_DIALOG);
@@ -1978,7 +2247,7 @@ else
interface_name_lb = gtk_label_new("No airpcap interface found!");
gtk_widget_set_sensitive(main_box,FALSE);
}
-
+
gtk_widget_set_name (interface_name_lb, "interface_name_lb");
gtk_widget_show (interface_name_lb);
gtk_box_pack_start (GTK_BOX (interface_sub_h_box), interface_name_lb, TRUE,
@@ -2013,7 +2282,7 @@ gtk_frame_set_label_widget (GTK_FRAME (interface_fr), interface_frame_lb);
gtk_label_set_use_markup (GTK_LABEL (interface_frame_lb), TRUE);
#else
gtk_frame_set_label(GTK_FRAME(interface_fr),"Interface");
-#endif
+#endif
basic_parameters_fr = gtk_frame_new (NULL);
gtk_widget_set_name (basic_parameters_fr, "basic_parameters_fr");
@@ -2082,7 +2351,7 @@ if(airpcap_if_selected != NULL)
{
airpcap_update_channel_combo(GTK_WIDGET(channel_cm), airpcap_if_selected);
}
-
+
g_list_free (channel_cm_items);
channel_en = GTK_COMBO (channel_cm)->entry;
@@ -2102,7 +2371,7 @@ capture_type_cm_items =
g_list_append (capture_type_cm_items, (gpointer) AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO);
gtk_combo_set_popdown_strings (GTK_COMBO (capture_type_cm),
capture_type_cm_items);
-
+
/* Current interface value */
capture_s = NULL;
if(airpcap_if_selected != NULL)
@@ -2110,7 +2379,7 @@ 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);
+ 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_type_cm)->entry), capture_s);
}
g_free(capture_s);
@@ -2136,7 +2405,7 @@ if(airpcap_if_selected != NULL)
else
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fcs_ck),FALSE);
}
-
+
gtk_widget_show (fcs_ck);
gtk_table_attach (GTK_TABLE (basic_parameters_tb), fcs_ck, 2, 3, 0, 1,
(GtkAttachOptions) (GTK_FILL),
@@ -2185,7 +2454,7 @@ if(airpcap_if_selected != NULL)
{
airpcap_validation_type_combo_set_by_type(fcs_filter_cm,airpcap_if_selected->CrcValidationOn);
}
-
+
gtk_widget_show (fcs_filter_en);
basic_parameters_frame_lb = gtk_label_new ("<b>Basic Parameters</b>");
@@ -2350,9 +2619,9 @@ gtk_timeout_remove(airpcap_if_selected->tag);
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_update_channel_combo(GTK_WIDGET(toolbar_channel_cm),airpcap_if_selected);
-
+
airpcap_validation_type_combo_set_by_type(toolbar_wrong_crc_cm,airpcap_if_selected->CrcValidationOn);
}
@@ -2473,7 +2742,7 @@ GtkWidget *right_h_button_box;
GtkWidget *ok_bt;
GtkWidget *apply_bt;
GtkWidget *cancel_bt;
-
+
/* widgets in the toolbar */
GtkWidget *toolbar,
*toolbar_decryption_ck;
@@ -2481,7 +2750,7 @@ GtkWidget *toolbar,
/* other stuff */
/*GList *channel_list,*capture_list;*/
GList *linktype_list = NULL;
-
+
/* Selected row/column structure */
airpcap_key_ls_selected_info_t *key_ls_selected_item;
key_ls_selected_item = (airpcap_key_ls_selected_info_t*)g_malloc(sizeof(airpcap_key_ls_selected_info_t));
@@ -2507,13 +2776,12 @@ airpcap_if_selected = airpcap_if_active;
/* Create the new window */
key_management_w = window_new(GTK_WINDOW_TOPLEVEL, "Decryption Keys Management");
-
gtk_container_set_border_width (GTK_CONTAINER (key_management_w), 5);
gtk_window_set_title (GTK_WINDOW (key_management_w),
"Decryption Keys Management");
gtk_window_set_position (GTK_WINDOW (key_management_w),
GTK_WIN_POS_CENTER);
-
+
#if GTK_MAJOR_VERSION >= 2
gtk_window_set_resizable (GTK_WINDOW (key_management_w), FALSE);
gtk_window_set_type_hint (GTK_WINDOW (key_management_w), GDK_WINDOW_TYPE_HINT_DIALOG);
@@ -2575,11 +2843,7 @@ gtk_widget_set_size_request (enable_decryption_cb, 83, -1);
#else
gtk_widget_set_usize (enable_decryption_cb, 83, -1);
#endif
-enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
-enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK);
-enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP);
-gtk_combo_set_popdown_strings (GTK_COMBO (enable_decryption_cb), enable_decryption_cb_items);
-g_list_free (enable_decryption_cb_items);
+update_decryption_mode_list(enable_decryption_cb);
enable_decryption_en = GTK_COMBO (enable_decryption_cb)->entry;
gtk_widget_set_name (enable_decryption_en, "enable_decryption_en");
@@ -2602,14 +2866,21 @@ gtk_box_pack_start (GTK_BOX (keys_v_sub_box), keys_scrolled_w, TRUE, TRUE,
0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (keys_scrolled_w), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+#ifdef HAVE_AIRPDCAP
key_ls = gtk_clist_new (3);
+#else
+key_ls = gtk_clist_new (2);
+#endif
+
gtk_widget_set_name (key_ls, "key_ls");
gtk_widget_show (key_ls);
gtk_container_add (GTK_CONTAINER (keys_scrolled_w), key_ls);
gtk_clist_set_column_width (GTK_CLIST (key_ls), 0, 54);
gtk_clist_set_column_width (GTK_CLIST (key_ls), 1, 113);
+#ifdef HAVE_AIRPDCAP
gtk_clist_set_column_width (GTK_CLIST (key_ls), 2, 80);
+#endif
gtk_clist_column_titles_show (GTK_CLIST (key_ls));
gtk_clist_set_shadow_type (GTK_CLIST (key_ls), GTK_SHADOW_ETCHED_IN);
gtk_clist_set_column_justification(GTK_CLIST (key_ls),0,GTK_JUSTIFY_CENTER);
@@ -2627,15 +2898,15 @@ gtk_widget_show (key_list_decryption_key_col_lb);
gtk_clist_set_column_widget (GTK_CLIST (key_ls), 1,
key_list_decryption_key_col_lb);
+#ifdef HAVE_AIRPDCAP
key_ls_decryption_ssid_col_lb = gtk_label_new ("SSID");
gtk_widget_set_name (key_ls_decryption_ssid_col_lb,
"key_ls_decryption_ssid_col_lb");
gtk_widget_show (key_ls_decryption_ssid_col_lb);
gtk_clist_set_column_widget (GTK_CLIST (key_ls), 2,
key_ls_decryption_ssid_col_lb);
+#endif
-/* XXX - USED ONLY BECAUSE WPA and WPA2 are note ready YET... */
-gtk_clist_set_column_visibility(GTK_CLIST (key_ls), 2, FALSE);
key_v_button_box = gtk_vbutton_box_new ();
gtk_widget_set_name (key_v_button_box, "key_v_button_box");
@@ -2721,7 +2992,6 @@ cancel_bt = OBJECT_GET_DATA(right_h_button_box, GTK_STOCK_CANCEL);
/* Connect the callbacks */
SIGNAL_CONNECT (key_management_w, "delete_event", window_delete_event_cb, key_management_w);
SIGNAL_CONNECT (key_management_w, "destroy", on_key_management_destroy, key_management_w);
-/*SIGNAL_CONNECT (enable_decryption_en, "changed",on_enable_decryption_en_changed, toolbar);*/
SIGNAL_CONNECT (add_new_key_bt, "clicked",on_add_new_key_bt_clicked, key_management_w);
SIGNAL_CONNECT (remove_key_bt, "clicked",on_remove_key_bt_clicked, key_management_w);
SIGNAL_CONNECT (edit_key_bt, "clicked",on_edit_key_bt_clicked, key_management_w);
@@ -2755,9 +3025,9 @@ OBJECT_SET_DATA(key_management_w,AIRPCAP_TOOLBAR_KEY,toolbar);
OBJECT_SET_DATA (key_management_w, AIRPCAP_TOOLBAR_DECRYPTION_KEY, toolbar_decryption_ck);
/* FIRST OF ALL, CHECK THE KEY COLLECTIONS */
-/*
- * This will read the decryption keys from the preferences file, and will store
- * them into the registry...
+/*
+ * This will read the decryption keys from the preferences file, and will store
+ * them into the registry...
*/
if(!airpcap_check_decryption_keys(airpcap_if_list))
{
@@ -2769,7 +3039,7 @@ else /* Keys from lists are equals, or wireshark has got no keys */
airpcap_load_decryption_keys(airpcap_if_list);
airpcap_fill_key_list(key_ls);
/* At the end, so that it appears completely all together ... */
- gtk_widget_show (key_management_w);
+ gtk_widget_show (key_management_w);
}
}
@@ -2817,24 +3087,22 @@ else if(g_strcasecmp(gtk_entry_get_text(GTK_ENTRY(decryption_en)),AIRPCAP_DECRYP
}
/* Save the configuration */
-if( (airpcap_if_selected != NULL) )
- {
airpcap_read_and_save_decryption_keys_from_clist(key_ls,airpcap_if_selected,airpcap_if_list); /* This will save the keys for every adapter */
-
- /* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
- if( g_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
- {
+
+/* The update will make redissect al the packets... no need to do it here again */
update_decryption_mode_cm(toolbar_cm);
- }
- }
/* Redissect all the packets, and re-evaluate the display filter. */
-cf_redissect_packets(&cfile);
+//cf_redissect_packets(&cfile);
/* Save the preferences to preferences file!!! */
write_prefs_to_file();
/* If interface active is airpcap, set sensitive TRUE for airpcap toolbar */
+if(airpcap_if_list != NULL)
+{
+ if(airpcap_if_active != NULL)
+ {
if( get_airpcap_if_by_name(airpcap_if_list,airpcap_if_active->description) != NULL)
{
airpcap_set_toolbar_start_capture(airpcap_if_active);
@@ -2843,6 +3111,8 @@ else
{
airpcap_set_toolbar_stop_capture(airpcap_if_active);
}
+ }
+}
gtk_widget_destroy(key_management_w);
}
@@ -2865,7 +3135,7 @@ GtkWidget *key_ls;
GtkWidget *toolbar,
*toolbar_decryption_ck,
*key_management_bt;
-
+
/* Row selected structure */
airpcap_key_ls_selected_info_t *selected_item;
@@ -2890,7 +3160,7 @@ gtk_widget_destroy(key_management_w);
}
/*
- * Dialog box that appears whenever keys are not consistent between wireshark and AirPcap
+ * Dialog box that appears whenever keys are not consistent between wireshark and AirPcap
*/
void
airpcap_keys_check_w(GtkWidget *w, gpointer data)
@@ -3061,9 +3331,9 @@ gtk_button_box_set_layout (GTK_BUTTON_BOX (low_h_button_box),
GTK_BUTTONBOX_SPREAD);
#if GTK_MAJOR_VERSION >= 2
-ok_bt = gtk_button_new_with_mnemonic ("Ok");
+ok_bt = gtk_button_new_with_mnemonic ("OK");
#else
-ok_bt = gtk_button_new_with_label ("Ok");
+ok_bt = gtk_button_new_with_label ("OK");
#endif
gtk_widget_set_name (ok_bt, "ok_bt");
gtk_widget_show (ok_bt);
@@ -3108,7 +3378,7 @@ keys_check_w = GTK_WIDGET(user_data);
key_management_w = OBJECT_GET_DATA(keys_check_w,AIRPCAP_CHECK_WINDOW_KEY);
-/* w may be NULL if airpcap_keys_check_w() has been called while wireshark was loading,
+/* w may be NULL if airpcap_keys_check_w() has been called while wireshark was loading,
and is not NULL if it was called when the Key Management widget has been clicked */
if(key_management_w != NULL)
{
@@ -3193,12 +3463,11 @@ write_prefs_to_file();
/* Free the memory */
free_key_list(wireshark_keys);
-free_key_list(merged_keys);
/* Close the window */
gtk_widget_destroy(keys_check_w);
-/* w may be NULL if airpcap_keys_check_w() has been called while wireshark was loading,
+/* w may be NULL if airpcap_keys_check_w() has been called while wireshark was loading,
and is not NULL if it was called when the Key Management widget has been clicked */
if(key_management_w != NULL)
{
@@ -3259,11 +3528,11 @@ for(i = 0; i<n_adapters; i++)
current_adapter_keys = get_airpcap_device_keys(curr_adapter);
n_curr_adapter_keys = g_list_length(current_adapter_keys);
- merged_list_tmp = merged_list;
- merged_list = merge_key_list(merged_list_tmp,current_adapter_keys);
+ merged_list_tmp = merged_list;
+ merged_list = merge_key_list(merged_list_tmp,current_adapter_keys);
free_key_list(merged_list_tmp);
-
- n_total_keys += n_curr_adapter_keys;
+
+ n_total_keys += n_curr_adapter_keys;
}
n_merged_keys = g_list_length(merged_list);
@@ -3279,7 +3548,7 @@ free_key_list(driver_keys);
gtk_widget_destroy(keys_check_w);
-/* w may be NULL if airpcap_keys_check_w() has been called while wireshark was loading,
+/* w may be NULL if airpcap_keys_check_w() has been called while wireshark was loading,
and is not NULL if it was called when the Key Management widget has been clicked */
if(key_management_w != NULL)
{
@@ -3338,11 +3607,11 @@ for(i = 0; i<n_adapters; i++)
current_adapter_keys = get_airpcap_device_keys(curr_adapter);
n_curr_adapter_keys = g_list_length(current_adapter_keys);
- merged_list_tmp = merged_list;
- merged_list = merge_key_list(merged_list_tmp,current_adapter_keys);
+ merged_list_tmp = merged_list;
+ merged_list = merge_key_list(merged_list_tmp,current_adapter_keys);
free_key_list(merged_list_tmp);
-
- n_total_keys += n_curr_adapter_keys;
+
+ n_total_keys += n_curr_adapter_keys;
}
n_merged_keys = g_list_length(merged_list);
@@ -3358,7 +3627,7 @@ free_key_list(driver_keys);
gtk_widget_destroy(keys_check_w);
-/* w may be NULL if airpcap_keys_check_w() has been called while wireshark was loading,
+/* w may be NULL if airpcap_keys_check_w() has been called while wireshark was loading,
and is not NULL if it was called when the Key Management widget has been clicked */
if(key_management_w != NULL)
{
@@ -3381,7 +3650,7 @@ keys_check_w = GTK_WIDGET(user_data);
key_management_w = OBJECT_GET_DATA(keys_check_w,AIRPCAP_CHECK_WINDOW_KEY);
-/* w may be NULL if airpcap_keys_check_w() has been called while wireshark was loading,
+/* w may be NULL if airpcap_keys_check_w() has been called while wireshark was loading,
and is not NULL if it was called when the Key Management widget has been clicked */
if(key_management_w != NULL)
{
diff --git a/gtk/airpcap_dlg.h b/gtk/airpcap_dlg.h
index 870a5617bf..e5fbcc904d 100644
--- a/gtk/airpcap_dlg.h
+++ b/gtk/airpcap_dlg.h
@@ -80,6 +80,12 @@ void
airpcap_fill_if_combo(GtkWidget *combo, GList* if_list);
/*
+ * Creates the list of available decryption modes, depending on the adapters found
+ */
+void
+update_decryption_mode_list(GtkWidget *w);
+
+/*
* Callback for the 'Add Key' button.
*/
void
diff --git a/gtk/airpcap_gui_utils.c b/gtk/airpcap_gui_utils.c
index 20c6e47ce0..92b558d4c0 100755
--- a/gtk/airpcap_gui_utils.c
+++ b/gtk/airpcap_gui_utils.c
@@ -50,6 +50,8 @@
#include "airpcap_loader.h"
#include "airpcap_gui_utils.h"
+#include "../airpdcap/airpdcap_ws.h"
+
#include "keys.h"
/*
@@ -100,33 +102,42 @@ return channels;
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_channel_lb;
GtkWidget *airpcap_toolbar_button;
+GtkWidget *airpcap_toolbar_fcs;
+GtkWidget *airpcap_toolbar_fcs_lb;
GtkWidget *airpcap_toolbar_decryption;
+GtkWidget *airpcap_toolbar_decryption_lb;
GtkWidget *airpcap_toolbar_keys_button;
gchar *if_label_text;
-airpcap_toolbar_crc_filter_combo = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_FCS_FILTER_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_channel_lb = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
+airpcap_toolbar_fcs = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
+airpcap_toolbar_fcs_lb = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_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);
+airpcap_toolbar_decryption_lb = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_LABEL_KEY);
airpcap_toolbar_keys_button = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_KEY_MANAGEMENT_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_label,TRUE);
gtk_widget_set_sensitive(airpcap_toolbar_channel,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_fcs,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,FALSE);
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);
+ gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_keys_button,FALSE);
- airpcap_validation_type_combo_set_by_type(GTK_WIDGET(airpcap_toolbar_crc_filter_combo),if_info->CrcValidationOn);
airpcap_update_channel_combo(GTK_WIDGET(airpcap_toolbar_channel),if_info);
/*decription check box*/
@@ -137,27 +148,24 @@ if(if_info != NULL)
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("AirPcap Interface: #%s", airpcap_get_if_string_number(if_info));
+ if_label_text = g_strdup_printf("Current Wireless Interface: #%s", 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)
+else /* Current interface is NOT an AirPcap one... */
{
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),"AirPcap interface: Not selected");
- }
- else
- {
- /* this shouldn't be visible as the toolbar is hidden if no AirPcap available */
- 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),"AirPcap interface: None available");
- }
+ gtk_widget_set_sensitive(airpcap_toolbar_label,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_channel,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_fcs,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_decryption,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_keys_button,FALSE);
+ airpcap_set_toolbar_no_if(airpcap_tb);
}
}
@@ -170,8 +178,12 @@ 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_channel_lb;
GtkWidget *airpcap_toolbar_button;
+GtkWidget *airpcap_toolbar_fcs;
+GtkWidget *airpcap_toolbar_fcs_lb;
GtkWidget *airpcap_toolbar_decryption;
+GtkWidget *airpcap_toolbar_decryption_lb;
GtkWidget *airpcap_toolbar_keys_button;
gchar *if_label_text;
@@ -179,19 +191,27 @@ gchar *if_label_text;
airpcap_toolbar_crc_filter_combo = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_FCS_FILTER_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_channel_lb = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
+airpcap_toolbar_fcs = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
+airpcap_toolbar_fcs_lb = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_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);
+airpcap_toolbar_decryption_lb = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_LABEL_KEY);
airpcap_toolbar_keys_button = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_KEY_MANAGEMENT_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_label,TRUE);
gtk_widget_set_sensitive(airpcap_toolbar_channel,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_fcs,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,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);
+ gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,TRUE);
gtk_widget_set_sensitive(airpcap_toolbar_keys_button,TRUE);
airpcap_validation_type_combo_set_by_type(GTK_WIDGET(airpcap_toolbar_crc_filter_combo),if_info->CrcValidationOn);
airpcap_update_channel_combo(GTK_WIDGET(airpcap_toolbar_channel),if_info);
@@ -205,27 +225,24 @@ if(if_info != NULL)
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("AirPcap Interface: #%s", airpcap_get_if_string_number(if_info));
+ if_label_text = g_strdup_printf("Current Wireless Interface: #%s", 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),"AirPcap interface: Not selected");
- }
- else
- {
- /* this shouldn't be visible as the toolbar is hidden if no AirPcap available */
- 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),"AirPcap interface: None available");
- }
+ gtk_widget_set_sensitive(airpcap_tb,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_label,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_channel,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_fcs,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_crc_filter_combo,FALSE);
+ gtk_widget_set_sensitive(airpcap_toolbar_decryption,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,TRUE);
+ gtk_widget_set_sensitive(airpcap_toolbar_keys_button,TRUE);
+ airpcap_set_toolbar_no_if(airpcap_tb);
}
}
@@ -271,12 +288,16 @@ g_free(new_row[2]);
}
/*
- * Fill the list with the keys
+ * Fill the list with the keys. BEWARE! At this point, Wireshark and Drivers
+ * keys should be EQUALS! But is better to load keys from Wireshark, because
+ * the driver is not always present, and maybe that cannot support some keys
+ * (i.e. the WPA problem)
*/
void
airpcap_fill_key_list(GtkWidget *keylist)
{
-gchar* s;
+gchar* s = NULL;
+gchar* s2 = NULL;
unsigned int i,n;
gchar* new_row[3];
airpcap_if_info_t* fake_if_info;
@@ -288,40 +309,44 @@ n = 0;
fake_if_info = airpcap_driver_fake_if_info_new();
/* We can retrieve the driver's key list (i.e. we have the right .dll)*/
- if( (fake_if_info != NULL) && (fake_if_info->keysCollection != NULL))
- {
- n = fake_if_info->keysCollection->nKeys;
+ wireshark_key_list = get_wireshark_keys();
+ n = g_list_length(wireshark_key_list);
+
for(i = 0; i < n; i++)
{
- s = airpcap_get_key_string(fake_if_info->keysCollection->Keys[i]);
+ curr_key = (decryption_key_t*)g_list_nth_data(wireshark_key_list,i);
- if(fake_if_info->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_WEP)
+ if(curr_key->type == AIRPDCAP_KEY_TYPE_WEP)
{
+ s = g_strdup(curr_key->key->str);
+
new_row[0] = g_strdup(AIRPCAP_WEP_KEY_STRING);
new_row[1] = g_strdup(s);
new_row[2] = g_strdup("");
+
+ gtk_clist_append(GTK_CLIST(keylist),new_row);
+
+ g_free(new_row[0]);
+ g_free(new_row[1]);
+ g_free(new_row[2]);
+
+ g_free(s);
}
- else if(fake_if_info->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_TKIP)
- {
- new_row[0] = g_strdup(AIRPCAP_WPA_KEY_STRING);
- new_row[1] = g_strdup(s);
- /* XXX - Put here the SSID */
- new_row[2] = g_strdup("");
- }
- else if(fake_if_info->keysCollection->Keys[i].KeyType == AIRPCAP_KEYTYPE_CCMP)
+ else if(curr_key->type == AIRPDCAP_KEY_TYPE_WPA_PWD)
{
- new_row[0] = g_strdup(AIRPCAP_WPA2_KEY_STRING);
+ s = g_strdup(curr_key->key->str);
+ if(curr_key->ssid != NULL)
+ s2= g_strdup(curr_key->ssid->str);
+ else
+ s2 = NULL;
+
+ new_row[0] = g_strdup(AIRPCAP_WPA_PWD_KEY_STRING);
new_row[1] = g_strdup(s);
- /* XXX - Put here the SSID */
- new_row[2] = g_strdup("");
- }
+
+ if(curr_key->ssid != NULL)
+ new_row[2] = g_strdup(s2);
else
- {
- /* This should never happen... but just in case... */
- new_row[0] = g_strdup("");
- new_row[1] = g_strdup("");
new_row[2] = g_strdup("");
- }
gtk_clist_append(GTK_CLIST(keylist),new_row);
@@ -330,19 +355,13 @@ fake_if_info = airpcap_driver_fake_if_info_new();
g_free(new_row[2]);
g_free(s);
+ if(s2 != NULL) g_free(s2);
}
- }
- else
- {
- wireshark_key_list = get_wireshark_keys();
- n = g_list_length(wireshark_key_list);
-
- for(i = 0; i < n; i++)
+ else if(curr_key->type == AIRPDCAP_KEY_TYPE_WPA_PMK)
{
- curr_key = (decryption_key_t*)g_list_nth_data(wireshark_key_list,i);
s = g_strdup(curr_key->key->str);
- new_row[0] = g_strdup(AIRPCAP_WEP_KEY_STRING);
+ new_row[0] = g_strdup(AIRPCAP_WPA_BIN_KEY_STRING);
new_row[1] = g_strdup(s);
new_row[2] = g_strdup("");
@@ -628,10 +647,10 @@ for(i = 0; i < keys_in_list; i++)
gtk_clist_get_text(GTK_CLIST(key_ls),i,2,&row_ssid);
if(g_strcasecmp(row_type,AIRPCAP_WEP_KEY_STRING) == 0)
- KeysCollection->Keys[i].KeyType = AIRPCAP_KEYTYPE_WEP;
- else if(g_strcasecmp(row_type,AIRPCAP_WPA_KEY_STRING) == 0)
+ KeysCollection->Keys[i].KeyType = AIRPDCAP_KEY_TYPE_WEP;
+ else if(g_strcasecmp(row_type,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
KeysCollection->Keys[i].KeyType = AIRPCAP_KEYTYPE_TKIP;
- else if(g_strcasecmp(row_type,AIRPCAP_WPA2_KEY_STRING) == 0)
+ else if(g_strcasecmp(row_type,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
KeysCollection->Keys[i].KeyType = AIRPCAP_KEYTYPE_CCMP;
/* Retrieve the Item corresponding to the i-th key */
@@ -727,11 +746,11 @@ for(i = 0; i < keys_in_list; i++)
gtk_clist_get_text(GTK_CLIST(key_ls),i,2,&row_ssid);
if(g_strcasecmp(row_type,AIRPCAP_WEP_KEY_STRING) == 0)
- KeysCollection->Keys[i].KeyType = AIRPCAP_KEYTYPE_WEP;
- else if(g_strcasecmp(row_type,AIRPCAP_WPA_KEY_STRING) == 0)
- KeysCollection->Keys[i].KeyType = AIRPCAP_KEYTYPE_TKIP;
- else if(g_strcasecmp(row_type,AIRPCAP_WPA2_KEY_STRING) == 0)
- KeysCollection->Keys[i].KeyType = AIRPCAP_KEYTYPE_CCMP;
+ KeysCollection->Keys[i].KeyType = AIRPDCAP_KEY_TYPE_WEP;
+ else if(g_strcasecmp(row_type,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
+ KeysCollection->Keys[i].KeyType = AIRPDCAP_KEY_TYPE_WPA_PWD;
+ else if(g_strcasecmp(row_type,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
+ KeysCollection->Keys[i].KeyType = AIRPDCAP_KEY_TYPE_WPA_PMK;
/* Retrieve the Item corresponding to the i-th key */
new_key = g_string_new(row_key);
@@ -739,6 +758,9 @@ for(i = 0; i < keys_in_list; i++)
KeysCollection->Keys[i].KeyLen = new_key->len / 2;
memset(&KeysCollection->Keys[i].KeyData, 0, sizeof(KeysCollection->Keys[i].KeyData));
+ /* Key must be saved in adifferent way, depending on its type... */
+ if(KeysCollection->Keys[i].KeyType == AIRPDCAP_KEY_TYPE_WEP)
+ {
for(j = 0 ; j < new_key->len; j += 2)
{
s[0] = new_key->str[j];
@@ -748,6 +770,8 @@ for(i = 0; i < keys_in_list; i++)
KeysCollection->Keys[i].KeyData[j / 2] = KeyByte;
}
}
+ /* XXX - Save the keys that are not WEP!!! */
+}
/*
* Free the old adapter key collection!
@@ -777,19 +801,70 @@ gint n = 0;
airpcap_if_info_t* curr_if = NULL;
airpcap_if_info_t* fake_info_if = NULL;
GList* key_list=NULL;
+
+char* tmp_type = NULL;
char* tmp_key = NULL;
+char* tmp_ssid = NULL;
+
+decryption_key_t* tmp_dk=NULL;
+
+/*
+ * Save the keys for Wireshark...
+ */
+
+/* Create a list of keys from the list widget... */
+n = GTK_CLIST(key_ls)->rows;
+
+for(i = 0; i < n; i++)
+ {
+ /* XXX - Create a decryption_key_t struct, and pass a list of those structs!!! */
+ gtk_clist_get_text(GTK_CLIST(key_ls),i,0,&tmp_type);
+ gtk_clist_get_text(GTK_CLIST(key_ls),i,1,&tmp_key);
+ gtk_clist_get_text(GTK_CLIST(key_ls),i,2,&tmp_ssid);
+
+ if(g_strcasecmp(tmp_type,AIRPCAP_WEP_KEY_STRING) == 0)
+ {
+ tmp_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+ tmp_dk->key = g_string_new(tmp_key);
+ tmp_dk->ssid = NULL;
+ tmp_dk->type = AIRPDCAP_KEY_TYPE_WEP;
+ tmp_dk->bits = tmp_dk->key->len * 4;
+ key_list = g_list_append(key_list,tmp_dk);
+ }
+ else if(g_strcasecmp(tmp_type,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
+ {
+ tmp_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+ tmp_dk->key = g_string_new(tmp_key);
+ tmp_dk->ssid = g_string_new(tmp_ssid);
+ tmp_dk->type = AIRPDCAP_KEY_TYPE_WPA_PWD;
+ tmp_dk->bits = 256;
+ key_list = g_list_append(key_list,tmp_dk);
+ }
+ else if(g_strcasecmp(tmp_type,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
+ {
+ tmp_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+ tmp_dk->key = g_string_new(tmp_key);
+ tmp_dk->ssid = NULL; /* No SSID in this case */
+ tmp_dk->type = AIRPDCAP_KEY_TYPE_WPA_PMK;
+ tmp_dk->bits = 256;
+ key_list = g_list_append(key_list,tmp_dk);
+ }
+ }
+
+r = save_wlan_wireshark_wep_keys(key_list);
+/* The key_list has been freed!!! */
/*
* Save the key list for driver.
*/
+if( (if_list == NULL) || (info_if == NULL) ) return;
+
fake_info_if = airpcap_driver_fake_if_info_new();
airpcap_add_keys_to_driver_from_list(key_ls,fake_info_if);
airpcap_save_driver_if_configuration(fake_info_if);
airpcap_if_info_free(fake_info_if);
-if( (if_list == NULL) || (info_if == NULL) ) return;
-
if_n = g_list_length(if_list);
/* For all the adapters in the list, empty the key list */
@@ -806,28 +881,11 @@ for(i = 0; i < if_n; i++)
airpcap_save_selected_if_configuration(curr_if);
}
}
-
-/* Save the settings of the given interface as default for Wireshark...
- * By the way, now all the adapters have the same keys, so it is not
- * really necessary to use THIS specific one...
- */
-if( (r = save_wlan_driver_wep_keys()) == 0)
- {
- /* Create a list of keys from the list widget... */
- n = GTK_CLIST(key_ls)->rows;
- for(i = 0; i < n; i++)
- {
- gtk_clist_get_text(GTK_CLIST(key_ls),i,1,&tmp_key);
- key_list = g_list_append(key_list,(gpointer)g_strdup(tmp_key));
- }
-
- r = save_wlan_wireshark_wep_keys(key_list);
- }
}
/*
* This function will load from the preferences file ALL the
- * keys (WEP, WPA and WPA2) and will set them as default for
+ * keys (WEP, WPA and WPA_BIN) and will set them as default for
* each adapter. To do this, it will save the keys in the registry...
* A check will be performed, to make sure that keys found in
* registry and keys found in Wireshark preferences are the same. If not,
@@ -892,7 +950,7 @@ return equals;
/*
* This function will load from the preferences file ALL the
- * keys (WEP, WPA and WPA2) and will set them as default for
+ * keys (WEP, WPA_PWD and WPA_BIN) and will set them as default for
* each adapter. To do this, it will save the keys in the registry...
* A check will be performed, to make sure that keys found in
* registry and keys found in Wireshark preferences are the same. If not,
@@ -952,7 +1010,85 @@ for(i = 0; i < if_n; i++)
* This will set the keys of the current adapter as Wireshark default...
* Now all the adapters have the same keys, so curr_if is ok as any other...
*/
-save_wlan_driver_wep_keys();
+save_wlan_wireshark_wep_keys(key_list);
+}
+
+/*
+ * This function is used to enable/disable the toolbar widgets
+ * depending on the type of interface selected... Not the whole
+ * toolbar must be grayed/enabled ... Only some widgets...
+ */
+void
+airpcap_enable_toolbar_widgets(GtkWidget* w, gboolean en)
+{
+GtkWidget *toolbar_tb,
+ *if_description_lb,
+ *channel_cb,
+ *channel_lb,
+ *fcs_cb,
+ *fcs_lb,
+ *advanced_bt;
+
+if(w == NULL)
+ return;
+
+toolbar_tb = w;
+
+if_description_lb = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_INTERFACE_KEY);
+channel_lb = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
+channel_cb = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_CHANNEL_KEY);
+fcs_lb = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY);
+fcs_cb = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
+advanced_bt = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_ADVANCED_KEY);
+
+
+if(if_description_lb != NULL) gtk_widget_set_sensitive(if_description_lb,en);
+if(channel_lb != NULL) gtk_widget_set_sensitive(channel_lb,en);
+if(channel_cb != NULL) gtk_widget_set_sensitive(channel_cb,en);
+if(fcs_lb != NULL) gtk_widget_set_sensitive(fcs_lb,en);
+if(fcs_cb != NULL) gtk_widget_set_sensitive(fcs_cb,en);
+if(advanced_bt != NULL) gtk_widget_set_sensitive(advanced_bt,en);
+
+return;
+}
+
+/*
+ * This function sets up the correct airpcap toolbar that must
+ * be displayed when no airpcap if is found on the system...
+ */
+void
+airpcap_set_toolbar_no_if(GtkWidget* w)
+{
+GtkWidget *toolbar_tb,
+ *if_description_lb,
+ *channel_cb,
+ *channel_lb,
+ *fcs_cb,
+ *fcs_lb,
+ *advanced_bt;
+
+if(w == NULL)
+ return;
+
+toolbar_tb = w;
+
+if_description_lb = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_INTERFACE_KEY);
+channel_lb = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
+channel_cb = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_CHANNEL_KEY);
+fcs_lb = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY);
+fcs_cb = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
+advanced_bt = OBJECT_GET_DATA(toolbar_tb,AIRPCAP_TOOLBAR_ADVANCED_KEY);
+
+if(fcs_cb != NULL) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(fcs_cb)->entry),"");
+if(channel_cb != NULL) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cb)->entry),"");
+if(if_description_lb != NULL) gtk_label_set_text(GTK_LABEL(if_description_lb),"Current Wireless Interface: None");
+
+/*if(if_description_lb != NULL) gtk_widget_set_sensitive(if_description_lb,FALSE);
+if(channel_lb != NULL) gtk_widget_set_sensitive(channel_lb,FALSE);
+if(channel_cb != NULL) gtk_widget_set_sensitive(channel_cb,FALSE);
+if(fcs_lb != NULL) gtk_widget_set_sensitive(fcs_lb,FALSE);
+if(fcs_cb != NULL) gtk_widget_set_sensitive(fcs_cb,FALSE);
+if(advanced_bt != NULL) gtk_widget_set_sensitive(advanced_bt,FALSE);*/
}
#endif /* HAVE_AIRPCAP */
diff --git a/gtk/airpcap_gui_utils.h b/gtk/airpcap_gui_utils.h
index ab01366ef4..d4e4e7c604 100755
--- a/gtk/airpcap_gui_utils.h
+++ b/gtk/airpcap_gui_utils.h
@@ -191,7 +191,7 @@ airpcap_read_and_save_decryption_keys_from_clist(GtkWidget* key_ls, airpcap_if_i
/*
* This function will load from the preferences file ALL the
- * keys (WEP, WPA and WPA2) and will set them as default for
+ * keys (WEP, WPA and WPA_BIN) and will set them as default for
* each adapter. To do this, it will save the keys in the registry...
*/
void
@@ -199,7 +199,7 @@ airpcap_load_decryption_keys(GList* if_list);
/*
* This function will load from the preferences file ALL the
- * keys (WEP, WPA and WPA2) and will set them as default for
+ * keys (WEP, WPA and WPA_BIN) and will set them as default for
* each adapter. To do this, it will save the keys in the registry...
*/
gboolean
@@ -212,4 +212,18 @@ airpcap_check_decryption_keys(GList* if_list);
void
airpcap_save_decryption_keys(GList* key_list, GList* adapters_list);
+/*
+ * This function is used to enable/disable the toolbar widgets
+ * depending on the type of interface selected...
+ */
+void
+airpcap_enable_toolbar_widgets(GtkWidget* w, gboolean en);
+
+/*
+ * This function sets up the correct airpcap toolbar that must
+ * be displayed when no airpcap if is found on the system...
+ */
+void
+airpcap_set_toolbar_no_if(GtkWidget* w);
+
#endif
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index 32478983f4..aa202d26d7 100644
--- a/gtk/capture_dlg.c
+++ b/gtk/capture_dlg.c
@@ -202,7 +202,7 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
/* 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);
+ airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
if( airpcap_if_selected != NULL)
{
gtk_widget_set_sensitive(advanced_bt,TRUE);
@@ -530,7 +530,7 @@ from_widget = (gint*)g_malloc(sizeof(gint));
OBJECT_SET_DATA(airpcap_tb,AIRPCAP_ADVANCED_FROM_KEY,from_widget);
airpcap_if_active = airpcap_if_selected;
-gtk_widget_set_sensitive(airpcap_tb,FALSE);
+airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
display_airpcap_advanced_cb(w,d);
}
#endif
@@ -580,8 +580,8 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
GtkAdjustment *snap_adj, *ringbuffer_nbf_adj,
*stop_packets_adj, *stop_filesize_adj, *stop_duration_adj, *stop_files_adj, *ring_filesize_adj, *file_duration_adj;
GList *if_list, *combo_list, *cfilter_list;
- int err;
int row;
+ int err;
char err_str[CAPTURE_PCAP_ERRBUF_SIZE];
gchar *cant_get_if_list_errstr;
#ifdef _WIN32
@@ -592,6 +592,8 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
gchar *cap_title;
gchar *if_device;
+ GtkWidget *decryption_cm;
+
if (cap_open_w != NULL) {
/* There's already a "Capture Options" dialog box; reactivate it. */
reactivate_window(cap_open_w);
@@ -623,6 +625,9 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
/* load the airpcap interfaces */
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
+ decryption_cm = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
+ update_decryption_mode_list(decryption_cm);
+
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",
diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c
index 0c0dccd101..340206b02d 100644
--- a/gtk/capture_if_dlg.c
+++ b/gtk/capture_if_dlg.c
@@ -401,6 +401,8 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
*help_bt,
*icon;
+ GtkWidget *decryption_cm;
+
GtkWidget *if_tb;
GtkWidget *if_lb;
#if GTK_MAJOR_VERSION < 2
@@ -453,6 +455,10 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
/* LOAD AIRPCAP INTERFACES */
/* load the airpcap interfaces */
airpcap_if_list = get_airpcap_interface_list(&err, err_str);
+ if(airpcap_if_list == NULL) airpcap_if_active = airpcap_if_selected = NULL;
+
+ decryption_cm = OBJECT_GET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_KEY);
+ update_decryption_mode_list(decryption_cm);
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);
@@ -467,13 +473,13 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
if(airpcap_if_list == NULL)
{
/*No airpcap device found */
- gtk_widget_set_sensitive(airpcap_tb,FALSE);
+ airpcap_enable_toolbar_widgets(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_enable_toolbar_widgets(airpcap_tb,FALSE);
}
}
diff --git a/gtk/keys.h b/gtk/keys.h
index 5a5ca43833..23dfd554ff 100644
--- a/gtk/keys.h
+++ b/gtk/keys.h
@@ -52,11 +52,14 @@
#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_CHANNEL_LABEL_KEY "airpcap_toolbar_ch_lb_key"
#define AIRPCAP_TOOLBAR_FCS_CHECK_KEY "airpcap_toolbar_fcs_check_key"
+#define AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY "airpcap_toolbar_fcs_filter_lb_key"
#define AIRPCAP_TOOLBAR_FCS_FILTER_KEY "airpcap_toolbar_fcs_filter_key"
#define AIRPCAP_TOOLBAR_ADVANCED_KEY "airpcap_toolbar_advanced_key"
#define AIRPCAP_TOOLBAR_KEY_MANAGEMENT_KEY "airpcap_toolbar_key_management_key"
#define AIRPCAP_TOOLBAR_DECRYPTION_KEY "airpcap_toolbar_decryption_key"
+#define AIRPCAP_TOOLBAR_DECRYPTION_LABEL_KEY "airpcap_toolbar_decryption_lb_key"
#define AIRPCAP_ADVANCED_KEY "airpcap_advanced_key"
#define AIRPCAP_ADVANCED_INTERFACE_KEY "airpcap_advanced_if_key"
@@ -71,12 +74,16 @@
#define AIRPCAP_ADVANCED_ADD_KEY_TYPE_KEY "airpcap_advanced_add_key_type_key"
#define AIRPCAP_ADVANCED_ADD_KEY_KEY_KEY "airpcap_advanced_add_key_key_key"
#define AIRPCAP_ADVANCED_ADD_KEY_SSID_KEY "airpcap_advanced_add_key_ssid_key"
+#define AIRPCAP_ADVANCED_ADD_KEY_KEY_LABEL_KEY "airpcap_advanced_add_key_key_label_key"
+#define AIRPCAP_ADVANCED_ADD_KEY_SSID_LABEL_KEY "airpcap_advanced_add_key_ssid_label_key"
#define AIRPCAP_ADVANCED_EDIT_KEY_SELECTED_KEY "airpcap_advanced_edit_key_selected_key"
#define AIRPCAP_ADVANCED_EDIT_KEY_OK_KEY "airpcap_advanced_edit_key_ok_key"
#define AIRPCAP_ADVANCED_EDIT_KEY_LIST_KEY "airpcap_advanced_edit_key_list_key"
#define AIRPCAP_ADVANCED_EDIT_KEY_TYPE_KEY "airpcap_advanced_edit_key_type_key"
#define AIRPCAP_ADVANCED_EDIT_KEY_KEY_KEY "airpcap_advanced_edit_key_key_key"
#define AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY "airpcap_advanced_edit_key_ssid_key"
+#define AIRPCAP_ADVANCED_EDIT_KEY_KEY_LABEL_KEY "airpcap_advanced_edit_key_key_label_key"
+#define AIRPCAP_ADVANCED_EDIT_KEY_SSID_LABEL_KEY "airpcap_advanced_edit_key_ssid_label_key"
#define AIRPCAP_ADVANCED_WEP_DECRYPTION_KEY "airpcap_advanced_wep_decryption_key"
#define AIRPCAP_ADVANCED_WPA_DECRYPTION_KEY "airpcap_advanced_wpa_decryption_key"
#define AIRPCAP_ADVANCED_NOTEBOOK_KEY "airpcap_advanced_notebook_key"
diff --git a/gtk/main.c b/gtk/main.c
index 08905fb5d2..150f7eb5d4 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -172,6 +172,12 @@
#include "./image/toolbar/wep_closed_24.xpm"
#endif
+#ifdef HAVE_AIRPDCAP
+/* Davide Schiera (2006-11-22): including AirPDcap project */
+#include "..\airpdcap\airpdcap_ws.h"
+/* Davide Schiera (2006-11-22) ---------------------------------------------- */
+#endif
+
/*
* Files under personal and global preferences directories in which
* GTK settings for Wireshark are stored.
@@ -2116,6 +2122,12 @@ main(int argc, char *argv[])
char optstring[sizeof(OPTSTRING_INIT) + sizeof(OPTSTRING_WIN32) - 1] =
OPTSTRING_INIT OPTSTRING_WIN32;
+#ifdef HAVE_AIRPDCAP
+ /* Davide Schiera (2006-11-18): init AirPDcap context */
+ AirPDcapInitContext(&airpdcap_ctx);
+ /* Davide Schiera (2006-11-18) ------------------------------------------- */
+#endif
+
/*
* Attempt to get the pathname of the executable file.
*/
@@ -2995,6 +3007,12 @@ main(int argc, char *argv[])
epan_cleanup();
g_free(rc_file);
+#ifdef HAVE_AIRPDCAP
+ /* Davide Schiera (2006-11-18): destroy AirPDcap context */
+ AirPDcapDestroyContext(&airpdcap_ctx);
+ /* Davide Schiera (2006-11-18) ------------------------------------------- */
+#endif
+
#ifdef _WIN32
/* hide the (unresponsive) main window, while asking the user to close the console window */
gtk_widget_hide(top_level);
@@ -3991,6 +4009,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
/* Create the "802.11 Channel:" label */
channel_lb = gtk_label_new(" 802.11 Channel: ");
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY,channel_lb);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), channel_lb,
"Current 802.11 Channel", "Private");
gtk_widget_show(channel_lb);
@@ -4040,6 +4059,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
/* Wrong CRC Label */
wrong_crc_lb = gtk_label_new(" FCS Filter: ");
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY,wrong_crc_lb);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), wrong_crc_lb,
"", "Private");
gtk_widget_show(wrong_crc_lb);
@@ -4058,7 +4078,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
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),
+ 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);
@@ -4074,6 +4094,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
/* Decryption mode combo box */
enable_decryption_lb = gtk_label_new ("Decryption Mode: ");
+ OBJECT_SET_DATA(airpcap_tb,AIRPCAP_TOOLBAR_DECRYPTION_LABEL_KEY,enable_decryption_lb);
gtk_widget_set_name (enable_decryption_lb, "enable_decryption_lb");
gtk_widget_show (enable_decryption_lb);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), enable_decryption_lb,
@@ -4083,11 +4104,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
gtk_widget_set_name (enable_decryption_cb, "enable_decryption_cb");
gtk_widget_show (enable_decryption_cb);
WIDGET_SET_SIZE (enable_decryption_cb, 83, -1);
- enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
- enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK);
- enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP);
- gtk_combo_set_popdown_strings (GTK_COMBO (enable_decryption_cb), enable_decryption_cb_items);
- g_list_free (enable_decryption_cb_items);
+ update_decryption_mode_list(enable_decryption_cb);
enable_decryption_en = GTK_COMBO (enable_decryption_cb)->entry;
gtk_widget_set_name (enable_decryption_en, "enable_decryption_en");
@@ -4130,17 +4147,17 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
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;
+ airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
+ //recent.airpcap_toolbar_show = TRUE;
} 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;
+ airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
+ //recent.airpcap_toolbar_show = TRUE;
}
} else {
airpcap_set_toolbar_stop_capture(airpcap_if_active);
- recent.airpcap_toolbar_show = TRUE;
+ //recent.airpcap_toolbar_show = TRUE;
}
#endif