[PATCH] hostapd: output hw_mode when using STATUS

Antonio Prcela antonio.prcela at gmail.com
Thu Feb 2 15:02:07 PST 2023


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 at gmail.com>
Signed-off-by: Antonio Prcela <antonio.prcela at sartura.hr>
---
 src/ap/ctrl_iface_ap.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
index 168e5f507..bbf778ac0 100644
--- a/src/ap/ctrl_iface_ap.c
+++ b/src/ap/ctrl_iface_ap.c
@@ -212,6 +212,25 @@ 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";
+	default:
+		return "Unknown";
+	}
+}
+
+
 static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
 				      struct sta_info *sta,
 				      char *buf, size_t buflen)
@@ -730,6 +749,15 @@ 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"
-- 
2.39.1




More information about the Hostap mailing list