aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/wnm_sta.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2014-11-22 13:37:27 (GMT)
committerJouni Malinen <j@w1.fi>2014-11-22 16:06:37 (GMT)
commit093226783dc78a7c80af516f2fe76909bda8b400 (patch)
tree5c2fef37d18d3fa2e8d8a7967846c9a144240338 /wpa_supplicant/wnm_sta.c
parent8c9af762f30d0a52d7397716b735a4f81b279dda (diff)
downloadhostap-093226783dc78a7c80af516f2fe76909bda8b400.zip
hostap-093226783dc78a7c80af516f2fe76909bda8b400.tar.gz
hostap-093226783dc78a7c80af516f2fe76909bda8b400.tar.bz2
WNM: Simplify how candidate subelements are stored
There is no need to use a separately allocated data structures for this. A bitfield indicating which information is present and variables within struct neighbor_report are simpler to use and more efficient. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/wnm_sta.c')
-rw-r--r--wpa_supplicant/wnm_sta.c65
1 files changed, 17 insertions, 48 deletions
diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c
index aa22223..8dea07a 100644
--- a/wpa_supplicant/wnm_sta.c
+++ b/wpa_supplicant/wnm_sta.c
@@ -309,13 +309,7 @@ void wnm_deallocate_memory(struct wpa_supplicant *wpa_s)
int i;
for (i = 0; i < wpa_s->wnm_num_neighbor_report; i++) {
- os_free(wpa_s->wnm_neighbor_report_elements[i].tsf_info);
- os_free(wpa_s->wnm_neighbor_report_elements[i].con_coun_str);
- os_free(wpa_s->wnm_neighbor_report_elements[i].bss_tran_can);
- os_free(wpa_s->wnm_neighbor_report_elements[i].bss_term_dur);
- os_free(wpa_s->wnm_neighbor_report_elements[i].bearing);
os_free(wpa_s->wnm_neighbor_report_elements[i].meas_pilot);
- os_free(wpa_s->wnm_neighbor_report_elements[i].rrm_cap);
os_free(wpa_s->wnm_neighbor_report_elements[i].mul_bssid);
}
@@ -334,12 +328,9 @@ static void wnm_parse_neighbor_report_elem(struct neighbor_report *rep,
wpa_printf(MSG_DEBUG, "WNM: Too short TSF");
break;
}
- os_free(rep->tsf_info);
- rep->tsf_info = os_zalloc(sizeof(struct tsf_info));
- if (rep->tsf_info == NULL)
- break;
- os_memcpy(rep->tsf_info->tsf_offset, pos, 2);
- os_memcpy(rep->tsf_info->beacon_interval, pos + 2, 2);
+ rep->tsf_offset = WPA_GET_LE16(pos);
+ rep->beacon_int = WPA_GET_LE16(pos + 2);
+ rep->tsf_present = 1;
break;
case WNM_NEIGHBOR_CONDENSED_COUNTRY_STRING:
if (elen < 2) {
@@ -347,12 +338,8 @@ static void wnm_parse_neighbor_report_elem(struct neighbor_report *rep,
"country string");
break;
}
- os_free(rep->con_coun_str);
- rep->con_coun_str =
- os_zalloc(sizeof(struct condensed_country_string));
- if (rep->con_coun_str == NULL)
- break;
- os_memcpy(rep->con_coun_str->country_string, pos, 2);
+ os_memcpy(rep->country, pos, 2);
+ rep->country_present = 1;
break;
case WNM_NEIGHBOR_BSS_TRANSITION_CANDIDATE:
if (elen < 1) {
@@ -360,25 +347,13 @@ static void wnm_parse_neighbor_report_elem(struct neighbor_report *rep,
"candidate");
break;
}
- os_free(rep->bss_tran_can);
- rep->bss_tran_can =
- os_zalloc(sizeof(struct bss_transition_candidate));
- if (rep->bss_tran_can == NULL)
- break;
- rep->bss_tran_can->preference = pos[0];
+ rep->preference = pos[0];
+ rep->preference_present = 1;
break;
case WNM_NEIGHBOR_BSS_TERMINATION_DURATION:
- if (elen < 10) {
- wpa_printf(MSG_DEBUG, "WNM: Too short BSS termination "
- "duration");
- break;
- }
- os_free(rep->bss_term_dur);
- rep->bss_term_dur =
- os_zalloc(sizeof(struct bss_termination_duration));
- if (rep->bss_term_dur == NULL)
- break;
- os_memcpy(rep->bss_term_dur->duration, pos, 10);
+ rep->bss_term_tsf = WPA_GET_LE64(pos);
+ rep->bss_term_dur = WPA_GET_LE16(pos + 8);
+ rep->bss_term_present = 1;
break;
case WNM_NEIGHBOR_BEARING:
if (elen < 8) {
@@ -386,11 +361,10 @@ static void wnm_parse_neighbor_report_elem(struct neighbor_report *rep,
"bearing");
break;
}
- os_free(rep->bearing);
- rep->bearing = os_zalloc(sizeof(struct bearing));
- if (rep->bearing == NULL)
- break;
- os_memcpy(rep->bearing->bearing, pos, 8);
+ rep->bearing = WPA_GET_LE16(pos);
+ rep->distance = WPA_GET_LE32(pos + 2);
+ rep->rel_height = WPA_GET_LE16(pos + 2 + 4);
+ rep->bearing_present = 1;
break;
case WNM_NEIGHBOR_MEASUREMENT_PILOT:
if (elen < 1) {
@@ -412,12 +386,8 @@ static void wnm_parse_neighbor_report_elem(struct neighbor_report *rep,
"capabilities");
break;
}
- os_free(rep->rrm_cap);
- rep->rrm_cap =
- os_zalloc(sizeof(struct rrm_enabled_capabilities));
- if (rep->rrm_cap == NULL)
- break;
- os_memcpy(rep->rrm_cap->capabilities, pos, 5);
+ os_memcpy(rep->rm_capab, pos, 5);
+ rep->rm_capab_present = 1;
break;
case WNM_NEIGHBOR_MULTIPLE_BSSID:
if (elen < 1) {
@@ -632,8 +602,7 @@ static void wnm_dump_cand_list(struct wpa_supplicant *wpa_s)
i, MAC2STR(nei->bssid), nei->bssid_info,
nei->regulatory_class,
nei->channel_number, nei->phy_type,
- nei->bss_tran_can ? nei->bss_tran_can->preference :
- -1);
+ nei->preference_present ? nei->preference : -1);
}
}