Lines Matching refs:peer
84 static void wpa_tdls_peer_free(struct wpa_sm *sm, struct wpa_tdls_peer *peer);
86 struct wpa_tdls_peer *peer);
175 static int wpa_tdls_del_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer) in wpa_tdls_del_key() argument
177 if (wpa_sm_set_key(sm, WPA_ALG_NONE, peer->addr, in wpa_tdls_del_key()
188 static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer) in wpa_tdls_set_key() argument
196 switch (peer->cipher) { in wpa_tdls_set_key()
211 if (wpa_sm_set_key(sm, alg, peer->addr, -1, 1, in wpa_tdls_set_key()
212 rsc, sizeof(rsc), peer->tpk.tk, key_len) < 0) { in wpa_tdls_set_key()
236 struct wpa_tdls_peer *peer; in wpa_tdls_tpk_send() local
258 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_tpk_send()
259 if (os_memcmp(peer->addr, dest, ETH_ALEN) == 0) in wpa_tdls_tpk_send()
263 if (peer == NULL) { in wpa_tdls_tpk_send()
269 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_send()
272 peer->sm_tmr.count = TPK_M2_RETRY_COUNT; in wpa_tdls_tpk_send()
273 peer->sm_tmr.timer = TPK_M2_TIMEOUT; in wpa_tdls_tpk_send()
275 peer->sm_tmr.count = TPK_M1_RETRY_COUNT; in wpa_tdls_tpk_send()
276 peer->sm_tmr.timer = TPK_M1_TIMEOUT; in wpa_tdls_tpk_send()
280 os_memcpy(peer->sm_tmr.dest, dest, ETH_ALEN); in wpa_tdls_tpk_send()
281 peer->sm_tmr.action_code = action_code; in wpa_tdls_tpk_send()
282 peer->sm_tmr.dialog_token = dialog_token; in wpa_tdls_tpk_send()
283 peer->sm_tmr.status_code = status_code; in wpa_tdls_tpk_send()
284 peer->sm_tmr.peer_capab = peer_capab; in wpa_tdls_tpk_send()
285 peer->sm_tmr.buf_len = msg_len; in wpa_tdls_tpk_send()
286 os_free(peer->sm_tmr.buf); in wpa_tdls_tpk_send()
287 peer->sm_tmr.buf = os_malloc(msg_len); in wpa_tdls_tpk_send()
288 if (peer->sm_tmr.buf == NULL) in wpa_tdls_tpk_send()
290 os_memcpy(peer->sm_tmr.buf, msg, msg_len); in wpa_tdls_tpk_send()
294 eloop_register_timeout(peer->sm_tmr.timer / 1000, in wpa_tdls_tpk_send()
295 (peer->sm_tmr.timer % 1000) * 1000, in wpa_tdls_tpk_send()
296 wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_send()
301 static int wpa_tdls_do_teardown(struct wpa_sm *sm, struct wpa_tdls_peer *peer, in wpa_tdls_do_teardown() argument
306 ret = wpa_tdls_send_teardown(sm, peer->addr, reason_code); in wpa_tdls_do_teardown()
308 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_do_teardown()
318 struct wpa_tdls_peer *peer = timeout_ctx; in wpa_tdls_tpk_retry_timeout() local
320 if (peer->sm_tmr.count) { in wpa_tdls_tpk_retry_timeout()
321 peer->sm_tmr.count--; in wpa_tdls_tpk_retry_timeout()
325 peer->sm_tmr.action_code); in wpa_tdls_tpk_retry_timeout()
327 if (peer->sm_tmr.buf == NULL) { in wpa_tdls_tpk_retry_timeout()
330 peer->sm_tmr.action_code); in wpa_tdls_tpk_retry_timeout()
332 peer); in wpa_tdls_tpk_retry_timeout()
337 if (wpa_tdls_send_tpk_msg(sm, peer->sm_tmr.dest, in wpa_tdls_tpk_retry_timeout()
338 peer->sm_tmr.action_code, in wpa_tdls_tpk_retry_timeout()
339 peer->sm_tmr.dialog_token, in wpa_tdls_tpk_retry_timeout()
340 peer->sm_tmr.status_code, in wpa_tdls_tpk_retry_timeout()
341 peer->sm_tmr.peer_capab, in wpa_tdls_tpk_retry_timeout()
342 peer->initiator, in wpa_tdls_tpk_retry_timeout()
343 peer->sm_tmr.buf, in wpa_tdls_tpk_retry_timeout()
344 peer->sm_tmr.buf_len)) { in wpa_tdls_tpk_retry_timeout()
349 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_retry_timeout()
350 eloop_register_timeout(peer->sm_tmr.timer / 1000, in wpa_tdls_tpk_retry_timeout()
351 (peer->sm_tmr.timer % 1000) * 1000, in wpa_tdls_tpk_retry_timeout()
352 wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_retry_timeout()
354 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_retry_timeout()
357 wpa_tdls_do_teardown(sm, peer, in wpa_tdls_tpk_retry_timeout()
364 struct wpa_tdls_peer *peer, in wpa_tdls_tpk_retry_timeout_cancel() argument
367 if (action_code == peer->sm_tmr.action_code) { in wpa_tdls_tpk_retry_timeout_cancel()
372 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_retry_timeout_cancel()
375 os_free(peer->sm_tmr.buf); in wpa_tdls_tpk_retry_timeout_cancel()
376 peer->sm_tmr.buf = NULL; in wpa_tdls_tpk_retry_timeout_cancel()
378 peer->sm_tmr.count = 0; in wpa_tdls_tpk_retry_timeout_cancel()
379 peer->sm_tmr.timer = 0; in wpa_tdls_tpk_retry_timeout_cancel()
380 peer->sm_tmr.buf_len = 0; in wpa_tdls_tpk_retry_timeout_cancel()
381 peer->sm_tmr.action_code = 0xff; in wpa_tdls_tpk_retry_timeout_cancel()
389 static void wpa_tdls_generate_tpk(struct wpa_tdls_peer *peer, in wpa_tdls_generate_tpk() argument
402 if (os_memcmp(peer->inonce, peer->rnonce, WPA_NONCE_LEN) < 0) { in wpa_tdls_generate_tpk()
403 nonce[0] = peer->inonce; in wpa_tdls_generate_tpk()
404 nonce[1] = peer->rnonce; in wpa_tdls_generate_tpk()
406 nonce[0] = peer->rnonce; in wpa_tdls_generate_tpk()
407 nonce[1] = peer->inonce; in wpa_tdls_generate_tpk()
423 if (os_memcmp(own_addr, peer->addr, ETH_ALEN) < 0) { in wpa_tdls_generate_tpk()
425 os_memcpy(data + ETH_ALEN, peer->addr, ETH_ALEN); in wpa_tdls_generate_tpk()
427 os_memcpy(data, peer->addr, ETH_ALEN); in wpa_tdls_generate_tpk()
434 (u8 *) &peer->tpk, sizeof(peer->tpk)); in wpa_tdls_generate_tpk()
436 peer->tpk.kck, sizeof(peer->tpk.kck)); in wpa_tdls_generate_tpk()
438 peer->tpk.tk, sizeof(peer->tpk.tk)); in wpa_tdls_generate_tpk()
439 peer->tpk_set = 1; in wpa_tdls_generate_tpk()
564 struct wpa_tdls_peer *peer, in wpa_supplicant_verify_tdls_mic() argument
570 if (peer->tpk_set) { in wpa_supplicant_verify_tdls_mic()
571 wpa_tdls_ftie_mic(peer->tpk.kck, trans_seq, lnkid, in wpa_supplicant_verify_tdls_mic()
572 peer->rsnie_p, timeoutie, (u8 *) ftie, in wpa_supplicant_verify_tdls_mic()
593 u8 trans_seq, u16 rcode, u8 dtoken, struct wpa_tdls_peer *peer, in wpa_supplicant_verify_tdls_mic_teardown() argument
598 if (peer->tpk_set) { in wpa_supplicant_verify_tdls_mic_teardown()
599 wpa_tdls_key_mic_teardown(peer->tpk.kck, trans_seq, rcode, in wpa_supplicant_verify_tdls_mic_teardown()
618 struct wpa_tdls_peer *peer = timeout_ctx; in wpa_tdls_tpk_timeout() local
628 if (peer->initiator) { in wpa_tdls_tpk_timeout()
630 " - try to renew", MAC2STR(peer->addr)); in wpa_tdls_tpk_timeout()
631 wpa_tdls_start(sm, peer->addr); in wpa_tdls_tpk_timeout()
634 " - tear down", MAC2STR(peer->addr)); in wpa_tdls_tpk_timeout()
635 wpa_tdls_do_teardown(sm, peer, in wpa_tdls_tpk_timeout()
642 struct wpa_tdls_peer *peer) in wpa_tdls_peer_remove_from_list() argument
648 while (cur && cur != peer) { in wpa_tdls_peer_remove_from_list()
653 if (cur != peer) { in wpa_tdls_peer_remove_from_list()
656 MAC2STR(peer->addr)); in wpa_tdls_peer_remove_from_list()
661 prev->next = peer->next; in wpa_tdls_peer_remove_from_list()
663 sm->tdls = peer->next; in wpa_tdls_peer_remove_from_list()
667 static void wpa_tdls_peer_clear(struct wpa_sm *sm, struct wpa_tdls_peer *peer) in wpa_tdls_peer_clear() argument
670 MAC2STR(peer->addr)); in wpa_tdls_peer_clear()
671 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer); in wpa_tdls_peer_clear()
672 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_peer_clear()
673 peer->reconfig_key = 0; in wpa_tdls_peer_clear()
674 peer->initiator = 0; in wpa_tdls_peer_clear()
675 peer->tpk_in_progress = 0; in wpa_tdls_peer_clear()
676 os_free(peer->sm_tmr.buf); in wpa_tdls_peer_clear()
677 peer->sm_tmr.buf = NULL; in wpa_tdls_peer_clear()
678 os_free(peer->ht_capabilities); in wpa_tdls_peer_clear()
679 peer->ht_capabilities = NULL; in wpa_tdls_peer_clear()
680 os_free(peer->vht_capabilities); in wpa_tdls_peer_clear()
681 peer->vht_capabilities = NULL; in wpa_tdls_peer_clear()
682 os_free(peer->ext_capab); in wpa_tdls_peer_clear()
683 peer->ext_capab = NULL; in wpa_tdls_peer_clear()
684 os_free(peer->supp_channels); in wpa_tdls_peer_clear()
685 peer->supp_channels = NULL; in wpa_tdls_peer_clear()
686 os_free(peer->supp_oper_classes); in wpa_tdls_peer_clear()
687 peer->supp_oper_classes = NULL; in wpa_tdls_peer_clear()
688 peer->rsnie_i_len = peer->rsnie_p_len = 0; in wpa_tdls_peer_clear()
689 peer->cipher = 0; in wpa_tdls_peer_clear()
690 peer->qos_info = 0; in wpa_tdls_peer_clear()
691 peer->wmm_capable = 0; in wpa_tdls_peer_clear()
692 peer->tpk_set = peer->tpk_success = 0; in wpa_tdls_peer_clear()
693 peer->chan_switch_enabled = 0; in wpa_tdls_peer_clear()
694 os_memset(&peer->tpk, 0, sizeof(peer->tpk)); in wpa_tdls_peer_clear()
695 os_memset(peer->inonce, 0, WPA_NONCE_LEN); in wpa_tdls_peer_clear()
696 os_memset(peer->rnonce, 0, WPA_NONCE_LEN); in wpa_tdls_peer_clear()
700 static void wpa_tdls_peer_free(struct wpa_sm *sm, struct wpa_tdls_peer *peer) in wpa_tdls_peer_free() argument
702 wpa_tdls_peer_clear(sm, peer); in wpa_tdls_peer_free()
703 wpa_tdls_peer_remove_from_list(sm, peer); in wpa_tdls_peer_free()
704 os_free(peer); in wpa_tdls_peer_free()
708 static void wpa_tdls_linkid(struct wpa_sm *sm, struct wpa_tdls_peer *peer, in wpa_tdls_linkid() argument
714 if (peer->initiator) { in wpa_tdls_linkid()
716 os_memcpy(lnkid->resp_sta, peer->addr, ETH_ALEN); in wpa_tdls_linkid()
718 os_memcpy(lnkid->init_sta, peer->addr, ETH_ALEN); in wpa_tdls_linkid()
727 struct wpa_tdls_peer *peer; in wpa_tdls_send_teardown() local
738 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_send_teardown()
739 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_send_teardown()
743 if (peer == NULL) { in wpa_tdls_send_teardown()
750 if (peer->chan_switch_enabled) { in wpa_tdls_send_teardown()
753 wpa_sm_tdls_disable_channel_switch(sm, peer->addr); in wpa_tdls_send_teardown()
756 dialog_token = peer->dtoken; in wpa_tdls_send_teardown()
762 if (wpa_tdls_get_privacy(sm) && peer->tpk_set && peer->tpk_success) { in wpa_tdls_send_teardown()
776 if (!wpa_tdls_get_privacy(sm) || !peer->tpk_set || !peer->tpk_success) in wpa_tdls_send_teardown()
782 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN); in wpa_tdls_send_teardown()
783 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); in wpa_tdls_send_teardown()
800 wpa_tdls_linkid(sm, peer, &lnkid); in wpa_tdls_send_teardown()
801 wpa_tdls_key_mic_teardown(peer->tpk.kck, 4, reason_code, in wpa_tdls_send_teardown()
811 reason_code, 0, peer->initiator, rbuf, pos - rbuf); in wpa_tdls_send_teardown()
820 struct wpa_tdls_peer *peer; in wpa_tdls_teardown_link() local
825 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_teardown_link()
826 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_teardown_link()
830 if (peer == NULL) { in wpa_tdls_teardown_link()
836 if (!peer->tpk_success) { in wpa_tdls_teardown_link()
842 return wpa_tdls_do_teardown(sm, peer, reason_code); in wpa_tdls_teardown_link()
847 struct wpa_tdls_peer *peer) in wpa_tdls_disable_peer_link() argument
849 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); in wpa_tdls_disable_peer_link()
850 wpa_tdls_peer_free(sm, peer); in wpa_tdls_disable_peer_link()
856 struct wpa_tdls_peer *peer; in wpa_tdls_disable_unreachable_link() local
858 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_disable_unreachable_link()
859 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_disable_unreachable_link()
863 if (!peer || !peer->tpk_success) { in wpa_tdls_disable_unreachable_link()
875 if (peer->chan_switch_enabled) in wpa_tdls_disable_unreachable_link()
876 wpa_sm_tdls_disable_channel_switch(sm, peer->addr); in wpa_tdls_disable_unreachable_link()
880 wpa_tdls_peer_free(sm, peer); in wpa_tdls_disable_unreachable_link()
882 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_disable_unreachable_link()
889 struct wpa_tdls_peer *peer; in wpa_tdls_get_link_status() local
894 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_get_link_status()
895 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_get_link_status()
899 if (peer == NULL) in wpa_tdls_get_link_status()
902 if (!peer->tpk_success) in wpa_tdls_get_link_status()
912 struct wpa_tdls_peer *peer = NULL; in wpa_tdls_recv_teardown() local
921 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_recv_teardown()
922 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0) in wpa_tdls_recv_teardown()
926 if (peer == NULL) { in wpa_tdls_recv_teardown()
959 if (!wpa_tdls_get_privacy(sm) || !peer->tpk_set || !peer->tpk_success) in wpa_tdls_recv_teardown()
971 peer->dtoken, peer, in wpa_tdls_recv_teardown()
983 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_recv_teardown()
1012 struct wpa_tdls_peer *peer; in wpa_tdls_add_peer() local
1016 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_add_peer()
1017 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) { in wpa_tdls_add_peer()
1020 return peer; /* re-use existing entry */ in wpa_tdls_add_peer()
1027 peer = os_zalloc(sizeof(*peer)); in wpa_tdls_add_peer()
1028 if (peer == NULL) in wpa_tdls_add_peer()
1031 os_memcpy(peer->addr, addr, ETH_ALEN); in wpa_tdls_add_peer()
1032 peer->next = sm->tdls; in wpa_tdls_add_peer()
1033 sm->tdls = peer; in wpa_tdls_add_peer()
1035 return peer; in wpa_tdls_add_peer()
1040 struct wpa_tdls_peer *peer) in wpa_tdls_send_tpk_m1() argument
1053 peer->rsnie_i_len = 0; in wpa_tdls_send_tpk_m1()
1064 hdr = (struct rsn_ie_hdr *) peer->rsnie_i; in wpa_tdls_send_tpk_m1()
1114 hdr->len = (pos - peer->rsnie_i) - 2; in wpa_tdls_send_tpk_m1()
1115 peer->rsnie_i_len = pos - peer->rsnie_i; in wpa_tdls_send_tpk_m1()
1117 peer->rsnie_i, peer->rsnie_i_len); in wpa_tdls_send_tpk_m1()
1122 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) + in wpa_tdls_send_tpk_m1()
1133 wpa_tdls_peer_free(sm, peer); in wpa_tdls_send_tpk_m1()
1142 pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len); in wpa_tdls_send_tpk_m1()
1148 if (os_get_random(peer->inonce, WPA_NONCE_LEN)) { in wpa_tdls_send_tpk_m1()
1152 wpa_tdls_peer_free(sm, peer); in wpa_tdls_send_tpk_m1()
1156 peer->inonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m1()
1157 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m1()
1176 peer->lifetime = TPK_LIFETIME; in wpa_tdls_send_tpk_m1()
1181 peer->lifetime = 301; in wpa_tdls_send_tpk_m1()
1186 peer->lifetime = 0xffffffff; in wpa_tdls_send_tpk_m1()
1190 sizeof(timeoutie), peer->lifetime); in wpa_tdls_send_tpk_m1()
1191 wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime); in wpa_tdls_send_tpk_m1()
1200 wpa_tdls_linkid(sm, peer, l); in wpa_tdls_send_tpk_m1()
1208 MAC2STR(peer->addr)); in wpa_tdls_send_tpk_m1()
1210 status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_SETUP_REQUEST, in wpa_tdls_send_tpk_m1()
1211 1, 0, 0, peer->initiator, rbuf, pos - rbuf); in wpa_tdls_send_tpk_m1()
1221 const struct wpa_tdls_peer *peer) in wpa_tdls_send_tpk_m2() argument
1234 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) + in wpa_tdls_send_tpk_m2()
1251 pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len); in wpa_tdls_send_tpk_m2()
1256 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m2()
1257 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m2()
1276 lifetime = peer->lifetime; in wpa_tdls_send_tpk_m2()
1290 wpa_tdls_ftie_mic(peer->tpk.kck, 2, (u8 *) lnkid, peer->rsnie_p, in wpa_tdls_send_tpk_m2()
1301 dtoken, 0, 0, peer->initiator, rbuf, in wpa_tdls_send_tpk_m2()
1312 const struct wpa_tdls_peer *peer) in wpa_tdls_send_tpk_m3() argument
1326 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) + in wpa_tdls_send_tpk_m3()
1343 pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len); in wpa_tdls_send_tpk_m3()
1348 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m3()
1349 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m3()
1366 lifetime = peer->lifetime; in wpa_tdls_send_tpk_m3()
1380 wpa_tdls_ftie_mic(peer->tpk.kck, 3, (u8 *) lnkid, peer->rsnie_p, in wpa_tdls_send_tpk_m3()
1391 if (peer->vht_capabilities) in wpa_tdls_send_tpk_m3()
1393 if (peer->ht_capabilities) in wpa_tdls_send_tpk_m3()
1395 if (peer->wmm_capable) in wpa_tdls_send_tpk_m3()
1399 dtoken, 0, peer_capab, peer->initiator, in wpa_tdls_send_tpk_m3()
1408 struct wpa_tdls_peer *peer, in wpa_tdls_send_discovery_response() argument
1420 "(peer " MACSTR ")", MAC2STR(peer->addr)); in wpa_tdls_send_discovery_response()
1425 hdr = (struct rsn_ie_hdr *) peer->rsnie_i; in wpa_tdls_send_discovery_response()
1457 peer->rsnie_i_len = pos - peer->rsnie_i; in wpa_tdls_send_discovery_response()
1465 buf_len += peer->rsnie_i_len + in wpa_tdls_send_discovery_response()
1470 wpa_tdls_peer_free(sm, peer); in wpa_tdls_send_discovery_response()
1478 pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len); in wpa_tdls_send_discovery_response()
1480 peer->lifetime = TPK_LIFETIME; in wpa_tdls_send_discovery_response()
1482 sizeof(timeoutie), peer->lifetime); in wpa_tdls_send_discovery_response()
1483 wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime); in wpa_tdls_send_discovery_response()
1485 status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_DISCOVERY_RESPONSE, in wpa_tdls_send_discovery_response()
1499 struct wpa_tdls_peer *peer; in wpa_tdls_process_discovery_request() local
1541 peer = wpa_tdls_add_peer(sm, addr, NULL); in wpa_tdls_process_discovery_request()
1542 if (peer == NULL) in wpa_tdls_process_discovery_request()
1545 return wpa_tdls_send_discovery_response(sm, peer, dialog_token); in wpa_tdls_process_discovery_request()
1562 struct wpa_tdls_peer *peer) in copy_supp_rates() argument
1568 peer->supp_rates_len = merge_byte_arrays( in copy_supp_rates()
1569 peer->supp_rates, sizeof(peer->supp_rates), in copy_supp_rates()
1578 struct wpa_tdls_peer *peer) in copy_peer_ht_capab() argument
1586 if (!peer->ht_capabilities) { in copy_peer_ht_capab()
1587 peer->ht_capabilities = in copy_peer_ht_capab()
1589 if (peer->ht_capabilities == NULL) in copy_peer_ht_capab()
1593 os_memcpy(peer->ht_capabilities, kde->ht_capabilities, in copy_peer_ht_capab()
1596 (u8 *) peer->ht_capabilities, in copy_peer_ht_capab()
1604 struct wpa_tdls_peer *peer) in copy_peer_vht_capab() argument
1612 if (!peer->vht_capabilities) { in copy_peer_vht_capab()
1613 peer->vht_capabilities = in copy_peer_vht_capab()
1615 if (peer->vht_capabilities == NULL) in copy_peer_vht_capab()
1619 os_memcpy(peer->vht_capabilities, kde->vht_capabilities, in copy_peer_vht_capab()
1622 (u8 *) peer->vht_capabilities, in copy_peer_vht_capab()
1630 struct wpa_tdls_peer *peer) in copy_peer_ext_capab() argument
1638 if (!peer->ext_capab || peer->ext_capab_len < kde->ext_capab_len - 2) { in copy_peer_ext_capab()
1640 os_free(peer->ext_capab); in copy_peer_ext_capab()
1641 peer->ext_capab = os_zalloc(kde->ext_capab_len - 2); in copy_peer_ext_capab()
1642 if (peer->ext_capab == NULL) in copy_peer_ext_capab()
1646 peer->ext_capab_len = kde->ext_capab_len - 2; in copy_peer_ext_capab()
1647 os_memcpy(peer->ext_capab, kde->ext_capab + 2, peer->ext_capab_len); in copy_peer_ext_capab()
1654 struct wpa_tdls_peer *peer) in copy_peer_wmm_capab() argument
1669 peer->qos_info = wmm->qos_info; in copy_peer_wmm_capab()
1671 peer->wmm_capable = 1; in copy_peer_wmm_capab()
1673 wpa_printf(MSG_DEBUG, "TDLS: Peer WMM QOS Info 0x%x", peer->qos_info); in copy_peer_wmm_capab()
1679 struct wpa_tdls_peer *peer) in copy_peer_supp_channels() argument
1686 if (!peer->supp_channels || in copy_peer_supp_channels()
1687 peer->supp_channels_len < kde->supp_channels_len) { in copy_peer_supp_channels()
1688 os_free(peer->supp_channels); in copy_peer_supp_channels()
1689 peer->supp_channels = os_zalloc(kde->supp_channels_len); in copy_peer_supp_channels()
1690 if (peer->supp_channels == NULL) in copy_peer_supp_channels()
1694 peer->supp_channels_len = kde->supp_channels_len; in copy_peer_supp_channels()
1696 os_memcpy(peer->supp_channels, kde->supp_channels, in copy_peer_supp_channels()
1697 peer->supp_channels_len); in copy_peer_supp_channels()
1699 (u8 *) peer->supp_channels, peer->supp_channels_len); in copy_peer_supp_channels()
1705 struct wpa_tdls_peer *peer) in copy_peer_supp_oper_classes() argument
1712 if (!peer->supp_oper_classes || in copy_peer_supp_oper_classes()
1713 peer->supp_oper_classes_len < kde->supp_oper_classes_len) { in copy_peer_supp_oper_classes()
1714 os_free(peer->supp_oper_classes); in copy_peer_supp_oper_classes()
1715 peer->supp_oper_classes = os_zalloc(kde->supp_oper_classes_len); in copy_peer_supp_oper_classes()
1716 if (peer->supp_oper_classes == NULL) in copy_peer_supp_oper_classes()
1720 peer->supp_oper_classes_len = kde->supp_oper_classes_len; in copy_peer_supp_oper_classes()
1721 os_memcpy(peer->supp_oper_classes, kde->supp_oper_classes, in copy_peer_supp_oper_classes()
1722 peer->supp_oper_classes_len); in copy_peer_supp_oper_classes()
1724 (u8 *) peer->supp_oper_classes, in copy_peer_supp_oper_classes()
1725 peer->supp_oper_classes_len); in copy_peer_supp_oper_classes()
1730 static int wpa_tdls_addset_peer(struct wpa_sm *sm, struct wpa_tdls_peer *peer, in wpa_tdls_addset_peer() argument
1733 return wpa_sm_tdls_peer_addset(sm, peer->addr, add, peer->aid, in wpa_tdls_addset_peer()
1734 peer->capability, in wpa_tdls_addset_peer()
1735 peer->supp_rates, peer->supp_rates_len, in wpa_tdls_addset_peer()
1736 peer->ht_capabilities, in wpa_tdls_addset_peer()
1737 peer->vht_capabilities, in wpa_tdls_addset_peer()
1738 peer->qos_info, peer->wmm_capable, in wpa_tdls_addset_peer()
1739 peer->ext_capab, peer->ext_capab_len, in wpa_tdls_addset_peer()
1740 peer->supp_channels, in wpa_tdls_addset_peer()
1741 peer->supp_channels_len, in wpa_tdls_addset_peer()
1742 peer->supp_oper_classes, in wpa_tdls_addset_peer()
1743 peer->supp_oper_classes_len); in wpa_tdls_addset_peer()
1750 struct wpa_tdls_peer *peer; in wpa_tdls_process_tpk_m1() local
1782 peer = wpa_tdls_add_peer(sm, src_addr, &existing_peer); in wpa_tdls_process_tpk_m1()
1783 if (peer == NULL) in wpa_tdls_process_tpk_m1()
1790 if (peer->tpk_success) { in wpa_tdls_process_tpk_m1()
1794 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); in wpa_tdls_process_tpk_m1()
1795 wpa_tdls_peer_clear(sm, peer); in wpa_tdls_process_tpk_m1()
1796 } else if (peer->initiator) { in wpa_tdls_process_tpk_m1()
1816 peer->addr); in wpa_tdls_process_tpk_m1()
1817 wpa_tdls_peer_clear(sm, peer); in wpa_tdls_process_tpk_m1()
1823 peer->capability = WPA_GET_LE16(cpos); in wpa_tdls_process_tpk_m1()
1854 if (copy_supp_rates(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1857 if (copy_peer_ht_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1860 if (copy_peer_vht_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1863 if (copy_peer_ext_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1866 if (copy_peer_supp_channels(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1869 if (copy_peer_supp_oper_classes(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1872 peer->qos_info = kde.qosinfo; in wpa_tdls_process_tpk_m1()
1875 if (copy_peer_wmm_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1878 peer->aid = kde.aid; in wpa_tdls_process_tpk_m1()
1882 peer = wpa_tdls_add_peer(sm, src_addr, NULL); in wpa_tdls_process_tpk_m1()
1883 if (peer == NULL) in wpa_tdls_process_tpk_m1()
1887 peer->initiator = 1; in wpa_tdls_process_tpk_m1()
1888 wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL, in wpa_tdls_process_tpk_m1()
1890 wpa_tdls_send_tpk_m1(sm, peer); in wpa_tdls_process_tpk_m1()
1974 if (os_memcmp(sm->own_addr, peer->addr, ETH_ALEN) < 0) { in wpa_tdls_process_tpk_m1()
1985 peer->initiator = 0; /* Need to check */ in wpa_tdls_process_tpk_m1()
1986 peer->dtoken = dtoken; in wpa_tdls_process_tpk_m1()
1989 peer->rsnie_i_len = 0; in wpa_tdls_process_tpk_m1()
1990 peer->rsnie_p_len = 0; in wpa_tdls_process_tpk_m1()
1991 peer->cipher = WPA_CIPHER_NONE; in wpa_tdls_process_tpk_m1()
1996 os_memcpy(peer->rsnie_i, kde.rsn_ie, kde.rsn_ie_len); in wpa_tdls_process_tpk_m1()
1997 peer->rsnie_i_len = kde.rsn_ie_len; in wpa_tdls_process_tpk_m1()
1998 peer->cipher = cipher; in wpa_tdls_process_tpk_m1()
2000 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) { in wpa_tdls_process_tpk_m1()
2010 os_memcpy(peer->inonce, ftie->Snonce, WPA_NONCE_LEN); in wpa_tdls_process_tpk_m1()
2011 if (os_get_random(peer->rnonce, WPA_NONCE_LEN)) { in wpa_tdls_process_tpk_m1()
2027 hdr = (struct rsn_ie_hdr *) peer->rsnie_p; in wpa_tdls_process_tpk_m1()
2052 hdr->len = (pos - peer->rsnie_p) - 2; in wpa_tdls_process_tpk_m1()
2053 peer->rsnie_p_len = pos - peer->rsnie_p; in wpa_tdls_process_tpk_m1()
2057 os_memcpy(peer->rsnie_p, peer->rsnie_i, peer->rsnie_i_len); in wpa_tdls_process_tpk_m1()
2058 peer->rsnie_p_len = peer->rsnie_i_len; in wpa_tdls_process_tpk_m1()
2061 peer->rsnie_p, peer->rsnie_p_len); in wpa_tdls_process_tpk_m1()
2063 peer->lifetime = lifetime; in wpa_tdls_process_tpk_m1()
2065 wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid); in wpa_tdls_process_tpk_m1()
2074 if (wpa_tdls_addset_peer(sm, peer, 1) < 0) in wpa_tdls_process_tpk_m1()
2080 peer->tpk_in_progress = 1; in wpa_tdls_process_tpk_m1()
2083 if (wpa_tdls_send_tpk_m2(sm, src_addr, dtoken, lnkid, peer) < 0) { in wpa_tdls_process_tpk_m1()
2084 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); in wpa_tdls_process_tpk_m1()
2093 if (peer) in wpa_tdls_process_tpk_m1()
2094 wpa_tdls_peer_free(sm, peer); in wpa_tdls_process_tpk_m1()
2099 static int wpa_tdls_enable_link(struct wpa_sm *sm, struct wpa_tdls_peer *peer) in wpa_tdls_enable_link() argument
2101 peer->tpk_success = 1; in wpa_tdls_enable_link()
2102 peer->tpk_in_progress = 0; in wpa_tdls_enable_link()
2103 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer); in wpa_tdls_enable_link()
2105 u32 lifetime = peer->lifetime; in wpa_tdls_enable_link()
2110 if (lifetime > 3 && peer->initiator) in wpa_tdls_enable_link()
2113 sm, peer); in wpa_tdls_enable_link()
2118 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer); in wpa_tdls_enable_link()
2123 if (peer->reconfig_key && wpa_tdls_set_key(sm, peer) < 0) { in wpa_tdls_enable_link()
2128 peer->reconfig_key = 0; in wpa_tdls_enable_link()
2130 return wpa_sm_tdls_oper(sm, TDLS_ENABLE_LINK, peer->addr); in wpa_tdls_enable_link()
2137 struct wpa_tdls_peer *peer; in wpa_tdls_process_tpk_m2() local
2153 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_process_tpk_m2()
2154 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0) in wpa_tdls_process_tpk_m2()
2157 if (peer == NULL) { in wpa_tdls_process_tpk_m2()
2162 if (!peer->initiator) { in wpa_tdls_process_tpk_m2()
2172 wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_REQUEST); in wpa_tdls_process_tpk_m2()
2175 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_process_tpk_m2()
2187 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_process_tpk_m2()
2199 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_process_tpk_m2()
2204 peer->capability = WPA_GET_LE16(pos); in wpa_tdls_process_tpk_m2()
2241 if (copy_supp_rates(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2244 if (copy_peer_ht_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2247 if (copy_peer_vht_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2250 if (copy_peer_ext_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2253 if (copy_peer_supp_channels(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2256 if (copy_peer_supp_oper_classes(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2259 peer->qos_info = kde.qosinfo; in wpa_tdls_process_tpk_m2()
2262 if (copy_peer_wmm_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2265 peer->aid = kde.aid; in wpa_tdls_process_tpk_m2()
2268 peer->rsnie_p_len = 0; in wpa_tdls_process_tpk_m2()
2269 peer->cipher = WPA_CIPHER_NONE; in wpa_tdls_process_tpk_m2()
2295 if (kde.rsn_ie_len != peer->rsnie_i_len || in wpa_tdls_process_tpk_m2()
2296 os_memcmp(peer->rsnie_i, kde.rsn_ie, peer->rsnie_i_len) != 0) { in wpa_tdls_process_tpk_m2()
2300 peer->rsnie_i, peer->rsnie_i_len); in wpa_tdls_process_tpk_m2()
2327 if (!os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) == 0) { in wpa_tdls_process_tpk_m2()
2335 os_memcpy(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN); in wpa_tdls_process_tpk_m2()
2336 os_memcpy(peer->rsnie_p, kde.rsn_ie, kde.rsn_ie_len); in wpa_tdls_process_tpk_m2()
2337 peer->rsnie_p_len = kde.rsn_ie_len; in wpa_tdls_process_tpk_m2()
2338 peer->cipher = cipher; in wpa_tdls_process_tpk_m2()
2350 if (lifetime != peer->lifetime) { in wpa_tdls_process_tpk_m2()
2352 "TPK M2 (expected %u)", lifetime, peer->lifetime); in wpa_tdls_process_tpk_m2()
2357 wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid); in wpa_tdls_process_tpk_m2()
2360 if (wpa_supplicant_verify_tdls_mic(2, peer, (u8 *) lnkid, in wpa_tdls_process_tpk_m2()
2363 wpa_tdls_del_key(sm, peer); in wpa_tdls_process_tpk_m2()
2364 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_process_tpk_m2()
2368 if (wpa_tdls_set_key(sm, peer) < 0) { in wpa_tdls_process_tpk_m2()
2375 peer->reconfig_key = 1; in wpa_tdls_process_tpk_m2()
2379 peer->dtoken = dtoken; in wpa_tdls_process_tpk_m2()
2382 if (wpa_tdls_addset_peer(sm, peer, 0) < 0) in wpa_tdls_process_tpk_m2()
2387 if (wpa_tdls_send_tpk_m3(sm, src_addr, dtoken, lnkid, peer) < 0) in wpa_tdls_process_tpk_m2()
2390 if (!peer->tpk_success) { in wpa_tdls_process_tpk_m2()
2396 ret = wpa_tdls_enable_link(sm, peer); in wpa_tdls_process_tpk_m2()
2400 sm, peer, in wpa_tdls_process_tpk_m2()
2409 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_process_tpk_m2()
2417 struct wpa_tdls_peer *peer; in wpa_tdls_process_tpk_m3() local
2430 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_process_tpk_m3()
2431 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0) in wpa_tdls_process_tpk_m3()
2434 if (peer == NULL) { in wpa_tdls_process_tpk_m3()
2439 wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_RESPONSE); in wpa_tdls_process_tpk_m3()
2498 if (kde.rsn_ie_len != peer->rsnie_p_len || in wpa_tdls_process_tpk_m3()
2499 os_memcmp(kde.rsn_ie, peer->rsnie_p, peer->rsnie_p_len) != 0) { in wpa_tdls_process_tpk_m3()
2505 if (!os_memcmp(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN) == 0) { in wpa_tdls_process_tpk_m3()
2511 if (!os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) == 0) { in wpa_tdls_process_tpk_m3()
2527 if (lifetime != peer->lifetime) { in wpa_tdls_process_tpk_m3()
2529 "TPK M3 (expected %u)", lifetime, peer->lifetime); in wpa_tdls_process_tpk_m3()
2533 if (wpa_supplicant_verify_tdls_mic(3, peer, (u8 *) lnkid, in wpa_tdls_process_tpk_m3()
2535 wpa_tdls_del_key(sm, peer); in wpa_tdls_process_tpk_m3()
2539 if (wpa_tdls_set_key(sm, peer) < 0) { in wpa_tdls_process_tpk_m3()
2546 peer->reconfig_key = 1; in wpa_tdls_process_tpk_m3()
2551 if (wpa_tdls_addset_peer(sm, peer, 0) < 0) in wpa_tdls_process_tpk_m3()
2554 if (!peer->tpk_success) { in wpa_tdls_process_tpk_m3()
2560 ret = wpa_tdls_enable_link(sm, peer); in wpa_tdls_process_tpk_m3()
2568 wpa_tdls_do_teardown(sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); in wpa_tdls_process_tpk_m3()
2598 struct wpa_tdls_peer *peer; in wpa_tdls_start() local
2619 peer = wpa_tdls_add_peer(sm, addr, NULL); in wpa_tdls_start()
2620 if (peer == NULL) in wpa_tdls_start()
2623 if (peer->tpk_in_progress) { in wpa_tdls_start()
2628 peer->initiator = 1; in wpa_tdls_start()
2631 if (wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL, in wpa_tdls_start()
2633 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_start()
2637 peer->tpk_in_progress = 1; in wpa_tdls_start()
2639 if (wpa_tdls_send_tpk_m1(sm, peer) < 0) { in wpa_tdls_start()
2640 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_start()
2650 struct wpa_tdls_peer *peer; in wpa_tdls_remove() local
2655 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_remove()
2656 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_remove()
2660 if (peer == NULL || !peer->tpk_success) in wpa_tdls_remove()
2668 wpa_tdls_do_teardown(sm, peer, in wpa_tdls_remove()
2788 struct wpa_tdls_peer *peer, *tmp; in wpa_tdls_teardown_peers() local
2792 peer = sm->tdls; in wpa_tdls_teardown_peers()
2796 while (peer) { in wpa_tdls_teardown_peers()
2797 tmp = peer->next; in wpa_tdls_teardown_peers()
2799 MAC2STR(peer->addr)); in wpa_tdls_teardown_peers()
2801 wpa_tdls_do_teardown(sm, peer, in wpa_tdls_teardown_peers()
2804 wpa_sm_tdls_oper(sm, TDLS_TEARDOWN, peer->addr); in wpa_tdls_teardown_peers()
2806 peer = tmp; in wpa_tdls_teardown_peers()
2813 struct wpa_tdls_peer *peer, *tmp; in wpa_tdls_remove_peers() local
2815 peer = sm->tdls; in wpa_tdls_remove_peers()
2817 while (peer) { in wpa_tdls_remove_peers()
2819 tmp = peer->next; in wpa_tdls_remove_peers()
2820 res = wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); in wpa_tdls_remove_peers()
2822 MAC2STR(peer->addr), res); in wpa_tdls_remove_peers()
2823 wpa_tdls_peer_free(sm, peer); in wpa_tdls_remove_peers()
2824 peer = tmp; in wpa_tdls_remove_peers()
2937 struct wpa_tdls_peer *peer; in wpa_tdls_enable_chan_switch() local
2955 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_enable_chan_switch()
2956 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_enable_chan_switch()
2960 if (peer == NULL || !peer->tpk_success) { in wpa_tdls_enable_chan_switch()
2966 if (peer->chan_switch_enabled) { in wpa_tdls_enable_chan_switch()
2973 ret = wpa_sm_tdls_enable_channel_switch(sm, peer->addr, in wpa_tdls_enable_chan_switch()
2976 peer->chan_switch_enabled = 1; in wpa_tdls_enable_chan_switch()
2984 struct wpa_tdls_peer *peer; in wpa_tdls_disable_chan_switch() local
2989 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_disable_chan_switch()
2990 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_disable_chan_switch()
2994 if (!peer || !peer->chan_switch_enabled) { in wpa_tdls_disable_chan_switch()
3001 wpa_sm_tdls_disable_channel_switch(sm, peer->addr); in wpa_tdls_disable_chan_switch()
3003 peer->chan_switch_enabled = 0; in wpa_tdls_disable_chan_switch()