Fix driver_ops function documentation
[wpasupplicant] / src / drivers / driver.h
index c5f2106..21d5bd5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * WPA Supplicant - driver interface definition
- * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -22,6 +22,7 @@
 #define AUTH_ALG_OPEN_SYSTEM   0x01
 #define AUTH_ALG_SHARED_KEY    0x02
 #define AUTH_ALG_LEAP          0x04
+#define AUTH_ALG_FT            0x08
 
 #define IEEE80211_MODE_INFRA   0
 #define IEEE80211_MODE_IBSS    1
@@ -81,8 +82,14 @@ struct wpa_scan_result {
 };
 
 
+#define WPA_SCAN_QUAL_INVALID          BIT(0)
+#define WPA_SCAN_NOISE_INVALID         BIT(1)
+#define WPA_SCAN_LEVEL_INVALID         BIT(2)
+#define WPA_SCAN_LEVEL_DBM             BIT(3)
+
 /**
  * struct wpa_scan_res - Scan result for an BSS/IBSS
+ * @flags: information flags about the BSS/IBSS (WPA_SCAN_*)
  * @bssid: BSSID
  * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
  * @beacon_int: beacon interval in TUs (host byte order)
@@ -103,6 +110,7 @@ struct wpa_scan_result {
  * report all IEs to make it easier to support future additions.
  */
 struct wpa_scan_res {
+       unsigned int flags;
        u8 bssid[ETH_ALEN];
        int freq;
        u16 beacon_int;
@@ -180,6 +188,27 @@ struct wpa_driver_scan_params {
         * extra_ies_len - Length of extra_ies in octets
         */
        size_t extra_ies_len;
+
+       /**
+        * freqs - Array of frequencies to scan or %NULL for all frequencies
+        *
+        * The frequency is set in MHz. The array is zero-terminated.
+        */
+       int *freqs;
+};
+
+/**
+ * struct wpa_driver_auth_params - Authentication parameters
+ * Data for struct wpa_driver_ops::authenticate().
+ */
+struct wpa_driver_auth_params {
+       int freq;
+       const u8 *bssid;
+       const u8 *ssid;
+       size_t ssid_len;
+       int auth_alg;
+       const u8 *ie;
+       size_t ie_len;
 };
 
 /**
@@ -328,6 +357,15 @@ struct wpa_driver_associate_params {
         * be prepared to handle %NULL value as an error.
         */
        const u8 *psk;
+
+       /**
+        * drop_unencrypted - Enable/disable unencrypted frame filtering
+        *
+        * Configure the driver to drop all non-EAPOL frames (both receive and
+        * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
+        * still be allowed for key negotiation.
+        */
+       int drop_unencrypted;
 };
 
 /**
@@ -361,6 +399,12 @@ struct wpa_driver_capa {
 /* Driver takes care of RSN 4-way handshake internally; PMK is configured with
  * struct wpa_driver_ops::set_key using alg = WPA_ALG_PMK */
 #define WPA_DRIVER_FLAGS_4WAY_HANDSHAKE 0x00000008
+#define WPA_DRIVER_FLAGS_WIRED         0x00000010
+/* Driver provides separate commands for authentication and association (SME in
+ * wpa_supplicant). */
+#define WPA_DRIVER_FLAGS_SME           0x00000020
+/* Driver supports AP mode */
+#define WPA_DRIVER_FLAGS_AP            0x00000040
        unsigned int flags;
 
        int max_scan_ssids;
