From a86fb43ca3a93da89e82e0aa307520baf2060004 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 4 Jul 2017 15:45:37 +0300 Subject: [PATCH] DPP: DPP_BOOTSTRAP_INFO for hostapd This extends the hostapd control interface to support the DPP_BOOTSTRAP_INFO command that was recently added for wpa_supplicant. Signed-off-by: Jouni Malinen --- hostapd/ctrl_iface.c | 3 +++ src/ap/dpp_hostapd.c | 21 +++++++++++++++++++++ src/ap/dpp_hostapd.h | 2 ++ 3 files changed, 26 insertions(+) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 5503f4476..c2eadb5b0 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -2690,6 +2690,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, if (os_snprintf_error(reply_size, reply_len)) reply_len = -1; } + } else if (os_strncmp(buf, "DPP_BOOTSTRAP_INFO ", 19) == 0) { + reply_len = hostapd_dpp_bootstrap_info(hapd, atoi(buf + 19), + reply, reply_size); } else if (os_strncmp(buf, "DPP_AUTH_INIT ", 14) == 0) { if (hostapd_dpp_auth_init(hapd, buf + 13) < 0) reply_len = -1; diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c index b5980d4c3..c8b4f87b8 100644 --- a/src/ap/dpp_hostapd.c +++ b/src/ap/dpp_hostapd.c @@ -262,6 +262,27 @@ const char * hostapd_dpp_bootstrap_get_uri(struct hostapd_data *hapd, } +int hostapd_dpp_bootstrap_info(struct hostapd_data *hapd, int id, + char *reply, int reply_size) +{ + struct dpp_bootstrap_info *bi; + + bi = dpp_bootstrap_get_id(hapd, id); + if (!bi) + return -1; + return os_snprintf(reply, reply_size, "type=%s\n" + "mac_addr=" MACSTR "\n" + "info=%s\n" + "num_freq=%u\n" + "curve=%s\n", + dpp_bootstrap_type_txt(bi->type), + MAC2STR(bi->mac_addr), + bi->info ? bi->info : "", + bi->num_freq, + bi->curve->name); +} + + void hostapd_dpp_tx_status(struct hostapd_data *hapd, const u8 *dst, const u8 *data, size_t data_len, int ok) { diff --git a/src/ap/dpp_hostapd.h b/src/ap/dpp_hostapd.h index 9aa08305d..d870b2051 100644 --- a/src/ap/dpp_hostapd.h +++ b/src/ap/dpp_hostapd.h @@ -14,6 +14,8 @@ int hostapd_dpp_bootstrap_gen(struct hostapd_data *hapd, const char *cmd); int hostapd_dpp_bootstrap_remove(struct hostapd_data *hapd, const char *id); const char * hostapd_dpp_bootstrap_get_uri(struct hostapd_data *hapd, unsigned int id); +int hostapd_dpp_bootstrap_info(struct hostapd_data *hapd, int id, + char *reply, int reply_size); int hostapd_dpp_auth_init(struct hostapd_data *hapd, const char *cmd); void hostapd_dpp_rx_action(struct hostapd_data *hapd, const u8 *src, const u8 *buf, size_t len, unsigned int freq);