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);
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);
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) {
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) {
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);
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->lifetime = 0xffffffff;
1197 sizeof(timeoutie), peer->lifetime);
1198 wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime);
1207 wpa_tdls_linkid(sm, peer, l);
1214 "Handshake Message 1 (peer " MACSTR ")",
1215 MAC2STR(peer->addr));
1217 status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_SETUP_REQUEST,
1218 1, 0, 0, peer->initiator, rbuf, pos - rbuf);
1228 const struct wpa_tdls_peer *peer)
1241 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) +
1258 pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len);
1263 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN);
1264 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
1283 lifetime = peer->lifetime;
1297 wpa_tdls_ftie_mic(peer->tpk.kck, 2, (u8 *) lnkid, peer->rsnie_p,
1308 dtoken, 0, 0, peer->initiator, rbuf,
1319 const struct wpa_tdls_peer *peer)
1333 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) +
1350 pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len);
1355 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN);
1356 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
1373 lifetime = peer->lifetime;
1387 wpa_tdls_ftie_mic(peer->tpk.kck, 3, (u8 *) lnkid, peer->rsnie_p,
1398 if (peer->vht_capabilities)
1400 if (peer->ht_capabilities)
1402 if (peer->wmm_capable)
1406 dtoken, 0, peer_capab, peer->initiator,
1415 struct wpa_tdls_peer *peer,
1427 "(peer " MACSTR ")", MAC2STR(peer->addr));
1432 hdr = (struct rsn_ie_hdr *) peer->rsnie_i;
1464 peer->rsnie_i_len = pos - peer->rsnie_i;
1472 buf_len += peer->rsnie_i_len +
1477 wpa_tdls_peer_free(sm, peer);
1485 pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len);
1487 peer->lifetime = TPK_LIFETIME;
1489 sizeof(timeoutie), peer->lifetime);
1490 wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime);
1492 status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_DISCOVERY_RESPONSE,
1506 struct wpa_tdls_peer *peer;
1548 peer = wpa_tdls_add_peer(sm, addr, NULL);
1549 if (peer == NULL)
1552 return wpa_tdls_send_discovery_response(sm, peer, dialog_token);
1561 wpa_printf(MSG_DEBUG, "TDLS: Sending Discovery Request to peer "
1569 struct wpa_tdls_peer *peer)
1575 peer->supp_rates_len = merge_byte_arrays(
1576 peer->supp_rates, sizeof(peer->supp_rates),
1585 struct wpa_tdls_peer *peer)
1593 if (!peer->ht_capabilities) {
1594 peer->ht_capabilities =
1596 if (peer->ht_capabilities == NULL)
1600 os_memcpy(peer->ht_capabilities, kde->ht_capabilities,
1603 (u8 *) peer->ht_capabilities,
1611 struct wpa_tdls_peer *peer)
1619 if (!peer->vht_capabilities) {
1620 peer->vht_capabilities =
1622 if (peer->vht_capabilities == NULL)
1626 os_memcpy(peer->vht_capabilities, kde->vht_capabilities,
1629 (u8 *) peer->vht_capabilities,
1637 struct wpa_tdls_peer *peer)
1645 if (!peer->ext_capab || peer->ext_capab_len < kde->ext_capab_len - 2) {
1647 os_free(peer->ext_capab);
1648 peer->ext_capab = os_zalloc(kde->ext_capab_len - 2);
1649 if (peer->ext_capab == NULL)
1653 peer->ext_capab_len = kde->ext_capab_len - 2;
1654 os_memcpy(peer->ext_capab, kde->ext_capab + 2, peer->ext_capab_len);
1661 struct wpa_tdls_peer *peer)
1676 peer->qos_info = wmm->qos_info;
1678 peer->wmm_capable = 1;
1680 wpa_printf(MSG_DEBUG, "TDLS: Peer WMM QOS Info 0x%x", peer->qos_info);
1686 struct wpa_tdls_peer *peer)
1693 if (!peer->supp_channels ||
1694 peer->supp_channels_len < kde->supp_channels_len) {
1695 os_free(peer->supp_channels);
1696 peer->supp_channels = os_zalloc(kde->supp_channels_len);
1697 if (peer->supp_channels == NULL)
1701 peer->supp_channels_len = kde->supp_channels_len;
1703 os_memcpy(peer->supp_channels, kde->supp_channels,
1704 peer->supp_channels_len);
1706 (u8 *) peer->supp_channels, peer->supp_channels_len);
1712 struct wpa_tdls_peer *peer)
1719 if (!peer->supp_oper_classes ||
1720 peer->supp_oper_classes_len < kde->supp_oper_classes_len) {
1721 os_free(peer->supp_oper_classes);
1722 peer->supp_oper_classes = os_zalloc(kde->supp_oper_classes_len);
1723 if (peer->supp_oper_classes == NULL)
1727 peer->supp_oper_classes_len = kde->supp_oper_classes_len;
1728 os_memcpy(peer->supp_oper_classes, kde->supp_oper_classes,
1729 peer->supp_oper_classes_len);
1731 (u8 *) peer->supp_oper_classes,
1732 peer->supp_oper_classes_len);
1737 static int wpa_tdls_addset_peer(struct wpa_sm *sm, struct wpa_tdls_peer *peer,
1740 return wpa_sm_tdls_peer_addset(sm, peer->addr, add, peer->aid,
1741 peer->capability,
1742 peer->supp_rates, peer->supp_rates_len,
1743 peer->ht_capabilities,
1744 peer->vht_capabilities,
1745 peer->qos_info, peer->wmm_capable,
1746 peer->ext_capab, peer->ext_capab_len,
1747 peer->supp_channels,
1748 peer->supp_channels_len,
1749 peer->supp_oper_classes,
1750 peer->supp_oper_classes_len);
1757 struct wpa_tdls_peer *peer;
1789 peer = wpa_tdls_add_peer(sm, src_addr, &existing_peer);
1790 if (peer == NULL)
1797 if (peer->tpk_success) {
1801 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
1802 wpa_tdls_peer_clear(sm, peer);
1803 } else if (peer->initiator) {
1813 "from peer with higher address "
1818 "from peer with lower address "
1823 peer->addr);
1824 wpa_tdls_peer_clear(sm, peer);
1830 peer->capability = WPA_GET_LE16(cpos);
1861 if (copy_supp_rates(&kde, peer) < 0)
1864 if (copy_peer_ht_capab(&kde, peer) < 0)
1867 if (copy_peer_vht_capab(&kde, peer) < 0)
1870 if (copy_peer_ext_capab(&kde, peer) < 0)
1873 if (copy_peer_supp_channels(&kde, peer) < 0)
1876 if (copy_peer_supp_oper_classes(&kde, peer) < 0)
1879 peer->qos_info = kde.qosinfo;
1882 if (copy_peer_wmm_capab(&kde, peer) < 0)
1885 peer->aid = kde.aid;
1889 peer = wpa_tdls_add_peer(sm, src_addr, NULL);
1890 if (peer == NULL)
1894 peer->initiator = 1;
1895 wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL,
1897 wpa_tdls_send_tpk_m1(sm, peer);
1981 if (os_memcmp(sm->own_addr, peer->addr, ETH_ALEN) < 0) {
1985 * the peer.
1992 peer->initiator = 0; /* Need to check */
1993 peer->dtoken = dtoken;
1996 peer->rsnie_i_len = 0;
1997 peer->rsnie_p_len = 0;
1998 peer->cipher = WPA_CIPHER_NONE;
2003 os_memcpy(peer->rsnie_i, kde.rsn_ie, kde.rsn_ie_len);
2004 peer->rsnie_i_len = kde.rsn_ie_len;
2005 peer->cipher = cipher;
2007 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) {
2017 os_memcpy(peer->inonce, ftie->Snonce, WPA_NONCE_LEN);
2018 if (os_get_random(peer->rnonce, WPA_NONCE_LEN)) {
2030 /* use min(peer's version, out version) */
2034 hdr = (struct rsn_ie_hdr *) peer->rsnie_p;
2059 hdr->len = (pos - peer->rsnie_p) - 2;
2060 peer->rsnie_p_len = pos - peer->rsnie_p;
2064 os_memcpy(peer->rsnie_p, peer->rsnie_i, peer->rsnie_i_len);
2065 peer->rsnie_p_len = peer->rsnie_i_len;
2068 peer->rsnie_p, peer->rsnie_p_len);
2070 peer->lifetime = lifetime;
2072 wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid);
2080 /* add supported rates, capabilities, and qos_info to the TDLS peer */
2081 if (wpa_tdls_addset_peer(sm, peer, 1) < 0)
2087 peer->tpk_in_progress = 1;
2090 if (wpa_tdls_send_tpk_m2(sm, src_addr, dtoken, lnkid, peer) < 0) {
2091 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
2100 if (peer)
2101 wpa_tdls_peer_free(sm, peer);
2106 static int wpa_tdls_enable_link(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
2108 peer->tpk_success = 1;
2109 peer->tpk_in_progress = 0;
2110 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer);
2112 u32 lifetime = peer->lifetime;
2117 if (lifetime > 3 && peer->initiator)
2120 sm, peer);
2125 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer);
2130 if (peer->reconfig_key && wpa_tdls_set_key(sm, peer) < 0) {
2135 peer->reconfig_key = 0;
2137 return wpa_sm_tdls_oper(sm, TDLS_ENABLE_LINK, peer->addr);
2144 struct wpa_tdls_peer *peer;
2160 for (peer = sm->tdls; peer; peer = peer->next) {
2161 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0)
2164 if (peer == NULL) {
2165 wpa_printf(MSG_INFO, "TDLS: No matching peer found for "
2169 if (!peer->initiator) {
2172 * same time and we accept the TPK M1 from the peer in
2180 if (peer->tpk_success) {
2187 wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_REQUEST);
2190 wpa_tdls_disable_peer_link(sm, peer);
2202 wpa_tdls_disable_peer_link(sm, peer);
2214 wpa_tdls_disable_peer_link(sm, peer);
2219 peer->capability = WPA_GET_LE16(pos);
2256 if (copy_supp_rates(&kde, peer) < 0)
2259 if (copy_peer_ht_capab(&kde, peer) < 0)
2262 if (copy_peer_vht_capab(&kde, peer) < 0)
2265 if (copy_peer_ext_capab(&kde, peer) < 0)
2268 if (copy_peer_supp_channels(&kde, peer) < 0)
2271 if (copy_peer_supp_oper_classes(&kde, peer) < 0)
2274 peer->qos_info = kde.qosinfo;
2277 if (copy_peer_wmm_capab(&kde, peer) < 0)
2280 peer->aid = kde.aid;
2283 peer->rsnie_p_len = 0;
2284 peer->cipher = WPA_CIPHER_NONE;
2310 if (kde.rsn_ie_len != peer->rsnie_i_len ||
2311 os_memcmp(peer->rsnie_i, kde.rsn_ie, peer->rsnie_i_len) != 0) {
2315 peer->rsnie_i, peer->rsnie_i_len);
2342 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) {
2350 os_memcpy(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN);
2351 os_memcpy(peer->rsnie_p, kde.rsn_ie, kde.rsn_ie_len);
2352 peer->rsnie_p_len = kde.rsn_ie_len;
2353 peer->cipher = cipher;
2365 if (lifetime != peer->lifetime) {
2367 "TPK M2 (expected %u)", lifetime, peer->lifetime);
2372 wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid);
2375 if (wpa_supplicant_verify_tdls_mic(2, peer, (u8 *) lnkid,
2378 wpa_tdls_del_key(sm, peer);
2379 wpa_tdls_disable_peer_link(sm, peer);
2383 if (wpa_tdls_set_key(sm, peer) < 0) {
2390 peer->reconfig_key = 1;
2394 peer->dtoken = dtoken;
2396 /* add supported rates, capabilities, and qos_info to the TDLS peer */
2397 if (wpa_tdls_addset_peer(sm, peer, 0) < 0)
2402 if (wpa_tdls_send_tpk_m3(sm, src_addr, dtoken, lnkid, peer) < 0)
2405 if (!peer->tpk_success) {
2411 ret = wpa_tdls_enable_link(sm, peer);
2415 sm, peer,
2425 wpa_tdls_disable_peer_link(sm, peer);
2433 struct wpa_tdls_peer *peer;
2446 for (peer = sm->tdls; peer; peer = peer->next) {
2447 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0)
2450 if (peer == NULL) {
2451 wpa_printf(MSG_INFO, "TDLS: No matching peer found for "
2455 wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_RESPONSE);
2514 if (kde.rsn_ie_len != peer->rsnie_p_len ||
2515 os_memcmp(kde.rsn_ie, peer->rsnie_p, peer->rsnie_p_len) != 0) {
2521 if (os_memcmp(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN) != 0) {
2527 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) {
2543 if (lifetime != peer->lifetime) {
2545 "TPK M3 (expected %u)", lifetime, peer->lifetime);
2549 if (wpa_supplicant_verify_tdls_mic(3, peer, (u8 *) lnkid,
2551 wpa_tdls_del_key(sm, peer);
2555 if (wpa_tdls_set_key(sm, peer) < 0) {
2562 peer->reconfig_key = 1;
2566 /* add supported rates, capabilities, and qos_info to the TDLS peer */
2567 if (wpa_tdls_addset_peer(sm, peer, 0) < 0)
2570 if (!peer->tpk_success) {
2576 ret = wpa_tdls_enable_link(sm, peer);
2584 wpa_tdls_do_teardown(sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED);
2606 * @peer: MAC address of the peer STA
2610 * handshake with the peer.
2614 struct wpa_tdls_peer *peer;
2635 peer = wpa_tdls_add_peer(sm, addr, NULL);
2636 if (peer == NULL)
2639 if (peer->tpk_in_progress) {
2640 wpa_printf(MSG_DEBUG, "TDLS: Setup is already in progress with the peer");
2644 peer->initiator = 1;
2646 /* add the peer to the driver as a "setup in progress" peer */
2647 if (wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL,
2649 wpa_tdls_disable_peer_link(sm, peer);
2653 peer->tpk_in_progress = 1;
2655 if (wpa_tdls_send_tpk_m1(sm, peer) < 0) {
2656 wpa_tdls_disable_peer_link(sm, peer);
2666 struct wpa_tdls_peer *peer;
2671 for (peer = sm->tdls; peer; peer = peer->next) {
2672 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
2676 if (peer == NULL || !peer->tpk_success)
2684 wpa_tdls_do_teardown(sm, peer,
2804 struct wpa_tdls_peer *peer, *tmp;
2808 peer = sm->tdls;
2812 while (peer) {
2813 tmp = peer->next;
2814 wpa_printf(MSG_DEBUG, "TDLS: Tear down peer " MACSTR,
2815 MAC2STR(peer->addr));
2817 wpa_tdls_do_teardown(sm, peer,
2820 wpa_sm_tdls_oper(sm, TDLS_TEARDOWN, peer->addr);
2822 peer = tmp;
2829 struct wpa_tdls_peer *peer, *tmp;
2831 peer = sm->tdls;
2833 while (peer) {
2835 tmp = peer->next;
2836 res = wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
2837 wpa_printf(MSG_DEBUG, "TDLS: Remove peer " MACSTR " (res=%d)",
2838 MAC2STR(peer->addr), res);
2839 wpa_tdls_peer_free(sm, peer);
2840 peer = tmp;
2955 struct wpa_tdls_peer *peer;
2973 for (peer = sm->tdls; peer; peer = peer->next) {
2974 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
2978 if (peer == NULL || !peer->tpk_success) {
2984 if (peer->chan_switch_enabled) {
2991 ret = wpa_sm_tdls_enable_channel_switch(sm, peer->addr,
2994 peer->chan_switch_enabled = 1;
3002 struct wpa_tdls_peer *peer;
3007 for (peer = sm->tdls; peer; peer = peer->next) {
3008 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
3012 if (!peer || !peer->chan_switch_enabled) {
3019 wpa_sm_tdls_disable_channel_switch(sm, peer->addr);
3021 peer->chan_switch_enabled = 0;