From 0859ed8448db94c0ea72baee1b99dcb27b93ce59 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 26 Oct 2023 13:26:46 -0700 Subject: [PATCH] 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. --- src/dpp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dpp.c b/src/dpp.c index 52a0ecc1..15b0a730 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -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)