blob: d908adda73f02d9fff189abc42195e9a3ba70762 [file] [log] [blame]
developerc41fcd32022-09-20 22:09:06 +08001From 5773e6a27eb2d2028972fb0ab1206faf6a117d17 Mon Sep 17 00:00:00 2001
developere2cc0fa2022-03-29 17:31:03 +08002From: "howard.hsu" <howard-yh.hsu@mediatek.com>
3Date: Wed, 19 Jan 2022 19:25:05 +0800
developerc41fcd32022-09-20 22:09:06 +08004Subject: [PATCH 99901/99916] Support including neighbor report elements in
5 ANQP response
developere2cc0fa2022-03-29 17:31:03 +08006
7---
8 src/ap/gas_serv.c | 29 +++++++++++++++++++++++++++++
9 src/ap/gas_serv.h | 2 ++
10 2 files changed, 31 insertions(+)
11
12diff --git a/src/ap/gas_serv.c b/src/ap/gas_serv.c
developerc41fcd32022-09-20 22:09:06 +080013index 90f15778b..5845ff857 100644
developere2cc0fa2022-03-29 17:31:03 +080014--- a/src/ap/gas_serv.c
15+++ b/src/ap/gas_serv.c
16@@ -19,6 +19,7 @@
17 #include "dpp_hostapd.h"
18 #include "sta_info.h"
19 #include "gas_serv.h"
20+#include "neighbor_db.h"
21
22
23 #ifdef CONFIG_DPP
24@@ -369,6 +370,24 @@ static void anqp_add_network_auth_type(struct hostapd_data *hapd,
25 }
26 }
27
28+static void anqp_add_neighbor_report(struct hostapd_data *hapd,
29+ struct wpabuf *buf)
30+{
31+ struct hostapd_neighbor_entry *nr;
32+ u8 *len_pos = gas_anqp_add_element(buf, ANQP_NEIGHBOR_REPORT);
33+ if (dl_list_empty(&hapd->nr_db)) {
34+ wpabuf_put_le16(buf, 0);
35+ }
36+ else {
37+ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry, list ) {
38+ wpabuf_put_u8(buf, WLAN_EID_NEIGHBOR_REPORT);
39+ wpabuf_put_u8(buf, wpabuf_len(nr->nr));
40+ wpabuf_put_buf(buf, nr->nr);
41+ }
42+ }
43+ gas_anqp_set_element_len(buf, len_pos);
44+}
45+
46
47 static void anqp_add_roaming_consortium(struct hostapd_data *hapd,
48 struct wpabuf *buf)
49@@ -986,6 +1005,9 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
50 len += 1000;
51 if (request & ANQP_REQ_ICON_REQUEST)
52 len += 65536;
53+ if (request & ANQP_REQ_NEIGHBOR_REPORT) {
54+ len += (40 * hostapd_neighbor_count(hapd));
55+ }
56 #ifdef CONFIG_FILS
57 if (request & ANQP_FILS_REALM_INFO)
58 len += 2 * dl_list_len(&hapd->conf->fils_realms);
59@@ -1028,6 +1050,8 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
60 anqp_add_elem(hapd, buf, ANQP_TDLS_CAPABILITY);
61 if (request & ANQP_REQ_EMERGENCY_NAI)
62 anqp_add_elem(hapd, buf, ANQP_EMERGENCY_NAI);
63+ if (request & ANQP_REQ_NEIGHBOR_REPORT)
64+ anqp_add_neighbor_report(hapd, buf);
65
66 for (i = 0; i < num_extra_req; i++) {
67 #ifdef CONFIG_FILS
68@@ -1172,6 +1196,11 @@ static void rx_anqp_query_list_id(struct hostapd_data *hapd, u16 info_id,
69 "Emergency NAI",
70 get_anqp_elem(hapd, info_id) != NULL, qi);
71 break;
72+ case ANQP_NEIGHBOR_REPORT:
73+ set_anqp_req(ANQP_REQ_NEIGHBOR_REPORT,
74+ "Neighbor Report",
75+ get_anqp_elem(hapd, info_id) != NULL, qi);
76+ break;
77 default:
78 #ifdef CONFIG_FILS
79 if (info_id == ANQP_FILS_REALM_INFO &&
80diff --git a/src/ap/gas_serv.h b/src/ap/gas_serv.h
developerc41fcd32022-09-20 22:09:06 +080081index 1528af4af..d0241f23c 100644
developere2cc0fa2022-03-29 17:31:03 +080082--- a/src/ap/gas_serv.h
83+++ b/src/ap/gas_serv.h
84@@ -40,6 +40,8 @@
85 (1 << (ANQP_TDLS_CAPABILITY - ANQP_QUERY_LIST))
86 #define ANQP_REQ_EMERGENCY_NAI \
87 (1 << (ANQP_EMERGENCY_NAI - ANQP_QUERY_LIST))
88+#define ANQP_REQ_NEIGHBOR_REPORT \
89+ (1 << (ANQP_NEIGHBOR_REPORT - ANQP_QUERY_LIST))
90 /*
91 * First 15 Hotspot 2.0 vendor specific ANQP-elements can be included in the
92 * optimized bitmap.
93--
developerc41fcd32022-09-20 22:09:06 +0800942.25.1
developere2cc0fa2022-03-29 17:31:03 +080095