P2P: Embed publically visible struct in peer info
This embeds some information about each P2P peer that will be publically visible in a struct that is shared. The dev_found notification function is also passed the new struct, which requires some work for the driver-based P2P management. Signed-off-by: Konguraj(Raj) Kulanthaivel <konguraj.kulanthaivel@intel.com> Signed-off-by: Fabien Marotte <fabienx.marotte@linux.intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
e926bcffd8
commit
c5db8e5170
12 changed files with 187 additions and 145 deletions
|
@ -3117,9 +3117,8 @@ static void test_go_neg_req_rx(void *ctx, const u8 *src, u16 dev_passwd_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void test_dev_found(void *ctx, const u8 *addr, const u8 *dev_addr,
|
static void test_dev_found(void *ctx, const u8 *addr,
|
||||||
const u8 *pri_dev_type, const char *dev_name,
|
const struct p2p_peer_info *info)
|
||||||
u16 config_methods, u8 dev_capab, u8 group_capab)
|
|
||||||
{
|
{
|
||||||
struct wpa_driver_test_data *drv = ctx;
|
struct wpa_driver_test_data *drv = ctx;
|
||||||
union wpa_event_data event;
|
union wpa_event_data event;
|
||||||
|
@ -3127,19 +3126,20 @@ static void test_dev_found(void *ctx, const u8 *addr, const u8 *dev_addr,
|
||||||
wpa_printf(MSG_DEBUG, "%s(" MACSTR " p2p_dev_addr=" MACSTR
|
wpa_printf(MSG_DEBUG, "%s(" MACSTR " p2p_dev_addr=" MACSTR
|
||||||
" pri_dev_type=%s name='%s' config_methods=0x%x "
|
" pri_dev_type=%s name='%s' config_methods=0x%x "
|
||||||
"dev_capab=0x%x group_capab=0x%x)",
|
"dev_capab=0x%x group_capab=0x%x)",
|
||||||
__func__, MAC2STR(addr), MAC2STR(dev_addr),
|
__func__, MAC2STR(addr), MAC2STR(info->p2p_device_addr),
|
||||||
wps_dev_type_bin2str(pri_dev_type, devtype,
|
wps_dev_type_bin2str(info->pri_dev_type, devtype,
|
||||||
sizeof(devtype)),
|
sizeof(devtype)),
|
||||||
dev_name, config_methods, dev_capab, group_capab);
|
info->device_name, info->config_methods, info->dev_capab,
|
||||||
|
info->group_capab);
|
||||||
|
|
||||||
os_memset(&event, 0, sizeof(event));
|
os_memset(&event, 0, sizeof(event));
|
||||||
event.p2p_dev_found.addr = addr;
|
event.p2p_dev_found.addr = addr;
|
||||||
event.p2p_dev_found.dev_addr = dev_addr;
|
event.p2p_dev_found.dev_addr = info->p2p_device_addr;
|
||||||
event.p2p_dev_found.pri_dev_type = pri_dev_type;
|
event.p2p_dev_found.pri_dev_type = info->pri_dev_type;
|
||||||
event.p2p_dev_found.dev_name = dev_name;
|
event.p2p_dev_found.dev_name = info->device_name;
|
||||||
event.p2p_dev_found.config_methods = config_methods;
|
event.p2p_dev_found.config_methods = info->config_methods;
|
||||||
event.p2p_dev_found.dev_capab = dev_capab;
|
event.p2p_dev_found.dev_capab = info->dev_capab;
|
||||||
event.p2p_dev_found.group_capab = group_capab;
|
event.p2p_dev_found.group_capab = info->group_capab;
|
||||||
wpa_supplicant_event(drv->ctx, EVENT_P2P_DEV_FOUND, &event);
|
wpa_supplicant_event(drv->ctx, EVENT_P2P_DEV_FOUND, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
133
src/p2p/p2p.c
133
src/p2p/p2p.c
|
@ -61,7 +61,7 @@ static void p2p_expire_peers(struct p2p_data *p2p)
|
||||||
if (dev->last_seen.sec + P2P_PEER_EXPIRATION_AGE >= now.sec)
|
if (dev->last_seen.sec + P2P_PEER_EXPIRATION_AGE >= now.sec)
|
||||||
continue;
|
continue;
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Expiring old peer "
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Expiring old peer "
|
||||||
"entry " MACSTR, MAC2STR(dev->p2p_device_addr));
|
"entry " MACSTR, MAC2STR(dev->info.p2p_device_addr));
|
||||||
dl_list_del(&dev->list);
|
dl_list_del(&dev->list);
|
||||||
p2p_device_free(p2p, dev);
|
p2p_device_free(p2p, dev);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ void p2p_go_neg_failed(struct p2p_data *p2p, struct p2p_device *peer,
|
||||||
os_memset(&res, 0, sizeof(res));
|
os_memset(&res, 0, sizeof(res));
|
||||||
res.status = status;
|
res.status = status;
|
||||||
if (peer) {
|
if (peer) {
|
||||||
os_memcpy(res.peer_device_addr, peer->p2p_device_addr,
|
os_memcpy(res.peer_device_addr, peer->info.p2p_device_addr,
|
||||||
ETH_ALEN);
|
ETH_ALEN);
|
||||||
os_memcpy(res.peer_interface_addr, peer->intended_addr,
|
os_memcpy(res.peer_interface_addr, peer->intended_addr,
|
||||||
ETH_ALEN);
|
ETH_ALEN);
|
||||||
|
@ -262,7 +262,7 @@ struct p2p_device * p2p_get_device(struct p2p_data *p2p, const u8 *addr)
|
||||||
{
|
{
|
||||||
struct p2p_device *dev;
|
struct p2p_device *dev;
|
||||||
dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
|
dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
|
||||||
if (os_memcmp(dev->p2p_device_addr, addr, ETH_ALEN) == 0)
|
if (os_memcmp(dev->info.p2p_device_addr, addr, ETH_ALEN) == 0)
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -324,7 +324,7 @@ static struct p2p_device * p2p_create_device(struct p2p_data *p2p,
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
dl_list_add(&p2p->devices, &dev->list);
|
dl_list_add(&p2p->devices, &dev->list);
|
||||||
os_memcpy(dev->p2p_device_addr, addr, ETH_ALEN);
|
os_memcpy(dev->info.p2p_device_addr, addr, ETH_ALEN);
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
@ -333,11 +333,11 @@ static struct p2p_device * p2p_create_device(struct p2p_data *p2p,
|
||||||
static void p2p_copy_client_info(struct p2p_device *dev,
|
static void p2p_copy_client_info(struct p2p_device *dev,
|
||||||
struct p2p_client_info *cli)
|
struct p2p_client_info *cli)
|
||||||
{
|
{
|
||||||
os_memcpy(dev->device_name, cli->dev_name, cli->dev_name_len);
|
os_memcpy(dev->info.device_name, cli->dev_name, cli->dev_name_len);
|
||||||
dev->device_name[cli->dev_name_len] = '\0';
|
dev->info.device_name[cli->dev_name_len] = '\0';
|
||||||
dev->dev_capab = cli->dev_capab;
|
dev->info.dev_capab = cli->dev_capab;
|
||||||
dev->config_methods = cli->config_methods;
|
dev->info.config_methods = cli->config_methods;
|
||||||
os_memcpy(dev->pri_dev_type, cli->pri_dev_type, 8);
|
os_memcpy(dev->info.pri_dev_type, cli->pri_dev_type, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -388,11 +388,9 @@ static int p2p_add_group_clients(struct p2p_data *p2p, const u8 *go_dev_addr,
|
||||||
dev->flags |= P2P_DEV_GROUP_CLIENT_ONLY;
|
dev->flags |= P2P_DEV_GROUP_CLIENT_ONLY;
|
||||||
p2p_copy_client_info(dev, cli);
|
p2p_copy_client_info(dev, cli);
|
||||||
dev->oper_freq = freq;
|
dev->oper_freq = freq;
|
||||||
p2p->cfg->dev_found(
|
p2p->cfg->dev_found(p2p->cfg->cb_ctx,
|
||||||
p2p->cfg->cb_ctx, dev->p2p_device_addr,
|
dev->info.p2p_device_addr,
|
||||||
dev->p2p_device_addr, dev->pri_dev_type,
|
&dev->info);
|
||||||
dev->device_name, dev->config_methods,
|
|
||||||
dev->dev_capab, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
os_memcpy(dev->interface_addr, cli->p2p_interface_addr,
|
os_memcpy(dev->interface_addr, cli->p2p_interface_addr,
|
||||||
|
@ -496,8 +494,8 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Update Listen frequency based on scan "
|
"P2P: Update Listen frequency based on scan "
|
||||||
"results (" MACSTR " %d -> %d MHz (DS param %d)",
|
"results (" MACSTR " %d -> %d MHz (DS param %d)",
|
||||||
MAC2STR(dev->p2p_device_addr), dev->listen_freq, freq,
|
MAC2STR(dev->info.p2p_device_addr), dev->listen_freq,
|
||||||
msg.ds_params ? *msg.ds_params : -1);
|
freq, msg.ds_params ? *msg.ds_params : -1);
|
||||||
}
|
}
|
||||||
dev->listen_freq = freq;
|
dev->listen_freq = freq;
|
||||||
if (msg.group_info)
|
if (msg.group_info)
|
||||||
|
@ -505,14 +503,16 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
|
||||||
dev->level = level;
|
dev->level = level;
|
||||||
|
|
||||||
if (msg.pri_dev_type)
|
if (msg.pri_dev_type)
|
||||||
os_memcpy(dev->pri_dev_type, msg.pri_dev_type,
|
os_memcpy(dev->info.pri_dev_type, msg.pri_dev_type,
|
||||||
sizeof(dev->pri_dev_type));
|
sizeof(dev->info.pri_dev_type));
|
||||||
os_memcpy(dev->device_name, msg.device_name, sizeof(dev->device_name));
|
os_memcpy(dev->info.device_name, msg.device_name,
|
||||||
dev->config_methods = msg.config_methods ? msg.config_methods :
|
sizeof(dev->info.device_name));
|
||||||
|
dev->info.config_methods = msg.config_methods ? msg.config_methods :
|
||||||
msg.wps_config_methods;
|
msg.wps_config_methods;
|
||||||
|
|
||||||
if (msg.capability) {
|
if (msg.capability) {
|
||||||
dev->dev_capab = msg.capability[0];
|
dev->info.dev_capab = msg.capability[0];
|
||||||
dev->group_capab = msg.capability[1];
|
dev->info.group_capab = msg.capability[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.ext_listen_timing) {
|
if (msg.ext_listen_timing) {
|
||||||
|
@ -539,10 +539,7 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
|
||||||
"P2P: Do not report rejected device");
|
"P2P: Do not report rejected device");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, dev->p2p_device_addr,
|
p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info);
|
||||||
dev->pri_dev_type, dev->device_name,
|
|
||||||
dev->config_methods, dev->dev_capab,
|
|
||||||
dev->group_capab);
|
|
||||||
dev->flags |= P2P_DEV_REPORTED;
|
dev->flags |= P2P_DEV_REPORTED;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -932,7 +929,8 @@ int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
|
if (dev->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
|
||||||
if (!(dev->dev_capab & P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
|
if (!(dev->info.dev_capab &
|
||||||
|
P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Cannot connect to P2P Device " MACSTR
|
"P2P: Cannot connect to P2P Device " MACSTR
|
||||||
" that is in a group and is not discoverable",
|
" that is in a group and is not discoverable",
|
||||||
|
@ -1059,15 +1057,15 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
|
||||||
os_get_time(&dev->last_seen);
|
os_get_time(&dev->last_seen);
|
||||||
|
|
||||||
if (msg->pri_dev_type)
|
if (msg->pri_dev_type)
|
||||||
os_memcpy(dev->pri_dev_type, msg->pri_dev_type,
|
os_memcpy(dev->info.pri_dev_type, msg->pri_dev_type,
|
||||||
sizeof(dev->pri_dev_type));
|
sizeof(dev->info.pri_dev_type));
|
||||||
os_memcpy(dev->device_name, msg->device_name,
|
os_memcpy(dev->info.device_name, msg->device_name,
|
||||||
sizeof(dev->device_name));
|
sizeof(dev->info.device_name));
|
||||||
dev->config_methods = msg->config_methods ? msg->config_methods :
|
dev->info.config_methods = msg->config_methods ? msg->config_methods :
|
||||||
msg->wps_config_methods;
|
msg->wps_config_methods;
|
||||||
if (msg->capability) {
|
if (msg->capability) {
|
||||||
dev->dev_capab = msg->capability[0];
|
dev->info.dev_capab = msg->capability[0];
|
||||||
dev->group_capab = msg->capability[1];
|
dev->info.group_capab = msg->capability[1];
|
||||||
}
|
}
|
||||||
if (msg->listen_channel) {
|
if (msg->listen_channel) {
|
||||||
int freq;
|
int freq;
|
||||||
|
@ -1086,7 +1084,7 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
|
||||||
} else {
|
} else {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Update "
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Update "
|
||||||
"peer " MACSTR " Listen channel: %u -> %u MHz",
|
"peer " MACSTR " Listen channel: %u -> %u MHz",
|
||||||
MAC2STR(dev->p2p_device_addr),
|
MAC2STR(dev->info.p2p_device_addr),
|
||||||
dev->listen_freq, freq);
|
dev->listen_freq, freq);
|
||||||
dev->listen_freq = freq;
|
dev->listen_freq = freq;
|
||||||
}
|
}
|
||||||
|
@ -1107,8 +1105,9 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
|
||||||
"P2P: Created device entry based on GO Neg Req: "
|
"P2P: Created device entry based on GO Neg Req: "
|
||||||
MACSTR " dev_capab=0x%x group_capab=0x%x name='%s' "
|
MACSTR " dev_capab=0x%x group_capab=0x%x name='%s' "
|
||||||
"listen_freq=%d",
|
"listen_freq=%d",
|
||||||
MAC2STR(dev->p2p_device_addr), dev->dev_capab,
|
MAC2STR(dev->info.p2p_device_addr),
|
||||||
dev->group_capab, dev->device_name, dev->listen_freq);
|
dev->info.dev_capab, dev->info.group_capab,
|
||||||
|
dev->info.device_name, dev->listen_freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->flags &= ~P2P_DEV_GROUP_CLIENT_ONLY;
|
dev->flags &= ~P2P_DEV_GROUP_CLIENT_ONLY;
|
||||||
|
@ -1119,10 +1118,7 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, dev->p2p_device_addr,
|
p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info);
|
||||||
dev->pri_dev_type, dev->device_name,
|
|
||||||
dev->config_methods, dev->dev_capab,
|
|
||||||
dev->group_capab);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1154,12 +1150,12 @@ void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer)
|
||||||
|
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: GO Negotiation with " MACSTR " completed (%s will be "
|
"P2P: GO Negotiation with " MACSTR " completed (%s will be "
|
||||||
"GO)", MAC2STR(peer->p2p_device_addr),
|
"GO)", MAC2STR(peer->info.p2p_device_addr),
|
||||||
go ? "local end" : "peer");
|
go ? "local end" : "peer");
|
||||||
|
|
||||||
os_memset(&res, 0, sizeof(res));
|
os_memset(&res, 0, sizeof(res));
|
||||||
res.role_go = go;
|
res.role_go = go;
|
||||||
os_memcpy(res.peer_device_addr, peer->p2p_device_addr, ETH_ALEN);
|
os_memcpy(res.peer_device_addr, peer->info.p2p_device_addr, ETH_ALEN);
|
||||||
os_memcpy(res.peer_interface_addr, peer->intended_addr, ETH_ALEN);
|
os_memcpy(res.peer_interface_addr, peer->intended_addr, ETH_ALEN);
|
||||||
res.wps_method = peer->wps_method;
|
res.wps_method = peer->wps_method;
|
||||||
if (peer->flags & P2P_DEV_PREFER_PERSISTENT_GROUP)
|
if (peer->flags & P2P_DEV_PREFER_PERSISTENT_GROUP)
|
||||||
|
@ -1420,8 +1416,8 @@ static void p2p_add_dev_from_probe_req(struct p2p_data *p2p, const u8 *addr,
|
||||||
dev->flags |= P2P_DEV_PROBE_REQ_ONLY;
|
dev->flags |= P2P_DEV_PROBE_REQ_ONLY;
|
||||||
|
|
||||||
if (msg.capability) {
|
if (msg.capability) {
|
||||||
dev->dev_capab = msg.capability[0];
|
dev->info.dev_capab = msg.capability[0];
|
||||||
dev->group_capab = msg.capability[1];
|
dev->info.group_capab = msg.capability[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.listen_channel) {
|
if (msg.listen_channel) {
|
||||||
|
@ -1431,19 +1427,21 @@ static void p2p_add_dev_from_probe_req(struct p2p_data *p2p, const u8 *addr,
|
||||||
msg.listen_channel[4]);
|
msg.listen_channel[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
os_memcpy(dev->device_name, msg.device_name, sizeof(dev->device_name));
|
os_memcpy(dev->info.device_name, msg.device_name,
|
||||||
|
sizeof(dev->info.device_name));
|
||||||
|
|
||||||
if (msg.wps_pri_dev_type)
|
if (msg.wps_pri_dev_type)
|
||||||
os_memcpy(dev->pri_dev_type, msg.wps_pri_dev_type,
|
os_memcpy(dev->info.pri_dev_type, msg.wps_pri_dev_type,
|
||||||
sizeof(dev->pri_dev_type));
|
sizeof(dev->info.pri_dev_type));
|
||||||
|
|
||||||
p2p_parse_free(&msg);
|
p2p_parse_free(&msg);
|
||||||
|
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Created device entry based on Probe Req: " MACSTR
|
"P2P: Created device entry based on Probe Req: " MACSTR
|
||||||
" dev_capab=0x%x group_capab=0x%x name='%s' listen_freq=%d",
|
" dev_capab=0x%x group_capab=0x%x name='%s' listen_freq=%d",
|
||||||
MAC2STR(dev->p2p_device_addr), dev->dev_capab,
|
MAC2STR(dev->info.p2p_device_addr), dev->info.dev_capab,
|
||||||
dev->group_capab, dev->device_name, dev->listen_freq);
|
dev->info.group_capab, dev->info.device_name,
|
||||||
|
dev->listen_freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1669,8 +1667,8 @@ int p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *ie,
|
||||||
|
|
||||||
if ((p2p->state == P2P_CONNECT || p2p->state == P2P_CONNECT_LISTEN) &&
|
if ((p2p->state == P2P_CONNECT || p2p->state == P2P_CONNECT_LISTEN) &&
|
||||||
p2p->go_neg_peer &&
|
p2p->go_neg_peer &&
|
||||||
os_memcmp(addr, p2p->go_neg_peer->p2p_device_addr, ETH_ALEN) == 0)
|
os_memcmp(addr, p2p->go_neg_peer->info.p2p_device_addr, ETH_ALEN)
|
||||||
{
|
== 0) {
|
||||||
/* Received a Probe Request from GO Negotiation peer */
|
/* Received a Probe Request from GO Negotiation peer */
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Found GO Negotiation peer - try to start GO "
|
"P2P: Found GO Negotiation peer - try to start GO "
|
||||||
|
@ -1681,8 +1679,8 @@ int p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *ie,
|
||||||
|
|
||||||
if ((p2p->state == P2P_INVITE || p2p->state == P2P_INVITE_LISTEN) &&
|
if ((p2p->state == P2P_INVITE || p2p->state == P2P_INVITE_LISTEN) &&
|
||||||
p2p->invite_peer &&
|
p2p->invite_peer &&
|
||||||
os_memcmp(addr, p2p->invite_peer->p2p_device_addr, ETH_ALEN) == 0)
|
os_memcmp(addr, p2p->invite_peer->info.p2p_device_addr, ETH_ALEN)
|
||||||
{
|
== 0) {
|
||||||
/* Received a Probe Request from Invite peer */
|
/* Received a Probe Request from Invite peer */
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Found Invite peer - try to start Invite from "
|
"P2P: Found Invite peer - try to start Invite from "
|
||||||
|
@ -2008,7 +2006,7 @@ void p2p_continue_find(struct p2p_data *p2p)
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Send "
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Send "
|
||||||
"pending Provisioning Discovery Request to "
|
"pending Provisioning Discovery Request to "
|
||||||
MACSTR " (config methods 0x%x)",
|
MACSTR " (config methods 0x%x)",
|
||||||
MAC2STR(dev->p2p_device_addr),
|
MAC2STR(dev->info.p2p_device_addr),
|
||||||
dev->req_config_methods);
|
dev->req_config_methods);
|
||||||
if (p2p_send_prov_disc_req(p2p, dev, 0) == 0)
|
if (p2p_send_prov_disc_req(p2p, dev, 0) == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -2047,7 +2045,6 @@ static void p2p_sd_cb(struct p2p_data *p2p, int success)
|
||||||
p2p_set_timeout(p2p, 0, 200000);
|
p2p_set_timeout(p2p, 0, 200000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void p2p_prov_disc_cb(struct p2p_data *p2p, int success)
|
static void p2p_prov_disc_cb(struct p2p_data *p2p, int success)
|
||||||
{
|
{
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
|
@ -2074,8 +2071,8 @@ int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
|
||||||
p2p_add_device(p2p, bssid, freq, level, ies, ies_len);
|
p2p_add_device(p2p, bssid, freq, level, ies, ies_len);
|
||||||
|
|
||||||
if (p2p->go_neg_peer && p2p->state == P2P_SEARCH &&
|
if (p2p->go_neg_peer && p2p->state == P2P_SEARCH &&
|
||||||
os_memcmp(p2p->go_neg_peer->p2p_device_addr, bssid, ETH_ALEN) == 0)
|
os_memcmp(p2p->go_neg_peer->info.p2p_device_addr, bssid, ETH_ALEN)
|
||||||
{
|
== 0) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Found GO Negotiation peer - try to start GO "
|
"P2P: Found GO Negotiation peer - try to start GO "
|
||||||
"negotiation");
|
"negotiation");
|
||||||
|
@ -2148,12 +2145,12 @@ static void p2p_go_neg_req_cb(struct p2p_data *p2p, int success)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success &&
|
if (!success &&
|
||||||
(dev->dev_capab & P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY) &&
|
(dev->info.dev_capab & P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY) &&
|
||||||
!is_zero_ether_addr(dev->member_in_go_dev)) {
|
!is_zero_ether_addr(dev->member_in_go_dev)) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Peer " MACSTR " did not acknowledge request - "
|
"P2P: Peer " MACSTR " did not acknowledge request - "
|
||||||
"try to use device discoverability through its GO",
|
"try to use device discoverability through its GO",
|
||||||
MAC2STR(dev->p2p_device_addr));
|
MAC2STR(dev->info.p2p_device_addr));
|
||||||
p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
|
p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
|
||||||
p2p_send_dev_disc_req(p2p, dev);
|
p2p_send_dev_disc_req(p2p, dev);
|
||||||
return;
|
return;
|
||||||
|
@ -2623,7 +2620,7 @@ int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
|
||||||
end = buf + buflen;
|
end = buf + buflen;
|
||||||
|
|
||||||
res = os_snprintf(pos, end - pos, MACSTR "\n",
|
res = os_snprintf(pos, end - pos, MACSTR "\n",
|
||||||
MAC2STR(dev->p2p_device_addr));
|
MAC2STR(dev->info.p2p_device_addr));
|
||||||
if (res < 0 || res >= end - pos)
|
if (res < 0 || res >= end - pos)
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
|
@ -2660,12 +2657,12 @@ int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
|
||||||
MAC2STR(dev->interface_addr),
|
MAC2STR(dev->interface_addr),
|
||||||
MAC2STR(dev->member_in_go_dev),
|
MAC2STR(dev->member_in_go_dev),
|
||||||
MAC2STR(dev->member_in_go_iface),
|
MAC2STR(dev->member_in_go_iface),
|
||||||
wps_dev_type_bin2str(dev->pri_dev_type,
|
wps_dev_type_bin2str(dev->info.pri_dev_type,
|
||||||
devtype, sizeof(devtype)),
|
devtype, sizeof(devtype)),
|
||||||
dev->device_name,
|
dev->info.device_name,
|
||||||
dev->config_methods,
|
dev->info.config_methods,
|
||||||
dev->dev_capab,
|
dev->info.dev_capab,
|
||||||
dev->group_capab,
|
dev->info.group_capab,
|
||||||
dev->go_neg_req_sent,
|
dev->go_neg_req_sent,
|
||||||
p2p_go_state_text(dev->go_state),
|
p2p_go_state_text(dev->go_state),
|
||||||
dev->dialog_token,
|
dev->dialog_token,
|
||||||
|
@ -3135,7 +3132,7 @@ int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr,
|
||||||
struct p2p_device *dev = p2p_get_device_interface(p2p, iface_addr);
|
struct p2p_device *dev = p2p_get_device_interface(p2p, iface_addr);
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
os_memcpy(dev_addr, dev->p2p_device_addr, ETH_ALEN);
|
os_memcpy(dev_addr, dev->info.p2p_device_addr, ETH_ALEN);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3235,5 +3232,5 @@ const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p)
|
||||||
{
|
{
|
||||||
if (p2p == NULL || p2p->go_neg_peer == NULL)
|
if (p2p == NULL || p2p->go_neg_peer == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return p2p->go_neg_peer->p2p_device_addr;
|
return p2p->go_neg_peer->info.p2p_device_addr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,42 @@ enum p2p_scan_type {
|
||||||
P2P_SCAN_SOCIAL_PLUS_ONE
|
P2P_SCAN_SOCIAL_PLUS_ONE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct p2p_peer_info - P2P peer information
|
||||||
|
|
||||||
|
*/
|
||||||
|
struct p2p_peer_info {
|
||||||
|
/**
|
||||||
|
* p2p_device_addr - P2P Device Address of the peer
|
||||||
|
*/
|
||||||
|
u8 p2p_device_addr[ETH_ALEN];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pri_dev_type - Primary Device Type
|
||||||
|
*/
|
||||||
|
u8 pri_dev_type[8];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* device_name - Device Name
|
||||||
|
*/
|
||||||
|
char device_name[33];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* config_methods - WPS Configuration Methods
|
||||||
|
*/
|
||||||
|
u16 config_methods;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dev_capab - Device Capabilities
|
||||||
|
*/
|
||||||
|
u8 dev_capab;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* group_capab - Group Capabilities
|
||||||
|
*/
|
||||||
|
u8 group_capab;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct p2p_config - P2P configuration
|
* struct p2p_config - P2P configuration
|
||||||
*
|
*
|
||||||
|
@ -393,21 +429,15 @@ struct p2p_config {
|
||||||
* dev_found - Notification of a found P2P Device
|
* dev_found - Notification of a found P2P Device
|
||||||
* @ctx: Callback context from cb_ctx
|
* @ctx: Callback context from cb_ctx
|
||||||
* @addr: Source address of the message triggering this notification
|
* @addr: Source address of the message triggering this notification
|
||||||
* @dev_addr: P2P Device Address of the found P2P Device
|
* @info: P2P peer information
|
||||||
* @pri_dev_type: Primary Device Type
|
|
||||||
* @dev_name: Device Name
|
|
||||||
* @config_methods: Configuration Methods
|
|
||||||
* @dev_capab: Device Capabilities
|
|
||||||
* @group_capab: Group Capabilities
|
|
||||||
*
|
*
|
||||||
* This callback is used to notify that a new P2P Device has been
|
* This callback is used to notify that a new P2P Device has been
|
||||||
* found. This may happen, e.g., during Search state based on scan
|
* found. This may happen, e.g., during Search state based on scan
|
||||||
* results or during Listen state based on receive Probe Request and
|
* results or during Listen state based on receive Probe Request and
|
||||||
* Group Owner Negotiation Request.
|
* Group Owner Negotiation Request.
|
||||||
*/
|
*/
|
||||||
void (*dev_found)(void *ctx, const u8 *addr, const u8 *dev_addr,
|
void (*dev_found)(void *ctx, const u8 *addr,
|
||||||
const u8 *pri_dev_type, const char *dev_name,
|
const struct p2p_peer_info *info);
|
||||||
u16 config_methods, u8 dev_capab, u8 group_capab);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* go_neg_req_rx - Notification of a receive GO Negotiation Request
|
* go_neg_req_rx - Notification of a receive GO Negotiation Request
|
||||||
|
|
|
@ -38,7 +38,7 @@ static struct wpabuf * p2p_build_dev_disc_req(struct p2p_data *p2p,
|
||||||
|
|
||||||
len = p2p_buf_add_ie_hdr(buf);
|
len = p2p_buf_add_ie_hdr(buf);
|
||||||
p2p_buf_add_device_id(buf, dev_id);
|
p2p_buf_add_device_id(buf, dev_id);
|
||||||
p2p_buf_add_group_id(buf, go->p2p_device_addr, go->oper_ssid,
|
p2p_buf_add_group_id(buf, go->info.p2p_device_addr, go->oper_ssid,
|
||||||
go->oper_ssid_len);
|
go->oper_ssid_len);
|
||||||
p2p_buf_update_ie_hdr(buf, len);
|
p2p_buf_update_ie_hdr(buf, len);
|
||||||
|
|
||||||
|
@ -86,21 +86,22 @@ int p2p_send_dev_disc_req(struct p2p_data *p2p, struct p2p_device *dev)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
req = p2p_build_dev_disc_req(p2p, go, dev->p2p_device_addr);
|
req = p2p_build_dev_disc_req(p2p, go, dev->info.p2p_device_addr);
|
||||||
if (req == NULL)
|
if (req == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Sending Device Discoverability Request to GO " MACSTR
|
"P2P: Sending Device Discoverability Request to GO " MACSTR
|
||||||
" for client " MACSTR,
|
" for client " MACSTR,
|
||||||
MAC2STR(go->p2p_device_addr), MAC2STR(dev->p2p_device_addr));
|
MAC2STR(go->info.p2p_device_addr),
|
||||||
|
MAC2STR(dev->info.p2p_device_addr));
|
||||||
|
|
||||||
p2p->pending_client_disc_go = go;
|
p2p->pending_client_disc_go = go;
|
||||||
os_memcpy(p2p->pending_client_disc_addr, dev->p2p_device_addr,
|
os_memcpy(p2p->pending_client_disc_addr, dev->info.p2p_device_addr,
|
||||||
ETH_ALEN);
|
ETH_ALEN);
|
||||||
p2p->pending_action_state = P2P_PENDING_DEV_DISC_REQUEST;
|
p2p->pending_action_state = P2P_PENDING_DEV_DISC_REQUEST;
|
||||||
if (p2p_send_action(p2p, dev->oper_freq, go->p2p_device_addr,
|
if (p2p_send_action(p2p, dev->oper_freq, go->info.p2p_device_addr,
|
||||||
p2p->cfg->dev_addr, go->p2p_device_addr,
|
p2p->cfg->dev_addr, go->info.p2p_device_addr,
|
||||||
wpabuf_head(req), wpabuf_len(req), 1000) < 0) {
|
wpabuf_head(req), wpabuf_len(req), 1000) < 0) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Failed to send Action frame");
|
"P2P: Failed to send Action frame");
|
||||||
|
@ -243,7 +244,8 @@ void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
|
||||||
MAC2STR(sa));
|
MAC2STR(sa));
|
||||||
|
|
||||||
go = p2p->pending_client_disc_go;
|
go = p2p->pending_client_disc_go;
|
||||||
if (go == NULL || os_memcmp(sa, go->p2p_device_addr, ETH_ALEN) != 0) {
|
if (go == NULL ||
|
||||||
|
os_memcmp(sa, go->info.p2p_device_addr, ETH_ALEN) != 0) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Ignore unexpected "
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Ignore unexpected "
|
||||||
"Device Discoverability Response");
|
"Device Discoverability Response");
|
||||||
return;
|
return;
|
||||||
|
@ -274,9 +276,9 @@ void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa,
|
||||||
|
|
||||||
if (p2p->go_neg_peer == NULL ||
|
if (p2p->go_neg_peer == NULL ||
|
||||||
os_memcmp(p2p->pending_client_disc_addr,
|
os_memcmp(p2p->pending_client_disc_addr,
|
||||||
p2p->go_neg_peer->p2p_device_addr, ETH_ALEN) != 0 ||
|
p2p->go_neg_peer->info.p2p_device_addr, ETH_ALEN) != 0 ||
|
||||||
os_memcmp(p2p->go_neg_peer->member_in_go_dev, go->p2p_device_addr,
|
os_memcmp(p2p->go_neg_peer->member_in_go_dev,
|
||||||
ETH_ALEN) != 0) {
|
go->info.p2p_device_addr, ETH_ALEN) != 0) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending "
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending "
|
||||||
"operation with the client discoverability peer "
|
"operation with the client discoverability peer "
|
||||||
"anymore");
|
"anymore");
|
||||||
|
|
|
@ -196,7 +196,7 @@ int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev)
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: No Listen/Operating frequency known for the "
|
"P2P: No Listen/Operating frequency known for the "
|
||||||
"peer " MACSTR " to send GO Negotiation Request",
|
"peer " MACSTR " to send GO Negotiation Request",
|
||||||
MAC2STR(dev->p2p_device_addr));
|
MAC2STR(dev->info.p2p_device_addr));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,8 +210,8 @@ int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev)
|
||||||
p2p->go_neg_peer = dev;
|
p2p->go_neg_peer = dev;
|
||||||
dev->flags |= P2P_DEV_WAIT_GO_NEG_RESPONSE;
|
dev->flags |= P2P_DEV_WAIT_GO_NEG_RESPONSE;
|
||||||
dev->connect_reqs++;
|
dev->connect_reqs++;
|
||||||
if (p2p_send_action(p2p, freq, dev->p2p_device_addr,
|
if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
|
||||||
p2p->cfg->dev_addr, dev->p2p_device_addr,
|
p2p->cfg->dev_addr, dev->info.p2p_device_addr,
|
||||||
wpabuf_head(req), wpabuf_len(req), 200) < 0) {
|
wpabuf_head(req), wpabuf_len(req), 200) < 0) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Failed to send Action frame");
|
"P2P: Failed to send Action frame");
|
||||||
|
|
|
@ -36,12 +36,7 @@ struct p2p_device {
|
||||||
int level;
|
int level;
|
||||||
enum p2p_wps_method wps_method;
|
enum p2p_wps_method wps_method;
|
||||||
|
|
||||||
u8 p2p_device_addr[ETH_ALEN]; /* P2P Device Address of the peer */
|
struct p2p_peer_info info;
|
||||||
u8 pri_dev_type[8];
|
|
||||||
char device_name[33];
|
|
||||||
u16 config_methods;
|
|
||||||
u8 dev_capab;
|
|
||||||
u8 group_capab;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the peer was discovered based on an interface address (e.g., GO
|
* If the peer was discovered based on an interface address (e.g., GO
|
||||||
|
|
|
@ -53,7 +53,7 @@ static struct wpabuf * p2p_build_invitation_req(struct p2p_data *p2p,
|
||||||
if (go_dev_addr)
|
if (go_dev_addr)
|
||||||
dev_addr = go_dev_addr;
|
dev_addr = go_dev_addr;
|
||||||
else if (p2p->inv_role == P2P_INVITE_ROLE_CLIENT)
|
else if (p2p->inv_role == P2P_INVITE_ROLE_CLIENT)
|
||||||
dev_addr = peer->p2p_device_addr;
|
dev_addr = peer->info.p2p_device_addr;
|
||||||
else
|
else
|
||||||
dev_addr = p2p->cfg->dev_addr;
|
dev_addr = p2p->cfg->dev_addr;
|
||||||
p2p_buf_add_group_id(buf, dev_addr, p2p->inv_ssid, p2p->inv_ssid_len);
|
p2p_buf_add_group_id(buf, dev_addr, p2p->inv_ssid, p2p->inv_ssid_len);
|
||||||
|
@ -343,7 +343,7 @@ int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: No Listen/Operating frequency known for the "
|
"P2P: No Listen/Operating frequency known for the "
|
||||||
"peer " MACSTR " to send Invitation Request",
|
"peer " MACSTR " to send Invitation Request",
|
||||||
MAC2STR(dev->p2p_device_addr));
|
MAC2STR(dev->info.p2p_device_addr));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,8 +356,8 @@ int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev,
|
||||||
p2p->pending_action_state = P2P_PENDING_INVITATION_REQUEST;
|
p2p->pending_action_state = P2P_PENDING_INVITATION_REQUEST;
|
||||||
p2p->invite_peer = dev;
|
p2p->invite_peer = dev;
|
||||||
dev->invitation_reqs++;
|
dev->invitation_reqs++;
|
||||||
if (p2p_send_action(p2p, freq, dev->p2p_device_addr,
|
if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
|
||||||
p2p->cfg->dev_addr, dev->p2p_device_addr,
|
p2p->cfg->dev_addr, dev->info.p2p_device_addr,
|
||||||
wpabuf_head(req), wpabuf_len(req), 200) < 0) {
|
wpabuf_head(req), wpabuf_len(req), 200) < 0) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Failed to send Action frame");
|
"P2P: Failed to send Action frame");
|
||||||
|
@ -443,7 +443,8 @@ int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
|
if (dev->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
|
||||||
if (!(dev->dev_capab & P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
|
if (!(dev->info.dev_capab &
|
||||||
|
P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Cannot invite a P2P Device " MACSTR
|
"P2P: Cannot invite a P2P Device " MACSTR
|
||||||
" that is in a group and is not discoverable",
|
" that is in a group and is not discoverable",
|
||||||
|
|
|
@ -56,8 +56,8 @@ static struct wpabuf * p2p_build_prov_disc_req(struct p2p_data *p2p,
|
||||||
p2p_buf_add_capability(buf, p2p->dev_capab, 0);
|
p2p_buf_add_capability(buf, p2p->dev_capab, 0);
|
||||||
p2p_buf_add_device_info(buf, p2p, NULL);
|
p2p_buf_add_device_info(buf, p2p, NULL);
|
||||||
if (go) {
|
if (go) {
|
||||||
p2p_buf_add_group_id(buf, go->p2p_device_addr, go->oper_ssid,
|
p2p_buf_add_group_id(buf, go->info.p2p_device_addr,
|
||||||
go->oper_ssid_len);
|
go->oper_ssid, go->oper_ssid_len);
|
||||||
}
|
}
|
||||||
p2p_buf_update_ie_hdr(buf, len);
|
p2p_buf_update_ie_hdr(buf, len);
|
||||||
|
|
||||||
|
@ -266,16 +266,17 @@ int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: No Listen/Operating frequency known for the "
|
"P2P: No Listen/Operating frequency known for the "
|
||||||
"peer " MACSTR " to send Provision Discovery Request",
|
"peer " MACSTR " to send Provision Discovery Request",
|
||||||
MAC2STR(dev->p2p_device_addr));
|
MAC2STR(dev->info.p2p_device_addr));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
|
if (dev->flags & P2P_DEV_GROUP_CLIENT_ONLY) {
|
||||||
if (!(dev->dev_capab & P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
|
if (!(dev->info.dev_capab &
|
||||||
|
P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY)) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Cannot use PD with P2P Device " MACSTR
|
"P2P: Cannot use PD with P2P Device " MACSTR
|
||||||
" that is in a group and is not discoverable",
|
" that is in a group and is not discoverable",
|
||||||
MAC2STR(dev->p2p_device_addr));
|
MAC2STR(dev->info.p2p_device_addr));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* TODO: use device discoverability request through GO */
|
/* TODO: use device discoverability request through GO */
|
||||||
|
@ -291,8 +292,8 @@ int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
p2p->pending_action_state = P2P_PENDING_PD;
|
p2p->pending_action_state = P2P_PENDING_PD;
|
||||||
if (p2p_send_action(p2p, freq, dev->p2p_device_addr,
|
if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
|
||||||
p2p->cfg->dev_addr, dev->p2p_device_addr,
|
p2p->cfg->dev_addr, dev->info.p2p_device_addr,
|
||||||
wpabuf_head(req), wpabuf_len(req), 200) < 0) {
|
wpabuf_head(req), wpabuf_len(req), 200) < 0) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Failed to send Action frame");
|
"P2P: Failed to send Action frame");
|
||||||
|
|
|
@ -25,14 +25,15 @@ struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p,
|
||||||
{
|
{
|
||||||
struct p2p_sd_query *q;
|
struct p2p_sd_query *q;
|
||||||
|
|
||||||
if (!(dev->dev_capab & P2P_DEV_CAPAB_SERVICE_DISCOVERY))
|
if (!(dev->info.dev_capab & P2P_DEV_CAPAB_SERVICE_DISCOVERY))
|
||||||
return 0; /* peer does not support SD */
|
return 0; /* peer does not support SD */
|
||||||
|
|
||||||
for (q = p2p->sd_queries; q; q = q->next) {
|
for (q = p2p->sd_queries; q; q = q->next) {
|
||||||
if (q->for_all_peers && !(dev->flags & P2P_DEV_SD_INFO))
|
if (q->for_all_peers && !(dev->flags & P2P_DEV_SD_INFO))
|
||||||
return q;
|
return q;
|
||||||
if (!q->for_all_peers &&
|
if (!q->for_all_peers &&
|
||||||
os_memcmp(q->peer, dev->p2p_device_addr, ETH_ALEN) == 0)
|
os_memcmp(q->peer, dev->info.p2p_device_addr, ETH_ALEN) ==
|
||||||
|
0)
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +266,7 @@ int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: No Listen/Operating frequency known for the "
|
"P2P: No Listen/Operating frequency known for the "
|
||||||
"peer " MACSTR " to send SD Request",
|
"peer " MACSTR " to send SD Request",
|
||||||
MAC2STR(dev->p2p_device_addr));
|
MAC2STR(dev->info.p2p_device_addr));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +276,7 @@ int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
|
||||||
|
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Start Service Discovery with " MACSTR,
|
"P2P: Start Service Discovery with " MACSTR,
|
||||||
MAC2STR(dev->p2p_device_addr));
|
MAC2STR(dev->info.p2p_device_addr));
|
||||||
|
|
||||||
req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs);
|
req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs);
|
||||||
if (req == NULL)
|
if (req == NULL)
|
||||||
|
@ -285,8 +286,8 @@ int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
|
||||||
p2p->sd_query = query;
|
p2p->sd_query = query;
|
||||||
p2p->pending_action_state = P2P_PENDING_SD;
|
p2p->pending_action_state = P2P_PENDING_SD;
|
||||||
|
|
||||||
if (p2p_send_action(p2p, freq, dev->p2p_device_addr,
|
if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
|
||||||
p2p->cfg->dev_addr, dev->p2p_device_addr,
|
p2p->cfg->dev_addr, dev->info.p2p_device_addr,
|
||||||
wpabuf_head(req), wpabuf_len(req), 5000) < 0) {
|
wpabuf_head(req), wpabuf_len(req), 5000) < 0) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Failed to send Action frame");
|
"P2P: Failed to send Action frame");
|
||||||
|
@ -472,7 +473,7 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
|
||||||
u16 update_indic;
|
u16 update_indic;
|
||||||
|
|
||||||
if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
|
if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
|
||||||
os_memcmp(sa, p2p->sd_peer->p2p_device_addr, ETH_ALEN) != 0) {
|
os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Ignore unexpected GAS Initial Response from "
|
"P2P: Ignore unexpected GAS Initial Response from "
|
||||||
MACSTR, MAC2STR(sa));
|
MACSTR, MAC2STR(sa));
|
||||||
|
@ -713,7 +714,7 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
|
||||||
wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Response", data, len);
|
wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Response", data, len);
|
||||||
|
|
||||||
if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
|
if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
|
||||||
os_memcmp(sa, p2p->sd_peer->p2p_device_addr, ETH_ALEN) != 0) {
|
os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
|
||||||
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
||||||
"P2P: Ignore unexpected GAS Comeback Response from "
|
"P2P: Ignore unexpected GAS Comeback Response from "
|
||||||
MACSTR, MAC2STR(sa));
|
MACSTR, MAC2STR(sa));
|
||||||
|
|
|
@ -1995,15 +1995,28 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
|
||||||
wpas_p2p_cancel_remain_on_channel_cb(
|
wpas_p2p_cancel_remain_on_channel_cb(
|
||||||
wpa_s, data->remain_on_channel.freq);
|
wpa_s, data->remain_on_channel.freq);
|
||||||
break;
|
break;
|
||||||
case EVENT_P2P_DEV_FOUND:
|
case EVENT_P2P_DEV_FOUND: {
|
||||||
wpas_dev_found(wpa_s, data->p2p_dev_found.addr,
|
struct p2p_peer_info peer_info;
|
||||||
data->p2p_dev_found.dev_addr,
|
|
||||||
data->p2p_dev_found.pri_dev_type,
|
os_memset(&peer_info, 0, sizeof(peer_info));
|
||||||
data->p2p_dev_found.dev_name,
|
if (data->p2p_dev_found.dev_addr)
|
||||||
data->p2p_dev_found.config_methods,
|
os_memcpy(peer_info.p2p_device_addr,
|
||||||
data->p2p_dev_found.dev_capab,
|
data->p2p_dev_found.dev_addr, ETH_ALEN);
|
||||||
data->p2p_dev_found.group_capab);
|
if (data->p2p_dev_found.pri_dev_type)
|
||||||
|
os_memcpy(peer_info.pri_dev_type,
|
||||||
|
data->p2p_dev_found.pri_dev_type,
|
||||||
|
sizeof(peer_info.pri_dev_type));
|
||||||
|
if (data->p2p_dev_found.dev_name)
|
||||||
|
os_strlcpy(peer_info.device_name,
|
||||||
|
data->p2p_dev_found.dev_name,
|
||||||
|
sizeof(peer_info.device_name));
|
||||||
|
peer_info.config_methods = data->p2p_dev_found.config_methods;
|
||||||
|
peer_info.dev_capab = data->p2p_dev_found.dev_capab;
|
||||||
|
peer_info.group_capab = data->p2p_dev_found.group_capab;
|
||||||
|
|
||||||
|
wpas_dev_found(wpa_s, data->p2p_dev_found.addr, &peer_info);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case EVENT_P2P_GO_NEG_REQ_RX:
|
case EVENT_P2P_GO_NEG_REQ_RX:
|
||||||
wpas_go_neg_req_rx(wpa_s, data->p2p_go_neg_req_rx.src,
|
wpas_go_neg_req_rx(wpa_s, data->p2p_go_neg_req_rx.src,
|
||||||
data->p2p_go_neg_req_rx.dev_passwd_id);
|
data->p2p_go_neg_req_rx.dev_passwd_id);
|
||||||
|
|
|
@ -1130,19 +1130,21 @@ void wpas_go_neg_req_rx(void *ctx, const u8 *src, u16 dev_passwd_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wpas_dev_found(void *ctx, const u8 *addr, const u8 *dev_addr,
|
void wpas_dev_found(void *ctx, const u8 *addr,
|
||||||
const u8 *pri_dev_type, const char *dev_name,
|
const struct p2p_peer_info *info)
|
||||||
u16 config_methods, u8 dev_capab, u8 group_capab)
|
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = ctx;
|
struct wpa_supplicant *wpa_s = ctx;
|
||||||
char devtype[WPS_DEV_TYPE_BUFSIZE];
|
char devtype[WPS_DEV_TYPE_BUFSIZE];
|
||||||
|
|
||||||
wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_DEVICE_FOUND MACSTR
|
wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_DEVICE_FOUND MACSTR
|
||||||
" p2p_dev_addr=" MACSTR
|
" p2p_dev_addr=" MACSTR
|
||||||
" pri_dev_type=%s name='%s' config_methods=0x%x "
|
" pri_dev_type=%s name='%s' config_methods=0x%x "
|
||||||
"dev_capab=0x%x group_capab=0x%x",
|
"dev_capab=0x%x group_capab=0x%x",
|
||||||
MAC2STR(addr), MAC2STR(dev_addr),
|
MAC2STR(addr), MAC2STR(info->p2p_device_addr),
|
||||||
wps_dev_type_bin2str(pri_dev_type, devtype, sizeof(devtype)),
|
wps_dev_type_bin2str(info->pri_dev_type, devtype,
|
||||||
dev_name, config_methods, dev_capab, group_capab);
|
sizeof(devtype)),
|
||||||
|
info->device_name, info->config_methods,
|
||||||
|
info->dev_capab, info->group_capab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
enum p2p_wps_method;
|
enum p2p_wps_method;
|
||||||
struct p2p_go_neg_results;
|
struct p2p_go_neg_results;
|
||||||
enum p2p_send_action_result;
|
enum p2p_send_action_result;
|
||||||
|
struct p2p_peer_info;
|
||||||
|
|
||||||
int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s);
|
int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s);
|
||||||
void wpas_p2p_deinit(struct wpa_supplicant *wpa_s);
|
void wpas_p2p_deinit(struct wpa_supplicant *wpa_s);
|
||||||
|
@ -62,9 +63,8 @@ void wpas_p2p_rx_action(struct wpa_supplicant *wpa_s, const u8 *da,
|
||||||
u8 category, const u8 *data, size_t len, int freq);
|
u8 category, const u8 *data, size_t len, int freq);
|
||||||
void wpas_p2p_scan_ie(struct wpa_supplicant *wpa_s, struct wpabuf *ies);
|
void wpas_p2p_scan_ie(struct wpa_supplicant *wpa_s, struct wpabuf *ies);
|
||||||
void wpas_p2p_group_deinit(struct wpa_supplicant *wpa_s);
|
void wpas_p2p_group_deinit(struct wpa_supplicant *wpa_s);
|
||||||
void wpas_dev_found(void *ctx, const u8 *addr, const u8 *dev_addr,
|
void wpas_dev_found(void *ctx, const u8 *addr,
|
||||||
const u8 *pri_dev_type, const char *dev_name,
|
const struct p2p_peer_info *info);
|
||||||
u16 config_methods, u8 dev_capab, u8 group_capab);
|
|
||||||
void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res);
|
void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res);
|
||||||
void wpas_go_neg_req_rx(void *ctx, const u8 *src, u16 dev_passwd_id);
|
void wpas_go_neg_req_rx(void *ctx, const u8 *src, u16 dev_passwd_id);
|
||||||
void wpas_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods,
|
void wpas_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods,
|
||||||
|
|
Loading…
Reference in a new issue