From 2ed2b52ff580513ea407966073a9581aec90a1c5 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 21 Apr 2019 21:18:24 +0300 Subject: [PATCH] DPP: Add configuration structure to dpp_global_init() This can be used to provide configurable parameter to the global DPP context. This initial commit introduces the msg_ctx context pointer for wpa_msg(). Signed-off-by: Jouni Malinen --- hostapd/main.c | 7 ++++++- src/common/dpp.c | 4 +++- src/common/dpp.h | 7 ++++++- wpa_supplicant/dpp_supplicant.c | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/hostapd/main.c b/hostapd/main.c index 93d2dd34c..08896ffe2 100644 --- a/hostapd/main.c +++ b/hostapd/main.c @@ -653,6 +653,9 @@ int main(int argc, char *argv[]) int start_ifaces_in_sync = 0; char **if_names = NULL; size_t if_names_size = 0; +#ifdef CONFIG_DPP + struct dpp_global_config dpp_conf; +#endif /* CONFIG_DPP */ if (os_program_init()) return -1; @@ -672,7 +675,9 @@ int main(int argc, char *argv[]) dl_list_init(&interfaces.eth_p_oui); #endif /* CONFIG_ETH_P_OUI */ #ifdef CONFIG_DPP - interfaces.dpp = dpp_global_init(); + os_memset(&dpp_conf, 0, sizeof(dpp_conf)); + /* TODO: dpp_conf.msg_ctx? */ + interfaces.dpp = dpp_global_init(&dpp_conf); if (!interfaces.dpp) return -1; #endif /* CONFIG_DPP */ diff --git a/src/common/dpp.c b/src/common/dpp.c index 49de47697..6f0d91dcd 100644 --- a/src/common/dpp.c +++ b/src/common/dpp.c @@ -71,6 +71,7 @@ static void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, struct dpp_global { + void *msg_ctx; struct dl_list bootstrap; /* struct dpp_bootstrap_info */ struct dl_list configurator; /* struct dpp_configurator */ }; @@ -8689,13 +8690,14 @@ int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id, } -struct dpp_global * dpp_global_init(void) +struct dpp_global * dpp_global_init(struct dpp_global_config *config) { struct dpp_global *dpp; dpp = os_zalloc(sizeof(*dpp)); if (!dpp) return NULL; + dpp->msg_ctx = config->msg_ctx; dl_list_init(&dpp->bootstrap); dl_list_init(&dpp->configurator); diff --git a/src/common/dpp.h b/src/common/dpp.h index 5a6d8cc79..42c70b115 100644 --- a/src/common/dpp.h +++ b/src/common/dpp.h @@ -497,7 +497,12 @@ int dpp_configurator_add(struct dpp_global *dpp, const char *cmd); int dpp_configurator_remove(struct dpp_global *dpp, const char *id); int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id, char *buf, size_t buflen); -struct dpp_global * dpp_global_init(void); + +struct dpp_global_config { + void *msg_ctx; +}; + +struct dpp_global * dpp_global_init(struct dpp_global_config *config); void dpp_global_clear(struct dpp_global *dpp); void dpp_global_deinit(struct dpp_global *dpp); diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c index e003a8514..4cfbbcba7 100644 --- a/wpa_supplicant/dpp_supplicant.c +++ b/wpa_supplicant/dpp_supplicant.c @@ -2196,6 +2196,7 @@ void wpas_dpp_stop(struct wpa_supplicant *wpa_s) int wpas_dpp_init(struct wpa_supplicant *wpa_s) { + struct dpp_global_config config; u8 adv_proto_id[7]; adv_proto_id[0] = WLAN_EID_VENDOR_SPECIFIC; @@ -2208,7 +2209,10 @@ int wpas_dpp_init(struct wpa_supplicant *wpa_s) sizeof(adv_proto_id), wpas_dpp_gas_req_handler, wpas_dpp_gas_status_handler, wpa_s) < 0) return -1; - wpa_s->dpp = dpp_global_init(); + + os_memset(&config, 0, sizeof(config)); + config.msg_ctx = wpa_s; + wpa_s->dpp = dpp_global_init(&config); return wpa_s->dpp ? 0 : -1; }