From 5caf4e094a3c07adccee3f5a571a5480ad9a7d05 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 10 Aug 2020 10:41:20 +0300 Subject: [PATCH] DPP2: Support RA/CA functionality in Controller initiated case Extend dpp_control_get_auth() to find the ongoing session for enterprise credential provisioning in cases where the Controller/Configurator initiated the exchange. Only the other direction was supported previously. Signed-off-by: Jouni Malinen --- src/common/dpp_tcp.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/common/dpp_tcp.c b/src/common/dpp_tcp.c index 639ff8c9f..33874400e 100644 --- a/src/common/dpp_tcp.c +++ b/src/common/dpp_tcp.c @@ -1678,6 +1678,29 @@ void dpp_controller_stop(struct dpp_global *dpp) } +static bool dpp_tcp_peer_id_match(struct dpp_authentication *auth, + unsigned int id) +{ + return auth && + ((auth->peer_bi && auth->peer_bi->id == id) || + (auth->tmp_peer_bi && auth->tmp_peer_bi->id == id)); +} + + +static struct dpp_authentication * dpp_tcp_get_auth(struct dpp_global *dpp, + unsigned int id) +{ + struct dpp_connection *conn; + + dl_list_for_each(conn, &dpp->tcp_init, struct dpp_connection, list) { + if (dpp_tcp_peer_id_match(conn->auth, id)) + return conn->auth; + } + + return NULL; +} + + struct dpp_authentication * dpp_controller_get_auth(struct dpp_global *dpp, unsigned int id) { @@ -1685,18 +1708,14 @@ struct dpp_authentication * dpp_controller_get_auth(struct dpp_global *dpp, struct dpp_connection *conn; if (!ctrl) - return NULL; + return dpp_tcp_get_auth(dpp, id); dl_list_for_each(conn, &ctrl->conn, struct dpp_connection, list) { - struct dpp_authentication *auth = conn->auth; - - if (auth && - ((auth->peer_bi && auth->peer_bi->id == id) || - (auth->tmp_peer_bi && auth->tmp_peer_bi->id == id))) - return auth; + if (dpp_tcp_peer_id_match(conn->auth, id)) + return conn->auth; } - return NULL; + return dpp_tcp_get_auth(dpp, id); }