diff mbox series

hostapd: Add multi_ap settings to get_config() output

Message ID 20201202165145.23578-1-raphael.melotte@mind.be
State Accepted
Headers show
Series hostapd: Add multi_ap settings to get_config() output | expand

Commit Message

Raphaël Mélotte Dec. 2, 2020, 4:51 p.m. UTC
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 <raphael.melotte@mind.be>
---
 hostapd/ctrl_iface.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

Comments

Jouni Malinen Feb. 6, 2021, 4:09 p.m. UTC | #1
On Wed, Dec 02, 2020 at 05:51:45PM +0100, Raphaël Mélotte wrote:
> 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).

Thanks, applied.
diff mbox series

Patch

diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index e2ae0ad44..19c5cc2fe 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -1222,6 +1222,45 @@  static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
 			return pos - buf;
 		pos += ret;
 	}
+
+	if (hapd->conf->multi_ap) {
+		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 (hapd->conf->multi_ap_backhaul_ssid.ssid) {
+			ret = os_snprintf(pos, end - pos, "multi_ap_backhaul_ssid=%s\n",
+							  hapd->conf->multi_ap_backhaul_ssid.ssid);
+			if (os_snprintf_error(end - pos, ret))
+				return pos - buf;
+			pos += ret;
+		}
+
+		if (hapd->conf->wps_state && hapd->conf->wpa &&
+			hapd->conf->multi_ap_backhaul_ssid.wpa_passphrase) {
+			ret = os_snprintf(pos, end - pos,
+							  "multi_ap_backhaul_wpa_passphrase=%s\n",
+							  hapd->conf->multi_ap_backhaul_ssid.wpa_passphrase);
+			if (os_snprintf_error(end - pos, ret))
+				return pos - buf;
+			pos += ret;
+		}
+
+		if (hapd->conf->wps_state && hapd->conf->wpa &&
+			hapd->conf->multi_ap_backhaul_ssid.wpa_psk &&
+			hapd->conf->multi_ap_backhaul_ssid.wpa_psk->group) {
+			char hex[PMK_LEN * 2 + 1];
+			wpa_snprintf_hex(hex, sizeof(hex),
+							 hapd->conf->multi_ap_backhaul_ssid.wpa_psk->psk, PMK_LEN);
+			ret = os_snprintf(pos, end - pos, "multi_ap_backhaul_wpa_psk=%s\n", hex);
+			if (os_snprintf_error(end - pos, ret))
+				return pos - buf;
+			pos += ret;
+		}
+	}
+
 #endif /* CONFIG_WPS */
 
 	if (hapd->conf->wpa) {