]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - hostapd/ctrl_iface.c
Use IFNAME= prefix for global UDP control interface events
[thirdparty/hostap.git] / hostapd / ctrl_iface.c
index 5eef75bf7ac0e0782f7903d9b3b351f4a12f0213..18cbc76e5f1b31000fdc7af8a45cc711b52fcf4c 100644 (file)
@@ -2388,6 +2388,34 @@ static int hostapd_ctrl_resend_group_m1(struct hostapd_data *hapd,
                                        plain ? restore_tk : NULL, hapd, sta);
 }
 
+
+static int hostapd_ctrl_get_pmk(struct hostapd_data *hapd, const char *cmd,
+                               char *buf, size_t buflen)
+{
+       struct sta_info *sta;
+       u8 addr[ETH_ALEN];
+       const u8 *pmk;
+       int pmk_len;
+
+       if (hwaddr_aton(cmd, addr))
+               return -1;
+
+       sta = ap_get_sta(hapd, addr);
+       if (!sta || !sta->wpa_sm) {
+               wpa_printf(MSG_DEBUG, "No STA WPA state machine for " MACSTR,
+                          MAC2STR(addr));
+               return -1;
+       }
+       pmk = wpa_auth_get_pmk(sta->wpa_sm, &pmk_len);
+       if (!pmk) {
+               wpa_printf(MSG_DEBUG, "No PMK stored for " MACSTR,
+                          MAC2STR(addr));
+               return -1;
+       }
+
+       return wpa_snprintf_hex(buf, buflen, pmk, pmk_len);
+}
+
 #endif /* CONFIG_TESTING_OPTIONS */
 
 
@@ -3256,6 +3284,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
        } else if (os_strcmp(buf, "REKEY_GTK") == 0) {
                if (wpa_auth_rekey_gtk(hapd->wpa_auth) < 0)
                        reply_len = -1;
+       } else if (os_strncmp(buf, "GET_PMK ", 8) == 0) {
+               reply_len = hostapd_ctrl_get_pmk(hapd, buf + 8, reply,
+                                                reply_size);
 #endif /* CONFIG_TESTING_OPTIONS */
        } else if (os_strncmp(buf, "CHAN_SWITCH ", 12) == 0) {
                if (hostapd_ctrl_iface_chan_switch(hapd->iface, buf + 12))
@@ -3372,6 +3403,24 @@ 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_NFC_HANDOVER_REQ ", 21) == 0) {
+               res = hostapd_dpp_nfc_handover_req(hapd, buf + 20);
+               if (res < 0) {
+                       reply_len = -1;
+               } else {
+                       reply_len = os_snprintf(reply, reply_size, "%d", res);
+                       if (os_snprintf_error(reply_size, reply_len))
+                               reply_len = -1;
+               }
+       } else if (os_strncmp(buf, "DPP_NFC_HANDOVER_SEL ", 21) == 0) {
+               res = hostapd_dpp_nfc_handover_sel(hapd, buf + 20);
+               if (res < 0) {
+                       reply_len = -1;
+               } else {
+                       reply_len = os_snprintf(reply, reply_size, "%d", res);
+                       if (os_snprintf_error(reply_size, reply_len))
+                               reply_len = -1;
+               }
        } else if (os_strncmp(buf, "DPP_BOOTSTRAP_GEN ", 18) == 0) {
                res = dpp_bootstrap_gen(hapd->iface->interfaces->dpp, buf + 18);
                if (res < 0) {
@@ -4640,13 +4689,8 @@ static void hostapd_ctrl_iface_send_internal(int sock, struct dl_list *ctrl_dst,
                return;
        idx = 0;
        if (ifname) {
-#ifdef CONFIG_CTRL_IFACE_UDP
-               io[idx].iov_base = "IFACE=";
-               io[idx].iov_len = 6;
-#else /* CONFIG_CTRL_IFACE_UDP */
                io[idx].iov_base = "IFNAME=";
                io[idx].iov_len = 7;
-#endif /* CONFIG_CTRL_IFACE_UDP */
                idx++;
                io[idx].iov_base = (char *) ifname;
                io[idx].iov_len = os_strlen(ifname);