[PATCHv2 1/3] DPP: move DPP_EVENT_AUTH_SUCCESS to a helper

Michal Kazior kazikcz at gmail.com
Fri Apr 30 14:20:30 BST 2021


From: Michal Kazior <michal at plume.com>

This event is generated in a couple of places.
It'll be easier to extend the event with
additional metadata if it's generated in a single
place.

Signed-off-by: Michal Kazior <michal at plume.com>
---

Notes:
    v2:
     - added to avoid code duplication
     - [patchset] the v1 patch became a series

 src/ap/dpp_hostapd.c            | 6 ++----
 src/common/dpp.c                | 6 ++++++
 src/common/dpp.h                | 1 +
 src/common/dpp_tcp.c            | 3 +--
 wpa_supplicant/dpp_supplicant.c | 4 ++--
 5 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c
index aaeb94c2f..8d0068cb5 100644
--- a/src/ap/dpp_hostapd.c
+++ b/src/ap/dpp_hostapd.c
@@ -1023,8 +1023,7 @@ static void hostapd_dpp_start_gas_client(struct hostapd_data *hapd)
 static void hostapd_dpp_auth_success(struct hostapd_data *hapd, int initiator)
 {
 	wpa_printf(MSG_DEBUG, "DPP: Authentication succeeded");
-	wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_AUTH_SUCCESS "init=%d",
-		initiator);
+	dpp_notify_auth_success(hapd->dpp_auth, initiator);
 #ifdef CONFIG_TESTING_OPTIONS
 	if (dpp_test == DPP_TEST_STOP_AT_AUTH_CONF) {
 		wpa_printf(MSG_INFO,
@@ -1991,8 +1990,7 @@ hostapd_dpp_gas_req_handler(struct hostapd_data *hapd, const u8 *sa,
 		 * from TX status handler, but since there was no such handler
 		 * call yet, simply send out the event message and proceed with
 		 * exchange. */
-		wpa_msg(hapd->msg_ctx, MSG_INFO,
-			DPP_EVENT_AUTH_SUCCESS "init=1");
+		dpp_notify_auth_success(hapd->dpp_auth, 1);
 		hapd->dpp_auth_ok_on_ack = 0;
 	}
 
diff --git a/src/common/dpp.c b/src/common/dpp.c
index 3c8c7682d..a8feb8090 100644
--- a/src/common/dpp.c
+++ b/src/common/dpp.c
@@ -4422,4 +4422,10 @@ void dpp_notify_chirp_received(void *msg_ctx, int id, const u8 *src,
 		id, MAC2STR(src), freq, hex);
 }
 
+void dpp_notify_auth_success(struct dpp_authentication *auth, int initiator)
+{
+	wpa_msg(auth->msg_ctx, MSG_INFO, DPP_EVENT_AUTH_SUCCESS "init=%d",
+		initiator);
+}
+
 #endif /* CONFIG_DPP2 */
diff --git a/src/common/dpp.h b/src/common/dpp.h
index 65ee905a7..03052939e 100644
--- a/src/common/dpp.h
+++ b/src/common/dpp.h
@@ -689,6 +689,7 @@ int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
 struct wpabuf * dpp_build_presence_announcement(struct dpp_bootstrap_info *bi);
 void dpp_notify_chirp_received(void *msg_ctx, int id, const u8 *src,
 				unsigned int freq, const u8 *hash);
+void dpp_notify_auth_success(struct dpp_authentication *auth, int initiator);
 
 struct dpp_global_config {
 	void *cb_ctx;
diff --git a/src/common/dpp_tcp.c b/src/common/dpp_tcp.c
index 609c243a6..2bfd02f56 100644
--- a/src/common/dpp_tcp.c
+++ b/src/common/dpp_tcp.c
@@ -287,8 +287,7 @@ static void dpp_controller_auth_success(struct dpp_connection *conn,
 		return;
 
 	wpa_printf(MSG_DEBUG, "DPP: Authentication succeeded");
-	wpa_msg(conn->msg_ctx, MSG_INFO,
-		DPP_EVENT_AUTH_SUCCESS "init=%d", initiator);
+	dpp_notify_auth_success(auth, initiator);
 #ifdef CONFIG_TESTING_OPTIONS
 	if (dpp_test == DPP_TEST_STOP_AT_AUTH_CONF) {
 		wpa_printf(MSG_INFO,
diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c
index 2bcf10b4e..01a2b2e3f 100644
--- a/wpa_supplicant/dpp_supplicant.c
+++ b/wpa_supplicant/dpp_supplicant.c
@@ -1763,7 +1763,7 @@ static void wpas_dpp_start_gas_client(struct wpa_supplicant *wpa_s)
 static void wpas_dpp_auth_success(struct wpa_supplicant *wpa_s, int initiator)
 {
 	wpa_printf(MSG_DEBUG, "DPP: Authentication succeeded");
-	wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_AUTH_SUCCESS "init=%d", initiator);
+	dpp_notify_auth_success(wpa_s->dpp_auth, initiator);
 #ifdef CONFIG_TESTING_OPTIONS
 	if (dpp_test == DPP_TEST_STOP_AT_AUTH_CONF) {
 		wpa_printf(MSG_INFO,
@@ -2959,7 +2959,7 @@ wpas_dpp_gas_req_handler(void *ctx, void *resp_ctx, const u8 *sa,
 		 * TX status handler, but since there was no such handler call
 		 * yet, simply send out the event message and proceed with
 		 * exchange. */
-		wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_AUTH_SUCCESS "init=1");
+		dpp_notify_auth_success(auth, 1);
 		wpa_s->dpp_auth_ok_on_ack = 0;
 	}
 
-- 
2.27.0




More information about the Hostap mailing list