Migrate the Airpcap UI code from GtkCombos (deprecated) to GtkComboBoxes.

Consolidate some common code. Rename a bunch of variables. Remove some
unused code.

Fix an offset flag bug in airpcap_loader.c.

This had to be merged by hand with r28349. Hopefully none of those
changes were clobbered.

svn path=/trunk/; revision=28350
This commit is contained in:
Gerald Combs 2009-05-13 16:14:28 +00:00
parent 95be22667a
commit 0a069bc6a3
9 changed files with 560 additions and 838 deletions

View File

@ -821,10 +821,10 @@ airpcap_if_get_device_supported_channels_array(PAirpcapHandle ah, guint32 * pNum
switch(chanInfo[i].ExtChannel)
{
case -1:
pSupportedChannels[numSupportedChannels].Flags = FLAG_CAN_BE_HIGH;
pSupportedChannels[numSupportedChannels].Flags = FLAG_CAN_BE_LOW;
break;
case +1:
pSupportedChannels[numSupportedChannels].Flags = FLAG_CAN_BE_LOW;
pSupportedChannels[numSupportedChannels].Flags = FLAG_CAN_BE_HIGH;
break;
case 0:
default:
@ -850,10 +850,10 @@ airpcap_if_get_device_supported_channels_array(PAirpcapHandle ah, guint32 * pNum
switch(chanInfo[i].ExtChannel)
{
case -1:
pSupportedChannels[supportedChannel].Flags |= FLAG_CAN_BE_HIGH;
pSupportedChannels[supportedChannel].Flags |= FLAG_CAN_BE_LOW;
break;
case +1:
pSupportedChannels[supportedChannel].Flags |= FLAG_CAN_BE_LOW;
pSupportedChannels[supportedChannel].Flags |= FLAG_CAN_BE_HIGH;
break;
case 0:
default:

File diff suppressed because it is too large Load Diff

View File

@ -142,13 +142,13 @@ on_reset_configuration_bt_clicked(GtkWidget *button, gpointer data _U_);
* Turns the decryption on or off
*/
void
on_enable_decryption_en_changed(GtkWidget *w, gpointer data);
on_decryption_mode_cb_changed(GtkWidget *w, gpointer data);
/*
* Will fill the given combo box with the current decryption mode string
* Selects the current decryption mode in the given combo box
*/
void
update_decryption_mode_cm(GtkWidget *w);
update_decryption_mode(GtkWidget *w);
/*
* Reset configuration

View File

@ -104,7 +104,7 @@ void
airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info)
{
GtkWidget *airpcap_toolbar_label;
GtkWidget *airpcap_toolbar_channel;
GtkWidget *toolbar_channel_cb;
GtkWidget *airpcap_toolbar_channel_lb;
GtkWidget *airpcap_toolbar_channel_offset;
GtkWidget *airpcap_toolbar_channel_offset_lb;
@ -118,7 +118,7 @@ airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info)
gchar *if_label_text;
airpcap_toolbar_label = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_INTERFACE_KEY);
airpcap_toolbar_channel = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
toolbar_channel_cb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
airpcap_toolbar_channel_lb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
airpcap_toolbar_channel_offset = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY);
airpcap_toolbar_channel_offset_lb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY);
@ -134,7 +134,7 @@ airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info)
{
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(toolbar_channel_cb,TRUE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,TRUE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,TRUE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,TRUE);
@ -146,7 +146,7 @@ airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info)
gtk_widget_set_sensitive(airpcap_toolbar_decryption_lb,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_keys_button,FALSE);
/*decription check box*/
/*decryption check box*/
g_signal_handlers_block_by_func (airpcap_toolbar_decryption,airpcap_toolbar_encryption_cb, airpcap_tb);
if(if_info->DecryptionOn == AIRPCAP_DECRYPTION_ON)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(airpcap_toolbar_decryption),TRUE);
@ -164,22 +164,19 @@ airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info)
GList *channel_list = NULL;
for (; i<if_info->numSupportedChannels; i++){
channel_list = g_list_append(channel_list, ieee80211_mhz_to_str(if_info->pSupportedChannels[i].Frequency));
gtk_combo_box_append_text(GTK_COMBO_BOX(toolbar_channel_cb), ieee80211_mhz_to_str(if_info->pSupportedChannels[i].Frequency));
}
gtk_combo_set_popdown_strings( GTK_COMBO(airpcap_toolbar_channel), channel_list);
airpcap_free_channel_combo_list(channel_list);
}
airpcap_update_channel_offset_combo_entry(airpcap_toolbar_channel_offset, if_info->channelInfo.ExtChannel);
airpcap_update_channel_combo(GTK_WIDGET(airpcap_toolbar_channel),if_info);
airpcap_update_channel_offset_cb(if_info, if_info->channelInfo.Frequency, airpcap_toolbar_channel_offset);
airpcap_update_channel_combo(GTK_WIDGET(toolbar_channel_cb),if_info);
airpcap_update_channel_offset_combo(if_info, if_info->channelInfo.Frequency, airpcap_toolbar_channel_offset);
change_airpcap_settings = TRUE;
}
else /* Current interface is NOT an AirPcap one... */
{
gtk_widget_set_sensitive(airpcap_tb,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_label,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_channel,FALSE);
gtk_widget_set_sensitive(toolbar_channel_cb,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,FALSE);
@ -202,7 +199,7 @@ 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 *toolbar_channel_cb;
GtkWidget *airpcap_toolbar_channel_lb;
GtkWidget *airpcap_toolbar_channel_offset;
GtkWidget *airpcap_toolbar_channel_offset_lb;
@ -217,7 +214,7 @@ airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info)
airpcap_toolbar_crc_filter_combo = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY);
airpcap_toolbar_label = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_INTERFACE_KEY);
airpcap_toolbar_channel = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
toolbar_channel_cb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
airpcap_toolbar_channel_lb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
airpcap_toolbar_channel_offset = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY);
airpcap_toolbar_channel_offset_lb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY);
@ -233,7 +230,7 @@ airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info)
{
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(toolbar_channel_cb,TRUE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,TRUE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,TRUE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,TRUE);
@ -244,7 +241,7 @@ airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info)
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_validation_type_combo_set_by_type(airpcap_toolbar_crc_filter_combo, if_info->CrcValidationOn);
/*decription check box*/
g_signal_handlers_block_by_func (airpcap_toolbar_decryption,airpcap_toolbar_encryption_cb, airpcap_tb);
@ -264,22 +261,19 @@ airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info)
GList *channel_list = NULL;
for (; i<if_info->numSupportedChannels; i++){
channel_list = g_list_append(channel_list, ieee80211_mhz_to_str(if_info->pSupportedChannels[i].Frequency));
gtk_combo_box_append_text(GTK_COMBO_BOX(toolbar_channel_cb), ieee80211_mhz_to_str(if_info->pSupportedChannels[i].Frequency));
}
gtk_combo_set_popdown_strings( GTK_COMBO(airpcap_toolbar_channel), channel_list);
airpcap_free_channel_combo_list(channel_list);
}
airpcap_update_channel_combo(GTK_WIDGET(airpcap_toolbar_channel),if_info);
airpcap_update_channel_offset_cb(if_info, if_info->channelInfo.Frequency, airpcap_toolbar_channel_offset);
airpcap_update_channel_offset_combo_entry(airpcap_toolbar_channel_offset, if_info->channelInfo.ExtChannel);
airpcap_update_channel_combo(GTK_WIDGET(toolbar_channel_cb),if_info);
airpcap_update_channel_offset_combo(if_info, if_info->channelInfo.Frequency, airpcap_toolbar_channel_offset);
change_airpcap_settings = TRUE;
}
else
{
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(toolbar_channel_cb,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_lb,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_offset,FALSE);
gtk_widget_set_sensitive(airpcap_toolbar_channel_offset_lb,FALSE);
@ -478,6 +472,26 @@ airpcap_get_validation_name(AirpcapValidationType vt)
return NULL;
}
/*
* Return an appropriate combo box entry number for the given an AirpcapValidationType,
* defaulting to 0
*/
gint
airpcap_get_validation_combo_entry(AirpcapValidationType vt)
{
switch (vt) {
case AIRPCAP_VT_ACCEPT_CORRECT_FRAMES:
return 1;
break;
case AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES:
return 2;
break;
default:
return 0;
break;
}
}
/*
* Returns the AirpcapLinkType corresponding to the given string name.
*/
@ -545,38 +559,7 @@ airpcap_link_type_combo_get_type(GtkWidget* c)
void
airpcap_validation_type_combo_set_by_type(GtkWidget* c, AirpcapValidationType type)
{
const gchar* s;
s = airpcap_get_validation_name(type);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(c)->entry),s);
}
/*
* Retrieves the name in the validation combo entry.
*/
AirpcapValidationType
airpcap_validation_type_combo_get_type(GtkWidget* c)
{
const gchar* s;
s = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(c)->entry));
return airpcap_get_validation_type(s);
}
/*
* Retrieve the UINT corresponding to the given string (channel only, handle with care!)
*/
ULONG
airpcap_get_frequency_from_str(const gchar* s)
{
ULONG ch_freq;
sscanf(s,"%ld",&ch_freq);
/* XXX - check for ch_num btween 1-14, and return -1 otherwise??? */
return ch_freq;
gtk_combo_box_set_active(GTK_COMBO_BOX(c), airpcap_get_validation_combo_entry(type));
}
/*
@ -588,35 +571,21 @@ airpcap_get_channel_name(UINT n)
return g_strdup_printf("%d",n);
}
/*
* Free a channel combo list
*/
static void
free_channel_string(gpointer data, gpointer user_data _U_)
{
g_free(data);
}
void
airpcap_free_channel_combo_list(GList *channel_list)
{
if (channel_list != NULL) {
g_list_foreach(channel_list, free_channel_string, NULL);
g_list_free(channel_list);
}
}
/*
* Set the combo box entry string given an UINT channel number
* Set the combo box entry string given a channel frequency
*/
void
airpcap_channel_combo_set_by_number(GtkWidget* w,UINT chan_freq)
airpcap_channel_combo_set_by_frequency(GtkWidget* cb, guint chan_freq)
{
gchar *entry_text;
guint i;
entry_text = ieee80211_mhz_to_str(chan_freq);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),entry_text);
g_free(entry_text);
for (i = 0; i < airpcap_if_selected->numSupportedChannels; i++) {
if (airpcap_if_selected->pSupportedChannels[i].Frequency == chan_freq) {
gtk_combo_box_set_active(GTK_COMBO_BOX(cb), i);
break;
}
}
}
/*
@ -642,51 +611,132 @@ airpcap_update_frequency_and_offset(airpcap_if_info_t* if_info)
}
/*
* Update the channel offset of the given combobox
* Changed callback for the channel combobox
*/
void
airpcap_update_channel_offset_cb(airpcap_if_info_t* if_info, ULONG ch_freq, GtkWidget *channel_offset_cb)
airpcap_channel_changed_cb(GtkWidget *channel_cb, gpointer channel_offset_cb)
{
const gchar *current_offset;
gchar current_offset_copy[10];
gchar *new_offset_str;
ULONG chan_flags;
gint cur_chan_idx;
if (airpcap_if_is_any(if_info)){
gtk_widget_set_sensitive(GTK_WIDGET(channel_offset_cb),FALSE);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_offset_cb)->entry), "0");
return;
}
current_offset = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(channel_offset_cb)->entry));
g_strlcpy (current_offset_copy, current_offset, sizeof(current_offset_copy));
chan_flags = airpcap_load_channel_offset_cb(if_info, channel_offset_cb, ch_freq);
new_offset_str = current_offset_copy;
/* If current_offset == -1 && new_offset cannot be -1 */
if (strcmp(current_offset_copy, "-1") == 0 && !(chan_flags & FLAG_CAN_BE_HIGH)){
if ((chan_flags & FLAG_CAN_BE_LOW)){
new_offset_str = "+1";
}else{
new_offset_str = "0";
}
}else if (strcmp(current_offset_copy, "+1") == 0 && !(chan_flags & FLAG_CAN_BE_LOW)){
if ((chan_flags & FLAG_CAN_BE_HIGH)){
new_offset_str = "-1";
}else{
new_offset_str = "0";
}
if (channel_cb && channel_offset_cb && change_airpcap_settings && airpcap_if_active) {
cur_chan_idx = gtk_combo_box_get_active(GTK_COMBO_BOX(channel_cb));
if (cur_chan_idx >= 0 && cur_chan_idx < (gint) airpcap_if_active->numSupportedChannels) {
airpcap_if_active->channelInfo.Frequency = airpcap_if_active->pSupportedChannels[cur_chan_idx].Frequency;
airpcap_update_channel_offset_combo(airpcap_if_active,
airpcap_if_active->channelInfo.Frequency,
GTK_WIDGET(channel_offset_cb));
}
}
}
change_airpcap_settings = FALSE;
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_offset_cb)->entry), new_offset_str);
change_airpcap_settings = TRUE;
static int
airpcap_get_selected_channel_offset(GtkWidget *channel_offset_cb) {
int offset;
gchar *off_str;
int retval = 0;
sscanf(new_offset_str,"%c",&(if_info->channelInfo.ExtChannel));
if (!airpcap_update_frequency_and_offset(if_info)){
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);
}
if (channel_offset_cb == NULL || !GTK_WIDGET_SENSITIVE(channel_offset_cb)) {
return 0;
}
off_str = gtk_combo_box_get_active_text(GTK_COMBO_BOX(channel_offset_cb));
if (off_str && (g_ascii_strcasecmp("", off_str)))
{
if (airpcap_if_selected != NULL)
{
sscanf(off_str, "%d", &offset);
if (offset >= -1 && offset <= -1) {
retval = offset;
}
}
}
g_free(off_str);
return retval;
}
/*
* Changed callback for the channel offset combobox
*/
void
airpcap_channel_offset_changed_cb(GtkWidget *channel_offset_cb, gpointer data _U_)
{
airpcap_if_selected->channelInfo.ExtChannel = airpcap_get_selected_channel_offset(channel_offset_cb);
airpcap_if_selected->saved = FALSE;
}
/*
* Update the channel offset of the given combobox according to the given frequency.
*/
void
airpcap_update_channel_offset_combo(airpcap_if_info_t* if_info, ULONG chan_freq, GtkWidget *channel_offset_cb)
{
gint current_offset;
gint new_offset;
guint i;
gint active_idx;
gint idx_count = -1;
if (!if_info || airpcap_if_is_any(if_info) || if_info->pSupportedChannels == NULL || if_info->numSupportedChannels < 1) {
gtk_widget_set_sensitive(GTK_WIDGET(channel_offset_cb),FALSE);
gtk_combo_box_set_active(GTK_COMBO_BOX(channel_offset_cb), -1);
return;
}
new_offset = current_offset = airpcap_get_selected_channel_offset(channel_offset_cb);
/* Clear out the list */
while (gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(channel_offset_cb)), NULL) > 0) {
gtk_combo_box_remove_text(GTK_COMBO_BOX(channel_offset_cb), 0);
}
for (i = 0; i < if_info->numSupportedChannels; i++) {
if (if_info->pSupportedChannels[i].Frequency == chan_freq) {
/* If we can't be low or high, nudge the offset to 0 */
if (current_offset == -1 && !(if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_LOW)) {
new_offset = 0;
} else if (current_offset == 1 && !(if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_HIGH)) {
new_offset = 0;
}
if ((if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_LOW)) {
gtk_combo_box_append_text(GTK_COMBO_BOX(channel_offset_cb), "-1");
idx_count++;
if (new_offset == -1) {
active_idx = idx_count;
}
}
gtk_combo_box_append_text(GTK_COMBO_BOX(channel_offset_cb), "0");
idx_count++;
if (new_offset == 0) {
active_idx = idx_count;
}
if ((if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_HIGH)){
gtk_combo_box_append_text(GTK_COMBO_BOX(channel_offset_cb), "+1");
idx_count++;
if (new_offset == 1) {
active_idx = idx_count;
}
}
break;
}
}
gtk_combo_box_set_active(GTK_COMBO_BOX(channel_offset_cb), active_idx);
change_airpcap_settings = TRUE;
if_info->channelInfo.ExtChannel = new_offset;
if (!airpcap_update_frequency_and_offset(if_info)){
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Adapter failed to be set with the following settings: Frequency - %ld Extension Channel - %d", if_info->channelInfo.Frequency, if_info->channelInfo.ExtChannel);
}
if (idx_count < 1) {
gtk_widget_set_sensitive(channel_offset_cb, FALSE);
}
}
/*
@ -705,74 +755,34 @@ airpcap_if_is_any(airpcap_if_info_t* if_info)
* Update channel combo box. If the airpcap interface is "Any", the combo box will be disabled.
*/
void
airpcap_update_channel_combo(GtkWidget* w, airpcap_if_info_t* if_info)
airpcap_update_channel_combo(GtkWidget* channel_cb, airpcap_if_info_t* if_info)
{
gchar* frequency_list;
if(airpcap_if_is_any(if_info))
if(!if_info || airpcap_if_is_any(if_info))
{
frequency_list = airpcap_get_all_channels_list(if_info);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),frequency_list);
g_free(frequency_list);
gtk_combo_box_set_active(GTK_COMBO_BOX(channel_cb), -1);
change_airpcap_settings = FALSE;
gtk_widget_set_sensitive(GTK_WIDGET(w),FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(channel_cb),FALSE);
}
else
{
airpcap_channel_combo_set_by_number(w,if_info->channelInfo.Frequency);
change_airpcap_settings = TRUE;
gtk_widget_set_sensitive(GTK_WIDGET(w),TRUE);
}
}
/*
* Update channel offset combo box to 'offset'.
*/
void
airpcap_update_channel_offset_combo_entry(GtkWidget* w, gchar extChannel)
{
gchar channel_offset_value[3];
if (extChannel > 0){
g_snprintf(channel_offset_value, sizeof(channel_offset_value), "+%d", extChannel);
}else{
g_snprintf(channel_offset_value, sizeof(channel_offset_value), "%d", extChannel);
}
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry), channel_offset_value);
}
/*
* Update channel offset combo box given the selected frequency. Return the flags from the given frequency.
*/
ULONG
airpcap_load_channel_offset_cb(airpcap_if_info_t* if_info, GtkWidget* channel_offset_cb, ULONG chan_freq)
{
GList *channel_offset_list = NULL;
if (if_info != NULL && if_info->pSupportedChannels != NULL && if_info->numSupportedChannels > 0){
guint i = 0;
for (; i<if_info->numSupportedChannels; i++){
if (if_info->pSupportedChannels[i].Frequency == chan_freq){
if ((if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_HIGH)){
channel_offset_list = g_list_append(channel_offset_list, "-1");
}
channel_offset_list = g_list_append(channel_offset_list, "0");
if ((if_info->pSupportedChannels[i].Flags & FLAG_CAN_BE_LOW)){
channel_offset_list = g_list_append(channel_offset_list, "+1");
}
gtk_combo_set_popdown_strings( GTK_COMBO(channel_offset_cb), channel_offset_list) ;
gtk_widget_set_sensitive(channel_offset_cb, g_list_length(channel_offset_list) > 1);
g_list_free(channel_offset_list);
return if_info->pSupportedChannels[i].Flags;
}
while (gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(channel_cb)), NULL) > 0) {
gtk_combo_box_remove_text(GTK_COMBO_BOX(channel_cb), 0);
}
}
if (if_info != NULL && if_info->pSupportedChannels != NULL && if_info->numSupportedChannels > 0){
guint i;
for (i = 0; i<(if_info->numSupportedChannels); i++){
gtk_combo_box_append_text(GTK_COMBO_BOX(channel_cb), ieee80211_mhz_to_str(airpcap_if_selected->pSupportedChannels[i].Frequency));
}
}
return 0;
airpcap_channel_combo_set_by_frequency(channel_cb, if_info->channelInfo.Frequency);
change_airpcap_settings = TRUE;
gtk_widget_set_sensitive(GTK_WIDGET(channel_cb), TRUE);
}
}
/*
* Takes the keys from the GtkList widget, and add them to the interface list
*/
@ -1205,7 +1215,7 @@ airpcap_enable_toolbar_widgets(GtkWidget* w, gboolean en)
{
GtkWidget *toolbar_tb,
*if_description_lb,
*channel_cb,
*toolbar_channel_cb,
*channel_lb,
*channel_offset_cb,
*channel_offset_lb,
@ -1220,7 +1230,7 @@ airpcap_enable_toolbar_widgets(GtkWidget* w, gboolean en)
if_description_lb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_INTERFACE_KEY);
channel_lb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
channel_cb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
toolbar_channel_cb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
channel_offset_cb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY);
channel_offset_lb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY);
fcs_lb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY);
@ -1230,7 +1240,7 @@ airpcap_enable_toolbar_widgets(GtkWidget* w, gboolean en)
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(toolbar_channel_cb != NULL) gtk_widget_set_sensitive(toolbar_channel_cb,en);
if(channel_offset_cb != NULL) gtk_widget_set_sensitive(channel_offset_cb,en);
if(channel_offset_lb != NULL) gtk_widget_set_sensitive(channel_offset_lb,en);
if(fcs_lb != NULL) gtk_widget_set_sensitive(fcs_lb,en);
@ -1249,7 +1259,7 @@ airpcap_set_toolbar_no_if(GtkWidget* w)
{
GtkWidget *toolbar_tb,
*if_description_lb,
*channel_cb,
*toolbar_channel_cb,
*channel_lb,
*channel_offset_cb,
*channel_offset_lb,
@ -1264,7 +1274,7 @@ airpcap_set_toolbar_no_if(GtkWidget* w)
if_description_lb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_INTERFACE_KEY);
channel_lb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY);
channel_cb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
toolbar_channel_cb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY);
channel_offset_lb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY);
channel_offset_cb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY);
fcs_lb = g_object_get_data(G_OBJECT(toolbar_tb),AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY);
@ -1272,7 +1282,7 @@ airpcap_set_toolbar_no_if(GtkWidget* w)
advanced_bt = g_object_get_data(G_OBJECT(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(toolbar_channel_cb != NULL) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(toolbar_channel_cb)->entry),"");
if(channel_offset_cb != NULL) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_offset_cb)->entry),"");
if(if_description_lb != NULL) gtk_label_set_text(GTK_LABEL(if_description_lb),"Current Wireless Interface: None");

