From: Jouni Malinen Date: Sun, 8 May 2022 13:59:31 +0000 (+0300) Subject: P2P: Maintain ip_pool bitfield index separately X-Git-Tag: hostap_2_11~1914 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77bb12a604866a42b8505c9d862b6d14bf46ac24;p=thirdparty%2Fhostap.git P2P: Maintain ip_pool bitfield index separately Avoid the somewhat confusing mechanism of determining the bitfield index from the assigned IP address to make this easier for static analyzers. Signed-off-by: Jouni Malinen --- diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c index f817c4a7e..0ad5de9d8 100644 --- a/src/ap/wpa_auth.c +++ b/src/ap/wpa_auth.c @@ -731,16 +731,13 @@ static void wpa_free_sta_sm(struct wpa_state_machine *sm) { #ifdef CONFIG_P2P if (WPA_GET_BE32(sm->ip_addr)) { - u32 start; wpa_printf(MSG_DEBUG, "P2P: Free assigned IP address %u.%u.%u.%u from " - MACSTR, + MACSTR " (bit %u)", sm->ip_addr[0], sm->ip_addr[1], sm->ip_addr[2], sm->ip_addr[3], - MAC2STR(sm->addr)); - start = WPA_GET_BE32(sm->wpa_auth->conf.ip_addr_start); - bitfield_clear(sm->wpa_auth->ip_pool, - WPA_GET_BE32(sm->ip_addr) - start); + MAC2STR(sm->addr), sm->ip_addr_bit); + bitfield_clear(sm->wpa_auth->ip_pool, sm->ip_addr_bit); } #endif /* CONFIG_P2P */ if (sm->GUpdateStationKeys) { @@ -3170,12 +3167,14 @@ SM_STATE(WPA_PTK, PTKCALCNEGOTIATING) if (idx >= 0) { u32 start = WPA_GET_BE32(wpa_auth->conf.ip_addr_start); bitfield_set(wpa_auth->ip_pool, idx); + sm->ip_addr_bit = idx; WPA_PUT_BE32(sm->ip_addr, start + idx); wpa_printf(MSG_DEBUG, "P2P: Assigned IP address %u.%u.%u.%u to " - MACSTR, sm->ip_addr[0], sm->ip_addr[1], + MACSTR " (bit %u)", + sm->ip_addr[0], sm->ip_addr[1], sm->ip_addr[2], sm->ip_addr[3], - MAC2STR(sm->addr)); + MAC2STR(sm->addr), sm->ip_addr_bit); } } #endif /* CONFIG_P2P */ diff --git a/src/ap/wpa_auth_i.h b/src/ap/wpa_auth_i.h index 17cb5a2e9..5bd699c25 100644 --- a/src/ap/wpa_auth_i.h +++ b/src/ap/wpa_auth_i.h @@ -152,6 +152,7 @@ struct wpa_state_machine { #ifdef CONFIG_P2P u8 ip_addr[4]; + unsigned int ip_addr_bit; #endif /* CONFIG_P2P */ #ifdef CONFIG_FILS