diff mbox series

[04/13] P2P2: Add freq list to subscriber to search for publisher on mutli channels

Message ID 1720431149-7494-4-git-send-email-quic_shivbara@quicinc.com
State Superseded
Headers show
Series [01/13] NAN: Option to offload NAN DE for USD into the driver | expand

Commit Message

Shivani Baranwal July 8, 2024, 9:32 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>
diff mbox series

Patch

diff --git a/src/common/nan_de.c b/src/common/nan_de.c
index 7017311b6..0b788413d 100644
--- a/src/common/nan_de.c
+++ b/src/common/nan_de.c
@@ -1349,6 +1349,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 bdac284b4..73f6c9c61 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/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 98b772f4c..11de96797 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -14155,7 +14155,7 @@  static int nl80211_nan_subscribe(void *priv, const u8 *src, int subscribe_id,
 	struct wpa_driver_nl80211_data *drv = bss->drv;
 	struct nl_msg *msg;
 	struct nlattr *container, *attr;
-	int ret;
+	int ret, freq_list_len = 0;
 
 	wpa_printf(MSG_DEBUG,
 		   "nl80211: Start NAN USD subscribe: freq=%u, ttl=%u",
@@ -14163,6 +14163,9 @@  static int nl80211_nan_subscribe(void *priv, const u8 *src, int subscribe_id,
 	wpa_hexdump(MSG_DEBUG, "nl80211: USD elems", wpabuf_head(elems),
 		    wpabuf_len(elems));
 
+	if (params->freq_list)
+		freq_list_len = int_array_len(params->freq_list);
+
 	msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR);
 	if (!msg ||
 	    nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_QCA) ||
@@ -14196,7 +14199,10 @@  static int nl80211_nan_subscribe(void *priv, const u8 *src, int subscribe_id,
 	if (!attr)
 		goto fail;
 	if (nla_put_u32(msg, QCA_WLAN_VENDOR_ATTR_NAN_USD_CHAN_CONFIG_DEFAULT_FREQ,
-			params->freq))
+			params->freq) ||
+	    (freq_list_len > 0 &&
+	     nla_put(msg, QCA_WLAN_VENDOR_ATTR_NAN_USD_CHAN_CONFIG_FREQ_LIST,
+		     sizeof(int) * freq_list_len, params->freq_list)))
 		goto fail;
 	nla_nest_end(msg, attr);