TDLS: Add peer as a STA during link setup
[mech_eap.git] / src / drivers / driver.h
index 76dbc9d..5d61481 100644 (file)
@@ -60,6 +60,8 @@ struct hostapd_channel_data {
        u8 max_tx_power;
 };
 
+#define HOSTAPD_MODE_FLAG_HT_INFO_KNOWN BIT(0)
+
 /**
  * struct hostapd_hw_modes - Supported hardware mode information
  */
@@ -103,6 +105,8 @@ struct hostapd_hw_modes {
         * a_mpdu_params - A-MPDU (IEEE 802.11n) parameters
         */
        u8 a_mpdu_params;
+
+       unsigned int flags; /* HOSTAPD_MODE_FLAG_* */
 };
 
 
@@ -195,7 +199,7 @@ struct wpa_interface_info {
        const char *drv_name;
 };
 
-#define WPAS_MAX_SCAN_SSIDS 10
+#define WPAS_MAX_SCAN_SSIDS 16
 
 /**
  * struct wpa_driver_scan_params - Scan parameters
@@ -614,8 +618,60 @@ struct wpa_driver_ap_params {
 
        /**
         * assocresp_ies - WPS IE(s) for (Re)Association Response frames
+        *
+        * This is used to add IEs like WPS IE by drivers that reply to
+        * (Re)Association Request frames internally.
         */
        const struct wpabuf *assocresp_ies;
+
+       /**
+        * isolate - Whether to isolate frames between associated stations
+        *
+        * If this is non-zero, the AP is requested to disable forwarding of
+        * frames between association stations.
+        */
+       int isolate;
+
+       /**
+        * cts_protect - Whether CTS protection is enabled
+        */
+       int cts_protect;
+
+       /**
+        * preamble - Whether short preamble is enabled
+        */
+       int preamble;
+
+       /**
+        * short_slot_time - Whether short slot time is enabled
+        *
+        * 0 = short slot time disable, 1 = short slot time enabled, -1 = do
+        * not set (e.g., when 802.11g mode is not in use)
+        */
+       int short_slot_time;
+
+       /**
+        * ht_opmode - HT operation mode or -1 if HT not in use
+        */
+       int ht_opmode;
+
+       /**
+        * interworking - Whether Interworking is enabled
+        */
+       int interworking;
+
+       /**
+        * hessid - Homogeneous ESS identifier or %NULL if not set
+        */
+       const u8 *hessid;
+
+       /**
+        * access_network_type - Access Network Type (0..15)
+        *
+        * This is used for filtering Probe Request frames when Interworking is
+        * enabled.
+        */
+       u8 access_network_type;
 };
 
 /**
@@ -646,7 +702,7 @@ struct wpa_driver_capa {
 #define WPA_DRIVER_FLAGS_DRIVER_IE     0x00000001
 /* Driver needs static WEP key setup after association command */
 #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC 0x00000002
-#define WPA_DRIVER_FLAGS_USER_SPACE_MLME 0x00000004
+/* unused: 0x00000004 */
 /* 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
@@ -691,9 +747,16 @@ struct wpa_driver_capa {
 #define WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS              0x00020000
 /* Driver supports roaming (BSS selection) in firmware */
 #define WPA_DRIVER_FLAGS_BSS_SELECTION                 0x00040000
+/* Driver supports operating as a TDLS peer */
+#define WPA_DRIVER_FLAGS_TDLS_SUPPORT                  0x00080000
+/* Driver requires external TDLS setup/teardown/discovery */
+#define WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP           0x00100000
        unsigned int flags;
 
        int max_scan_ssids;
+       int max_sched_scan_ssids;
+       int sched_scan_supported;
+       int max_match_sets;
 
        /**
         * max_remain_on_chan - Maximum remain-on-channel duration in msec
@@ -731,6 +794,7 @@ struct hostapd_sta_add_params {
        u16 listen_interval;
        const struct ieee80211_ht_capabilities *ht_capabilities;
        u32 flags; /* bitmask of WPA_STA_* flags */
