Don't destroy something if it doesn't exist.
[obnox/wireshark/wip.git] / gtk / airpcap_gui_utils.h
1 /* airpcap_utils.h
2  * Declarations of utility routines for the "Airpcap" dialog widgets
3  *
4  * $Id$
5  *
6  * Giorgio Tino <giorgio.tino@cacetech.com>
7  * Copyright (c) CACE Technologies, LLC 2006
8  *
9  * Wireshark - Network traffic analyzer
10  * By Gerald Combs <gerald@wireshark.org>
11  * Copyright 1998 Gerald Combs
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26  */
27
28 #ifndef __AIRPCAP_GUI_UTILS_H__
29 #define __AIRPCAP_GUI_UTILS_H__
30
31 #define AIRPCAP_VALIDATION_TYPE_NAME_ALL     "All Frames"
32 #define AIRPCAP_VALIDATION_TYPE_NAME_CORRECT "Valid Frames"
33 #define AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT "Invalid Frames"
34 #define AIRPCAP_VALIDATION_TYPE_NAME_UNKNOWN         "Unknown"
35
36 #define AIRPCAP_LINK_TYPE_NAME_802_11_ONLY                      "802.11 Only"
37 #define AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO        "802.11 + Radio"
38 #define AIRPCAP_LINK_TYPE_NAME_UNKNOWN                                  "Unknown"
39
40 #define AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK "Wireshark"
41 #define AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP   "AirPcap"
42 #define AIRPCAP_DECRYPTION_TYPE_STRING_NONE      "None"
43
44 #define NO_ROW_SELECTED -1
45 #define NO_COLUMN_SELECTED -1
46
47 /*
48  * This structure is used because we need to store infos about the currently selected 
49  * row in the key list. 
50  */
51 typedef struct{
52 gint row;
53 gint column;
54 }airpcap_key_ls_selected_info_t;
55
56 /*
57  * Used to retrieve a string containing a list of all the channels
58  * on which at least one adapter is capturing. This is true
59  * if the adapter passed as parameter is "Any" ... if not,
60  * this function returns the only channel number string.
61  */
62 gchar*
63 airpcap_get_all_channels_list(airpcap_if_info_t* if_info);
64
65 /*
66  * set up the airpcap toolbar for the new capture interface
67  */
68 void
69 airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info);
70
71 /*
72  * Set up the airpcap toolbar for the new capture interface
73  */
74 void
75 airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info);
76
77 /*
78  * Add a key (string) to the given list
79  */
80 void
81 airpcap_add_key_to_list(GtkWidget *keylist, gchar* type, gchar* key, gchar* ssid);
82
83 /*
84  * Modify a key given a list and a row
85  */
86 void
87 airpcap_modify_key_in_list(GtkWidget *keylist, gint row, gchar* type, gchar* key, gchar* ssid);
88
89 /*
90  * Fill the list with the keys
91  */
92 void
93 airpcap_fill_key_list(GtkWidget *keylist,airpcap_if_info_t* if_info);
94
95 /*
96  * Function used to retrieve the AirpcapValidationType given the string name.
97  */
98 AirpcapValidationType
99 airpcap_get_validation_type(const gchar* name);
100
101 /*
102  * Function used to retrieve the string name given an AirpcapValidationType.
103  */
104 gchar*
105 airpcap_get_validation_name(AirpcapValidationType vt);
106
107 /*
108  * Returns the AirpcapLinkType corresponding to the given string name.
109  */
110 AirpcapLinkType
111 airpcap_get_link_type(const gchar* name);
112
113 /*
114  * Returns the string name corresponding to the given AirpcapLinkType.
115  */
116 gchar*
117 airpcap_get_link_name(AirpcapLinkType lt);
118
119 /*
120  * Sets the entry of the link type combo using the AirpcapLinkType.
121  */
122 void
123 airpcap_link_type_combo_set_by_type(GtkWidget* c, AirpcapLinkType type);
124
125 /*
126  * Retrieves the name in link type the combo entry.
127  */
128 AirpcapLinkType
129 airpcap_link_type_combo_get_type(GtkWidget* c);
130
131 /*
132  * Sets the entry of the validation combo using the AirpcapValidationType.
133  */
134 void
135 airpcap_validation_type_combo_set_by_type(GtkWidget* c,AirpcapValidationType type);
136
137 /*
138  * Retrieves the name in the validation combo entry.
139  */
140 AirpcapValidationType
141 airpcap_validation_type_combo_get_type(GtkWidget* c);
142
143 /*
144  * Returns the string corresponding to the given UINT (1-14, for channel only)
145  */
146 UINT
147 airpcap_get_channel_number(const gchar* s);
148
149 /*
150  * Retrieve the UINT corresponding to the given string (channel only, handle with care!)
151  */
152 gchar*
153 airpcap_get_channel_name(UINT n);
154
155 /*
156  * Set the combo box entry string given an UINT channel number
157  */
158 void
159 airpcap_channel_combo_set_by_number(GtkWidget* w,UINT channel);
160
161 /*
162  * Returns '1' if this is the "Any" adapter, '0' otherwise
163  */
164 int
165 airpcap_if_is_any(airpcap_if_info_t* if_info);
166
167 /*
168  * Takes the keys from the GtkList widget, and add them to the interface list
169  */
170 void 
171 airpcap_add_keys_from_list(GtkWidget *w, airpcap_if_info_t *if_info);
172
173 /*
174  * Update channel combo box. If the airpcap interface is "Any", the combo box will be disabled.
175  */
176 void
177 airpcap_update_channel_combo(GtkWidget* w, airpcap_if_info_t* if_info);
178
179 /*
180  * This function will take the current keys (widget list), specified for the
181  * current adapter, and save them as default for ALL the others.
182  */
183 void
184 airpcap_read_and_save_decryption_keys_from_clist(GtkWidget* key_ls, airpcap_if_info_t* info_if, GList* if_list);
185
186 /*
187  * This function will load from the preferences file ALL the
188  * keys (WEP, WPA and WPA2) and will set them as default for 
189  * each adapter. To do this, it will save the keys in the registry...
190  */
191 void
192 airpcap_load_decryption_keys(GList* if_list);
193
194 /*
195  * This function will load from the preferences file ALL the
196  * keys (WEP, WPA and WPA2) and will set them as default for 
197  * each adapter. To do this, it will save the keys in the registry...
198  */
199 gboolean
200 airpcap_check_decryption_keys(GList* if_list);
201
202 /*
203  * This function will set the gibven GList of decryption_key_t structures 
204  * as the defoult for both Wireshark and the AirPcap adapters...
205  */
206 void
207 airpcap_save_decryption_keys(GList* key_list, GList* adapters_list);
208
209 #endif