From 0670de74ae1b842712b09f48af2e33547d2f34a2 Mon Sep 17 00:00:00 2001 From: Max Stepanov Date: Thu, 2 Jul 2015 16:21:21 +0300 Subject: [PATCH] P2PS: Add CPT parameter to P2PS_PROVISION and P2PS_PROVISION_RESP Add a parameter allowing to specify a value of Coordination Protocol Transport to P2PS_PROVISION and P2PS_PROVISION_RESP commands. Extend the p2ps_provision structure to contain cpt_priority and cpt_mask properties and initialize them on a P2PS PD request command. The format of the parameter: cpt=[:cpt] where is CPT name e.g. UDP or MAC. The CPT names are listed according to their preferences to be used for a specific P2PS session. Signed-off-by: Max Stepanov Reviewed-by: Andrei Otcheretianski Reviewed-by: Ilan Peer --- src/p2p/p2p.h | 17 +++++++++++++++++ wpa_supplicant/ctrl_iface.c | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index b1956870d..a4db554e1 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -196,6 +196,23 @@ struct p2ps_provision { */ u8 adv_mac[ETH_ALEN]; + /** + * cpt_mask - Supported Coordination Protocol Transport mask + * + * A bitwise mask of supported ASP Coordination Protocol Transports. + * This property is set together and corresponds with cpt_priority. + */ + u8 cpt_mask; + + /** + * cpt_priority - Coordination Protocol Transport priority list + * + * Priorities of supported ASP Coordination Protocol Transports. + * This property is set together and corresponds with cpt_mask. + * The CPT priority list is 0 terminated. + */ + u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1]; + /** * info - Vendor defined extra Provisioning information */ diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 16fb8115d..f7882ca54 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -4702,6 +4702,7 @@ static struct p2ps_provision * p2p_parse_asp_provision_cmd(const char *cmd) char *info = NULL; u8 role = P2PS_SETUP_NONE; long long unsigned val; + int i; pos = os_strstr(cmd, "info="); if (pos) { @@ -4760,6 +4761,18 @@ static struct p2ps_provision * p2p_parse_asp_provision_cmd(const char *cmd) if (!pos || hwaddr_aton(pos + 12, p2ps_prov->session_mac)) goto invalid_args; + pos = os_strstr(cmd, "cpt="); + if (pos) { + if (p2ps_ctrl_parse_cpt_priority(pos + 4, + p2ps_prov->cpt_priority)) + goto invalid_args; + } else { + p2ps_prov->cpt_priority[0] = P2PS_FEATURE_CAPAB_UDP_TRANSPORT; + } + + for (i = 0; p2ps_prov->cpt_priority[i]; i++) + p2ps_prov->cpt_mask |= p2ps_prov->cpt_priority[i]; + /* force conncap with tstCap (no sanity checks) */ pos = os_strstr(cmd, "tstCap="); if (pos) {