]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP2: Get DPP Relay Controller context based on hostapd callback context
authorDisha Das <dishad@codeaurora.org>
Thu, 15 Apr 2021 13:21:06 +0000 (18:51 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 21 Apr 2021 20:06:00 +0000 (23:06 +0300)
Get the DPP Relay Controller context from the list of configured
Controllers based on the correct hostapd callback context. This is
needed to pick the correct hostapd interface for sending out the
response over air, e.g., when the same hostapd process controls a 2.4
GHz only and a 5 GHz only interface.

Signed-off-by: Disha Das <dishad@codeaurora.org>
src/ap/dpp_hostapd.c
src/common/dpp.h
src/common/dpp_tcp.c

index aaeb94c2f53b8fb60a61e3caeeca7179bd9d401b..93ffd8cf7c3623eef44b336cae2b0c246ce38250 100644 (file)
@@ -757,7 +757,7 @@ static void hostapd_dpp_rx_auth_req(struct hostapd_data *hapd, const u8 *src,
        if (!own_bi) {
                if (dpp_relay_rx_action(hapd->iface->interfaces->dpp,
                                        src, hdr, buf, len, freq, i_bootstrap,
-                                       r_bootstrap) == 0)
+                                       r_bootstrap, hapd) == 0)
                        return;
        }
 #endif /* CONFIG_DPP2 */
@@ -1276,7 +1276,7 @@ hostapd_dpp_rx_presence_announcement(struct hostapd_data *hapd, const u8 *src,
        if (!peer_bi) {
                if (dpp_relay_rx_action(hapd->iface->interfaces->dpp,
                                        src, hdr, buf, len, freq, NULL,
-                                       r_bootstrap) == 0)
+                                       r_bootstrap, hapd) == 0)
                        return;
                wpa_printf(MSG_DEBUG,
                           "DPP: No matching bootstrapping information found");
@@ -1366,7 +1366,7 @@ hostapd_dpp_rx_reconfig_announcement(struct hostapd_data *hapd, const u8 *src,
        if (!conf) {
                if (dpp_relay_rx_action(hapd->iface->interfaces->dpp,
                                        src, hdr, buf, len, freq, NULL,
-                                       NULL) == 0)
+                                       NULL, hapd) == 0)
                        return;
                wpa_printf(MSG_DEBUG,
                           "DPP: No matching Configurator information found");
@@ -1892,7 +1892,8 @@ void hostapd_dpp_rx_action(struct hostapd_data *hapd, const u8 *src,
 
 #ifdef CONFIG_DPP2
        if (dpp_relay_rx_action(hapd->iface->interfaces->dpp,
-                               src, hdr, buf, len, freq, NULL, NULL) == 0)
+                               src, hdr, buf, len, freq, NULL, NULL,
+                               hapd) == 0)
                return;
 #endif /* CONFIG_DPP2 */
 
index 65ee905a78f9411040f739bd8e855e84931c0085..75de3cae93e9239b32b7ec5521eff37478385912 100644 (file)
@@ -669,7 +669,8 @@ int dpp_relay_add_controller(struct dpp_global *dpp,
                             struct dpp_relay_config *config);
 int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr,
                        const u8 *buf, size_t len, unsigned int freq,
-                       const u8 *i_bootstrap, const u8 *r_bootstrap);
+                       const u8 *i_bootstrap, const u8 *r_bootstrap,
+                       void *cb_ctx);
 int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data,
                         size_t data_len);
 int dpp_controller_start(struct dpp_global *dpp,
index ddc720fecbed82045f050bc0afca4f79a41782c7..c373f107791cb6965d83fd58f9d908a5183568e2 100644 (file)
@@ -156,6 +156,24 @@ dpp_relay_controller_get(struct dpp_global *dpp, const u8 *pkhash)
 }
 
 
+static struct dpp_relay_controller *
+dpp_relay_controller_get_ctx(struct dpp_global *dpp, void *cb_ctx)
+{
+       struct dpp_relay_controller *ctrl;
+
+       if (!dpp)
+               return NULL;
+
+       dl_list_for_each(ctrl, &dpp->controllers, struct dpp_relay_controller,
+                        list) {
+               if (cb_ctx == ctrl->cb_ctx)
+                       return ctrl;
+       }
+
+       return NULL;
+}
+
+
 static void dpp_controller_gas_done(struct dpp_connection *conn)
 {
        struct dpp_authentication *auth = conn->auth;
@@ -477,7 +495,8 @@ static int dpp_relay_tx(struct dpp_connection *conn, const u8 *hdr,
 
 int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr,
                        const u8 *buf, size_t len, unsigned int freq,
-                       const u8 *i_bootstrap, const u8 *r_bootstrap)
+                       const u8 *i_bootstrap, const u8 *r_bootstrap,
+                       void *cb_ctx)
 {
        struct dpp_relay_controller *ctrl;
        struct dpp_connection *conn;
@@ -505,8 +524,7 @@ int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr,
            type == DPP_PA_RECONFIG_ANNOUNCEMENT) {
                /* TODO: Could send this to all configured Controllers. For now,
                 * only the first Controller is supported. */
-               ctrl = dl_list_first(&dpp->controllers,
-                                    struct dpp_relay_controller, list);
+               ctrl = dpp_relay_controller_get_ctx(dpp, cb_ctx);
        } else {
                if (!r_bootstrap)
                        return -1;