From 83e520e4739bc290f2d34bca2fb1618502c936f7 Mon Sep 17 00:00:00 2001 From: Max Stepanov Date: Wed, 10 Jun 2015 11:43:48 +0300 Subject: [PATCH] P2PS: Add a wildcard with other advertised service info Quoting P2PS specification: "If multiple Service Hash values are included in the Probe Request frame, then the ASP shall find a match for each Service Hash, and it shall send a Probe Response frame with the information listed in this section for all matched Service Hashes." This commit changes handling of wildcard hash matching by adding a wildcard 'org.wi-fi.wfds' info together with the other hash matches. Signed-off-by: Max Stepanov Reviewed-by: Ilan Peer --- src/p2p/p2p_build.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/p2p/p2p_build.c b/src/p2p/p2p_build.c index fa7f589bb..ede78b2d3 100644 --- a/src/p2p/p2p_build.c +++ b/src/p2p/p2p_build.c @@ -551,8 +551,6 @@ void p2p_buf_add_service_instance(struct wpabuf *buf, struct p2p_data *p2p, return; p2ps_wildcard = p2ps_wildcard_hash(p2p, hash, hash_count); - if (p2ps_wildcard) - goto end; /* Allocate temp buffer, allowing for overflow of 1 instance */ tmp_buf = wpabuf_alloc(MAX_SVC_ADV_IE_LEN + 256 + P2PS_HASH_LEN); @@ -573,6 +571,12 @@ void p2p_buf_add_service_instance(struct wpabuf *buf, struct p2p_data *p2p, p2p_buf_update_ie_hdr(tmp_buf, ie_len); pos = wpabuf_put(tmp_buf, 0); + if (p2ps_wildcard) { + p2p_buf_add_service_info(tmp_buf, p2p, 0, 0, P2PS_WILD_HASH_STR, + &ie_len, &pos, &total_len, attr_len); + p2ps_wildcard = 0; + } + /* add advertised service info of matching services */ for (adv = adv_list; adv && total_len <= MAX_SVC_ADV_LEN; adv = adv->next) { @@ -606,9 +610,8 @@ void p2p_buf_add_service_instance(struct wpabuf *buf, struct p2p_data *p2p, end: if (p2ps_wildcard) { /* - * Add the attribute with P2PS wildcard if either a wildcard - * hash was present in a Probe Request frame hash attribute or - * we failed to add at least one matching advertisement. + * Add a single attribute with P2PS wildcard if we failed + * to add at least one matching advertisement. */ ie_len = p2p_buf_add_ie_hdr(buf); wpabuf_put_u8(buf, P2P_ATTR_ADVERTISED_SERVICE);