remove obsolete "HAVE_AIRPCAP_API" comment
[metze/wireshark/wip.git] / airpcap_loader.c
1 /* airpcap_loader.c
2  *
3  * $Id$
4  *
5  * Giorgio Tino <giorgio.tino@cacetech.com>
6  * Copyright (c) CACE Technologies, LLC 2006
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 2000 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef _WIN32
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #ifdef HAVE_LIBPCAP
34 #include <glib.h>
35 #include <gmodule.h>
36
37
38 #include <wtap.h>
39 #include <pcap.h>
40 #endif
41
42 #include "capture_ui_utils.h"
43 #include <epan/prefs.h>
44
45 #include "simple_dialog.h"
46
47 #include <airpcap.h>
48 #include "airpcap_loader.h"
49
50 /*
51  * We load dinamically the dag library in order link it only when
52  * it's present on the system
53  */
54 static HMODULE AirpcapLib;
55
56 static AirpcapGetLastErrorHandler g_PAirpcapGetLastError;
57 static AirpcapGetDeviceListHandler g_PAirpcapGetDeviceList;
58 static AirpcapFreeDeviceListHandler g_PAirpcapFreeDeviceList;
59 static AirpcapOpenHandler g_PAirpcapOpen;
60 static AirpcapCloseHandler g_PAirpcapClose;
61 static AirpcapGetLinkTypeHandler g_PAirpcapGetLinkType;
62 static AirpcapSetLinkTypeHandler g_PAirpcapSetLinkType;
63 static AirpcapSetKernelBufferHandler g_PAirpcapSetKernelBuffer;
64 static AirpcapSetFilterHandler g_PAirpcapSetFilter;
65 static AirpcapGetMacAddressHandler g_PAirpcapGetMacAddress;
66 static AirpcapSetMinToCopyHandler g_PAirpcapSetMinToCopy;
67 static AirpcapGetReadEventHandler g_PAirpcapGetReadEvent;
68 static AirpcapReadHandler g_PAirpcapRead;
69 static AirpcapGetStatsHandler g_PAirpcapGetStats;
70 static AirpcapTurnLedOnHandler g_PAirpcapTurnLedOn;
71 static AirpcapTurnLedOffHandler g_PAirpcapTurnLedOff;
72 static AirpcapGetDeviceChannelHandler g_PAirpcapGetDeviceChannel;
73 static AirpcapSetDeviceChannelHandler g_PAirpcapSetDeviceChannel;
74 static AirpcapGetFcsPresenceHandler g_PAirpcapGetFcsPresence;
75 static AirpcapSetFcsPresenceHandler g_PAirpcapSetFcsPresence;
76 static AirpcapGetFcsValidationHandler g_PAirpcapGetFcsValidation;
77 static AirpcapSetFcsValidationHandler g_PAirpcapSetFcsValidation;
78 static AirpcapGetDeviceKeysHandler g_PAirpcapGetDeviceKeys;
79 static AirpcapSetDeviceKeysHandler g_PAirpcapSetDeviceKeys;
80 static AirpcapGetDecryptionStateHandler g_PAirpcapGetDecryptionState;
81 static AirpcapSetDecryptionStateHandler g_PAirpcapSetDecryptionState;
82 static AirpcapStoreCurConfigAsAdapterDefaultHandler g_PAirpcapStoreCurConfigAsAdapterDefault;
83
84 /* Airpcap interface list */
85 GList *airpcap_if_list = NULL;
86
87 /* Airpcap current selected interface */
88 airpcap_if_info_t *airpcap_if_selected = NULL;
89
90 /* Airpcap current active interface */
91 airpcap_if_info_t *airpcap_if_active = NULL;
92
93 /*
94  * Get an error message string for a CANT_GET_INTERFACE_LIST error from
95  * "get_airpcap_interface_list()".
96  */
97 gchar *
98 cant_get_airpcap_if_list_error_message(const char *err_str)
99 {
100         return g_strdup_printf("Can't get list of Wireless interfaces: %s", err_str);
101 }
102
103 /*
104  * Airpcap wrapper, used to store the current settings for the selected adapter
105  */
106 BOOL
107 airpcap_if_store_cur_config_as_adapter_default(PAirpcapHandle ah)
108 {
109         return g_PAirpcapStoreCurConfigAsAdapterDefault(ah);
110 }
111
112 /*
113  * Airpcap wrapper, used to open an airpcap adapter
114  */
115 PAirpcapHandle
116 airpcap_if_open(PCHAR name, PCHAR err)
117 {
118         return g_PAirpcapOpen(name,err);
119 }
120
121 /*
122  * Airpcap wrapper, used to close an airpcap adapter
123  */
124 VOID
125 airpcap_if_close(PAirpcapHandle handle)
126 {
127 g_PAirpcapClose(handle);
128
129 }
130
131 /*
132  * Airpcap wrapper, used to turn on the led of an airpcap adapter
133  */
134 BOOL
135 airpcap_if_turn_led_on(PAirpcapHandle AdapterHandle, UINT LedNumber)
136 {
137         return g_PAirpcapTurnLedOn(AdapterHandle,LedNumber);
138 }
139
140 /*
141  * Airpcap wrapper, used to turn off the led of an airpcap adapter
142  */
143 BOOL
144 airpcap_if_turn_led_off(PAirpcapHandle AdapterHandle, UINT LedNumber)
145 {
146         return g_PAirpcapTurnLedOff(AdapterHandle,LedNumber);
147 }
148
149 /*
150  * Airpcap wrapper, used to get the channel of an airpcap adapter
151  */
152 BOOL
153 airpcap_if_get_device_channel(PAirpcapHandle ah, PUINT ch)
154 {
155         return g_PAirpcapGetDeviceChannel(ah,ch);
156 }
157
158 /*
159  * Airpcap wrapper, used to set the channel of an airpcap adapter
160  */
161 BOOL
162 airpcap_if_set_device_channel(PAirpcapHandle ah, UINT ch)
163 {
164         return g_PAirpcapSetDeviceChannel(ah,ch);
165 }
166
167 /*
168  * Airpcap wrapper, used to get the link type of an airpcap adapter
169  */
170 BOOL
171 airpcap_if_get_link_type(PAirpcapHandle ah, PAirpcapLinkType lt)
172 {
173         return g_PAirpcapGetLinkType(ah,lt);
174 }
175
176 /*
177  * Airpcap wrapper, used to set the link type of an airpcap adapter
178  */
179 BOOL
180 airpcap_if_set_link_type(PAirpcapHandle ah, AirpcapLinkType lt)
181 {
182         return g_PAirpcapSetLinkType(ah,lt);
183 }
184
185 /*
186  * Airpcap wrapper, used to get the fcs presence of an airpcap adapter
187  */
188 BOOL
189 airpcap_if_get_fcs_presence(PAirpcapHandle ah, PBOOL fcs)
190 {
191         return g_PAirpcapGetFcsPresence(ah,fcs);
192 }
193
194 /*
195  * Airpcap wrapper, used to set the fcs presence of an airpcap adapter
196  */
197 BOOL
198 airpcap_if_set_fcs_presence(PAirpcapHandle ah, BOOL fcs)
199 {
200         return g_PAirpcapSetFcsPresence(ah,fcs);
201 }
202
203 /*
204  * Airpcap wrapper, used to get the decryption enabling of an airpcap adapter
205  */
206 BOOL
207 airpcap_if_get_decryption_state(PAirpcapHandle ah, PAirpcapDecryptionState PEnable)
208 {
209         return g_PAirpcapGetDecryptionState(ah,PEnable);
210 }
211
212 /*
213  * Airpcap wrapper, used to set the decryption enabling of an airpcap adapter
214  */
215 BOOL
216 airpcap_if_set_decryption_state(PAirpcapHandle ah, AirpcapDecryptionState Enable)
217 {
218         return g_PAirpcapSetDecryptionState(ah,Enable);
219 }
220
221 /*
222  * Airpcap wrapper, used to get the fcs validation of an airpcap adapter
223  */
224 BOOL
225 airpcap_if_get_fcs_validation(PAirpcapHandle ah, PAirpcapValidationType val)
226 {
227         return g_PAirpcapGetFcsValidation(ah,val);
228 }
229
230 /*
231  * Airpcap wrapper, used to set the fcs validation of an airpcap adapter
232  */
233 BOOL
234 airpcap_if_set_fcs_validation(PAirpcapHandle ah, AirpcapValidationType val)
235 {
236         return g_PAirpcapSetFcsValidation(ah,val);
237 }
238
239 /*
240  * Airpcap wrapper, used to save the settings for the selected_if
241  */
242 BOOL
243 airpcap_if_set_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection)
244 {
245         return g_PAirpcapSetDeviceKeys(AdapterHandle,KeysCollection);
246 }
247
248 /*
249  * Airpcap wrapper, used to save the settings for the selected_if
250  */
251 BOOL
252 airpcap_if_get_device_keys(PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize)
253 {
254         return g_PAirpcapGetDeviceKeys(AdapterHandle,KeysCollection,PKeysCollectionSize);
255 }
256
257 /*
258  * This function will create a new airpcap_if_info_t using a name and a description
259  */
260 airpcap_if_info_t *
261 airpcap_if_info_new(char *name, char *description)
262 {
263 PAirpcapHandle ad;
264 char* ebuf = NULL;
265
266         airpcap_if_info_t *if_info;
267
268         if_info = g_malloc(sizeof (airpcap_if_info_t));
269         if_info->name = g_strdup(name);
270         if (description == NULL)
271                 if_info->description = NULL;
272         else
273                 if_info->description = g_strdup(description);
274         if_info->ip_addr = NULL;
275         if_info->loopback = FALSE;
276
277         /* Probably I have to switch on the leds!!! */
278         ad = airpcap_if_open(if_info->name, ebuf);
279         if(ad)
280                 {
281                 airpcap_if_get_fcs_validation(ad,&(if_info->CrcValidationOn));
282                 airpcap_if_get_fcs_presence(ad,&(if_info->IsFcsPresent));
283                 airpcap_if_get_link_type(ad,&(if_info->linkType));
284                 airpcap_if_get_device_channel(ad,&(if_info->channel));
285                 airpcap_if_turn_led_on(ad, 0);
286                 airpcap_if_get_decryption_state(ad, &(if_info->DecryptionOn));
287                 if_info->led = TRUE;
288                 if_info->blinking = FALSE;
289                 if_info->saved = TRUE; /* NO NEED TO BE SAVED */
290
291                 /* get the keys, if everything is ok, close the adapter */
292                 if(airpcap_if_load_keys(ad,if_info))
293                         airpcap_if_close(ad);
294                 }
295         return if_info;
296 }
297
298 /*
299  * Function used to load the WEP keys for a selected interface
300  */
301 BOOL
302 airpcap_if_load_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info)
303 {
304 if_info->keysCollectionSize = 0;
305 if_info->keysCollection = NULL;
306
307 if(!airpcap_if_get_device_keys(ad, NULL, &(if_info->keysCollectionSize)))
308         {
309         if(if_info->keysCollectionSize == 0)
310                 {
311                 if_info->keysCollection = NULL;
312                 airpcap_if_close(ad);
313                 return FALSE;
314                 }
315
316         if_info->keysCollection = (PAirpcapKeysCollection)malloc(if_info->keysCollectionSize);
317         if(!if_info->keysCollection)
318                 {
319                 if_info->keysCollectionSize = 0;
320                 if_info->keysCollection = NULL;
321                 airpcap_if_close(ad);
322                 return FALSE;
323                 }
324
325         airpcap_if_get_device_keys(ad, if_info->keysCollection, &(if_info->keysCollectionSize));
326         return TRUE;
327         }
328 airpcap_if_close(ad);
329 return FALSE;
330 }
331
332 /*
333  * Function used to save the WEP keys for a selected interface
334  */
335 void
336 airpcap_if_save_keys(PAirpcapHandle ad, airpcap_if_info_t *if_info)
337 {
338         if(if_info->keysCollection != NULL)
339                 g_PAirpcapSetDeviceKeys(ad,if_info->keysCollection);
340 }
341
342 /*
343  * Callback used to free an instance of airpcap_if_info_t
344  */
345 static void
346 free_airpcap_if_cb(gpointer data, gpointer user_data _U_)
347 {
348         airpcap_if_info_t *if_info = data;
349
350         if (if_info->name != NULL)
351                 g_free(if_info->name);
352
353         if (if_info->description != NULL)
354                 g_free(if_info->description);
355
356         /* XXX - FREE THE WEP KEY LIST HERE!!!*/
357         if(if_info->keysCollection != NULL)
358                 g_free(if_info->keysCollection);
359
360         if(if_info->ip_addr != NULL)
361                 g_slist_free(if_info->ip_addr);
362
363         if(if_info != NULL)
364                 g_free(if_info);
365 }
366
367 /*
368  * Function used to free the airpcap interface list
369  */
370 void
371 free_airpcap_interface_list(GList *if_list)
372 {
373         g_list_foreach(if_list, free_airpcap_if_cb, NULL);
374         g_list_free(if_list);
375         if_list = NULL;
376 }
377
378 /*
379  * This function will use the airpcap.dll to find all the airpcap devices.
380  * Will return null if no device is found.
381  */
382 GList*
383 get_airpcap_interface_list(int *err, char *err_str)
384 {
385         GList  *il = NULL;
386         airpcap_if_info_t *if_info;
387         int i, n_adapts;
388     AirpcapDeviceDescription *devsList, *adListEntry;
389
390         if(!g_PAirpcapGetDeviceList(&devsList, err_str))
391         {
392                 /* No interfaces, return il = NULL; */
393                 *err = NO_AIRPCAP_INTERFACES_FOUND;
394                 return il;
395         }
396
397         /*
398          * Count the adapters
399          */
400         adListEntry = devsList;
401         n_adapts = 0;
402         while(adListEntry)
403         {
404                 n_adapts++;
405                 adListEntry = adListEntry->next;
406         }
407
408         if(n_adapts == 0)
409         {
410                 /* No interfaces, return il= NULL */
411                 g_PAirpcapFreeDeviceList(devsList);
412                 *err = NO_AIRPCAP_INTERFACES_FOUND;
413                 return il;
414         }
415
416         /*
417          * Insert the adapters in our list
418          */
419         adListEntry = devsList;
420         for(i = 0; i < n_adapts; i++)
421         {
422                 if_info = airpcap_if_info_new(adListEntry->Name, adListEntry->Description);
423         il = g_list_append(il, if_info);
424
425                 adListEntry = adListEntry->next;
426         }
427
428         g_PAirpcapFreeDeviceList(devsList);
429
430         return il;
431 }
432
433 /*
434  * Used to retrieve the name of the interface given the description
435  * (the name is used in AirpcapOpen, the description is put in the combo box)
436  */
437 gchar* get_airpcap_name_from_description(GList* if_list, gchar* description)
438 {
439 unsigned int ifn;
440 GList* curr;
441 airpcap_if_info_t* if_info;
442
443 ifn = 0;
444 if(if_list != NULL)
445         {
446         while( ifn < g_list_length(if_list) )
447                 {
448                 curr = g_list_nth(if_list, ifn);
449
450                 if_info = NULL;
451                 if(curr != NULL)
452                         if_info = curr->data;
453                 if(if_info != NULL)
454                         if ( g_ascii_strcasecmp(if_info->description,description) == 0)
455                                 {
456                                 return if_info->name;
457                                 }
458                 ifn++;
459                 }
460         }
461 return NULL;
462 }
463
464 /*
465  * Used to retrieve the interface given the name
466  * (the name is used in AirpcapOpen)
467  */
468 airpcap_if_info_t* get_airpcap_if_by_name(GList* if_list, const gchar* name)
469 {
470 unsigned int ifn;
471 GList* curr;
472 airpcap_if_info_t* if_info;
473
474 ifn = 0;
475 if(if_list != NULL)
476         {
477         while( ifn < g_list_length(if_list) )
478                 {
479                 curr = g_list_nth(if_list, ifn);
480
481                 if_info = NULL;
482                 if(curr != NULL)
483                         if_info = curr->data;
484                 if(if_info != NULL)
485                         if ( g_ascii_strcasecmp(if_info->name,name) == 0)
486                                 {
487                                 return if_info;
488                                 }
489                 ifn++;
490                 }
491         }
492 return NULL;
493 }
494
495 /*
496  * Returns the ASCII string of a key given the key bites
497  */
498 gchar*
499 airpcap_get_key_string(AirpcapKey key)
500 {
501 unsigned int j = 0;
502 gchar *s,*s1;
503
504 s = NULL;
505 s1 = NULL;
506
507 if(key.KeyType == AIRPCAP_KEYTYPE_WEP)
508         {
509         s = g_strdup_printf("");
510         for(j = 0; j < key.KeyLen != 0; j++)
511                 {
512                 s1 = g_strdup_printf("%.2x", key.KeyData[j]);
513                 g_strlcat(s,s1,WEP_KEY_MAX_SIZE);
514                 }
515         }
516 return s;
517 }
518
519 /*
520  * Used to retrieve the airpcap_if_info_t of the selected interface given the
521  * description (that is the entry of the combo box).
522  */
523 gpointer get_airpcap_if_from_description(GList* if_list, const gchar* description)
524 {
525 unsigned int ifn;
526 GList* curr;
527 airpcap_if_info_t* if_info;
528
529 ifn = 0;
530 if(if_list != NULL)
531         {
532         while( ifn < g_list_length(if_list) )
533                 {
534                 curr = g_list_nth(if_list, ifn);
535
536                 if_info = NULL;
537                 if(curr != NULL)
538                         if_info = curr->data;
539                 if(if_info != NULL)
540                         if ( g_ascii_strcasecmp(if_info->description,description) == 0)
541                                 {
542                                 return if_info;
543                                 }
544                 ifn++;
545                 }
546         }
547 return NULL;
548 }
549
550 /*
551  * Used to retrieve the two chars string from interface
552  */
553 gchar*
554 airpcap_get_if_string_number(airpcap_if_info_t* if_info)
555 {
556         gchar* number;
557         guint n;
558         int a;
559
560         a = sscanf(if_info->name,AIRPCAP_DEVICE_NUMBER_EXTRACT_STRING,&n);
561
562         number = g_strdup_printf("%.2u\0",n);
563
564         return number;
565 }
566
567 /*
568  * Used to retrieve the two chars string from interface
569  */
570 gchar*
571 airpcap_get_if_string_number_from_description(gchar* description)
572 {
573         gchar* number;
574         gchar* pointer;
575
576         number = (gchar*)g_malloc(sizeof(gchar)*3);
577
578         pointer = g_strrstr(description,"#\0");
579
580         number[0] = *(pointer+1);
581         number[1] = *(pointer+2);
582         number[2] = '\0';
583
584         return number;
585 }
586
587 /*
588  * Returns the default airpcap interface of a list, NULL if list is empty
589  */
590 airpcap_if_info_t*
591 airpcap_get_default_if(GList* airpcap_if_list)
592 {
593 int ifn = 0;
594 GList* popdown_if_list = NULL;
595 GList* curr = NULL;
596
597         gchar* s;
598         airpcap_if_info_t* if_info = NULL;
599
600     if(prefs.capture_device != NULL)
601     {
602         s = g_strdup(get_if_name(prefs.capture_device));
603         if_info = get_airpcap_if_by_name(airpcap_if_list,g_strdup(get_if_name(prefs.capture_device)));
604         g_free(s);
605     }
606         return if_info;
607 }
608
609 /*
610  * Load the configuration for the specified interface
611  */
612 void
613 airpcap_load_selected_if_configuration(airpcap_if_info_t* if_info)
614 {
615 gchar ebuf[AIRPCAP_ERRBUF_SIZE];
616 PAirpcapHandle ad;
617
618 if(if_info != NULL)
619         {
620         ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list, if_info->description), ebuf);
621
622         if(ad)
623                 {
624                 /* Stop blinking (if it was blinkig!)*/
625                 if(if_info->blinking)
626                         {
627                         /* Turn on the light (if it was off) */
628                         if(!(if_info->led)) airpcap_if_turn_led_on(ad, 0);
629                         }
630
631                 /* Apply settings... */
632                 airpcap_if_get_device_channel(ad,&(if_info->channel));
633                 airpcap_if_get_fcs_validation(ad,&(if_info->CrcValidationOn));
634                 airpcap_if_get_fcs_presence(ad,&(if_info->IsFcsPresent));
635                 airpcap_if_get_link_type(ad,&(if_info->linkType));
636                 airpcap_if_get_decryption_state(ad, &(if_info->DecryptionOn));
637                 /* get the keys, if everything is ok, close the adapter */
638                 if(airpcap_if_load_keys(ad,if_info))
639                         airpcap_if_close(ad);
640
641                 if_info->saved = TRUE;
642                 }
643         else
644                 {
645                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, " Error in opening adapter for %s",if_info->description);
646                 }
647         }
648 }
649
650 /*
651  * Save the configuration for the specified interface
652  */
653 void
654 airpcap_save_selected_if_configuration(airpcap_if_info_t* if_info)
655 {
656 gchar ebuf[AIRPCAP_ERRBUF_SIZE];
657 PAirpcapHandle ad;
658
659 if(if_info != NULL)
660         {
661         ad = airpcap_if_open(get_airpcap_name_from_description(airpcap_if_list, if_info->description), ebuf);
662
663         if(ad)
664                 {
665                 /* Stop blinking (if it was blinkig!)*/
666                 if(if_info->blinking)
667                         {
668                         /* Turn on the light (if it was off) */
669                         if(!(if_info->led)) airpcap_if_turn_led_on(ad, 0);
670                         }
671
672                 /* Apply settings... */
673                 airpcap_if_set_device_channel(ad,if_info->channel);
674                 airpcap_if_set_fcs_validation(ad,if_info->CrcValidationOn);
675                 airpcap_if_set_fcs_presence(ad,if_info->IsFcsPresent);
676                 airpcap_if_set_link_type(ad,if_info->linkType);
677                 airpcap_if_set_decryption_state(ad, if_info->DecryptionOn);
678                 airpcap_if_save_keys(ad,if_info);
679
680                 /* ... and save them */
681                 if(!airpcap_if_store_cur_config_as_adapter_default(ad))
682                         {
683                         simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Cannot save Wireless configuration!!!\nRemember that in order to store the configuration in the registry you have to:\n\n- Close all the airpcap-based applications.\n- Be sure to have administrative privileges.");
684                         if_info->saved = FALSE;
685                         airpcap_if_close(ad);
686                         return;
687                         }
688
689                 if_info->saved = TRUE;
690                 airpcap_if_close(ad);
691                 }
692         else
693                 {
694                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, " Error in opening adapter for %s",if_info->description);
695                 }
696         }
697 }
698
699 /*
700  *  Used to dinamically load the airpcap library in order link it only when
701  *  it's present on the system
702  */
703 BOOL load_airpcap(void)
704 {
705  if((AirpcapLib =  LoadLibrary(TEXT("airpcap.dll"))) == NULL)
706  {
707   /* Report the error but go on */
708   return FALSE;
709  }
710  else
711  {
712   if((g_PAirpcapGetLastError = (AirpcapGetLastErrorHandler) GetProcAddress(AirpcapLib, "AirpcapGetLastError")) == NULL) return FALSE;
713   if((g_PAirpcapGetDeviceList = (AirpcapGetDeviceListHandler) GetProcAddress(AirpcapLib, "AirpcapGetDeviceList")) == NULL) return FALSE;
714   if((g_PAirpcapFreeDeviceList = (AirpcapFreeDeviceListHandler) GetProcAddress(AirpcapLib, "AirpcapFreeDeviceList")) == NULL) return FALSE;
715   if((g_PAirpcapOpen = (AirpcapOpenHandler) GetProcAddress(AirpcapLib, "AirpcapOpen")) == NULL) return FALSE;
716   if((g_PAirpcapClose = (AirpcapCloseHandler) GetProcAddress(AirpcapLib, "AirpcapClose")) == NULL) return FALSE;
717   if((g_PAirpcapGetLinkType = (AirpcapGetLinkTypeHandler) GetProcAddress(AirpcapLib, "AirpcapGetLinkType")) == NULL) return FALSE;
718   if((g_PAirpcapSetLinkType = (AirpcapSetLinkTypeHandler) GetProcAddress(AirpcapLib, "AirpcapSetLinkType")) == NULL) return FALSE;
719   if((g_PAirpcapSetKernelBuffer = (AirpcapSetKernelBufferHandler) GetProcAddress(AirpcapLib, "AirpcapSetKernelBuffer")) == NULL) return FALSE;
720   if((g_PAirpcapSetFilter = (AirpcapSetFilterHandler) GetProcAddress(AirpcapLib, "AirpcapSetFilter")) == NULL) return FALSE;
721   if((g_PAirpcapGetMacAddress = (AirpcapGetMacAddressHandler) GetProcAddress(AirpcapLib, "AirpcapGetMacAddress")) == NULL) return FALSE;
722   if((g_PAirpcapSetMinToCopy = (AirpcapSetMinToCopyHandler) GetProcAddress(AirpcapLib, "AirpcapSetMinToCopy")) == NULL) return FALSE;
723   if((g_PAirpcapGetReadEvent = (AirpcapGetReadEventHandler) GetProcAddress(AirpcapLib, "AirpcapGetReadEvent")) == NULL) return FALSE;
724   if((g_PAirpcapRead = (AirpcapReadHandler) GetProcAddress(AirpcapLib, "AirpcapRead")) == NULL) return FALSE;
725   if((g_PAirpcapGetStats = (AirpcapGetStatsHandler) GetProcAddress(AirpcapLib, "AirpcapGetStats")) == NULL) return FALSE;
726   if((g_PAirpcapTurnLedOn = (AirpcapTurnLedOnHandler) GetProcAddress(AirpcapLib, "AirpcapTurnLedOn")) == NULL) return FALSE;
727   if((g_PAirpcapTurnLedOff = (AirpcapTurnLedOffHandler) GetProcAddress(AirpcapLib, "AirpcapTurnLedOff")) == NULL) return FALSE;
728   if((g_PAirpcapGetDeviceChannel = (AirpcapGetDeviceChannelHandler) GetProcAddress(AirpcapLib, "AirpcapGetDeviceChannel")) == NULL) return FALSE;
729   if((g_PAirpcapSetDeviceChannel = (AirpcapSetDeviceChannelHandler) GetProcAddress(AirpcapLib, "AirpcapSetDeviceChannel")) == NULL) return FALSE;
730   if((g_PAirpcapGetFcsPresence = (AirpcapGetFcsPresenceHandler) GetProcAddress(AirpcapLib, "AirpcapGetFcsPresence")) == NULL) return FALSE;
731   if((g_PAirpcapSetFcsPresence = (AirpcapSetFcsPresenceHandler) GetProcAddress(AirpcapLib, "AirpcapSetFcsPresence")) == NULL) return FALSE;
732   if((g_PAirpcapGetFcsValidation = (AirpcapGetFcsValidationHandler) GetProcAddress(AirpcapLib, "AirpcapGetFcsValidation")) == NULL) return FALSE;
733   if((g_PAirpcapSetFcsValidation = (AirpcapSetFcsValidationHandler) GetProcAddress(AirpcapLib, "AirpcapSetFcsValidation")) == NULL) return FALSE;
734   if((g_PAirpcapGetDeviceKeys = (AirpcapGetDeviceKeysHandler) GetProcAddress(AirpcapLib, "AirpcapGetDeviceKeys")) == NULL) return FALSE;
735   if((g_PAirpcapSetDeviceKeys = (AirpcapSetDeviceKeysHandler) GetProcAddress(AirpcapLib, "AirpcapSetDeviceKeys")) == NULL) return FALSE;
736   if((g_PAirpcapGetDecryptionState = (AirpcapGetDecryptionStateHandler) GetProcAddress(AirpcapLib, "AirpcapGetDecryptionState")) == NULL) return FALSE;
737   if((g_PAirpcapSetDecryptionState = (AirpcapSetDecryptionStateHandler) GetProcAddress(AirpcapLib, "AirpcapSetDecryptionState")) == NULL) return FALSE;
738   if((g_PAirpcapStoreCurConfigAsAdapterDefault = (AirpcapStoreCurConfigAsAdapterDefaultHandler) GetProcAddress(AirpcapLib, "AirpcapStoreCurConfigAsAdapterDefault")) == NULL) return FALSE;
739   return TRUE;
740  }
741 }
742
743 #endif /* _WIN32 */