@@ -594,6 +638,9 @@ struct wpa_driver_ops {
         * Configure the driver to drop all non-EAPOL frames (both receive and
         * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
         * still be allowed for key negotiation.
+        *
+        * This function is deprecated. New driver wrapper implementations
+        * should use associate() parameter drop_unencrypted instead.
         */
        int (*set_drop_unencrypted)(void *priv, int enabled);
 
@@ -611,7 +658,7 @@ struct wpa_driver_ops {
         * results event for wpa_supplicant which will eventually request the
         * results with wpa_driver_get_scan_results().
         *
-        * This function is depracated. New driver wrapper implementations
+        * This function is deprecated. New driver wrapper implementations
         * should implement support for scan2().
         */
        int (*scan)(void *priv, const u8 *ssid, size_t ssid_len);
@@ -629,7 +676,7 @@ struct wpa_driver_ops {
         * returned and the remaining entries will not be included in the
         * buffer.
         *
-        * This function is depracated. New driver wrapper implementations
+        * This function is deprecated. New driver wrapper implementations
         * should implement support for get_scan_results2().
         */
        int (*get_scan_results)(void *priv,
@@ -685,6 +732,9 @@ struct wpa_driver_ops {
         * associate() params, so set_auth_alg may not be needed in case of
         * most drivers.
         *
+        * This function is deprecated. New driver wrapper implementations
+        * should use associate() parameter auth_alg instead.
+        *
         * Returns: 0 on success, -1 on failure
         */
        int (*set_auth_alg)(void *priv, int auth_alg);
@@ -747,7 +797,7 @@ struct wpa_driver_ops {
        int (*flush_pmkid)(void *priv);
 
        /**
-        * flush_pmkid - Flush PMKSA cache
+        * get_capa - Get driver capabilities
         * @priv: private driver interface data
         *
         * Returns: 0 on success, -1 on failure
@@ -1002,8 +1052,12 @@ struct wpa_driver_ops {
         * This handler will be called before any key configuration and call to
         * associate() handler in order to allow the operation mode to be
         * configured as early as possible. This information is also available
-        * in associate() params and as such, some driver wrappers may not need
+        * in associate() params and as such, driver wrappers may not need
         * to implement set_mode() handler.
+        *
+        * This function is deprecated. New driver wrapper implementations
+        * should use associate() parameter mode instead.
+        *
         * Returns: 0 on success, -1 on failure
         */
        int (*set_mode)(void *priv, int mode);
@@ -1075,14 +1129,27 @@ struct wpa_driver_ops {
         * results with wpa_driver_get_scan_results2().
         */
        int (*scan2)(void *priv, struct wpa_driver_scan_params *params);
-};
 
-/* Function to check whether a driver is for wired connections */
-static inline int IS_WIRED(const struct wpa_driver_ops *drv)
-{
-       return os_strcmp(drv->name, "wired") == 0 ||
-               os_strcmp(drv->name, "roboswitch") == 0;
-}
+       /**
+        * authenticate - Request driver to authenticate
+        * @priv: private driver interface data
+        * @params: authentication parameters
+        * Returns: 0 on success, -1 on failure
+        *
+        * This is an optional function that can be used with drivers that
+        * support separate authentication and association steps, i.e., when
+        * wpa_supplicant can act as the SME. If not implemented, associate()
+        * function is expected to take care of IEEE 802.11 authentication,
+        * too.
+        */
+       int (*authenticate)(void *priv,
+                           struct wpa_driver_auth_params *params);
+
+       int (*set_beacon)(void *priv, const u8 *head, size_t head_len,
+                         const u8 *tail, size_t tail_len, int dtim_period);
+
+       int (*set_beacon_int)(void *priv, int value);
+};
 
 /**
  * enum wpa_event_type - Event type for wpa_supplicant_event() calls
@@ -1107,7 +1174,9 @@ typedef enum wpa_event_type {
         *
         * This event should be called when association is lost either due to
         * receiving deauthenticate or disassociate frame from the AP or when
-        * sending either of these frames to the current AP.
+        * sending either of these frames to the current AP. If the driver
+        * supports separate deauthentication event, EVENT_DISASSOC should only
+        * be used for disassociation and EVENT_DEAUTH for deauthentication.
         */
        EVENT_DISASSOC,
 
@@ -1215,7 +1284,36 @@ typedef enum wpa_event_type {
         * event starts RSN authentication with the other STA to authenticate
         * the STA and set up encryption keys with it.
         */
-       EVENT_IBSS_RSN_START
+       EVENT_IBSS_RSN_START,
+
+       /**
+        * EVENT_AUTH - Authentication result
+        *
+        * This event should be called when authentication attempt has been
+        * completed. This is only used if the driver supports separate
+        * authentication step (struct wpa_driver_ops::authenticate).
+        * Information about authentication result is included in
+        * union wpa_event_data::auth.
+        */
+       EVENT_AUTH,
+
+       /**
+        * EVENT_DEAUTH - Authentication lost
+        *
+        * This event should be called when authentication is lost either due
+        * to receiving deauthenticate frame from the AP or when sending that
+        * frame to the current AP.
+        */
+       EVENT_DEAUTH,
+
+       /**
+        * EVENT_ASSOC_REJECT - Association rejected
+        *
+        * This event should be called when (re)association attempt has been
+        * rejected by the AP. Information about authentication result is
+        * included in union wpa_event_data::assoc_reject.
+        */
+       EVENT_ASSOC_REJECT
 } wpa_event_type;
 
 
@@ -1341,6 +1439,10 @@ union wpa_event_data {
                size_t ies_len;
                int ft_action;
                u8 target_ap[ETH_ALEN];
+               /** Optional IE(s), e.g., WMM TSPEC(s), for RIC-Request */
+               const u8 *ric_ies;
+               /** Length of ric_ies buffer in octets */
+               size_t ric_ies_len;
        } ft_ies;
 
        /**
@@ -1349,6 +1451,45 @@ union wpa_event_data {
        struct ibss_rsn_start {
                u8 peer[ETH_ALEN];
        } ibss_rsn_start;
+
+       /**
+        * struct auth_info - Data for EVENT_AUTH events
+        */
+       struct auth_info {
+               u8 peer[ETH_ALEN];
+               u16 auth_type;
+               u16 status_code;
+               const u8 *ies;
+               size_t ies_len;
+       } auth;
+
+       /**
+        * struct assoc_reject - Data for EVENT_ASSOC_REJECT events
+        */
+       struct assoc_reject {
+               /**
+                * resp_ies - (Re)Association Response IEs
+                *
+                * Optional association data from the driver. This data is not
+                * required WPA, but may be useful for some protocols and as
+                * such, should be reported if this is available to the driver
+                * interface.
+                *
+                * This should start with the first IE (fixed fields before IEs
+                * are not included).
+                */
+               u8 *resp_ies;
+
+               /**
+                * resp_ies_len - Length of resp_ies in bytes
+                */
+               size_t resp_ies_len;
+
+               /**
+                * status_code - Status Code from (Re)association Response
+                */
+               u16 status_code;
+       } assoc_reject;
 };
 
 /**