]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
NAN USD: Add publishChannelList option for Subscriber
authorShivani Baranwal <quic_shivbara@quicinc.com>
Mon, 5 Aug 2024 09:33:04 +0000 (15:03 +0530)
committerJouni Malinen <j@w1.fi>
Tue, 27 Aug 2024 07:51:56 +0000 (10:51 +0300)
Add frequency list to active NAN USD Subscriber to search for a
Publisher on multiple channels. This is the publish channel list used by
the Subscriber to periodically search for a service on these channels.
publishChannelList was already supported in the Publisher and this
commit extends that to the Subscriber.

This is needed for a P2P2 seeker that is an active subscriber looking
for an advertiser on a list of publish channels.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
src/common/nan_de.c
src/common/nan_de.h
wpa_supplicant/ctrl_iface.c

index c7294c59d5d95157fc0da749306aadc3095b9e6b..5e79b8c160c914780bb3351abc9e4439ea6969be 100644 (file)
@@ -1358,6 +1358,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);
index bdac284b4f76eb6af3d2af27f0e01940d5921b01..73f6c9c6136398a8b1dd5e7e2e82d8d754805389 100644 (file)
@@ -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;
 };
index f3d74a869f067bc33c5f6f9a46957ea2014c7c62..743e42e51536c68ca6e00eae920fb07b3ea85d35 100644 (file)
@@ -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;
@@ -12431,6 +12453,7 @@ static int wpas_ctrl_nan_subscribe(struct wpa_supplicant *wpa_s, char *cmd,
                ret = os_snprintf(buf, buflen, "%d", subscribe_id);
 fail:
        wpabuf_free(ssi);
+       os_free(freq_list);
        return ret;
 }