dpp: make the protocol timeout more flexible

Include a specific timeout value so different protocols can specify
different timeouts. For example once the authentication timeout
should not take very long (even 10 seconds seems excessive) but
adding PKEX may warrant longer timeouts.

For example discovering a configurator IWD may want to wait several
minutes before ending the discovery. Similarly running PKEX as a
configurator we should put a hard limit on the time, but again
minutes rather than 10 seconds.
This commit is contained in:
James Prestwood 2023-10-26 13:26:46 -07:00 committed by Denis Kenzior
parent efdc2a63eb
commit 0859ed8448
1 changed files with 6 additions and 5 deletions

View File

@ -56,6 +56,7 @@
#define DPP_FRAME_MAX_RETRIES 5
#define DPP_FRAME_RETRY_TIMEOUT 1
#define DPP_AUTH_PROTO_TIMEOUT 10
static uint32_t netdev_watch;
static struct l_genl_family *nl80211;
@ -480,12 +481,12 @@ static void dpp_protocol_timeout(struct l_timeout *timeout, void *user_data)
dpp_reset(dpp);
}
static void dpp_reset_protocol_timer(struct dpp_sm *dpp)
static void dpp_reset_protocol_timer(struct dpp_sm *dpp, uint32_t time)
{
if (dpp->timeout)
l_timeout_modify(dpp->timeout, 10);
l_timeout_modify(dpp->timeout, time);
else
dpp->timeout = l_timeout_create(10, dpp_protocol_timeout,
dpp->timeout = l_timeout_create(time, dpp_protocol_timeout,
dpp, NULL);
}
@ -1348,7 +1349,7 @@ static void authenticate_confirm(struct dpp_sm *dpp, const uint8_t *from,
l_debug("Authentication successful");
dpp_reset_protocol_timer(dpp);
dpp_reset_protocol_timer(dpp, DPP_AUTH_PROTO_TIMEOUT);
if (dpp->role == DPP_CAPABILITY_ENROLLEE)
dpp_configuration_start(dpp, from);
@ -1821,7 +1822,7 @@ static void authenticate_request(struct dpp_sm *dpp, const uint8_t *from,
memcpy(dpp->peer_addr, from, 6);
dpp->state = DPP_STATE_AUTHENTICATING;
dpp_reset_protocol_timer(dpp);
dpp_reset_protocol_timer(dpp, DPP_AUTH_PROTO_TIMEOUT);
/* Don't send if the frequency is changing */
if (!dpp->new_freq)