Rename get_epan_and_portaudio_version_info() to get_gui_compiled_info()
[metze/wireshark/wip.git] / airpcap_loader.h
1 /* airpcap_loader.h
2  * Declarations of routines for the "About" dialog
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_LOADER_H__
29 #define __AIRPCAP_LOADER_H__
30
31 /* Error values from "get_airpcap_interface_list()". */
32 #define CANT_GET_AIRPCAP_INTERFACE_LIST 0       /* error getting list */
33 #define NO_AIRPCAP_INTERFACES_FOUND     1       /* list is empty */
34
35 #define AIRPCAP_CHANNEL_ANY_NAME "ANY"
36
37 /*
38  * WEP_KEY_MAX_SIZE is in bytes, but each byte is rapresented in strings with an ascii char
39  * 4 bit are needed to store an exadecimal number, 8 bit to store a char...
40  */
41 #define WEP_KEY_MAX_CHAR_SIZE (WEP_KEY_MAX_SIZE*2)
42
43 /*
44  * WEP_KEY_MAX_SIZE is in bytes, this is in bits...
45  */
46 #define WEP_KEY_MAX_BIT_SIZE (WEP_KEY_MAX_SIZE*8)
47
48 #define AIRPCAP_WEP_KEY_STRING  "WEP"
49 #define AIRPCAP_WPA_KEY_STRING  "WPA"
50 #define AIRPCAP_WPA2_KEY_STRING "WPA2"
51
52 typedef PCHAR (*AirpcapGetLastErrorHandler)(PAirpcapHandle AdapterHandle);
53 typedef BOOL (*AirpcapGetDeviceListHandler)(PAirpcapDeviceDescription *PPAllDevs, PCHAR Ebuf);
54 typedef VOID (*AirpcapFreeDeviceListHandler)(PAirpcapDeviceDescription PAllDevs);
55 typedef PAirpcapHandle (*AirpcapOpenHandler)(PCHAR DeviceName, PCHAR Ebuf);
56 typedef VOID (*AirpcapCloseHandler)(PAirpcapHandle AdapterHandle);
57 typedef BOOL (*AirpcapGetLinkTypeHandler)(PAirpcapHandle AdapterHandle, PAirpcapLinkType PLinkType);
58 typedef BOOL (*AirpcapSetLinkTypeHandler)(PAirpcapHandle AdapterHandle, AirpcapLinkType NewLinkType);
59 typedef BOOL (*AirpcapSetKernelBufferHandler)(PAirpcapHandle AdapterHandle, UINT BufferSize);
60 typedef BOOL (*AirpcapSetFilterHandler)(PAirpcapHandle AdapterHandle, PVOID Instructions, UINT Len);
61 typedef BOOL (*AirpcapGetMacAddressHandler)(PAirpcapHandle AdapterHandle, PAirpcapMacAddress PMacAddress);
62 typedef BOOL (*AirpcapSetMinToCopyHandler)(PAirpcapHandle AdapterHandle, UINT MinToCopy);
63 typedef BOOL (*AirpcapGetReadEventHandler)(PAirpcapHandle AdapterHandle, HANDLE* PReadEvent);
64 typedef BOOL (*AirpcapReadHandler)(PAirpcapHandle AdapterHandle, PBYTE Buffer, UINT BufSize, PUINT PReceievedBytes);
65 typedef BOOL (*AirpcapGetStatsHandler)(PAirpcapHandle AdapterHandle, PAirpcapStats PStats);
66 typedef BOOL (*AirpcapTurnLedOnHandler)(PAirpcapHandle  AdapterHandle, UINT  LedNumber);
67 typedef BOOL (*AirpcapTurnLedOffHandler)(PAirpcapHandle  AdapterHandle, UINT  LedNumber);
68 typedef BOOL (*AirpcapSetDeviceChannelHandler)(PAirpcapHandle  AdapterHandle, UINT  Channel);
69 typedef BOOL (*AirpcapGetDeviceChannelHandler)(PAirpcapHandle  AdapterHandle, PUINT PChannel);
70 typedef BOOL (*AirpcapSetFcsPresenceHandler)(PAirpcapHandle  AdapterHandle, BOOL  IsFcsPresent);
71 typedef BOOL (*AirpcapGetFcsPresenceHandler)(PAirpcapHandle  AdapterHandle, PBOOL PIsFcsPresent);
72 typedef BOOL (*AirpcapSetFcsValidationHandler)(PAirpcapHandle  AdapterHandle, AirpcapValidationType ValidationType);
73 typedef BOOL (*AirpcapGetFcsValidationHandler)(PAirpcapHandle  AdapterHandle, PAirpcapValidationType PValidationType);
74 typedef BOOL (*AirpcapSetDeviceKeysHandler)(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
75 typedef BOOL (*AirpcapGetDeviceKeysHandler)(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize);
76 typedef BOOL (*AirpcapSetDecryptionStateHandler)(PAirpcapHandle AdapterHandle, AirpcapDecryptionState Enable);
77 typedef BOOL (*AirpcapGetDecryptionStateHandler)(PAirpcapHandle AdapterHandle, PAirpcapDecryptionState PEnable);
78 typedef BOOL (*AirpcapStoreCurConfigAsAdapterDefaultHandler)(PAirpcapHandle AdapterHandle);
79 typedef VOID (*AirpcapGetVersionHandler)(PUINT VersionMajor, PUINT VersionMinor, PUINT VersionRev, PUINT VersionBuild);
80 /*
81  * The list of interfaces returned by "get_airpcap_interface_list()" is
82  * a list of these structures.
83  */
84 typedef struct {
85         char                                    *name;                          /* e.g. "eth0" */
86         char                                    *description;           /* from OS, e.g. "Local Area Connection" or NULL */
87         GSList                                  *ip_addr;                       /* containing address values of if_addr_t */
88         gboolean                                loopback;                       /* TRUE if loopback, FALSE otherwise */
89         AirpcapLinkType                 linkType;                       /* The link layer type*/
90         UINT                                    channel;                        /* Channel (1-14)*/
91         BOOL                                    IsFcsPresent;           /* Include 802.11 CRC in frames */
92         AirpcapValidationType   CrcValidationOn;        /* Capture Frames with Wrong CRC */
93         AirpcapDecryptionState  DecryptionOn;           /* TRUE if decryption is on, FALSE otherwise*/
94         PAirpcapKeysCollection  keysCollection;         /* WEP Key collection for the adapter */
95         UINT                                    keysCollectionSize;     /* Size of the key collection */
96         gboolean                                blinking;                       /* TRUE if is blinkng, FALSE otherwise*/
97         gboolean                                led;                            /* TRUE if on, FALSE if off*/
98         gboolean                                saved;                          /* TRUE if current configuration has been saved, FALSE otherwise */
99         gint                                    tag;                            /* int for the gtk blinking callback */
100 } airpcap_if_info_t;
101
102 /*
103  * Struct used to store infos to pass to the preferences manager callbacks
104  */
105 typedef struct {
106    GList *list;
107    int current_index;
108    int number_of_keys;
109 } keys_cb_data_t;
110
111 /*
112  * Struct to store infos about a specific decryption key.
113  */
114 typedef struct {
115     GString *key;
116     GString *ssid;
117     guint   bits;
118     guint   type;
119 } decryption_key_t;
120
121 /* Airpcap interface list */
122 extern GList *airpcap_if_list;
123
124 /* Airpcap current selected interface */
125 extern airpcap_if_info_t *airpcap_if_selected;
126
127 /* Airpcap current active interface */
128 extern airpcap_if_info_t *airpcap_if_active;
129
130 /* WLAN preferences pointer */
131 //extern module_t *wlan_prefs;
132
133 /*
134  * Function used to read the Decryption Keys from the preferences and store them
135  * properly into the airpcap adapter.
136  */
137 BOOL
138 load_wlan_wep_keys(airpcap_if_info_t* info_if);
139
140 /*
141  *  Function used to save to the prefereces file the Decryption Keys.
142  */
143 BOOL
144 save_wlan_wep_keys(airpcap_if_info_t* info_if);
145
146 /*
147  * This function will tell the airpcap driver the key list to use
148  * This will be stored into the registry...
149  */
150 gboolean
151 write_wlan_wep_keys_to_regitry(airpcap_if_info_t* info_if, GList* key_list);
152
153 /* Returs TRUE if the WEP key is valid, false otherwise */
154 gboolean
155 wep_key_is_valid(char* key);
156
157 /*
158  * Callback used to free an instance of airpcap_if_info_t
159  */
160 static void
161 free_airpcap_if_cb(gpointer data, gpointer user_data _U_);
162
163 /*
164  * Used to retrieve the two chars string from interface
165  */
166 gchar*
167 airpcap_get_if_string_number_from_description(gchar* description);
168
169 /*
170  * Function used to free the airpcap interface list
171  */
172 void
173 free_airpcap_interface_list(GList *if_list);
174
175 /*
176  * Used to retrieve the interface given the name
177  * (the name is used in AirpcapOpen)
178  */
179 airpcap_if_info_t* get_airpcap_if_by_name(GList* if_list, const gchar* name);
180
181 /*
182  * Airpcap wrapper, used to store the current settings for the selected adapter
183  */
184 BOOL
185 airpcap_if_store_cur_config_as_adapter_default(PAirpcapHandle ah);
186
187 /*
188  * Function used to load the WEP keys for a selected interface
189  */
190 BOOL
191 airpcap_if_load_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info);
192
193 /*
194  * Function used to save the WEP keys for a selected interface
195  */
196 void
197 airpcap_if_save_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info);
198
199 /*
200  * Airpcap wrapper, used to get the fcs validation of an airpcap adapter
201  */
202 BOOL
203 airpcap_if_get_fcs_validation(PAirpcapHandle ah, PAirpcapValidationType val);
204
205 /*
206  * Airpcap wrapper, used to set the fcs validation of an airpcap adapter
207  */
208 BOOL
209 airpcap_if_set_fcs_validation(PAirpcapHandle ah, AirpcapValidationType val);
210
211 /*
212  * Airpcap wrapper, used to get the decryption enabling of an airpcap adapter
213  */
214 BOOL
215 airpcap_if_get_decryption_state(PAirpcapHandle ah, PAirpcapDecryptionState val);
216
217 /*
218  * Airpcap wrapper, used to set the decryption enabling of an airpcap adapter
219  */
220 BOOL
221 airpcap_if_set_decryption_state(PAirpcapHandle ah, AirpcapDecryptionState val);
222
223 /*
224  * Airpcap wrapper, used to get the fcs presence of an airpcap adapter
225  */
226 BOOL
227 airpcap_if_get_fcs_presence(PAirpcapHandle ah, PBOOL ch);
228
229 /*
230  * Airpcap wrapper, used to set the fcs presence of an airpcap adapter
231  */
232 BOOL
233 airpcap_if_set_fcs_presence(PAirpcapHandle ah, BOOL ch);
234
235 /*
236  * Airpcap wrapper, used to get the link type of an airpcap adapter
237  */
238 BOOL
239 airpcap_if_get_link_type(PAirpcapHandle ah, PAirpcapLinkType lt);
240
241 /*
242  * Airpcap wrapper, used to set the link type of an airpcap adapter
243  */
244 BOOL
245 airpcap_if_set_link_type(PAirpcapHandle ah, AirpcapLinkType lt);
246
247 /*
248  * Airpcap wrapper, used to get the channel of an airpcap adapter
249  */
250 BOOL
251 airpcap_if_get_device_channel(PAirpcapHandle ah, PUINT ch);
252
253 /*
254  * Airpcap wrapper, used to set the channel of an airpcap adapter
255  */
256 BOOL
257 airpcap_if_set_device_channel(PAirpcapHandle ah, UINT ch);
258
259 /*
260  * Airpcap wrapper, used to open an airpcap adapter
261  */
262 PAirpcapHandle airpcap_if_open(PCHAR name, PCHAR err);
263
264 /*
265  * Airpcap wrapper, used to close an airpcap adapter
266  */
267 VOID airpcap_if_close(PAirpcapHandle handle);
268
269 /*
270  * Airpcap wrapper, used to turn on the led of an airpcap adapter
271  */
272 BOOL airpcap_if_turn_led_on(PAirpcapHandle AdapterHandle, UINT LedNumber);
273
274 /*
275  * Airpcap wrapper, used to turn off the led of an airpcap adapter
276  */
277 BOOL airpcap_if_turn_led_off(PAirpcapHandle AdapterHandle, UINT LedNumber);
278
279 /*
280  * This function will create a new airpcap_if_info_t using a name and a description
281  */
282 airpcap_if_info_t* airpcap_if_info_new(char *name, char *description);
283
284 /*
285  *  Used to dinamically load the airpcap library in order link it only when
286  *  it's present on the system.
287  */
288 BOOL load_airpcap(void);
289
290 /*
291  * Get an error message string for a CANT_GET_INTERFACE_LIST error from
292  * "get_airpcap_interface_list()".
293  */
294 gchar*
295 cant_get_airpcap_if_list_error_message(const char *err_str);
296
297 /*
298  * This function will use the airpcap.dll to find all the airpcap devices.
299  * Will return null if no device is found.
300  */
301 GList*
302 get_airpcap_interface_list(int *err, char *err_str);
303
304 /*
305  * Returns the ASCII string of a key given the key bites
306  */
307 gchar*
308 airpcap_get_key_string(AirpcapKey key);
309
310 /*
311  * Load the configuration for the specified interface
312  */
313 void
314 airpcap_load_selected_if_configuration(airpcap_if_info_t* if_info);
315
316 /*
317  * Save the configuration for the specified interface
318  */
319 void
320 airpcap_save_selected_if_configuration(airpcap_if_info_t* if_info);
321
322 /*
323  * Used to retrieve the name of the interface given the description
324  * (the name is used in AirpcapOpen, the description is put in the combo box)
325  */
326 gchar*
327 get_airpcap_name_from_description(GList* if_list, gchar* description);
328
329 /*
330  * Used to retrieve the airpcap_if_info_t of the selected interface given the
331  * description (that is the entry of the combo box).
332  */
333 gpointer
334 get_airpcap_if_from_description(GList* if_list, const gchar* description);
335
336 /*
337  * Used to retrieve the two chars string from interface description
338  */
339 gchar*
340 airpcap_get_if_string_number(airpcap_if_info_t* if_info);
341
342 /*
343  * Returns the default airpcap interface of a list, NULL if list is empty
344  */
345 airpcap_if_info_t*
346 airpcap_get_default_if(GList* airpcap_if_list);
347
348 /*
349  * Airpcap wrapper, used to save the settings for the selected_if
350  */
351 BOOL
352 airpcap_if_set_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
353
354 /*
355  * Airpcap wrapper, used to save the settings for the selected_if
356  */
357 BOOL
358 airpcap_if_get_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize);
359
360 /*
361  * DECRYPTION KEYS FUNCTIONS
362  */
363 /*
364  * This function is used for DEBUG PURPOSES ONLY!!!
365  */
366 void
367 print_key_list(GList* key_list);
368
369 /*
370  * Retrieves a GList of decryption_key_t structures containing infos about the
371  * keys for the given adapter... returns NULL if no keys are found.
372  */
373 GList*
374 get_airpcap_device_keys(airpcap_if_info_t* if_info);
375
376 /*
377  * Returns the list of the decryption keys specified for wireshark, NULL if
378  * no key is found
379  */
380 GList*
381 get_wireshark_keys();
382
383 /*
384  * Tests if two collection of keys are equal or not, to be considered equals, they have to
385  * contain the same keys in the SAME ORDER! (If both lists are NULL, which means empty will
386  * return TRUE)
387  */
388 gboolean
389 key_lists_are_equal(GList* list1, GList* list2);
390
391 /*
392  * Merges two lists of keys. If a key is found multiple times, it will just appear once!
393  */
394 GList*
395 merge_key_list(GList* list1, GList* list2);
396
397 /*
398  * If the given key is contained in the list, returns TRUE.
399  * Returns FALSE otherwise.
400  */
401 gboolean
402 key_is_in_list(decryption_key_t *dk,GList *list);
403
404 /*
405  * Returns TRUE if keys are equals, FALSE otherwise
406  */
407 gboolean
408 keys_are_equals(decryption_key_t *k1,decryption_key_t *k2);
409
410 /*
411  * Use this function to free a key list.
412  */
413 void
414 free_key_list(GList *list);
415
416 /*
417  * Returns TRUE if the Wireshark decryption is active, false otherwise
418  */
419 gboolean
420 wireshark_decryption_on();
421
422 /*
423  * Returns TRUE if the AirPcap decryption is active, false otherwise
424  */
425 gboolean
426 airpcap_decryption_on();
427
428 /*
429  * Enables decryption for Wireshark if on_off is TRUE, disables it otherwise.
430  */
431 void
432 set_wireshark_decryption(gboolean on_off);
433
434 /*
435  * Enables decryption for all the adapters if on_off is TRUE, disables it otherwise.
436  */
437 gboolean
438 set_airpcap_decryption(gboolean on_off);
439
440 /*
441  * Adds compiled version string to str
442  */
443 void
444 get_compiled_airpcap_version(GString *str);
445
446 void
447 get_runtime_airpcap_version(GString *str);
448
449 #endif