diff --git a/src/rsn_supp/tdls.c b/src/rsn_supp/tdls.c index 0d892d241..04f544e2e 100644 --- a/src/rsn_supp/tdls.c +++ b/src/rsn_supp/tdls.c @@ -1825,6 +1825,22 @@ int wpa_tdls_start(struct wpa_sm *sm, const u8 *addr) } +int wpa_tdls_reneg(struct wpa_sm *sm, const u8 *addr) +{ + struct wpa_tdls_peer *peer; + + for (peer = sm->tdls; peer; peer = peer->next) { + if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) + break; + } + + if (peer == NULL || !peer->tpk_success) + return -1; + + return wpa_tdls_start(sm, addr); +} + + /** * wpa_supplicant_rx_tdls - Receive TDLS data frame * diff --git a/src/rsn_supp/wpa.h b/src/rsn_supp/wpa.h index f22a831a5..f14062b8f 100644 --- a/src/rsn_supp/wpa.h +++ b/src/rsn_supp/wpa.h @@ -339,6 +339,7 @@ wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies, size_t ies_len, /* tdls.c */ int wpa_tdls_start(struct wpa_sm *sm, const u8 *addr); +int wpa_tdls_reneg(struct wpa_sm *sm, const u8 *addr); int wpa_tdls_recv_teardown_notify(struct wpa_sm *sm, const u8 *addr, u16 reason_code); int wpa_tdls_init(struct wpa_sm *sm); diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 327c11603..ed9a7666a 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -211,6 +211,7 @@ static int wpa_supplicant_ctrl_iface_tdls_setup( struct wpa_supplicant *wpa_s, char *addr) { u8 peer[ETH_ALEN]; + int ret; if (hwaddr_aton(addr, peer)) { wpa_printf(MSG_DEBUG, "CTRL_IFACE TDLS_SETUP: invalid " @@ -221,7 +222,10 @@ static int wpa_supplicant_ctrl_iface_tdls_setup( wpa_printf(MSG_DEBUG, "CTRL_IFACE TDLS_SETUP " MACSTR, MAC2STR(peer)); - return wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, peer); + ret = wpa_tdls_reneg(wpa_s->wpa, peer); + if (ret) + ret = wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, peer); + return ret; }