]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP: Report transmitted messages as control interface events
authorJouni Malinen <jouni@qca.qualcomm.com>
Sun, 22 Oct 2017 09:35:06 +0000 (12:35 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 22 Oct 2017 14:21:57 +0000 (17:21 +0300)
This is helpful for testing purposes and also for upper layer components
that may want to show more detailed progress through a DPP exchange.
Both the DPP-TX and DPP-TX-STATUS events are provided.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/dpp_hostapd.c
src/common/wpa_ctrl.h
wpa_supplicant/dpp_supplicant.c

index f0b8634b31c2fadff1735376e682dc07756ea83f..ca039c8694b6d182c1cb0daa2d52dd2c53c2a414 100644 (file)
@@ -75,6 +75,10 @@ int hostapd_dpp_qr_code(struct hostapd_data *hapd, const char *cmd)
            dpp_notify_new_qr_code(auth, bi) == 1) {
                wpa_printf(MSG_DEBUG,
                           "DPP: Sending out pending authentication response");
+               wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+                       " freq=%u type=%d",
+                       MAC2STR(auth->peer_mac_addr), auth->curr_freq,
+                       DPP_PA_AUTHENTICATION_RESP);
                hostapd_drv_send_action(hapd, auth->curr_freq, 0,
                                        auth->peer_mac_addr,
                                        wpabuf_head(hapd->dpp_auth->resp_msg),
@@ -279,6 +283,8 @@ void hostapd_dpp_tx_status(struct hostapd_data *hapd, const u8 *dst,
 {
        wpa_printf(MSG_DEBUG, "DPP: TX status: dst=" MACSTR " ok=%d",
                   MAC2STR(dst), ok);
+       wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX_STATUS "dst=" MACSTR
+               " result=%s", MAC2STR(dst), ok ? "SUCCESS" : "FAILED");
 
        if (!hapd->dpp_auth) {
                wpa_printf(MSG_DEBUG,
@@ -520,6 +526,10 @@ int hostapd_dpp_auth_init(struct hostapd_data *hapd, const char *cmd)
        }
        hapd->dpp_auth_ok_on_ack = 0;
 
+       wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+               " freq=%u type=%d",
+               MAC2STR(dst), hapd->dpp_auth->curr_freq,
+               DPP_PA_AUTHENTICATION_REQ);
        res = hostapd_drv_send_action(hapd, hapd->dpp_auth->curr_freq, 0,
                                      dst, wpabuf_head(hapd->dpp_auth->req_msg),
                                      wpabuf_len(hapd->dpp_auth->req_msg));
@@ -612,6 +622,10 @@ static void hostapd_dpp_rx_auth_req(struct hostapd_data *hapd, const u8 *src,
                                     hapd->dpp_configurator_params);
        os_memcpy(hapd->dpp_auth->peer_mac_addr, src, ETH_ALEN);
 
+       wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+               " freq=%u type=%d",
+               MAC2STR(src), hapd->dpp_auth->curr_freq,
+               DPP_PA_AUTHENTICATION_RESP);
        hostapd_drv_send_action(hapd, hapd->dpp_auth->curr_freq, 0,
                                src, wpabuf_head(hapd->dpp_auth->resp_msg),
                                wpabuf_len(hapd->dpp_auth->resp_msg));
@@ -837,6 +851,9 @@ static void hostapd_dpp_rx_auth_resp(struct hostapd_data *hapd, const u8 *src,
        }
        os_memcpy(auth->peer_mac_addr, src, ETH_ALEN);
 
+       wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+               " freq=%u type=%d", MAC2STR(src), auth->curr_freq,
+               DPP_PA_AUTHENTICATION_CONF);
        hostapd_drv_send_action(hapd, auth->curr_freq, 0, src,
                                wpabuf_head(msg), wpabuf_len(msg));
        wpabuf_free(msg);
@@ -966,6 +983,9 @@ static void hostapd_dpp_rx_peer_disc_req(struct hostapd_data *hapd,
 
        wpa_printf(MSG_DEBUG, "DPP: Send Peer Discovery Response to " MACSTR,
                   MAC2STR(src));
+       wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+               " freq=%u type=%d", MAC2STR(src), freq,
+               DPP_PA_PEER_DISCOVERY_RESP);
        hostapd_drv_send_action(hapd, freq, 0, src,
                                wpabuf_head(msg), wpabuf_len(msg));
        wpabuf_free(msg);