View File

@ -35,8 +35,12 @@
#define AIRPCAP_LINK_TYPE_NAME_802_11_ONLY "802.11 Only"
#define AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO "802.11 + Radio"
#define AIRPCAP_LINK_TYPE_NAME_UNKNOWN "Unknown"
#define AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_PPI "802.11 + PPI"
#define AIRPCAP_LINK_TYPE_NAME_UNKNOWN "Unknown"
#define AIRPCAP_LINK_TYPE_NUM_802_11_ONLY 0
#define AIRPCAP_LINK_TYPE_NUM_802_11_PLUS_RADIO 1
#define AIRPCAP_LINK_TYPE_NUM_802_11_PLUS_PPI 2
#define AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK "Wireshark"
#define AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP "Driver"
@ -49,12 +53,12 @@
extern gboolean change_airpcap_settings;
/*
* This structure is used because we need to store infos about the currently selected
* row in the key list.
* This structure is used because we need to store infos about the currently selected
* row in the key list.
*/
typedef struct{
gint row;
gint column;
gint row;
gint column;
}airpcap_key_ls_selected_info_t;
/* XXX Not used anywhere -> Delete??? */
@ -117,6 +121,12 @@ airpcap_get_validation_type(const gchar* name);
gchar*
airpcap_get_validation_name(AirpcapValidationType vt);
/*
* Return an appropriate combo box entry number for the given an AirpcapValidationType.
*/
gint
airpcap_get_validation_combo_entry(AirpcapValidationType vt);
/*
* Returns the AirpcapLinkType corresponding to the given string name.
*/
@ -147,23 +157,12 @@ airpcap_link_type_combo_get_type(GtkWidget* c);
void
airpcap_validation_type_combo_set_by_type(GtkWidget* c,AirpcapValidationType type);
/*
* Retrieves the name in the validation combo entry.
*/
AirpcapValidationType
airpcap_validation_type_combo_get_type(GtkWidget* c);
/*
* Update channel offset combo box to 'offset'.
*/
void
airpcap_update_channel_offset_combo_entry(GtkWidget* w, gchar extChannel);
airpcap_update_channel_offset_combo(airpcap_if_info_t* if_info, ULONG ch_freq, GtkWidget *channel_offset_cb);
/*
* Returns the string corresponding to the given UINT (1-14, for channel only)
*/
ULONG
airpcap_get_frequency_from_str(const gchar* s);
/*
* Retrieve the UINT corresponding to the given string (channel only, handle with care!)
@ -175,13 +174,28 @@ airpcap_get_channel_name(UINT n);
* Set the combo box entry string given an UINT channel number
*/
void
airpcap_channel_combo_set_by_number(GtkWidget* w,UINT channel);
airpcap_channel_combo_set_by_frequency(GtkWidget* w,UINT channel);
/*
* Free a channel combo list
/** Respond to the user changing the channel combo box.
* Update the active interface channel and update the offset
* combo box.
* Requires AirPcap globals.
*
* @param channel_cb The channel GtkComboBox
* @param channel_offset_cb The channel offset GtkComboBox
*/
void
airpcap_free_channel_combo_list(GList *channel_list);
airpcap_channel_changed_cb(GtkWidget *channel_cb, gpointer channel_offset_cb);
/** Respond to the user changing the channel offset combo box.
* Update the active interface channel offset.
* Requires AirPcap globals.
*
* @param channel_offset_cb The channel offset GtkComboBox
* @param data Unused
*/
void
airpcap_channel_offset_changed_cb(GtkWidget *channel_offset_cb, gpointer data);
/*
* Returns '1' if this is the "Any" adapter, '0' otherwise
@ -198,14 +212,14 @@ airpcap_update_frequency_and_offset(airpcap_if_info_t* if_info);
/*
* Takes the keys from the GtkList widget, and add them to the interface list
*/
void
void
airpcap_add_keys_from_list(GtkWidget *w, airpcap_if_info_t *if_info);
/*
* Update channel combo box. If the airpcap interface is "Any", the combo box will be disabled.
*/
void
airpcap_update_channel_combo(GtkWidget* w, airpcap_if_info_t* if_info);
airpcap_update_channel_combo(GtkWidget* channel_cb, airpcap_if_info_t* if_info);
/*
* Update the channel offset of the given combobox
@ -213,12 +227,6 @@ airpcap_update_channel_combo(GtkWidget* w, airpcap_if_info_t* if_info);
void
airpcap_update_channel_offset_cb(airpcap_if_info_t* if_info, ULONG ch_freq, GtkWidget *channel_offset_cb);
/*
* Update channel offset combo box given the selected frequency. Return the flags from the given frequency.
*/
ULONG
airpcap_load_channel_offset_cb(airpcap_if_info_t* if_info, GtkWidget* channel_offset_cb, ULONG chan_freq);
/*
* This function will take the current keys (widget list), specified for the
* current adapter, and save them as default for ALL the others.
@ -228,7 +236,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 WPA_BIN) 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
@ -236,14 +244,14 @@ airpcap_load_decryption_keys(GList* if_list);
/*
* This function will load from the preferences file ALL the
* keys (WEP, WPA and WPA_BIN) 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
airpcap_check_decryption_keys(GList* if_list);
/*
* This function will set the gibven GList of decryption_key_t structures
* This function will set the gibven GList of decryption_key_t structures
* as the defoult for both Wireshark and the AirPcap adapters...
*/
void
@ -251,7 +259,7 @@ 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...
* depending on the type of interface selected...
*/
void
airpcap_enable_toolbar_widgets(GtkWidget* w, gboolean en);

