Wireshark  4.3.0
The Wireshark network protocol analyzer
airpcap_loader.h
Go to the documentation of this file.
1 
15 #ifndef __AIRPCAP_LOADER_H__
16 #define __AIRPCAP_LOADER_H__
17 
19 #include <wsutil/feature_list.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /* Error values from "get_airpcap_interface_list()". */
26 #define CANT_GET_AIRPCAP_INTERFACE_LIST 0 /* error getting list */
27 #define NO_AIRPCAP_INTERFACES_FOUND 1 /* list is empty */
28 #define AIRPCAP_NOT_LOADED 2 /* Airpcap DLL not loaded */
29 
30 #define AIRPCAP_CHANNEL_ANY_NAME "ANY"
31 
32 #define AIRPCAP_WEP_KEY_STRING "WEP"
33 /*
34  * XXX - WPA_PWD is the passphrase+ssid and WPA-PSK is the hexadecimal key
35  */
36 #define AIRPCAP_WPA_PWD_KEY_STRING "WPA-PWD"
37 #define AIRPCAP_WPA_BIN_KEY_STRING "WPA-PSK"
38 
39 #define AIRPCAP_DLL_OK 0
40 #define AIRPCAP_DLL_OLD 1
41 #define AIRPCAP_DLL_ERROR 2
42 #define AIRPCAP_DLL_NOT_FOUND 3
43 
44 /* #define AIRPCAP_DEBUG 1 */
45 
46 typedef char * (*AirpcapGetLastErrorHandler)(PAirpcapHandle AdapterHandle);
47 typedef bool (*AirpcapGetDeviceListHandler)(PAirpcapDeviceDescription *PPAllDevs, char * Ebuf);
48 typedef void (*AirpcapFreeDeviceListHandler)(PAirpcapDeviceDescription PAllDevs);
49 typedef PAirpcapHandle (*AirpcapOpenHandler)(char * DeviceName, char * Ebuf);
50 typedef void (*AirpcapCloseHandler)(PAirpcapHandle AdapterHandle);
51 typedef bool (*AirpcapGetLinkTypeHandler)(PAirpcapHandle AdapterHandle, PAirpcapLinkType PLinkType);
52 typedef bool (*AirpcapSetLinkTypeHandler)(PAirpcapHandle AdapterHandle, AirpcapLinkType NewLinkType);
53 typedef bool (*AirpcapSetKernelBufferHandler)(PAirpcapHandle AdapterHandle, unsigned BufferSize);
54 typedef bool (*AirpcapSetFilterHandler)(PAirpcapHandle AdapterHandle, void * Instructions, unsigned Len);
55 typedef bool (*AirpcapGetMacAddressHandler)(PAirpcapHandle AdapterHandle, PAirpcapMacAddress PMacAddress);
56 typedef bool (*AirpcapSetMinToCopyHandler)(PAirpcapHandle AdapterHandle, unsigned MinToCopy);
57 typedef bool (*AirpcapGetReadEventHandler)(PAirpcapHandle AdapterHandle, void *** PReadEvent);
58 typedef bool (*AirpcapReadHandler)(PAirpcapHandle AdapterHandle, uint8_t * Buffer, unsigned BufSize, unsigned * PReceievedBytes);
59 typedef bool (*AirpcapGetStatsHandler)(PAirpcapHandle AdapterHandle, PAirpcapStats PStats);
60 typedef bool (*AirpcapTurnLedOnHandler)(PAirpcapHandle AdapterHandle, unsigned LedNumber);
61 typedef bool (*AirpcapTurnLedOffHandler)(PAirpcapHandle AdapterHandle, unsigned LedNumber);
62 typedef bool (*AirpcapSetDeviceChannelHandler)(PAirpcapHandle AdapterHandle, unsigned Channel);
63 typedef bool (*AirpcapGetDeviceChannelHandler)(PAirpcapHandle AdapterHandle, unsigned * PChannel);
64 typedef bool (*AirpcapSetFcsPresenceHandler)(PAirpcapHandle AdapterHandle, bool IsFcsPresent);
65 typedef bool (*AirpcapGetFcsPresenceHandler)(PAirpcapHandle AdapterHandle, bool * PIsFcsPresent);
66 typedef bool (*AirpcapSetFcsValidationHandler)(PAirpcapHandle AdapterHandle, AirpcapValidationType ValidationType);
67 typedef bool (*AirpcapGetFcsValidationHandler)(PAirpcapHandle AdapterHandle, PAirpcapValidationType PValidationType);
68 typedef bool (*AirpcapSetDeviceKeysHandler)(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
69 typedef bool (*AirpcapGetDeviceKeysHandler)(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, unsigned * PKeysCollectionSize);
70 typedef bool (*AirpcapSetDriverKeysHandler)(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
71 typedef bool (*AirpcapGetDriverKeysHandler)(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, unsigned * PKeysCollectionSize);
72 typedef bool (*AirpcapSetDecryptionStateHandler)(PAirpcapHandle AdapterHandle, AirpcapDecryptionState Enable);
73 typedef bool (*AirpcapGetDecryptionStateHandler)(PAirpcapHandle AdapterHandle, PAirpcapDecryptionState PEnable);
74 typedef bool (*AirpcapSetDriverDecryptionStateHandler)(PAirpcapHandle AdapterHandle, AirpcapDecryptionState Enable);
75 typedef bool (*AirpcapGetDriverDecryptionStateHandler)(PAirpcapHandle AdapterHandle, PAirpcapDecryptionState PEnable);
76 typedef bool (*AirpcapStoreCurConfigAsAdapterDefaultHandler)(PAirpcapHandle AdapterHandle);
77 typedef void (*AirpcapGetVersionHandler)(unsigned * VersionMajor, unsigned * VersionMinor, unsigned * VersionRev, unsigned * VersionBuild);
78 typedef bool (*AirpcapSetDeviceChannelExHandler)(PAirpcapHandle AdapterHandle, AirpcapChannelInfo ChannelInfo);
79 typedef bool (*AirpcapGetDeviceChannelExHandler)(PAirpcapHandle AdapterHandle, PAirpcapChannelInfo PChannelInfo);
80 typedef bool (*AirpcapGetDeviceSupportedChannelsHandler)(PAirpcapHandle AdapterHandle, AirpcapChannelInfo **ppChannelInfo, uint32_t * pNumChannelInfo);
81 
82 #define FLAG_CAN_BE_LOW 0x00000001
83 #define FLAG_CAN_BE_HIGH 0x00000002
84 #define FLAG_IS_BG_CHANNEL 0x00000004
85 #define FLAG_IS_A_CHANNEL 0x00000008
86 
87 typedef struct _Dot11Channel
88 {
89  unsigned Channel;
90  uint32_t Frequency;
91  uint32_t Flags;
92 } Dot11Channel;
93 
94 /*
95  * The list of interfaces returned by "get_airpcap_interface_list()" is
96  * a list of these structures.
97  */
98 typedef struct {
99  char *name; /* e.g. "eth0" */
100  char *description; /* from OS, e.g. "Local Area Connection" or NULL */
101  GSList *ip_addr; /* containing address values of if_addr_t */
102  bool loopback; /* true if loopback, false otherwise */
103  AirpcapLinkType linkType; /* The link layer type */
104  AirpcapChannelInfo channelInfo; /* Channel Information */
105  bool IsFcsPresent; /* Include 802.11 CRC in frames */
106  AirpcapValidationType CrcValidationOn; /* Capture Frames with Wrong CRC */
107  AirpcapDecryptionState DecryptionOn; /* true if decryption is on, false otherwise */
108  PAirpcapKeysCollection keysCollection; /* WEP Key collection for the adapter */
109  unsigned keysCollectionSize; /* Size of the key collection */
110  bool blinking; /* true if is blinkng, false otherwise */
111  bool led; /* true if on, false if off */
112  bool saved; /* true if current configuration has been saved, false otherwise */
113  int tag; /* int for the gtk blinking callback */
114  Dot11Channel *pSupportedChannels;
115  uint32_t numSupportedChannels;
117 
118 /*
119  * Struct used to store infos to pass to the preferences manager callbacks
120  */
121 typedef struct {
122  GList *list;
123  int current_index;
124  int number_of_keys;
126 
127 /* Airpcap interface list */
128 extern GList *g_airpcap_if_list;
129 
130 /* Airpcap current selected interface */
131 extern airpcap_if_info_t *airpcap_if_selected;
132 
133 /* Airpcap current active interface */
134 extern airpcap_if_info_t *airpcap_if_active;
135 
136 #ifdef AIRPCAP_DEBUG
137 /*
138  * USED FOR DEBUG ONLY... PRINTS AN AirPcap ADAPTER STRUCTURE in a fancy way.
139  */
140 void
141 airpcap_if_info_print(airpcap_if_info_t* if_info);
142 #endif
143 
144 /*
145  * Used to retrieve the two chars string from interface
146  */
147 char*
148 airpcap_get_if_string_number_from_description(char* description);
149 
150 /*
151  * Function used to free the airpcap interface list
152  */
153 void
154 free_airpcap_interface_list(GList *if_list);
155 
156 /*
157  * Used to retrieve the interface given the name
158  * (the name is used in AirpcapOpen).
159  */
160 airpcap_if_info_t* get_airpcap_if_from_name(GList* if_list, const char* name);
161 
162 /*
163  * Airpcap wrapper, used to store the current settings for the selected adapter
164  */
165 bool
166 airpcap_if_store_cur_config_as_adapter_default(PAirpcapHandle ah);
167 
168 /*
169  * Function used to load the WEP keys for a selected interface
170  */
171 bool
172 airpcap_if_load_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info);
173 
174 /*
175  * Function used to load the WEP keys from the global driver list
176  */
177 bool
178 airpcap_if_load_driver_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info);
179 
180 /*
181  * Function used to save the WEP keys for a selected interface
182  */
183 void
184 airpcap_if_save_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info);
185 
186 /*
187  * Function used to save the WEP keys for a selected interface
188  */
189 void
190 airpcap_if_save_driver_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info);
191 
192 /*
193  * Airpcap wrapper, used to get the fcs validation of an airpcap adapter
194  */
195 bool
196 airpcap_if_get_fcs_validation(PAirpcapHandle ah, PAirpcapValidationType val);
197 
198 /*
199  * Airpcap wrapper, used to set the fcs validation of an airpcap adapter
200  */
201 bool
202 airpcap_if_set_fcs_validation(PAirpcapHandle ah, AirpcapValidationType val);
203 
204 /* Many of these are GTK+ only. */
205 /*
206  * Airpcap wrapper, used to get the decryption enabling of an airpcap adapter
207  */
208 bool
209 airpcap_if_get_decryption_state(PAirpcapHandle ah, PAirpcapDecryptionState val);
210 
211 /*
212  * Airpcap wrapper, used to set the decryption enabling of an airpcap adapter
213  */
214 bool
215 airpcap_if_set_decryption_state(PAirpcapHandle ah, AirpcapDecryptionState val);
216 
217 /*
218  * Airpcap wrapper, used to get the fcs presence of an airpcap adapter
219  */
220 bool
221 airpcap_if_get_fcs_presence(PAirpcapHandle ah, bool * ch);
222 
223 /*
224  * Airpcap wrapper, used to set the fcs presence of an airpcap adapter
225  */
226 bool
227 airpcap_if_set_fcs_presence(PAirpcapHandle ah, bool ch);
228 
229 /*
230  * Airpcap wrapper, used to get the link type of an airpcap adapter
231  */
232 bool
233 airpcap_if_get_link_type(PAirpcapHandle ah, PAirpcapLinkType lt);
234 
235 /*
236  * Airpcap wrapper, used to set the link type of an airpcap adapter
237  */
238 bool
239 airpcap_if_set_link_type(PAirpcapHandle ah, AirpcapLinkType lt);
240 
241 /*
242  * Airpcap wrapper, used to get the channel of an airpcap adapter
243  */
244 bool
245 airpcap_if_get_device_channel(PAirpcapHandle ah, unsigned * ch);
246 
247 /*
248  * Airpcap wrapper, get the channels supported by the adapter
249  */
250 bool
251 airpcap_if_get_device_supported_channels(PAirpcapHandle ah, AirpcapChannelInfo **cInfo, uint32_t * nInfo);
252 
253 /*
254  * Airpcap wrapper, get supported channels formatted into an array
255  */
257 airpcap_if_get_device_supported_channels_array(PAirpcapHandle ah, uint32_t * pNumSupportedChannels);
258 
259 /*
260  * Airpcap wrapper, used to set the channel of an airpcap adapter
261  */
262 bool
263 airpcap_if_set_device_channel(PAirpcapHandle ah, unsigned ch);
264 
265 /*
266  * Airpcap wrapper, used to get the frequency of an airpcap adapter
267  */
268 bool
269 airpcap_if_get_device_channel_ex(PAirpcapHandle ah, PAirpcapChannelInfo pChannelInfo);
270 
271 /*
272  * Airpcap wrapper, used to set the frequency of an airpcap adapter
273  */
274 bool
275 airpcap_if_set_device_channel_ex(PAirpcapHandle ah, AirpcapChannelInfo ChannelInfo);
276 
277 /*
278  * Airpcap wrapper, used to open an airpcap adapter
279  */
280 PAirpcapHandle airpcap_if_open(char * name, char * err);
281 
282 /*
283  * Airpcap wrapper, used to close an airpcap adapter
284  */
285 void airpcap_if_close(PAirpcapHandle handle);
286 
287 /*
288  * Retrieve the state of the Airpcap DLL
289  */
290 int
291 airpcap_get_dll_state(void);
292 
293 /*
294  * Airpcap wrapper, used to turn on the led of an airpcap adapter
295  */
296 bool airpcap_if_turn_led_on(PAirpcapHandle AdapterHandle, unsigned LedNumber);
297 
298 /*
299  * Airpcap wrapper, used to turn off the led of an airpcap adapter
300  */
301 bool airpcap_if_turn_led_off(PAirpcapHandle AdapterHandle, unsigned LedNumber);
302 
303 /*
304  * This function will create a new airpcap_if_info_t using a name and a description
305  */
306 airpcap_if_info_t* airpcap_if_info_new(char *name, char *description);
307 
308 /*
309  * This function will create a new fake drivers' interface, to load global keys...
310  */
311 airpcap_if_info_t* airpcap_driver_fake_if_info_new(void);
312 
313 /*
314  * Used to dinamically load the airpcap library in order link it only when
315  * it's present on the system.
316  */
317 int load_airpcap(void);
318 
319 /*
320  * This function will use the airpcap.dll to find all the airpcap devices.
321  * Will return null if no device is found.
322  */
323 GList* get_airpcap_interface_list(int *err, char **err_str);
324 
325 /*
326  * Load the configuration for the specified interface
327  */
328 void
329 airpcap_load_selected_if_configuration(airpcap_if_info_t* if_info);
330 
331 /*
332  * Save the configuration for the specified interface
333  */
334 void
335 airpcap_save_selected_if_configuration(airpcap_if_info_t* if_info);
336 
337 /*
338  * Used to retrieve the two chars string from interface description
339  */
340 char*
341 airpcap_get_if_string_number(airpcap_if_info_t* if_info);
342 
343 /*
344  * Airpcap wrapper, used to save the settings for the selected_if
345  */
346 bool
347 airpcap_if_set_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
348 
349 /*
350  * Airpcap wrapper, used to save the settings for the selected_if
351  */
352 bool
353 airpcap_if_get_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, unsigned * PKeysCollectionSize);
354 
355 /*
356  * Airpcap wrapper, used to save the settings for the selected_if
357  */
358 bool
359 airpcap_if_set_driver_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection);
360 
361 /*
362  * Airpcap wrapper, used to save the settings for the selected_if
363  */
364 bool
365 airpcap_if_get_driver_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, unsigned * PKeysCollectionSize);
366 
367 /*
368  * Airpcap wrapper, used to get the decryption enabling of an airpcap driver
369  */
370 bool
371 airpcap_if_get_driver_decryption_state(PAirpcapHandle ah, PAirpcapDecryptionState PEnable);
372 /*
373  * Airpcap wrapper, used to set the decryption enabling of an airpcap driver
374  */
375 bool
376 airpcap_if_set_driver_decryption_state(PAirpcapHandle ah, AirpcapDecryptionState Enable);
377 
378 /*
379  * Save the configuration for the specified interface
380  */
381 void
382 airpcap_save_driver_if_configuration(airpcap_if_info_t* fake_if_info);
383 
384 /*
385  * Free an instance of airpcap_if_info_t
386  */
387 void
388 airpcap_if_info_free(airpcap_if_info_t *if_info);
389 
390 /*
391  * Clear keys and decryption status for the specified interface
392  */
393 void
394 airpcap_if_clear_decryption_settings(airpcap_if_info_t* info_if);
395 
396 /*
397  * Adds compiled version string to str
398  */
399 void
400 gather_airpcap_compile_info(feature_list l);
401 
402 void
403 gather_airpcap_runtime_info(feature_list l);
404 
405 #ifdef __cplusplus
406 }
407 #endif
408 
409 #endif /* __AIRPCAP_LOADER_H__ */
enum _AirpcapLinkType AirpcapLinkType
Link type. AirPcap supports two kind of 802.11 linktypes: plain 802.11 and radiotap.
enum _AirpcapDecryptionState AirpcapDecryptionState
Type of decryption the adapter performs. An adapter can be instructed to turn decryption (based on th...
enum _AirpcapValidationType AirpcapValidationType
Type of frame validation the adapter performs. An adapter can be instructed to accept different kind ...
Channel information. Used by AirpcapSetDeviceChannelEx(), AirpcapGetDeviceChannelEx(),...
Definition: airpcap.h:259
Entry in the list returned by AirpcapGetDeviceList();.
Definition: airpcap.h:69
This structure is used to store a collection of WEP keys. Note that the definition of the structure h...
Definition: airpcap.h:174
Storage for a MAC address.
Definition: airpcap.h:145
Capture statistics. Returned by AirpcapGetStats();.
Definition: airpcap.h:242
Definition: airpcap_loader.h:88
Definition: buffer.h:22
Definition: airpcap_loader.h:98
Definition: iptrace.c:57
Definition: airpcap_loader.h:121