Lines Matching refs:peer
86 static void wpa_tdls_peer_free(struct wpa_sm *sm, struct wpa_tdls_peer *peer);
88 struct wpa_tdls_peer *peer);
178 static int wpa_tdls_del_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer) in wpa_tdls_del_key() argument
180 if (wpa_sm_set_key(sm, WPA_ALG_NONE, peer->addr, in wpa_tdls_del_key()
191 static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer) in wpa_tdls_set_key() argument
197 if (peer->tk_set) { in wpa_tdls_set_key()
207 MAC2STR(peer->addr)); in wpa_tdls_set_key()
213 switch (peer->cipher) { in wpa_tdls_set_key()
229 MAC2STR(peer->addr)); in wpa_tdls_set_key()
230 if (wpa_sm_set_key(sm, alg, peer->addr, 0, 1, rsc, sizeof(rsc), in wpa_tdls_set_key()
231 peer->tpk.tk, key_len, in wpa_tdls_set_key()
237 peer->tk_set = 1; in wpa_tdls_set_key()
257 struct wpa_tdls_peer *peer; in wpa_tdls_tpk_send() local
279 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_tpk_send()
280 if (os_memcmp(peer->addr, dest, ETH_ALEN) == 0) in wpa_tdls_tpk_send()
284 if (peer == NULL) { in wpa_tdls_tpk_send()
290 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_send()
293 peer->sm_tmr.count = TPK_M2_RETRY_COUNT; in wpa_tdls_tpk_send()
294 peer->sm_tmr.timer = TPK_M2_TIMEOUT; in wpa_tdls_tpk_send()
296 peer->sm_tmr.count = TPK_M1_RETRY_COUNT; in wpa_tdls_tpk_send()
297 peer->sm_tmr.timer = TPK_M1_TIMEOUT; in wpa_tdls_tpk_send()
301 os_memcpy(peer->sm_tmr.dest, dest, ETH_ALEN); in wpa_tdls_tpk_send()
302 peer->sm_tmr.action_code = action_code; in wpa_tdls_tpk_send()
303 peer->sm_tmr.dialog_token = dialog_token; in wpa_tdls_tpk_send()
304 peer->sm_tmr.status_code = status_code; in wpa_tdls_tpk_send()
305 peer->sm_tmr.peer_capab = peer_capab; in wpa_tdls_tpk_send()
306 peer->sm_tmr.buf_len = msg_len; in wpa_tdls_tpk_send()
307 os_free(peer->sm_tmr.buf); in wpa_tdls_tpk_send()
308 peer->sm_tmr.buf = os_memdup(msg, msg_len); in wpa_tdls_tpk_send()
309 if (peer->sm_tmr.buf == NULL) in wpa_tdls_tpk_send()
314 eloop_register_timeout(peer->sm_tmr.timer / 1000, in wpa_tdls_tpk_send()
315 (peer->sm_tmr.timer % 1000) * 1000, in wpa_tdls_tpk_send()
316 wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_send()
321 static int wpa_tdls_do_teardown(struct wpa_sm *sm, struct wpa_tdls_peer *peer, in wpa_tdls_do_teardown() argument
326 ret = wpa_tdls_send_teardown(sm, peer->addr, reason_code); in wpa_tdls_do_teardown()
328 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_do_teardown()
338 struct wpa_tdls_peer *peer = timeout_ctx; in wpa_tdls_tpk_retry_timeout() local
340 if (peer->sm_tmr.count) { in wpa_tdls_tpk_retry_timeout()
341 peer->sm_tmr.count--; in wpa_tdls_tpk_retry_timeout()
345 peer->sm_tmr.action_code); in wpa_tdls_tpk_retry_timeout()
347 if (peer->sm_tmr.buf == NULL) { in wpa_tdls_tpk_retry_timeout()
350 peer->sm_tmr.action_code); in wpa_tdls_tpk_retry_timeout()
352 peer); in wpa_tdls_tpk_retry_timeout()
357 if (wpa_tdls_send_tpk_msg(sm, peer->sm_tmr.dest, in wpa_tdls_tpk_retry_timeout()
358 peer->sm_tmr.action_code, in wpa_tdls_tpk_retry_timeout()
359 peer->sm_tmr.dialog_token, in wpa_tdls_tpk_retry_timeout()
360 peer->sm_tmr.status_code, in wpa_tdls_tpk_retry_timeout()
361 peer->sm_tmr.peer_capab, in wpa_tdls_tpk_retry_timeout()
362 peer->initiator, in wpa_tdls_tpk_retry_timeout()
363 peer->sm_tmr.buf, in wpa_tdls_tpk_retry_timeout()
364 peer->sm_tmr.buf_len)) { in wpa_tdls_tpk_retry_timeout()
369 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_retry_timeout()
370 eloop_register_timeout(peer->sm_tmr.timer / 1000, in wpa_tdls_tpk_retry_timeout()
371 (peer->sm_tmr.timer % 1000) * 1000, in wpa_tdls_tpk_retry_timeout()
372 wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_retry_timeout()
374 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_retry_timeout()
377 wpa_tdls_do_teardown(sm, peer, in wpa_tdls_tpk_retry_timeout()
384 struct wpa_tdls_peer *peer, in wpa_tdls_tpk_retry_timeout_cancel() argument
387 if (action_code == peer->sm_tmr.action_code) { in wpa_tdls_tpk_retry_timeout_cancel()
392 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_tpk_retry_timeout_cancel()
395 os_free(peer->sm_tmr.buf); in wpa_tdls_tpk_retry_timeout_cancel()
396 peer->sm_tmr.buf = NULL; in wpa_tdls_tpk_retry_timeout_cancel()
398 peer->sm_tmr.count = 0; in wpa_tdls_tpk_retry_timeout_cancel()
399 peer->sm_tmr.timer = 0; in wpa_tdls_tpk_retry_timeout_cancel()
400 peer->sm_tmr.buf_len = 0; in wpa_tdls_tpk_retry_timeout_cancel()
401 peer->sm_tmr.action_code = 0xff; in wpa_tdls_tpk_retry_timeout_cancel()
409 static void wpa_tdls_generate_tpk(struct wpa_tdls_peer *peer, in wpa_tdls_generate_tpk() argument
423 if (os_memcmp(peer->inonce, peer->rnonce, WPA_NONCE_LEN) < 0) { in wpa_tdls_generate_tpk()
424 nonce[0] = peer->inonce; in wpa_tdls_generate_tpk()
425 nonce[1] = peer->rnonce; in wpa_tdls_generate_tpk()
427 nonce[0] = peer->rnonce; in wpa_tdls_generate_tpk()
428 nonce[1] = peer->inonce; in wpa_tdls_generate_tpk()
441 if (os_memcmp(own_addr, peer->addr, ETH_ALEN) < 0) { in wpa_tdls_generate_tpk()
443 os_memcpy(data + ETH_ALEN, peer->addr, ETH_ALEN); in wpa_tdls_generate_tpk()
445 os_memcpy(data, peer->addr, ETH_ALEN); in wpa_tdls_generate_tpk()
452 (u8 *) &peer->tpk, sizeof(peer->tpk)); in wpa_tdls_generate_tpk()
454 peer->tpk.kck, sizeof(peer->tpk.kck)); in wpa_tdls_generate_tpk()
456 peer->tpk.tk, sizeof(peer->tpk.tk)); in wpa_tdls_generate_tpk()
457 peer->tpk_set = 1; in wpa_tdls_generate_tpk()
582 struct wpa_tdls_peer *peer, in wpa_supplicant_verify_tdls_mic() argument
588 if (peer->tpk_set) { in wpa_supplicant_verify_tdls_mic()
589 wpa_tdls_ftie_mic(peer->tpk.kck, trans_seq, lnkid, in wpa_supplicant_verify_tdls_mic()
590 peer->rsnie_p, timeoutie, (u8 *) ftie, in wpa_supplicant_verify_tdls_mic()
611 u8 trans_seq, u16 rcode, u8 dtoken, struct wpa_tdls_peer *peer, in wpa_supplicant_verify_tdls_mic_teardown() argument
616 if (peer->tpk_set) { in wpa_supplicant_verify_tdls_mic_teardown()
617 wpa_tdls_key_mic_teardown(peer->tpk.kck, trans_seq, rcode, in wpa_supplicant_verify_tdls_mic_teardown()
636 struct wpa_tdls_peer *peer = timeout_ctx; in wpa_tdls_tpk_timeout() local
646 if (peer->initiator) { in wpa_tdls_tpk_timeout()
650 " - try to renew", MAC2STR(peer->addr)); in wpa_tdls_tpk_timeout()
652 os_memcpy(addr, peer->addr, ETH_ALEN); in wpa_tdls_tpk_timeout()
653 wpa_tdls_do_teardown(sm, peer, in wpa_tdls_tpk_timeout()
658 " - tear down", MAC2STR(peer->addr)); in wpa_tdls_tpk_timeout()
659 wpa_tdls_do_teardown(sm, peer, in wpa_tdls_tpk_timeout()
666 struct wpa_tdls_peer *peer) in wpa_tdls_peer_remove_from_list() argument
672 while (cur && cur != peer) { in wpa_tdls_peer_remove_from_list()
677 if (cur != peer) { in wpa_tdls_peer_remove_from_list()
680 MAC2STR(peer->addr)); in wpa_tdls_peer_remove_from_list()
685 prev->next = peer->next; in wpa_tdls_peer_remove_from_list()
687 sm->tdls = peer->next; in wpa_tdls_peer_remove_from_list()
691 static void wpa_tdls_peer_clear(struct wpa_sm *sm, struct wpa_tdls_peer *peer) in wpa_tdls_peer_clear() argument
694 MAC2STR(peer->addr)); in wpa_tdls_peer_clear()
695 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer); in wpa_tdls_peer_clear()
696 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); in wpa_tdls_peer_clear()
697 peer->reconfig_key = 0; in wpa_tdls_peer_clear()
698 peer->initiator = 0; in wpa_tdls_peer_clear()
699 peer->tpk_in_progress = 0; in wpa_tdls_peer_clear()
700 os_free(peer->sm_tmr.buf); in wpa_tdls_peer_clear()
701 peer->sm_tmr.buf = NULL; in wpa_tdls_peer_clear()
702 os_free(peer->ht_capabilities); in wpa_tdls_peer_clear()
703 peer->ht_capabilities = NULL; in wpa_tdls_peer_clear()
704 os_free(peer->vht_capabilities); in wpa_tdls_peer_clear()
705 peer->vht_capabilities = NULL; in wpa_tdls_peer_clear()
706 os_free(peer->ext_capab); in wpa_tdls_peer_clear()
707 peer->ext_capab = NULL; in wpa_tdls_peer_clear()
708 os_free(peer->supp_channels); in wpa_tdls_peer_clear()
709 peer->supp_channels = NULL; in wpa_tdls_peer_clear()
710 os_free(peer->supp_oper_classes); in wpa_tdls_peer_clear()
711 peer->supp_oper_classes = NULL; in wpa_tdls_peer_clear()
712 peer->rsnie_i_len = peer->rsnie_p_len = 0; in wpa_tdls_peer_clear()
713 peer->cipher = 0; in wpa_tdls_peer_clear()
714 peer->qos_info = 0; in wpa_tdls_peer_clear()
715 peer->wmm_capable = 0; in wpa_tdls_peer_clear()
716 peer->tk_set = peer->tpk_set = peer->tpk_success = 0; in wpa_tdls_peer_clear()
717 peer->chan_switch_enabled = 0; in wpa_tdls_peer_clear()
718 os_memset(&peer->tpk, 0, sizeof(peer->tpk)); in wpa_tdls_peer_clear()
719 os_memset(peer->inonce, 0, WPA_NONCE_LEN); in wpa_tdls_peer_clear()
720 os_memset(peer->rnonce, 0, WPA_NONCE_LEN); in wpa_tdls_peer_clear()
724 static void wpa_tdls_peer_free(struct wpa_sm *sm, struct wpa_tdls_peer *peer) in wpa_tdls_peer_free() argument
726 wpa_tdls_peer_clear(sm, peer); in wpa_tdls_peer_free()
727 wpa_tdls_peer_remove_from_list(sm, peer); in wpa_tdls_peer_free()
728 os_free(peer); in wpa_tdls_peer_free()
732 static void wpa_tdls_linkid(struct wpa_sm *sm, struct wpa_tdls_peer *peer, in wpa_tdls_linkid() argument
738 if (peer->initiator) { in wpa_tdls_linkid()
740 os_memcpy(lnkid->resp_sta, peer->addr, ETH_ALEN); in wpa_tdls_linkid()
742 os_memcpy(lnkid->init_sta, peer->addr, ETH_ALEN); in wpa_tdls_linkid()
751 struct wpa_tdls_peer *peer; in wpa_tdls_send_teardown() local
762 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_send_teardown()
763 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_send_teardown()
767 if (peer == NULL) { in wpa_tdls_send_teardown()
774 if (peer->chan_switch_enabled) { in wpa_tdls_send_teardown()
777 wpa_sm_tdls_disable_channel_switch(sm, peer->addr); in wpa_tdls_send_teardown()
780 dialog_token = peer->dtoken; in wpa_tdls_send_teardown()
786 if (wpa_tdls_get_privacy(sm) && peer->tpk_set && peer->tpk_success) { in wpa_tdls_send_teardown()
800 if (!wpa_tdls_get_privacy(sm) || !peer->tpk_set || !peer->tpk_success) in wpa_tdls_send_teardown()
806 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN); in wpa_tdls_send_teardown()
807 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); in wpa_tdls_send_teardown()
824 wpa_tdls_linkid(sm, peer, &lnkid); in wpa_tdls_send_teardown()
825 wpa_tdls_key_mic_teardown(peer->tpk.kck, 4, reason_code, in wpa_tdls_send_teardown()
835 reason_code, 0, peer->initiator, rbuf, pos - rbuf); in wpa_tdls_send_teardown()
844 struct wpa_tdls_peer *peer; in wpa_tdls_teardown_link() local
849 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_teardown_link()
850 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_teardown_link()
854 if (peer == NULL) { in wpa_tdls_teardown_link()
860 if (!peer->tpk_success) { in wpa_tdls_teardown_link()
866 return wpa_tdls_do_teardown(sm, peer, reason_code); in wpa_tdls_teardown_link()
871 struct wpa_tdls_peer *peer) in wpa_tdls_disable_peer_link() argument
873 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); in wpa_tdls_disable_peer_link()
874 wpa_tdls_peer_free(sm, peer); in wpa_tdls_disable_peer_link()
880 struct wpa_tdls_peer *peer; in wpa_tdls_disable_unreachable_link() local
882 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_disable_unreachable_link()
883 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_disable_unreachable_link()
887 if (!peer || !peer->tpk_success) { in wpa_tdls_disable_unreachable_link()
899 if (peer->chan_switch_enabled) in wpa_tdls_disable_unreachable_link()
900 wpa_sm_tdls_disable_channel_switch(sm, peer->addr); in wpa_tdls_disable_unreachable_link()
904 wpa_tdls_peer_free(sm, peer); in wpa_tdls_disable_unreachable_link()
906 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_disable_unreachable_link()
913 struct wpa_tdls_peer *peer; in wpa_tdls_get_link_status() local
918 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_get_link_status()
919 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_get_link_status()
923 if (peer == NULL) in wpa_tdls_get_link_status()
926 if (!peer->tpk_success) in wpa_tdls_get_link_status()
936 struct wpa_tdls_peer *peer = NULL; in wpa_tdls_recv_teardown() local
945 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_recv_teardown()
946 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0) in wpa_tdls_recv_teardown()
950 if (peer == NULL) { in wpa_tdls_recv_teardown()
983 if (!wpa_tdls_get_privacy(sm) || !peer->tpk_set || !peer->tpk_success) in wpa_tdls_recv_teardown()
995 peer->dtoken, peer, in wpa_tdls_recv_teardown()
1007 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_recv_teardown()
1036 struct wpa_tdls_peer *peer; in wpa_tdls_add_peer() local
1040 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_add_peer()
1041 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) { in wpa_tdls_add_peer()
1044 return peer; /* re-use existing entry */ in wpa_tdls_add_peer()
1051 peer = os_zalloc(sizeof(*peer)); in wpa_tdls_add_peer()
1052 if (peer == NULL) in wpa_tdls_add_peer()
1055 os_memcpy(peer->addr, addr, ETH_ALEN); in wpa_tdls_add_peer()
1056 peer->next = sm->tdls; in wpa_tdls_add_peer()
1057 sm->tdls = peer; in wpa_tdls_add_peer()
1059 return peer; in wpa_tdls_add_peer()
1064 struct wpa_tdls_peer *peer) in wpa_tdls_send_tpk_m1() argument
1077 peer->rsnie_i_len = 0; in wpa_tdls_send_tpk_m1()
1088 hdr = (struct rsn_ie_hdr *) peer->rsnie_i; in wpa_tdls_send_tpk_m1()
1138 hdr->len = (pos - peer->rsnie_i) - 2; in wpa_tdls_send_tpk_m1()
1139 peer->rsnie_i_len = pos - peer->rsnie_i; in wpa_tdls_send_tpk_m1()
1141 peer->rsnie_i, peer->rsnie_i_len); in wpa_tdls_send_tpk_m1()
1146 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) + in wpa_tdls_send_tpk_m1()
1157 wpa_tdls_peer_free(sm, peer); in wpa_tdls_send_tpk_m1()
1166 pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len); in wpa_tdls_send_tpk_m1()
1172 if (os_get_random(peer->inonce, WPA_NONCE_LEN)) { in wpa_tdls_send_tpk_m1()
1176 wpa_tdls_peer_free(sm, peer); in wpa_tdls_send_tpk_m1()
1179 peer->tk_set = 0; /* A new nonce results in a new TK */ in wpa_tdls_send_tpk_m1()
1181 peer->inonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m1()
1182 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m1()
1201 peer->lifetime = TPK_LIFETIME; in wpa_tdls_send_tpk_m1()
1206 peer->lifetime = 301; in wpa_tdls_send_tpk_m1()
1211 peer->lifetime = 0xffffffff; in wpa_tdls_send_tpk_m1()
1215 sizeof(timeoutie), peer->lifetime); in wpa_tdls_send_tpk_m1()
1216 wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime); in wpa_tdls_send_tpk_m1()
1226 wpa_tdls_linkid(sm, peer, l); in wpa_tdls_send_tpk_m1()
1234 MAC2STR(peer->addr)); in wpa_tdls_send_tpk_m1()
1236 status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_SETUP_REQUEST, in wpa_tdls_send_tpk_m1()
1237 1, 0, 0, peer->initiator, rbuf, pos - rbuf); in wpa_tdls_send_tpk_m1()
1247 const struct wpa_tdls_peer *peer) in wpa_tdls_send_tpk_m2() argument
1260 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) + in wpa_tdls_send_tpk_m2()
1277 pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len); in wpa_tdls_send_tpk_m2()
1282 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m2()
1283 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m2()
1302 lifetime = peer->lifetime; in wpa_tdls_send_tpk_m2()
1316 wpa_tdls_ftie_mic(peer->tpk.kck, 2, (u8 *) lnkid, peer->rsnie_p, in wpa_tdls_send_tpk_m2()
1327 dtoken, 0, 0, peer->initiator, rbuf, in wpa_tdls_send_tpk_m2()
1338 const struct wpa_tdls_peer *peer) in wpa_tdls_send_tpk_m3() argument
1352 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) + in wpa_tdls_send_tpk_m3()
1369 pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len); in wpa_tdls_send_tpk_m3()
1374 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m3()
1375 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); in wpa_tdls_send_tpk_m3()
1392 lifetime = peer->lifetime; in wpa_tdls_send_tpk_m3()
1406 wpa_tdls_ftie_mic(peer->tpk.kck, 3, (u8 *) lnkid, peer->rsnie_p, in wpa_tdls_send_tpk_m3()
1417 if (peer->vht_capabilities) in wpa_tdls_send_tpk_m3()
1419 if (peer->ht_capabilities) in wpa_tdls_send_tpk_m3()
1421 if (peer->wmm_capable) in wpa_tdls_send_tpk_m3()
1425 dtoken, 0, peer_capab, peer->initiator, in wpa_tdls_send_tpk_m3()
1434 struct wpa_tdls_peer *peer, in wpa_tdls_send_discovery_response() argument
1446 "(peer " MACSTR ")", MAC2STR(peer->addr)); in wpa_tdls_send_discovery_response()
1451 hdr = (struct rsn_ie_hdr *) peer->rsnie_i; in wpa_tdls_send_discovery_response()
1483 peer->rsnie_i_len = pos - peer->rsnie_i; in wpa_tdls_send_discovery_response()
1491 buf_len += peer->rsnie_i_len + in wpa_tdls_send_discovery_response()
1496 wpa_tdls_peer_free(sm, peer); in wpa_tdls_send_discovery_response()
1504 pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len); in wpa_tdls_send_discovery_response()
1506 peer->lifetime = TPK_LIFETIME; in wpa_tdls_send_discovery_response()
1508 sizeof(timeoutie), peer->lifetime); in wpa_tdls_send_discovery_response()
1509 wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime); in wpa_tdls_send_discovery_response()
1511 status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_DISCOVERY_RESPONSE, in wpa_tdls_send_discovery_response()
1525 struct wpa_tdls_peer *peer; in wpa_tdls_process_discovery_request() local
1567 peer = wpa_tdls_add_peer(sm, addr, NULL); in wpa_tdls_process_discovery_request()
1568 if (peer == NULL) in wpa_tdls_process_discovery_request()
1571 return wpa_tdls_send_discovery_response(sm, peer, dialog_token); in wpa_tdls_process_discovery_request()
1588 struct wpa_tdls_peer *peer) in copy_supp_rates() argument
1594 peer->supp_rates_len = merge_byte_arrays( in copy_supp_rates()
1595 peer->supp_rates, sizeof(peer->supp_rates), in copy_supp_rates()
1604 struct wpa_tdls_peer *peer) in copy_peer_ht_capab() argument
1612 if (!peer->ht_capabilities) { in copy_peer_ht_capab()
1613 peer->ht_capabilities = in copy_peer_ht_capab()
1615 if (peer->ht_capabilities == NULL) in copy_peer_ht_capab()
1619 os_memcpy(peer->ht_capabilities, kde->ht_capabilities, in copy_peer_ht_capab()
1622 (u8 *) peer->ht_capabilities, in copy_peer_ht_capab()
1630 struct wpa_tdls_peer *peer) in copy_peer_vht_capab() argument
1638 if (!peer->vht_capabilities) { in copy_peer_vht_capab()
1639 peer->vht_capabilities = in copy_peer_vht_capab()
1641 if (peer->vht_capabilities == NULL) in copy_peer_vht_capab()
1645 os_memcpy(peer->vht_capabilities, kde->vht_capabilities, in copy_peer_vht_capab()
1648 (u8 *) peer->vht_capabilities, in copy_peer_vht_capab()
1656 struct wpa_tdls_peer *peer) in copy_peer_ext_capab() argument
1664 if (!peer->ext_capab || peer->ext_capab_len < kde->ext_capab_len - 2) { in copy_peer_ext_capab()
1666 os_free(peer->ext_capab); in copy_peer_ext_capab()
1667 peer->ext_capab = os_zalloc(kde->ext_capab_len - 2); in copy_peer_ext_capab()
1668 if (peer->ext_capab == NULL) in copy_peer_ext_capab()
1672 peer->ext_capab_len = kde->ext_capab_len - 2; in copy_peer_ext_capab()
1673 os_memcpy(peer->ext_capab, kde->ext_capab + 2, peer->ext_capab_len); in copy_peer_ext_capab()
1680 struct wpa_tdls_peer *peer) in copy_peer_wmm_capab() argument
1695 peer->qos_info = wmm->qos_info; in copy_peer_wmm_capab()
1697 peer->wmm_capable = 1; in copy_peer_wmm_capab()
1699 wpa_printf(MSG_DEBUG, "TDLS: Peer WMM QOS Info 0x%x", peer->qos_info); in copy_peer_wmm_capab()
1705 struct wpa_tdls_peer *peer) in copy_peer_supp_channels() argument
1712 if (!peer->supp_channels || in copy_peer_supp_channels()
1713 peer->supp_channels_len < kde->supp_channels_len) { in copy_peer_supp_channels()
1714 os_free(peer->supp_channels); in copy_peer_supp_channels()
1715 peer->supp_channels = os_zalloc(kde->supp_channels_len); in copy_peer_supp_channels()
1716 if (peer->supp_channels == NULL) in copy_peer_supp_channels()
1720 peer->supp_channels_len = kde->supp_channels_len; in copy_peer_supp_channels()
1722 os_memcpy(peer->supp_channels, kde->supp_channels, in copy_peer_supp_channels()
1723 peer->supp_channels_len); in copy_peer_supp_channels()
1725 (u8 *) peer->supp_channels, peer->supp_channels_len); in copy_peer_supp_channels()
1731 struct wpa_tdls_peer *peer) in copy_peer_supp_oper_classes() argument
1738 if (!peer->supp_oper_classes || in copy_peer_supp_oper_classes()
1739 peer->supp_oper_classes_len < kde->supp_oper_classes_len) { in copy_peer_supp_oper_classes()
1740 os_free(peer->supp_oper_classes); in copy_peer_supp_oper_classes()
1741 peer->supp_oper_classes = os_zalloc(kde->supp_oper_classes_len); in copy_peer_supp_oper_classes()
1742 if (peer->supp_oper_classes == NULL) in copy_peer_supp_oper_classes()
1746 peer->supp_oper_classes_len = kde->supp_oper_classes_len; in copy_peer_supp_oper_classes()
1747 os_memcpy(peer->supp_oper_classes, kde->supp_oper_classes, in copy_peer_supp_oper_classes()
1748 peer->supp_oper_classes_len); in copy_peer_supp_oper_classes()
1750 (u8 *) peer->supp_oper_classes, in copy_peer_supp_oper_classes()
1751 peer->supp_oper_classes_len); in copy_peer_supp_oper_classes()
1756 static int wpa_tdls_addset_peer(struct wpa_sm *sm, struct wpa_tdls_peer *peer, in wpa_tdls_addset_peer() argument
1759 return wpa_sm_tdls_peer_addset(sm, peer->addr, add, peer->aid, in wpa_tdls_addset_peer()
1760 peer->capability, in wpa_tdls_addset_peer()
1761 peer->supp_rates, peer->supp_rates_len, in wpa_tdls_addset_peer()
1762 peer->ht_capabilities, in wpa_tdls_addset_peer()
1763 peer->vht_capabilities, in wpa_tdls_addset_peer()
1764 peer->qos_info, peer->wmm_capable, in wpa_tdls_addset_peer()
1765 peer->ext_capab, peer->ext_capab_len, in wpa_tdls_addset_peer()
1766 peer->supp_channels, in wpa_tdls_addset_peer()
1767 peer->supp_channels_len, in wpa_tdls_addset_peer()
1768 peer->supp_oper_classes, in wpa_tdls_addset_peer()
1769 peer->supp_oper_classes_len); in wpa_tdls_addset_peer()
1789 struct wpa_tdls_peer *peer; in wpa_tdls_process_tpk_m1() local
1821 peer = wpa_tdls_add_peer(sm, src_addr, &existing_peer); in wpa_tdls_process_tpk_m1()
1822 if (peer == NULL) in wpa_tdls_process_tpk_m1()
1829 if (peer->tpk_success) { in wpa_tdls_process_tpk_m1()
1833 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); in wpa_tdls_process_tpk_m1()
1834 wpa_tdls_peer_clear(sm, peer); in wpa_tdls_process_tpk_m1()
1835 } else if (peer->initiator) { in wpa_tdls_process_tpk_m1()
1855 peer->addr); in wpa_tdls_process_tpk_m1()
1856 wpa_tdls_peer_clear(sm, peer); in wpa_tdls_process_tpk_m1()
1862 peer->capability = WPA_GET_LE16(cpos); in wpa_tdls_process_tpk_m1()
1893 if (copy_supp_rates(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1896 if (copy_peer_ht_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1899 if (copy_peer_vht_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1902 if (copy_peer_ext_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1905 if (copy_peer_supp_channels(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1908 if (copy_peer_supp_oper_classes(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1911 peer->qos_info = kde.qosinfo; in wpa_tdls_process_tpk_m1()
1914 if (copy_peer_wmm_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m1()
1917 peer->aid = kde.aid; in wpa_tdls_process_tpk_m1()
1921 peer = wpa_tdls_add_peer(sm, src_addr, NULL); in wpa_tdls_process_tpk_m1()
1922 if (peer == NULL) in wpa_tdls_process_tpk_m1()
1926 peer->initiator = 1; in wpa_tdls_process_tpk_m1()
1927 wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL, in wpa_tdls_process_tpk_m1()
1929 if (wpa_tdls_send_tpk_m1(sm, peer) == -2) { in wpa_tdls_process_tpk_m1()
1930 peer = NULL; in wpa_tdls_process_tpk_m1()
2016 if (os_memcmp(sm->own_addr, peer->addr, ETH_ALEN) < 0) { in wpa_tdls_process_tpk_m1()
2027 peer->initiator = 0; /* Need to check */ in wpa_tdls_process_tpk_m1()
2028 peer->dtoken = dtoken; in wpa_tdls_process_tpk_m1()
2031 peer->rsnie_i_len = 0; in wpa_tdls_process_tpk_m1()
2032 peer->rsnie_p_len = 0; in wpa_tdls_process_tpk_m1()
2033 peer->cipher = WPA_CIPHER_NONE; in wpa_tdls_process_tpk_m1()
2038 os_memcpy(peer->rsnie_i, kde.rsn_ie, kde.rsn_ie_len); in wpa_tdls_process_tpk_m1()
2039 peer->rsnie_i_len = kde.rsn_ie_len; in wpa_tdls_process_tpk_m1()
2040 peer->cipher = cipher; in wpa_tdls_process_tpk_m1()
2042 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0 || in wpa_tdls_process_tpk_m1()
2043 !tdls_nonce_set(peer->inonce)) { in wpa_tdls_process_tpk_m1()
2053 os_memcpy(peer->inonce, ftie->Snonce, WPA_NONCE_LEN); in wpa_tdls_process_tpk_m1()
2054 if (os_get_random(peer->rnonce, WPA_NONCE_LEN)) { in wpa_tdls_process_tpk_m1()
2059 peer->tk_set = 0; /* A new nonce results in a new TK */ in wpa_tdls_process_tpk_m1()
2071 hdr = (struct rsn_ie_hdr *) peer->rsnie_p; in wpa_tdls_process_tpk_m1()
2096 hdr->len = (pos - peer->rsnie_p) - 2; in wpa_tdls_process_tpk_m1()
2097 peer->rsnie_p_len = pos - peer->rsnie_p; in wpa_tdls_process_tpk_m1()
2101 os_memcpy(peer->rsnie_p, peer->rsnie_i, peer->rsnie_i_len); in wpa_tdls_process_tpk_m1()
2102 peer->rsnie_p_len = peer->rsnie_i_len; in wpa_tdls_process_tpk_m1()
2105 peer->rsnie_p, peer->rsnie_p_len); in wpa_tdls_process_tpk_m1()
2107 peer->lifetime = lifetime; in wpa_tdls_process_tpk_m1()
2109 wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid); in wpa_tdls_process_tpk_m1()
2118 if (wpa_tdls_addset_peer(sm, peer, 1) < 0) in wpa_tdls_process_tpk_m1()
2124 peer->tpk_in_progress = 1; in wpa_tdls_process_tpk_m1()
2127 if (wpa_tdls_send_tpk_m2(sm, src_addr, dtoken, lnkid, peer) < 0) { in wpa_tdls_process_tpk_m1()
2128 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); in wpa_tdls_process_tpk_m1()
2135 wpa_tdls_send_tpk_m2(sm, src_addr, dtoken, lnkid, peer); in wpa_tdls_process_tpk_m1()
2144 if (peer) in wpa_tdls_process_tpk_m1()
2145 wpa_tdls_peer_free(sm, peer); in wpa_tdls_process_tpk_m1()
2150 static int wpa_tdls_enable_link(struct wpa_sm *sm, struct wpa_tdls_peer *peer) in wpa_tdls_enable_link() argument
2152 peer->tpk_success = 1; in wpa_tdls_enable_link()
2153 peer->tpk_in_progress = 0; in wpa_tdls_enable_link()
2154 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer); in wpa_tdls_enable_link()
2156 u32 lifetime = peer->lifetime; in wpa_tdls_enable_link()
2161 if (lifetime > 3 && peer->initiator) in wpa_tdls_enable_link()
2164 sm, peer); in wpa_tdls_enable_link()
2169 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer); in wpa_tdls_enable_link()
2174 if (peer->reconfig_key && wpa_tdls_set_key(sm, peer) < 0) { in wpa_tdls_enable_link()
2179 peer->reconfig_key = 0; in wpa_tdls_enable_link()
2181 return wpa_sm_tdls_oper(sm, TDLS_ENABLE_LINK, peer->addr); in wpa_tdls_enable_link()
2188 struct wpa_tdls_peer *peer; in wpa_tdls_process_tpk_m2() local
2204 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_process_tpk_m2()
2205 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0) in wpa_tdls_process_tpk_m2()
2208 if (peer == NULL) { in wpa_tdls_process_tpk_m2()
2213 if (!peer->initiator) { in wpa_tdls_process_tpk_m2()
2224 if (peer->tpk_success) { in wpa_tdls_process_tpk_m2()
2231 wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_REQUEST); in wpa_tdls_process_tpk_m2()
2234 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_process_tpk_m2()
2246 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_process_tpk_m2()
2258 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_process_tpk_m2()
2263 peer->capability = WPA_GET_LE16(pos); in wpa_tdls_process_tpk_m2()
2300 if (copy_supp_rates(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2303 if (copy_peer_ht_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2306 if (copy_peer_vht_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2309 if (copy_peer_ext_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2312 if (copy_peer_supp_channels(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2315 if (copy_peer_supp_oper_classes(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2318 peer->qos_info = kde.qosinfo; in wpa_tdls_process_tpk_m2()
2321 if (copy_peer_wmm_capab(&kde, peer) < 0) in wpa_tdls_process_tpk_m2()
2324 peer->aid = kde.aid; in wpa_tdls_process_tpk_m2()
2327 peer->rsnie_p_len = 0; in wpa_tdls_process_tpk_m2()
2328 peer->cipher = WPA_CIPHER_NONE; in wpa_tdls_process_tpk_m2()
2354 if (kde.rsn_ie_len != peer->rsnie_i_len || in wpa_tdls_process_tpk_m2()
2355 os_memcmp(peer->rsnie_i, kde.rsn_ie, peer->rsnie_i_len) != 0) { in wpa_tdls_process_tpk_m2()
2359 peer->rsnie_i, peer->rsnie_i_len); in wpa_tdls_process_tpk_m2()
2386 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) { in wpa_tdls_process_tpk_m2()
2394 os_memcpy(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN); in wpa_tdls_process_tpk_m2()
2395 os_memcpy(peer->rsnie_p, kde.rsn_ie, kde.rsn_ie_len); in wpa_tdls_process_tpk_m2()
2396 peer->rsnie_p_len = kde.rsn_ie_len; in wpa_tdls_process_tpk_m2()
2397 peer->cipher = cipher; in wpa_tdls_process_tpk_m2()
2409 if (lifetime != peer->lifetime) { in wpa_tdls_process_tpk_m2()
2411 "TPK M2 (expected %u)", lifetime, peer->lifetime); in wpa_tdls_process_tpk_m2()
2416 wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid); in wpa_tdls_process_tpk_m2()
2419 if (wpa_supplicant_verify_tdls_mic(2, peer, (u8 *) lnkid, in wpa_tdls_process_tpk_m2()
2422 wpa_tdls_del_key(sm, peer); in wpa_tdls_process_tpk_m2()
2423 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_process_tpk_m2()
2427 if (wpa_tdls_set_key(sm, peer) < 0) { in wpa_tdls_process_tpk_m2()
2434 peer->reconfig_key = 1; in wpa_tdls_process_tpk_m2()
2438 peer->dtoken = dtoken; in wpa_tdls_process_tpk_m2()
2441 if (wpa_tdls_addset_peer(sm, peer, 0) < 0) in wpa_tdls_process_tpk_m2()
2446 if (wpa_tdls_send_tpk_m3(sm, src_addr, dtoken, lnkid, peer) < 0) in wpa_tdls_process_tpk_m2()
2449 if (!peer->tpk_success) { in wpa_tdls_process_tpk_m2()
2455 ret = wpa_tdls_enable_link(sm, peer); in wpa_tdls_process_tpk_m2()
2459 sm, peer, in wpa_tdls_process_tpk_m2()
2469 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_process_tpk_m2()
2477 struct wpa_tdls_peer *peer; in wpa_tdls_process_tpk_m3() local
2490 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_process_tpk_m3()
2491 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0) in wpa_tdls_process_tpk_m3()
2494 if (peer == NULL) { in wpa_tdls_process_tpk_m3()
2499 wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_RESPONSE); in wpa_tdls_process_tpk_m3()
2558 if (kde.rsn_ie_len != peer->rsnie_p_len || in wpa_tdls_process_tpk_m3()
2559 os_memcmp(kde.rsn_ie, peer->rsnie_p, peer->rsnie_p_len) != 0) { in wpa_tdls_process_tpk_m3()
2565 if (os_memcmp(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN) != 0) { in wpa_tdls_process_tpk_m3()
2571 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) { in wpa_tdls_process_tpk_m3()
2587 if (lifetime != peer->lifetime) { in wpa_tdls_process_tpk_m3()
2589 "TPK M3 (expected %u)", lifetime, peer->lifetime); in wpa_tdls_process_tpk_m3()
2593 if (wpa_supplicant_verify_tdls_mic(3, peer, (u8 *) lnkid, in wpa_tdls_process_tpk_m3()
2595 wpa_tdls_del_key(sm, peer); in wpa_tdls_process_tpk_m3()
2599 if (wpa_tdls_set_key(sm, peer) < 0) { in wpa_tdls_process_tpk_m3()
2606 peer->reconfig_key = 1; in wpa_tdls_process_tpk_m3()
2611 if (wpa_tdls_addset_peer(sm, peer, 0) < 0) in wpa_tdls_process_tpk_m3()
2614 if (!peer->tpk_success) { in wpa_tdls_process_tpk_m3()
2620 ret = wpa_tdls_enable_link(sm, peer); in wpa_tdls_process_tpk_m3()
2628 wpa_tdls_do_teardown(sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); in wpa_tdls_process_tpk_m3()
2658 struct wpa_tdls_peer *peer; in wpa_tdls_start() local
2680 peer = wpa_tdls_add_peer(sm, addr, NULL); in wpa_tdls_start()
2681 if (peer == NULL) in wpa_tdls_start()
2684 if (peer->tpk_in_progress) { in wpa_tdls_start()
2689 peer->initiator = 1; in wpa_tdls_start()
2692 if (wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL, in wpa_tdls_start()
2694 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_start()
2698 peer->tpk_in_progress = 1; in wpa_tdls_start()
2700 res = wpa_tdls_send_tpk_m1(sm, peer); in wpa_tdls_start()
2703 wpa_tdls_disable_peer_link(sm, peer); in wpa_tdls_start()
2713 struct wpa_tdls_peer *peer; in wpa_tdls_remove() local
2718 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_remove()
2719 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_remove()
2723 if (peer == NULL || !peer->tpk_success) in wpa_tdls_remove()
2731 wpa_tdls_do_teardown(sm, peer, in wpa_tdls_remove()
2856 struct wpa_tdls_peer *peer, *tmp; in wpa_tdls_teardown_peers() local
2860 peer = sm->tdls; in wpa_tdls_teardown_peers()
2864 while (peer) { in wpa_tdls_teardown_peers()
2865 tmp = peer->next; in wpa_tdls_teardown_peers()
2867 MAC2STR(peer->addr)); in wpa_tdls_teardown_peers()
2869 wpa_tdls_do_teardown(sm, peer, in wpa_tdls_teardown_peers()
2872 wpa_sm_tdls_oper(sm, TDLS_TEARDOWN, peer->addr); in wpa_tdls_teardown_peers()
2874 peer = tmp; in wpa_tdls_teardown_peers()
2881 struct wpa_tdls_peer *peer, *tmp; in wpa_tdls_remove_peers() local
2883 peer = sm->tdls; in wpa_tdls_remove_peers()
2885 while (peer) { in wpa_tdls_remove_peers()
2887 tmp = peer->next; in wpa_tdls_remove_peers()
2888 res = wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); in wpa_tdls_remove_peers()
2890 MAC2STR(peer->addr), res); in wpa_tdls_remove_peers()
2891 wpa_tdls_peer_free(sm, peer); in wpa_tdls_remove_peers()
2892 peer = tmp; in wpa_tdls_remove_peers()
3007 struct wpa_tdls_peer *peer; in wpa_tdls_enable_chan_switch() local
3025 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_enable_chan_switch()
3026 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_enable_chan_switch()
3030 if (peer == NULL || !peer->tpk_success) { in wpa_tdls_enable_chan_switch()
3036 if (peer->chan_switch_enabled) { in wpa_tdls_enable_chan_switch()
3043 ret = wpa_sm_tdls_enable_channel_switch(sm, peer->addr, in wpa_tdls_enable_chan_switch()
3046 peer->chan_switch_enabled = 1; in wpa_tdls_enable_chan_switch()
3054 struct wpa_tdls_peer *peer; in wpa_tdls_disable_chan_switch() local
3059 for (peer = sm->tdls; peer; peer = peer->next) { in wpa_tdls_disable_chan_switch()
3060 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) in wpa_tdls_disable_chan_switch()
3064 if (!peer || !peer->chan_switch_enabled) { in wpa_tdls_disable_chan_switch()
3071 wpa_sm_tdls_disable_channel_switch(sm, peer->addr); in wpa_tdls_disable_chan_switch()
3073 peer->chan_switch_enabled = 0; in wpa_tdls_disable_chan_switch()