P2PS: Add CPT parameter to P2PS_PROVISION and P2PS_PROVISION_RESP
authorMax Stepanov <Max.Stepanov@intel.com>
Thu, 2 Jul 2015 13:21:21 +0000 (16:21 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 26 Jul 2015 21:47:19 +0000 (00:47 +0300)
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>[:cpt]

where <cpt> 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 <Max.Stepanov@intel.com>
Reviewed-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
src/p2p/p2p.h
wpa_supplicant/ctrl_iface.c

index b195687..a4db554 100644 (file)
@@ -197,6 +197,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
         */
        char info[0];
index 16fb811..f7882ca 100644 (file)
@@ -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) {