mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 09:09:10 -04: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,
|
const u8 *data, size_t data_len,
|
||||||
int no_cck)
|
int no_cck)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = -1;
|
||||||
wifi_mgmt_frm_req_t *req = os_zalloc(sizeof(*req) + data_len);;
|
wifi_mgmt_frm_req_t *req;
|
||||||
if (!req)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!wpa_s->current_bss) {
|
if (!wpa_s->current_bss) {
|
||||||
wpa_printf(MSG_ERROR, "STA not associated, return");
|
return ret;
|
||||||
ret = -1;
|
}
|
||||||
goto cleanup;
|
|
||||||
|
req = os_zalloc(sizeof(*req) + data_len);
|
||||||
|
if (!req) {
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->ifx = WIFI_IF_STA;
|
req->ifx = WIFI_IF_STA;
|
||||||
@ -798,14 +799,14 @@ int wpa_drv_send_action(struct wpa_supplicant *wpa_s,
|
|||||||
req->data_len = data_len;
|
req->data_len = data_len;
|
||||||
os_memcpy(req->data, data, req->data_len);
|
os_memcpy(req->data, data, req->data_len);
|
||||||
|
|
||||||
if (esp_wifi_send_mgmt_frm_internal(req) != 0) {
|
ret = esp_wifi_send_mgmt_frm_internal(req);
|
||||||
wpa_printf(MSG_ERROR, "action frame sending failed");
|
|
||||||
ret = -1;
|
if (ret != 0) {
|
||||||
goto cleanup;
|
wpa_printf(MSG_ERROR, "action frame sending failed");
|
||||||
}
|
} else {
|
||||||
wpa_printf(MSG_INFO, "action frame sent");
|
wpa_printf(MSG_INFO, "action frame sent");
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
os_free(req);
|
os_free(req);
|
||||||
return ret;
|
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));
|
reply = os_zalloc(sizeof(wifi_mgmt_frm_req_t) + sizeof(uint16_t));
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
wpa_printf(MSG_ERROR, "failed to allocate memory for assoc response");
|
wpa_printf(MSG_ERROR, "failed to allocate memory for assoc response");
|
||||||
res = WLAN_STATUS_UNSPECIFIED_FAILURE;
|
return WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||||
goto done;
|
|
||||||
}
|
}
|
||||||
reply->ifx = WIFI_IF_AP;
|
reply->ifx = WIFI_IF_AP;
|
||||||
reply->subtype = subtype;
|
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");
|
wpa_printf(MSG_INFO, "esp_send_assoc_resp_failed: send failed");
|
||||||
}
|
}
|
||||||
#undef ASSOC_RESP_LENGTH
|
#undef ASSOC_RESP_LENGTH
|
||||||
done:
|
|
||||||
os_free(reply);
|
os_free(reply);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -667,35 +667,39 @@ int esp_send_sae_auth_reply(struct hostapd_data *hapd,
|
|||||||
u16 auth_alg, u16 auth_transaction, u16 resp,
|
u16 auth_alg, u16 auth_transaction, u16 resp,
|
||||||
const u8 *ies, size_t ies_len)
|
const u8 *ies, size_t ies_len)
|
||||||
{
|
{
|
||||||
int reply_res = ESP_FAIL;
|
int status = ESP_FAIL;
|
||||||
ies_len += 3 * sizeof(uint16_t);
|
/* 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) {
|
if (!req) {
|
||||||
wpa_printf(MSG_ERROR, "failed to send sae auth reply");
|
wpa_printf(MSG_ERROR, "Failed to allocate SAE authentication reply");
|
||||||
return reply_res;
|
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) {
|
/* Populate the frame data */
|
||||||
os_memcpy(&((uint16_t *)req->data)[3], ies, ies_len - 3 * sizeof(uint16_t));
|
((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->ifx = WIFI_IF_AP;
|
||||||
req->subtype = (WLAN_FC_STYPE_AUTH << 4);
|
req->subtype = (WLAN_FC_STYPE_AUTH << 4);
|
||||||
req->data_len = ies_len;
|
req->data_len = data_len;
|
||||||
os_memcpy(req->da, bssid, ETH_ALEN);
|
os_memcpy(req->da, bssid, ETH_ALEN);
|
||||||
|
|
||||||
if (esp_wifi_send_mgmt_frm_internal(req) != 0) {
|
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 {
|
} else {
|
||||||
reply_res = ESP_OK;
|
status = ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
os_free(req);
|
os_free(req);
|
||||||
return reply_res;
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esp_wifi_register_wpa3_ap_cb(struct wpa_funcs *wpa_cb)
|
void esp_wifi_register_wpa3_ap_cb(struct wpa_funcs *wpa_cb)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user