@@ -1010,6 +1030,9 @@ hostapd_dpp_rx_pkex_exchange_req(struct hostapd_data *hapd, const u8 *src,
        }
 
        msg = hapd->dpp_pkex->exchange_resp;
+       wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+               " freq=%u type=%d", MAC2STR(src), freq,
+               DPP_PA_PKEX_EXCHANGE_RESP);
        hostapd_drv_send_action(hapd, freq, 0, src,
                                wpabuf_head(msg), wpabuf_len(msg));
 }
@@ -1043,6 +1066,9 @@ hostapd_dpp_rx_pkex_exchange_resp(struct hostapd_data *hapd, const u8 *src,
        wpa_printf(MSG_DEBUG, "DPP: Send PKEX Commit-Reveal Request to " MACSTR,
                   MAC2STR(src));
 
+       wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+               " freq=%u type=%d", MAC2STR(src), freq,
+               DPP_PA_PKEX_COMMIT_REVEAL_REQ);
        hostapd_drv_send_action(hapd, freq, 0, src,
                                wpabuf_head(msg), wpabuf_len(msg));
        wpabuf_free(msg);
@@ -1075,6 +1101,9 @@ hostapd_dpp_rx_pkex_commit_reveal_req(struct hostapd_data *hapd, const u8 *src,
        wpa_printf(MSG_DEBUG, "DPP: Send PKEX Commit-Reveal Response to "
                   MACSTR, MAC2STR(src));
 
+       wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+               " freq=%u type=%d", MAC2STR(src), freq,
+               DPP_PA_PKEX_COMMIT_REVEAL_RESP);
        hostapd_drv_send_action(hapd, freq, 0, src,
                                wpabuf_head(msg), wpabuf_len(msg));
        wpabuf_free(msg);
@@ -1402,6 +1431,9 @@ int hostapd_dpp_pkex_add(struct hostapd_data *hapd, const char *cmd)
 
                msg = hapd->dpp_pkex->exchange_req;
                /* TODO: Which channel to use? */
+               wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+                       " freq=%u type=%d", MAC2STR(broadcast), 2437,
+                       DPP_PA_PKEX_EXCHANGE_REQ);
                hostapd_drv_send_action(hapd, 2437, 0, broadcast,
                                        wpabuf_head(msg), wpabuf_len(msg));
        }
