[RFC 23/34] wpa_supplicant: Support synchronized NAN publish/subscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Extend wpas_nan_publish() and wpas_nan_subscribe() to support
synchronized discovery configuration.
Make sure NAN synchronization is active and check driver support for
user space DE.
In addition, prevent P2P2 discovery as it supposed to be USD only.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@xxxxxxxxx>
---
 wpa_supplicant/ctrl_iface.c     | 10 ++++++++
 wpa_supplicant/nan_supplicant.c | 45 +++++++++++++++++++++++++++++++--
 2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 9180c90623..b4498c4773 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -12658,6 +12658,11 @@ static int wpas_ctrl_nan_publish(struct wpa_supplicant *wpa_s, char *cmd,
 			continue;
 		}
 
+		if (os_strcmp(token, "sync=1") == 0) {
+			params.sync = true;
+			continue;
+		}
+
 		wpa_printf(MSG_INFO, "CTRL: Invalid NAN_PUBLISH parameter: %s",
 			   token);
 		goto fail;
@@ -12815,6 +12820,11 @@ static int wpas_ctrl_nan_subscribe(struct wpa_supplicant *wpa_s, char *cmd,
 			continue;
 		}
 
+		if (os_strcmp(token, "sync=1") == 0) {
+			params.sync = true;
+			continue;
+		}
+
 		wpa_printf(MSG_INFO,
 			   "CTRL: Invalid NAN_SUBSCRIBE parameter: %s",
 			   token);
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index 28661b4753..1a2c04edbc 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -528,6 +528,27 @@ int wpas_nan_publish(struct wpa_supplicant *wpa_s, const char *service_name,
 	if (!wpa_s->nan_de)
 		return -1;
 
+	if (params->sync) {
+		if (!(wpa_s->nan_drv_flags &
+		      WPA_DRIVER_FLAGS_NAN_SUPPORT_USERSPACE_DE)) {
+			wpa_printf(MSG_DEBUG,
+				   "NAN: Can't advertise sync service, driver does not support user space DE");
+			return -1;
+		}
+
+		if (!wpas_nan_ready(wpa_s)) {
+			wpa_printf(MSG_DEBUG,
+				   "NAN: Synchronized support is not enabled");
+			return -1;
+		}
+
+		if (p2p) {
+			wpa_printf(MSG_DEBUG,
+				   "NAN: Sync discovery is not supported for P2P");
+			return -1;
+		}
+	}
+
 	if (p2p) {
 		elems = wpas_p2p_usd_elems(wpa_s, service_name);
 		addr = wpa_s->global->p2p_dev_addr;
@@ -537,7 +558,7 @@ int wpas_nan_publish(struct wpa_supplicant *wpa_s, const char *service_name,
 
 	publish_id = nan_de_publish(wpa_s->nan_de, service_name, srv_proto_type,
 				    ssi, elems, params, p2p);
-	if (publish_id >= 1 &&
+	if (publish_id >= 1 && !params->sync &&
 	    (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_NAN_USD_OFFLOAD) &&
 	    wpas_drv_nan_publish(wpa_s, addr, publish_id, service_name,
 				 nan_de_get_service_id(wpa_s->nan_de,
@@ -601,6 +622,26 @@ int wpas_nan_subscribe(struct wpa_supplicant *wpa_s,
 	if (!wpa_s->nan_de)
 		return -1;
 
+	if (params->sync) {
+		if (!(wpa_s->nan_drv_flags &
+		      WPA_DRIVER_FLAGS_NAN_SUPPORT_USERSPACE_DE)) {
+			wpa_printf(MSG_DEBUG,
+				   "NAN: Can't subscribe sync, user space DE is not supported");
+			return -1;
+		}
+
+		if (!wpas_nan_ready(wpa_s)) {
+			wpa_printf(MSG_DEBUG, "NAN: Not ready (subscribe)");
+			return -1;
+		}
+
+		if (p2p) {
+			wpa_printf(MSG_DEBUG,
+				   "NAN: Sync discovery is not supported for P2P (subscribe)");
+			return -1;
+		}
+	}
+
 	if (p2p) {
 		elems = wpas_p2p_usd_elems(wpa_s, service_name);
 		addr = wpa_s->global->p2p_dev_addr;
@@ -611,7 +652,7 @@ int wpas_nan_subscribe(struct wpa_supplicant *wpa_s,
 	subscribe_id = nan_de_subscribe(wpa_s->nan_de, service_name,
 					srv_proto_type, ssi, elems, params,
 					p2p);
-	if (subscribe_id >= 1 &&
+	if (subscribe_id >= 1 && !params->sync &&
 	    (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_NAN_USD_OFFLOAD) &&
 	    wpas_drv_nan_subscribe(wpa_s, addr, subscribe_id, service_name,
 				   nan_de_get_service_id(wpa_s->nan_de,
-- 
2.49.0


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux