P2P: Fix p2p_connect join with interface address

Need to fetch P2P Device Address from the peers table in case the
p2p_connect join command uses interface address.
This commit is contained in:
Jouni Malinen 2010-07-10 13:07:08 -07:00 committed by Jouni Malinen
parent 72044390f3
commit 4147a2cc64
3 changed files with 20 additions and 3 deletions

View file

@ -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) void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr)
{ {
os_memcpy(p2p->peer_filter, addr, ETH_ALEN); os_memcpy(p2p->peer_filter, addr, ETH_ALEN);

View file

@ -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, int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr,
u8 *iface_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); void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr);

View file

@ -2501,7 +2501,7 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
wpa_s->p2p_pin[0] = '\0'; wpa_s->p2p_pin[0] = '\0';
if (join) { if (join) {
u8 iface_addr[ETH_ALEN]; u8 iface_addr[ETH_ALEN], dev_addr[ETH_ALEN];
if (auth) { if (auth) {
wpa_printf(MSG_DEBUG, "P2P: Authorize invitation to " wpa_printf(MSG_DEBUG, "P2P: Authorize invitation to "
"connect a running group from " MACSTR, "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); os_memcpy(wpa_s->p2p_auth_invite, peer_addr, ETH_ALEN);
return ret; return ret;
} }
os_memcpy(dev_addr, peer_addr, ETH_ALEN);
if (p2p_get_interface_addr(wpa_s->global->p2p, peer_addr, 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); 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) 0)
return -1; return -1;
return ret; return ret;