]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Add multi_ap settings to get_config() output
authorRaphaël Mélotte <raphael.melotte@mind.be>
Wed, 2 Dec 2020 16:51:45 +0000 (17:51 +0100)
committerJouni Malinen <j@w1.fi>
Sat, 6 Feb 2021 16:03:58 +0000 (18:03 +0200)
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

index 381809d72f3d9bdfc8c9bc3f453f50608d2a1dbf..55084a919aa427710a8a7c6672db5d7cd3eddf60 100644 (file)
@@ -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) {