]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP: Event message for indicating when Relay would need a Controller
authorJouni Malinen <quic_jouni@quicinc.com>
Sat, 23 Jul 2022 19:42:24 +0000 (22:42 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 24 Jul 2022 21:23:31 +0000 (00:23 +0300)
The new DPP-RELAY-NEEDS-CONTROLLER control interface event can be used
to trigger mDNS discovery of a Controller to see if such a connection
can be established automatically at the time an Enrollee is trying to
initiate an operation.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/ap/dpp_hostapd.c
src/ap/hostapd.h
src/common/wpa_ctrl.h

index a92ae0d79abeaa902d204b9b7f0e40586ce63ec5..7c7b297058a46ee19b57b1779bc76b278c68d0ff 100644 (file)
@@ -1001,6 +1001,27 @@ void hostapd_dpp_listen_stop(struct hostapd_data *hapd)
 }
 
 
+#ifdef CONFIG_DPP2
+static void
+hostapd_dpp_relay_needs_controller(struct hostapd_data *hapd, const u8 *src,
+                                  enum dpp_public_action_frame_type type)
+{
+       struct os_reltime now;
+
+       if (!hapd->conf->dpp_relay_port)
+               return;
+
+       os_get_reltime(&now);
+       if (hapd->dpp_relay_last_needs_ctrl.sec &&
+           !os_reltime_expired(&now, &hapd->dpp_relay_last_needs_ctrl, 60))
+               return;
+       hapd->dpp_relay_last_needs_ctrl = now;
+       wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_RELAY_NEEDS_CONTROLLER
+               MACSTR " %u", MAC2STR(src), type);
+}
+#endif /* CONFIG_DPP2 */
+
+
 static void hostapd_dpp_rx_auth_req(struct hostapd_data *hapd, const u8 *src,
                                    const u8 *hdr, const u8 *buf, size_t len,
                                    unsigned int freq)
@@ -1049,6 +1070,8 @@ static void hostapd_dpp_rx_auth_req(struct hostapd_data *hapd, const u8 *src,
                                        src, hdr, buf, len, freq, i_bootstrap,
                                        r_bootstrap, hapd) == 0)
                        return;
+               hostapd_dpp_relay_needs_controller(hapd, src,
+                                                  DPP_PA_AUTHENTICATION_REQ);
        }
 #endif /* CONFIG_DPP2 */
        if (!own_bi) {
@@ -1668,6 +1691,8 @@ hostapd_dpp_rx_presence_announcement(struct hostapd_data *hapd, const u8 *src,
                        return;
                wpa_printf(MSG_DEBUG,
                           "DPP: No matching bootstrapping information found");
+               hostapd_dpp_relay_needs_controller(
+                       hapd, src, DPP_PA_PRESENCE_ANNOUNCEMENT);
                return;
        }
 
@@ -1758,6 +1783,8 @@ hostapd_dpp_rx_reconfig_announcement(struct hostapd_data *hapd, const u8 *src,
                        return;
                wpa_printf(MSG_DEBUG,
                           "DPP: No matching Configurator information found");
+               hostapd_dpp_relay_needs_controller(
+                       hapd, src, DPP_PA_RECONFIG_ANNOUNCEMENT);
                return;
        }
 
@@ -2198,9 +2225,12 @@ try_relay:
 #ifdef CONFIG_DPP2
        if (v2 && dpp_relay_rx_action(hapd->iface->interfaces->dpp,
                                      src, hdr, buf, len, freq, NULL, NULL,
-                                     hapd) != 0)
+                                     hapd) != 0) {
                wpa_printf(MSG_DEBUG,
                           "DPP: No Relay available for the message");
+               hostapd_dpp_relay_needs_controller(hapd, src,
+                                                  DPP_PA_PKEX_EXCHANGE_REQ);
+       }
 #else /* CONFIG_DPP2 */
        wpa_printf(MSG_DEBUG, "DPP: No relay functionality included - skip");
 #endif /* CONFIG_DPP2 */
index c11cebc4ba2fef64a7031191d5ed91c0632db7a5..cbeceb3ef0dfa7afb6980d26b74c550ddf5b2038 100644 (file)
@@ -433,6 +433,7 @@ struct hostapd_data {
        int dpp_chirp_round;
        int dpp_chirp_scan_done;
        int dpp_chirp_listen;
+       struct os_reltime dpp_relay_last_needs_ctrl;
 #endif /* CONFIG_DPP2 */
 #ifdef CONFIG_TESTING_OPTIONS
        char *dpp_config_obj_override;
index 51dd3e836c6226a907db15a7d460f20ad44b5565..3435084245f69a5fa702e836d547a4141bba3491 100644 (file)
@@ -215,6 +215,7 @@ extern "C" {
 #define DPP_EVENT_CONF_NEEDED "DPP-CONF-NEEDED "
 #define DPP_EVENT_PB_STATUS "DPP-PB-STATUS "
 #define DPP_EVENT_PB_RESULT "DPP-PB-RESULT "
+#define DPP_EVENT_RELAY_NEEDS_CONTROLLER "DPP-RELAY-NEEDS-CONTROLLER "
 
 /* MESH events */
 #define MESH_GROUP_STARTED "MESH-GROUP-STARTED "