Didier Gautheron:
[obnox/wireshark/wip.git] / airpcap_loader.h
index 5260fe0403dbbcce78fc2337f8dcad20422ed9c3..f974800dcdef27b856061aab8e0eda4d04577bf2 100644 (file)
 #ifndef __AIRPCAP_LOADER_H__
 #define __AIRPCAP_LOADER_H__
 
+#include <epan/crypt/airpdcap_user.h>
+
 /* Error values from "get_airpcap_interface_list()". */
 #define        CANT_GET_AIRPCAP_INTERFACE_LIST 0       /* error getting list */
 #define        NO_AIRPCAP_INTERFACES_FOUND     1       /* list is empty */
+#define AIRPCAP_NOT_LOADED             2       /* Airpcap DLL not loaded */
 
 #define AIRPCAP_CHANNEL_ANY_NAME "ANY"
 
+#define AIRPCAP_WEP_KEY_STRING  "WEP"
 /*
- * WEP_KEY_MAX_SIZE is in bytes, but each byte is rapresented in strings with an ascii char
- * 4 bit are needed to store an exadecimal number, 8 bit to store a char...
- */
-#define WEP_KEY_MAX_CHAR_SIZE (WEP_KEY_MAX_SIZE*2)
-
-/*
- * WEP_KEY_MAX_SIZE is in bytes, this is in bits...
+ * XXX - WPA_PWD is the passphrase+ssid and WPA-PSK is the hexadecimal key
  */
-#define WEP_KEY_MAX_BIT_SIZE (WEP_KEY_MAX_SIZE*8)
-
-#define AIRPCAP_WEP_KEY_STRING  "WEP"
-#define AIRPCAP_WPA_KEY_STRING  "WPA"
-#define AIRPCAP_WPA2_KEY_STRING "WPA2"
+#define AIRPCAP_WPA_PWD_KEY_STRING  "WPA-PWD"
+#define AIRPCAP_WPA_BIN_KEY_STRING  "WPA-PSK"
 
 #define AIRPCAP_DLL_OK                 0
 #define AIRPCAP_DLL_OLD                        1
