|
@@ -61,7 +61,7 @@ static void p2p_expire_peers(struct p2p_data *p2p)
|
|
|
if (dev->last_seen.sec + P2P_PEER_EXPIRATION_AGE >= now.sec)
|
|
|
continue;
|
|
|
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);
|
|
|
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));
|
|
|
res.status = status;
|
|
|
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);
|
|
|
os_memcpy(res.peer_interface_addr, peer->intended_addr,
|
|
|
ETH_ALEN);
|
|
@@ -262,7 +262,7 @@ struct p2p_device * p2p_get_device(struct p2p_data *p2p, const u8 *addr)
|
|
|
{
|
|
|
struct p2p_device *dev;
|
|
|
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 NULL;
|
|
@@ -324,7 +324,7 @@ static struct p2p_device * p2p_create_device(struct p2p_data *p2p,
|
|
|
if (dev == NULL)
|
|
|
return NULL;
|
|
|
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;
|
|
|
}
|
|
@@ -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,
|
|
|
struct p2p_client_info *cli)
|
|
|
{
|
|
|
- os_memcpy(dev->device_name, cli->dev_name, cli->dev_name_len);
|
|
|
- dev->device_name[cli->dev_name_len] = '\0';
|
|
|
- dev->dev_capab = cli->dev_capab;
|
|
|
- dev->config_methods = cli->config_methods;
|
|
|
- os_memcpy(dev->pri_dev_type, cli->pri_dev_type, 8);
|
|
|
+ os_memcpy(dev->info.device_name, cli->dev_name, cli->dev_name_len);
|
|
|
+ dev->info.device_name[cli->dev_name_len] = '\0';
|
|
|
+ dev->info.dev_capab = cli->dev_capab;
|
|
|
+ dev->info.config_methods = cli->config_methods;
|
|
|
+ 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;
|
|
|
p2p_copy_client_info(dev, cli);
|
|
|
dev->oper_freq = freq;
|
|
|
- p2p->cfg->dev_found(
|
|
|
- p2p->cfg->cb_ctx, dev->p2p_device_addr,
|
|
|
- dev->p2p_device_addr, dev->pri_dev_type,
|
|
|
- dev->device_name, dev->config_methods,
|
|
|
- dev->dev_capab, 0);
|
|
|
+ p2p->cfg->dev_found(p2p->cfg->cb_ctx,
|
|
|
+ dev->info.p2p_device_addr,
|
|
|
+ &dev->info);
|
|
|
}
|
|
|
|
|
|
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,
|
|
|
"P2P: Update Listen frequency based on scan "
|
|
|
"results (" MACSTR " %d -> %d MHz (DS param %d)",
|
|
|
- MAC2STR(dev->p2p_device_addr), dev->listen_freq, freq,
|
|
|
- msg.ds_params ? *msg.ds_params : -1);
|
|
|
+ MAC2STR(dev->info.p2p_device_addr), dev->listen_freq,
|
|
|
+ freq, msg.ds_params ? *msg.ds_params : -1);
|
|
|
}
|
|
|
dev->listen_freq = freq;
|
|
|
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;
|
|
|
|
|
|
if (msg.pri_dev_type)
|
|
|
- os_memcpy(dev->pri_dev_type, msg.pri_dev_type,
|
|
|
- sizeof(dev->pri_dev_type));
|
|
|
- os_memcpy(dev->device_name, msg.device_name, sizeof(dev->device_name));
|
|
|
- dev->config_methods = msg.config_methods ? msg.config_methods :
|
|
|
+ os_memcpy(dev->info.pri_dev_type, msg.pri_dev_type,
|
|
|
+ sizeof(dev->info.pri_dev_type));
|
|
|
+ os_memcpy(dev->info.device_name, msg.device_name,
|
|
|
+ sizeof(dev->info.device_name));
|
|
|
+ dev->info.config_methods = msg.config_methods ? msg.config_methods :
|
|
|
msg.wps_config_methods;
|
|
|
+
|
|
|
if (msg.capability) {
|
|
|
- dev->dev_capab = msg.capability[0];
|
|
|
- dev->group_capab = msg.capability[1];
|
|
|
+ dev->info.dev_capab = msg.capability[0];
|
|
|
+ dev->info.group_capab = msg.capability[1];
|
|
|
}
|
|
|
|
|
|
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");
|
|
|
return 0;
|
|
|
}
|
|
|
- p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, dev->p2p_device_addr,
|
|
|
- dev->pri_dev_type, dev->device_name,
|
|
|
- dev->config_methods, dev->dev_capab,
|
|
|
- dev->group_capab);
|
|
|
+ p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info);
|
|
|
dev->flags |= P2P_DEV_REPORTED;
|
|
|
|
|
|
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->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,
|
|
|
"P2P: Cannot connect to P2P Device " MACSTR
|
|
|
" 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);
|
|
|
|
|
|
if (msg->pri_dev_type)
|
|
|
- os_memcpy(dev->pri_dev_type, msg->pri_dev_type,
|
|
|
- sizeof(dev->pri_dev_type));
|
|
|
- os_memcpy(dev->device_name, msg->device_name,
|
|
|
- sizeof(dev->device_name));
|
|
|
- dev->config_methods = msg->config_methods ? msg->config_methods :
|
|
|
+ os_memcpy(dev->info.pri_dev_type, msg->pri_dev_type,
|
|
|
+ sizeof(dev->info.pri_dev_type));
|
|
|
+ os_memcpy(dev->info.device_name, msg->device_name,
|
|
|
+ sizeof(dev->info.device_name));
|
|
|
+ dev->info.config_methods = msg->config_methods ? msg->config_methods :
|
|
|
msg->wps_config_methods;
|
|
|
if (msg->capability) {
|
|
|
- dev->dev_capab = msg->capability[0];
|
|
|
- dev->group_capab = msg->capability[1];
|
|
|
+ dev->info.dev_capab = msg->capability[0];
|
|
|
+ dev->info.group_capab = msg->capability[1];
|
|
|
}
|
|
|
if (msg->listen_channel) {
|
|
|
int freq;
|
|
@@ -1086,7 +1084,7 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
|
|
|
} else {
|
|
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Update "
|
|
|
"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;
|
|
|
}
|
|
@@ -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: "
|
|
|
MACSTR " dev_capab=0x%x group_capab=0x%x name='%s' "
|
|
|
"listen_freq=%d",
|
|
|
- MAC2STR(dev->p2p_device_addr), dev->dev_capab,
|
|
|
- dev->group_capab, dev->device_name, dev->listen_freq);
|
|
|
+ MAC2STR(dev->info.p2p_device_addr),
|
|
|
+ dev->info.dev_capab, dev->info.group_capab,
|
|
|
+ dev->info.device_name, dev->listen_freq);
|
|
|
}
|
|
|
|
|
|
dev->flags &= ~P2P_DEV_GROUP_CLIENT_ONLY;
|
|
@@ -1119,10 +1118,7 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, dev->p2p_device_addr,
|
|
|
- dev->pri_dev_type, dev->device_name,
|
|
|
- dev->config_methods, dev->dev_capab,
|
|
|
- dev->group_capab);
|
|
|
+ p2p->cfg->dev_found(p2p->cfg->cb_ctx, addr, &dev->info);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1154,12 +1150,12 @@ void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer)
|
|
|
|
|
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
|
|
"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");
|
|
|
|
|
|
os_memset(&res, 0, sizeof(res));
|
|
|
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);
|
|
|
res.wps_method = peer->wps_method;
|
|
|
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;
|
|
|
|
|
|
if (msg.capability) {
|
|
|
- dev->dev_capab = msg.capability[0];
|
|
|
- dev->group_capab = msg.capability[1];
|
|
|
+ dev->info.dev_capab = msg.capability[0];
|
|
|
+ dev->info.group_capab = msg.capability[1];
|
|
|
}
|
|
|
|
|
|
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]);
|
|
|
}
|
|
|
|
|
|
- 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)
|
|
|
- os_memcpy(dev->pri_dev_type, msg.wps_pri_dev_type,
|
|
|
- sizeof(dev->pri_dev_type));
|
|
|
+ os_memcpy(dev->info.pri_dev_type, msg.wps_pri_dev_type,
|
|
|
+ sizeof(dev->info.pri_dev_type));
|
|
|
|
|
|
p2p_parse_free(&msg);
|
|
|
|
|
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
|
|
"P2P: Created device entry based on Probe Req: " MACSTR
|
|
|
" dev_capab=0x%x group_capab=0x%x name='%s' listen_freq=%d",
|
|
|
- MAC2STR(dev->p2p_device_addr), dev->dev_capab,
|
|
|
- dev->group_capab, dev->device_name, dev->listen_freq);
|
|
|
+ MAC2STR(dev->info.p2p_device_addr), dev->info.dev_capab,
|
|
|
+ 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) &&
|
|
|
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 */
|
|
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
|
|
"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) &&
|
|
|
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 */
|
|
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
|
|
"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 "
|
|
|
"pending Provisioning Discovery Request to "
|
|
|
MACSTR " (config methods 0x%x)",
|
|
|
- MAC2STR(dev->p2p_device_addr),
|
|
|
+ MAC2STR(dev->info.p2p_device_addr),
|
|
|
dev->req_config_methods);
|
|
|
if (p2p_send_prov_disc_req(p2p, dev, 0) == 0)
|
|
|
return;
|
|
@@ -2047,7 +2045,6 @@ static void p2p_sd_cb(struct p2p_data *p2p, int success)
|
|
|
p2p_set_timeout(p2p, 0, 200000);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
static void p2p_prov_disc_cb(struct p2p_data *p2p, int success)
|
|
|
{
|
|
|
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);
|
|
|
|
|
|
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,
|
|
|
"P2P: Found GO Negotiation peer - try to start GO "
|
|
|
"negotiation");
|
|
@@ -2148,12 +2145,12 @@ static void p2p_go_neg_req_cb(struct p2p_data *p2p, int 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)) {
|
|
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
|
|
|
"P2P: Peer " MACSTR " did not acknowledge request - "
|
|
|
"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_send_dev_disc_req(p2p, dev);
|
|
|
return;
|
|
@@ -2623,7 +2620,7 @@ int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
|
|
|
end = buf + buflen;
|
|
|
|
|
|
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)
|
|
|
return pos - buf;
|
|
|
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->member_in_go_dev),
|
|
|
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)),
|
|
|
- dev->device_name,
|
|
|
- dev->config_methods,
|
|
|
- dev->dev_capab,
|
|
|
- dev->group_capab,
|
|
|
+ dev->info.device_name,
|
|
|
+ dev->info.config_methods,
|
|
|
+ dev->info.dev_capab,
|
|
|
+ dev->info.group_capab,
|
|
|
dev->go_neg_req_sent,
|
|
|
p2p_go_state_text(dev->go_state),
|
|
|
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);
|
|
|
if (dev == NULL)
|
|
|
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;
|
|
|
}
|
|
|
|
|
@@ -3235,5 +3232,5 @@ const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p)
|
|
|
{
|
|
|
if (p2p == NULL || p2p->go_neg_peer == NULL)
|
|
|
return NULL;
|
|
|
- return p2p->go_neg_peer->p2p_device_addr;
|
|
|
+ return p2p->go_neg_peer->info.p2p_device_addr;
|
|
|
}
|