diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index aa193bf71..01836cdf2 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -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; diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c index 58bd55485..34aad4ef5 100644 --- a/hostapd/hostapd_cli.c +++ b/hostapd/hostapd_cli.c @@ -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,