]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Keep track of secondary device types for peers
authorJean-Michel Bachot <jean-michelx.bachot@linux.intel.com>
Thu, 17 Mar 2011 09:45:46 +0000 (11:45 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 17 Mar 2011 09:45:46 +0000 (11:45 +0200)
Signed-off-by: Jean-Michel Bachot <jean-michelx.bachot@linux.intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
src/p2p/p2p.c
src/p2p/p2p.h
src/p2p/p2p_i.h
src/p2p/p2p_parse.c
src/wps/wps.h
src/wps/wps_attr_parse.c
src/wps/wps_i.h

index 3211ba2840bd151f5007ad2e3abcfb1f44b5b427..ba2c2c26bffb9aa1a2150b85a6c273be9eb05d9a 100644 (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,
index f41e64d6abb331b1df046acdbb452af265499263..eab15b85fbf79f360e88a72c5b336d37908b58ff 100644 (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;
+
 };
 
 /**
index 91ba5fd1da9512299f080b4729d88e07633ea0bb..782ea356a5eb274ec51699329a7ede26a1b96c72 100644 (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;
index 871badc311728d38676bcbc61daa70552fac445e..56c1e71b9edad53b6a90ff4272346842330a2464 100644 (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;
 }
index d2fca3f2e9af009e4b6ef8b1bc5177693984d568..60a33d5246a5d9f3b908db2d3c2b501e19e878ca 100644 (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
index 95463ebbdbaabc401daff6931df4a040cee751f7..0c4a4b4e6868a45144153a6f5064c148c6b75199 100644 (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;
index a9f8949e7866007009d9d19a6e2f24a39c549d04..827a82a677f414f875e075ead209e8665b944f4a 100644 (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