diff mbox series

[v3,06/25] P2P: Add freq list to subscriber to search for publisher on mutli channels

Message ID 1722850403-8852-7-git-send-email-quic_shivbara@quicinc.com
State Accepted
Headers show
Series Add support for P2P2 | expand

Commit Message

Shivani Baranwal Aug. 5, 2024, 9:33 a.m. UTC
Add freq list to active NAN USD subscriber to search for a publisher on
multiple channels. These are the publish channel list used by the
subscriber to periodically search for a service on these channels. In P2P2
seeker is an active subscriber looking for advertiser on list of publish
channels.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
---
 src/common/nan_de.c         | 11 +++++++++++
 src/common/nan_de.h         |  3 +++
 wpa_supplicant/ctrl_iface.c | 22 ++++++++++++++++++++++
 3 files changed, 36 insertions(+)
diff mbox series

Patch

diff --git a/src/common/nan_de.c b/src/common/nan_de.c
index 5a68cc9..938a357 100644
--- a/src/common/nan_de.c
+++ b/src/common/nan_de.c
@@ -1355,6 +1355,17 @@  int nan_de_subscribe(struct nan_de *de, const char *service_name,
 	if (nan_de_derive_service_id(srv) < 0)
 		goto fail;
 	os_memcpy(&srv->subscribe, params, sizeof(*params));
+
+	if (params->freq_list) {
+		size_t len;
+
+		len = (int_array_len(params->freq_list) + 1) * sizeof(int);
+		srv->freq_list = os_memdup(params->freq_list, len);
+		if (!srv->freq_list)
+			goto fail;
+	}
+	srv->subscribe.freq_list = NULL;
+
 	srv->srv_proto_type = srv_proto_type;
 	if (ssi) {
 		srv->ssi = wpabuf_dup(ssi);
diff --git a/src/common/nan_de.h b/src/common/nan_de.h
index bdac284..73f6c9c 100644
--- a/src/common/nan_de.h
+++ b/src/common/nan_de.h
@@ -125,6 +125,9 @@  struct nan_subscribe_params {
 	/* Selected frequency */
 	unsigned int freq;
 
+	/* Multi-channel frequencies (publishChannelList) */
+	const int *freq_list;
+
 	/* Query period in ms; 0 = use default */
 	unsigned int query_period;
 };
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index f3d74a8..5588e79 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -12373,6 +12373,7 @@  static int wpas_ctrl_nan_subscribe(struct wpa_supplicant *wpa_s, char *cmd,
 	struct wpabuf *ssi = NULL;
 	int ret = -1;
 	enum nan_service_protocol_type srv_proto_type = 0;
+	int *freq_list = NULL;
 	bool p2p = false;
 
 	os_memset(&params, 0, sizeof(params));
@@ -12399,6 +12400,27 @@  static int wpas_ctrl_nan_subscribe(struct wpa_supplicant *wpa_s, char *cmd,
 			continue;
 		}
 
+		if (os_strncmp(token, "freq_list=", 10) == 0) {
+			char *pos = token + 10;
+
+			if (os_strcmp(pos, "all") == 0) {
+				os_free(freq_list);
+				freq_list = wpas_nan_usd_all_freqs(wpa_s);
+				params.freq_list = freq_list;
+				continue;
+			}
+
+			while (pos && pos[0]) {
+				int_array_add_unique(&freq_list, atoi(pos));
+				pos = os_strchr(pos, ',');
+				if (pos)
+					pos++;
+			}
+
+			params.freq_list = freq_list;
+			continue;
+		}
+
 		if (os_strncmp(token, "srv_proto_type=", 15) == 0) {
 			srv_proto_type = atoi(token + 15);
 			continue;