[PATCH 19/23] P2PS: Don't add unnecessary follow-on PD request attributes
Ilan Peer
ilan.peer
Thu Sep 24 10:38:09 PDT 2015
From: Max Stepanov <Max.Stepanov at intel.com>
Don't add unnecessary P2PS follow-on PD request attributes when
the request status differ of P2P_SC_SUCCESS_DEFERRED.
Signed-off-by: Max Stepanov <Max.Stepanov at intel.com>
---
src/p2p/p2p_pd.c | 77 ++++++++++++++++++++++++++++++++------------------------
1 file changed, 44 insertions(+), 33 deletions(-)
diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c
index 307523f..6f2235c 100644
--- a/src/p2p/p2p_pd.c
+++ b/src/p2p/p2p_pd.c
@@ -92,10 +92,13 @@ static void p2ps_add_pd_req_attrs(struct p2p_data *p2p, struct p2p_device *dev,
size_t ssid_len;
u8 go_dev_addr[ETH_ALEN];
u8 intended_addr[ETH_ALEN];
+ int follow_on_req_fail = (prov->status >= 0 &&
+ prov->status != P2P_SC_SUCCESS_DEFERRED);
/* If we might be explicite group owner, add GO details */
- if (prov->conncap & (P2PS_SETUP_GROUP_OWNER |
- P2PS_SETUP_NEW))
+ if (!follow_on_req_fail &&
+ (prov->conncap & (P2PS_SETUP_GROUP_OWNER |
+ P2PS_SETUP_NEW)))
p2ps_add_new_group_info(p2p, buf);
if (prov->status >= 0)
@@ -103,46 +106,54 @@ static void p2ps_add_pd_req_attrs(struct p2p_data *p2p, struct p2p_device *dev,
else
prov->method = config_methods;
- if (p2p->cfg->get_persistent_group) {
- shared_group = p2p->cfg->get_persistent_group(
- p2p->cfg->cb_ctx, dev->info.p2p_device_addr, NULL, 0,
- go_dev_addr, ssid, &ssid_len, intended_addr);
- }
-
- if (shared_group ||
- (prov->conncap & P2PS_SETUP_CLIENT) ||
- (prov->conncap & P2PS_SETUP_NEW))
- p2p_buf_add_channel_list(buf, p2p->cfg->country,
- &p2p->channels);
+ if (!follow_on_req_fail) {
+ if (p2p->cfg->get_persistent_group) {
+ shared_group = p2p->cfg->get_persistent_group(
+ p2p->cfg->cb_ctx, dev->info.p2p_device_addr,
+ NULL, 0, go_dev_addr, ssid, &ssid_len,
+ intended_addr);
+ }
- if ((shared_group && !is_zero_ether_addr(intended_addr)) ||
- (prov->conncap & P2PS_SETUP_GROUP_OWNER) ||
- (prov->conncap & P2PS_SETUP_NEW))
- p2p_buf_add_operating_channel(buf, p2p->cfg->country,
- p2p->op_reg_class,
- p2p->op_channel);
+ if (shared_group ||
+ (prov->conncap & P2PS_SETUP_CLIENT) ||
+ (prov->conncap & P2PS_SETUP_NEW))
+ p2p_buf_add_channel_list(buf, p2p->cfg->country,
+ &p2p->channels);
+
+ if ((shared_group && !is_zero_ether_addr(intended_addr)) ||
+ (prov->conncap & P2PS_SETUP_GROUP_OWNER) ||
+ (prov->conncap & P2PS_SETUP_NEW))
+ p2p_buf_add_operating_channel(buf, p2p->cfg->country,
+ p2p->op_reg_class,
+ p2p->op_channel);
+ }
- if (prov->info[0])
+ if (prov->status < 0 && prov->info[0])
p2p_buf_add_session_info(buf, prov->info);
- p2p_buf_add_connection_capability(buf, prov->conncap);
+ if (!follow_on_req_fail)
+ p2p_buf_add_connection_capability(buf, prov->conncap);
p2p_buf_add_advertisement_id(buf, prov->adv_id, prov->adv_mac);
- if (shared_group || prov->conncap == P2PS_SETUP_NEW ||
- prov->conncap ==
- (P2PS_SETUP_GROUP_OWNER | P2PS_SETUP_NEW) ||
- prov->conncap ==
- (P2PS_SETUP_GROUP_OWNER | P2PS_SETUP_CLIENT)) {
- /* Add Config Timeout */
- p2p_buf_add_config_timeout(buf, p2p->go_timeout,
- p2p->client_timeout);
- }
+ if (!follow_on_req_fail) {
+ if (shared_group || prov->conncap == P2PS_SETUP_NEW ||
+ prov->conncap ==
+ (P2PS_SETUP_GROUP_OWNER | P2PS_SETUP_NEW) ||
+ prov->conncap ==
+ (P2PS_SETUP_GROUP_OWNER | P2PS_SETUP_CLIENT)) {
+ /* Add Config Timeout */
+ p2p_buf_add_config_timeout(buf, p2p->go_timeout,
+ p2p->client_timeout);
+ }
- p2p_buf_add_listen_channel(buf, p2p->cfg->country, p2p->cfg->reg_class,
- p2p->cfg->channel);
+ p2p_buf_add_listen_channel(buf, p2p->cfg->country,
+ p2p->cfg->reg_class,
+ p2p->cfg->channel);
+ }
- p2p_buf_add_session_id(buf, prov->session_id, prov->session_mac);
+ p2p_buf_add_session_id(buf, prov->session_id,
+ prov->session_mac);
p2p_buf_add_feature_capability(buf, sizeof(fcap), (const u8 *) &fcap);
--
1.9.1
More information about the Hostap
mailing list