[PATCH V3 03/20] NAN: Add inline stubs and remove unnecessary ifdef guards
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Thu Feb 5 07:12:00 PST 2026
Add inline stub functions to nan_supplicant.h for when CONFIG_NAN_USD
or CONFIG_NAN are not enabled. This allows removing many #ifdef
CONFIG_NAN_USD guards from the calling code, making the code cleaner.
The header is reorganized into three sections:
1. CONFIG_NAN only (synchronized NAN)
2. CONFIG_NAN || CONFIG_NAN_USD (common functions)
3. CONFIG_NAN_USD only (USD-specific)
Each section provides inline stubs when the feature is not enabled.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
wpa_supplicant/ctrl_iface.c | 10 ++--
wpa_supplicant/events.c | 8 ---
wpa_supplicant/nan_supplicant.c | 2 -
wpa_supplicant/nan_supplicant.h | 92 ++++++++++++++++++++++++++++++---
wpa_supplicant/notify.c | 4 +-
wpa_supplicant/wpa_supplicant.c | 6 ---
6 files changed, 90 insertions(+), 32 deletions(-)
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 06e3d0e320..f6b9fdccd9 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -9210,9 +9210,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
wpa_s->conf->ignore_old_scan_res = 0;
-#ifdef CONFIG_NAN_USD
wpas_nan_de_flush(wpa_s);
-#endif /* CONFIG_NAN_USD */
wpas_pr_flush(wpa_s);
}
@@ -12732,7 +12730,7 @@ static int wpas_ctrl_ml_probe(struct wpa_supplicant *wpa_s, char *cmd)
#endif /* CONFIG_TESTING_OPTIONS */
-#ifdef CONFIG_NAN_USD
+#if defined(CONFIG_NAN) || defined(CONFIG_NAN_USD)
static int wpas_ctrl_nan_publish(struct wpa_supplicant *wpa_s, char *cmd,
char *buf, size_t buflen)
@@ -13192,7 +13190,7 @@ static int wpas_ctrl_nan_unpause_publish(struct wpa_supplicant *wpa_s,
peer_addr);
}
-#endif /* CONFIG_NAN_USD */
+#endif /* CONFIG_NAN || CONFIG_NAN_USD */
char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
@@ -14201,7 +14199,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
reply_len = -1;
#endif /* CONFIG_DPP3 */
#endif /* CONFIG_DPP */
-#ifdef CONFIG_NAN_USD
+#if defined(CONFIG_NAN) || defined(CONFIG_NAN_USD)
} else if (os_strncmp(buf, "NAN_PUBLISH ", 12) == 0) {
reply_len = wpas_ctrl_nan_publish(wpa_s, buf + 12, reply,
reply_size);
@@ -14231,7 +14229,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
reply_len = -1;
} else if (os_strcmp(buf, "NAN_FLUSH") == 0) {
wpas_nan_de_flush(wpa_s);
-#endif /* CONFIG_NAN_USD */
+#endif /* CONFIG_NAN || CONFIG_NAN_USD */
#ifdef CONFIG_PASN
} else if (os_strncmp(buf, "PASN_START ", 11) == 0) {
if (wpas_ctrl_iface_pasn_start(wpa_s, buf + 11) < 0)
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 3d3237ed51..3a6a3439a1 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -5686,7 +5686,6 @@ static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s,
}
#endif /* CONFIG_FST */
-#ifdef CONFIG_NAN_USD
if (category == WLAN_ACTION_PUBLIC && plen >= 5 &&
payload[0] == WLAN_PA_VENDOR_SPECIFIC &&
WPA_GET_BE32(&payload[1]) == NAN_SDF_VENDOR_TYPE) {
@@ -5696,7 +5695,6 @@ static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s,
payload, plen);
return;
}
-#endif /* CONFIG_NAN_USD */
#ifdef CONFIG_DPP
if (category == WLAN_ACTION_PUBLIC && plen >= 5 &&
@@ -6977,11 +6975,9 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
wpa_s, data->remain_on_channel.freq,
data->remain_on_channel.duration);
#endif /* CONFIG_DPP */
-#ifdef CONFIG_NAN_USD
wpas_nan_usd_remain_on_channel_cb(
wpa_s, data->remain_on_channel.freq,
data->remain_on_channel.duration);
-#endif /* CONFIG_NAN_USD */
break;
case EVENT_CANCEL_REMAIN_ON_CHANNEL:
#ifdef CONFIG_OFFCHANNEL
@@ -6994,10 +6990,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
wpas_dpp_cancel_remain_on_channel_cb(
wpa_s, data->remain_on_channel.freq);
#endif /* CONFIG_DPP */
-#ifdef CONFIG_NAN_USD
wpas_nan_usd_cancel_remain_on_channel_cb(
wpa_s, data->remain_on_channel.freq);
-#endif /* CONFIG_NAN_USD */
break;
case EVENT_EAPOL_RX:
wpa_supplicant_rx_eapol(wpa_s, data->eapol_rx.src,
@@ -7339,9 +7333,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
#ifdef CONFIG_DPP
wpas_dpp_tx_wait_expire(wpa_s);
#endif /* CONFIG_DPP */
-#ifdef CONFIG_NAN_USD
wpas_nan_usd_tx_wait_expire(wpa_s);
-#endif /* CONFIG_NAN_USD */
break;
case EVENT_TID_LINK_MAP:
if (data)
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index c2629f902c..e71a6db253 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -155,7 +155,6 @@ void wpas_nan_next_dw(struct wpa_supplicant *wpa_s, u32 freq)
#endif /* CONFIG_NAN */
-#ifdef CONFIG_NAN_USD
static const char *
tx_status_result_txt(enum offchannel_send_action_result result)
@@ -852,4 +851,3 @@ void wpas_nan_usd_state_change_notif(struct wpa_supplicant *wpa_s)
}
}
-#endif /* CONFIG_NAN_USD */
diff --git a/wpa_supplicant/nan_supplicant.h b/wpa_supplicant/nan_supplicant.h
index 5bb09ae51f..3a2411584f 100644
--- a/wpa_supplicant/nan_supplicant.h
+++ b/wpa_supplicant/nan_supplicant.h
@@ -10,6 +10,7 @@
#ifndef NAN_SUPPLICANT_H
#define NAN_SUPPLICANT_H
+/* NAN synchronization only */
#ifdef CONFIG_NAN
int wpas_nan_init(struct wpa_supplicant *wpa_s);
@@ -45,14 +46,22 @@ static inline int wpas_nan_stop(struct wpa_supplicant *wpa_s)
static inline void wpas_nan_flush(struct wpa_supplicant *wpa_s)
{}
-#endif /* CONFIG_NAN */
+static inline void wpas_nan_cluster_join(struct wpa_supplicant *wpa_s,
+ const u8 *cluster_id,
+ bool new_cluster)
+{}
-#ifdef CONFIG_NAN_USD
+static inline void wpas_nan_next_dw(struct wpa_supplicant *wpa_s, u32 freq)
+{}
+#endif /* CONFIG_NAN */
struct nan_subscribe_params;
struct nan_publish_params;
enum nan_service_protocol_type;
+/* NAN sync and USD common */
+#if defined(CONFIG_NAN_USD) || defined(CONFIG_NAN)
+
int wpas_nan_de_init(struct wpa_supplicant *wpa_s);
void wpas_nan_de_deinit(struct wpa_supplicant *wpa_s);
void wpas_nan_de_rx_sdf(struct wpa_supplicant *wpa_s, const u8 *src,
@@ -66,10 +75,6 @@ int wpas_nan_publish(struct wpa_supplicant *wpa_s, const char *service_name,
void wpas_nan_cancel_publish(struct wpa_supplicant *wpa_s, int publish_id);
int wpas_nan_update_publish(struct wpa_supplicant *wpa_s, int publish_id,
const struct wpabuf *ssi);
-int wpas_nan_usd_unpause_publish(struct wpa_supplicant *wpa_s, int publish_id,
- u8 peer_instance_id, const u8 *peer_addr);
-int wpas_nan_usd_publish_stop_listen(struct wpa_supplicant *wpa_s,
- int publish_id);
int wpas_nan_subscribe(struct wpa_supplicant *wpa_s,
const char *service_name,
enum nan_service_protocol_type srv_proto_type,
@@ -77,11 +82,33 @@ int wpas_nan_subscribe(struct wpa_supplicant *wpa_s,
struct nan_subscribe_params *params, bool p2p);
void wpas_nan_cancel_subscribe(struct wpa_supplicant *wpa_s,
int subscribe_id);
-int wpas_nan_usd_subscribe_stop_listen(struct wpa_supplicant *wpa_s,
- int subscribe_id);
int wpas_nan_transmit(struct wpa_supplicant *wpa_s, int handle,
const struct wpabuf *ssi, const struct wpabuf *elems,
const u8 *peer_addr, u8 req_instance_id);
+
+#else /* CONFIG_NAN_USD || CONFIG_NAN */
+
+static inline int wpas_nan_de_init(struct wpa_supplicant *wpa_s)
+{
+ return 0;
+}
+
+static inline void wpas_nan_de_deinit(struct wpa_supplicant *wpa_s)
+{}
+
+static inline
+void wpas_nan_de_rx_sdf(struct wpa_supplicant *wpa_s, const u8 *src,
+ const u8 *a3, unsigned int freq,
+ const u8 *buf, size_t len)
+{}
+
+static inline void wpas_nan_de_flush(struct wpa_supplicant *wpa_s)
+{}
+
+#endif /* CONFIG_NAN_USD || CONFIG_NAN */
+
+/* NAN USD only */
+#ifdef CONFIG_NAN_USD
void wpas_nan_usd_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
unsigned int freq,
unsigned int duration);
@@ -89,8 +116,57 @@ void wpas_nan_usd_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
unsigned int freq);
void wpas_nan_usd_tx_wait_expire(struct wpa_supplicant *wpa_s);
int * wpas_nan_usd_all_freqs(struct wpa_supplicant *wpa_s);
+int wpas_nan_usd_unpause_publish(struct wpa_supplicant *wpa_s, int publish_id,
+ u8 peer_instance_id, const u8 *peer_addr);
+int wpas_nan_usd_publish_stop_listen(struct wpa_supplicant *wpa_s,
+ int publish_id);
+int wpas_nan_usd_subscribe_stop_listen(struct wpa_supplicant *wpa_s,
+ int subscribe_id);
void wpas_nan_usd_state_change_notif(struct wpa_supplicant *wpa_s);
+#else /* CONFIG_NAN_USD */
+
+static inline
+void wpas_nan_usd_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
+ unsigned int freq,
+ unsigned int duration)
+{}
+
+static inline
+void wpas_nan_usd_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
+ unsigned int freq)
+{}
+
+static inline
+int * wpas_nan_usd_all_freqs(struct wpa_supplicant *wpa_s)
+{
+ return NULL;
+}
+
+static inline
+int wpas_nan_usd_unpause_publish(struct wpa_supplicant *wpa_s, int publish_id,
+ u8 peer_instance_id, const u8 *peer_addr)
+{
+ return -1;
+}
+
+static inline
+int wpas_nan_usd_publish_stop_listen(struct wpa_supplicant *wpa_s,
+ int publish_id)
+{
+ return -1;
+}
+
+static inline
+int wpas_nan_usd_subscribe_stop_listen(struct wpa_supplicant *wpa_s,
+ int subscribe_id)
+{
+ return -1;
+}
+
+static inline void wpas_nan_usd_state_change_notif(struct wpa_supplicant *wpa_s)
+{}
+
#endif /* CONFIG_NAN_USD */
#endif /* NAN_SUPPLICANT_H */
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index c79f0fca5b..36694b48c8 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -1097,7 +1097,7 @@ void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
#endif /* CONFIG_HS20 */
-#ifdef CONFIG_NAN_USD
+#if defined(CONFIG_NAN) || defined(CONFIG_NAN_USD)
void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s,
enum nan_service_protocol_type
@@ -1213,7 +1213,7 @@ void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s,
nan_reason_txt(reason));
}
-#endif /* CONFIG_NAN_USD */
+#endif /* CONFIG_NAN || CONFIG_NAN_USD */
#ifdef CONFIG_PR
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index f9eaaf66df..353ea90e7d 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -855,9 +855,7 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
wpa_s->dpp = NULL;
#endif /* CONFIG_DPP */
-#ifdef CONFIG_NAN_USD
wpas_nan_de_deinit(wpa_s);
-#endif /* CONFIG_NAN_USD */
#ifdef CONFIG_PASN
wpas_pasn_auth_stop(wpa_s);
@@ -1324,9 +1322,7 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
wpas_update_fils_connect_params(wpa_s);
#endif /* CONFIG_FILS && IEEE8021X_EAPOL */
-#ifdef CONFIG_NAN_USD
wpas_nan_usd_state_change_notif(wpa_s);
-#endif /* CONFIG_NAN_USD */
}
@@ -7986,10 +7982,8 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
return -1;
#endif /* CONFIG_DPP */
-#ifdef CONFIG_NAN_USD
if (wpas_nan_de_init(wpa_s) < 0)
return -1;
-#endif /* CONFIG_NAN_USD */
#ifdef CONFIG_NAN
wpa_s->nan_drv_flags = capa.nan_flags;
--
2.52.0
More information about the Hostap
mailing list