217
219
edit_ssid_te = OBJECT_GET_DATA(edit_key_w,AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY);
220
key_lb = OBJECT_GET_DATA(edit_key_w,AIRPCAP_ADVANCED_EDIT_KEY_KEY_LABEL_KEY);
221
ssid_lb = OBJECT_GET_DATA(edit_key_w,AIRPCAP_ADVANCED_EDIT_KEY_SSID_LABEL_KEY);
219
223
type_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(type_te)));
221
225
if(string_is_not_empty(type_text))
224
* If it is a WEP key, no SSID is required! Gray out rhe entry text so
228
* If it is a WEP key, no SSID is required! Gray out rhe entry text so
225
229
* it doesn't create confusion ...
227
231
if(g_strcasecmp(type_text,AIRPCAP_WEP_KEY_STRING) == 0)
229
233
gtk_widget_set_sensitive(edit_ssid_te,FALSE);
235
* Maybe the user has already entered some text into the SSID field
236
* and then switched to WEP...
238
gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),"");
239
gtk_label_set_text(GTK_LABEL(key_lb),"Key");
240
gtk_label_set_text(GTK_LABEL(ssid_lb),"");
242
else if(g_strcasecmp(type_text,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
244
gtk_widget_set_sensitive(edit_ssid_te,FALSE);
246
* Maybe the user has already entered some text into the SSID field
247
* and then switched to WEP...
249
gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),"");
250
gtk_label_set_text(GTK_LABEL(key_lb),"Key");
251
gtk_label_set_text(GTK_LABEL(ssid_lb),"");
253
else if(g_strcasecmp(type_text,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
233
255
gtk_widget_set_sensitive(edit_ssid_te,TRUE);
257
* Maybe the user has already entered some text into the SSID field
258
* and then switched to WEP...
260
gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),"");
261
gtk_label_set_text(GTK_LABEL(key_lb),"Passphrase");
262
gtk_label_set_text(GTK_LABEL(ssid_lb),"SSID");
236
265
gtk_widget_show(edit_ssid_te);
256
287
add_ssid_te = OBJECT_GET_DATA(add_key_w,AIRPCAP_ADVANCED_ADD_KEY_SSID_KEY);
288
key_lb = OBJECT_GET_DATA(add_key_w,AIRPCAP_ADVANCED_ADD_KEY_KEY_LABEL_KEY);
289
ssid_lb = OBJECT_GET_DATA(add_key_w,AIRPCAP_ADVANCED_ADD_KEY_SSID_LABEL_KEY);
258
291
type_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(type_te)));
260
293
if(string_is_not_empty(type_text))
263
* If it is a WEP key, no SSID is required! Gray out rhe entry text so
296
* If it is a WEP key, no SSID is required! Gray out rhe entry text so
264
297
* it doesn't create confusion ...
266
299
if(g_strcasecmp(type_text,AIRPCAP_WEP_KEY_STRING) == 0)
268
301
gtk_widget_set_sensitive(add_ssid_te,FALSE);
303
* Maybe the user has already entered some text into the SSID field
304
* and then switched to WEP...
306
gtk_entry_set_text(GTK_ENTRY(add_ssid_te),"");
307
gtk_label_set_text(GTK_LABEL(key_lb),"Key");
308
gtk_label_set_text(GTK_LABEL(ssid_lb),"");
310
else if(g_strcasecmp(type_text,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
312
gtk_widget_set_sensitive(add_ssid_te,FALSE);
314
* Maybe the user has already entered some text into the SSID field
315
* and then switched to WEP...
317
gtk_entry_set_text(GTK_ENTRY(add_ssid_te),"");
318
gtk_label_set_text(GTK_LABEL(key_lb),"Key");
319
gtk_label_set_text(GTK_LABEL(ssid_lb),"");
321
else if(g_strcasecmp(type_text,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
272
323
gtk_widget_set_sensitive(add_ssid_te,TRUE);
325
* Maybe the user has already entered some text into the SSID field
326
* and then switched to WEP...
328
gtk_entry_set_text(GTK_ENTRY(add_ssid_te),"");
329
gtk_label_set_text(GTK_LABEL(key_lb),"Passphrase");
330
gtk_label_set_text(GTK_LABEL(ssid_lb),"SSID");
275
333
gtk_widget_show(add_ssid_te);
665
723
gtk_widget_set_sensitive(toolbar,TRUE);
667
725
gtk_widget_set_sensitive(toolbar,FALSE);
668
727
g_free(from_widget);
670
729
/* reload the configuration!!! Configuration has not been saved but
671
730
the corresponding structure has been modified probably...*/
731
if(airpcap_if_selected != NULL)
672
733
if(!airpcap_if_selected->saved)
674
735
airpcap_load_selected_if_configuration(airpcap_if_selected);
678
741
/* the Advenced wireless Settings window was closed, cleanup things */
680
743
on_airpcap_advanced_destroy(GtkWidget *w _U_, gpointer data _U_)
682
745
GtkWidget *airpcap_advanced_w,
685
748
gint *from_widget = NULL;
687
750
/* Retrieve the GUI object pointers */
756
820
/* Save the configuration */
757
if( (airpcap_if_selected != NULL) )
759
821
airpcap_read_and_save_decryption_keys_from_clist(key_ls,airpcap_if_selected,airpcap_if_list); /* This will save the keys for every adapter */
761
/* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
762
if( g_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
823
/* The update will make redissect al the packets... no need to do it here again */
764
824
update_decryption_mode_cm(toolbar_cm);
768
826
/* Redissect all the packets, and re-evaluate the display filter. */
769
cf_redissect_packets(&cfile);
827
//cf_redissect_packets(&cfile);
926
984
/* Check which type of key the user has entered */
927
985
if(g_strcasecmp(new_type_string->str,AIRPCAP_WEP_KEY_STRING) == 0) /* WEP key */
930
if( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < 2))
988
if( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WEP_KEY_MIN_CHAR_SIZE))
932
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);
990
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);
934
992
g_string_free(new_type_string,TRUE);
935
993
g_string_free(new_key_string, TRUE);
936
994
g_string_free(new_ssid_string,TRUE);
938
996
g_free(type_entered);
939
997
g_free(key_entered );
940
998
g_free(ssid_entered);
975
/* If so... Modify key */
1033
/* If so... add key */
976
1034
airpcap_add_key_to_list(key_ls, new_type_string->str, new_key_string->str, new_ssid_string->str);
978
airpcap_if_selected->saved = FALSE;
1036
if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
980
else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_KEY_STRING) == 0) /* WPA Key */
1038
else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_PWD_KEY_STRING) == 0) /* WPA Key */
982
1040
/* XXX - Perform some WPA related input fields check */
983
1041
/* If everything is ok, modify the entry int he list */
985
airpcap_if_selected->saved = FALSE;
1043
if( ((new_key_string->len) > WPA_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WPA_KEY_MIN_CHAR_SIZE))
1045
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);
1047
g_string_free(new_type_string,TRUE);
1048
g_string_free(new_key_string, TRUE);
1049
g_string_free(new_ssid_string,TRUE);
1051
g_free(type_entered);
1052
g_free(key_entered );
1053
g_free(ssid_entered);
1058
* XXX - Maybe we need some check on the characters? I'm not sure if only stabdard ASCII are ok...
1060
if( ((new_ssid_string->len) > WPA_SSID_MAX_CHAR_SIZE) || ((new_ssid_string->len) < WPA_SSID_MIN_CHAR_SIZE))
1062
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);
1064
g_string_free(new_type_string,TRUE);
1065
g_string_free(new_key_string, TRUE);
1066
g_string_free(new_ssid_string,TRUE);
1068
g_free(type_entered);
1069
g_free(key_entered );
1070
g_free(ssid_entered);
1074
/* If so... add key */
1075
airpcap_add_key_to_list(key_ls, new_type_string->str, new_key_string->str, new_ssid_string->str);
1077
if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
987
else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA2_KEY_STRING) == 0) /* WPA2 Key */
1079
else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_BIN_KEY_STRING) == 0) /* WPA_BIN Key */
989
/* XXX - Perform some WPA2 related input fields check */
1081
/* XXX - Perform some WPA_BIN related input fields check */
990
1082
/* If everything is ok, modify the entry int he list */
992
airpcap_if_selected->saved = FALSE;
1084
if( ((new_key_string->len) != WPA_PSK_KEY_CHAR_SIZE))
1086
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);
1088
g_string_free(new_type_string,TRUE);
1089
g_string_free(new_key_string, TRUE);
1090
g_string_free(new_ssid_string,TRUE);
1092
g_free(type_entered);
1093
g_free(key_entered );
1094
g_free(ssid_entered);
1098
for(i = 0; i < new_key_string->len; i++)
1100
if(!g_ascii_isxdigit(new_key_string->str[i]))
1102
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WPA PSK/PMK key!\nKey must be an hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
1104
g_string_free(new_type_string,TRUE);
1105
g_string_free(new_key_string, TRUE);
1106
g_string_free(new_ssid_string,TRUE);
1108
g_free(type_entered);
1109
g_free(key_entered );
1110
g_free(ssid_entered);
1115
/* If so... add key */
1116
airpcap_add_key_to_list(key_ls, new_type_string->str, new_key_string->str, new_ssid_string->str);
1118
if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
994
1120
else /* Should never happen!!! */
996
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Unknown error in the key \"Type\" field!");
1122
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Unknown error in the key \"Type\" field!");
999
1125
g_string_free(new_type_string,TRUE);
1066
1192
/* Check which type of key the user has entered */
1067
1193
if(g_strcasecmp(new_type_string->str,AIRPCAP_WEP_KEY_STRING) == 0) /* WEP key */
1070
if( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < 2))
1196
if( ((new_key_string->len) > WEP_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WEP_KEY_MIN_CHAR_SIZE))
1072
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);
1198
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);
1074
1200
g_string_free(new_type_string,TRUE);
1075
1201
g_string_free(new_key_string, TRUE);
1076
1202
g_string_free(new_ssid_string,TRUE);
1078
1204
g_free(type_entered);
1079
1205
g_free(key_entered );
1080
1206
g_free(ssid_entered);
1115
1241
/* If so... Modify key */
1116
1242
airpcap_modify_key_in_list(key_ls, r, new_type_string->str, new_key_string->str, new_ssid_string->str);
1118
airpcap_if_selected->saved = FALSE;
1244
if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
1120
else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_KEY_STRING) == 0) /* WPA Key */
1246
else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_PWD_KEY_STRING) == 0) /* WPA Key */
1122
1248
/* XXX - Perform some WPA related input fields check */
1123
1249
/* If everything is ok, modify the entry int he list */
1125
airpcap_if_selected->saved = FALSE;
1127
else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA2_KEY_STRING) == 0) /* WPA2 Key */
1129
/* XXX - Perform some WPA2 related input fields check */
1251
if( ((new_key_string->len) > WPA_KEY_MAX_CHAR_SIZE) || ((new_key_string->len) < WPA_KEY_MIN_CHAR_SIZE))
1253
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);
1255
g_string_free(new_type_string,TRUE);
1256
g_string_free(new_key_string, TRUE);
1257
g_string_free(new_ssid_string,TRUE);
1259
g_free(type_entered);
1260
g_free(key_entered );
1261
g_free(ssid_entered);
1266
* XXX - Maybe we need some check on the characters? I'm not sure if only stabdard ASCII are ok...
1268
if( ((new_ssid_string->len) > WPA_SSID_MAX_CHAR_SIZE) || ((new_ssid_string->len) < WPA_SSID_MIN_CHAR_SIZE))
1270
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);
1272
g_string_free(new_type_string,TRUE);
1273
g_string_free(new_key_string, TRUE);
1274
g_string_free(new_ssid_string,TRUE);
1276
g_free(type_entered);
1277
g_free(key_entered );
1278
g_free(ssid_entered);
1282
/* If so... Modify key */
1283
airpcap_modify_key_in_list(key_ls, r, new_type_string->str, new_key_string->str, new_ssid_string->str);
1285
if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
1287
else if(g_strcasecmp(new_type_string->str,AIRPCAP_WPA_BIN_KEY_STRING) == 0) /* WPA_BIN Key */
1289
/* XXX - Perform some WPA_BIN related input fields check */
1130
1290
/* If everything is ok, modify the entry int he list */
1132
airpcap_if_selected->saved = FALSE;
1292
if( ((new_key_string->len) != WPA_PSK_KEY_CHAR_SIZE))
1294
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);
1296
g_string_free(new_type_string,TRUE);
1297
g_string_free(new_key_string, TRUE);
1298
g_string_free(new_ssid_string,TRUE);
1300
g_free(type_entered);
1301
g_free(key_entered );
1302
g_free(ssid_entered);
1306
for(i = 0; i < new_key_string->len; i++)
1308
if(!g_ascii_isxdigit(new_key_string->str[i]))
1310
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Invalid WPA PSK/PMK key!\nKey must be an hexadecimal number.\nThe valid characters are: 0123456789ABCDEF.");
1312
g_string_free(new_type_string,TRUE);
1313
g_string_free(new_key_string, TRUE);
1314
g_string_free(new_ssid_string,TRUE);
1316
g_free(type_entered);
1317
g_free(key_entered );
1318
g_free(ssid_entered);
1323
/* If so... Modify key */
1324
airpcap_modify_key_in_list(key_ls, r, new_type_string->str, new_key_string->str, new_ssid_string->str);
1326
if(airpcap_if_selected != NULL) airpcap_if_selected->saved = FALSE;
1134
1328
else /* Should never happen!!! */
1136
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Unknown error in the key \"Type\" field!");
1330
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Unknown error in the key \"Type\" field!");
1139
1333
g_string_free(new_type_string,TRUE);
1201
1395
if(keys_in_list >= MAX_ENCRYPTION_KEYS) /* Check if we have already reached the maximum number of allowed keys... */
1203
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Maximum number (%d) of decryption keys reached! You cannot add another key!\n",MAX_ENCRYPTION_KEYS);
1397
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Maximum number (%d) of decryption keys reached! You cannot add another key!\n",MAX_ENCRYPTION_KEYS);
1207
1401
/* Gray out the Advanced Wireless Setting window */
1208
1402
gtk_widget_set_sensitive(airpcap_advanced_w,FALSE);
1210
/* Pop-up a new window */
1404
/* Pop-up a new window */
1211
1405
add_key_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1212
1406
gtk_widget_set_name (add_key_window, "add_key_window");
1213
1407
gtk_container_set_border_width (GTK_CONTAINER (add_key_window), 5);
1251
1445
(GtkAttachOptions) (GTK_FILL),
1252
1446
(GtkAttachOptions) (0), 0, 0);
1253
1447
#if GTK_MAJOR_VERSION >= 2
1254
gtk_widget_set_size_request (add_type_cm, 63, -1);
1448
gtk_widget_set_size_request (add_type_cm, 83, -1);
1256
gtk_widget_set_usize (add_type_cm, 63, -1);
1450
gtk_widget_set_usize (add_type_cm, 83, -1);
1258
1452
add_type_cm_items = g_list_append (add_type_cm_items, (gpointer) AIRPCAP_WEP_KEY_STRING);
1260
/* XXX - DEcomment only when WPA and WPA2 will be ready */
1262
add_type_cm_items = g_list_append (add_type_cm_items, (gpointer) AIRPCAP_WPA_KEY_STRING);
1263
add_type_cm_items = g_list_append (add_type_cm_items, (gpointer) AIRPCAP_WPA2_KEY_STRING);*/
1454
/* XXX - DEcomment only when WPA and WPA_BIN will be ready */
1455
#ifdef HAVE_AIRPDCAP
1456
add_type_cm_items = g_list_append (add_type_cm_items, (gpointer) AIRPCAP_WPA_PWD_KEY_STRING);
1457
add_type_cm_items = g_list_append (add_type_cm_items, (gpointer) AIRPCAP_WPA_BIN_KEY_STRING);
1264
1459
gtk_combo_set_popdown_strings (GTK_COMBO (add_type_cm),
1265
1460
add_type_cm_items);
1266
1461
g_list_free (add_type_cm_items);
1285
1480
add_ssid_te = gtk_entry_new ();
1286
1481
gtk_widget_set_name (add_ssid_te, "add_ssid_te");
1287
1482
gtk_widget_set_sensitive(add_ssid_te,FALSE);
1288
/* XXX - Decomment only when WPA and WPA2 will be ready */
1289
/* gtk_widget_show (add_ssid_te); */
1483
/* XXX - Decomment only when WPA and WPA_BIN will be ready */
1484
gtk_widget_show (add_ssid_te);
1290
1485
gtk_table_attach (GTK_TABLE (add_tb), add_ssid_te, 2, 3, 1, 2,
1291
1486
(GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0);
1301
1496
add_key_lb = gtk_label_new ("Key");
1302
1497
gtk_widget_set_name (add_key_lb, "add_key_lb");
1303
gtk_widget_show (add_key_lb);
1498
gtk_widget_show (add_key_lb);
1304
1499
gtk_table_attach (GTK_TABLE (add_tb), add_key_lb, 1, 2, 0, 1,
1305
1500
(GtkAttachOptions) (GTK_FILL),
1306
1501
(GtkAttachOptions) (0), 0, 0);
1307
1502
gtk_label_set_justify (GTK_LABEL (add_key_lb), GTK_JUSTIFY_CENTER);
1309
add_ssid_lb = gtk_label_new ("SSID");
1504
add_ssid_lb = gtk_label_new ("");
1310
1505
gtk_widget_set_name (add_ssid_lb, "add_ssid_lb");
1311
/* XXX - Decomment only when WPA and WPA2 will be ready */
1312
/* gtk_widget_show (add_ssid_lb); */
1506
/* XXX - Decomment only when WPA and WPA_BIN will be ready */
1507
gtk_widget_show (add_ssid_lb);
1313
1508
gtk_table_attach (GTK_TABLE (add_tb), add_ssid_lb, 2, 3, 0, 1,
1314
1509
(GtkAttachOptions) (GTK_FILL),
1315
1510
(GtkAttachOptions) (0), 0, 0);
1356
1551
/* Add callbacks */
1357
SIGNAL_CONNECT(ok_bt, "clicked", add_key, add_key_window );
1552
SIGNAL_CONNECT(ok_bt, "clicked", on_add_key_ok_bt_clicked, add_key_window );
1358
1553
SIGNAL_CONNECT(cancel_bt, "clicked", window_cancel_button_cb, add_key_window );
1359
1554
SIGNAL_CONNECT(add_type_en, "changed",on_add_type_en_changed, add_key_window);
1360
1555
SIGNAL_CONNECT(add_key_window, "delete_event",window_delete_event_cb, add_key_window);
1511
1708
gtk_clist_get_text(GTK_CLIST(key_ls),r,0,&row_type);
1512
1709
gtk_clist_get_text(GTK_CLIST(key_ls),r,1,&row_key);
1513
1710
gtk_clist_get_text(GTK_CLIST(key_ls),r,2,&row_ssid);
1515
1712
/* Gray out the Advanced Wireless Setting window */
1516
1713
gtk_widget_set_sensitive(airpcap_advanced_w,FALSE);
1518
/* Pop-up a new window */
1715
/* Pop-up a new window */
1519
1716
edit_key_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1520
1717
gtk_widget_set_name (edit_key_window, "edit_key_window");
1521
1718
gtk_container_set_border_width (GTK_CONTAINER (edit_key_window), 5);
1526
1723
gtk_window_set_policy(GTK_WINDOW(edit_key_window), FALSE, FALSE, TRUE);
1529
1726
main_v_box = gtk_vbox_new (FALSE, 0);
1530
1727
gtk_widget_set_name (main_v_box, "main_v_box");
1531
1728
gtk_widget_show (main_v_box);
1532
1729
gtk_container_add (GTK_CONTAINER (edit_key_window), main_v_box);
1534
1731
edit_frame = gtk_frame_new (NULL);
1535
1732
gtk_widget_set_name (edit_frame, "edit_frame");
1536
1733
gtk_widget_show (edit_frame);
1537
1734
gtk_box_pack_start (GTK_BOX (main_v_box), edit_frame, TRUE, TRUE, 0);
1539
1736
edit_frame_al = gtk_alignment_new (0.5, 0.5, 1, 1);
1540
1737
gtk_widget_set_name (edit_frame_al, "edit_frame_al");
1541
1738
gtk_widget_show (edit_frame_al);
1546
1743
gtk_alignment_set (GTK_ALIGNMENT (edit_frame_al), 0, 0, 12, 0);
1549
1746
edit_tb = gtk_table_new (2, 3, FALSE);
1550
1747
gtk_widget_set_name (edit_tb, "edit_tb");
1551
1748
gtk_container_set_border_width(GTK_CONTAINER(edit_tb),5);
1552
1749
gtk_widget_show (edit_tb);
1553
1750
gtk_container_add (GTK_CONTAINER (edit_frame_al), edit_tb);
1555
1752
edit_type_cm = gtk_combo_new ();
1556
1753
gtk_widget_set_name (edit_type_cm, "edit_type_cm");
1557
1754
gtk_widget_show (edit_type_cm);
1559
1756
(GtkAttachOptions) (GTK_FILL),
1560
1757
(GtkAttachOptions) (0), 0, 0);
1561
1758
#if GTK_MAJOR_VERSION >= 2
1562
gtk_widget_set_size_request (edit_type_cm, 63, -1);
1759
gtk_widget_set_size_request (edit_type_cm, 83, -1);
1564
gtk_widget_set_usize (edit_type_cm, 63, -1);
1761
gtk_widget_set_usize (edit_type_cm, 83, -1);
1566
1763
edit_type_cm_items = g_list_append (edit_type_cm_items, (gpointer) AIRPCAP_WEP_KEY_STRING);
1567
/* XXX - Decomment only when WPA and WPA2 support will be ready!!! */
1568
/* edit_type_cm_items = g_list_append (edit_type_cm_items, (gpointer) AIRPCAP_WPA_KEY_STRING);
1569
edit_type_cm_items = g_list_append (edit_type_cm_items, (gpointer) AIRPCAP_WPA2_KEY_STRING);*/
1764
/* XXX - Decomment only when WPA and WPA_BIN support will be ready!!! */
1765
#ifdef HAVE_AIRPDCAP
1766
edit_type_cm_items = g_list_append (edit_type_cm_items, (gpointer) AIRPCAP_WPA_PWD_KEY_STRING);
1767
edit_type_cm_items = g_list_append (edit_type_cm_items, (gpointer) AIRPCAP_WPA_BIN_KEY_STRING);
1570
1769
gtk_combo_set_popdown_strings (GTK_COMBO (edit_type_cm),
1571
1770
edit_type_cm_items);
1572
1771
g_list_free (edit_type_cm_items);
1574
1773
edit_type_en = GTK_COMBO (edit_type_cm)->entry;
1575
1774
gtk_widget_set_name (edit_type_en, "edit_type_en");
1576
1775
/* Set current type */
1577
1776
gtk_entry_set_text(GTK_ENTRY(edit_type_en),row_type);
1578
1777
gtk_editable_set_editable (GTK_EDITABLE (edit_type_en), FALSE);
1579
1778
gtk_widget_show (edit_type_en);
1581
1780
edit_key_te = gtk_entry_new ();
1582
1781
gtk_widget_set_name (edit_key_te, "edit_key_te");
1583
1782
/* Set current key */
1604
1803
gtk_widget_set_sensitive(edit_ssid_te,TRUE);
1605
1804
gtk_entry_set_text(GTK_ENTRY(edit_ssid_te),row_ssid);
1608
1807
/* XXX - Decomment only when WPA and WPA@ will be ready */
1609
/* gtk_widget_show (edit_ssid_te); */
1808
#ifdef HAVE_AIRPDCAP
1809
gtk_widget_show (edit_ssid_te);
1610
1811
gtk_table_attach (GTK_TABLE (edit_tb), edit_ssid_te, 2, 3, 1, 2,
1611
1812
(GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0);
1613
1814
edit_type_lb = gtk_label_new ("Type");
1614
1815
gtk_widget_set_name (edit_type_lb, "edit_type_lb");
1615
1816
gtk_widget_show (edit_type_lb);
1625
1826
(GtkAttachOptions) (GTK_FILL),
1626
1827
(GtkAttachOptions) (0), 0, 0);
1627
1828
gtk_label_set_justify (GTK_LABEL (edit_key_lb), GTK_JUSTIFY_CENTER);
1629
edit_ssid_lb = gtk_label_new ("SSID");
1830
edit_ssid_lb = gtk_label_new ("");
1630
1831
gtk_widget_set_name (edit_ssid_lb, "edit_ssid_lb");
1631
/* XXX - Decomment only when WPA and WPA2 will be ready */
1632
/* gtk_widget_show (edit_ssid_lb); */
1832
/* XXX - Decomment only when WPA and WPA_BIN will be ready */
1833
gtk_widget_show (edit_ssid_lb);
1633
1834
gtk_table_attach (GTK_TABLE (edit_tb), edit_ssid_lb, 2, 3, 0, 1,
1634
1835
(GtkAttachOptions) (GTK_FILL),
1635
1836
(GtkAttachOptions) (0), 0, 0);
1636
1837
gtk_label_set_justify (GTK_LABEL (edit_ssid_lb), GTK_JUSTIFY_CENTER);
1638
1839
low_h_button_box = gtk_hbutton_box_new ();
1639
1840
gtk_widget_set_name (low_h_button_box, "low_h_button_box");
1640
1841
gtk_container_set_border_width (GTK_CONTAINER (low_h_button_box), 5);
1642
1843
gtk_box_pack_end (GTK_BOX (main_v_box), low_h_button_box, FALSE, FALSE, 0);
1643
1844
gtk_button_box_set_layout (GTK_BUTTON_BOX (low_h_button_box),
1644
1845
GTK_BUTTONBOX_END);
1646
1847
#if GTK_MAJOR_VERISON >= 2
1647
ok_bt = gtk_button_new_with_mnemonic ("Ok");
1848
ok_bt = gtk_button_new_with_mnemonic ("OK");
1649
ok_bt = gtk_button_new_with_label ("Ok");
1850
ok_bt = gtk_button_new_with_label ("OK");
1651
1852
gtk_widget_set_name (ok_bt, "ok_bt");
1652
1853
gtk_widget_show (ok_bt);
1653
1854
gtk_container_add (GTK_CONTAINER (low_h_button_box), ok_bt);
1654
1855
GTK_WIDGET_SET_FLAGS (ok_bt, GTK_CAN_DEFAULT);
1656
1857
#if GTK_MAJOR_VERISON >= 2
1657
1858
cancel_bt = gtk_button_new_with_mnemonic ("Cancel");
1673
1874
gtk_frame_set_label (GTK_FRAME (edit_frame), "Modify Selected Key");
1676
1877
/* Add callbacks */
1677
1878
SIGNAL_CONNECT(ok_bt, "clicked", on_edit_key_ok_bt_clicked, edit_key_window );
1678
1879
SIGNAL_CONNECT(cancel_bt, "clicked", window_cancel_button_cb, edit_key_window );
1679
1880
SIGNAL_CONNECT(edit_type_en, "changed",on_edit_type_en_changed, edit_key_window);
1680
1881
SIGNAL_CONNECT(edit_key_window, "delete_event",window_delete_event_cb, edit_key_window);
1681
1882
SIGNAL_CONNECT(edit_key_window, "destroy",on_edit_key_w_destroy, data);
1683
1884
/* Add widget data */
1684
1885
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_LIST_KEY,key_ls);
1685
1886
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_SELECTED_KEY,selected_item);
1686
1887
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_TYPE_KEY,edit_type_cm);
1687
1888
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_KEY_KEY,edit_key_te);
1688
1889
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY,edit_ssid_te);
1890
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_KEY_LABEL_KEY,edit_key_lb);
1891
OBJECT_SET_DATA(edit_key_window,AIRPCAP_ADVANCED_EDIT_KEY_SSID_LABEL_KEY,edit_ssid_lb);
1690
1893
gtk_widget_show(edit_key_window);
1849
2066
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
2073
* Creates the list of available decryption modes, depending on the adapters found
2076
update_decryption_mode_list(GtkWidget *w)
2078
GList *enable_decryption_cb_items = NULL;
2080
gchar *current_text;
2085
entry = GTK_COMBO(w)->entry;
2086
current_text = NULL;
2089
* XXX - Retrieve the current 'decryption mode'. It would be better just block the
2090
* signal handler, but it doesn't work... one of these days I'll try to figure otu why...
2092
current_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
2094
enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
2095
enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK);
2097
if(airpcap_if_list != NULL)
2099
enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP);
2103
/* The last decryption mode was 'Driver', but no more AirPcap adapter are found */
2104
if(g_strcasecmp(current_text,AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP) == 0)
2106
if(current_text != NULL) g_free(current_text);
2108
current_text = g_strdup(AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
2112
gtk_signal_handler_block_by_data(GTK_OBJECT(entry),(gpointer)airpcap_tb);
2113
gtk_combo_set_popdown_strings (GTK_COMBO (w), enable_decryption_cb_items);
2114
/* The 'changed' callback will be called twice */
2115
gtk_entry_set_text(GTK_ENTRY(entry),current_text);
2116
gtk_signal_handler_unblock_by_data(GTK_OBJECT(entry),(gpointer)airpcap_tb);
2118
if(current_text != NULL) g_free(current_text);
2120
g_list_free (enable_decryption_cb_items);
1854
2123
/* Called to create the airpcap settings' window */
2507
2776
/* Create the new window */
2508
2777
key_management_w = window_new(GTK_WINDOW_TOPLEVEL, "Decryption Keys Management");
2511
2779
gtk_container_set_border_width (GTK_CONTAINER (key_management_w), 5);
2512
2780
gtk_window_set_title (GTK_WINDOW (key_management_w),
2513
2781
"Decryption Keys Management");
2514
2782
gtk_window_set_position (GTK_WINDOW (key_management_w),
2515
2783
GTK_WIN_POS_CENTER);
2517
2785
#if GTK_MAJOR_VERSION >= 2
2518
2786
gtk_window_set_resizable (GTK_WINDOW (key_management_w), FALSE);
2519
2787
gtk_window_set_type_hint (GTK_WINDOW (key_management_w), GDK_WINDOW_TYPE_HINT_DIALOG);
2576
2844
gtk_widget_set_usize (enable_decryption_cb, 83, -1);
2578
enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_NONE);
2579
enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK);
2580
enable_decryption_cb_items = g_list_append (enable_decryption_cb_items, AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP);
2581
gtk_combo_set_popdown_strings (GTK_COMBO (enable_decryption_cb), enable_decryption_cb_items);
2582
g_list_free (enable_decryption_cb_items);
2846
update_decryption_mode_list(enable_decryption_cb);
2584
2848
enable_decryption_en = GTK_COMBO (enable_decryption_cb)->entry;
2585
2849
gtk_widget_set_name (enable_decryption_en, "enable_decryption_en");
2603
2867
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (keys_scrolled_w), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2869
#ifdef HAVE_AIRPDCAP
2605
2870
key_ls = gtk_clist_new (3);
2872
key_ls = gtk_clist_new (2);
2606
2875
gtk_widget_set_name (key_ls, "key_ls");
2607
2876
gtk_widget_show (key_ls);
2609
2878
gtk_container_add (GTK_CONTAINER (keys_scrolled_w), key_ls);
2610
2879
gtk_clist_set_column_width (GTK_CLIST (key_ls), 0, 54);
2611
2880
gtk_clist_set_column_width (GTK_CLIST (key_ls), 1, 113);
2881
#ifdef HAVE_AIRPDCAP
2612
2882
gtk_clist_set_column_width (GTK_CLIST (key_ls), 2, 80);
2613
2884
gtk_clist_column_titles_show (GTK_CLIST (key_ls));
2614
2885
gtk_clist_set_shadow_type (GTK_CLIST (key_ls), GTK_SHADOW_ETCHED_IN);
2615
2886
gtk_clist_set_column_justification(GTK_CLIST (key_ls),0,GTK_JUSTIFY_CENTER);
2627
2898
gtk_clist_set_column_widget (GTK_CLIST (key_ls), 1,
2628
2899
key_list_decryption_key_col_lb);
2901
#ifdef HAVE_AIRPDCAP
2630
2902
key_ls_decryption_ssid_col_lb = gtk_label_new ("SSID");
2631
2903
gtk_widget_set_name (key_ls_decryption_ssid_col_lb,
2632
2904
"key_ls_decryption_ssid_col_lb");
2633
2905
gtk_widget_show (key_ls_decryption_ssid_col_lb);
2634
2906
gtk_clist_set_column_widget (GTK_CLIST (key_ls), 2,
2635
2907
key_ls_decryption_ssid_col_lb);
2637
/* XXX - USED ONLY BECAUSE WPA and WPA2 are note ready YET... */
2638
gtk_clist_set_column_visibility(GTK_CLIST (key_ls), 2, FALSE);
2640
2911
key_v_button_box = gtk_vbutton_box_new ();
2641
2912
gtk_widget_set_name (key_v_button_box, "key_v_button_box");
2721
2992
/* Connect the callbacks */
2722
2993
SIGNAL_CONNECT (key_management_w, "delete_event", window_delete_event_cb, key_management_w);
2723
2994
SIGNAL_CONNECT (key_management_w, "destroy", on_key_management_destroy, key_management_w);
2724
/*SIGNAL_CONNECT (enable_decryption_en, "changed",on_enable_decryption_en_changed, toolbar);*/
2725
2995
SIGNAL_CONNECT (add_new_key_bt, "clicked",on_add_new_key_bt_clicked, key_management_w);
2726
2996
SIGNAL_CONNECT (remove_key_bt, "clicked",on_remove_key_bt_clicked, key_management_w);
2727
2997
SIGNAL_CONNECT (edit_key_bt, "clicked",on_edit_key_bt_clicked, key_management_w);
2819
3089
/* Save the configuration */
2820
if( (airpcap_if_selected != NULL) )
2822
3090
airpcap_read_and_save_decryption_keys_from_clist(key_ls,airpcap_if_selected,airpcap_if_list); /* This will save the keys for every adapter */
2824
/* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
2825
if( g_strcasecmp(airpcap_if_selected->description,airpcap_if_active->description) == 0)
3092
/* The update will make redissect al the packets... no need to do it here again */
2827
3093
update_decryption_mode_cm(toolbar_cm);
2831
3095
/* Redissect all the packets, and re-evaluate the display filter. */
2832
cf_redissect_packets(&cfile);
3096
//cf_redissect_packets(&cfile);
2834
3098
/* Save the preferences to preferences file!!! */
2835
3099
write_prefs_to_file();
2837
3101
/* If interface active is airpcap, set sensitive TRUE for airpcap toolbar */
3102
if(airpcap_if_list != NULL)
3104
if(airpcap_if_active != NULL)
2838
3106
if( get_airpcap_if_by_name(airpcap_if_list,airpcap_if_active->description) != NULL)
2840
3108
airpcap_set_toolbar_start_capture(airpcap_if_active);