developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 1 | From adacd810f97a89472f26b454805cd67d0e6f5d31 Mon Sep 17 00:00:00 2001 |
| 2 | From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 3 | Date: Wed, 19 Jan 2022 19:25:05 +0800 |
| 4 | Subject: [PATCH 2/9] Support including neighbor report elements in ANQP |
| 5 | response |
| 6 | |
| 7 | --- |
| 8 | src/ap/gas_serv.c | 29 +++++++++++++++++++++++++++++ |
| 9 | src/ap/gas_serv.h | 2 ++ |
| 10 | 2 files changed, 31 insertions(+) |
| 11 | |
| 12 | diff --git a/src/ap/gas_serv.c b/src/ap/gas_serv.c |
| 13 | index 90f1577..5845ff8 100644 |
| 14 | --- 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 && |
| 80 | diff --git a/src/ap/gas_serv.h b/src/ap/gas_serv.h |
| 81 | index 1528af4..d0241f2 100644 |
| 82 | --- 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 | -- |
| 94 | 2.18.0 |
| 95 | |