Lines Matching defs: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)
180 if (wpa_sm_set_key(sm, WPA_ALG_NONE, peer->addr,
191 static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
197 if (peer->tk_set) {
205 wpa_printf(MSG_INFO, "TDLS: TPK-TK for the peer " MACSTR
207 MAC2STR(peer->addr));
213 switch (peer->cipher) {
228 wpa_printf(MSG_DEBUG, "TDLS: Configure pairwise key for peer " MACSTR,
229 MAC2STR(peer->addr));
230 if (wpa_sm_set_key(sm, alg, peer->addr, -1, 1,
231 rsc, sizeof(rsc), peer->tpk.tk, key_len) < 0) {
236 peer->tk_set = 1;
256 struct wpa_tdls_peer *peer;
278 for (peer = sm->tdls; peer; peer = peer->next) {
279 if (os_memcmp(peer->addr, dest, ETH_ALEN) == 0)
283 if (peer == NULL) {
289 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer);
292 peer->sm_tmr.count = TPK_M2_RETRY_COUNT;
293 peer->sm_tmr.timer = TPK_M2_TIMEOUT;
295 peer->sm_tmr.count = TPK_M1_RETRY_COUNT;
296 peer->sm_tmr.timer = TPK_M1_TIMEOUT;
300 os_memcpy(peer->sm_tmr.dest, dest, ETH_ALEN);
301 peer->sm_tmr.action_code = action_code;
302 peer->sm_tmr.dialog_token = dialog_token;
303 peer->sm_tmr.status_code = status_code;
304 peer->sm_tmr.peer_capab = peer_capab;
305 peer->sm_tmr.buf_len = msg_len;
306 os_free(peer->sm_tmr.buf);
307 peer->sm_tmr.buf = os_memdup(msg, msg_len);
308 if (peer->sm_tmr.buf == NULL)
313 eloop_register_timeout(peer->sm_tmr.timer / 1000,
314 (peer->sm_tmr.timer % 1000) * 1000,
315 wpa_tdls_tpk_retry_timeout, sm, peer);
320 static int wpa_tdls_do_teardown(struct wpa_sm *sm, struct wpa_tdls_peer *peer,
325 ret = wpa_tdls_send_teardown(sm, peer->addr, reason_code);
327 wpa_tdls_disable_peer_link(sm, peer);
337 struct wpa_tdls_peer *peer = timeout_ctx;
339 if (peer->sm_tmr.count) {
340 peer->sm_tmr.count--;
344 peer->sm_tmr.action_code);
346 if (peer->sm_tmr.buf == NULL) {
349 peer->sm_tmr.action_code);
351 peer);
356 if (wpa_tdls_send_tpk_msg(sm, peer->sm_tmr.dest,
357 peer->sm_tmr.action_code,
358 peer->sm_tmr.dialog_token,
359 peer->sm_tmr.status_code,
360 peer->sm_tmr.peer_capab,
361 peer->initiator,
362 peer->sm_tmr.buf,
363 peer->sm_tmr.buf_len)) {
368 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer);
369 eloop_register_timeout(peer->sm_tmr.timer / 1000,
370 (peer->sm_tmr.timer % 1000) * 1000,
371 wpa_tdls_tpk_retry_timeout, sm, peer);
373 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer);
376 wpa_tdls_do_teardown(sm, peer,
383 struct wpa_tdls_peer *peer,
386 if (action_code == peer->sm_tmr.action_code) {
391 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer);
394 os_free(peer->sm_tmr.buf);
395 peer->sm_tmr.buf = NULL;
397 peer->sm_tmr.count = 0;
398 peer->sm_tmr.timer = 0;
399 peer->sm_tmr.buf_len = 0;
400 peer->sm_tmr.action_code = 0xff;
408 static void wpa_tdls_generate_tpk(struct wpa_tdls_peer *peer,
422 if (os_memcmp(peer->inonce, peer->rnonce, WPA_NONCE_LEN) < 0) {
423 nonce[0] = peer->inonce;
424 nonce[1] = peer->rnonce;
426 nonce[0] = peer->rnonce;
427 nonce[1] = peer->inonce;
440 if (os_memcmp(own_addr, peer->addr, ETH_ALEN) < 0) {
442 os_memcpy(data + ETH_ALEN, peer->addr, ETH_ALEN);
444 os_memcpy(data, peer->addr, ETH_ALEN);
451 (u8 *) &peer->tpk, sizeof(peer->tpk));
453 peer->tpk.kck, sizeof(peer->tpk.kck));
455 peer->tpk.tk, sizeof(peer->tpk.tk));
456 peer->tpk_set = 1;
581 struct wpa_tdls_peer *peer,
587 if (peer->tpk_set) {
588 wpa_tdls_ftie_mic(peer->tpk.kck, trans_seq, lnkid,
589 peer->rsnie_p, timeoutie, (u8 *) ftie,
610 u8 trans_seq, u16 rcode, u8 dtoken, struct wpa_tdls_peer *peer,
615 if (peer->tpk_set) {
616 wpa_tdls_key_mic_teardown(peer->tpk.kck, trans_seq, rcode,
635 struct wpa_tdls_peer *peer = timeout_ctx;
645 if (peer->initiator) {
649 " - try to renew", MAC2STR(peer->addr));
650 /* cache the peer address before do_teardown */
651 os_memcpy(addr, peer->addr, ETH_ALEN);
652 wpa_tdls_do_teardown(sm, peer,
657 " - tear down", MAC2STR(peer->addr));
658 wpa_tdls_do_teardown(sm, peer,
665 struct wpa_tdls_peer *peer)
671 while (cur && cur != peer) {
676 if (cur != peer) {
677 wpa_printf(MSG_ERROR, "TDLS: Could not find peer " MACSTR
679 MAC2STR(peer->addr));
684 prev->next = peer->next;
686 sm->tdls = peer->next;
690 static void wpa_tdls_peer_clear(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
692 wpa_printf(MSG_DEBUG, "TDLS: Clear state for peer " MACSTR,
693 MAC2STR(peer->addr));
694 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer);
695 eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer);
696 peer->reconfig_key = 0;
697 peer->initiator = 0;
698 peer->tpk_in_progress = 0;
699 os_free(peer->sm_tmr.buf);
700 peer->sm_tmr.buf = NULL;
701 os_free(peer->ht_capabilities);
702 peer->ht_capabilities = NULL;
703 os_free(peer->vht_capabilities);
704 peer->vht_capabilities = NULL;
705 os_free(peer->ext_capab);
706 peer->ext_capab = NULL;
707 os_free(peer->supp_channels);
708 peer->supp_channels = NULL;
709 os_free(peer->supp_oper_classes);
710 peer->supp_oper_classes = NULL;
711 peer->rsnie_i_len = peer->rsnie_p_len = 0;
712 peer->cipher = 0;
713 peer->qos_info = 0;
714 peer->wmm_capable = 0;
715 peer->tk_set = peer->tpk_set = peer->tpk_success = 0;
716 peer->chan_switch_enabled = 0;
717 os_memset(&peer->tpk, 0, sizeof(peer->tpk));
718 os_memset(peer->inonce, 0, WPA_NONCE_LEN);
719 os_memset(peer->rnonce, 0, WPA_NONCE_LEN);
723 static void wpa_tdls_peer_free(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
725 wpa_tdls_peer_clear(sm, peer);
726 wpa_tdls_peer_remove_from_list(sm, peer);
727 os_free(peer);
731 static void wpa_tdls_linkid(struct wpa_sm *sm, struct wpa_tdls_peer *peer,
737 if (peer->initiator) {
739 os_memcpy(lnkid->resp_sta, peer->addr, ETH_ALEN);
741 os_memcpy(lnkid->init_sta, peer->addr, ETH_ALEN);
750 struct wpa_tdls_peer *peer;
761 for (peer = sm->tdls; peer; peer = peer->next) {
762 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
766 if (peer == NULL) {
773 if (peer->chan_switch_enabled) {
776 wpa_sm_tdls_disable_channel_switch(sm, peer->addr);
779 dialog_token = peer->dtoken;
785 if (wpa_tdls_get_privacy(sm) && peer->tpk_set && peer->tpk_success) {
799 if (!wpa_tdls_get_privacy(sm) || !peer->tpk_set || !peer->tpk_success)
805 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN);
806 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
823 wpa_tdls_linkid(sm, peer, &lnkid);
824 wpa_tdls_key_mic_teardown(peer->tpk.kck, 4, reason_code,
834 reason_code, 0, peer->initiator, rbuf, pos - rbuf);
843 struct wpa_tdls_peer *peer;
848 for (peer = sm->tdls; peer; peer = peer->next) {
849 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
853 if (peer == NULL) {
854 wpa_printf(MSG_DEBUG, "TDLS: Could not find peer " MACSTR
859 if (!peer->tpk_success) {
865 return wpa_tdls_do_teardown(sm, peer, reason_code);
870 struct wpa_tdls_peer *peer)
872 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
873 wpa_tdls_peer_free(sm, peer);
879 struct wpa_tdls_peer *peer;
881 for (peer = sm->tdls; peer; peer = peer->next) {
882 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
886 if (!peer || !peer->tpk_success) {
898 if (peer->chan_switch_enabled)
899 wpa_sm_tdls_disable_channel_switch(sm, peer->addr);
903 wpa_tdls_peer_free(sm, peer);
905 wpa_tdls_disable_peer_link(sm, peer);
912 struct wpa_tdls_peer *peer;
917 for (peer = sm->tdls; peer; peer = peer->next) {
918 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
922 if (peer == NULL)
923 return "peer does not exist";
925 if (!peer->tpk_success)
926 return "peer not connected";
935 struct wpa_tdls_peer *peer = NULL;
944 for (peer = sm->tdls; peer; peer = peer->next) {
945 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0)
949 if (peer == NULL) {
982 if (!wpa_tdls_get_privacy(sm) || !peer->tpk_set || !peer->tpk_success)
994 peer->dtoken, peer,
1006 wpa_tdls_disable_peer_link(sm, peer);
1035 struct wpa_tdls_peer *peer;
1039 for (peer = sm->tdls; peer; peer = peer->next) {
1040 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) {
1043 return peer; /* re-use existing entry */
1047 wpa_printf(MSG_INFO, "TDLS: Creating peer entry for " MACSTR,
1050 peer = os_zalloc(sizeof(*peer));
1051 if (peer == NULL)
1054 os_memcpy(peer->addr, addr, ETH_ALEN);
1055 peer->next = sm->tdls;
1056 sm->tdls = peer;
1058 return peer;
1063 struct wpa_tdls_peer *peer)
1076 peer->rsnie_i_len = 0;
1087 hdr = (struct rsn_ie_hdr *) peer->rsnie_i;
1137 hdr->len = (pos - peer->rsnie_i) - 2;
1138 peer->rsnie_i_len = pos - peer->rsnie_i;
1140 peer->rsnie_i, peer->rsnie_i_len);
1145 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) +
1156 wpa_tdls_peer_free(sm, peer);
1165 pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len);
1171 if (os_get_random(peer->inonce, WPA_NONCE_LEN)) {
1175 wpa_tdls_peer_free(sm, peer);
1178 peer->tk_set = 0; /* A new nonce results in a new TK */
1180 peer->inonce, WPA_NONCE_LEN);
1181 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
1200 peer->lifetime = TPK_LIFETIME;
1205 peer->lifetime = 301;
1210 peer->lifetime = 0xffffffff;
1214 sizeof(timeoutie), peer->lifetime);
1215 wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime);
1225 wpa_tdls_linkid(sm, peer, l);
1232 "Handshake Message 1 (peer " MACSTR ")",
1233 MAC2STR(peer->addr));
1235 status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_SETUP_REQUEST,
1236 1, 0, 0, peer->initiator, rbuf, pos - rbuf);
1246 const struct wpa_tdls_peer *peer)
1259 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) +
1276 pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len);
1281 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN);
1282 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
1301 lifetime = peer->lifetime;
1315 wpa_tdls_ftie_mic(peer->tpk.kck, 2, (u8 *) lnkid, peer->rsnie_p,
1326 dtoken, 0, 0, peer->initiator, rbuf,
1337 const struct wpa_tdls_peer *peer)
1351 buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) +
1368 pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len);
1373 os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN);
1374 os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
1391 lifetime = peer->lifetime;
1405 wpa_tdls_ftie_mic(peer->tpk.kck, 3, (u8 *) lnkid, peer->rsnie_p,
1416 if (peer->vht_capabilities)
1418 if (peer->ht_capabilities)
1420 if (peer->wmm_capable)
1424 dtoken, 0, peer_capab, peer->initiator,
1433 struct wpa_tdls_peer *peer,
1445 "(peer " MACSTR ")", MAC2STR(peer->addr));
1450 hdr = (struct rsn_ie_hdr *) peer->rsnie_i;
1482 peer->rsnie_i_len = pos - peer->rsnie_i;
1490 buf_len += peer->rsnie_i_len +
1495 wpa_tdls_peer_free(sm, peer);
1503 pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len);
1505 peer->lifetime = TPK_LIFETIME;
1507 sizeof(timeoutie), peer->lifetime);
1508 wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime);
1510 status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_DISCOVERY_RESPONSE,
1524 struct wpa_tdls_peer *peer;
1566 peer = wpa_tdls_add_peer(sm, addr, NULL);
1567 if (peer == NULL)
1570 return wpa_tdls_send_discovery_response(sm, peer, dialog_token);
1579 wpa_printf(MSG_DEBUG, "TDLS: Sending Discovery Request to peer "
1587 struct wpa_tdls_peer *peer)
1593 peer->supp_rates_len = merge_byte_arrays(
1594 peer->supp_rates, sizeof(peer->supp_rates),
1603 struct wpa_tdls_peer *peer)
1611 if (!peer->ht_capabilities) {
1612 peer->ht_capabilities =
1614 if (peer->ht_capabilities == NULL)
1618 os_memcpy(peer->ht_capabilities, kde->ht_capabilities,
1621 (u8 *) peer->ht_capabilities,
1629 struct wpa_tdls_peer *peer)
1637 if (!peer->vht_capabilities) {
1638 peer->vht_capabilities =
1640 if (peer->vht_capabilities == NULL)
1644 os_memcpy(peer->vht_capabilities, kde->vht_capabilities,
1647 (u8 *) peer->vht_capabilities,
1655 struct wpa_tdls_peer *peer)
1663 if (!peer->ext_capab || peer->ext_capab_len < kde->ext_capab_len - 2) {
1665 os_free(peer->ext_capab);
1666 peer->ext_capab = os_zalloc(kde->ext_capab_len - 2);
1667 if (peer->ext_capab == NULL)
1671 peer->ext_capab_len = kde->ext_capab_len - 2;
1672 os_memcpy(peer->ext_capab, kde->ext_capab + 2, peer->ext_capab_len);
1679 struct wpa_tdls_peer *peer)
1694 peer->qos_info = wmm->qos_info;
1696 peer->wmm_capable = 1;
1698 wpa_printf(MSG_DEBUG, "TDLS: Peer WMM QOS Info 0x%x", peer->qos_info);
1704 struct wpa_tdls_peer *peer)
1711 if (!peer->supp_channels ||
1712 peer->supp_channels_len < kde->supp_channels_len) {
1713 os_free(peer->supp_channels);
1714 peer->supp_channels = os_zalloc(kde->supp_channels_len);
1715 if (peer->supp_channels == NULL)
1719 peer->supp_channels_len = kde->supp_channels_len;
1721 os_memcpy(peer->supp_channels, kde->supp_channels,
1722 peer->supp_channels_len);
1724 (u8 *) peer->supp_channels, peer->supp_channels_len);
1730 struct wpa_tdls_peer *peer)
1737 if (!peer->supp_oper_classes ||
1738 peer->supp_oper_classes_len < kde->supp_oper_classes_len) {
1739 os_free(peer->supp_oper_classes);
1740 peer->supp_oper_classes = os_zalloc(kde->supp_oper_classes_len);
1741 if (peer->supp_oper_classes == NULL)
1745 peer->supp_oper_classes_len = kde->supp_oper_classes_len;
1746 os_memcpy(peer->supp_oper_classes, kde->supp_oper_classes,
1747 peer->supp_oper_classes_len);
1749 (u8 *) peer->supp_oper_classes,
1750 peer->supp_oper_classes_len);
1755 static int wpa_tdls_addset_peer(struct wpa_sm *sm, struct wpa_tdls_peer *peer,
1758 return wpa_sm_tdls_peer_addset(sm, peer->addr, add, peer->aid,
1759 peer->capability,
1760 peer->supp_rates, peer->supp_rates_len,
1761 peer->ht_capabilities,
1762 peer->vht_capabilities,
1763 peer->qos_info, peer->wmm_capable,
1764 peer->ext_capab, peer->ext_capab_len,
1765 peer->supp_channels,
1766 peer->supp_channels_len,
1767 peer->supp_oper_classes,
1768 peer->supp_oper_classes_len);
1788 struct wpa_tdls_peer *peer;
1820 peer = wpa_tdls_add_peer(sm, src_addr, &existing_peer);
1821 if (peer == NULL)
1828 if (peer->tpk_success) {
1832 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
1833 wpa_tdls_peer_clear(sm, peer);
1834 } else if (peer->initiator) {
1844 "from peer with higher address "
1849 "from peer with lower address "
1854 peer->addr);
1855 wpa_tdls_peer_clear(sm, peer);
1861 peer->capability = WPA_GET_LE16(cpos);
1892 if (copy_supp_rates(&kde, peer) < 0)
1895 if (copy_peer_ht_capab(&kde, peer) < 0)
1898 if (copy_peer_vht_capab(&kde, peer) < 0)
1901 if (copy_peer_ext_capab(&kde, peer) < 0)
1904 if (copy_peer_supp_channels(&kde, peer) < 0)
1907 if (copy_peer_supp_oper_classes(&kde, peer) < 0)
1910 peer->qos_info = kde.qosinfo;
1913 if (copy_peer_wmm_capab(&kde, peer) < 0)
1916 peer->aid = kde.aid;
1920 peer = wpa_tdls_add_peer(sm, src_addr, NULL);
1921 if (peer == NULL)
1925 peer->initiator = 1;
1926 wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL,
1928 wpa_tdls_send_tpk_m1(sm, peer);
2012 if (os_memcmp(sm->own_addr, peer->addr, ETH_ALEN) < 0) {
2016 * the peer.
2023 peer->initiator = 0; /* Need to check */
2024 peer->dtoken = dtoken;
2027 peer->rsnie_i_len = 0;
2028 peer->rsnie_p_len = 0;
2029 peer->cipher = WPA_CIPHER_NONE;
2034 os_memcpy(peer->rsnie_i, kde.rsn_ie, kde.rsn_ie_len);
2035 peer->rsnie_i_len = kde.rsn_ie_len;
2036 peer->cipher = cipher;
2038 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0 ||
2039 !tdls_nonce_set(peer->inonce)) {
2049 os_memcpy(peer->inonce, ftie->Snonce, WPA_NONCE_LEN);
2050 if (os_get_random(peer->rnonce, WPA_NONCE_LEN)) {
2055 peer->tk_set = 0; /* A new nonce results in a new TK */
2063 /* use min(peer's version, out version) */
2067 hdr = (struct rsn_ie_hdr *) peer->rsnie_p;
2092 hdr->len = (pos - peer->rsnie_p) - 2;
2093 peer->rsnie_p_len = pos - peer->rsnie_p;
2097 os_memcpy(peer->rsnie_p, peer->rsnie_i, peer->rsnie_i_len);
2098 peer->rsnie_p_len = peer->rsnie_i_len;
2101 peer->rsnie_p, peer->rsnie_p_len);
2103 peer->lifetime = lifetime;
2105 wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid);
2113 /* add supported rates, capabilities, and qos_info to the TDLS peer */
2114 if (wpa_tdls_addset_peer(sm, peer, 1) < 0)
2120 peer->tpk_in_progress = 1;
2123 if (wpa_tdls_send_tpk_m2(sm, src_addr, dtoken, lnkid, peer) < 0) {
2124 wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
2131 wpa_tdls_send_tpk_m2(sm, src_addr, dtoken, lnkid, peer);
2140 if (peer)
2141 wpa_tdls_peer_free(sm, peer);
2146 static int wpa_tdls_enable_link(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
2148 peer->tpk_success = 1;
2149 peer->tpk_in_progress = 0;
2150 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer);
2152 u32 lifetime = peer->lifetime;
2157 if (lifetime > 3 && peer->initiator)
2160 sm, peer);
2165 eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer);
2170 if (peer->reconfig_key && wpa_tdls_set_key(sm, peer) < 0) {
2175 peer->reconfig_key = 0;
2177 return wpa_sm_tdls_oper(sm, TDLS_ENABLE_LINK, peer->addr);
2184 struct wpa_tdls_peer *peer;
2200 for (peer = sm->tdls; peer; peer = peer->next) {
2201 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0)
2204 if (peer == NULL) {
2205 wpa_printf(MSG_INFO, "TDLS: No matching peer found for "
2209 if (!peer->initiator) {
2212 * same time and we accept the TPK M1 from the peer in
2220 if (peer->tpk_success) {
2227 wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_REQUEST);
2230 wpa_tdls_disable_peer_link(sm, peer);
2242 wpa_tdls_disable_peer_link(sm, peer);
2254 wpa_tdls_disable_peer_link(sm, peer);
2259 peer->capability = WPA_GET_LE16(pos);
2296 if (copy_supp_rates(&kde, peer) < 0)
2299 if (copy_peer_ht_capab(&kde, peer) < 0)
2302 if (copy_peer_vht_capab(&kde, peer) < 0)
2305 if (copy_peer_ext_capab(&kde, peer) < 0)
2308 if (copy_peer_supp_channels(&kde, peer) < 0)
2311 if (copy_peer_supp_oper_classes(&kde, peer) < 0)
2314 peer->qos_info = kde.qosinfo;
2317 if (copy_peer_wmm_capab(&kde, peer) < 0)
2320 peer->aid = kde.aid;
2323 peer->rsnie_p_len = 0;
2324 peer->cipher = WPA_CIPHER_NONE;
2350 if (kde.rsn_ie_len != peer->rsnie_i_len ||
2351 os_memcmp(peer->rsnie_i, kde.rsn_ie, peer->rsnie_i_len) != 0) {
2355 peer->rsnie_i, peer->rsnie_i_len);
2382 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) {
2390 os_memcpy(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN);
2391 os_memcpy(peer->rsnie_p, kde.rsn_ie, kde.rsn_ie_len);
2392 peer->rsnie_p_len = kde.rsn_ie_len;
2393 peer->cipher = cipher;
2405 if (lifetime != peer->lifetime) {
2407 "TPK M2 (expected %u)", lifetime, peer->lifetime);
2412 wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid);
2415 if (wpa_supplicant_verify_tdls_mic(2, peer, (u8 *) lnkid,
2418 wpa_tdls_del_key(sm, peer);
2419 wpa_tdls_disable_peer_link(sm, peer);
2423 if (wpa_tdls_set_key(sm, peer) < 0) {
2430 peer->reconfig_key = 1;
2434 peer->dtoken = dtoken;
2436 /* add supported rates, capabilities, and qos_info to the TDLS peer */
2437 if (wpa_tdls_addset_peer(sm, peer, 0) < 0)
2442 if (wpa_tdls_send_tpk_m3(sm, src_addr, dtoken, lnkid, peer) < 0)
2445 if (!peer->tpk_success) {
2451 ret = wpa_tdls_enable_link(sm, peer);
2455 sm, peer,
2465 wpa_tdls_disable_peer_link(sm, peer);
2473 struct wpa_tdls_peer *peer;
2486 for (peer = sm->tdls; peer; peer = peer->next) {
2487 if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0)
2490 if (peer == NULL) {
2491 wpa_printf(MSG_INFO, "TDLS: No matching peer found for "
2495 wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_RESPONSE);
2554 if (kde.rsn_ie_len != peer->rsnie_p_len ||
2555 os_memcmp(kde.rsn_ie, peer->rsnie_p, peer->rsnie_p_len) != 0) {
2561 if (os_memcmp(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN) != 0) {
2567 if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) {
2583 if (lifetime != peer->lifetime) {
2585 "TPK M3 (expected %u)", lifetime, peer->lifetime);
2589 if (wpa_supplicant_verify_tdls_mic(3, peer, (u8 *) lnkid,
2591 wpa_tdls_del_key(sm, peer);
2595 if (wpa_tdls_set_key(sm, peer) < 0) {
2602 peer->reconfig_key = 1;
2606 /* add supported rates, capabilities, and qos_info to the TDLS peer */
2607 if (wpa_tdls_addset_peer(sm, peer, 0) < 0)
2610 if (!peer->tpk_success) {
2616 ret = wpa_tdls_enable_link(sm, peer);
2624 wpa_tdls_do_teardown(sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED);
2646 * @peer: MAC address of the peer STA
2650 * handshake with the peer.
2654 struct wpa_tdls_peer *peer;
2675 peer = wpa_tdls_add_peer(sm, addr, NULL);
2676 if (peer == NULL)
2679 if (peer->tpk_in_progress) {
2680 wpa_printf(MSG_DEBUG, "TDLS: Setup is already in progress with the peer");
2684 peer->initiator = 1;
2686 /* add the peer to the driver as a "setup in progress" peer */
2687 if (wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL,
2689 wpa_tdls_disable_peer_link(sm, peer);
2693 peer->tpk_in_progress = 1;
2695 if (wpa_tdls_send_tpk_m1(sm, peer) < 0) {
2696 wpa_tdls_disable_peer_link(sm, peer);
2706 struct wpa_tdls_peer *peer;
2711 for (peer = sm->tdls; peer; peer = peer->next) {
2712 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
2716 if (peer == NULL || !peer->tpk_success)
2724 wpa_tdls_do_teardown(sm, peer,
2844 struct wpa_tdls_peer *peer, *tmp;
2848 peer = sm->tdls;
2852 while (peer) {
2853 tmp = peer->next;
2854 wpa_printf(MSG_DEBUG, "TDLS: Tear down peer " MACSTR,
2855 MAC2STR(peer->addr));
2857 wpa_tdls_do_teardown(sm, peer,
2860 wpa_sm_tdls_oper(sm, TDLS_TEARDOWN, peer->addr);
2862 peer = tmp;
2869 struct wpa_tdls_peer *peer, *tmp;
2871 peer = sm->tdls;
2873 while (peer) {
2875 tmp = peer->next;
2876 res = wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr);
2877 wpa_printf(MSG_DEBUG, "TDLS: Remove peer " MACSTR " (res=%d)",
2878 MAC2STR(peer->addr), res);
2879 wpa_tdls_peer_free(sm, peer);
2880 peer = tmp;
2995 struct wpa_tdls_peer *peer;
3013 for (peer = sm->tdls; peer; peer = peer->next) {
3014 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
3018 if (peer == NULL || !peer->tpk_success) {
3024 if (peer->chan_switch_enabled) {
3031 ret = wpa_sm_tdls_enable_channel_switch(sm, peer->addr,
3034 peer->chan_switch_enabled = 1;
3042 struct wpa_tdls_peer *peer;
3047 for (peer = sm->tdls; peer; peer = peer->next) {
3048 if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
3052 if (!peer || !peer->chan_switch_enabled) {
3059 wpa_sm_tdls_disable_channel_switch(sm, peer->addr);
3061 peer->chan_switch_enabled = 0;