BSS: Use wrapper function for getting a pointer to the IE buffer

This makes it easier to change the internal struct wpa_bss design for
storing the variable length IE buffers.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2020-11-16 16:21:56 +02:00 committed by Jouni Malinen
parent 95edd81441
commit be7ee264f6
8 changed files with 35 additions and 30 deletions

View File

@ -361,8 +361,7 @@ static bool is_p2p_pending_bss(struct wpa_supplicant *wpa_s,
ETH_ALEN) == 0)
return true;
if (!is_zero_ether_addr(wpa_s->pending_join_dev_addr) &&
p2p_parse_dev_addr((const u8 *) (bss + 1), bss->ie_len,
addr) == 0 &&
p2p_parse_dev_addr(wpa_bss_ie_ptr(bss), bss->ie_len, addr) == 0 &&
os_memcmp(addr, wpa_s->pending_join_dev_addr, ETH_ALEN) == 0)
return true;
#endif /* CONFIG_P2P */
@ -568,7 +567,7 @@ static u32 wpa_bss_compare_res(const struct wpa_bss *old,
changes |= WPA_BSS_MODE_CHANGED_FLAG;
if (old->ie_len == new_res->ie_len &&
os_memcmp(old + 1, new_res + 1, old->ie_len) == 0)
os_memcmp(wpa_bss_ie_ptr(old), new_res + 1, old->ie_len) == 0)
return changes;
changes |= WPA_BSS_IES_CHANGED_FLAG;
@ -1075,7 +1074,7 @@ struct wpa_bss * wpa_bss_get_p2p_dev_addr(struct wpa_supplicant *wpa_s,
struct wpa_bss *bss, *found = NULL;
dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) {
u8 addr[ETH_ALEN];
if (p2p_parse_dev_addr((const u8 *) (bss + 1), bss->ie_len,
if (p2p_parse_dev_addr(wpa_bss_ie_ptr(bss), bss->ie_len,
addr) != 0 ||
os_memcmp(addr, dev_addr, ETH_ALEN) != 0)
continue;
@ -1139,7 +1138,7 @@ struct wpa_bss * wpa_bss_get_id_range(struct wpa_supplicant *wpa_s,
*/
const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie)
{
return get_ie((const u8 *) (bss + 1), bss->ie_len, ie);
return get_ie(wpa_bss_ie_ptr(bss), bss->ie_len, ie);
}
@ -1154,7 +1153,7 @@ const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie)
*/
const u8 * wpa_bss_get_ie_ext(const struct wpa_bss *bss, u8 ext)
{
return get_ie_ext((const u8 *) (bss + 1), bss->ie_len, ext);
return get_ie_ext(wpa_bss_ie_ptr(bss), bss->ie_len, ext);
}
@ -1172,7 +1171,7 @@ const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type)
const u8 *ies;
const struct element *elem;
ies = (const u8 *) (bss + 1);
ies = wpa_bss_ie_ptr(bss);
for_each_element_id(elem, WLAN_EID_VENDOR_SPECIFIC, ies, bss->ie_len) {
if (elem->datalen >= 4 &&
@ -1205,7 +1204,7 @@ const u8 * wpa_bss_get_vendor_ie_beacon(const struct wpa_bss *bss,
if (bss->beacon_ie_len == 0)
return NULL;
ies = (const u8 *) (bss + 1);
ies = wpa_bss_ie_ptr(bss);
ies += bss->ie_len;
for_each_element_id(elem, WLAN_EID_VENDOR_SPECIFIC, ies,
@ -1239,7 +1238,7 @@ struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
if (buf == NULL)
return NULL;
pos = (const u8 *) (bss + 1);
pos = wpa_bss_ie_ptr(bss);
end = pos + bss->ie_len;
while (end - pos > 1) {
@ -1288,7 +1287,7 @@ struct wpabuf * wpa_bss_get_vendor_ie_multi_beacon(const struct wpa_bss *bss,
if (buf == NULL)
return NULL;
pos = (const u8 *) (bss + 1);
pos = wpa_bss_ie_ptr(bss);
pos += bss->ie_len;
end = pos + bss->beacon_ie_len;

View File

@ -113,6 +113,11 @@ struct wpa_bss {
/* followed by beacon_ie_len octets of IEs */
};
static inline const u8 * wpa_bss_ie_ptr(const struct wpa_bss *bss)
{
return (const u8 *) (bss + 1);
}
void wpa_bss_update_start(struct wpa_supplicant *wpa_s);
void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
struct wpa_scan_res *res,

View File

@ -5022,7 +5022,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
return 0;
pos += ret;
ie = (const u8 *) (bss + 1);
ie = wpa_bss_ie_ptr(bss);
for (i = 0; i < bss->ie_len; i++) {
ret = os_snprintf(pos, end - pos, "%02x", *ie++);
if (os_snprintf_error(end - pos, ret))
@ -5189,7 +5189,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
#ifdef CONFIG_WPS
if (mask & WPA_BSS_MASK_WPS_SCAN) {
ie = (const u8 *) (bss + 1);
ie = wpa_bss_ie_ptr(bss);
ret = wpas_wps_scan_result_text(ie, bss->ie_len, pos, end);
if (ret >= end - pos)
return 0;
@ -5200,7 +5200,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
#ifdef CONFIG_P2P
if (mask & WPA_BSS_MASK_P2P_SCAN) {
ie = (const u8 *) (bss + 1);
ie = wpa_bss_ie_ptr(bss);
ret = wpas_p2p_scan_result_text(ie, bss->ie_len, pos, end);
if (ret >= end - pos)
return 0;
@ -5212,7 +5212,8 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
#ifdef CONFIG_WIFI_DISPLAY
if (mask & WPA_BSS_MASK_WIFI_DISPLAY) {
struct wpabuf *wfd;
ie = (const u8 *) (bss + 1);
ie = wpa_bss_ie_ptr(bss);
wfd = ieee802_11_vendor_ie_concat(ie, bss->ie_len,
WFD_IE_VENDOR_TYPE);
if (wfd) {
@ -5290,7 +5291,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
#ifdef CONFIG_MESH
if (mask & WPA_BSS_MASK_MESH_SCAN) {
ie = (const u8 *) (bss + 1);
ie = wpa_bss_ie_ptr(bss);
ret = wpas_mesh_scan_result_text(ie, bss->ie_len, pos, end);
if (ret >= end - pos)
return 0;
@ -5337,7 +5338,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
return 0;
pos += ret;
ie = (const u8 *) (bss + 1);
ie = wpa_bss_ie_ptr(bss);
ie += bss->ie_len;
for (i = 0; i < bss->beacon_ie_len; i++) {
ret = os_snprintf(pos, end - pos, "%02x", *ie++);

View File

@ -1852,7 +1852,7 @@ wpas_get_est_throughput_from_bss_snr(const struct wpa_supplicant *wpa_s,
const struct wpa_bss *bss, int snr)
{
int rate = wpa_bss_get_max_rate(bss);
const u8 *ies = (const void *) (bss + 1);
const u8 *ies = wpa_bss_ie_ptr(bss);
size_t ie_len = bss->ie_len ? bss->ie_len : bss->beacon_ie_len;
return wpas_get_est_tpt(wpa_s, ies, ie_len, rate, snr);
@ -3029,7 +3029,7 @@ static void wpas_fst_update_mb_assoc(struct wpa_supplicant *wpa_s,
if (!bss)
return;
ieprb = (const u8 *) (bss + 1);
ieprb = wpa_bss_ie_ptr(bss);
iebcn = ieprb + bss->ie_len;
if (!wpas_fst_update_mbie(wpa_s, ieprb, bss->ie_len))

View File

@ -424,12 +424,13 @@ static int wpas_sta_secondary_channel_offset(struct wpa_bss *bss, u8 *current,
u8 *channel)
{
u8 *ies, phy_type;
const u8 *ies;
u8 phy_type;
size_t ies_len;
if (!bss)
return -1;
ies = (u8 *) (bss + 1);
ies = wpa_bss_ie_ptr(bss);
ies_len = bss->ie_len ? bss->ie_len : bss->beacon_ie_len;
return wpas_get_op_chan_phy(bss->freq, ies, ies_len, current,
channel, &phy_type);

View File

@ -1107,9 +1107,9 @@ static int wpas_p2p_persistent_group(struct wpa_supplicant *wpa_s,
"group is persistent - BSS " MACSTR
" did not include P2P IE", MAC2STR(bssid));
wpa_hexdump(MSG_DEBUG, "P2P: Probe Response IEs",
(u8 *) (bss + 1), bss->ie_len);
wpa_bss_ie_ptr(bss), bss->ie_len);
wpa_hexdump(MSG_DEBUG, "P2P: Beacon IEs",
((u8 *) bss + 1) + bss->ie_len,
wpa_bss_ie_ptr(bss) + bss->ie_len,
bss->beacon_ie_len);
return 0;
}
@ -5200,7 +5200,7 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
wpa_printf(MSG_DEBUG, "P2P: Target GO operating frequency "
"from BSS table: %d MHz (SSID %s)", freq,
wpa_ssid_txt(bss->ssid, bss->ssid_len));
if (p2p_parse_dev_addr((const u8 *) (bss + 1), bss->ie_len,
if (p2p_parse_dev_addr(wpa_bss_ie_ptr(bss), bss->ie_len,
dev_addr) == 0 &&
os_memcmp(wpa_s->pending_join_dev_addr,
wpa_s->pending_join_iface_addr, ETH_ALEN) == 0 &&

View File

@ -775,10 +775,10 @@ int wpas_get_op_chan_phy(int freq, const u8 *ies, size_t ies_len,
static int wpas_beacon_rep_add_frame_body(struct bitfield *eids,
enum beacon_report_detail detail,
struct wpa_bss *bss, u8 *buf,
size_t buf_len, u8 **ies_buf,
size_t buf_len, const u8 **ies_buf,
size_t *ie_len, int add_fixed)
{
u8 *ies = *ies_buf;
const u8 *ies = *ies_buf;
size_t ies_len = *ie_len;
u8 *pos = buf;
int rem_len;
@ -860,7 +860,7 @@ static int wpas_add_beacon_rep_elem(struct beacon_rep_data *data,
struct wpa_bss *bss,
struct wpabuf **wpa_buf,
struct rrm_measurement_beacon_report *rep,
u8 **ie, size_t *ie_len, u8 idx)
const u8 **ie, size_t *ie_len, u8 idx)
{
int ret;
u8 *buf, *pos;
@ -927,8 +927,8 @@ static int wpas_add_beacon_rep(struct wpa_supplicant *wpa_s,
u64 start, u64 parent_tsf)
{
struct beacon_rep_data *data = &wpa_s->beacon_rep_data;
u8 *ies = (u8 *) (bss + 1);
u8 *pos = ies;
const u8 *ies = wpa_bss_ie_ptr(bss);
const u8 *pos = ies;
size_t ies_len = bss->ie_len ? bss->ie_len : bss->beacon_ie_len;
struct rrm_measurement_beacon_report rep;
u8 idx = 0;

View File

@ -2276,8 +2276,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
#ifdef CONFIG_TDLS
if (bss)
wpa_tdls_ap_ies(wpa_s->wpa, (const u8 *) (bss + 1),
bss->ie_len);
wpa_tdls_ap_ies(wpa_s->wpa, wpa_bss_ie_ptr(bss), bss->ie_len);
#endif /* CONFIG_TDLS */
#ifdef CONFIG_MBO