mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-12-01 11:48:23 -05:00
Add MGMT_TX_STATUS_PROCESS command for testing purposes
This allows ext_mgmt_frame_handling=1 cases with hostapd to process TX status events based on external processing. This is useful for increased test coverage of management frame processing. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
2a9c5217b1
commit
df94906201
@ -1509,6 +1509,67 @@ static int hostapd_ctrl_iface_mgmt_tx(struct hostapd_data *hapd, char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int hostapd_ctrl_iface_mgmt_tx_status_process(struct hostapd_data *hapd,
|
||||||
|
char *cmd)
|
||||||
|
{
|
||||||
|
char *pos, *param;
|
||||||
|
size_t len;
|
||||||
|
u8 *buf;
|
||||||
|
int stype = 0, ok = 0;
|
||||||
|
union wpa_event_data event;
|
||||||
|
|
||||||
|
if (!hapd->ext_mgmt_frame_handling)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* stype=<val> ok=<0/1> buf=<frame hexdump> */
|
||||||
|
|
||||||
|
wpa_printf(MSG_DEBUG, "External MGMT TX status process: %s", cmd);
|
||||||
|
|
||||||
|
pos = cmd;
|
||||||
|
param = os_strstr(pos, "stype=");
|
||||||
|
if (param) {
|
||||||
|
param += 6;
|
||||||
|
stype = atoi(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
param = os_strstr(pos, " ok=");
|
||||||
|
if (param) {
|
||||||
|
param += 4;
|
||||||
|
ok = atoi(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
param = os_strstr(pos, " buf=");
|
||||||
|
if (!param)
|
||||||
|
return -1;
|
||||||
|
param += 5;
|
||||||
|
|
||||||
|
len = os_strlen(param);
|
||||||
|
if (len & 1)
|
||||||
|
return -1;
|
||||||
|
len /= 2;
|
||||||
|
|
||||||
|
buf = os_malloc(len);
|
||||||
|
if (!buf || hexstr2bin(param, buf, len) < 0) {
|
||||||
|
os_free(buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_memset(&event, 0, sizeof(event));
|
||||||
|
event.tx_status.type = WLAN_FC_TYPE_MGMT;
|
||||||
|
event.tx_status.data = buf;
|
||||||
|
event.tx_status.data_len = len;
|
||||||
|
event.tx_status.stype = stype;
|
||||||
|
event.tx_status.ack = ok;
|
||||||
|
hapd->ext_mgmt_frame_handling = 0;
|
||||||
|
wpa_supplicant_event(hapd, EVENT_TX_STATUS, &event);
|
||||||
|
hapd->ext_mgmt_frame_handling = 1;
|
||||||
|
|
||||||
|
os_free(buf);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int hostapd_ctrl_iface_mgmt_rx_process(struct hostapd_data *hapd,
|
static int hostapd_ctrl_iface_mgmt_rx_process(struct hostapd_data *hapd,
|
||||||
char *cmd)
|
char *cmd)
|
||||||
{
|
{
|
||||||
@ -2574,6 +2635,10 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
|
|||||||
} else if (os_strncmp(buf, "MGMT_TX ", 8) == 0) {
|
} else if (os_strncmp(buf, "MGMT_TX ", 8) == 0) {
|
||||||
if (hostapd_ctrl_iface_mgmt_tx(hapd, buf + 8))
|
if (hostapd_ctrl_iface_mgmt_tx(hapd, buf + 8))
|
||||||
reply_len = -1;
|
reply_len = -1;
|
||||||
|
} else if (os_strncmp(buf, "MGMT_TX_STATUS_PROCESS ", 23) == 0) {
|
||||||
|
if (hostapd_ctrl_iface_mgmt_tx_status_process(hapd,
|
||||||
|
buf + 23) < 0)
|
||||||
|
reply_len = -1;
|
||||||
} else if (os_strncmp(buf, "MGMT_RX_PROCESS ", 16) == 0) {
|
} else if (os_strncmp(buf, "MGMT_RX_PROCESS ", 16) == 0) {
|
||||||
if (hostapd_ctrl_iface_mgmt_rx_process(hapd, buf + 16) < 0)
|
if (hostapd_ctrl_iface_mgmt_rx_process(hapd, buf + 16) < 0)
|
||||||
reply_len = -1;
|
reply_len = -1;
|
||||||
|
@ -4161,8 +4161,16 @@ void ieee802_11_mgmt_cb(struct hostapd_data *hapd, const u8 *buf, size_t len,
|
|||||||
|
|
||||||
#ifdef CONFIG_TESTING_OPTIONS
|
#ifdef CONFIG_TESTING_OPTIONS
|
||||||
if (hapd->ext_mgmt_frame_handling) {
|
if (hapd->ext_mgmt_frame_handling) {
|
||||||
wpa_msg(hapd->msg_ctx, MSG_INFO, "MGMT-TX-STATUS stype=%u ok=%d",
|
size_t hex_len = 2 * len + 1;
|
||||||
stype, ok);
|
char *hex = os_malloc(hex_len);
|
||||||
|
|
||||||
|
if (hex) {
|
||||||
|
wpa_snprintf_hex(hex, hex_len, buf, len);
|
||||||
|
wpa_msg(hapd->msg_ctx, MSG_INFO,
|
||||||
|
"MGMT-TX-STATUS stype=%u ok=%d buf=%s",
|
||||||
|
stype, ok, hex);
|
||||||
|
os_free(hex);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_TESTING_OPTIONS */
|
#endif /* CONFIG_TESTING_OPTIONS */
|
||||||
|
Loading…
Reference in New Issue
Block a user