]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP2: Support RA/CA functionality in Controller initiated case
authorJouni Malinen <jouni@codeaurora.org>
Mon, 10 Aug 2020 07:41:20 +0000 (10:41 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 10 Aug 2020 07:41:20 +0000 (10:41 +0300)
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 <jouni@codeaurora.org>
src/common/dpp_tcp.c

index 639ff8c9fe72bd502512f1f222cd26bea16d8f1f..33874400ecb1f6b9c1891381f1661152b66b85ce 100644 (file)
@@ -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);
 }