]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
TDLS: Clear peer entries on association/disassociation
authorJouni Malinen <jouni.malinen@atheros.com>
Fri, 21 Jan 2011 18:51:55 +0000 (20:51 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 6 Mar 2011 12:53:58 +0000 (14:53 +0200)
Since the TDLS links are allowed only to STAs that are in the same
BSS with us, clear all peer data whenever the BSS may have changed.

src/rsn_supp/tdls.c
src/rsn_supp/wpa.c
src/rsn_supp/wpa_i.h

index 349a892224035266079a156159e7250f09355710..22b859382cf6a4dfa68981d1bb69365f2e0d3181 100644 (file)
@@ -1765,6 +1765,26 @@ int wpa_tdls_init(struct wpa_sm *sm)
 }
 
 
+static void wpa_tdls_remove_peers(struct wpa_sm *sm)
+{
+       struct wpa_tdls_peer *peer, *tmp;
+
+       peer = sm->tdls;
+       sm->tdls = NULL;
+
+       while (peer) {
+               int res;
+               tmp = peer->next;
+               res = wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
+               wpa_printf(MSG_DEBUG, "TDLS: Remove peer " MACSTR " (res=%d)",
+                          MAC2STR(peer->addr), res);
+               wpa_supplicant_peer_free(sm, peer);
+               os_free(peer);
+               peer = tmp;
+       }
+}
+
+
 /**
  * wpa_tdls_deinit - Deinitialize driver interface parameters for TDLS
  *
@@ -1773,8 +1793,6 @@ int wpa_tdls_init(struct wpa_sm *sm)
  */
 void wpa_tdls_deinit(struct wpa_sm *sm)
 {
-       struct wpa_tdls_peer *peer;
-
        if (sm == NULL)
                return;
 
@@ -1782,14 +1800,19 @@ void wpa_tdls_deinit(struct wpa_sm *sm)
                l2_packet_deinit(sm->l2_tdls);
        sm->l2_tdls = NULL;
 
-       peer = sm->tdls;
-       while (peer) {
-               struct wpa_tdls_peer *tmp;
-               tmp = peer->next;
-               /* clear tdls sm */
-               wpa_supplicant_peer_free(sm, peer);
-               os_free(peer);
-               peer = tmp;
-       }
-       sm->tdls = NULL;
+       wpa_tdls_remove_peers(sm);
+}
+
+
+void wpa_tdls_assoc(struct wpa_sm *sm)
+{
+       wpa_printf(MSG_DEBUG, "TDLS: Remove peers on association");
+       wpa_tdls_remove_peers(sm);
+}
+
+
+void wpa_tdls_disassoc(struct wpa_sm *sm)
+{
+       wpa_printf(MSG_DEBUG, "TDLS: Remove peers on disassociation");
+       wpa_tdls_remove_peers(sm);
 }
index 63a3589cdcc46613649734b8e973b51e20e86291..ac891c1740e73e328ae835ee540f7e0bec308386 100644 (file)
@@ -2128,6 +2128,10 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
                sm->ptk_set = 0;
                sm->tptk_set = 0;
        }
+
+#ifdef CONFIG_TDLS
+       wpa_tdls_assoc(sm);
+#endif /* CONFIG_TDLS */
 }
 
 
@@ -2143,6 +2147,9 @@ void wpa_sm_notify_disassoc(struct wpa_sm *sm)
        rsn_preauth_deinit(sm);
        if (wpa_sm_get_state(sm) == WPA_4WAY_HANDSHAKE)
                sm->dot11RSNA4WayHandshakeFailures++;
+#ifdef CONFIG_TDLS
+       wpa_tdls_disassoc(sm);
+#endif /* CONFIG_TDLS */
 }
 
 
index ee61ce5d8b43bb810cfebec75106f7ece0acc673..b8bb6286d7c6abe3fe28ef53ad9d73a012745a86 100644 (file)
@@ -282,4 +282,7 @@ int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr,
                      const struct wpa_eapol_key *key,
                      struct wpa_ptk *ptk, size_t ptk_len);
 
+void wpa_tdls_assoc(struct wpa_sm *sm);
+void wpa_tdls_disassoc(struct wpa_sm *sm);
+
 #endif /* WPA_I_H */