index 35980e259277cb5888daf7037d11eaccb9067fad..05d2f448938236c61db709e9371c94bdd8471d32 100644 (file)
@@ -168,6 +168,8 @@ extern "C" {
 #define DPP_EVENT_MISSING_CONNECTOR "DPP-MISSING-CONNECTOR "
 #define DPP_EVENT_NETWORK_ID "DPP-NETWORK-ID "
 #define DPP_EVENT_RX "DPP-RX "
+#define DPP_EVENT_TX "DPP-TX "
+#define DPP_EVENT_TX_STATUS "DPP-TX-STATUS "
 
 /* MESH events */
 #define MESH_GROUP_STARTED "MESH-GROUP-STARTED "
index 982783ae6f5a1c2175f7a014174ce45844287a83..49d6e493df6760f200b2c5aa8d44b08475732cfa 100644 (file)
@@ -93,6 +93,10 @@ int wpas_dpp_qr_code(struct wpa_supplicant *wpa_s, const char *cmd)
            dpp_notify_new_qr_code(auth, bi) == 1) {
                wpa_printf(MSG_DEBUG,
                           "DPP: Sending out pending authentication response");
+               wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+                       " freq=%u type=%d",
+                       MAC2STR(auth->peer_mac_addr), auth->curr_freq,
+                       DPP_PA_AUTHENTICATION_RESP);
                offchannel_send_action(wpa_s, auth->curr_freq,
                                       auth->peer_mac_addr, wpa_s->own_addr,
                                       broadcast,
@@ -300,12 +304,15 @@ static void wpas_dpp_tx_status(struct wpa_supplicant *wpa_s,
                               const u8 *data, size_t data_len,
                               enum offchannel_send_action_result result)
 {
+       const char *res_txt;
+
+       res_txt = result == OFFCHANNEL_SEND_ACTION_SUCCESS ? "SUCCESS" :
+               (result == OFFCHANNEL_SEND_ACTION_NO_ACK ? "no-ACK" :
+                "FAILED");
        wpa_printf(MSG_DEBUG, "DPP: TX status: freq=%u dst=" MACSTR
-                  " result=%s",
-                  freq, MAC2STR(dst),
-                  result == OFFCHANNEL_SEND_ACTION_SUCCESS ? "SUCCESS" :
-                  (result == OFFCHANNEL_SEND_ACTION_NO_ACK ? "no-ACK" :
-                   "FAILED"));
+                  " result=%s", freq, MAC2STR(dst), res_txt);
+       wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX_STATUS "dst=" MACSTR
+               " freq=%u result=%s", MAC2STR(dst), freq, res_txt);
 
        if (!wpa_s->dpp_auth) {
                wpa_printf(MSG_DEBUG,
@@ -586,6 +593,9 @@ int wpas_dpp_auth_init(struct wpa_supplicant *wpa_s, const char *cmd)
        eloop_register_timeout(wait_time / 1000, (wait_time % 1000) * 1000,
                               wpas_dpp_reply_wait_timeout,
                               wpa_s, NULL);
+       wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR " freq=%u type=%d",
+               MAC2STR(dst), wpa_s->dpp_auth->curr_freq,
+               DPP_PA_AUTHENTICATION_REQ);
        res = offchannel_send_action(wpa_s, wpa_s->dpp_auth->curr_freq,
                                     dst, wpa_s->own_addr, broadcast,
                                     wpabuf_head(wpa_s->dpp_auth->req_msg),
@@ -854,6 +864,9 @@ static void wpas_dpp_rx_auth_req(struct wpa_supplicant *wpa_s, const u8 *src,
                                  wpa_s->dpp_configurator_params);
        os_memcpy(wpa_s->dpp_auth->peer_mac_addr, src, ETH_ALEN);
 
+       wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR " freq=%u type=%d",
+               MAC2STR(src), wpa_s->dpp_auth->curr_freq,
+               DPP_PA_AUTHENTICATION_RESP);
        offchannel_send_action(wpa_s, wpa_s->dpp_auth->curr_freq,
                               src, wpa_s->own_addr, broadcast,
                               wpabuf_head(wpa_s->dpp_auth->resp_msg),
@@ -1185,6 +1198,8 @@ static void wpas_dpp_rx_auth_resp(struct wpa_supplicant *wpa_s, const u8 *src,
        }
        os_memcpy(auth->peer_mac_addr, src, ETH_ALEN);
 
+       wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR " freq=%u type=%d",
+               MAC2STR(src), auth->curr_freq, DPP_PA_AUTHENTICATION_CONF);
        offchannel_send_action(wpa_s, auth->curr_freq,
                               src, wpa_s->own_addr, broadcast,
                               wpabuf_head(msg), wpabuf_len(msg),
@@ -1328,12 +1343,16 @@ wpas_dpp_tx_pkex_status(struct wpa_supplicant *wpa_s,
                        const u8 *data, size_t data_len,
                        enum offchannel_send_action_result result)
 {
+       const char *res_txt;
+
+       res_txt = result == OFFCHANNEL_SEND_ACTION_SUCCESS ? "SUCCESS" :
+               (result == OFFCHANNEL_SEND_ACTION_NO_ACK ? "no-ACK" :
+                "FAILED");
        wpa_printf(MSG_DEBUG, "DPP: TX status: freq=%u dst=" MACSTR
                   " result=%s (PKEX)",
-                  freq, MAC2STR(dst),
-                  result == OFFCHANNEL_SEND_ACTION_SUCCESS ? "SUCCESS" :
-                  (result == OFFCHANNEL_SEND_ACTION_NO_ACK ? "no-ACK" :
-                   "FAILED"));
+                  freq, MAC2STR(dst), res_txt);
+       wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX_STATUS "dst=" MACSTR
+               " freq=%u result=%s", MAC2STR(dst), freq, res_txt);
        /* TODO: Time out wait for response more quickly in error cases? */
 }
 
