Get it to compile...
[obnox/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 MAX_ENCRYPTION_KEYS 64
36
37 #define AIRPCAP_CHANNEL_ANY_NAME "ANY"
38
39 /*
40  * WEP_KEY_MAX_SIZE is in bytes. but each byte is rapresented in strings with an ascii char
41  * 4 bit are needed to store an exadecimal number, 8 bit to store a char...
42  */
43 #define WEP_KEY_MAX_CHAR_SIZE (WEP_KEY_MAX_SIZE*2)
44
45 typedef PCHAR (*AirpcapGetLastErrorHandler)(PAirpcapHandle AdapterHandle);
46 typedef BOOL (*AirpcapGetDeviceListHandler)(PAirpcapDeviceDescription *PPAllDevs, PCHAR Ebuf);
47 typedef VOID (*AirpcapFreeDeviceListHandler)(PAirpcapDeviceDescription PAllDevs);
48 typedef PAirpcapHandle (*AirpcapOpenHandler)(PCHAR DeviceName, PCHAR Ebuf);
49 typedef VOID (*AirpcapCloseHandler)(PAirpcapHandle AdapterHandle);
50 typedef BOOL (*AirpcapGetLinkTypeHandler)(PAirpcapHandle AdapterHandle, PAirpcapLinkType PLinkType);
51 typedef BOOL (*AirpcapSetLinkTypeHandler)(PAirpcapHandle AdapterHandle, AirpcapLinkType NewLinkType);
52 typedef BOOL (*AirpcapSetKernelBufferHandler)(PAirpcapHandle AdapterHandle, UINT BufferSize);
53 typedef BOOL (*AirpcapSetFilterHandler)(PAirpcapHandle AdapterHandle, PVOID Instructions, UINT Len);
54 typedef BOOL (*AirpcapGetMacAddressHandler)(PAirpcapHandle AdapterHandle, PAirpcapMacAddress PMacAddress);
55 typedef BOOL (*AirpcapSetMinToCopyHandler)(PAirpcapHandle AdapterHandle, UINT MinToCopy);
56 typedef BOOL (*AirpcapGetReadEventHandler)(PAirpcapHandle AdapterHandle, HANDLE* PReadEvent);
57 typedef BOOL (*AirpcapReadHandler)(PAirpcapHandle AdapterHandle, PBYTE Buffer, UINT BufSize, PUINT PReceievedBytes);
58 typedef BOOL (*AirpcapGetStatsHandler)(PAirpcapHandle AdapterHandle, PAirpcapStats PStats);
59 typedef BOOL (*AirpcapTurnLedOnHandler)(PAirpcapHandle  AdapterHandle, UINT  LedNumber);
60 typedef BOOL (*AirpcapTurnLedOffHandler)(PAirpcapHandle  AdapterHandle, UINT  LedNumber);
61 typedef BOOL (*AirpcapSetDeviceChannelHandler)(PAirpcapHandle  AdapterHandle, UINT  Channel);
62 typedef BOOL (*AirpcapGetDeviceChannelHandler)(PAirpcapHandle  AdapterHandle, PUINT PChannel);
63 typedef BOOL (*AirpcapSetFcsPresenceHandler)(PAirpcapHandle  AdapterHandle, BOOL  IsFcsPresent);
64 typedef BOOL (*AirpcapGetFcsPresenceHandler)(PAirpcapHandle  AdapterHandle, PBOOL PIsFcsPresent);
65 typedef BOOL (*AirpcapSetFcsValidationHandler)(PAirpcapHandle  AdapterHandle, AirpcapValidationType ValidationType);
66 typedef BOOL (*AirpcapGetFcsValidationHandler)(PAirpcapHandle  AdapterHandle, PAirpcapValidationType PValidationType);
67 typedef BOOL (*AirpcapSetDeviceKeysHandler)(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
68 typedef BOOL (*AirpcapGetDeviceKeysHandler)(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize);
69 typedef BOOL (*AirpcapSetDecryptionStateHandler)(PAirpcapHandle AdapterHandle, AirpcapDecryptionState Enable);
70 typedef BOOL (*AirpcapGetDecryptionStateHandler)(PAirpcapHandle AdapterHandle, PAirpcapDecryptionState PEnable);
71 typedef BOOL (*AirpcapStoreCurConfigAsAdapterDefaultHandler)(PAirpcapHandle AdapterHandle);
72 /*
73  * The list of interfaces returned by "get_airpcap_interface_list()" is
74  * a list of these structures.
75  */
76 typedef struct {
77         char                                    *name;                          /* e.g. "eth0" */
78         char                                    *description;           /* from OS, e.g. "Local Area Connection" or NULL */
79         GSList                                  *ip_addr;                       /* containing address values of if_addr_t */
80         gboolean                                loopback;                       /* TRUE if loopback, FALSE otherwise */
81         AirpcapLinkType                 linkType;                       /* The link layer type*/
82         UINT                                    channel;                        /* Channel (1-14)*/
83         BOOL                                    IsFcsPresent;           /* Include 802.11 CRC in frames */
84         AirpcapValidationType   CrcValidationOn;        /* Capture Frames with Wrong CRC */
85         AirpcapDecryptionState  DecryptionOn;           /* TRUE if decryption is on, FALSE otherwise*/
86         PAirpcapKeysCollection  keysCollection;         /* WEP Key collection for the adapter */
87         UINT                                    keysCollectionSize;     /* Size of the key collection */
88         gboolean                                blinking;                       /* TRUE if is blinkng, FALSE otherwise*/
89         gboolean                                led;                            /* TRUE if on, FALSE if off*/
90         gboolean                                saved;                          /* TRUE if current configuration has been saved, FALSE otherwise */
91         gint                                    tag;                            /* int for the gtk blinking callback */
92 } airpcap_if_info_t;
93
94 /* Airpcap interface list */
95 extern GList *airpcap_if_list;
96
97 /* Airpcap current selected interface */
98 extern airpcap_if_info_t *airpcap_if_selected;
99
100 /* Airpcap current active interface */
101 extern airpcap_if_info_t *airpcap_if_active;
102
103 /*
104  * Callback used to free an instance of airpcap_if_info_t
105  */
106 static void
107 free_airpcap_if_cb(gpointer data, gpointer user_data _U_);
108
109 /*
110  * Used to retrieve the two chars string from interface
111  */
112 gchar*
113 airpcap_get_if_string_number_from_description(gchar* description);
114
115 /*
116  * Function used to free the airpcap interface list
117  */
118 void
119 free_airpcap_interface_list(GList *if_list);
120
121 /*
122  * Used to retrieve the interface given the name
123  * (the name is used in AirpcapOpen)
124  */
125 airpcap_if_info_t* get_airpcap_if_by_name(GList* if_list, const gchar* name);
126
127 /*
128  * Airpcap wrapper, used to store the current settings for the selected adapter
129  */
130 BOOL
131 airpcap_if_store_cur_config_as_adapter_default(PAirpcapHandle ah);
132
133 /*
134  * Function used to load the WEP keys for a selected interface
135  */
136 BOOL
137 airpcap_if_load_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info);
138
139 /*
140  * Function used to save the WEP keys for a selected interface
141  */
142 void
143 airpcap_if_save_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info);
144
145 /*
146  * Airpcap wrapper, used to get the fcs validation of an airpcap adapter
147  */
148 BOOL
149 airpcap_if_get_fcs_validation(PAirpcapHandle ah, PAirpcapValidationType val);
150
151 /*
152  * Airpcap wrapper, used to set the fcs validation of an airpcap adapter
153  */
154 BOOL
155 airpcap_if_set_fcs_validation(PAirpcapHandle ah, AirpcapValidationType val);
156
157 /*
158  * Airpcap wrapper, used to get the decryption enabling of an airpcap adapter
159  */
160 BOOL
161 airpcap_if_get_decryption_state(PAirpcapHandle ah, PAirpcapDecryptionState val);
162
163 /*
164  * Airpcap wrapper, used to set the decryption enabling of an airpcap adapter
165  */
166 BOOL
167 airpcap_if_set_decryption_state(PAirpcapHandle ah, AirpcapDecryptionState val);
168
169 /*
170  * Airpcap wrapper, used to get the fcs presence of an airpcap adapter
171  */
172 BOOL
173 airpcap_if_get_fcs_presence(PAirpcapHandle ah, PBOOL ch);
174
175 /*
176  * Airpcap wrapper, used to set the fcs presence of an airpcap adapter
177  */
178 BOOL
179 airpcap_if_set_fcs_presence(PAirpcapHandle ah, BOOL ch);
180
181 /*
182  * Airpcap wrapper, used to get the link type of an airpcap adapter
183  */
184 BOOL
185 airpcap_if_get_link_type(PAirpcapHandle ah, PAirpcapLinkType lt);
186
187 /*
188  * Airpcap wrapper, used to set the link type of an airpcap adapter
189  */
190 BOOL
191 airpcap_if_set_link_type(PAirpcapHandle ah, AirpcapLinkType lt);
192
193 /*
194  * Airpcap wrapper, used to get the channel of an airpcap adapter
195  */
196 BOOL
197 airpcap_if_get_device_channel(PAirpcapHandle ah, PUINT ch);
198
199 /*
200  * Airpcap wrapper, used to set the channel of an airpcap adapter
201  */
202 BOOL
203 airpcap_if_set_device_channel(PAirpcapHandle ah, UINT ch);
204
205 /*
206  * Airpcap wrapper, used to open an airpcap adapter
207  */
208 PAirpcapHandle airpcap_if_open(PCHAR name, PCHAR err);
209
210 /*
211  * Airpcap wrapper, used to close an airpcap adapter
212  */
213 VOID airpcap_if_close(PAirpcapHandle handle);
214
215 /*
216  * Airpcap wrapper, used to turn on the led of an airpcap adapter
217  */
218 BOOL airpcap_if_turn_led_on(PAirpcapHandle AdapterHandle, UINT LedNumber);
219
220 /*
221  * Airpcap wrapper, used to turn off the led of an airpcap adapter
222  */
223 BOOL airpcap_if_turn_led_off(PAirpcapHandle AdapterHandle, UINT LedNumber);
224
225 /*
226  * This function will create a new airpcap_if_info_t using a name and a description
227  */
228 airpcap_if_info_t* airpcap_if_info_new(char *name, char *description);
229
230 /*
231  *  Used to dinamically load the airpcap library in order link it only when
232  *  it's present on the system.
233  */
234 BOOL load_airpcap(void);
235
236 /*
237  * Get an error message string for a CANT_GET_INTERFACE_LIST error from
238  * "get_airpcap_interface_list()".
239  */
240 gchar*
241 cant_get_airpcap_if_list_error_message(const char *err_str);
242
243 /*
244  * This function will use the airpcap.dll to find all the airpcap devices.
245  * Will return null if no device is found.
246  */
247 GList*
248 get_airpcap_interface_list(int *err, char *err_str);
249
250 /*
251  * Returns the ASCII string of a key given the key bites
252  */
253 gchar*
254 airpcap_get_key_string(AirpcapKey key);
255
256 /*
257  * Load the configuration for the specified interface
258  */
259 void
260 airpcap_load_selected_if_configuration(airpcap_if_info_t* if_info);
261
262 /*
263  * Save the configuration for the specified interface
264  */
265 void
266 airpcap_save_selected_if_configuration(airpcap_if_info_t* if_info);
267
268 /*
269  * Used to retrieve the name of the interface given the description
270  * (the name is used in AirpcapOpen, the description is put in the combo box)
271  */
272 gchar*
273 get_airpcap_name_from_description(GList* if_list, gchar* description);
274
275 /*
276  * Used to retrieve the airpcap_if_info_t of the selected interface given the
277  * description (that is the entry of the combo box).
278  */
279 gpointer
280 get_airpcap_if_from_description(GList* if_list, const gchar* description);
281
282 /*
283  * Used to retrieve the two chars string from interface description
284  */
285 gchar*
286 airpcap_get_if_string_number(airpcap_if_info_t* if_info);
287
288 /*
289  * Returns the default airpcap interface of a list, NULL if list is empty
290  */
291 airpcap_if_info_t*
292 airpcap_get_default_if(GList* airpcap_if_list);
293
294 /*
295  * Airpcap wrapper, used to save the settings for the selected_if
296  */
297 BOOL
298 airpcap_if_set_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
299
300 /*
301  * Airpcap wrapper, used to save the settings for the selected_if
302  */
303 BOOL
304 airpcap_if_get_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize);
305 #endif