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