]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
FT: Add control interface command to show configured RxKHs
authorDariusz Kopka <dariusz@plume.com>
Mon, 15 Jan 2024 13:16:00 +0000 (14:16 +0100)
committerJouni Malinen <j@w1.fi>
Sat, 20 Jan 2024 08:23:43 +0000 (10:23 +0200)
The new GET_RXKHS control interface command can be used to list the
currently configured RxKHs.

Signed-off-by: Dariusz Kopka <dariusz@plume.com>
hostapd/ctrl_iface.c
hostapd/hostapd_cli.c

index aa193bf7131718c2a72b89b318a5ade18fe371f8..01836cdf2a24291fd27e5378e20e02878d51174e 100644 (file)
@@ -1471,6 +1471,58 @@ static int hostapd_ctrl_iface_reload_wpa_psk(struct hostapd_data *hapd)
 
 
 #ifdef CONFIG_IEEE80211R_AP
+
+static int hostapd_ctrl_iface_get_rxkhs(struct hostapd_data *hapd,
+                                       char *buf, size_t buflen)
+{
+       int ret, start_pos;
+       char *pos, *end;
+       struct ft_remote_r0kh *r0kh;
+       struct ft_remote_r1kh *r1kh;
+       struct hostapd_bss_config *conf = hapd->conf;
+
+       pos = buf;
+       end = buf + buflen;
+
+       for (r0kh = conf->r0kh_list; r0kh; r0kh=r0kh->next) {
+               start_pos = pos - buf;
+               ret = os_snprintf(pos, end - pos, "r0kh=" MACSTR " ",
+                                 MAC2STR(r0kh->addr));
+               if (os_snprintf_error(end - pos, ret))
+                       return start_pos;
+               pos += ret;
+               if (r0kh->id_len + 1 >= (size_t) (end - pos))
+                       return start_pos;
+               os_memcpy(pos, r0kh->id, r0kh->id_len);
+               pos += r0kh->id_len;
+               *pos++ = ' ';
+               pos += wpa_snprintf_hex(pos, end - pos, r0kh->key,
+                                       sizeof(r0kh->key));
+               ret = os_snprintf(pos, end - pos, "\n");
+               if (os_snprintf_error(end - pos, ret))
+                       return start_pos;
+               pos += ret;
+       }
+
+       for (r1kh = conf->r1kh_list; r1kh; r1kh=r1kh->next) {
+               start_pos = pos - buf;
+               ret = os_snprintf(pos, end - pos, "r1kh=" MACSTR " " MACSTR " ",
+                       MAC2STR(r1kh->addr), MAC2STR(r1kh->id));
+               if (os_snprintf_error(end - pos, ret))
+                       return start_pos;
+               pos += ret;
+               pos += wpa_snprintf_hex(pos, end - pos, r1kh->key,
+                                       sizeof(r1kh->key));
+               ret = os_snprintf(pos, end - pos, "\n");
+               if (os_snprintf_error(end - pos, ret))
+                       return start_pos;
+               pos += ret;
+       }
+
+       return pos - buf;
+}
+
+
 static int hostapd_ctrl_iface_reload_rxkhs(struct hostapd_data *hapd)
 {
        struct hostapd_bss_config *conf = hapd->conf;
@@ -1487,6 +1539,7 @@ static int hostapd_ctrl_iface_reload_rxkhs(struct hostapd_data *hapd)
 
        return 0;
 }
+
 #endif /* CONFIG_IEEE80211R_AP */
 
 
@@ -3620,6 +3673,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
                if (hostapd_ctrl_iface_reload_wpa_psk(hapd))
                        reply_len = -1;
 #ifdef CONFIG_IEEE80211R_AP
+       } else if (os_strcmp(buf, "GET_RXKHS") == 0) {
+               reply_len = hostapd_ctrl_iface_get_rxkhs(hapd, reply,
+                                                        reply_size);
        } else if (os_strcmp(buf, "RELOAD_RXKHS") == 0) {
                if (hostapd_ctrl_iface_reload_rxkhs(hapd))
                        reply_len = -1;
index 58bd554855e04223e7752222ae9dc9aa9db167b2..34aad4ef51cae6917c36b8851e166815e94b81b6 100644 (file)
@@ -1592,11 +1592,20 @@ static int hostapd_cli_cmd_reload_wpa_psk(struct wpa_ctrl *ctrl, int argc,
 
 
 #ifdef CONFIG_IEEE80211R_AP
+
+static int hostapd_cli_cmd_get_rxkhs(struct wpa_ctrl *ctrl, int argc,
+                                    char *argv[])
+{
+       return wpa_ctrl_command(ctrl, "GET_RXKHS");
+}
+
+
 static int hostapd_cli_cmd_reload_rxkhs(struct wpa_ctrl *ctrl, int argc,
                                        char *argv[])
 {
        return wpa_ctrl_command(ctrl, "RELOAD_RXKHS");
 }
+
 #endif /* CONFIG_IEEE80211R_AP */
 
 
@@ -1816,6 +1825,8 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
 #ifdef CONFIG_IEEE80211R_AP
        { "reload_rxkhs", hostapd_cli_cmd_reload_rxkhs, NULL,
          "= reload R0KHs and R1KHs" },
+       { "get_rxkhs", hostapd_cli_cmd_get_rxkhs, NULL,
+         "= get R0KHs and R1KHs" },
 #endif /* CONFIG_IEEE80211R_AP */
 #ifdef ANDROID
        { "driver", hostapd_cli_cmd_driver, NULL,