diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 86261cac2..63a8c6cce 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -2959,6 +2959,17 @@ int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr, } +int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr, + u8 *dev_addr) +{ + struct p2p_device *dev = p2p_get_device_interface(p2p, iface_addr); + if (dev == NULL) + return -1; + os_memcpy(dev_addr, dev->p2p_device_addr, ETH_ALEN); + return 0; +} + + void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr) { os_memcpy(p2p->peer_filter, addr, ETH_ALEN); diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 8be8aead4..c5ace02df 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -1220,6 +1220,8 @@ int p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len); int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr, u8 *iface_addr); +int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr, + u8 *dev_addr); void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr); diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index cbe1c4f26..38a51db8f 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -2501,7 +2501,7 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr, wpa_s->p2p_pin[0] = '\0'; if (join) { - u8 iface_addr[ETH_ALEN]; + u8 iface_addr[ETH_ALEN], dev_addr[ETH_ALEN]; if (auth) { wpa_printf(MSG_DEBUG, "P2P: Authorize invitation to " "connect a running group from " MACSTR, @@ -2509,10 +2509,14 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr, os_memcpy(wpa_s->p2p_auth_invite, peer_addr, ETH_ALEN); return ret; } + os_memcpy(dev_addr, peer_addr, ETH_ALEN); if (p2p_get_interface_addr(wpa_s->global->p2p, peer_addr, - iface_addr) < 0) + iface_addr) < 0) { os_memcpy(iface_addr, peer_addr, ETH_ALEN); - if (wpas_p2p_join(wpa_s, iface_addr, peer_addr, wps_method) < + p2p_get_dev_addr(wpa_s->global->p2p, peer_addr, + dev_addr); + } + if (wpas_p2p_join(wpa_s, iface_addr, dev_addr, wps_method) < 0) return -1; return ret;