]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Output hw_mode when using STATUS
authorAntonio Prcela <antonio.prcela@gmail.com>
Thu, 2 Feb 2023 23:02:07 +0000 (00:02 +0100)
committerJouni Malinen <j@w1.fi>
Mon, 20 Feb 2023 17:38:02 +0000 (19:38 +0200)
Adding the hw_mode config parameter to the STATUS output to easier
determine the current hw_mode of an hostapd access-point. Currently
neither STATUS, GET hw_mode, nor GET_CONFIG output it.

Useful if the hostapd access point has been created with
wpa_ctrl_request() without using a *.conf file, like hostapd.conf.

Signed-off-by: Antonio Prcela <antonio.prcela@gmail.com>
Signed-off-by: Antonio Prcela <antonio.prcela@sartura.hr>
src/ap/ctrl_iface_ap.c

index 168e5f507b3fceac76db07a2ea281650876d17d3..2a7c33bf944f6bb5f1410fc48465382f9daf2a09 100644 (file)
@@ -212,6 +212,26 @@ static const char * timeout_next_str(int val)
 }
 
 
+static const char * hw_mode_str(enum hostapd_hw_mode mode)
+{
+       switch (mode) {
+       case HOSTAPD_MODE_IEEE80211B:
+               return "b";
+       case HOSTAPD_MODE_IEEE80211G:
+               return "g";
+       case HOSTAPD_MODE_IEEE80211A:
+               return "a";
+       case HOSTAPD_MODE_IEEE80211AD:
+               return "ad";
+       case HOSTAPD_MODE_IEEE80211ANY:
+               return "any";
+       case NUM_HOSTAPD_MODES:
+               return "invalid";
+       }
+       return "unknown";
+}
+
+
 static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
                                      struct sta_info *sta,
                                      char *buf, size_t buflen)
@@ -730,6 +750,14 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
                return len;
        len += ret;
 
+       if (mode) {
+               ret = os_snprintf(buf + len, buflen - len, "hw_mode=%s\n",
+                                 hw_mode_str(mode->mode));
+               if (os_snprintf_error(buflen - len, ret))
+                       return len;
+               len += ret;
+       }
+
        if (!iface->cac_started || !iface->dfs_cac_ms) {
                ret = os_snprintf(buf + len, buflen - len,
                                  "cac_time_seconds=%d\n"