blob: cc1088725c38be142ce4aac3cbec0b1b34898e1d [file] [log] [blame]
developerc41fcd32022-09-20 22:09:06 +08001From dc41ee6abddd05f25cba50126afe7890b890dfbc 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:49:09 +0800
developerc41fcd32022-09-20 22:09:06 +08004Subject: [PATCH 99902/99916] Support including neignbor report elements in BTM
developere2cc0fa2022-03-29 17:31:03 +08005 response
6
7---
8 src/ap/wnm_ap.c | 25 +++++++++++++++++++++++--
9 1 file changed, 23 insertions(+), 2 deletions(-)
10
11diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c
developerc41fcd32022-09-20 22:09:06 +080012index 3ea92af2d..532d9dbe6 100644
developere2cc0fa2022-03-29 17:31:03 +080013--- a/src/ap/wnm_ap.c
14+++ b/src/ap/wnm_ap.c
15@@ -20,6 +20,7 @@
16 #include "ap/wpa_auth.h"
17 #include "mbo_ap.h"
18 #include "wnm_ap.h"
19+#include "ap/neighbor_db.h"
20
21 #define MAX_TFS_IE_LEN 1024
22
23@@ -370,9 +371,21 @@ static int ieee802_11_send_bss_trans_mgmt_request(struct hostapd_data *hapd,
24 u8 *pos;
25 int res;
26
27- mgmt = os_zalloc(sizeof(*mgmt));
28- if (mgmt == NULL)
29+ int nr_num = hostapd_neighbor_count(hapd);
30+ int nr_size = ETH_ALEN + 4 + 1 + 1 + 1 + 5;
31+ int total_nr_size = nr_num * nr_size;
32+ u8 *nr_data = os_malloc(total_nr_size);
33+ int nr_data_len = 0;
34+ if(nr_data == NULL) {
35+ wpa_printf (MSG_ERROR, "Failed to allocate memory");
36+ } else {
37+ nr_data_len = hostapd_neighbor_insert_buffer(hapd, nr_data, total_nr_size);
38+ }
39+ mgmt = os_zalloc(sizeof(*mgmt) + nr_data_len);
40+ if (mgmt == NULL) {
41+ wpa_printf (MSG_ERROR, "Failed to allocate memory for mgmt frame");
42 return -1;
43+ }
44 os_memcpy(mgmt->da, addr, ETH_ALEN);
45 os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
46 os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
47@@ -382,10 +395,18 @@ static int ieee802_11_send_bss_trans_mgmt_request(struct hostapd_data *hapd,
48 mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ;
49 mgmt->u.action.u.bss_tm_req.dialog_token = dialog_token;
50 mgmt->u.action.u.bss_tm_req.req_mode = 0;
51+ if(nr_num) {
52+ mgmt->u.action.u.bss_tm_req.req_mode |= WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED;
53+ }
54 mgmt->u.action.u.bss_tm_req.disassoc_timer = host_to_le16(0);
55 mgmt->u.action.u.bss_tm_req.validity_interval = 1;
56 pos = mgmt->u.action.u.bss_tm_req.variable;
57
58+ if(nr_num) {
59+ os_memcpy(pos, nr_data, nr_data_len);
60+ pos += nr_data_len;
61+ }
62+
63 hapd->openwrt_stats.wnm.bss_transition_request_tx++;
64 wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Request to "
65 MACSTR " dialog_token=%u req_mode=0x%x disassoc_timer=%u "
66--
developerc41fcd32022-09-20 22:09:06 +0800672.25.1
developere2cc0fa2022-03-29 17:31:03 +080068