mirror of
https://github.com/espressif/esp-idf
synced 2025-03-08 15:49:08 -05:00
fix(esp_wifi): Add review comments and some cleanup
This commit is contained in:
parent
8652a5c552
commit
f5a114a42f
@ -782,15 +782,16 @@ int wpa_drv_send_action(struct wpa_supplicant *wpa_s,
|
||||
const u8 *data, size_t data_len,
|
||||
int no_cck)
|
||||
{
|
||||
int ret = 0;
|
||||
wifi_mgmt_frm_req_t *req = os_zalloc(sizeof(*req) + data_len);;
|
||||
if (!req)
|
||||
return -1;
|
||||
int ret = -1;
|
||||
wifi_mgmt_frm_req_t *req;
|
||||
|
||||
if (!wpa_s->current_bss) {
|
||||
wpa_printf(MSG_ERROR, "STA not associated, return");
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
return ret;
|
||||
}
|
||||
|
||||
req = os_zalloc(sizeof(*req) + data_len);
|
||||
if (!req) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
req->ifx = WIFI_IF_STA;
|
||||
@ -798,14 +799,14 @@ int wpa_drv_send_action(struct wpa_supplicant *wpa_s,
|
||||
req->data_len = data_len;
|
||||
os_memcpy(req->data, data, req->data_len);
|
||||
|
||||
if (esp_wifi_send_mgmt_frm_internal(req) != 0) {
|
||||
wpa_printf(MSG_ERROR, "action frame sending failed");
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
wpa_printf(MSG_INFO, "action frame sent");
|
||||
ret = esp_wifi_send_mgmt_frm_internal(req);
|
||||
|
||||
if (ret != 0) {
|
||||
wpa_printf(MSG_ERROR, "action frame sending failed");
|
||||
} else {
|
||||
wpa_printf(MSG_INFO, "action frame sent");
|
||||
}
|
||||
|
||||
cleanup:
|
||||
os_free(req);
|
||||
return ret;
|
||||
}
|
||||
|
@ -308,8 +308,7 @@ u16 esp_send_assoc_resp(struct hostapd_data *hapd, const u8 *addr,
|
||||
reply = os_zalloc(sizeof(wifi_mgmt_frm_req_t) + sizeof(uint16_t));
|
||||
if (!reply) {
|
||||
wpa_printf(MSG_ERROR, "failed to allocate memory for assoc response");
|
||||
res = WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
goto done;
|
||||
return WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
}
|
||||
reply->ifx = WIFI_IF_AP;
|
||||
reply->subtype = subtype;
|
||||
@ -322,7 +321,6 @@ u16 esp_send_assoc_resp(struct hostapd_data *hapd, const u8 *addr,
|
||||
wpa_printf(MSG_INFO, "esp_send_assoc_resp_failed: send failed");
|
||||
}
|
||||
#undef ASSOC_RESP_LENGTH
|
||||
done:
|
||||
os_free(reply);
|
||||
return res;
|
||||
}
|
||||
|
@ -667,35 +667,39 @@ int esp_send_sae_auth_reply(struct hostapd_data *hapd,
|
||||
u16 auth_alg, u16 auth_transaction, u16 resp,
|
||||
const u8 *ies, size_t ies_len)
|
||||
{
|
||||
int reply_res = ESP_FAIL;
|
||||
ies_len += 3 * sizeof(uint16_t);
|
||||
int status = ESP_FAIL;
|
||||
/* Calculate total frame data length (auth_alg + transaction + resp + IEs) */
|
||||
size_t data_len = ies_len + 3 * sizeof(uint16_t);
|
||||
|
||||
wifi_mgmt_frm_req_t *req = os_zalloc(sizeof(*req) + ies_len);
|
||||
wifi_mgmt_frm_req_t *req = os_zalloc(sizeof(*req) + data_len);
|
||||
if (!req) {
|
||||
wpa_printf(MSG_ERROR, "failed to send sae auth reply");
|
||||
return reply_res;
|
||||
wpa_printf(MSG_ERROR, "Failed to allocate SAE authentication reply");
|
||||
return status;
|
||||
}
|
||||
((uint16_t *)req->data)[0] = htole16(auth_alg);
|
||||
((uint16_t *)req->data)[1] = htole16(auth_transaction);
|
||||
((uint16_t *)req->data)[2] = htole16(resp);
|
||||
|
||||
if (ies_len) {
|
||||
os_memcpy(&((uint16_t *)req->data)[3], ies, ies_len - 3 * sizeof(uint16_t));
|
||||
/* Populate the frame data */
|
||||
((uint16_t *)req->data)[0] = htole16(auth_alg); /* Authentication algorithm */
|
||||
((uint16_t *)req->data)[1] = htole16(auth_transaction); /* Transaction number */
|
||||
((uint16_t *)req->data)[2] = htole16(resp); /* Response code */
|
||||
|
||||
if (ies && ies_len) {
|
||||
os_memcpy(&((uint16_t *)req->data)[3], ies, ies_len);
|
||||
}
|
||||
|
||||
req->ifx = WIFI_IF_AP;
|
||||
req->subtype = (WLAN_FC_STYPE_AUTH << 4);
|
||||
req->data_len = ies_len;
|
||||
req->data_len = data_len;
|
||||
os_memcpy(req->da, bssid, ETH_ALEN);
|
||||
|
||||
if (esp_wifi_send_mgmt_frm_internal(req) != 0) {
|
||||
wpa_printf(MSG_INFO, "%s: send failed", __func__);
|
||||
wpa_printf(MSG_INFO, "%s: SAE authentication reply send failed", __func__);
|
||||
} else {
|
||||
reply_res = ESP_OK;
|
||||
status = ESP_OK;
|
||||
}
|
||||
|
||||
os_free(req);
|
||||
return reply_res;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void esp_wifi_register_wpa3_ap_cb(struct wpa_funcs *wpa_cb)
|
||||
|
Loading…
x
Reference in New Issue
Block a user