developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 1 | From 4a7b4a0fe05dd01ae64dd4e291d05de6d5f05bb7 Mon Sep 17 00:00:00 2001 |
| 2 | From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 3 | Date: Wed, 19 Jan 2022 19:49:09 +0800 |
| 4 | Subject: [PATCH 3/9] Support including neignbor report elements in BTM |
| 5 | response |
| 6 | |
| 7 | --- |
| 8 | src/ap/wnm_ap.c | 25 +++++++++++++++++++++++-- |
| 9 | 1 file changed, 23 insertions(+), 2 deletions(-) |
| 10 | |
| 11 | diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c |
| 12 | index 72cd126..b55b3f3 100644 |
| 13 | --- 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 | -- |
| 67 | 2.18.0 |
| 68 | |