]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2PS: Add service hash to Probe Request frames
authorBrian Gix <bgix@qce.qualcomm.com>
Fri, 5 Sep 2014 14:20:18 +0000 (17:20 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 2 Feb 2015 14:55:45 +0000 (16:55 +0200)
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/p2p/p2p.c
src/p2p/p2p_build.c
src/p2p/p2p_i.h

index f442c4881cefd5a057a4e551c2f03ae8aaec3d28..2f62bf7d7819942b9467f2690cc4c1f80438a3aa 100644 (file)
@@ -3074,6 +3074,7 @@ void p2p_scan_res_handled(struct p2p_data *p2p)
 
 void p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id)
 {
+       u8 dev_capab;
        u8 *len;
 
 #ifdef CONFIG_WIFI_DISPLAY
@@ -3086,8 +3087,15 @@ void p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id)
                               p2p->vendor_elem[VENDOR_ELEM_PROBE_REQ_P2P]);
 
        len = p2p_buf_add_ie_hdr(ies);
-       p2p_buf_add_capability(ies, p2p->dev_capab &
-                              ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY, 0);
+
+       dev_capab = p2p->dev_capab & ~P2P_DEV_CAPAB_CLIENT_DISCOVERABILITY;
+
+       /* P2PS requires Probe Request frames to include SD bit */
+       if (p2p->p2ps_seek && p2p->p2ps_seek_count)
+               dev_capab |= P2P_DEV_CAPAB_SERVICE_DISCOVERY;
+
+       p2p_buf_add_capability(ies, dev_capab, 0);
+
        if (dev_id)
                p2p_buf_add_device_id(ies, dev_id);
        if (p2p->cfg->reg_class && p2p->cfg->channel)
@@ -3097,6 +3105,10 @@ void p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id)
        if (p2p->ext_listen_interval)
                p2p_buf_add_ext_listen_timing(ies, p2p->ext_listen_period,
                                              p2p->ext_listen_interval);
+
+       if (p2p->p2ps_seek && p2p->p2ps_seek_count)
+               p2p_buf_add_service_hash(ies, p2p);
+
        /* TODO: p2p_buf_add_operating_channel() if GO */
        p2p_buf_update_ie_hdr(ies, len);
 }
index aaea89b1d2b6772c7f9b8984ca4b120d56c4b2b7..bb77f1814d60e83722416b46f779999fc1411c51 100644 (file)
@@ -342,6 +342,21 @@ void p2p_buf_add_oob_go_neg_channel(struct wpabuf *buf, const char *country,
 }
 
 
+void p2p_buf_add_service_hash(struct wpabuf *buf, struct p2p_data *p2p)
+{
+       if (!p2p)
+               return;
+
+       /* Service Hash */
+       wpabuf_put_u8(buf, P2P_ATTR_SERVICE_HASH);
+       wpabuf_put_le16(buf, p2p->p2ps_seek_count * P2PS_HASH_LEN);
+       wpabuf_put_data(buf, p2p->query_hash,
+                       p2p->p2ps_seek_count * P2PS_HASH_LEN);
+       wpa_hexdump(MSG_DEBUG, "P2P: * Service Hash",
+                   p2p->query_hash, p2p->p2ps_seek_count * P2PS_HASH_LEN);
+}
+
+
 void p2p_buf_add_session_info(struct wpabuf *buf, const char *info)
 {
        size_t info_len = 0;
index e7bcf0045933fa24b23f93ee11e66b648e4b1ca3..f686c88c639a399c02d200066ab58bef45c01069 100644 (file)
@@ -729,6 +729,7 @@ void p2p_buf_add_p2p_interface(struct wpabuf *buf, struct p2p_data *p2p);
 void p2p_buf_add_oob_go_neg_channel(struct wpabuf *buf, const char *country,
                                    u8 oper_class, u8 channel,
                                    enum p2p_role_indication role);
+void p2p_buf_add_service_hash(struct wpabuf *buf, struct p2p_data *p2p);
 void p2p_buf_add_session_info(struct wpabuf *buf, const char *info);
 void p2p_buf_add_connection_capability(struct wpabuf *buf, u8 connection_cap);
 void p2p_buf_add_advertisement_id(struct wpabuf *buf, u32 id, const u8 *mac);