TDLS: Add peer as a STA during link setup
[mech_eap.git] / wpa_supplicant / wpas_glue.c
index 2662eec..c02fdd0 100644 (file)
@@ -24,7 +24,6 @@
 #include "wpa_supplicant_i.h"
 #include "driver_i.h"
 #include "rsn_supp/pmksa_cache.h"
-#include "mlme.h"
 #include "sme.h"
 #include "common/ieee802_11_defs.h"
 #include "common/wpa_ctrl.h"
@@ -32,6 +31,7 @@
 #include "wps_supplicant.h"
 #include "bss.h"
 #include "scan.h"
+#include "notify.h"
 
 
 #ifndef CONFIG_NO_CONFIG_BLOBS
@@ -437,10 +437,6 @@ static void * wpa_supplicant_get_network_ctx(void *wpa_s)
 static int wpa_supplicant_get_bssid(void *ctx, u8 *bssid)
 {
        struct wpa_supplicant *wpa_s = ctx;
-       if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME) {
-               os_memcpy(bssid, wpa_s->bssid, ETH_ALEN);
-               return 0;
-       }
        return wpa_drv_get_bssid(wpa_s, bssid);
 }
 
@@ -488,8 +484,6 @@ static int wpa_supplicant_update_ft_ies(void *ctx, const u8 *md,
                                        const u8 *ies, size_t ies_len)
 {
        struct wpa_supplicant *wpa_s = ctx;
-       if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
-               return ieee80211_sta_update_ft_ies(wpa_s, md, ies, ies_len);
        if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
                return sme_update_ft_ies(wpa_s, md, ies, ies_len);
        return wpa_drv_update_ft_ies(wpa_s, md, ies, ies_len);
@@ -501,9 +495,6 @@ static int wpa_supplicant_send_ft_action(void *ctx, u8 action,
                                         const u8 *ies, size_t ies_len)
 {
        struct wpa_supplicant *wpa_s = ctx;
-       if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
-               return ieee80211_sta_send_ft_action(wpa_s, action, target_ap,
-                                                   ies, ies_len);
        return wpa_drv_send_ft_action(wpa_s, action, target_ap, ies, ies_len);
 }
 
@@ -514,9 +505,6 @@ static int wpa_supplicant_mark_authenticated(void *ctx, const u8 *target_ap)
        struct wpa_driver_auth_params params;
        struct wpa_bss *bss;
 
-       if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
-               return -1;
-
        bss = wpa_bss_get_bssid(wpa_s, target_ap);
        if (bss == NULL)
                return -1;
@@ -537,6 +525,27 @@ static int wpa_supplicant_mark_authenticated(void *ctx, const u8 *target_ap)
 
 #ifdef CONFIG_TDLS
 
+static int wpa_supplicant_tdls_get_capa(void *ctx, int *tdls_supported,
+                                       int *tdls_ext_setup)
+{
+       struct wpa_supplicant *wpa_s = ctx;
+
+       *tdls_supported = 0;
+       *tdls_ext_setup = 0;
+
+       if (!wpa_s->drv_capa_known)
+               return -1;
+
+       if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_SUPPORT)
+               *tdls_supported = 1;
+
+       if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP)
+               *tdls_ext_setup = 1;
+
+       return 0;
+}
+
+
 static int wpa_supplicant_send_tdls_mgmt(void *ctx, const u8 *dst,
                                         u8 action_code, u8 dialog_token,
                                         u16 status_code, const u8 *buf,
@@ -554,6 +563,27 @@ static int wpa_supplicant_tdls_oper(void *ctx, int oper, const u8 *peer)
        return wpa_drv_tdls_oper(wpa_s, oper, peer);
 }
 
+
+static int wpa_supplicant_tdls_peer_addset(
+       void *ctx, const u8 *peer, int add, u16 capability,
+       const u8 *supp_rates, size_t supp_rates_len)
+{
+       struct wpa_supplicant *wpa_s = ctx;
+       struct hostapd_sta_add_params params;
+
+       params.addr = peer;
+       params.aid = 1;
+       params.capability = capability;
+       params.flags = WPA_STA_TDLS_PEER | WPA_STA_AUTHORIZED;
+       params.ht_capabilities = NULL;
+       params.listen_interval = 0;
+       params.supp_rates = supp_rates;
+       params.supp_rates_len = supp_rates_len;
+       params.set = !add;
+
+       return wpa_drv_sta_add(wpa_s, &params);
+}
+
 #endif /* CONFIG_TDLS */
 
 
@@ -611,6 +641,16 @@ static void wpa_supplicant_port_cb(void *ctx, int authorized)
                   authorized ? "Authorized" : "Unauthorized");
        wpa_drv_set_supp_port(wpa_s, authorized);
 }
+
+
+static void wpa_supplicant_cert_cb(void *ctx, int depth, const char *subject,
+                                  const char *cert_hash,
+                                  const struct wpabuf *cert)
+{
+       struct wpa_supplicant *wpa_s = ctx;
+
+       wpas_notify_certification(wpa_s, depth, subject, cert_hash, cert);
+}
 #endif /* IEEE8021X_EAPOL */
 
 
@@ -641,6 +681,7 @@ int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
        ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
        ctx->port_cb = wpa_supplicant_port_cb;
        ctx->cb = wpa_supplicant_eapol_cb;
+       ctx->cert_cb = wpa_supplicant_cert_cb;
        ctx->cb_ctx = wpa_s;
        wpa_s->eapol = eapol_sm_init(ctx);
        if (wpa_s->eapol == NULL) {
@@ -655,6 +696,16 @@ int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
 }
 
 
+static void wpa_supplicant_set_rekey_offload(void *ctx, const u8 *kek,
+                                            const u8 *kck,
+                                            const u8 *replay_ctr)
+{
+       struct wpa_supplicant *wpa_s = ctx;
+
+       wpa_drv_set_rekey_info(wpa_s, kek, kck, replay_ctr);
+}
+
+
 int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
 {
 #ifndef CONFIG_NO_WPA
@@ -691,9 +742,12 @@ int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
        ctx->mark_authenticated = wpa_supplicant_mark_authenticated;
 #endif /* CONFIG_IEEE80211R */
 #ifdef CONFIG_TDLS
+       ctx->tdls_get_capa = wpa_supplicant_tdls_get_capa;
        ctx->send_tdls_mgmt = wpa_supplicant_send_tdls_mgmt;
        ctx->tdls_oper = wpa_supplicant_tdls_oper;
+       ctx->tdls_peer_addset = wpa_supplicant_tdls_peer_addset;
 #endif /* CONFIG_TDLS */
+       ctx->set_rekey_offload = wpa_supplicant_set_rekey_offload;
 
        wpa_s->wpa = wpa_sm_init(ctx);
        if (wpa_s->wpa == NULL) {
@@ -717,6 +771,7 @@ void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
                conf.peerkey_enabled = ssid->peerkey;
                conf.allowed_pairwise_cipher = ssid->pairwise_cipher;
 #ifdef IEEE8021X_EAPOL
+               conf.proactive_key_caching = ssid->proactive_key_caching;
                conf.eap_workaround = ssid->eap_workaround;
                conf.eap_conf_ctx = &ssid->eap;
 #endif /* IEEE8021X_EAPOL */