Fix the wireless settings button for AirPCap devices in the
[obnox/wireshark/wip.git] / gtk / airpcap_gui_utils.c
1 /* airpcap_gui_utils.c
2  *
3  * $Id$
4  *
5  * Giorgio Tino <giorgio.tino@cacetech.com>
6  * Copyright (c) CACE Technologies, LLC 2006
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 2000 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #ifdef HAVE_AIRPCAP
32
33 #include <gtk/gtk.h>
34 #include <glib.h>
35
36 #include <stdio.h>
37 #include <string.h>
38
39 #include <epan/filesystem.h>
40 #include <epan/strutil.h>
41 #include <epan/frequency-utils.h>
42 #include <epan/crypt/airpdcap_ws.h>
43
44 #include "../simple_dialog.h"
45
46 #include "gtk/main.h"
47 #include "gtk/dlg_utils.h"
48 #include "gtk/gui_utils.h"
49 #include "gtk/dfilter_expr_dlg.h"
50 #include "gtk/help_dlg.h"
51 #include "gtk/keys.h"
52 #include "gtk/old-gtk-compat.h"
53
54 #include <airpcap.h>
55 #include "airpcap_loader.h"
56 #include "airpcap_gui_utils.h"
57
58
59 /* Controls the releay of settings back to the adapter. */
60 gboolean change_airpcap_settings = FALSE;
61
62 /*
63  * Set up the airpcap toolbar for the new capture interface
64  */
65 void
66 airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info)
67 {
68     GtkWidget *airpcap_toolbar_label;
69     GtkWidget *toolbar_channel_cb;
70     GtkWidget *airpcap_toolbar_channel_lb;
71     GtkWidget *airpcap_toolbar_channel_offset;
72     GtkWidget *airpcap_toolbar_channel_offset_lb;
73     GtkWidget *airpcap_toolbar_button;
74     GtkWidget *airpcap_toolbar_fcs;
75     GtkWidget *airpcap_toolbar_fcs_lb;
76     GtkWidget *airpcap_toolbar_decryption;
77     GtkWidget *airpcap_toolbar_decryption_lb;
78     GtkWidget *airpcap_toolbar_keys_button;
79
80     gchar *if_label_text;
81
82     airpcap_toolbar_label    = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_INTERFACE_KEY);
83     toolbar_channel_cb  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
84     airpcap_toolbar_channel_lb  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
85     airpcap_toolbar_channel_offset  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY);
86     airpcap_toolbar_channel_offset_lb  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY);
87     airpcap_toolbar_fcs  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
88     airpcap_toolbar_fcs_lb  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY);
89     airpcap_toolbar_button   = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_ADVANCED_KEY);
90     airpcap_toolbar_decryption = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
91     airpcap_toolbar_decryption_lb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_LABEL_KEY);
92     airpcap_toolbar_keys_button = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_KEY_MANAGEMENT_KEY);
93
94     /* The current interface is an airpcap interface */
95     if(if_info != NULL)
96     {
97         gtk_widget_set_sensitive(airpcap_tb,TRUE);
98         gtk_widget_set_sensitive(airpcap_toolbar_label,TRUE);
99         gtk_widget_set_sensitive(toolbar_channel_cb,TRUE);
100         gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,TRUE);
101         gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,TRUE);
102         gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,TRUE);
103         gtk_widget_set_sensitive(airpcap_toolbar_fcs,FALSE);
104         gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,FALSE);
105         gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
106         gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
107         gtk_widget_set_sensitive(airpcap_toolbar_decryption,FALSE);
108         gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,FALSE);
109         gtk_widget_set_sensitive(airpcap_toolbar_keys_button,FALSE);
110
111         /*decryption check box*/
112         g_signal_handlers_block_by_func (airpcap_toolbar_decryption,airpcap_toolbar_encryption_cb, airpcap_tb);
113         if(if_info->DecryptionOn == AIRPCAP_DECRYPTION_ON)
114             gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),TRUE);
115         else
116             gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),FALSE);
117         g_signal_handlers_unblock_by_func (airpcap_toolbar_decryption,airpcap_toolbar_encryption_cb, airpcap_tb);
118
119         if_label_text = g_strdup_printf("Current Wireless Interface: #%s", airpcap_get_if_string_number(if_info));
120         gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),if_label_text);
121         g_free(if_label_text);
122
123         change_airpcap_settings = FALSE;
124         if (if_info->pSupportedChannels != NULL && if_info->numSupportedChannels > 0){
125             guint i = 0;
126
127             for (; i<if_info->numSupportedChannels; i++){
128                 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(toolbar_channel_cb), ieee80211_mhz_to_str(if_info->pSupportedChannels[i].Frequency));
129             }
130         }
131
132         airpcap_update_channel_combo(GTK_WIDGET(toolbar_channel_cb),if_info);
133         airpcap_update_channel_offset_combo(if_info, if_info->channelInfo.Frequency, airpcap_toolbar_channel_offset, TRUE);
134         change_airpcap_settings = TRUE;
135     }
136     else /* Current interface is NOT an AirPcap one... */
137     {
138         gtk_widget_set_sensitive(airpcap_tb,FALSE);
139         gtk_widget_set_sensitive(airpcap_toolbar_label,FALSE);
140         gtk_widget_set_sensitive(toolbar_channel_cb,FALSE);
141         gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,FALSE);
142         gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,FALSE);
143         gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,FALSE);
144         gtk_widget_set_sensitive(airpcap_toolbar_fcs,FALSE);
145         gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,FALSE);
146         gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
147         gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
148         gtk_widget_set_sensitive(airpcap_toolbar_decryption,FALSE);
149         gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,FALSE);
150         gtk_widget_set_sensitive(airpcap_toolbar_keys_button,FALSE);
151     }
152 }
153
154 /*
155  * Set up the airpcap toolbar for the new capture interface
156  */
157 void
158 airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info)
159 {
160     GtkWidget *airpcap_toolbar_crc_filter_combo;
161     GtkWidget *airpcap_toolbar_label;
162     GtkWidget *toolbar_channel_cb;
163     GtkWidget *airpcap_toolbar_channel_lb;
164     GtkWidget *airpcap_toolbar_channel_offset;
165     GtkWidget *airpcap_toolbar_channel_offset_lb;
166     GtkWidget *airpcap_toolbar_button;
167     GtkWidget *airpcap_toolbar_fcs;
168     GtkWidget *airpcap_toolbar_fcs_lb;
169     GtkWidget *airpcap_toolbar_decryption;
170     GtkWidget *airpcap_toolbar_decryption_lb;
171     GtkWidget *airpcap_toolbar_keys_button;
172
173     gchar *if_label_text;
174
175     airpcap_toolbar_crc_filter_combo = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
176     airpcap_toolbar_label    = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_INTERFACE_KEY);
177     toolbar_channel_cb  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
178     airpcap_toolbar_channel_lb  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
179     airpcap_toolbar_channel_offset  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY);
180     airpcap_toolbar_channel_offset_lb  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY);
181     airpcap_toolbar_fcs  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
182     airpcap_toolbar_fcs_lb  = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY);
183     airpcap_toolbar_button   = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_ADVANCED_KEY);
184     airpcap_toolbar_decryption = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
185     airpcap_toolbar_decryption_lb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_LABEL_KEY);
186     airpcap_toolbar_keys_button = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_KEY_MANAGEMENT_KEY);
187
188     /* The current interface is an airpcap interface */
189     if(if_info != NULL)
190     {
191           gtk_widget_set_sensitive(airpcap_tb,TRUE);
192           gtk_widget_set_sensitive(airpcap_toolbar_label,TRUE);
193           gtk_widget_set_sensitive(toolbar_channel_cb,TRUE);
194           gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,TRUE);
195           gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,TRUE);
196           gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,TRUE);
197           gtk_widget_set_sensitive(airpcap_toolbar_fcs,TRUE);
198           gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,TRUE);
199           gtk_widget_set_sensitive(airpcap_toolbar_button,TRUE);
200           gtk_widget_set_sensitive(airpcap_toolbar_crc_filter_combo,TRUE);
201           gtk_widget_set_sensitive(airpcap_toolbar_decryption,TRUE);
202           gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,TRUE);
203           gtk_widget_set_sensitive(airpcap_toolbar_keys_button,TRUE);
204           airpcap_validation_type_combo_set_by_type(airpcap_toolbar_crc_filter_combo, if_info->CrcValidationOn);
205
206           /*decription check box*/
207           g_signal_handlers_block_by_func (airpcap_toolbar_decryption,airpcap_toolbar_encryption_cb, airpcap_tb);
208           if(if_info->DecryptionOn == AIRPCAP_DECRYPTION_ON)
209               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),TRUE);
210           else
211               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),FALSE);
212           g_signal_handlers_unblock_by_func (airpcap_toolbar_decryption,airpcap_toolbar_encryption_cb, airpcap_tb);
213
214           if_label_text = g_strdup_printf("Current Wireless Interface: #%s", airpcap_get_if_string_number(if_info));
215           gtk_label_set_text(GTK_LABEL(airpcap_toolbar_label),if_label_text);
216           g_free(if_label_text);
217
218           change_airpcap_settings = FALSE;
219           if (if_info->pSupportedChannels != NULL && if_info->numSupportedChannels > 0){
220               guint i = 0;
221
222               for (; i<if_info->numSupportedChannels; i++){
223                   gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(toolbar_channel_cb), ieee80211_mhz_to_str(if_info->pSupportedChannels[i].Frequency));
224               }
225           }
226
227           airpcap_update_channel_combo(GTK_WIDGET(toolbar_channel_cb),if_info);
228           airpcap_update_channel_offset_combo(if_info, if_info->channelInfo.Frequency, airpcap_toolbar_channel_offset, TRUE);
229           change_airpcap_settings = TRUE;
230       }
231     else
232     {
233           gtk_widget_set_sensitive(airpcap_tb,TRUE);
234           gtk_widget_set_sensitive(airpcap_toolbar_label,FALSE);
235           gtk_widget_set_sensitive(toolbar_channel_cb,FALSE);
236           gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,FALSE);
237           gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,FALSE);
238           gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,FALSE);
239           gtk_widget_set_sensitive(airpcap_toolbar_fcs,FALSE);
240           gtk_widget_set_sensitive(airpcap_toolbar_fcs_lb,FALSE);
241           gtk_widget_set_sensitive(airpcap_toolbar_button,FALSE);
242           gtk_widget_set_sensitive(airpcap_toolbar_crc_filter_combo,FALSE);
243           gtk_widget_set_sensitive(airpcap_toolbar_decryption,TRUE);
244           gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,TRUE);
245           gtk_widget_set_sensitive(airpcap_toolbar_keys_button,TRUE);
246           change_airpcap_settings = FALSE;
247     }
248 }
249
250 /*
251  * Add a key (string) to the given list
252  */
253 void
254 airpcap_add_key_to_list(GtkListStore *key_list_store, gchar* type, gchar* key, gchar* ssid)
255 {
256     GtkTreeIter iter;
257
258     gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT,
259         KL_COL_TYPE, type,
260         KL_COL_KEY, key,
261         KL_COL_SSID, ssid,
262         -1);
263 }
264
265 /*
266  * Fill the list with the keys. BEWARE! At this point, Wireshark and Drivers
267  * keys should be EQUALS! But is better to load keys from Wireshark, because
268  * the driver is not always present, and maybe that cannot support some keys
269  * (i.e. the WPA problem)
270  */
271 void
272 airpcap_fill_key_list(GtkListStore *key_list_store)
273 {
274     gchar*         s = NULL;
275     unsigned int i,n;
276     airpcap_if_info_t* fake_if_info;
277     GList*         wireshark_key_list=NULL;
278     decryption_key_t* curr_key = NULL;
279     GtkTreeIter    iter;
280
281     n = 0;
282
283     fake_if_info = airpcap_driver_fake_if_info_new();
284
285     /* We can retrieve the driver's key list (i.e. we have the right .dll)*/
286     wireshark_key_list = get_wireshark_keys();
287     n = g_list_length(wireshark_key_list);
288
289     for(i = 0; i < n; i++)
290     {
291         curr_key = (decryption_key_t*)g_list_nth_data(wireshark_key_list,i);
292
293         if(curr_key->type == AIRPDCAP_KEY_TYPE_WEP)
294         {
295             gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT,
296                 KL_COL_TYPE, AIRPCAP_WEP_KEY_STRING,
297                 KL_COL_KEY, curr_key->key->str,
298                 KL_COL_SSID, "",
299                 -1);
300         }
301         else if(curr_key->type == AIRPDCAP_KEY_TYPE_WPA_PWD)
302         {
303             if(curr_key->ssid != NULL)
304                 s = format_uri(curr_key->ssid, ":");
305             else
306                 s = "";
307
308             gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT,
309                 KL_COL_TYPE, AIRPCAP_WPA_PWD_KEY_STRING,
310                 KL_COL_KEY, curr_key->key->str,
311                 KL_COL_SSID, s,
312                 -1);
313
314         }
315         else if(curr_key->type == AIRPDCAP_KEY_TYPE_WPA_PMK)
316         {
317             gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT,
318                 KL_COL_TYPE, AIRPCAP_WPA_BIN_KEY_STRING,
319                 KL_COL_KEY, curr_key->key->str,
320                 KL_COL_SSID, "",
321                 -1);
322
323         }
324     }
325
326     airpcap_if_info_free(fake_if_info);
327     return;
328 }
329
330 /*
331  * Function used to retrieve the AirpcapValidationType given the string name.
332  */
333 AirpcapValidationType
334 airpcap_get_validation_type(const gchar* name)
335 {
336     if(!(g_ascii_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_ALL,name)))
337     {
338         return AIRPCAP_VT_ACCEPT_EVERYTHING;
339     }
340     else if(!(g_ascii_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_CORRECT,name)))
341     {
342         return AIRPCAP_VT_ACCEPT_CORRECT_FRAMES;
343     }
344     else if(!(g_ascii_strcasecmp(AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT,name)))
345     {
346         return AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES;
347     }
348     return AIRPCAP_VT_UNKNOWN;
349 }
350
351 /*
352  * Function used to retrieve the string name given an AirpcapValidationType,
353  * or NULL in case of error
354  */
355 gchar*
356 airpcap_get_validation_name(AirpcapValidationType vt)
357 {
358     if(vt == AIRPCAP_VT_ACCEPT_EVERYTHING)
359     {
360         return AIRPCAP_VALIDATION_TYPE_NAME_ALL;
361     }
362     else if(vt == AIRPCAP_VT_ACCEPT_CORRECT_FRAMES)
363     {
364         return AIRPCAP_VALIDATION_TYPE_NAME_CORRECT;
365     }
366     else if(vt == AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES)
367     {
368         return AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT;
369     }
370     else if(vt == AIRPCAP_VT_UNKNOWN)
371     {
372         return AIRPCAP_VALIDATION_TYPE_NAME_UNKNOWN;
373     }
374     return NULL;
375 }
376
377 /*
378  * Return an appropriate combo box entry number for the given an AirpcapValidationType,
379  * defaulting to 0
380  */
381 gint
382 airpcap_get_validation_combo_entry(AirpcapValidationType vt)
383 {
384     switch (vt) {
385         case AIRPCAP_VT_ACCEPT_CORRECT_FRAMES:
386             return 1;
387             break;
388         case AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES:
389             return 2;
390             break;
391         default:
392             return 0;
393             break;
394     }
395 }
396
397 /*
398  * Returns the AirpcapLinkType corresponding to the given string name.
399  */
400 AirpcapLinkType
401 airpcap_get_link_type(const gchar* name)
402 {
403     if(!(g_ascii_strcasecmp(AIRPCAP_LINK_TYPE_NAME_802_11_ONLY,name))){
404         return AIRPCAP_LT_802_11;
405     }else if(!(g_ascii_strcasecmp(AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO,name))){
406         return AIRPCAP_LT_802_11_PLUS_RADIO;
407     }else if(!(g_ascii_strcasecmp(AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_PPI,name))){
408         return AIRPCAP_LT_802_11_PLUS_PPI;
409     }else{
410         return AIRPCAP_LT_UNKNOWN;
411     }
412 }
413
414 /*
415  * Returns the string name corresponding to the given AirpcapLinkType, or
416  * NULL in case of error.
417  */
418 gchar*
419 airpcap_get_link_name(AirpcapLinkType lt)
420 {
421     if(lt == AIRPCAP_LT_802_11){
422         return AIRPCAP_LINK_TYPE_NAME_802_11_ONLY;
423     }else if(lt == AIRPCAP_LT_802_11_PLUS_RADIO){
424         return AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO;
425     }else if(lt == AIRPCAP_LT_802_11_PLUS_PPI){
426         return AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_PPI;
427     }else if(lt == AIRPCAP_LT_UNKNOWN){
428         return AIRPCAP_LINK_TYPE_NAME_UNKNOWN;
429     }
430     return NULL;
431 }
432
433 /*
434  * Sets the entry of the validation combo using the AirpcapValidationType.
435  */
436 void
437 airpcap_validation_type_combo_set_by_type(GtkWidget* c, AirpcapValidationType type)
438 {
439     gtk_combo_box_set_active(GTK_COMBO_BOX(c), airpcap_get_validation_combo_entry(type));
440 }
441
442 /*
443  * Returns the string corresponding to the given guint (1-14, for channel only)
444  */
445 gchar*
446 airpcap_get_channel_name(guint n)
447 {
448     return g_strdup_printf("%d",n);
449 }
450
451
452 /*
453  * Set the combo box entry string given a channel frequency
454  */
455 void
456 airpcap_channel_combo_set_by_frequency(GtkWidget* cb, guint chan_freq)
457 {
458     guint i;
459
460     for (i = 0; i < airpcap_if_selected->numSupportedChannels; i++) {
461         if (airpcap_if_selected->pSupportedChannels[i].Frequency == chan_freq) {
462             gtk_combo_box_set_active(GTK_COMBO_BOX(cb), i);
463             break;
464         }
465     }
466 }
467
468 /*
469  * Change channel of Airpcap Adapter
470  */
471 static gboolean
472 airpcap_update_frequency_and_offset(airpcap_if_info_t* if_info)
473 {
474     gchar ebuf[AIRPCAP_ERRBUF_SIZE];
475     PAirpcapHandle ad;
476     gboolean return_value = FALSE;
477
478     if (if_info != NULL){
479         ad = airpcap_if_open(if_info->name, ebuf);
480
481         if(ad != NULL) {
482             return_value = airpcap_if_set_device_channel_ex(ad,if_info->channelInfo);
483             airpcap_if_close(ad);
484         }
485     }
486
487     return return_value;
488 }
489
490 /*
491  * Changed callback for the channel combobox - common routine
492  */
493 static void
494 airpcap_channel_changed_common(GtkWidget *channel_cb, gpointer channel_offset_cb, gboolean set)
495 {
496     gint cur_chan_idx;
497
498     if (channel_cb && channel_offset_cb && change_airpcap_settings && airpcap_if_active) {
499         cur_chan_idx = gtk_combo_box_get_active(GTK_COMBO_BOX(channel_cb));
500         if (cur_chan_idx >= 0 && cur_chan_idx < (gint) airpcap_if_active->numSupportedChannels) {
501             if (set) {
502                 airpcap_if_active->channelInfo.Frequency = airpcap_if_active->pSupportedChannels[cur_chan_idx].Frequency;
503             }
504             airpcap_update_channel_offset_combo(airpcap_if_active,
505                     airpcap_if_active->channelInfo.Frequency,
506                     GTK_WIDGET(channel_offset_cb), set);
507         }
508     }
509 }
510
511 /*
512  * Changed callback for the channel combobox - set channel and offset
513  */
514 void
515 airpcap_channel_changed_set_cb(GtkWidget *channel_cb, gpointer channel_offset_cb)
516 {
517     airpcap_channel_changed_common(channel_cb, channel_offset_cb, TRUE);
518 }
519
520 /*
521  * Changed callback for the channel combobox - don't set channel and offset
522  */
523 void
524 airpcap_channel_changed_noset_cb(GtkWidget *channel_cb, gpointer channel_offset_cb)
525 {
526     airpcap_channel_changed_common(channel_cb, channel_offset_cb, FALSE);
527 }
528
529 static int
530 airpcap_get_selected_channel_offset(GtkWidget *channel_offset_cb) {
531     int offset;
532     gchar *off_str;
533     int retval = 0;
534
535
536     if (channel_offset_cb == NULL || !gtk_widget_get_sensitive(channel_offset_cb)) {
537         return 0;
538     }
539
540     off_str = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(channel_offset_cb));
541     if (off_str && (g_ascii_strcasecmp("", off_str)))
542     {
543         if (airpcap_if_selected != NULL)
544         {
545             sscanf(off_str, "%d", &offset);
546             if (offset >= -1 && offset <= 1) {
547                 retval = offset;
548             }
549         }
550     }
551     g_free(off_str);
552     return retval;
553 }
554
555 /*
556  * Changed callback for the channel offset combobox
557  */
558 void
559 airpcap_channel_offset_changed_cb(GtkWidget *channel_offset_cb, gpointer data _U_)
560 {
561     airpcap_if_selected->channelInfo.ExtChannel = airpcap_get_selected_channel_offset(channel_offset_cb);
562     airpcap_if_selected->saved = FALSE;
563     change_airpcap_settings = TRUE;
564     if (!airpcap_update_frequency_and_offset(airpcap_if_selected)){
565         simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,
566                       "Unable to set extension channel %d",
567                       airpcap_if_selected->channelInfo.ExtChannel);
568     }
569 }
570
571
572 /*
573  * Update the channel offset of the given combobox according to the given frequency.
574  */
575 void
576 airpcap_update_channel_offset_combo(airpcap_if_info_t* if_info, guint chan_freq, GtkWidget *channel_offset_cb, gboolean set)
577 {
578     gint current_offset;
579     gint new_offset;
580     guint i;
581     gint active_idx = 0;
582     gint idx_count = -1;
583
584     if (!if_info || airpcap_if_is_any(if_info) || if_info->pSupportedChannels == NULL || if_info->numSupportedChannels < 1) {
585         gtk_widget_set_sensitive(GTK_WIDGET(channel_offset_cb),FALSE);
586         gtk_combo_box_set_active(GTK_COMBO_BOX(channel_offset_cb), -1);
587         return;
588     }
589
590     new_offset = current_offset = if_info->channelInfo.ExtChannel;
591
592     /* Clear out the list */
593     while (gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(channel_offset_cb)), NULL) > 0) {
594         gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(channel_offset_cb), 0);
595     }
596
597     gtk_widget_set_sensitive(GTK_WIDGET(channel_offset_cb), TRUE);
598
599     for (i = 0; i < if_info->numSupportedChannels; i++) {
600         if (if_info->pSupportedChannels[i].Frequency == chan_freq) {
601
602             /* If we can't be low or high, nudge the offset to 0 */
603             if (current_offset == -1 && !(if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_LOW)) {
604                 new_offset = 0;
605             } else if (current_offset == 1 && !(if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_HIGH)) {
606                 new_offset = 0;
607             }
608
609             if ((if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_LOW)) {
610                 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(channel_offset_cb), "-1");
611                 idx_count++;
612                 if (new_offset == -1) {
613                     active_idx = idx_count;
614                 }
615             }
616             gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(channel_offset_cb), "0");
617             idx_count++;
618             if (new_offset == 0) {
619                 active_idx = idx_count;
620             }
621             if ((if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_HIGH)){
622                 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(channel_offset_cb), "+1");
623                 idx_count++;
624                 if (new_offset == 1) {
625                     active_idx = idx_count;
626                 }
627             }
628             break;
629         }
630     }
631
632     gtk_combo_box_set_active(GTK_COMBO_BOX(channel_offset_cb), active_idx);
633
634
635     if (set) {
636         change_airpcap_settings = TRUE;
637
638         if_info->channelInfo.ExtChannel = new_offset;
639         if (!airpcap_update_frequency_and_offset(if_info)){
640             simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Adapter failed to be set with the following settings: Frequency - %d   Extension Channel - %d", if_info->channelInfo.Frequency, if_info->channelInfo.ExtChannel);
641         }
642     }
643
644     if (idx_count < 1) {
645         gtk_widget_set_sensitive(channel_offset_cb, FALSE);
646     }
647 }
648
649 /*
650  * Returns '1' if this is the "Any" adapter, '0' otherwise
651  */
652 int
653 airpcap_if_is_any(airpcap_if_info_t* if_info)
654 {
655     if(g_ascii_strcasecmp(if_info->name,AIRPCAP_DEVICE_ANY_EXTRACT_STRING)==0)
656         return 1;
657     else
658         return 0;
659 }
660
661 /*
662  * Update channel combo box. If the airpcap interface is "Any", the combo box will be disabled.
663  */
664 void
665 airpcap_update_channel_combo(GtkWidget* channel_cb, airpcap_if_info_t* if_info)
666 {
667     if(!if_info || airpcap_if_is_any(if_info) || !airpcap_if_selected)
668     {
669         gtk_combo_box_set_active(GTK_COMBO_BOX(channel_cb), -1);
670         change_airpcap_settings = FALSE;
671         gtk_widget_set_sensitive(GTK_WIDGET(channel_cb),FALSE);
672     }
673     else
674     {
675         while (gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(channel_cb)), NULL) > 0) {
676             gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(channel_cb), 0);
677         }
678
679         if (if_info != NULL && if_info->pSupportedChannels != NULL && if_info->numSupportedChannels > 0){
680             guint i;
681             for (i = 0; i<(if_info->numSupportedChannels); i++){
682                 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(channel_cb), ieee80211_mhz_to_str(airpcap_if_selected->pSupportedChannels[i].Frequency));
683             }
684         }
685
686         airpcap_channel_combo_set_by_frequency(channel_cb, if_info->channelInfo.Frequency);
687         change_airpcap_settings = TRUE;
688         gtk_widget_set_sensitive(GTK_WIDGET(channel_cb), TRUE);
689     }
690 }
691
692 /*
693  * Takes the keys from the GtkList widget, and add them to the interface list
694  */
695 static void
696 airpcap_add_keys_to_driver_from_list(GtkListStore *key_list_store, airpcap_if_info_t *fake_if_info)
697 {
698     GtkTreePath *path;
699     GtkTreeIter iter;
700     GtkTreeModel *model = GTK_TREE_MODEL(key_list_store);
701
702     /* airpcap stuff */
703     guint i, j;
704     gchar s[3];
705     PAirpcapKeysCollection KeysCollection;
706     guint KeysCollectionSize;
707     guint8 KeyByte;
708
709     guint keys_in_list = 0;
710
711     gchar *row_type, *row_key; /* SSID not needed for AirPcap */
712     size_t key_len;
713
714     if(fake_if_info == NULL)
715         return;
716
717     keys_in_list = gtk_tree_model_iter_n_children(model, NULL);
718
719     /*
720      * Save the encryption keys, if we have any of them
721      */
722     KeysCollectionSize = 0;
723
724     /*
725      * Calculate the size of the keys collection
726      */
727     KeysCollectionSize = sizeof(AirpcapKeysCollection) + keys_in_list * sizeof(AirpcapKey);
728
729     /*
730      * Allocate the collection
731      */
732     KeysCollection = (PAirpcapKeysCollection)g_malloc(KeysCollectionSize);
733
734     /*
735      * Populate the key collection
736      */
737     KeysCollection->nKeys = keys_in_list;
738
739     for(i = 0; i < keys_in_list; i++)
740     {
741         path = gtk_tree_path_new_from_indices(i, -1);
742         gtk_tree_model_get_iter(model, &iter, path);
743         gtk_tree_path_free(path);
744         gtk_tree_model_get(model, &iter,
745                            KL_COL_TYPE, &row_type,
746                            KL_COL_KEY, &row_key,
747                            -1);
748
749         if(g_ascii_strcasecmp(row_type,AIRPCAP_WEP_KEY_STRING) == 0)
750             KeysCollection->Keys[i].KeyType = AIRPDCAP_KEY_TYPE_WEP;
751         else if(g_ascii_strcasecmp(row_type,AIRPCAP_WPA_PWD_KEY_STRING) == 0)
752             KeysCollection->Keys[i].KeyType = AIRPDCAP_KEY_TYPE_WPA_PWD;
753         else if(g_ascii_strcasecmp(row_type,AIRPCAP_WPA_BIN_KEY_STRING) == 0)
754             KeysCollection->Keys[i].KeyType = AIRPDCAP_KEY_TYPE_WPA_PMK;
755
756         /* Retrieve the Item corresponding to the i-th key */
757         key_len = strlen(row_key);
758
759         KeysCollection->Keys[i].KeyLen = (guint) key_len / 2;
760         memset(&KeysCollection->Keys[i].KeyData, 0, sizeof(KeysCollection->Keys[i].KeyData));
761
762         /* Key must be saved in adifferent way, depending on its type... */
763         if(KeysCollection->Keys[i].KeyType == AIRPDCAP_KEY_TYPE_WEP)
764         {
765             for(j = 0 ; j < key_len; j += 2)
766             {
767                 s[0] = row_key[j];
768                 s[1] = row_key[j+1];
769                 s[2] = '\0';
770                 KeyByte = (guint8)strtol(s, NULL, 16);
771                 KeysCollection->Keys[i].KeyData[j / 2] = KeyByte;
772             }
773         }
774         g_free(row_type);
775         g_free(row_key);
776     }
777
778     /*
779      * Free the old adapter key collection!
780      */
781     if(fake_if_info->keysCollection != NULL)
782         g_free(fake_if_info->keysCollection);
783
784     /*
785      * Set this collection ad the new one
786      */
787     fake_if_info->keysCollection = KeysCollection;
788     fake_if_info->keysCollectionSize = KeysCollectionSize;
789     return;
790 }
791
792 /*
793  * This function will take the current keys (widget list), specified for the
794  * current adapter, and save them as default for ALL the others.
795  */
796 void
797 airpcap_read_and_save_decryption_keys_from_list_store(GtkListStore* key_list_store, airpcap_if_info_t* info_if, GList* if_list)
798 {
799     GtkTreeIter iter;
800     GtkTreeModel *model = GTK_TREE_MODEL(key_list_store);
801     gboolean items_left;
802     gint if_n = 0;
803     gint i = 0;
804     gint r = 0;
805     airpcap_if_info_t* curr_if = NULL;
806     airpcap_if_info_t* fake_info_if = NULL;
807     GList* key_list=NULL;
808
809     char* tmp_type = NULL;
810     char* tmp_key = NULL;
811     char* tmp_ssid = "";
812
813     decryption_key_t* tmp_dk=NULL;
814
815     /*
816      * Save the keys for Wireshark...
817      */
818
819     /* Create a list of keys from the list store */
820     for (items_left = gtk_tree_model_get_iter_first (model, &iter);
821          items_left;
822          items_left = gtk_tree_model_iter_next (model, &iter)) {
823
824         gtk_tree_model_get(model, &iter,
825                            KL_COL_TYPE, &tmp_type,
826                            KL_COL_KEY, &tmp_key,
827                            KL_COL_SSID, &tmp_ssid,
828                            -1);
829
830         if(g_ascii_strcasecmp(tmp_type, AIRPCAP_WEP_KEY_STRING) == 0)
831         {
832             tmp_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
833             tmp_dk->key = g_string_new(tmp_key);
834             tmp_dk->ssid = NULL;
835             tmp_dk->type = AIRPDCAP_KEY_TYPE_WEP;
836             tmp_dk->bits = (guint) tmp_dk->key->len * 4;
837             key_list = g_list_append(key_list,tmp_dk);
838         }
839         else if(g_ascii_strcasecmp(tmp_type, AIRPCAP_WPA_PWD_KEY_STRING) == 0)
840         {
841             tmp_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
842             tmp_dk->key = g_string_new(tmp_key);
843             tmp_dk->ssid = g_byte_array_new();
844             uri_str_to_bytes(tmp_ssid, tmp_dk->ssid);
845             tmp_dk->type = AIRPDCAP_KEY_TYPE_WPA_PWD;
846             tmp_dk->bits = 256;
847             key_list = g_list_append(key_list,tmp_dk);
848         }
849         else if(g_ascii_strcasecmp(tmp_type, AIRPCAP_WPA_BIN_KEY_STRING) == 0)
850         {
851             tmp_dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
852             tmp_dk->key = g_string_new(tmp_key);
853             tmp_dk->ssid = NULL; /* No SSID in this case */
854             tmp_dk->type = AIRPDCAP_KEY_TYPE_WPA_PMK;
855             tmp_dk->bits = 256;
856             key_list = g_list_append(key_list,tmp_dk);
857         }
858         g_free(tmp_type);
859         g_free(tmp_ssid);
860     }
861
862     r = save_wlan_wireshark_wep_keys(key_list);
863     /* The key_list has been freed!!! */
864
865     /*
866      * Save the key list for driver.
867      */
868     if( (if_list == NULL) || (info_if == NULL) ) return;
869
870     fake_info_if = airpcap_driver_fake_if_info_new();
871
872     airpcap_add_keys_to_driver_from_list(key_list_store,fake_info_if);
873     airpcap_save_driver_if_configuration(fake_info_if);
874     airpcap_if_info_free(fake_info_if);
875
876     if_n = g_list_length(if_list);
877
878     /* For all the adapters in the list, empty the key list */
879     for(i = 0; i < if_n; i++)
880     {
881         curr_if = (airpcap_if_info_t*)g_list_nth_data(if_list,i);
882
883         if(curr_if != NULL)
884         {
885             /* XXX - Set an empty collection */
886             airpcap_if_clear_decryption_settings(curr_if);
887
888             /* Save to registry */
889             airpcap_save_selected_if_configuration(curr_if);
890         }
891     }
892 }
893
894 /*
895  * This function will load from the preferences file ALL the
896  * keys (WEP, WPA and WPA_BIN) and will set them as default for
897  * each adapter. To do this, it will save the keys in the registry...
898  * A check will be performed, to make sure that keys found in
899  * registry and keys found in Wireshark preferences are the same. If not,
900  * the user will be asked to choose if use all keys (merge them),
901  * or use Wireshark preferences ones. In the last case, registry keys will
902  * be overwritten for all the connected AirPcap adapters.
903  * In the first case, adapters will use their own keys, but those
904  * keys will not be accessible via Wireshark...
905  */
906 gboolean
907 airpcap_check_decryption_keys(GList* if_list)
908 {
909     gint if_n = 0;
910     gint i = 0;
911     gint n_adapters_keys = 0;
912     gint n_driver_keys = 0;
913     gint n_wireshark_keys = 0;
914     airpcap_if_info_t* curr_if = NULL;
915
916     GList* wireshark_key_list;
917     GList* driver_key_list;
918     GList* curr_adapter_key_list;
919
920     gboolean equals = TRUE;
921     gboolean adapters_keys_equals=TRUE;
922
923     /*
924      * If no AirPcap interface is found, return TRUE, so Wireshark
925      * will use HIS OWN keys.
926      */
927     if(if_list == NULL)
928         return TRUE;
929
930     if_n = g_list_length(if_list);
931
932     /* Get Wireshark preferences keys */
933     wireshark_key_list = get_wireshark_keys();
934     n_wireshark_keys = g_list_length(wireshark_key_list);
935
936     /* Retrieve AirPcap driver's keys */
937     driver_key_list = get_airpcap_driver_keys();
938     n_driver_keys = g_list_length(driver_key_list);
939
940     equals &= key_lists_are_equal(wireshark_key_list,driver_key_list);
941
942     for(i = 0; i < if_n; i++)
943     {
944         curr_if = (airpcap_if_info_t*)g_list_nth_data(if_list,i);
945         curr_adapter_key_list = get_airpcap_device_keys(curr_if);
946         n_adapters_keys += g_list_length(curr_adapter_key_list);
947         adapters_keys_equals &= key_lists_are_equal(wireshark_key_list,curr_adapter_key_list);
948     }
949
950     if(n_adapters_keys != 0) /* If for some reason at least one specific key has been found */
951         equals &= adapters_keys_equals;        /* */
952
953     if(n_driver_keys == 0) /* No keys set in any of the AirPcap adapters... */
954         return TRUE; /* Use Wireshark keys and set them ad default for airpcap devices */
955
956     return equals;
957 }
958
959 /*
960  * This function will load from the preferences file ALL the
961  * keys (WEP, WPA_PWD and WPA_BIN) and will set them as default for
962  * each adapter. To do this, it will save the keys in the registry...
963  * A check will be performed, to make sure that keys found in
964  * registry and keys found in Wireshark preferences are the same. If not,
965  * the user will be asked to choose if use all keys (merge them),
966  * or use Wireshark preferences ones. In the last case, registry keys will
967  * be overwritten for all the connected AirPcap adapters.
968  * In the first case, adapters will use their own keys, but those
969  * keys will not be accessible via Wireshark...
970  */
971 void
972 airpcap_load_decryption_keys(GList* if_list)
973 {
974     gint if_n = 0;
975     gint i = 0;
976     airpcap_if_info_t* curr_if = NULL;
977
978     if(if_list == NULL) return;
979
980     if_n = g_list_length(if_list);
981
982     for(i = 0; i < if_n; i++)
983     {
984         curr_if = (airpcap_if_info_t*)g_list_nth_data(if_list,i);
985         load_wlan_driver_wep_keys();
986     }
987 }
988
989 /*
990  * This function will set the gibven GList of decryption_key_t structures
991  * as the defoult for both Wireshark and the AirPcap adapters...
992  */
993 void
994 airpcap_save_decryption_keys(GList* key_list, GList* adapters_list)
995 {
996     gint if_n = 0;
997     gint key_n = 0;
998     gint i = 0;
999     airpcap_if_info_t* curr_if = NULL;
1000     GList* empty_key_list = NULL;
1001
1002     if( (key_list == NULL) || (adapters_list == NULL)) return;
1003
1004     if_n = g_list_length(adapters_list);
1005     key_n = g_list_length(key_list);
1006
1007     /* Set the driver's global list of keys. */
1008     write_wlan_driver_wep_keys_to_registry(key_list);
1009
1010     /* Empty the key list for each interface */
1011     for(i = 0; i < if_n; i++)
1012     {
1013         curr_if = (airpcap_if_info_t*)g_list_nth_data(adapters_list,i);
1014         write_wlan_wep_keys_to_registry(curr_if,empty_key_list);
1015     }
1016
1017     /*
1018      * This will set the keys of the current adapter as Wireshark default...
1019      * Now all the adapters have the same keys, so curr_if is ok as any other...
1020      */
1021     save_wlan_wireshark_wep_keys(key_list);
1022 }
1023
1024 /*
1025  * This function is used to enable/disable the toolbar widgets
1026  * depending on the type of interface selected... Not the whole
1027  * toolbar must be grayed/enabled ... Only some widgets...
1028  */
1029 void
1030 airpcap_enable_toolbar_widgets(GtkWidget* w, gboolean en)
1031 {
1032     GtkWidget   *toolbar_tb,
1033                 *if_description_lb,
1034                 *toolbar_channel_cb,
1035                 *channel_lb,
1036                 *channel_offset_cb,
1037                 *channel_offset_lb,
1038                 *fcs_cb,
1039                 *fcs_lb,
1040                 *advanced_bt;
1041
1042     if(w == NULL)
1043         return;
1044
1045     toolbar_tb = w;
1046
1047     if_description_lb   = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_INTERFACE_KEY);
1048     channel_lb          = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
1049     toolbar_channel_cb  = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
1050     channel_offset_cb   = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY);
1051     channel_offset_lb   = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY);
1052     fcs_lb              = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY);
1053     fcs_cb              = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
1054     advanced_bt         = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_ADVANCED_KEY);
1055
1056
1057     if(if_description_lb != NULL)
1058         gtk_widget_set_sensitive(if_description_lb,en);
1059     if(channel_lb != NULL)
1060         gtk_widget_set_sensitive(channel_lb,en);
1061     if(toolbar_channel_cb != NULL)
1062         gtk_widget_set_sensitive(toolbar_channel_cb,en);
1063     if(channel_offset_cb != NULL)
1064         gtk_widget_set_sensitive(channel_offset_cb,en);
1065     if(channel_offset_lb != NULL)
1066         gtk_widget_set_sensitive(channel_offset_lb,en);
1067     if(fcs_lb != NULL)
1068         gtk_widget_set_sensitive(fcs_lb,en);
1069     if(fcs_cb != NULL)
1070         gtk_widget_set_sensitive(fcs_cb,en);
1071     if(advanced_bt != NULL)
1072         gtk_widget_set_sensitive(advanced_bt,en);
1073
1074     return;
1075 }
1076
1077 #endif /* HAVE_AIRPCAP */
1078
1079 /*
1080  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
1081  *
1082  * Local variables:
1083  * c-basic-offset: 4
1084  * tab-width: 4
1085  * indent-tabs-mode: nil
1086  * End:
1087  *
1088  * vi: set shiftwidth=4 tabstop=4 expandtab
1089  * :indentSize=4:tabSize=4:noTabs=true:
1090  */