P2P: Clean up p2p_go_neg_failed() calls
This function is always called with the peer argument equal to p2p->go_neg_peer, so there is no need for that argument to be there. In addition, p2p->go_neg_peer is not NULL in cases where there is an ongoing GO Negotiation, so the function can be simplified to just check once whether the peer pointer is set and if not, skip all processing. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
0ee41e866c
commit
8c00fd00cd
3 changed files with 28 additions and 33 deletions
|
@ -211,30 +211,29 @@ void p2p_clear_timeout(struct p2p_data *p2p)
|
|||
}
|
||||
|
||||
|
||||
void p2p_go_neg_failed(struct p2p_data *p2p, struct p2p_device *peer,
|
||||
int status)
|
||||
void p2p_go_neg_failed(struct p2p_data *p2p, int status)
|
||||
{
|
||||
struct p2p_go_neg_results res;
|
||||
struct p2p_device *peer = p2p->go_neg_peer;
|
||||
|
||||
if (!peer)
|
||||
return;
|
||||
|
||||
p2p_clear_timeout(p2p);
|
||||
eloop_cancel_timeout(p2p_go_neg_wait_timeout, p2p, NULL);
|
||||
p2p_set_state(p2p, P2P_IDLE);
|
||||
if (p2p->go_neg_peer) {
|
||||
p2p->go_neg_peer->flags &= ~P2P_DEV_PEER_WAITING_RESPONSE;
|
||||
p2p->go_neg_peer->wps_method = WPS_NOT_READY;
|
||||
p2p->go_neg_peer->oob_pw_id = 0;
|
||||
}
|
||||
|
||||
peer->flags &= ~P2P_DEV_PEER_WAITING_RESPONSE;
|
||||
peer->wps_method = WPS_NOT_READY;
|
||||
peer->oob_pw_id = 0;
|
||||
wpabuf_free(peer->go_neg_conf);
|
||||
peer->go_neg_conf = NULL;
|
||||
p2p->go_neg_peer = NULL;
|
||||
|
||||
os_memset(&res, 0, sizeof(res));
|
||||
res.status = status;
|
||||
if (peer) {
|
||||
wpabuf_free(peer->go_neg_conf);
|
||||
peer->go_neg_conf = NULL;
|
||||
os_memcpy(res.peer_device_addr, peer->info.p2p_device_addr,
|
||||
ETH_ALEN);
|
||||
os_memcpy(res.peer_interface_addr, peer->intended_addr,
|
||||
ETH_ALEN);
|
||||
}
|
||||
os_memcpy(res.peer_device_addr, peer->info.p2p_device_addr, ETH_ALEN);
|
||||
os_memcpy(res.peer_interface_addr, peer->intended_addr, ETH_ALEN);
|
||||
p2p->cfg->go_neg_completed(p2p->cfg->cb_ctx, &res);
|
||||
}
|
||||
|
||||
|
@ -872,8 +871,7 @@ static void p2p_device_free(struct p2p_data *p2p, struct p2p_device *dev)
|
|||
/*
|
||||
* If GO Negotiation is in progress, report that it has failed.
|
||||
*/
|
||||
p2p_go_neg_failed(p2p, dev, -1);
|
||||
p2p->go_neg_peer = NULL;
|
||||
p2p_go_neg_failed(p2p, -1);
|
||||
}
|
||||
if (p2p->invite_peer == dev)
|
||||
p2p->invite_peer = NULL;
|
||||
|
@ -3109,8 +3107,7 @@ static void p2p_go_neg_resp_failure_cb(struct p2p_data *p2p, int success,
|
|||
{
|
||||
p2p_dbg(p2p, "GO Negotiation Response (failure) TX callback: success=%d", success);
|
||||
if (p2p->go_neg_peer && p2p->go_neg_peer->status != P2P_SC_SUCCESS) {
|
||||
p2p_go_neg_failed(p2p, p2p->go_neg_peer,
|
||||
p2p->go_neg_peer->status);
|
||||
p2p_go_neg_failed(p2p, p2p->go_neg_peer->status);
|
||||
} else if (success) {
|
||||
struct p2p_device *dev;
|
||||
dev = p2p_get_device(p2p, addr);
|
||||
|
@ -3129,7 +3126,7 @@ static void p2p_go_neg_conf_cb(struct p2p_data *p2p,
|
|||
p2p_dbg(p2p, "GO Negotiation Confirm TX callback: result=%d", result);
|
||||
if (result == P2P_SEND_ACTION_FAILED) {
|
||||
p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
|
||||
p2p_go_neg_failed(p2p, p2p->go_neg_peer, -1);
|
||||
p2p_go_neg_failed(p2p, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3300,7 +3297,7 @@ int p2p_listen_end(struct p2p_data *p2p, unsigned int freq)
|
|||
if (p2p->state == P2P_CONNECT_LISTEN && p2p->go_neg_peer) {
|
||||
if (p2p->go_neg_peer->connect_reqs >= 120) {
|
||||
p2p_dbg(p2p, "Timeout on sending GO Negotiation Request without getting response");
|
||||
p2p_go_neg_failed(p2p, p2p->go_neg_peer, -1);
|
||||
p2p_go_neg_failed(p2p, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3351,7 +3348,7 @@ static void p2p_timeout_connect(struct p2p_data *p2p)
|
|||
if (p2p->go_neg_peer &&
|
||||
(p2p->go_neg_peer->flags & P2P_DEV_WAIT_GO_NEG_CONFIRM)) {
|
||||
p2p_dbg(p2p, "Wait for GO Negotiation Confirm timed out - assume GO Negotiation failed");
|
||||
p2p_go_neg_failed(p2p, p2p->go_neg_peer, -1);
|
||||
p2p_go_neg_failed(p2p, -1);
|
||||
return;
|
||||
}
|
||||
if (p2p->go_neg_peer &&
|
||||
|
@ -3382,7 +3379,7 @@ static void p2p_timeout_connect_listen(struct p2p_data *p2p)
|
|||
|
||||
if (p2p->go_neg_peer->connect_reqs >= 120) {
|
||||
p2p_dbg(p2p, "Timeout on sending GO Negotiation Request without getting response");
|
||||
p2p_go_neg_failed(p2p, p2p->go_neg_peer, -1);
|
||||
p2p_go_neg_failed(p2p, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4906,6 +4903,5 @@ void p2p_go_neg_wait_timeout(void *eloop_ctx, void *timeout_ctx)
|
|||
|
||||
p2p_dbg(p2p,
|
||||
"Timeout on waiting peer to become ready for GO Negotiation");
|
||||
if (p2p->go_neg_peer)
|
||||
p2p_go_neg_failed(p2p, p2p->go_neg_peer, -1);
|
||||
p2p_go_neg_failed(p2p, -1);
|
||||
}
|
||||
|
|
|
@ -623,7 +623,7 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
|
|||
* Request frame.
|
||||
*/
|
||||
p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
|
||||
p2p_go_neg_failed(p2p, dev, *msg.status);
|
||||
p2p_go_neg_failed(p2p, *msg.status);
|
||||
p2p_parse_free(&msg);
|
||||
return;
|
||||
}
|
||||
|
@ -974,7 +974,7 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
|
|||
p2p_set_timeout(p2p, 0, 0);
|
||||
} else {
|
||||
p2p_dbg(p2p, "Stop GO Negotiation attempt");
|
||||
p2p_go_neg_failed(p2p, dev, *msg.status);
|
||||
p2p_go_neg_failed(p2p, *msg.status);
|
||||
}
|
||||
p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
|
||||
p2p_parse_free(&msg);
|
||||
|
@ -1156,13 +1156,13 @@ fail:
|
|||
wpabuf_head(dev->go_neg_conf),
|
||||
wpabuf_len(dev->go_neg_conf), 200) < 0) {
|
||||
p2p_dbg(p2p, "Failed to send Action frame");
|
||||
p2p_go_neg_failed(p2p, dev, -1);
|
||||
p2p_go_neg_failed(p2p, -1);
|
||||
p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
|
||||
} else
|
||||
dev->go_neg_conf_sent++;
|
||||
if (status != P2P_SC_SUCCESS) {
|
||||
p2p_dbg(p2p, "GO Negotiation failed");
|
||||
p2p_go_neg_failed(p2p, dev, status);
|
||||
p2p_go_neg_failed(p2p, status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1213,7 +1213,7 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
|
|||
}
|
||||
if (*msg.status) {
|
||||
p2p_dbg(p2p, "GO Negotiation rejected: status %d", *msg.status);
|
||||
p2p_go_neg_failed(p2p, dev, *msg.status);
|
||||
p2p_go_neg_failed(p2p, *msg.status);
|
||||
p2p_parse_free(&msg);
|
||||
return;
|
||||
}
|
||||
|
@ -1225,7 +1225,7 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
|
|||
} else if (dev->go_state == REMOTE_GO) {
|
||||
p2p_dbg(p2p, "Mandatory P2P Group ID attribute missing from GO Negotiation Confirmation");
|
||||
p2p->ssid_len = 0;
|
||||
p2p_go_neg_failed(p2p, dev, P2P_SC_FAIL_INVALID_PARAMS);
|
||||
p2p_go_neg_failed(p2p, P2P_SC_FAIL_INVALID_PARAMS);
|
||||
p2p_parse_free(&msg);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -773,8 +773,7 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
|
|||
struct p2p_device * p2p_get_device(struct p2p_data *p2p, const u8 *addr);
|
||||
struct p2p_device * p2p_get_device_interface(struct p2p_data *p2p,
|
||||
const u8 *addr);
|
||||
void p2p_go_neg_failed(struct p2p_data *p2p, struct p2p_device *peer,
|
||||
int status);
|
||||
void p2p_go_neg_failed(struct p2p_data *p2p, int status);
|
||||
void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer);
|
||||
int p2p_match_dev_type(struct p2p_data *p2p, struct wpabuf *wps);
|
||||
int dev_type_list_match(const u8 *dev_type, const u8 *req_dev_type[],
|
||||
|
|
Loading…
Reference in a new issue