@@ -86,6 +81,21 @@ typedef BOOL (*AirpcapSetDriverDecryptionStateHandler)(PAirpcapHandle AdapterHan
 typedef BOOL (*AirpcapGetDriverDecryptionStateHandler)(PAirpcapHandle AdapterHandle, PAirpcapDecryptionState PEnable);
 typedef BOOL (*AirpcapStoreCurConfigAsAdapterDefaultHandler)(PAirpcapHandle AdapterHandle);
 typedef VOID (*AirpcapGetVersionHandler)(PUINT VersionMajor, PUINT VersionMinor, PUINT VersionRev, PUINT VersionBuild);
+typedef BOOL (*AirpcapSetDeviceChannelExHandler)(PAirpcapHandle AdapterHandle, AirpcapChannelInfo ChannelInfo);
+typedef BOOL (*AirpcapGetDeviceChannelExHandler)(PAirpcapHandle AdapterHandle, PAirpcapChannelInfo PChannelInfo);
+typedef BOOL (*AirpcapGetDeviceSupportedChannelsHandler)(PAirpcapHandle AdapterHandle, AirpcapChannelInfo **ppChannelInfo, PULONG pNumChannelInfo);
+
+#define FLAG_CAN_BE_LOW                0x00000001
+#define FLAG_CAN_BE_HIGH       0x00000002
+#define FLAG_IS_BG_CHANNEL     0x00000004
+#define FLAG_IS_A_CHANNEL      0x00000008
+
+typedef struct _Dot11Channel
+{
+       UINT  Channel;
+       ULONG Frequency;
+       ULONG Flags;
+} Dot11Channel;
 
 /*
  * The list of interfaces returned by "get_airpcap_interface_list()" is
@@ -96,17 +106,19 @@ typedef struct {
        char                                    *description;           /* from OS, e.g. "Local Area Connection" or NULL */
        GSList                                  *ip_addr;                       /* containing address values of if_addr_t */
        gboolean                                loopback;                       /* TRUE if loopback, FALSE otherwise */
-       AirpcapLinkType                 linkType;                       /* The link layer type*/
-       UINT                                    channel;                        /* Channel (1-14)*/
+       AirpcapLinkType                 linkType;                       /* The link layer type */
+       AirpcapChannelInfo              channelInfo;            /* Channel Information */
        BOOL                                    IsFcsPresent;           /* Include 802.11 CRC in frames */
        AirpcapValidationType   CrcValidationOn;        /* Capture Frames with Wrong CRC */
-       AirpcapDecryptionState  DecryptionOn;           /* TRUE if decryption is on, FALSE otherwise*/
+       AirpcapDecryptionState  DecryptionOn;           /* TRUE if decryption is on, FALSE otherwise */
        PAirpcapKeysCollection  keysCollection;         /* WEP Key collection for the adapter */
        UINT                                    keysCollectionSize;     /* Size of the key collection */
-       gboolean                                blinking;                       /* TRUE if is blinkng, FALSE otherwise*/
-       gboolean                                led;                            /* TRUE if on, FALSE if off*/
+       gboolean                                blinking;                       /* TRUE if is blinkng, FALSE otherwise */
+       gboolean                                led;                            /* TRUE if on, FALSE if off */
        gboolean                                saved;                          /* TRUE if current configuration has been saved, FALSE otherwise */
        gint                                    tag;                            /* int for the gtk blinking callback */
+       Dot11Channel                    *pSupportedChannels;
+       ULONG                                   numSupportedChannels;
 } airpcap_if_info_t;
 
 /*
@@ -118,16 +130,6 @@ typedef struct {
    int number_of_keys;
 } keys_cb_data_t;
 
-/*
- * Struct to store infos about a specific decryption key.
- */
-typedef struct {
-    GString *key;
-    GString *ssid;
-    guint   bits;
-    guint   type;
-} decryption_key_t;
-
 /* Airpcap interface list */
 extern GList *airpcap_if_list;
 
@@ -138,14 +140,7 @@ extern airpcap_if_info_t *airpcap_if_selected;
 extern airpcap_if_info_t *airpcap_if_active;
 
 /* WLAN preferences pointer */
-//extern module_t *wlan_prefs;
-
-/*
- * Function used to read the Decryption Keys from the preferences and store them
- * properly into the airpcap adapter.
- */
-BOOL
-load_wlan_wep_keys(airpcap_if_info_t* info_if);
+/*extern module_t *wlan_prefs; - TODO: What is this?? */
 
 /*
  * Function used to read the Decryption Keys from the preferences and store them
@@ -165,7 +160,7 @@ save_wlan_wep_keys(airpcap_if_info_t* info_if);
  * This will be stored into the registry...
  */
 gboolean
-write_wlan_wep_keys_to_regitry(airpcap_if_info_t* info_if, GList* key_list);
+write_wlan_wep_keys_to_registry(airpcap_if_info_t* info_if, GList* key_list);
 
 /* Returs TRUE if the WEP key is valid, false otherwise */
 gboolean
@@ -199,7 +194,7 @@ free_airpcap_interface_list(GList *if_list);
  * Used to retrieve the interface given the name
  * (the name is used in AirpcapOpen)
  */
