From f130b105ec4462b55e829dffe8b3c6b6003227ca Mon Sep 17 00:00:00 2001 From: Sunil Dutt Date: Mon, 30 Sep 2013 17:10:18 +0300 Subject: [PATCH] TDLS: Clean up wpa_tdls_teardown_link() uses Making this function be used only for external setup case simplifies the implementation and makes core wpa_supplicant calls in ctrl_iface.c and events.c consistent. Signed-hostap: Jouni Malinen --- src/rsn_supp/tdls.c | 26 +++++++++----------------- wpa_supplicant/events.c | 8 ++++++-- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/rsn_supp/tdls.c b/src/rsn_supp/tdls.c index eb5879146..5fa687e17 100644 --- a/src/rsn_supp/tdls.c +++ b/src/rsn_supp/tdls.c @@ -276,21 +276,13 @@ static int wpa_tdls_tpk_send(struct wpa_sm *sm, const u8 *dest, u8 action_code, static int wpa_tdls_do_teardown(struct wpa_sm *sm, struct wpa_tdls_peer *peer, - u16 reason_code, int free_peer) + u16 reason_code) { int ret; - if (sm->tdls_external_setup) { - ret = wpa_tdls_send_teardown(sm, peer->addr, reason_code); - - /* disable the link after teardown was sent */ - wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); - } else { - ret = wpa_sm_tdls_oper(sm, TDLS_TEARDOWN, peer->addr); - } - - if (sm->tdls_external_setup || free_peer) - wpa_tdls_peer_free(sm, peer); + ret = wpa_tdls_send_teardown(sm, peer->addr, reason_code); + /* disable the link after teardown was sent */ + wpa_tdls_disable_link(sm, peer->addr); return ret; } @@ -338,7 +330,7 @@ static void wpa_tdls_tpk_retry_timeout(void *eloop_ctx, void *timeout_ctx) wpa_printf(MSG_DEBUG, "TDLS: Sending Teardown Request"); wpa_tdls_do_teardown(sm, peer, - WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED, 1); + WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); } } @@ -616,7 +608,7 @@ static void wpa_tdls_tpk_timeout(void *eloop_ctx, void *timeout_ctx) wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime expired for " MACSTR " - tear down", MAC2STR(peer->addr)); wpa_tdls_do_teardown(sm, peer, - WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED, 1); + WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); } } @@ -775,7 +767,7 @@ int wpa_tdls_teardown_link(struct wpa_sm *sm, const u8 *addr, u16 reason_code) return -1; } - return wpa_tdls_do_teardown(sm, peer, reason_code, 0); + return wpa_tdls_do_teardown(sm, peer, reason_code); } @@ -2057,7 +2049,7 @@ skip_rsn: if (ret < 0) { wpa_printf(MSG_DEBUG, "TDLS: Could not enable link"); wpa_tdls_do_teardown(sm, peer, - WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED, 1); + WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); } return ret; @@ -2202,7 +2194,7 @@ skip_rsn: if (ret < 0) { wpa_printf(MSG_DEBUG, "TDLS: Could not enable link"); wpa_tdls_do_teardown(sm, peer, - WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED, 1); + WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); } return ret; error: diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 69e40302c..977564ca8 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -2281,8 +2281,12 @@ static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s, wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, data->tdls.peer); break; case TDLS_REQUEST_TEARDOWN: - wpa_tdls_teardown_link(wpa_s->wpa, data->tdls.peer, - data->tdls.reason_code); + if (wpa_tdls_is_external_setup(wpa_s->wpa)) + wpa_tdls_teardown_link(wpa_s->wpa, data->tdls.peer, + data->tdls.reason_code); + else + wpa_drv_tdls_oper(wpa_s, TDLS_TEARDOWN, + data->tdls.peer); break; } }