+       int set; /* Set STA parameters instead of add */
 };
 
 struct hostapd_freq_params {
@@ -782,6 +846,7 @@ enum wpa_driver_if_type {
 };
 
 struct wpa_init_params {
+       void *global_priv;
        const u8 *bssid;
        const char *ifname;
        const u8 *ssid;
@@ -814,6 +879,7 @@ struct wpa_bss_params {
 #define WPA_STA_WMM BIT(1)
 #define WPA_STA_SHORT_PREAMBLE BIT(2)
 #define WPA_STA_MFP BIT(3)
+#define WPA_STA_TDLS_PEER BIT(4)
 
 /**
  * struct p2p_params - P2P parameters for driver-based P2P management
@@ -1200,93 +1266,21 @@ struct wpa_driver_ops {
         * flags: Variable for returning hardware feature flags
         * Returns: Pointer to allocated hardware data on success or %NULL on
         * failure. Caller is responsible for freeing this.
-        *
-        * This function is only needed for drivers that export MLME
-        * (management frame processing) to %wpa_supplicant or hostapd.
         */
        struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
                                                         u16 *num_modes,
                                                         u16 *flags);
 
        /**
-        * set_channel - Set channel
-        * @priv: Private driver interface data
-        * @phymode: HOSTAPD_MODE_IEEE80211B, ..
-        * @chan: IEEE 802.11 channel number
-        * @freq: Frequency of the channel in MHz
-        * Returns: 0 on success, -1 on failure
-        *
-        * This function is only needed for drivers that export MLME
-        * (management frame processing) to wpa_supplicant.
-        */
-       int (*set_channel)(void *priv, enum hostapd_hw_mode phymode, int chan,
-                          int freq);
-
-       /**
-        * set_ssid - Set SSID
-        * @priv: Private driver interface data
-        * @ssid: SSID
-        * @ssid_len: SSID length
-        * Returns: 0 on success, -1 on failure
-        *
-        * This function is only needed for drivers that export MLME
-        * (management frame processing) to wpa_supplicant.
-        */
-       int (*set_ssid)(void *priv, const u8 *ssid, size_t ssid_len);
-
-       /**
-        * set_bssid - Set BSSID
-        * @priv: Private driver interface data
-        * @bssid: BSSID
-        * Returns: 0 on success, -1 on failure
-        *
-        * This function is only needed for drivers that export MLME
-        * (management frame processing) to wpa_supplicant.
-        */
-       int (*set_bssid)(void *priv, const u8 *bssid);
-
-       /**
         * send_mlme - Send management frame from MLME
         * @priv: Private driver interface data
         * @data: IEEE 802.11 management frame with IEEE 802.11 header
         * @data_len: Size of the management frame
         * Returns: 0 on success, -1 on failure
-        *
-        * This function is only needed for drivers that export MLME
-        * (management frame processing) to wpa_supplicant.
         */
        int (*send_mlme)(void *priv, const u8 *data, size_t data_len);
 
        /**
-        * mlme_add_sta - Add a STA entry into the driver/netstack
-        * @priv: Private driver interface data
-        * @addr: MAC address of the STA (e.g., BSSID of the AP)
-        * @supp_rates: Supported rate set (from (Re)AssocResp); in IEEE 802.11
-        * format (one octet per rate, 1 = 0.5 Mbps)
-        * @supp_rates_len: Number of entries in supp_rates
-        * Returns: 0 on success, -1 on failure
-        *
-        * This function is only needed for drivers that export MLME
-        * (management frame processing) to wpa_supplicant. When the MLME code
-        * completes association with an AP, this function is called to
-        * configure the driver/netstack with a STA entry for data frame
-        * processing (TX rate control, encryption/decryption).
-        */
-       int (*mlme_add_sta)(void *priv, const u8 *addr, const u8 *supp_rates,
-                           size_t supp_rates_len);
-
-       /**
-        * mlme_remove_sta - Remove a STA entry from the driver/netstack
-        * @priv: Private driver interface data
-        * @addr: MAC address of the STA (e.g., BSSID of the AP)
-        * Returns: 0 on success, -1 on failure
-        *
-        * This function is only needed for drivers that export MLME
-        * (management frame processing) to wpa_supplicant.
-        */
-       int (*mlme_remove_sta)(void *priv, const u8 *addr);
-
-       /**
         * update_ft_ies - Update FT (IEEE 802.11r) IEs
         * @priv: Private driver interface data
         * @md: Mobility domain (2 octets) (also included inside ies)
@@ -1462,6 +1456,8 @@ struct wpa_driver_ops {
         * can be left undefined (set to %NULL) if IEEE 802.1X support is
         * always enabled and the driver uses set_ap() to set WPA/RSN IE
         * for Beacon frames.
+        *
+        * DEPRECATED - use set_ap() instead
         */
        int (*set_ieee8021x)(void *priv, struct wpa_bss_params *params);
 
@@ -1474,6 +1470,8 @@ struct wpa_driver_ops {
         * This is an optional function to configure privacy field in the
         * kernel driver for Beacon frames. This can be left undefined (set to
         * %NULL) if the driver uses the Beacon template from set_ap().
+        *
+        * DEPRECATED - use set_ap() instead
         */
        int (*set_privacy)(void *priv, int enabled);
 
@@ -1516,6 +1514,8 @@ struct wpa_driver_ops {
         * kernel driver for Beacon and Probe Response frames. This can be left
         * undefined (set to %NULL) if the driver uses the Beacon template from
         * set_ap().
+        *
+        * DEPRECATED - use set_ap() instead
         */
        int (*set_generic_elem)(void *priv, const u8 *elem, size_t elem_len);
 
@@ -1599,6 +1599,8 @@ struct wpa_driver_ops {
         * @buf: SSID
         * @len: Length of the SSID in octets
         * Returns: 0 on success, -1 on failure
+        *
+        * DEPRECATED - use set_ap() instead
         */
        int (*hapd_set_ssid)(void *priv, const u8 *buf, int len);
 
@@ -1622,6 +1624,9 @@ struct wpa_driver_ops {
         * This function is used to add a station entry to the driver once the
         * station has completed association. This is only used if the driver
         * does not take care of association processing.
+        *
+        * With TDLS, this function is also used to add or set (params->set 1)
+        * TDLS peer entries.
         */
        int (*sta_add)(void *priv, struct hostapd_sta_add_params *params);
 
@@ -1689,30 +1694,6 @@ struct wpa_driver_ops {
                             int mode);
 
        /**
-        * set_cts_protect - Set CTS protection mode (AP only)
-        * @priv: Private driver interface data
-        * @value: Whether CTS protection is enabled
-        * Returns: 0 on success, -1 on failure
-        */
-       int (*set_cts_protect)(void *priv, int value);
-
-       /**
-        * set_preamble - Set preamble mode (AP only)
-        * @priv: Private driver interface data
-        * @value: Whether short preamble is enabled
-        * Returns: 0 on success, -1 on failure
-        */
-       int (*set_preamble)(void *priv, int value);
-
-       /**
-        * set_short_slot_time - Set short slot time (AP only)
-        * @priv: Private driver interface data
-        * @value: Whether short slot time is enabled
-        * Returns: 0 on success, -1 on failure
-        */
-       int (*set_short_slot_time)(void *priv, int value);
-
-       /**
         * set_tx_queue_params - Set TX queue parameters
         * @priv: Private driver interface data
         * @queue: Queue number (0 = VO, 1 = VI, 2 = BE, 3 = BK)
@@ -1830,19 +1811,6 @@ struct wpa_driver_ops {
        int (*set_radius_acl_expire)(void *priv, const u8 *mac);
 
        /**
-        * set_ht_params - Set HT parameters (AP only)
-        * @priv: Private driver interface data
-        * @ht_capab: HT Capabilities IE
-        * @ht_capab_len: Length of ht_capab in octets
-        * @ht_oper: HT Operation IE
-        * @ht_oper_len: Length of ht_oper in octets
-        * Returns: 0 on success, -1 on failure
-        */
-       int (*set_ht_params)(void *priv,
-                            const u8 *ht_capab, size_t ht_capab_len,
-                            const u8 *ht_oper, size_t ht_oper_len);
-
-       /**
         * set_ap_wps_ie - Add WPS IE(s) into Beacon/Probe Response frames (AP)
         * @priv: Private driver interface data
         * @beacon: WPS IE(s) for Beacon frames or %NULL to remove extra IE(s)
@@ -1867,6 +1835,8 @@ struct wpa_driver_ops {
         * also used to provide Probe Response IEs for P2P Listen state
         * operations for drivers that generate the Probe Response frames
         * internally.
+        *
+        * DEPRECATED - use set_ap() instead
         */
        int (*set_ap_wps_ie)(void *priv, const struct wpabuf *beacon,
                             const struct wpabuf *proberesp,
@@ -2111,11 +2081,6 @@ struct wpa_driver_ops {
        int (*ampdu)(void *priv, int ampdu);
 
        /**
-        * set_intra_bss - Enables/Disables intra BSS bridging
-        */
-       int (*set_intra_bss)(void *priv, int enabled);
-
-       /**
         * get_radio_name - Get physical radio name for the device
         * @priv: Private driver interface data
         * Returns: Radio name or %NULL if not known
@@ -2353,7 +2318,7 @@ struct wpa_driver_ops {
         * @status_code: Status Code or Reason Code to use (if needed)
         * @buf: TDLS IEs to add to the message
         * @len: Length of buf in octets
-        * Returns: 0 on success, -1 on failure
+        * Returns: 0 on success, negative (<0) on failure
         *
         * This optional function can be used to send packet to driver which is
         * responsible for receiving and sending all TDLS packets.
@@ -2362,6 +2327,16 @@ struct wpa_driver_ops {
                              u8 dialog_token, u16 status_code,
                              const u8 *buf, size_t len);
 
+       /**
+        * tdls_oper - Ask the driver to perform high-level TDLS operations
+        * @priv: Private driver interface data
+        * @oper: TDLS high-level operation. See %enum tdls_oper
+        * @peer: Destination (peer) MAC address
+        * Returns: 0 on success, negative (<0) on failure
+        *
+        * This optional function can be used to send high-level TDLS commands
+        * to the driver.
+        */
        int (*tdls_oper)(void *priv, enum tdls_oper oper, const u8 *peer);
 
        /**
@@ -2380,6 +2355,8 @@ struct wpa_driver_ops {
         * This function can be used to set authentication algorithms for AP
         * mode when static WEP is used. If the driver uses user space MLME/SME
         * implementation, there is no need to implement this function.
+        *
+        * DEPRECATED - use set_ap() instead
         */
        int (*set_authmode)(void *priv, int authmode);
 
@@ -2455,6 +2432,49 @@ struct wpa_driver_ops {
         * the station gets added by FT-over-DS.
         */
        int (*add_sta_node)(void *priv, const u8 *addr, u16 auth_alg);
+
+       /**
+        * sched_scan - Request the driver to initiate scheduled scan
+        * @priv: Private driver interface data
+        * @params: Scan parameters
+        * @interval: Interval between scan cycles in milliseconds
+        * Returns: 0 on success, -1 on failure
+        *
+        * This operation should be used for scheduled scan offload to
+        * the hardware. Every time scan results are available, the
+        * driver should report scan results event for wpa_supplicant
+        * which will eventually request the results with
+        * wpa_driver_get_scan_results2(). This operation is optional
+        * and if not provided or if it returns -1, we fall back to
+        * normal host-scheduled scans.
+        */
+       int (*sched_scan)(void *priv, struct wpa_driver_scan_params *params,
+                         u32 interval);
+
+       /**
+        * stop_sched_scan - Request the driver to stop a scheduled scan
+        * @priv: Private driver interface data
+        * Returns: 0 on success, -1 on failure
+        *
+        * This should cause the scheduled scan to be stopped and
+        * results should stop being sent. Must be supported if
+        * sched_scan is supported.
+        */
+       int (*stop_sched_scan)(void *priv);
+
+       /**
+        * poll_client - Probe (null data or such) the given station
+        * @priv: Private driver interface data
+        * @own_addr: MAC address of sending interface
+        * @addr: MAC address of the station to probe
+        * @qos: Indicates whether station is QoS station
+        *
+        * This function is used to verify whether an associated station is
+        * still present. This function does not need to be implemented if the
+        * driver provides such inactivity polling mechanism.
+        */
+       void (*poll_client)(void *priv, const u8 *own_addr,
+                           const u8 *addr, int qos);
 };
 
 
@@ -2867,7 +2887,20 @@ enum wpa_event_type {
         * completed Group Key Handshake while the host (including
         * wpa_supplicant was sleeping).
         */
-       EVENT_DRIVER_GTK_REKEY
+       EVENT_DRIVER_GTK_REKEY,
+
+       /**
+        * EVENT_SCHED_SCAN_STOPPED - Scheduled scan was stopped
+        */
+       EVENT_SCHED_SCAN_STOPPED,
+
+       /**
+        * EVENT_DRIVER_CLIENT_POLL_OK - Station responded to poll
+        *
+        * This event indicates that the station responded to the poll
+        * initiated with @poll_client.
+        */
+       EVENT_DRIVER_CLIENT_POLL_OK
 };
 
 
@@ -3161,8 +3194,9 @@ union wpa_event_data {
         * struct rx_from_unknown - Data for EVENT_RX_FROM_UNKNOWN events
         */
        struct rx_from_unknown {
-               const u8 *frame;
-               size_t len;
+               const u8 *bssid;
+               const u8 *addr;
+               int wds;
        } rx_from_unknown;
 
        /**
@@ -3421,6 +3455,14 @@ union wpa_event_data {
                const u8 *bssid;
                const u8 *replay_ctr;
        } driver_gtk_rekey;
+
+       /**
+        * struct client_poll - Data for EVENT_DRIVER_CLIENT_POLL_OK events
+        * @addr: station address
+        */
+       struct client_poll {
+               u8 addr[ETH_ALEN];
+       } client_poll;
 };
 
 /**
@@ -3473,4 +3515,17 @@ static inline void drv_event_eapol_rx(void *ctx, const u8 *src, const u8 *data,
        wpa_supplicant_event(ctx, EVENT_EAPOL_RX, &event);
 }
 
+static inline void wpa_scan_results_free(struct wpa_scan_results *res)
+{
+       size_t i;
+
+       if (res == NULL)
+               return;
+
+       for (i = 0; i < res->num; i++)
+               os_free(res->res[i]);
+       os_free(res->res);
+       os_free(res);
+}
+
 #endif /* DRIVER_H */