-airpcap_if_info_t* get_airpcap_if_by_name(GList* if_list, const gchar* name);
+airpcap_if_info_t* get_airpcap_if_from_name(GList* if_list, const gchar* name);
 
 /*
  * Airpcap wrapper, used to store the current settings for the selected adapter
@@ -285,12 +280,36 @@ airpcap_if_set_link_type(PAirpcapHandle ah, AirpcapLinkType lt);
 BOOL
 airpcap_if_get_device_channel(PAirpcapHandle ah, PUINT ch);
 
+/*
+ * Airpcap wrapper, get the channels supported by the adapter
+ */
+BOOL
+airpcap_if_get_device_supported_channels(PAirpcapHandle ah, AirpcapChannelInfo **cInfo, PULONG nInfo);
+
+/*
+ * Airpcap wrapper, get supported channels formatted into an array
+ */
+Dot11Channel*
+airpcap_if_get_device_supported_channels_array(PAirpcapHandle ah, PULONG pNumSupportedChannels);
+
 /*
  * Airpcap wrapper, used to set the channel of an airpcap adapter
  */
 BOOL
 airpcap_if_set_device_channel(PAirpcapHandle ah, UINT ch);
 
+/*
+ * Airpcap wrapper, used to get the frequency of an airpcap adapter
+ */
+BOOL
+airpcap_if_get_device_channel_ex(PAirpcapHandle ah, PAirpcapChannelInfo pChannelInfo);
+
+/*
+ * Airpcap wrapper, used to set the frequency of an airpcap adapter
+ */
+BOOL
+airpcap_if_set_device_channel_ex(PAirpcapHandle ah, AirpcapChannelInfo ChannelInfo);
+
 /*
  * Airpcap wrapper, used to open an airpcap adapter
  */
@@ -301,6 +320,12 @@ PAirpcapHandle airpcap_if_open(PCHAR name, PCHAR err);
  */
 VOID airpcap_if_close(PAirpcapHandle handle);
 
+/*
+ * Retrieve the state of the Airpcap DLL
+ */
+int
+airpcap_get_dll_state();
+
 /*
  * Airpcap wrapper, used to turn on the led of an airpcap adapter
  */
@@ -327,19 +352,12 @@ airpcap_if_info_t* airpcap_driver_fake_if_info_new();
  */
 int load_airpcap(void);
 
-/*
- * Get an error message string for a CANT_GET_INTERFACE_LIST error from
- * "get_airpcap_interface_list()".
- */
-gchar*
-cant_get_airpcap_if_list_error_message(const char *err_str);
-
 /*
  * This function will use the airpcap.dll to find all the airpcap devices.
  * Will return null if no device is found.
  */
 GList*
-get_airpcap_interface_list(int *err, char *err_str);
+get_airpcap_interface_list(int *err, char **err_str);
 
 /*
  * Returns the ASCII string of a key given the key bites
@@ -359,20 +377,6 @@ airpcap_load_selected_if_configuration(airpcap_if_info_t* if_info);
 void
 airpcap_save_selected_if_configuration(airpcap_if_info_t* if_info);
 
-/*
- * Used to retrieve the name of the interface given the description
- * (the name is used in AirpcapOpen, the description is put in the combo box)
- */
-gchar*
-get_airpcap_name_from_description(GList* if_list, gchar* description);
-
-/*
- * Used to retrieve the airpcap_if_info_t of the selected interface given the
- * description (that is the entry of the combo box).
- */
-gpointer
-get_airpcap_if_from_description(GList* if_list, const gchar* description);
-
 /*
  * Used to retrieve the two chars string from interface description
  */
@@ -437,7 +441,7 @@ airpcap_if_info_free(airpcap_if_info_t *if_info);
  * This will be stored into the registry...
  */
 BOOL
-write_wlan_driver_wep_keys_to_regitry(GList* key_list);
+write_wlan_driver_wep_keys_to_registry(GList* key_list);
 
 /*
  * Clear keys and decryption status for the specified interface
@@ -445,13 +449,13 @@ write_wlan_driver_wep_keys_to_regitry(GList* key_list);
 void
 airpcap_if_clear_decryption_settings(airpcap_if_info_t* info_if);
 
-/* 
+/*
  *  Function used to save to the preference file the Decryption Keys.
  */
 int
 save_wlan_driver_wep_keys();
 
-/* 
+/*
  *  Function used to save to the preference file the Decryption Keys.
  */
 int