mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
wpa_supplicant: Add some miscellaneous fixes
1. Complilation correction when supplicant's debug are enabled 2. Scan optimization/correction in BTM request 3. BSS Transition reason code in case of BTM disconnect
This commit is contained in:
parent
267fcd97ea
commit
a9f1cf070a
@ -73,6 +73,7 @@ typedef enum {
|
||||
WIFI_REASON_ASSOC_NOT_AUTHED = 9,
|
||||
WIFI_REASON_DISASSOC_PWRCAP_BAD = 10,
|
||||
WIFI_REASON_DISASSOC_SUPCHAN_BAD = 11,
|
||||
WIFI_REASON_BSS_TRANSITION_DISASSOC = 12,
|
||||
WIFI_REASON_IE_INVALID = 13,
|
||||
WIFI_REASON_MIC_FAILURE = 14,
|
||||
WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
|
||||
|
@ -62,7 +62,6 @@ void wpa_debug_print_timestamp(void);
|
||||
*/
|
||||
#define wpa_printf(level,fmt, args...) ESP_LOG_LEVEL_LOCAL(level, TAG, fmt, ##args)
|
||||
#define wpa_dbg(ctx, level, fmt, args...) wpa_printf(level, fmt, ##args)
|
||||
static inline void wpa_msg(void *ctx, int level, const char *fmt, ...) { }
|
||||
|
||||
void wpa_dump_mem(char* desc, uint8_t *addr, uint16_t len);
|
||||
static inline void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, size_t len)
|
||||
@ -176,7 +175,7 @@ void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
|
||||
*
|
||||
* Note: New line '\n' is added to the end of the text when printing to stdout.
|
||||
*/
|
||||
void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4);
|
||||
static inline void wpa_msg(void *ctx, int level, const char *fmt, ...) { }
|
||||
|
||||
/**
|
||||
* wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
|
||||
|
@ -38,6 +38,10 @@ void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec)
|
||||
return;
|
||||
}
|
||||
params = os_zalloc(sizeof(*params));
|
||||
if (!params) {
|
||||
wpa_printf(MSG_ERROR, "Memory allocation failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (wpa_s->wnm_mode) {
|
||||
/* Use the same memory */
|
||||
|
@ -470,15 +470,15 @@ static void wnm_send_bss_transition_mgmt_resp(
|
||||
struct wpabuf *buf;
|
||||
int res;
|
||||
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"WNM: Send BSS Transition Management Response to " MACSTR
|
||||
" dialog_token=%u status=%u reason=%u delay=%d",
|
||||
MAC2STR(wpa_s->current_bss->bssid), dialog_token, status, reason, delay);
|
||||
if (!wpa_s->current_bss) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"WNM: Current BSS not known - drop response");
|
||||
return;
|
||||
}
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"WNM: Send BSS Transition Management Response to " MACSTR
|
||||
" dialog_token=%u status=%u reason=%u delay=%d",
|
||||
MAC2STR(wpa_s->current_bss->bssid), dialog_token, status, reason, delay);
|
||||
|
||||
buf = wpabuf_alloc(BTM_RESP_MIN_SIZE);
|
||||
if (!buf) {
|
||||
@ -653,7 +653,7 @@ static void wnm_dump_cand_list(struct wpa_supplicant *wpa_s)
|
||||
static void wnm_set_scan_freqs(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
unsigned int i;
|
||||
int num_chan;
|
||||
int num_chan = 0;
|
||||
u8 chan = 0;
|
||||
|
||||
wpa_s->next_scan_chan = 0;
|
||||
@ -671,8 +671,10 @@ static void wnm_set_scan_freqs(struct wpa_supplicant *wpa_s)
|
||||
MAC2STR(nei->bssid));
|
||||
return;
|
||||
}
|
||||
if (nei->channel_number != chan)
|
||||
if (nei->channel_number != chan) {
|
||||
chan = nei->channel_number;
|
||||
num_chan++;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_chan == 1) {
|
||||
@ -692,6 +694,9 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
|
||||
{
|
||||
unsigned int beacon_int;
|
||||
u8 valid_int;
|
||||
#ifdef ESP_SUPPLICANT
|
||||
bool scan_required = false;
|
||||
#endif
|
||||
|
||||
if (wpa_s->disable_btm)
|
||||
return;
|
||||
@ -757,9 +762,11 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
|
||||
#ifdef ESP_SUPPLICANT
|
||||
os_memset(wpa_s->next_scan_bssid, 0, ETH_ALEN);
|
||||
wpa_s->next_scan_chan = 0;
|
||||
#endif
|
||||
scan_required = true;
|
||||
#else
|
||||
wpa_printf(MSG_DEBUG, "Trying to find another BSS");
|
||||
wpa_supplicant_req_scan(wpa_s, 0, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -871,7 +878,14 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
|
||||
"WNM: Scan only for a specific BSSID since there is only a single candidate "
|
||||
MACSTR, MAC2STR(wpa_s->next_scan_bssid));
|
||||
}
|
||||
#ifdef ESP_SUPPLICANT
|
||||
scan_required = true;
|
||||
}
|
||||
if (scan_required) {
|
||||
wpa_printf(MSG_DEBUG, "Trying to find another BSS");
|
||||
#else
|
||||
wpa_supplicant_req_scan(wpa_s, 0, 0);
|
||||
#endif
|
||||
} else if (reply) {
|
||||
enum bss_trans_mgmt_status_code status;
|
||||
if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT)
|
||||
|
@ -306,7 +306,7 @@ void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
|
||||
/* We only support roaming in same ESS, therefore only bssid setting is needed */
|
||||
os_memcpy(config->sta.bssid, bss->bssid, ETH_ALEN);
|
||||
config->sta.bssid_set = 1;
|
||||
esp_wifi_internal_issue_disconnect(WIFI_REASON_ROAMING);
|
||||
esp_wifi_internal_issue_disconnect(WIFI_REASON_BSS_TRANSITION_DISASSOC);
|
||||
esp_wifi_set_config(WIFI_IF_STA, config);
|
||||
os_free(config);
|
||||
esp_wifi_connect();
|
||||
|
@ -881,7 +881,7 @@ static bool wpa_supplicant_gtk_in_use(struct wpa_sm *sm, struct wpa_gtk_data *gd
|
||||
if (wpa_sm_get_key(&ifx, &alg, bssid, &keyidx, gtk_get, gd->gtk_len, gd->keyidx - 2) == 0) {
|
||||
if (ifx == 0 && alg == gd->alg && memcmp(bssid, sm->bssid, ETH_ALEN) == 0 &&
|
||||
memcmp(_gtk, gtk_get, gd->gtk_len) == 0) {
|
||||
wpa_printf(MSG_DEBUG, "GTK %d is already in use in entry %d, it may be an attack, ignore it.", gd->keyidx, hw_keyidx);
|
||||
wpa_printf(MSG_DEBUG, "GTK %d is already in use, it may be an attack, ignore it.", gd->keyidx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -110,9 +110,5 @@ int eloop_register_timeout(unsigned int secs, unsigned int usecs,
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wpa_msg(void *ctx, int level, const char *fmt, ...)
|
||||
{
|
||||
}
|
||||
#endif // ESP_SUPPLICANT
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user