endif
endif
+ifdef CONFIG_NAN
+OBJS += nan_supplicant.c
+OBJS += src/nan/nan.c
+CFLAGS += -DCONFIG_NAN
+endif
+
ifdef CONFIG_NAN_USD
OBJS += src/common/nan_de.c
OBJS += nan_usd.c
endif
endif
+ifdef CONFIG_NAN
+OBJS += nan_supplicant.o
+OBJS += ../src/nan/nan.o
+CFLAGS += -DCONFIG_NAN
+endif
+
ifdef CONFIG_NAN_USD
OBJS += ../src/common/nan_de.o
OBJS += nan_usd.o
type = WPA_IF_STATION;
} else if (os_strcmp(pos, "ap") == 0) {
type = WPA_IF_AP_BSS;
+ } else if (os_strcmp(pos, "nan") == 0) {
+ type = WPA_IF_NAN;
+ iface.nan_mgmt = true;
} else {
wpa_printf(MSG_DEBUG,
"INTERFACE_ADD unsupported interface type: '%s'",
# Wi-Fi Aware unsynchronized service discovery (NAN USD)
#CONFIG_NAN_USD=y
+
+# Wi-Fi Aware (NAN) support
+#CONFIG_NAN=y
subscribe_id);
}
+
+#ifdef CONFIG_NAN
+
+static inline int wpa_drv_nan_start(struct wpa_supplicant *wpa_s,
+ struct nan_cluster_config *conf)
+{
+ if (!wpa_s->driver->nan_start)
+ return -1;
+ return wpa_s->driver->nan_start(wpa_s->drv_priv, conf);
+}
+
+static inline void wpa_drv_nan_stop(struct wpa_supplicant *wpa_s)
+{
+ if (!wpa_s->driver->nan_stop)
+ return;
+ wpa_s->driver->nan_stop(wpa_s->drv_priv);
+}
+
+#endif /* CONFIG_NAN */
+
#endif /* DRIVER_I_H */
#include "nan_usd.h"
#include "dpp_supplicant.h"
#include "pr_supplicant.h"
+#include "nan_supplicant.h"
#define MAX_OWE_TRANSITION_BSS_SELECT_COUNT 5
else
wpa_sm_pmksa_cache_reconfig(wpa_s->wpa);
wpa_supplicant_set_default_scan_ies(wpa_s);
- if (wpa_s->p2p_mgmt) {
+ if (wpa_s->p2p_mgmt || wpa_s->nan_mgmt) {
wpa_supplicant_set_state(wpa_s,
WPA_DISCONNECTED);
break;
break;
case EVENT_INTERFACE_DISABLED:
wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled");
+ if (wpa_s->nan_mgmt) {
+ wpas_nan_flush(wpa_s);
+ wpa_supplicant_set_state(wpa_s,
+ WPA_INTERFACE_DISABLED);
+ break;
+ }
#ifdef CONFIG_P2P
if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO ||
(wpa_s->current_ssid && wpa_s->current_ssid->p2p_group &&
--- /dev/null
+/*
+ * wpa_supplicant - NAN
+ * Copyright (C) 2025 Intel Corporation
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#include "includes.h"
+
+#include "common.h"
+#include "wpa_supplicant_i.h"
+#include "driver_i.h"
+#include "nan/nan.h"
+#include "config.h"
+
+#define DEFAULT_NAN_MASTER_PREF 2
+#define DEFAULT_NAN_DUAL_BAND 0
+
+
+static int wpas_nan_start_cb(void *ctx, struct nan_cluster_config *config)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ return wpa_drv_nan_start(wpa_s, config);
+}
+
+
+static void wpas_nan_stop_cb(void *ctx)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ wpa_drv_nan_stop(wpa_s);
+}
+
+
+int wpas_nan_init(struct wpa_supplicant *wpa_s)
+{
+ struct nan_config nan;
+
+ if (!(wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SUPPORT_NAN)) {
+ wpa_printf(MSG_INFO, "NAN: Driver does not support NAN");
+ return -1;
+ }
+
+ os_memset(&nan, 0, sizeof(nan));
+ nan.cb_ctx = wpa_s;
+
+ nan.start = wpas_nan_start_cb;
+ nan.stop = wpas_nan_stop_cb;
+
+ wpa_s->nan = nan_init(&nan);
+ if (!wpa_s->nan) {
+ wpa_printf(MSG_INFO, "NAN: Failed to init");
+ return -1;
+ }
+
+ return 0;
+}
+
+
+void wpas_nan_deinit(struct wpa_supplicant *wpa_s)
+{
+ if (!wpa_s || !wpa_s->nan)
+ return;
+
+ nan_deinit(wpa_s->nan);
+ wpa_s->nan = NULL;
+}
+
+
+static int wpas_nan_ready(struct wpa_supplicant *wpa_s)
+{
+ return wpa_s->nan_mgmt && wpa_s->nan &&
+ wpa_s->wpa_state != WPA_INTERFACE_DISABLED;
+}
+
+
+/* Join a cluster using current configuration */
+int wpas_nan_start(struct wpa_supplicant *wpa_s)
+{
+ struct nan_cluster_config cluster_config;
+
+ if (!wpas_nan_ready(wpa_s))
+ return -1;
+
+ cluster_config.master_pref = DEFAULT_NAN_MASTER_PREF;
+ cluster_config.dual_band = DEFAULT_NAN_DUAL_BAND;
+
+ return nan_start(wpa_s->nan, &cluster_config);
+}
+
+
+int wpas_nan_stop(struct wpa_supplicant *wpa_s)
+{
+ if (!wpas_nan_ready(wpa_s))
+ return -1;
+
+ nan_stop(wpa_s->nan);
+
+ return 0;
+}
+
+
+void wpas_nan_flush(struct wpa_supplicant *wpa_s)
+{
+ if (!wpas_nan_ready(wpa_s))
+ return;
+
+ nan_flush(wpa_s->nan);
+}
--- /dev/null
+/*
+ * wpa_supplicant - NAN
+ * Copyright (C) 2025 Intel Corporation
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#ifndef NAN_SUPPLICANT_H
+#define NAN_SUPPLICANT_H
+
+#ifdef CONFIG_NAN
+
+int wpas_nan_init(struct wpa_supplicant *wpa_s);
+void wpas_nan_deinit(struct wpa_supplicant *wpa_s);
+int wpas_nan_start(struct wpa_supplicant *wpa_s);
+int wpas_nan_stop(struct wpa_supplicant *wpa_s);
+void wpas_nan_flush(struct wpa_supplicant *wpa_s);
+
+#else /* CONFIG_NAN */
+
+static inline int wpas_nan_init(struct wpa_supplicant *wpa_s)
+{
+ return -1;
+}
+
+static inline void wpas_nan_deinit(struct wpa_supplicant *wpa_s)
+{}
+
+static inline int wpas_nan_start(struct wpa_supplicant *wpa_s)
+{
+ return -1;
+}
+
+static inline int wpas_nan_stop(struct wpa_supplicant *wpa_s)
+{
+ return -1;
+}
+
+static inline void wpas_nan_flush(struct wpa_supplicant *wpa_s)
+{}
+
+#endif /* CONFIG_NAN */
+
+#endif /* NAN_SUPPLICANT_H */
#include "dpp_supplicant.h"
#include "nan_usd.h"
#include "pr_supplicant.h"
+#include "nan_supplicant.h"
#ifdef CONFIG_MESH
#include "ap/ap_config.h"
#include "ap/hostapd.h"
if ((!wpa_s->p2p_mgmt ||
!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)) &&
- !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE)) {
+ !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE) &&
+ !wpa_s->nan_mgmt) {
l2_packet_deinit(wpa_s->l2);
wpa_s->l2 = l2_packet_init(wpa_s->ifname,
wpa_drv_get_mac_addr(wpa_s),
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)
wpa_s->p2p_mgmt = iface->p2p_mgmt;
+ wpa_s->nan_mgmt = iface->nan_mgmt;
+
if (wpa_s->num_multichan_concurrent == 0)
wpa_s->num_multichan_concurrent = 1;
return -1;
#ifdef CONFIG_TDLS
- if (!iface->p2p_mgmt && wpa_tdls_init(wpa_s->wpa))
+ if (!iface->p2p_mgmt && !iface->nan_mgmt && wpa_tdls_init(wpa_s->wpa))
return -1;
#endif /* CONFIG_TDLS */
wpa_supplicant_set_default_scan_ies(wpa_s);
+ if (wpa_s->nan_mgmt && wpas_nan_init(wpa_s) < 0) {
+ wpa_msg(wpa_s, MSG_ERROR, "Failed to init NAN");
+ return -1;
+ }
+
return 0;
}
wpa_supplicant_cleanup(wpa_s);
wpas_p2p_deinit_iface(wpa_s);
+ wpas_nan_deinit(wpa_s);
+
wpas_ctrl_radio_work_flush(wpa_s);
radio_remove_interface(wpa_s);
return NULL;
}
- if (iface->p2p_mgmt == 0) {
+ if (iface->p2p_mgmt == 0 && !iface->nan_mgmt) {
/* Notify the control interfaces about new iface */
if (wpas_notify_iface_added(wpa_s)) {
wpa_supplicant_deinit_iface(wpa_s, 1, 0);
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
#ifdef CONFIG_P2P
- if (wpa_s->global->p2p == NULL &&
+ if (!wpa_s->global->p2p && !iface->nan_mgmt &&
!wpa_s->global->p2p_disabled && !wpa_s->conf->p2p_disabled &&
(wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) &&
wpas_p2p_add_p2pdev_interface(
WPA_IFACE_MATCHED
} matched;
#endif /* CONFIG_MATCH_IFACE */
+
+ /**
+ * nan_mgmt - Interface used for NAN management (NAN Device operations)
+ */
+ bool nan_mgmt;
};
/**
bool ext_auth_to_same_bss; /* Whether external authentication has been
* completed successfully with the BSS that
* we are already associated with. */
+
+ bool nan_mgmt;
+
+#ifdef CONFIG_NAN
+ struct nan_data *nan;
+#endif /* CONFIG_NAN */
};