View File

@ -1466,7 +1466,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
*help_bt;
#ifdef HAVE_AIRPCAP
GtkWidget *advanced_bt;
GtkWidget *decryption_cm;
GtkWidget *decryption_cb;
#endif
#ifdef HAVE_PCAP_REMOTE
GtkWidget *iftype_cb;
@ -1555,8 +1555,8 @@ 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 = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
update_decryption_mode_list(decryption_cm);
decryption_cb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
update_decryption_mode_list(decryption_cb);
if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);

View File

@ -446,7 +446,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
*icon;
#ifdef HAVE_AIRPCAP
GtkWidget *decryption_cm;
GtkWidget *decryption_cb;
#endif
GtkWidget *if_tb;
@ -500,8 +500,8 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
if (airpcap_if_list == NULL)
airpcap_if_active = airpcap_if_selected = NULL;
decryption_cm = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
update_decryption_mode_list(decryption_cm);
decryption_cb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
update_decryption_mode_list(decryption_cb);
if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
#if 0

View File

@ -86,7 +86,7 @@
#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_DECRYPTION_MODE_KEY "airpcap_advanced_decryption_mode_key"
#define AIRPCAP_ADVANCED_WPA_DECRYPTION_KEY "airpcap_advanced_wpa_decryption_key"
#define AIRPCAP_ADVANCED_NOTEBOOK_KEY "airpcap_advanced_notebook_key"
#define AIRPCAP_ADVANCED_CANCEL_KEY "airpcap_advanced_cancel_key"

