[PATCH] NAN: Send synchronized service SSI also in SDA Service Info

Paul Hu paulhu at google.com
Tue Nov 10 22:42:11 PST 2026


nan_de puts the service specific info (SSI) of synchronized services
only in the Service Info field of the SDEA. The SDA has its own Service
Info field, and other NAN implementations commonly carry SSI there. Some
of them do not deliver SSI that is only in the SDEA to the application,
so service discovery that depends on the SSI fails with them.

For synchronized services, also put SSI of up to 255 octets in the SDA
Service Info field. Keep sending it in the SDEA as well for peers that
read it from there. When both are present, nan_de uses the SSI from the
SDEA, so this does not change the result between wpa_supplicant
instances. USD services are not changed.

Add an hwsim test case that verifies from the capture that both the
publisher and the subscriber send the SSI in the Service Info field of
the SDA and of the SDEA.

Signed-off-by: Paul Hu <paulhu at google.com>
---
 src/common/nan_de.c     | 19 +++++++++++++++++++
 tests/hwsim/test_nan.py | 23 +++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/src/common/nan_de.c b/src/common/nan_de.c
index f070d82aa..e60e064ef 100644
--- a/src/common/nan_de.c
+++ b/src/common/nan_de.c
@@ -650,6 +650,20 @@ static size_t nan_de_sdf_attrs_put(struct wpabuf *buf, struct nan_de *de,
 		ctrl |= NAN_SRV_CTRL_RESP_FILTER;
 	}
 
+	/*
+	 * For synchronized services, also send SSI that fits into the SDA
+	 * Service Info field (one octet length) in the SDA. Other NAN
+	 * implementations carry and expect SSI there and some of them do not
+	 * deliver SSI that is only in the SDEA Service Info field. The SSI is
+	 * still sent in the SDEA as well for implementations that read it from
+	 * there.
+	 */
+	if (srv->sync && ssi && wpabuf_len(ssi) && wpabuf_len(ssi) <= 255) {
+		/* Service Info length + Service Info */
+		sda_len += 1 + wpabuf_len(ssi);
+		ctrl |= NAN_SRV_CTRL_SRV_INFO;
+	}
+
 	if ((srv->type == NAN_DE_SUBSCRIBE || srv->type == NAN_DE_PUBLISH) &&
 	    srv->close_proximity)
 		ctrl |= NAN_SRV_CTRL_DISCOVERY_RANGE_LIMITED;
@@ -789,6 +803,11 @@ static size_t nan_de_sdf_attrs_put(struct wpabuf *buf, struct nan_de *de,
 		wpabuf_put_buf(buf, srv->srf);
 	}
 
+	if (ctrl & NAN_SRV_CTRL_SRV_INFO) {
+		wpabuf_put_u8(buf, wpabuf_len(ssi));
+		wpabuf_put_buf(buf, ssi);
+	}
+
 	/* Service Descriptor Extension attribute */
 	if (srv->type == NAN_DE_PUBLISH) {
 		if (srv->gtk_required)
diff --git a/tests/hwsim/test_nan.py b/tests/hwsim/test_nan.py
index f58dc906c..5a61beb38 100644
--- a/tests/hwsim/test_nan.py
+++ b/tests/hwsim/test_nan.py
@@ -4,6 +4,7 @@
 # This software may be distributed under the terms of the BSD license.
 # See README for more details.
 
+import os
 from wpasupplicant import WpaSupplicant
 import logging
 logger = logging.getLogger()
@@ -13,6 +14,7 @@ import hwsim_utils
 from hwsim import HWSimRadio, HWSimController
 from contextlib import contextmanager, ExitStack
 from test_p2p_channel import set_country
+from tshark import run_tshark
 import time
 
 @contextmanager
@@ -583,6 +585,27 @@ def test_nan_sync_passive_subscribe(dev, apdev, params):
                            sssi="ddbbccaa001122334455667788",
                            active=0)
 
+def test_nan_sync_ssi_in_sda(dev, apdev, params):
+    """NAN synchronized discovery with SSI in SDA and SDEA Service Info"""
+    with hwsim_nan_radios(count=2) as [wpas1, wpas2], \
+        NanDevice(wpas1, "nan0") as pub, NanDevice(wpas2, "nan1") as sub:
+        nan_sync_discovery(pub, sub, "test_service",
+                           pssi="aabbccdd", sssi="ddbbccaa",
+                           unsolicited=0)
+
+    capfile = os.path.join(params['logdir'], "hwsim0.pcapng")
+    sda = run_tshark(capfile, "wifi_nan.sda.service_info",
+                     ["wifi_nan.sda.service_info"])
+    sda = sda.replace(':', '').replace('-', '').split()
+    sdea = run_tshark(capfile, "wifi_nan.sdea.service_info_specific",
+                      ["wifi_nan.sdea.service_info_specific"])
+    sdea = sdea.replace(':', '').replace('-', '').split()
+    for ssi in ["aabbccdd", "ddbbccaa"]:
+        if ssi not in sda:
+            raise Exception("SSI %s not seen in SDA Service Info" % ssi)
+        if ssi not in sdea:
+            raise Exception("SSI %s not seen in SDEA Service Info" % ssi)
+
 def test_nan_sync_active_subscribe_no_match(dev, apdev, params):
     """NAN synchronized active subscribe and with 2 Publishes: no match"""
     with hwsim_nan_radios(count=3) as [wpas1, wpas2, wpas3], \
-- 
2.56.0.542.g3ef89b7020-goog




More information about the Hostap mailing list