git: 84ed86380aeb - main - hostapd: Work around lack of MLME support

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Mon, 04 Mar 2024 16:41:36 UTC
The branch main has been updated by cy:

URL: https://cgit.FreeBSD.org/src/commit/?id=84ed86380aeb566ffd8b957ba99c36ad345413ef

commit 84ed86380aeb566ffd8b957ba99c36ad345413ef
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2024-02-27 03:34:09 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2024-03-04 16:40:58 +0000

    hostapd: Work around lack of MLME support
    
    hostap MLME uses Linux data structures and definitions not available
    in FreeBSD. The ability for hostapd to select the frequency (channel)
    depends Linux MLME, though strictly it's not required. Work around the
    Linux MLME requirement to configure device frequency.
    
    The detailed description is: hostapd will only set the channel (frequency)
    when Linux MLME is configured. Enabling NEED_AP_MLME will result in
    numerous build errors due do Linux data structures and definitions not
    available under FreeBSD. The code to set the frequency from the selected
    channel is only within the NEED_AP_MLME code path because without MLME,
    hostapd_get_hw_features() is an inline that always returns -1 whereas with
    MLME hostapd_get_hw_features() will obtain hardware features from the
    kernel. Until such time we simply set the frequency as configured.
    
    PR:             276375
    MFC after:      1 month
---
 contrib/wpa/src/ap/hostapd.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/contrib/wpa/src/ap/hostapd.c b/contrib/wpa/src/ap/hostapd.c
index 4b88641a2dde..a5cabc01f163 100644
--- a/contrib/wpa/src/ap/hostapd.c
+++ b/contrib/wpa/src/ap/hostapd.c
@@ -1698,6 +1698,20 @@ static int setup_interface2(struct hostapd_iface *iface)
 {
 	iface->wait_channel_update = 0;
 
+#ifdef __FreeBSD
+	/* XXX hostapd_get_hw_features() is an inline that always returns -1
+	 * because MLME will not build under FreeBSD due to its use of
+	 * Linux definitions. Normally FreeBSD would uncondionally execute the
+	 * "Not all drivers support..." block. Instead we #ifdef out the entire
+	 * block of code instead of maintaining the fallacy that
+	 * hostapd_get_hw_features() returns anything meaninful.
+	 *
+	 * Ideally WANT_AP_MLME should be taught about FreeBSD data structures
+	 * and defintions. Instead we do this to enable channel selection in
+	 * hostapd.conf.
+	 */
+	iface->freq = iface->conf->channel;
+#else
 	if (hostapd_get_hw_features(iface)) {
 		/* Not all drivers support this yet, so continue without hw
 		 * feature data. */
@@ -1744,6 +1758,7 @@ static int setup_interface2(struct hostapd_iface *iface)
 		if (iface->conf->ieee80211h)
 			wpa_printf(MSG_DEBUG, "DFS support is enabled");
 	}
+#endif
 	return hostapd_setup_interface_complete(iface, 0);
 
 fail: