]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP3: Allow external configuration to be specified on AP for PB
authorJouni Malinen <quic_jouni@quicinc.com>
Thu, 7 Jul 2022 21:12:07 +0000 (00:12 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 7 Jul 2022 21:14:06 +0000 (00:14 +0300)
While the most likely production use case for DPP push button is to
provision the AP's current configuration, there might be some use cases
for providing different configuration. Add possibility for doing this by
extending the DPP_PUSH_BUTTON command to accept an optional set of
parameters similarly to the other DPP commands for the Configurator.

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

index e0b582030cdb9def48bc8032d846109b64b6d00b..a976e8fcad8e4d218c0501c9acf485209ec544aa 100644 (file)
@@ -3676,7 +3676,10 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
 #endif /* CONFIG_DPP2 */
 #ifdef CONFIG_DPP3
        } else if (os_strcmp(buf, "DPP_PUSH_BUTTON") == 0) {
-               if (hostapd_dpp_push_button(hapd) < 0)
+               if (hostapd_dpp_push_button(hapd, NULL) < 0)
+                       reply_len = -1;
+       } else if (os_strncmp(buf, "DPP_PUSH_BUTTON ", 16) == 0) {
+               if (hostapd_dpp_push_button(hapd, buf + 15) < 0)
                        reply_len = -1;
 #endif /* CONFIG_DPP3 */
 #endif /* CONFIG_DPP */
index 7ab97817977993b092088b0ffbd617341bd6ebf8..56a7cadcccbdd608d6a591acb020f989d0182593 100644 (file)
@@ -1509,7 +1509,7 @@ static int hostapd_cli_cmd_dpp_stop_chirp(struct wpa_ctrl *ctrl, int argc,
 static int hostapd_cli_cmd_dpp_push_button(struct wpa_ctrl *ctrl, int argc,
                                           char *argv[])
 {
-       return wpa_ctrl_command(ctrl, "DPP_PUSH_BUTTON");
+       return hostapd_cli_cmd(ctrl, "DPP_PUSH_BUTTON", 1, argc, argv);
 }
 #endif /* CONFIG_DPP3 */
 #endif /* CONFIG_DPP */
index 1c4be2430350145ce7e295faeeab5fed04115f19..5a6fab628a91f648223e0cdc85abd119462f37ab 100644 (file)
@@ -2348,6 +2348,18 @@ static void hostapd_dpp_pb_pkex_init(struct hostapd_data *hapd,
        pkex->exch_req_wait_time = 2000;
        pkex->exch_req_tries = 1;
 
+       if (ifaces->dpp_pb_cmd) {
+               /* Use the externally provided configuration */
+               os_free(hapd->dpp_pkex_auth_cmd);
+               hapd->dpp_pkex_auth_cmd = os_strdup(ifaces->dpp_pb_cmd);
+               if (!hapd->dpp_pkex_auth_cmd) {
+                       hostapd_dpp_push_button_stop(hapd);
+                       return;
+               }
+               return;
+       }
+
+       /* Build config based on the current AP configuration */
        wpa_snprintf_hex(ssid_hex, sizeof(ssid_hex),
                         (const u8 *) hapd->conf->ssid.ssid,
                         hapd->conf->ssid.ssid_len);
@@ -3487,7 +3499,7 @@ static void hostapd_dpp_push_button_expire(void *eloop_ctx, void *timeout_ctx)
 }
 
 
-int hostapd_dpp_push_button(struct hostapd_data *hapd)
+int hostapd_dpp_push_button(struct hostapd_data *hapd, const char *cmd)
 {
        struct hapd_interfaces *ifaces = hapd->iface->interfaces;
 
@@ -3496,6 +3508,13 @@ int hostapd_dpp_push_button(struct hostapd_data *hapd)
        os_get_reltime(&ifaces->dpp_pb_time);
        ifaces->dpp_pb_announce_time.sec = 0;
        ifaces->dpp_pb_announce_time.usec = 0;
+       str_clear_free(ifaces->dpp_pb_cmd);
+       ifaces->dpp_pb_cmd = NULL;
+       if (cmd) {
+               ifaces->dpp_pb_cmd = os_strdup(cmd);
+               if (!ifaces->dpp_pb_cmd)
+                       return -1;
+       }
        eloop_register_timeout(100, 0, hostapd_dpp_push_button_expire,
                               hapd, NULL);
 
@@ -3532,6 +3551,9 @@ void hostapd_dpp_push_button_stop(struct hostapd_data *hapd)
        }
 
        ifaces->dpp_pb_result_indicated = false;
+
+       str_clear_free(ifaces->dpp_pb_cmd);
+       ifaces->dpp_pb_cmd = NULL;
 }
 
 #endif /* CONFIG_DPP3 */
index 6b7716428cfdbc7fbdd568b48be69fbd478fc05d..e7276e889e62877d96e887c0407f39b464feff26 100644 (file)
@@ -45,7 +45,7 @@ int hostapd_dpp_controller_start(struct hostapd_data *hapd, const char *cmd);
 int hostapd_dpp_chirp(struct hostapd_data *hapd, const char *cmd);
 void hostapd_dpp_chirp_stop(struct hostapd_data *hapd);
 void hostapd_dpp_remove_bi(void *ctx, struct dpp_bootstrap_info *bi);
-int hostapd_dpp_push_button(struct hostapd_data *hapd);
+int hostapd_dpp_push_button(struct hostapd_data *hapd, const char *cmd);
 void hostapd_dpp_push_button_stop(struct hostapd_data *hapd);
 
 #endif /* DPP_HOSTAPD_H */
index 2e9a898906010d780f10885767ce049a2290f1b3..33d4cb7840af37a8cd2795bab8d1e5d08f1765e0 100644 (file)
@@ -92,6 +92,7 @@ struct hapd_interfaces {
        u8 dpp_pb_resp_hash[SHA256_MAC_LEN];
        struct os_reltime dpp_pb_last_resp;
        bool dpp_pb_result_indicated;
+       char *dpp_pb_cmd;
 #endif /* CONFIG_DPP3 */
 #endif /* CONFIG_DPP */