From: Raphaël Mélotte Date: Wed, 2 Dec 2020 16:51:45 +0000 (+0100) Subject: hostapd: Add multi_ap settings to get_config() output X-Git-Tag: hostap_2_10~627 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=871d6648f502df396d6156542d61e53cdb0d1e25;p=thirdparty%2Fhostap.git hostapd: Add multi_ap settings to get_config() output Since a running hostapd is not necessarily using the settings that are in the configuration file (if they were changed at runtime, or the file was changed but not reloaded, etc.), being able to get their value at runtime can be useful (to know if they have to be updated for example). If multi_ap is set, also print the SSID and passphrase (or PSK). Signed-off-by: Raphaël Mélotte --- diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 381809d72..55084a919 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -1223,6 +1223,52 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd, return pos - buf; pos += ret; } + + if (hapd->conf->multi_ap) { + struct hostapd_ssid *ssid = &hapd->conf->multi_ap_backhaul_ssid; + + ret = os_snprintf(pos, end - pos, "multi_ap=%d\n", + hapd->conf->multi_ap); + if (os_snprintf_error(end - pos, ret)) + return pos - buf; + pos += ret; + + if (ssid->ssid) { + ret = os_snprintf(pos, end - pos, + "multi_ap_backhaul_ssid=%s\n", + wpa_ssid_txt(ssid->ssid, + ssid->ssid_len)); + if (os_snprintf_error(end - pos, ret)) + return pos - buf; + pos += ret; + } + + if (hapd->conf->wps_state && hapd->conf->wpa && + ssid->wpa_passphrase) { + ret = os_snprintf(pos, end - pos, + "multi_ap_backhaul_wpa_passphrase=%s\n", + ssid->wpa_passphrase); + if (os_snprintf_error(end - pos, ret)) + return pos - buf; + pos += ret; + } + + if (hapd->conf->wps_state && hapd->conf->wpa && + ssid->wpa_psk && + ssid->wpa_psk->group) { + char hex[PMK_LEN * 2 + 1]; + + wpa_snprintf_hex(hex, sizeof(hex), ssid->wpa_psk->psk, + PMK_LEN); + ret = os_snprintf(pos, end - pos, + "multi_ap_backhaul_wpa_psk=%s\n", + hex); + forced_memzero(hex, sizeof(hex)); + if (os_snprintf_error(end - pos, ret)) + return pos - buf; + pos += ret; + } + } #endif /* CONFIG_WPS */ if (hapd->conf->wpa) {