P2P: Keep track of secondary device types for peers

Signed-off-by: Jean-Michel Bachot <jean-michelx.bachot@linux.intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Jean-Michel Bachot 2011-03-17 11:45:46 +02:00 committed by Jouni Malinen
parent 8e8c0df158
commit e57ae6e19e
7 changed files with 61 additions and 0 deletions

View file

@ -338,6 +338,9 @@ static void p2p_copy_client_info(struct p2p_device *dev,
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);
dev->info.wps_sec_dev_type_list_len = 8 * cli->num_sec_dev_types;
os_memcpy(dev->info.wps_sec_dev_type_list, cli->sec_dev_types,
dev->info.wps_sec_dev_type_list_len);
}
@ -511,6 +514,14 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
dev->info.config_methods = msg.config_methods ? msg.config_methods :
msg.wps_config_methods;
if (msg.wps_sec_dev_type_list) {
os_memcpy(dev->info.wps_sec_dev_type_list,
msg.wps_sec_dev_type_list,
msg.wps_sec_dev_type_list_len);
dev->info.wps_sec_dev_type_list_len =
msg.wps_sec_dev_type_list_len;
}
if (msg.capability) {
dev->info.dev_capab = msg.capability[0];
dev->info.group_capab = msg.capability[1];
@ -1068,6 +1079,15 @@ void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
sizeof(dev->info.device_name));
dev->info.config_methods = msg->config_methods ? msg->config_methods :
msg->wps_config_methods;
if (msg->wps_sec_dev_type_list) {
os_memcpy(dev->info.wps_sec_dev_type_list,
msg->wps_sec_dev_type_list,
msg->wps_sec_dev_type_list_len);
dev->info.wps_sec_dev_type_list_len =
msg->wps_sec_dev_type_list_len;
}
if (msg->capability) {
dev->info.dev_capab = msg->capability[0];
dev->info.group_capab = msg->capability[1];
@ -1441,6 +1461,14 @@ static void p2p_add_dev_from_probe_req(struct p2p_data *p2p, const u8 *addr,
os_memcpy(dev->info.pri_dev_type, msg.wps_pri_dev_type,
sizeof(dev->info.pri_dev_type));
if (msg.wps_sec_dev_type_list) {
os_memcpy(dev->info.wps_sec_dev_type_list,
msg.wps_sec_dev_type_list,
msg.wps_sec_dev_type_list_len);
dev->info.wps_sec_dev_type_list_len =
msg.wps_sec_dev_type_list_len;
}
p2p_parse_free(&msg);
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,

View file

@ -172,6 +172,20 @@ struct p2p_peer_info {
* group_capab - Group Capabilities
*/
u8 group_capab;
/**
* wps_sec_dev_type_list - WPS secondary device type list
*
* This list includes from 0 to 16 Secondary Device Types as indicated
* by wps_sec_dev_type_list_len (8 * number of types).
*/
u8 wps_sec_dev_type_list[128];
/**
* wps_sec_dev_type_list_len - Length of secondary device type list
*/
size_t wps_sec_dev_type_list_len;
};
/**

View file

@ -437,6 +437,8 @@ struct p2p_message {
u16 dev_password_id;
u16 wps_config_methods;
const u8 *wps_pri_dev_type;
const u8 *wps_sec_dev_type_list;
size_t wps_sec_dev_type_list_len;
/* DS Parameter Set IE */
const u8 *ds_params;

View file

@ -353,6 +353,10 @@ static int p2p_parse_wps_ie(const struct wpabuf *buf, struct p2p_message *msg)
wps_dev_type_bin2str(msg->wps_pri_dev_type, devtype,
sizeof(devtype)));
}
if (attr.sec_dev_type_list) {
msg->wps_sec_dev_type_list = attr.sec_dev_type_list;
msg->wps_sec_dev_type_list_len = attr.sec_dev_type_list_len;
}
return 0;
}

View file

@ -63,6 +63,7 @@ struct wps_credential {
#define WPS_DEV_TYPE_LEN 8
#define WPS_DEV_TYPE_BUFSIZE 21
#define WPS_SEC_DEV_TYPE_MAX_LEN 128
/**
* struct wps_device_data - WPS Device Data

View file

@ -512,6 +512,16 @@ static int wps_set_attr(struct wps_parse_attr *attr, u16 type,
attr->req_dev_type[attr->num_req_dev_type] = pos;
attr->num_req_dev_type++;
break;
case ATTR_SECONDARY_DEV_TYPE_LIST:
if (len > WPS_SEC_DEV_TYPE_MAX_LEN ||
(len % WPS_DEV_TYPE_LEN) > 0) {
wpa_printf(MSG_DEBUG, "WPS: Invalid Secondary Device "
"Type length %u", len);
return -1;
}
attr->sec_dev_type_list = pos;
attr->sec_dev_type_list_len = len;
break;
case ATTR_VENDOR_EXT:
if (wps_parse_vendor_ext(attr, pos, len) < 0)
return -1;

View file

@ -195,6 +195,8 @@ struct wps_parse_attr {
size_t eap_identity_len;
const u8 *authorized_macs; /* <= 30 octets */
size_t authorized_macs_len;
const u8 *sec_dev_type_list; /* <= 128 octets */
size_t sec_dev_type_list_len;
/* attributes that can occur multiple times */
#define MAX_CRED_COUNT 10