From 8b9d0bfa004cba666c5995e5fe0a42556765e073 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 16 Feb 2012 16:26:44 +0200 Subject: [PATCH] Add mechanism for disabling radio for testing purposes "wpa_cli set radio_disabled 1/0" can be used to disable/enable radio to simulate out-of-radio-range condition in a testbed device. Signed-hostap: Jouni Malinen --- src/drivers/driver.h | 12 ++++++++++++ wpa_supplicant/ctrl_iface.c | 6 ++++++ wpa_supplicant/driver_i.h | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 8db7a6783..04aedcf0e 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -2497,6 +2497,18 @@ struct wpa_driver_ops { */ void (*poll_client)(void *priv, const u8 *own_addr, const u8 *addr, int qos); + + /** + * radio_disable - Disable/enable radio + * @priv: Private driver interface data + * @disabled: 1=disable 0=enable radio + * Returns: 0 on success, -1 on failure + * + * This optional command is for testing purposes. It can be used to + * disable the radio on a testbed device to simulate out-of-radio-range + * conditions. + */ + int (*radio_disable)(void *priv, int disabled); }; diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 148992259..3602556b0 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -197,6 +197,12 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s, ret = pno_start(wpa_s); else ret = pno_stop(wpa_s); + } else if (os_strcasecmp(cmd, "radio_disabled") == 0) { + int disabled = atoi(value); + if (wpa_drv_radio_disable(wpa_s, disabled) < 0) + ret = -1; + else if (disabled) + wpa_supplicant_set_state(wpa_s, WPA_INACTIVE); } else { value[-1] = '='; ret = wpa_config_process_global(wpa_s->conf, cmd, -1); diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h index ebbe17dc4..5b1054052 100644 --- a/wpa_supplicant/driver_i.h +++ b/wpa_supplicant/driver_i.h @@ -657,4 +657,12 @@ static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s, wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kck, replay_ctr); } +static inline int wpa_drv_radio_disable(struct wpa_supplicant *wpa_s, + int disabled) +{ + if (!wpa_s->driver->radio_disable) + return -1; + return wpa_s->driver->radio_disable(wpa_s->drv_priv, disabled); +} + #endif /* DRIVER_I_H */