Lines Matching refs:peer
85 static void wpa_tdls_peer_free(struct wpa_sm *sm, struct wpa_tdls_peer *peer);
87 struct wpa_tdls_peer *peer);
104 u8 rsnie_p[TDLS_MAX_IE_LEN]; /* Peer RSN IE */
176 static int wpa_tdls_del_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
178 if (wpa_sm_set_key(sm, WPA_ALG_NONE, peer->addr,
189 static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
197 switch (peer->cipher) {
212 if (wpa_sm_set_key(sm, alg, peer->addr, -1, 1,
213 rsc, sizeof(rsc), peer->tpk.tk, key_len) < 0) {
237 struct wpa_tdls_peer *peer;
259 for (peer = sm->tdls; peer; peer = peer->next) {
260 if (os_memcmp(peer->addr, dest, ETH_ALEN) == 0)
264 if (peer == NULL) {
270 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer);
273 peer->sm_tmr.count = TPK_M2_RETRY_COUNT;
274 peer->sm_tmr.timer = TPK_M2_TIMEOUT;
276 peer->sm_tmr.count = TPK_M1_RETRY_COUNT;
277 peer->sm_tmr.timer = TPK_M1_TIMEOUT;
281 os_memcpy(peer->sm_tmr.dest, dest, ETH_ALEN);
282 peer->sm_tmr.action_code = action_code;
283 peer->sm_tmr.dialog_token = dialog_token;
284 peer->sm_tmr.status_code = status_code;
285 peer->sm_tmr.peer_capab = peer_capab;
286 peer->sm_tmr.buf_len = msg_len;
287 os_free(peer->sm_tmr.buf);
288 peer->sm_tmr.buf = os_malloc(msg_len);
289 if (peer->sm_tmr.buf == NULL)
291 os_memcpy(peer->sm_tmr.buf, msg, msg_len);
295 eloop_register_timeout(peer->sm_tmr.timer / 1000,
296 (peer->sm_tmr.timer % 1000) * 1000,
297 wpa_tdls_tpk_retry_timeout, sm, peer);
302 static int wpa_tdls_do_teardown(struct wpa_sm *sm, struct wpa_tdls_peer *peer,
307 ret = wpa_tdls_send_teardown(sm, peer->addr, reason_code);
309 wpa_tdls_disable_peer_link(sm, peer);
319 struct wpa_tdls_peer *peer = timeout_ctx;
321 if (peer->sm_tmr.count) {
322 peer->sm_tmr.count--;
326 peer->sm_tmr.action_code);
328 if (peer->sm_tmr.buf == NULL) {
331 peer->sm_tmr.action_code);
333 peer);
337 /* resend TPK Handshake Message to Peer */
338 if (wpa_tdls_send_tpk_msg(sm, peer->sm_tmr.dest,
339 peer->sm_tmr.action_code,
340 peer->sm_tmr.dialog_token,
341 peer->sm_tmr.status_code,
342 peer->sm_tmr.peer_capab,
343 peer->initiator,
344 peer->sm_tmr.buf,
345 peer->sm_tmr.buf_len)) {
350 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer);
351 eloop_register_timeout(peer->sm_tmr.timer / 1000,
352 (peer->sm_tmr.timer % 1000) * 1000,
353 wpa_tdls_tpk_retry_timeout, sm, peer);
355 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer);
358 wpa_tdls_do_teardown(sm, peer,
365 struct wpa_tdls_peer *peer,
368 if (action_code == peer->sm_tmr.action_code) {
373 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer);
376 os_free(peer->sm_tmr.buf);
377 peer->sm_tmr.buf = NULL;
379 peer->sm_tmr.count = 0;
380 peer->sm_tmr.timer = 0;
381 peer->sm_tmr.buf_len = 0;
382 peer->sm_tmr.action_code = 0xff;
390 static void wpa_tdls_generate_tpk(struct wpa_tdls_peer *peer,
403 if (os_memcmp(peer->inonce, peer->rnonce, WPA_NONCE_LEN) < 0) {
404 nonce[0] = peer->inonce;
405 nonce[1] = peer->rnonce;
407 nonce[0] = peer->rnonce;
408 nonce[1] = peer->inonce;
424 if (os_memcmp(own_addr, peer->addr, ETH_ALEN) < 0) {
426 os_memcpy(data + ETH_ALEN, peer->addr, ETH_ALEN);
428 os_memcpy(data, peer->addr, ETH_ALEN);
435 (u8 *) &peer->tpk, sizeof(peer->tpk));
437 peer->tpk.kck, sizeof(peer->tpk.kck));
439 peer->tpk.tk, sizeof(peer->tpk.tk));
440 peer->tpk_set = 1;
565 struct wpa_tdls_peer *peer,
571 if (peer->tpk_set) {
572 wpa_tdls_ftie_mic(peer->tpk.kck, trans_seq, lnkid,
573 peer->rsnie_p, timeoutie, (u8 *) ftie,
594 u8 trans_seq, u16 rcode, u8 dtoken, struct wpa_tdls_peer *peer,
599 if (peer->tpk_set) {
600 wpa_tdls_key_mic_teardown(peer->tpk.kck, trans_seq, rcode,
619 struct wpa_tdls_peer *peer = timeout_ctx;
629 if (peer->initiator) {
633 " - try to renew", MAC2STR(peer->addr));
634 /* cache the peer address before do_teardown */
635 os_memcpy(addr, peer->addr, ETH_ALEN);
636 wpa_tdls_do_teardown(sm, peer,
641 " - tear down", MAC2STR(peer->addr));
642 wpa_tdls_do_teardown(sm, peer,
649 struct wpa_tdls_peer *peer)
655 while (cur && cur != peer) {
660 if (cur != peer) {
661 wpa_printf(MSG_ERROR, "TDLS: Could not find peer " MACSTR
663 MAC2STR(peer->addr));
668 prev->next = peer->next;
670 sm->tdls = peer->next;
674 static void wpa_tdls_peer_clear(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
676 wpa_printf(MSG_DEBUG, "TDLS: Clear state for peer " MACSTR,
677 MAC2STR(peer->addr));
678 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer);
679 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer);
680 peer->reconfig_key = 0;
681 peer->initiator = 0;
682 peer->tpk_in_progress = 0;
683 os_free(peer->sm_tmr.buf);
684 peer->sm_tmr.buf = NULL;
685 os_free(peer->ht_capabilities);
686 peer->ht_capabilities = NULL;
687 os_free(peer->vht_capabilities);
688 peer->vht_capabilities = NULL;
689 os_free(peer->ext_capab);
690 peer->ext_capab = NULL;
691 os_free(peer->supp_channels);
692 peer->supp_channels = NULL;
693 os_free(peer->supp_oper_classes);
694 peer->supp_oper_classes = NULL;
695 peer->rsnie_i_len = peer->rsnie_p_len = 0;
696 peer->cipher = 0;
697 peer->qos_info = 0;
698 peer->wmm_capable = 0;
699 peer->tpk_set = peer->tpk_success = 0;
700 peer->chan_switch_enabled = 0;
701 os_memset(&peer->tpk, 0, sizeof(peer->tpk));
702 os_memset(peer->inonce, 0, WPA_NONCE_LEN);
703 os_memset(peer->rnonce, 0, WPA_NONCE_LEN);
707 static void wpa_tdls_peer_free(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
709 wpa_tdls_peer_clear(sm, peer);
710 wpa_tdls_peer_remove_from_list(sm, peer);
711 os_free(peer);
715 static void wpa_tdls_linkid(struct wpa_sm *sm, struct wpa_tdls_peer *peer,
721 if (peer->initiator) {
723 os_memcpy(lnkid->resp_sta, peer->addr, ETH_ALEN);
725 os_memcpy(lnkid->init_sta, peer->addr, ETH_ALEN);
734 struct wpa_tdls_peer *peer;
745 for (peer = sm->tdls; peer; peer = peer->next) {
746 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
750 if (peer == NULL) {
757 if (peer->chan_switch_enabled) {
760 wpa_sm_tdls_disable_channel_switch(sm, peer->addr);
763 dialog_token = peer->dtoken;
769 if (wpa_tdls_get_privacy(sm) && peer->tpk_set && peer->tpk_success) {
783 if (!wpa_tdls_get_privacy(sm) || !peer->tpk_set || !peer->tpk_success)
789 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN);
790 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
807 wpa_tdls_linkid(sm, peer, &lnkid);
808 wpa_tdls_key_mic_teardown(peer->tpk.kck, 4, reason_code,
818 reason_code, 0, peer->initiator, rbuf, pos - rbuf);
827 struct wpa_tdls_peer *peer;
832 for (peer = sm->tdls; peer; peer = peer->next) {
833 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
837 if (peer == NULL) {
838 wpa_printf(MSG_DEBUG, "TDLS: Could not find peer " MACSTR
843 if (!peer->tpk_success) {
844 wpa_printf(MSG_DEBUG, "TDLS: Peer " MACSTR
849 return wpa_tdls_do_teardown(sm, peer, reason_code);
854 struct wpa_tdls_peer *peer)
856 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
857 wpa_tdls_peer_free(sm, peer);
863 struct wpa_tdls_peer *peer;
865 for (peer = sm->tdls; peer; peer = peer->next) {
866 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
870 if (!peer || !peer->tpk_success) {
871 wpa_printf(MSG_DEBUG, "TDLS: Peer " MACSTR
882 if (peer->chan_switch_enabled)
883 wpa_sm_tdls_disable_channel_switch(sm, peer->addr);
887 wpa_tdls_peer_free(sm, peer);
889 wpa_tdls_disable_peer_link(sm, peer);
896 struct wpa_tdls_peer *peer;
901 for (peer = sm->tdls; peer; peer = peer->next) {
902 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
906 if (peer == NULL)
907 return "peer does not exist";
909 if (!peer->tpk_success)
910 return "peer not connected";
919 struct wpa_tdls_peer *peer = NULL;
928 for (peer = sm->tdls; peer; peer = peer->next) {
929 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0)
933 if (peer == NULL) {
966 if (!wpa_tdls_get_privacy(sm) || !peer->tpk_set || !peer->tpk_success)
978 peer->dtoken, peer,
990 wpa_tdls_disable_peer_link(sm, peer);
998 * @dst - MAC addr of Peer station
1019 struct wpa_tdls_peer *peer;
1023 for (peer = sm->tdls; peer; peer = peer->next) {
1024 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) {
1027 return peer; /* re-use existing entry */
1031 wpa_printf(MSG_INFO, "TDLS: Creating peer entry for " MACSTR,
1034 peer = os_zalloc(sizeof(*peer));
1035 if (peer == NULL)
1038 os_memcpy(peer->addr, addr, ETH_ALEN);
1039 peer->next = sm->tdls;
1040 sm->tdls = peer;
1042 return peer;
1047 struct wpa_tdls_peer *peer)
1060 peer->rsnie_i_len = 0;
1071 hdr = (struct rsn_ie_hdr *) peer->rsnie_i;
1121 hdr->len = (pos - peer->rsnie_i) - 2;
1122 peer->rsnie_i_len = pos - peer->rsnie_i;
1124 peer->rsnie_i, peer->rsnie_i_len);
1129 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) +
1140 wpa_tdls_peer_free(sm, peer);
1149 pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len);
1155 if (os_get_random(peer->inonce, WPA_NONCE_LEN)) {
1159 wpa_tdls_peer_free(sm, peer);
1163 peer->inonce, WPA_NONCE_LEN);
1164 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
1183 peer->lifetime = TPK_LIFETIME;
1188 peer->lifetime = 301;
1193 peer
1197 sizeof(timeoutie), peer->lifetime);
1198 wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime);
1208 wpa_tdls_linkid(sm, peer, l);
1215 "Handshake Message 1 (peer " MACSTR ")",
1216 MAC2STR(peer->addr));
1218 status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_SETUP_REQUEST,
1219 1, 0, 0, peer->initiator, rbuf, pos - rbuf);
1229 const struct wpa_tdls_peer *peer)
1240 /* Peer RSN IE, FTIE(Initiator Nonce, Responder Nonce),
1242 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) +
1258 /* Peer RSN IE */
1259 pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len);
1264 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN);
1265 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
1284 lifetime = peer->lifetime;
1298 wpa_tdls_ftie_mic(peer->tpk.kck, 2, (u8 *) lnkid, peer->rsnie_p,
1309 dtoken, 0, 0, peer->initiator, rbuf,
1320 const struct wpa_tdls_peer *peer)
1332 /* Peer RSN IE, FTIE(Initiator Nonce, Responder Nonce),
1334 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) +
1350 /* Peer RSN IE */
1351 pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len);
1356 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN);
1357 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
1374 lifetime = peer->lifetime;
1388 wpa_tdls_ftie_mic(peer->tpk.kck, 3, (u8 *) lnkid, peer->rsnie_p,
1399 if (peer->vht_capabilities)
1401 if (peer->ht_capabilities)
1403 if (peer->wmm_capable)
1407 dtoken, 0, peer_capab, peer->initiator,
1416 struct wpa_tdls_peer *peer,
1428 "(peer " MACSTR ")", MAC2STR(peer->addr));
1433 hdr = (struct rsn_ie_hdr *) peer->rsnie_i;
1465 peer->rsnie_i_len = pos - peer->rsnie_i;
1472 /* Peer RSN IE, Lifetime */
1473 buf_len += peer->rsnie_i_len +
1478 wpa_tdls_peer_free(sm, peer);
1486 pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len);
1488 peer->lifetime = TPK_LIFETIME;
1490 sizeof(timeoutie), peer->lifetime);
1491 wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime);
1493 status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_DISCOVERY_RESPONSE,
1507 struct wpa_tdls_peer *peer;
1549 peer = wpa_tdls_add_peer(sm, addr, NULL);
1550 if (peer == NULL)
1553 return wpa_tdls_send_discovery_response(sm, peer, dialog_token);
1562 wpa_printf(MSG_DEBUG, "TDLS: Sending Discovery Request to peer "
1570 struct wpa_tdls_peer *peer)
1576 peer->supp_rates_len = merge_byte_arrays(
1577 peer->supp_rates, sizeof(peer->supp_rates),
1586 struct wpa_tdls_peer *peer)
1594 if (!peer->ht_capabilities) {
1595 peer->ht_capabilities =
1597 if (peer->ht_capabilities == NULL)
1601 os_memcpy(peer->ht_capabilities, kde->ht_capabilities,
1603 wpa_hexdump(MSG_DEBUG, "TDLS: Peer HT capabilities",
1604 (u8 *) peer->ht_capabilities,
1612 struct wpa_tdls_peer *peer)
1620 if (!peer->vht_capabilities) {
1621 peer->vht_capabilities =
1623 if (peer->vht_capabilities == NULL)
1627 os_memcpy(peer->vht_capabilities, kde->vht_capabilities,
1629 wpa_hexdump(MSG_DEBUG, "TDLS: Peer VHT capabilities",
1630 (u8 *) peer->vht_capabilities,
1638 struct wpa_tdls_peer *peer)
1646 if (!peer->ext_capab || peer->ext_capab_len < kde->ext_capab_len - 2) {
1648 os_free(peer->ext_capab);
1649 peer->ext_capab = os_zalloc(kde->ext_capab_len - 2);
1650 if (peer->ext_capab == NULL)
1654 peer->ext_capab_len = kde->ext_capab_len - 2;
1655 os_memcpy(peer->ext_capab, kde->ext_capab + 2, peer->ext_capab_len);
1662 struct wpa_tdls_peer *peer)
1677 peer->qos_info = wmm->qos_info;
1679 peer->wmm_capable = 1;
1681 wpa_printf(MSG_DEBUG, "TDLS: Peer WMM QOS Info 0x%x", peer->qos_info);
1687 struct wpa_tdls_peer *peer)
1694 if (!peer->supp_channels ||
1695 peer->supp_channels_len < kde->supp_channels_len) {
1696 os_free(peer->supp_channels);
1697 peer->supp_channels = os_zalloc(kde->supp_channels_len);
1698 if (peer->supp_channels == NULL)
1702 peer->supp_channels_len = kde->supp_channels_len;
1704 os_memcpy(peer->supp_channels, kde->supp_channels,
1705 peer->supp_channels_len);
1706 wpa_hexdump(MSG_DEBUG, "TDLS: Peer Supported Channels",
1707 (u8 *) peer->supp_channels, peer->supp_channels_len);
1713 struct wpa_tdls_peer *peer)
1720 if (!peer->supp_oper_classes ||
1721 peer->supp_oper_classes_len < kde->supp_oper_classes_len) {
1722 os_free(peer->supp_oper_classes);
1723 peer->supp_oper_classes = os_zalloc(kde->supp_oper_classes_len);
1724 if (peer->supp_oper_classes == NULL)
1728 peer->supp_oper_classes_len = kde->supp_oper_classes_len;
1729 os_memcpy(peer->supp_oper_classes, kde->supp_oper_classes,
1730 peer->supp_oper_classes_len);
1731 wpa_hexdump(MSG_DEBUG, "TDLS: Peer Supported Operating Classes",
1732 (u8 *) peer->supp_oper_classes,
1733 peer->supp_oper_classes_len);
1738 static int wpa_tdls_addset_peer(struct wpa_sm *sm, struct wpa_tdls_peer *peer,
1741 return wpa_sm_tdls_peer_addset(sm, peer->addr, add, peer->aid,
1742 peer->capability,
1743 peer->supp_rates, peer->supp_rates_len,
1744 peer->ht_capabilities,
1745 peer->vht_capabilities,
1746 peer->qos_info, peer->wmm_capable,
1747 peer->ext_capab, peer->ext_capab_len,
1748 peer->supp_channels,
1749 peer->supp_channels_len,
1750 peer->supp_oper_classes,
1751 peer->supp_oper_classes_len);
1758 struct wpa_tdls_peer *peer;
1790 peer = wpa_tdls_add_peer(sm, src_addr, &existing_peer);
1791 if (peer == NULL)
1798 if (peer->tpk_success) {
1802 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
1803 wpa_tdls_peer_clear(sm, peer);
1804 } else if (peer->initiator) {
1814 "from peer with higher address "
1819 "from peer with lower address "
1824 peer->addr);
1825 wpa_tdls_peer_clear(sm, peer);
1831 peer->capability = WPA_GET_LE16(cpos);
1862 if (copy_supp_rates(&kde, peer) < 0)
1865 if (copy_peer_ht_capab(&kde, peer) < 0)
1868 if (copy_peer_vht_capab(&kde, peer) < 0)
1871 if (copy_peer_ext_capab(&kde, peer) < 0)
1874 if (copy_peer_supp_channels(&kde, peer) < 0)
1877 if (copy_peer_supp_oper_classes(&kde, peer) < 0)
1880 peer->qos_info = kde.qosinfo;
1883 if (copy_peer_wmm_capab(&kde, peer) < 0)
1886 peer->aid = kde.aid;
1890 peer = wpa_tdls_add_peer(sm, src_addr, NULL);
1891 if (peer == NULL)
1895 peer->initiator = 1;
1896 wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL,
1898 wpa_tdls_send_tpk_m1(sm, peer);
1982 if (os_memcmp(sm->own_addr, peer->addr, ETH_ALEN) < 0) {
1986 * the peer.
1993 peer->initiator = 0; /* Need to check */
1994 peer->dtoken = dtoken;
1997 peer->rsnie_i_len = 0;
1998 peer->rsnie_p_len = 0;
1999 peer->cipher = WPA_CIPHER_NONE;
2004 os_memcpy(peer->rsnie_i, kde.rsn_ie, kde.rsn_ie_len);
2005 peer->rsnie_i_len = kde.rsn_ie_len;
2006 peer->cipher = cipher;
2008 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) {
2018 os_memcpy(peer->inonce, ftie->Snonce, WPA_NONCE_LEN);
2019 if (os_get_random(peer->rnonce, WPA_NONCE_LEN)) {
2027 /* get version info from RSNIE received from Peer */
2031 /* use min(peer's version, out version) */
2035 hdr = (struct rsn_ie_hdr *) peer->rsnie_p;
2060 hdr->len = (pos - peer->rsnie_p) - 2;
2061 peer->rsnie_p_len = pos - peer->rsnie_p;
2065 os_memcpy(peer->rsnie_p, peer->rsnie_i, peer->rsnie_i_len);
2066 peer->rsnie_p_len = peer->rsnie_i_len;
2069 peer->rsnie_p, peer->rsnie_p_len);
2071 peer->lifetime = lifetime;
2073 wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid);
2081 /* add supported rates, capabilities, and qos_info to the TDLS peer */
2082 if (wpa_tdls_addset_peer(sm, peer, 1) < 0)
2088 peer->tpk_in_progress = 1;
2091 if (wpa_tdls_send_tpk_m2(sm, src_addr, dtoken, lnkid, peer) < 0) {
2092 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
2101 if (peer)
2102 wpa_tdls_peer_free(sm, peer);
2107 static int wpa_tdls_enable_link(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
2109 peer->tpk_success = 1;
2110 peer->tpk_in_progress = 0;
2111 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer);
2113 u32 lifetime = peer->lifetime;
2118 if (lifetime > 3 && peer->initiator)
2121 sm, peer);
2126 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer);
2131 if (peer->reconfig_key && wpa_tdls_set_key(sm, peer) < 0) {
2136 peer->reconfig_key = 0;
2138 return wpa_sm_tdls_oper(sm, TDLS_ENABLE_LINK, peer->addr);
2145 struct wpa_tdls_peer *peer;
2160 "(Peer " MACSTR ")", MAC2STR(src_addr));
2161 for (peer = sm->tdls; peer; peer = peer->next) {
2162 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0)
2165 if (peer == NULL) {
2166 wpa_printf(MSG_INFO, "TDLS: No matching peer found for "
2170 if (!peer->initiator) {
2173 * same time and we accept the TPK M1 from the peer in
2181 if (peer->tpk_success) {
2188 wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_REQUEST);
2191 wpa_tdls_disable_peer_link(sm, peer);
2203 wpa_tdls_disable_peer_link(sm, peer);
2215 wpa_tdls_disable_peer_link(sm, peer);
2220 peer->capability = WPA_GET_LE16(pos);
2257 if (copy_supp_rates(&kde, peer) < 0)
2260 if (copy_peer_ht_capab(&kde, peer) < 0)
2263 if (copy_peer_vht_capab(&kde, peer) < 0)
2266 if (copy_peer_ext_capab(&kde, peer) < 0)
2269 if (copy_peer_supp_channels(&kde, peer) < 0)
2272 if (copy_peer_supp_oper_classes(&kde, peer) < 0)
2275 peer->qos_info = kde.qosinfo;
2278 if (copy_peer_wmm_capab(&kde, peer) < 0)
2281 peer->aid = kde.aid;
2284 peer->rsnie_p_len = 0;
2285 peer->cipher = WPA_CIPHER_NONE;
2311 if (kde.rsn_ie_len != peer->rsnie_i_len ||
2312 os_memcmp(peer->rsnie_i, kde.rsn_ie, peer->rsnie_i_len) != 0) {
2316 peer->rsnie_i, peer->rsnie_i_len);
2343 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) {
2351 os_memcpy(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN);
2352 os_memcpy(peer->rsnie_p, kde.rsn_ie, kde.rsn_ie_len);
2353 peer->rsnie_p_len = kde.rsn_ie_len;
2354 peer->cipher = cipher;
2366 if (lifetime != peer->lifetime) {
2368 "TPK M2 (expected %u)", lifetime, peer->lifetime);
2373 wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid);
2376 if (wpa_supplicant_verify_tdls_mic(2, peer, (u8 *) lnkid,
2379 wpa_tdls_del_key(sm, peer);
2380 wpa_tdls_disable_peer_link(sm, peer);
2384 if (wpa_tdls_set_key(sm, peer) < 0) {
2391 peer->reconfig_key = 1;
2395 peer->dtoken = dtoken;
2397 /* add supported rates, capabilities, and qos_info to the TDLS peer */
2398 if (wpa_tdls_addset_peer(sm, peer, 0) < 0)
2403 if (wpa_tdls_send_tpk_m3(sm, src_addr, dtoken, lnkid, peer) < 0)
2406 if (!peer->tpk_success) {
2412 ret = wpa_tdls_enable_link(sm, peer);
2416 sm, peer,
2426 wpa_tdls_disable_peer_link(sm, peer);
2434 struct wpa_tdls_peer *peer;
2446 "(Peer " MACSTR ")", MAC2STR(src_addr));
2447 for (peer = sm->tdls; peer; peer = peer->next) {
2448 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0)
2451 if (peer == NULL) {
2452 wpa_printf(MSG_INFO, "TDLS: No matching peer found for "
2456 wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_RESPONSE);
2515 if (kde.rsn_ie_len != peer->rsnie_p_len ||
2516 os_memcmp(kde.rsn_ie, peer->rsnie_p, peer->rsnie_p_len) != 0) {
2522 if (os_memcmp(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN) != 0) {
2528 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) {
2544 if (lifetime != peer->lifetime) {
2546 "TPK M3 (expected %u)", lifetime, peer->lifetime);
2550 if (wpa_supplicant_verify_tdls_mic(3, peer, (u8 *) lnkid,
2552 wpa_tdls_del_key(sm, peer);
2556 if (wpa_tdls_set_key(sm, peer) < 0) {
2563 peer->reconfig_key = 1;
2567 /* add supported rates, capabilities, and qos_info to the TDLS peer */
2568 if (wpa_tdls_addset_peer(sm, peer, 0) < 0)
2571 if (!peer->tpk_success) {
2577 ret = wpa_tdls_enable_link(sm, peer);
2585 wpa_tdls_do_teardown(sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED);
2607 * @peer: MAC address of the peer STA
2611 * handshake with the peer.
2615 struct wpa_tdls_peer *peer;
2636 peer = wpa_tdls_add_peer(sm, addr, NULL);
2637 if (peer == NULL)
2640 if (peer->tpk_in_progress) {
2641 wpa_printf(MSG_DEBUG, "TDLS: Setup is already in progress with the peer");
2645 peer->initiator = 1;
2647 /* add the peer to the driver as a "setup in progress" peer */
2648 if (wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL,
2650 wpa_tdls_disable_peer_link(sm, peer);
2654 peer->tpk_in_progress = 1;
2656 if (wpa_tdls_send_tpk_m1(sm, peer) < 0) {
2657 wpa_tdls_disable_peer_link(sm, peer);
2667 struct wpa_tdls_peer *peer;
2672 for (peer = sm->tdls; peer; peer = peer->next) {
2673 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
2677 if (peer == NULL || !peer->tpk_success)
2685 wpa_tdls_do_teardown(sm, peer,
2805 struct wpa_tdls_peer *peer, *tmp;
2809 peer = sm->tdls;
2813 while (peer) {
2814 tmp = peer->next;
2815 wpa_printf(MSG_DEBUG, "TDLS: Tear down peer " MACSTR,
2816 MAC2STR(peer->addr));
2818 wpa_tdls_do_teardown(sm, peer,
2821 wpa_sm_tdls_oper(sm, TDLS_TEARDOWN, peer->addr);
2823 peer = tmp;
2830 struct wpa_tdls_peer *peer, *tmp;
2832 peer = sm->tdls;
2834 while (peer) {
2836 tmp = peer->next;
2837 res = wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
2838 wpa_printf(MSG_DEBUG, "TDLS: Remove peer " MACSTR " (res=%d)",
2839 MAC2STR(peer->addr), res);
2840 wpa_tdls_peer_free(sm, peer);
2841 peer = tmp;
2956 struct wpa_tdls_peer *peer;
2974 for (peer = sm->tdls; peer; peer = peer->next) {
2975 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
2979 if (peerpeer->tpk_success) {
2980 wpa_printf(MSG_ERROR, "TDLS: Peer " MACSTR
2985 if (peer->chan_switch_enabled) {
2986 wpa_printf(MSG_DEBUG, "TDLS: Peer " MACSTR
2992 ret = wpa_sm_tdls_enable_channel_switch(sm, peer->addr,
2995 peer->chan_switch_enabled = 1;
3003 struct wpa_tdls_peer *peer;
3008 for (peer = sm->tdls; peer; peer = peer->next) {
3009 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
3013 if (!peer || !peer->chan_switch_enabled) {
3020 wpa_sm_tdls_disable_channel_switch(sm, peer->addr);
3022 peer->chan_switch_enabled = 0;