View File

@ -58,76 +58,30 @@ gboolean block_toolbar_signals = FALSE;
static GtkWidget *driver_warning_dialog;
/*
* Changed callback for the channel combobox
*/
static void
airpcap_toolbar_channel_changed_cb(GtkWidget *w, gpointer data)
{
const gchar *s;
ULONG ch_freq;
if ((data != NULL) && (w != NULL) && change_airpcap_settings) {
s = gtk_entry_get_text(GTK_ENTRY(w));
if ((g_ascii_strcasecmp("",s))) {
ch_freq = airpcap_get_frequency_from_str(s);
if (airpcap_if_active != NULL) {
airpcap_if_active->channelInfo.Frequency = ch_freq;
airpcap_update_channel_offset_cb(airpcap_if_active, ch_freq, GTK_WIDGET(data));
}
}
}
}
/*
* Changed callback for the channel offset combobox
*/
static void
on_channel_offset_cb_changed(GtkWidget *w, gpointer data _U_)
{
const gchar *s;
int offset;
if (w == NULL) {
return;
}
if (change_airpcap_settings)
{
s = gtk_entry_get_text(GTK_ENTRY(w));
if ((g_ascii_strcasecmp("",s)))
{
if (airpcap_if_active != NULL)
{
sscanf(s,"%d",&offset);
airpcap_if_active->channelInfo.ExtChannel = offset;
airpcap_update_frequency_and_offset(airpcap_if_active);
}
}
}
}
/*
* Callback for the wrong crc combo
*/
static void
airpcap_toolbar_wrong_crc_combo_cb(GtkWidget *entry, gpointer user_data _U_)
airpcap_toolbar_fcs_filter_combo_cb(GtkWidget *fcs_filter_cb, gpointer user_data _U_)
{
gchar ebuf[AIRPCAP_ERRBUF_SIZE];
PAirpcapHandle ad;
PAirpcapHandle ad;
gchar ebuf[AIRPCAP_ERRBUF_SIZE];
gchar *fcs_filter_str;
if( !block_toolbar_signals && (airpcap_if_active != NULL)) {
ad = airpcap_if_open(airpcap_if_active->name, ebuf);
if (fcs_filter_cb != NULL && !block_toolbar_signals && (airpcap_if_active != NULL)) {
fcs_filter_str = gtk_combo_box_get_active_text(GTK_COMBO_BOX(fcs_filter_cb));
ad = airpcap_if_open(airpcap_if_active->name, ebuf);
if (ad) {
airpcap_if_active->CrcValidationOn = airpcap_get_validation_type(gtk_entry_get_text(GTK_ENTRY(entry)));
airpcap_if_set_fcs_validation(ad,airpcap_if_active->CrcValidationOn);
/* Save configuration */
airpcap_if_store_cur_config_as_adapter_default(ad);
airpcap_if_close(ad);
if (fcs_filter_str && (g_ascii_strcasecmp("", fcs_filter_str)) && ad) {
airpcap_if_selected->CrcValidationOn = airpcap_get_validation_type(fcs_filter_str);
airpcap_if_selected->saved = FALSE;
airpcap_if_set_fcs_validation(ad,airpcap_if_active->CrcValidationOn);
/* Save configuration */
airpcap_if_store_cur_config_as_adapter_default(ad);
airpcap_if_close(ad);
}
g_free(fcs_filter_str);
}
}
}
void
@ -231,21 +185,19 @@ GtkWidget *airpcap_toolbar_new()
GtkWidget *key_management_bt = NULL,
*advanced_bt = NULL,
*channel_lb = NULL,
*channel_cm = NULL,
*channel_cb = NULL,
*channel_offset_lb = NULL,
*channel_offset_cb = NULL,
*wrong_crc_lb = NULL,
*wrong_crc_cm = NULL;
*fcs_filter_lb = NULL,
*fcs_filter_cb = NULL;
GtkWidget *airpcap_tb;
GtkWidget *enable_decryption_lb;
GtkWidget *enable_decryption_cb;
GtkWidget *enable_decryption_en;
GtkWidget *decryption_mode_lb;
GtkWidget *decryption_mode_cb;
GList *channel_list = NULL;
GList *linktype_list = NULL;
GtkTooltips *airpcap_tooltips;
gchar *chan_str;
gint cur_chan_idx = -1;
/* airpcap toolbar */
airpcap_tooltips = gtk_tooltips_new();
@ -280,35 +232,20 @@ GtkWidget *airpcap_toolbar_new()
gtk_widget_set_size_request(channel_lb, 85, 28);
/* Create the channel combo box */
channel_cm = gtk_combo_new();
gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(channel_cm)->entry),FALSE);
g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY,channel_cm);
channel_cb = gtk_combo_box_new_text();
g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_CHANNEL_KEY,channel_cb);
if (airpcap_if_active != NULL && airpcap_if_active->pSupportedChannels != NULL && airpcap_if_active->numSupportedChannels > 0){
guint i = 0;
for (; i<airpcap_if_active->numSupportedChannels; i++){
channel_list = g_list_append(channel_list, ieee80211_mhz_to_str(airpcap_if_active->pSupportedChannels[i].Frequency));
}
gtk_combo_set_popdown_strings( GTK_COMBO(channel_cm), channel_list);
airpcap_free_channel_combo_list(channel_list);
}
/* Select the current channel */
airpcap_update_channel_combo(GTK_WIDGET(channel_cb), airpcap_if_selected);
gtk_tooltips_set_tip(airpcap_tooltips, GTK_WIDGET(GTK_COMBO(channel_cm)->entry),
gtk_tooltips_set_tip(airpcap_tooltips, GTK_WIDGET(channel_cb),
"Change the 802.11 RF channel", NULL);
gtk_widget_set_size_request(channel_cm, 120, 28);
gtk_widget_set_size_request(channel_cb, 120, 28);
if(airpcap_if_active != NULL) {
chan_str = ieee80211_mhz_to_str(airpcap_if_active->channelInfo.Frequency);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cm)->entry), chan_str);
g_free(chan_str);
}
else {
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cm)->entry),"");
}
gtk_widget_show(channel_cm);
gtk_widget_show(channel_cb);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), channel_cm,
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), channel_cb,
"802.11 Channel", "Private");
/* gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb)); */
@ -323,15 +260,13 @@ GtkWidget *airpcap_toolbar_new()
gtk_widget_set_size_request(channel_offset_lb, 80, 28);
/* Start: Channel offset combo box */
channel_offset_cb = gtk_combo_new();
gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(channel_offset_cb)->entry),FALSE);
channel_offset_cb = gtk_combo_box_new_text();
g_object_set_data(G_OBJECT(airpcap_tb), AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY, channel_offset_cb);
if(airpcap_if_active != NULL){
airpcap_update_channel_offset_cb(airpcap_if_active, airpcap_if_active->channelInfo.Frequency, channel_offset_cb);
airpcap_update_channel_offset_combo_entry(channel_offset_cb, airpcap_if_active->channelInfo.ExtChannel);
airpcap_update_channel_offset_combo(airpcap_if_active, airpcap_if_active->channelInfo.Frequency, channel_offset_cb);
} else {
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_offset_cb)->entry),"");
gtk_combo_box_set_active(GTK_COMBO_BOX(channel_offset_cb), -1);
}
gtk_tooltips_set_tip(airpcap_tooltips, GTK_WIDGET(GTK_COMBO(channel_offset_cb)->entry),
@ -347,74 +282,66 @@ GtkWidget *airpcap_toolbar_new()
gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb));
/* callback for channel combo box */
g_signal_connect(GTK_COMBO(channel_cm)->entry,"changed", G_CALLBACK(airpcap_toolbar_channel_changed_cb), channel_offset_cb);
g_signal_connect(channel_cb,"changed", G_CALLBACK(airpcap_channel_changed_cb), channel_offset_cb);
/* callback for channel offset combo box */
g_signal_connect(GTK_COMBO(channel_offset_cb)->entry,"changed", G_CALLBACK(on_channel_offset_cb_changed), NULL);
g_signal_connect(GTK_COMBO(channel_offset_cb)->entry,"changed", G_CALLBACK(airpcap_channel_offset_changed_cb), NULL);
/* End: Channel offset combo box */
/* Wrong CRC Label */
wrong_crc_lb = gtk_label_new(" FCS Filter: ");
g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY,wrong_crc_lb);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), wrong_crc_lb,
fcs_filter_lb = gtk_label_new(" FCS Filter: ");
g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY,fcs_filter_lb);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), fcs_filter_lb,
"", "Private");
gtk_widget_show(wrong_crc_lb);
gtk_widget_show(fcs_filter_lb);
/* Wrong CRC combo */
wrong_crc_cm = gtk_combo_new();
gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(wrong_crc_cm)->entry),FALSE);
g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY,wrong_crc_cm);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), wrong_crc_cm,
/* FCS filter combo */
fcs_filter_cb = gtk_combo_box_new_text();
g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_FCS_FILTER_KEY,fcs_filter_cb);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), fcs_filter_cb,
"", "Private");
gtk_widget_set_size_request(wrong_crc_cm, 100, -1);
gtk_widget_set_size_request(fcs_filter_cb, 100, -1);
linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_ALL);
linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_CORRECT);
linktype_list = g_list_append(linktype_list, AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT);
gtk_combo_box_append_text(GTK_COMBO_BOX(fcs_filter_cb), airpcap_get_validation_name(AIRPCAP_VT_ACCEPT_EVERYTHING));
gtk_combo_box_append_text(GTK_COMBO_BOX(fcs_filter_cb), airpcap_get_validation_name(AIRPCAP_VT_ACCEPT_CORRECT_FRAMES));
gtk_combo_box_append_text(GTK_COMBO_BOX(fcs_filter_cb), airpcap_get_validation_name(AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES));
gtk_combo_box_set_active(GTK_COMBO_BOX(fcs_filter_cb), 0);
gtk_combo_set_popdown_strings( GTK_COMBO(wrong_crc_cm), linktype_list) ;
g_list_free(linktype_list);
gtk_tooltips_set_tip(airpcap_tooltips, GTK_WIDGET(GTK_COMBO(wrong_crc_cm)->entry),
gtk_tooltips_set_tip(airpcap_tooltips, GTK_WIDGET(fcs_filter_cb),
"Select the 802.11 FCS filter that the wireless adapter will apply.",
NULL);
if(airpcap_if_active != NULL)
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_cm)->entry), airpcap_get_validation_name(airpcap_if_active->CrcValidationOn));
else
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wrong_crc_cm)->entry),"");
if (airpcap_if_selected != NULL)
{
airpcap_validation_type_combo_set_by_type(fcs_filter_cb, airpcap_if_selected->CrcValidationOn);
}
g_signal_connect(GTK_COMBO(wrong_crc_cm)->entry,"changed",G_CALLBACK(airpcap_toolbar_wrong_crc_combo_cb),airpcap_tb);
gtk_widget_show(wrong_crc_cm);
g_signal_connect (fcs_filter_cb, "changed", G_CALLBACK(airpcap_toolbar_fcs_filter_combo_cb), NULL);
gtk_widget_show(fcs_filter_cb);
gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb));
/* Decryption mode combo box */
enable_decryption_lb = gtk_label_new ("Decryption Mode: ");
g_object_set_data(G_OBJECT(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,
decryption_mode_lb = gtk_label_new ("Decryption Mode: ");
g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_LABEL_KEY,decryption_mode_lb);
gtk_widget_set_name (decryption_mode_lb, "decryption_mode_lb");
gtk_widget_show (decryption_mode_lb);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), decryption_mode_lb,
NULL, "Private");
enable_decryption_cb = gtk_combo_new ();
gtk_widget_set_name (enable_decryption_cb, "enable_decryption_cb");
gtk_widget_show (enable_decryption_cb);
gtk_widget_set_size_request(enable_decryption_cb, 83, -1);
update_decryption_mode_list(enable_decryption_cb);
decryption_mode_cb = gtk_combo_box_new_text();
gtk_widget_set_name (decryption_mode_cb, "decryption_mode_cb");
gtk_widget_show (decryption_mode_cb);
gtk_widget_set_size_request(decryption_mode_cb, 83, -1);
update_decryption_mode_list(decryption_mode_cb);
enable_decryption_en = GTK_COMBO (enable_decryption_cb)->entry;
gtk_widget_set_name (enable_decryption_en, "enable_decryption_en");
gtk_widget_show (enable_decryption_en);
gtk_editable_set_editable (GTK_EDITABLE (enable_decryption_en), FALSE);
GTK_WIDGET_UNSET_FLAGS (enable_decryption_en, GTK_CAN_FOCUS);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), enable_decryption_cb,
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), decryption_mode_cb,
"Choose a Decryption Mode", "Private");
/* Set current decryption mode!!!! */
update_decryption_mode_cm(enable_decryption_cb);
g_signal_connect(enable_decryption_en, "changed", G_CALLBACK(on_enable_decryption_en_changed), airpcap_tb);
g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY,enable_decryption_cb);
update_decryption_mode(decryption_mode_cb);
g_signal_connect(decryption_mode_cb, "changed", G_CALLBACK(on_decryption_mode_cb_changed), airpcap_tb);
g_object_set_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY,decryption_mode_cb);
gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb));