]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP: Add process_conf_obj into TCP connection data struct
authorJouni Malinen <jouni@codeaurora.org>
Fri, 14 Aug 2020 14:04:11 +0000 (17:04 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 14 Aug 2020 14:31:51 +0000 (17:31 +0300)
This is needed to avoid issues with hostapd not having set this function
pointer in dpp_global.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/ap/dpp_hostapd.c
src/common/dpp.h
src/common/dpp_tcp.c
wpa_supplicant/dpp_supplicant.c

index cafbc8302188928292877ada61324a8875129a0d..c886103fb111ead1a0288074322b6cbac7965d6d 100644 (file)
@@ -29,6 +29,9 @@ static int hostapd_dpp_auth_init_next(struct hostapd_data *hapd);
 #ifdef CONFIG_DPP2
 static void hostapd_dpp_reconfig_reply_wait_timeout(void *eloop_ctx,
                                                    void *timeout_ctx);
+static void hostapd_dpp_handle_config_obj(struct hostapd_data *hapd,
+                                         struct dpp_authentication *auth,
+                                         struct dpp_config_obj *conf);
 #endif /* CONFIG_DPP2 */
 
 static const u8 broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
@@ -486,6 +489,22 @@ static int hostapd_dpp_auth_init_next(struct hostapd_data *hapd)
 }
 
 
+#ifdef CONFIG_DPP2
+static int hostapd_dpp_process_conf_obj(void *ctx,
+                                    struct dpp_authentication *auth)
+{
+       struct hostapd_data *hapd = ctx;
+       unsigned int i;
+
+       for (i = 0; i < auth->num_conf_obj; i++)
+               hostapd_dpp_handle_config_obj(hapd, auth,
+                                             &auth->conf_obj[i]);
+
+       return 0;
+}
+#endif /* CONFIG_DPP2 */
+
+
 int hostapd_dpp_auth_init(struct hostapd_data *hapd, const char *cmd)
 {
        const char *pos;
@@ -602,7 +621,8 @@ int hostapd_dpp_auth_init(struct hostapd_data *hapd, const char *cmd)
        if (tcp)
                return dpp_tcp_init(hapd->iface->interfaces->dpp, auth,
                                    &ipaddr, tcp_port, hapd->conf->dpp_name,
-                                   DPP_NETROLE_AP, hapd->msg_ctx);
+                                   DPP_NETROLE_AP, hapd->msg_ctx, hapd,
+                                   hostapd_dpp_process_conf_obj);
 #endif /* CONFIG_DPP2 */
 
        hapd->dpp_auth = auth;
index 5a81a9bf9df2c20ef03ceb7a87bdc416a41d0262..b3d505cc7ab88f7d38447abccc6d237dc378a4ec 100644 (file)
@@ -673,7 +673,11 @@ void dpp_controller_new_qr_code(struct dpp_global *dpp,
                                struct dpp_bootstrap_info *bi);
 int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
                 const struct hostapd_ip_addr *addr, int port,
-                const char *name, enum dpp_netrole netrole, void *msg_ctx);
+                const char *name, enum dpp_netrole netrole, void *msg_ctx,
+                void *cb_ctx,
+                int (*process_conf_obj)(void *ctx,
+                                        struct dpp_authentication *auth));
+
 struct wpabuf * dpp_build_presence_announcement(struct dpp_bootstrap_info *bi);
 
 struct dpp_global_config {
index 07be26d6b31e355b007fc2d5d2149f305fa23696..e243a6d44220257ce4f68ca330e27fdf5a88aa39 100644 (file)
@@ -26,6 +26,8 @@ struct dpp_connection {
        struct dpp_global *global;
        struct dpp_authentication *auth;
        void *msg_ctx;
+       void *cb_ctx;
+       int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth);
        int sock;
        u8 mac_addr[ETH_ALEN];
        unsigned int freq;
@@ -370,6 +372,8 @@ dpp_relay_new_conn(struct dpp_relay_controller *ctrl, const u8 *src,
        conn->global = ctrl->global;
        conn->relay = ctrl;
        conn->msg_ctx = ctrl->global->msg_ctx;
+       conn->cb_ctx = ctrl->global->cb_ctx;
+       conn->process_conf_obj = ctrl->global->process_conf_obj;
        os_memcpy(conn->mac_addr, src, ETH_ALEN);
        conn->freq = freq;
 
@@ -1213,9 +1217,8 @@ static int dpp_tcp_rx_gas_resp(struct dpp_connection *conn, struct wpabuf *resp)
                return -1;
        }
 
-       if (conn->global->process_conf_obj)
-               res = conn->global->process_conf_obj(conn->global->cb_ctx,
-                                                    auth);
+       if (conn->process_conf_obj)
+               res = conn->process_conf_obj(conn->cb_ctx, auth);
        else
                res = 0;
 
@@ -1498,6 +1501,8 @@ static void dpp_controller_tcp_cb(int sd, void *eloop_ctx, void *sock_ctx)
        conn->global = ctrl->global;
        conn->ctrl = ctrl;
        conn->msg_ctx = ctrl->global->msg_ctx;
+       conn->cb_ctx = ctrl->global->cb_ctx;
+       conn->process_conf_obj = ctrl->global->process_conf_obj;
        conn->sock = fd;
 
        if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) != 0) {
@@ -1524,7 +1529,9 @@ fail:
 
 int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
                 const struct hostapd_ip_addr *addr, int port, const char *name,
-                enum dpp_netrole netrole, void *msg_ctx)
+                enum dpp_netrole netrole, void *msg_ctx, void *cb_ctx,
+                int (*process_conf_obj)(void *ctx,
+                                        struct dpp_authentication *auth))
 {
        struct dpp_connection *conn;
        struct sockaddr_storage saddr;
@@ -1547,6 +1554,8 @@ int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
        }
 
        conn->msg_ctx = msg_ctx;
+       conn->cb_ctx = cb_ctx;
+       conn->process_conf_obj = process_conf_obj;
        conn->name = os_strdup(name ? name : "Test");
        conn->netrole = netrole;
        conn->global = dpp;
index 1e4a6072a36a9d0e5b7268b32266febc56356efc..fdb9cbd2b5ed147c1add40b1d7ce7d91030b6e9d 100644 (file)
@@ -50,6 +50,8 @@ wpas_dpp_tx_pkex_status(struct wpa_supplicant *wpa_s,
 static void wpas_dpp_reconfig_reply_wait_timeout(void *eloop_ctx,
                                                 void *timeout_ctx);
 static void wpas_dpp_start_gas_client(struct wpa_supplicant *wpa_s);
+static int wpas_dpp_process_conf_obj(void *ctx,
+                                    struct dpp_authentication *auth);
 #endif /* CONFIG_DPP2 */
 
 static const u8 broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
@@ -837,7 +839,7 @@ int wpas_dpp_auth_init(struct wpa_supplicant *wpa_s, const char *cmd)
        if (tcp)
                return dpp_tcp_init(wpa_s->dpp, auth, &ipaddr, tcp_port,
                                    wpa_s->conf->dpp_name, DPP_NETROLE_STA,
-                                   wpa_s);
+                                   wpa_s, wpa_s, wpas_dpp_process_conf_obj);
 #endif /* CONFIG_DPP2 */
 
        wpa_s->dpp_auth = auth;