From ad12f2f42232f4617815747dfc616c240f4540a8 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 15 May 2014 21:09:48 +0300 Subject: [PATCH] Add DRIVER_EVENT ctrl_iface command for testing purposes This new command can be used to simulate driver events without having to go through the driver wrapper or kernel code for this. This enables more testing coverage with hwsim. Signed-off-by: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 9970597f7..b2936c59a 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -6085,6 +6085,39 @@ static void wpas_ctrl_iface_mgmt_tx_done(struct wpa_supplicant *wpa_s) offchannel_send_action_done(wpa_s); } + +static int wpas_ctrl_iface_driver_event(struct wpa_supplicant *wpa_s, char *cmd) +{ + char *pos, *param; + union wpa_event_data event; + enum wpa_event_type ev; + + /* [parameters..] */ + + wpa_dbg(wpa_s, MSG_DEBUG, "Testing - external driver event: %s", cmd); + + pos = cmd; + param = os_strchr(pos, ' '); + if (param) + *param++ = '\0'; + + os_memset(&event, 0, sizeof(event)); + + if (os_strcmp(cmd, "INTERFACE_ENABLED") == 0) { + ev = EVENT_INTERFACE_ENABLED; + } else if (os_strcmp(cmd, "INTERFACE_DISABLED") == 0) { + ev = EVENT_INTERFACE_DISABLED; + } else { + wpa_dbg(wpa_s, MSG_DEBUG, "Testing - unknown driver event: %s", + cmd); + return -1; + } + + wpa_supplicant_event(wpa_s, ev, &event); + + return 0; +} + #endif /* CONFIG_TESTING_OPTIONS */ @@ -6649,6 +6682,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, reply_len = -1; } else if (os_strcmp(buf, "MGMT_TX_DONE") == 0) { wpas_ctrl_iface_mgmt_tx_done(wpa_s); + } else if (os_strncmp(buf, "DRIVER_EVENT ", 13) == 0) { + if (wpas_ctrl_iface_driver_event(wpa_s, buf + 13) < 0) + reply_len = -1; #endif /* CONFIG_TESTING_OPTIONS */ } else { os_memcpy(reply, "UNKNOWN COMMAND\n", 16);