P2P: Allow adding of WPS vendor extension attributes
This adds the ability to add WPS vendor extension attributes in P2P frames, like GO Negotiation and Probe Response frames. 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:
parent
4028a7fd43
commit
f95cac271b
6 changed files with 99 additions and 0 deletions
|
@ -1936,6 +1936,7 @@ void p2p_deinit(struct p2p_data *p2p)
|
|||
os_free(p2p->groups);
|
||||
wpabuf_free(p2p->sd_resp);
|
||||
os_free(p2p->after_scan_tx);
|
||||
p2p_remove_wps_vendor_extensions(p2p);
|
||||
os_free(p2p);
|
||||
}
|
||||
|
||||
|
@ -2019,6 +2020,40 @@ int p2p_set_sec_dev_types(struct p2p_data *p2p, const u8 dev_types[][8],
|
|||
}
|
||||
|
||||
|
||||
void p2p_remove_wps_vendor_extensions(struct p2p_data *p2p)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXTENSIONS; i++) {
|
||||
wpabuf_free(p2p->wps_vendor_ext[i]);
|
||||
p2p->wps_vendor_ext[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int p2p_add_wps_vendor_extension(struct p2p_data *p2p,
|
||||
const struct wpabuf *vendor_ext)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (vendor_ext == NULL)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXTENSIONS; i++) {
|
||||
if (p2p->wps_vendor_ext[i] == NULL)
|
||||
break;
|
||||
}
|
||||
if (i >= P2P_MAX_WPS_VENDOR_EXTENSIONS)
|
||||
return -1;
|
||||
|
||||
p2p->wps_vendor_ext[i] = wpabuf_dup(vendor_ext);
|
||||
if (p2p->wps_vendor_ext[i] == NULL)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int p2p_set_country(struct p2p_data *p2p, const char *country)
|
||||
{
|
||||
os_memcpy(p2p->cfg->country, country, 3);
|
||||
|
|
|
@ -1405,4 +1405,22 @@ const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next);
|
|||
const struct p2p_peer_info *
|
||||
p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next);
|
||||
|
||||
/**
|
||||
* p2p_remove_wps_vendor_extensions - Remove WPS vendor extensions
|
||||
* @p2p: P2P module context from p2p_init()
|
||||
*/
|
||||
void p2p_remove_wps_vendor_extensions(struct p2p_data *p2p);
|
||||
|
||||
/**
|
||||
* p2p_add_wps_vendor_extension - Add a WPS vendor extension
|
||||
* @p2p: P2P module context from p2p_init()
|
||||
* @vendor_ext: The vendor extensions to add
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* The wpabuf structures in the array are owned by the P2P
|
||||
* module after this call.
|
||||
*/
|
||||
int p2p_add_wps_vendor_extension(struct p2p_data *p2p,
|
||||
const struct wpabuf *vendor_ext);
|
||||
|
||||
#endif /* P2P_H */
|
||||
|
|
|
@ -334,6 +334,8 @@ void p2p_build_wps_ie(struct p2p_data *p2p, struct wpabuf *buf, u16 pw_id,
|
|||
int all_attr)
|
||||
{
|
||||
u8 *len;
|
||||
int i;
|
||||
|
||||
wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
|
||||
len = wpabuf_put(buf, 1);
|
||||
wpabuf_put_be32(buf, WPS_DEV_OUI_WFA);
|
||||
|
@ -394,5 +396,17 @@ void p2p_build_wps_ie(struct p2p_data *p2p, struct wpabuf *buf, u16 pw_id,
|
|||
p2p->cfg->num_sec_dev_types);
|
||||
}
|
||||
|
||||
/* Add the WPS vendor extensions */
|
||||
for (i = 0; i < P2P_MAX_WPS_VENDOR_EXTENSIONS; i++) {
|
||||
if (p2p->wps_vendor_ext[i] == NULL)
|
||||
break;
|
||||
if (wpabuf_tailroom(buf) <
|
||||
4 + wpabuf_len(p2p->wps_vendor_ext[i]))
|
||||
continue;
|
||||
wpabuf_put_be16(buf, ATTR_VENDOR_EXT);
|
||||
wpabuf_put_be16(buf, wpabuf_len(p2p->wps_vendor_ext[i]));
|
||||
wpabuf_put_buf(buf, p2p->wps_vendor_ext[i]);
|
||||
}
|
||||
|
||||
p2p_buf_update_ie_hdr(buf, len);
|
||||
}
|
||||
|
|
|
@ -384,6 +384,12 @@ struct p2p_data {
|
|||
int best_freq_24;
|
||||
int best_freq_5;
|
||||
int best_freq_overall;
|
||||
|
||||
#define P2P_MAX_WPS_VENDOR_EXTENSIONS 10
|
||||
/**
|
||||
* wps_vendor_ext - WPS Vendor Extensions to add
|
||||
*/
|
||||
struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXTENSIONS];
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue