[PATCH 11/19] P2PS: add provision discovery request feature capability
Ilan Peer
ilan.peer
Wed Jun 10 01:43:41 PDT 2015
From: Max Stepanov <Max.Stepanov at intel.com>
Replace a hardcoded feature capability value of P2PS provision
discovery with a configurable one. The ASP PD request/response ctrl-iface
API was extended with an optional feature_cap=<hex_val> parameter in
P2P_ASP_PROVISION and P2P_ASP_PROVISION_RESP commands. A value of the
parameter is used as a feature capability value in PD frames.
If feature_cap parameter is not specified, a supplicant uses
UDP Transport (0x01) as a default value of Coordination Protocol
Transport Bitmask.
Use request's feature capability for PD response as a temporary
solution, this is about to be changed in the following patches.
Signed-off-by: Max Stepanov <Max.Stepanov at intel.com>
Reviewed-by: Ilan Peer <ilan.peer at intel.com>
---
src/common/ieee802_11_defs.h | 3 +++
src/p2p/p2p.h | 6 ++++++
src/p2p/p2p_pd.c | 24 ++++++++++++++----------
wpa_supplicant/ctrl_iface.c | 10 ++++++++++
4 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
index 47b15de..1727fa7 100644
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -1067,6 +1067,9 @@ enum p2p_attr_id {
#define P2P_GROUP_CAPAB_GROUP_FORMATION BIT(6)
#define P2P_GROUP_CAPAB_IP_ADDR_ALLOCATION BIT(7)
+/* P2PS Feature Capability bitmap */
+#define P2PS_FEATURE_CAPAB_UDP_TRANSPORT BIT(0)
+
/* Invitation Flags */
#define P2P_INVITATION_FLAGS_TYPE BIT(0)
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 7806598..82c8454 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -21,6 +21,7 @@
#define P2PS_WILD_HASH_STR "org.wi-fi.wfds"
#define P2PS_HASH_LEN 6
#define P2P_MAX_QUERY_HASH 6
+#define P2PS_FEATURE_CAPAB_LEN 2
/**
* P2P_MAX_REG_CLASSES - Maximum number of regulatory classes
@@ -196,6 +197,11 @@ struct p2ps_provision {
u8 adv_mac[ETH_ALEN];
/**
+ * feature_cap - feature capability
+ */
+ u8 feature_cap[P2PS_FEATURE_CAPAB_LEN];
+
+ /**
* info - Vendor defined extra Provisioning information
*/
char info[0];
diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c
index 4e70a7b..89c9a3a 100644
--- a/src/p2p/p2p_pd.c
+++ b/src/p2p/p2p_pd.c
@@ -79,10 +79,10 @@ static void p2ps_add_new_group_info(struct p2p_data *p2p, struct wpabuf *buf)
static void p2ps_add_pd_req_attrs(struct p2p_data *p2p, struct p2p_device *dev,
- struct wpabuf *buf, u16 config_methods)
+ struct wpabuf *buf, u16 config_methods,
+ const u8 *feat_cap, u16 feat_cap_len)
{
struct p2ps_provision *prov = p2p->p2ps_prov;
- u8 feat_cap_mask[] = { 1, 0 };
int shared_group = 0;
u8 ssid[SSID_MAX_LEN];
size_t ssid_len;
@@ -146,8 +146,7 @@ static void p2ps_add_pd_req_attrs(struct p2p_data *p2p, struct p2p_device *dev,
p2p_buf_add_session_id(buf, prov->session_id, prov->session_mac);
- p2p_buf_add_feature_capability(buf, sizeof(feat_cap_mask),
- feat_cap_mask);
+ p2p_buf_add_feature_capability(buf, feat_cap_len, feat_cap);
if (shared_group)
p2p_buf_add_persistent_group_info(buf, go_dev_addr,
@@ -201,7 +200,9 @@ static struct wpabuf * p2p_build_prov_disc_req(struct p2p_data *p2p,
group_capab);
p2p_buf_add_device_info(buf, p2p, NULL);
if (p2p->p2ps_prov) {
- p2ps_add_pd_req_attrs(p2p, dev, buf, config_methods);
+ p2ps_add_pd_req_attrs(p2p, dev, buf, config_methods,
+ p2p->p2ps_prov->feature_cap,
+ sizeof(p2p->p2ps_prov->feature_cap));
} else if (go) {
p2p_buf_add_group_id(buf, go->info.p2p_device_addr,
go->oper_ssid, go->oper_ssid_len);
@@ -232,7 +233,9 @@ static struct wpabuf * p2p_build_prov_disc_resp(struct p2p_data *p2p,
const u8 *group_id,
size_t group_id_len,
const u8 *persist_ssid,
- size_t persist_ssid_len)
+ size_t persist_ssid_len,
+ const u8 *feat_cap,
+ size_t feat_cap_len)
{
struct wpabuf *buf;
size_t extra = 0;
@@ -270,7 +273,6 @@ static struct wpabuf * p2p_build_prov_disc_resp(struct p2p_data *p2p,
/* Add P2P IE for P2PS */
if (p2p->p2ps_prov && p2p->p2ps_prov->adv_id == adv_id) {
- u8 feat_cap_mask[] = { 1, 0 };
u8 *len = p2p_buf_add_ie_hdr(buf);
struct p2ps_provision *prov = p2p->p2ps_prov;
u8 group_capab;
@@ -344,8 +346,7 @@ static struct wpabuf * p2p_build_prov_disc_resp(struct p2p_data *p2p,
p2p_buf_add_session_id(buf, prov->session_id,
prov->session_mac);
- p2p_buf_add_feature_capability(buf, sizeof(feat_cap_mask),
- feat_cap_mask);
+ p2p_buf_add_feature_capability(buf, feat_cap_len, feat_cap);
p2p_buf_update_ie_hdr(buf, len);
} else if (status != P2P_SC_SUCCESS || adv_id) {
u8 *len = p2p_buf_add_ie_hdr(buf);
@@ -655,11 +656,14 @@ out:
config_methods = msg.wps_config_methods;
else
config_methods = 0;
+
resp = p2p_build_prov_disc_resp(p2p, dev, msg.dialog_token, reject,
config_methods, adv_id,
msg.group_id, msg.group_id_len,
msg.persistent_ssid,
- msg.persistent_ssid_len);
+ msg.persistent_ssid_len,
+ msg.feature_cap,
+ msg.feature_cap_len);
if (resp == NULL) {
p2p_parse_free(&msg);
return;
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index faf683c..ce5a155 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -4705,6 +4705,16 @@ static struct p2ps_provision * p2p_parse_asp_provision_cmd(const char *cmd)
}
p2ps_prov->role = role;
+ pos = os_strstr(cmd, "feature_cap=");
+ if (pos) {
+ /* read a hexadecimal string of all feature capability bytes */
+ if (hexstr2bin(pos + 12, p2ps_prov->feature_cap,
+ sizeof(p2ps_prov->feature_cap)) < 0)
+ goto invalid_args;
+ } else {
+ p2ps_prov->feature_cap[0] = P2PS_FEATURE_CAPAB_UDP_TRANSPORT;
+ }
+
return p2ps_prov;
invalid_args:
--
1.9.1
More information about the Hostap
mailing list