@@ -1379,6 +1398,8 @@ wpas_dpp_rx_pkex_exchange_req(struct wpa_supplicant *wpa_s, const u8 *src,
        wait_time = wpa_s->max_remain_on_chan;
        if (wait_time > 2000)
                wait_time = 2000;
+       wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR " freq=%u type=%d",
+               MAC2STR(src), freq, DPP_PA_PKEX_EXCHANGE_RESP);
        offchannel_send_action(wpa_s, freq, src, wpa_s->own_addr,
                               broadcast,
                               wpabuf_head(msg), wpabuf_len(msg),
@@ -1418,6 +1439,8 @@ wpas_dpp_rx_pkex_exchange_resp(struct wpa_supplicant *wpa_s, const u8 *src,
        wait_time = wpa_s->max_remain_on_chan;
        if (wait_time > 2000)
                wait_time = 2000;
+       wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR " freq=%u type=%d",
+               MAC2STR(src), freq, DPP_PA_PKEX_COMMIT_REVEAL_REQ);
        offchannel_send_action(wpa_s, freq, src, wpa_s->own_addr,
                               broadcast,
                               wpabuf_head(msg), wpabuf_len(msg),
@@ -1456,6 +1479,8 @@ wpas_dpp_rx_pkex_commit_reveal_req(struct wpa_supplicant *wpa_s, const u8 *src,
        wait_time = wpa_s->max_remain_on_chan;
        if (wait_time > 2000)
                wait_time = 2000;
+       wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR " freq=%u type=%d",
+               MAC2STR(src), freq, DPP_PA_PKEX_COMMIT_REVEAL_RESP);
        offchannel_send_action(wpa_s, freq, src, wpa_s->own_addr,
                               broadcast,
                               wpabuf_head(msg), wpabuf_len(msg),
@@ -1787,12 +1812,16 @@ wpas_dpp_tx_introduction_status(struct wpa_supplicant *wpa_s,
                                const u8 *data, size_t data_len,
                                enum offchannel_send_action_result result)
 {
+       const char *res_txt;
+
+       res_txt = result == OFFCHANNEL_SEND_ACTION_SUCCESS ? "SUCCESS" :
+               (result == OFFCHANNEL_SEND_ACTION_NO_ACK ? "no-ACK" :
+                "FAILED");
        wpa_printf(MSG_DEBUG, "DPP: TX status: freq=%u dst=" MACSTR
                   " result=%s (DPP Peer Discovery Request)",
-                  freq, MAC2STR(dst),
-                  result == OFFCHANNEL_SEND_ACTION_SUCCESS ? "SUCCESS" :
-                  (result == OFFCHANNEL_SEND_ACTION_NO_ACK ? "no-ACK" :
-                   "FAILED"));
+                  freq, MAC2STR(dst), res_txt);
+       wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX_STATUS "dst=" MACSTR
+               " freq=%u result=%s", MAC2STR(dst), freq, res_txt);
        /* TODO: Time out wait for response more quickly in error cases? */
 }
 
@@ -1851,6 +1880,8 @@ int wpas_dpp_check_connect(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
        wait_time = wpa_s->max_remain_on_chan;
        if (wait_time > 2000)
                wait_time = 2000;
+       wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR " freq=%u type=%d",
+               MAC2STR(bss->bssid), bss->freq, DPP_PA_PEER_DISCOVERY_REQ);
        offchannel_send_action(wpa_s, bss->freq, bss->bssid, wpa_s->own_addr,
                               broadcast,
                               wpabuf_head(msg), wpabuf_len(msg),
@@ -1927,6 +1958,9 @@ int wpas_dpp_pkex_add(struct wpa_supplicant *wpa_s, const char *cmd)
                if (wait_time > 2000)
                        wait_time = 2000;
                /* TODO: Which channel to use? */
+               wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
+                       " freq=%u type=%d",
+                       MAC2STR(broadcast), 2437, DPP_PA_PKEX_EXCHANGE_REQ);
                offchannel_send_action(wpa_s, 2437, broadcast, wpa_s->own_addr,
                                       broadcast,
                                       wpabuf_head(msg), wpabuf_len(msg),