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 <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2012-02-16 16:26:44 +02:00 committed by Jouni Malinen
parent 56c2588aa8
commit 8b9d0bfa00
3 changed files with 26 additions and 0 deletions

View file

@ -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);
};

View file

@ -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);

View file

@ -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 */