Skip to content

Commit

Permalink
[nrf noup] zephyr: Improve error logging
Browse files Browse the repository at this point in the history
fixup! [nrf noup] zephyr: Redesign the events passing to wpa_supplicant from driver

Useful in debugging.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
  • Loading branch information
krish2718 committed Apr 12, 2024
1 parent 51873bb commit 2cc1381
Showing 1 changed file with 51 additions and 33 deletions.
84 changes: 51 additions & 33 deletions src/drivers/driver_zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *ies = os_zalloc(data->auth.ies_len);

if (!ies) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc ies\n", __func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, data->auth.ies_len);
return;
}

Expand All @@ -64,8 +66,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *frame = os_zalloc(data->rx_mgmt.frame_len);

if (!frame) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc frame\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, data->rx_mgmt.frame_len);
return;
}

Expand All @@ -80,8 +83,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *frame = os_zalloc(data->tx_status.data_len);

if (!frame) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc frame\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, data->tx_status.data_len);
return;
}

Expand All @@ -95,8 +99,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *addr = os_zalloc(ETH_ALEN);

if (!addr) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc addr\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, ETH_ALEN);
return;
}

Expand All @@ -107,8 +112,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *req_ies = os_zalloc(data->assoc_info.req_ies_len);

if (!req_ies) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc req_ies\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, data->assoc_info.req_ies_len);
return;
}

Expand All @@ -120,8 +126,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *resp_ies = os_zalloc(data->assoc_info.resp_ies_len);

if (!resp_ies) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc resp_ies\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, data->assoc_info.resp_ies_len);
return;
}

Expand All @@ -133,8 +140,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *resp_frame = os_zalloc(data->assoc_info.resp_frame_len);

if (!resp_frame) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc resp_frame\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, data->assoc_info.resp_frame_len);
return;
}

Expand All @@ -147,8 +155,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *bssid = os_zalloc(ETH_ALEN);

if (!bssid) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc bssid\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, ETH_ALEN);
return;
}

Expand All @@ -159,8 +168,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *resp_ies = os_zalloc(data->assoc_reject.resp_ies_len);

if (!resp_ies) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc resp_ies\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, data->assoc_reject.resp_ies_len);
return;
}

Expand All @@ -173,8 +183,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *sa = os_zalloc(ETH_ALEN);

if (!sa) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc SA\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, ETH_ALEN);
return;
}

Expand All @@ -184,8 +195,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *ie = os_zalloc(data->deauth_info.ie_len);

if (!ie) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc ie\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, data->deauth_info.ie_len);
return;
}

Expand All @@ -197,8 +209,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *sa = os_zalloc(ETH_ALEN);

if (!sa) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc SA\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, ETH_ALEN);
return;
}

Expand All @@ -208,8 +221,9 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *ie = os_zalloc(data->disassoc_info.ie_len);

if (!ie) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc ie\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, data->disassoc_info.ie_len);
return;
}

Expand All @@ -222,14 +236,16 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *da = os_zalloc(ETH_ALEN);

if (!sa) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc sa\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, ETH_ALEN);
return;
}

if (!da) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc da\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, ETH_ALEN);
return;
}
os_memcpy(sa, data->unprot_deauth.sa, ETH_ALEN);
Expand All @@ -242,14 +258,16 @@ void wpa_supplicant_event_wrapper(void *ctx,
char *da = os_zalloc(ETH_ALEN);

if (!sa) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc sa\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, ETH_ALEN);
return;
}

if (!da) {
wpa_printf(MSG_ERROR, "%s: Failed to alloc da\n",
__func__);
wpa_printf(MSG_ERROR,
"%s:%d Failed to alloc %d bytes\n",
__func__, __LINE__, ETH_ALEN);
return;
}
os_memcpy(sa, data->unprot_disassoc.sa, ETH_ALEN);
Expand Down

0 comments on commit 2cc1381

Please sign in to comment.