]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add mechanism for disabling radio for testing purposes
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 16 Feb 2012 14:26:44 +0000 (16:26 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 16 Feb 2012 14:26:44 +0000 (16:26 +0200)
"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>

src/drivers/driver.h
wpa_supplicant/ctrl_iface.c
wpa_supplicant/driver_i.h

index 8db7a6783a0cce67d139336131511499a34f5be6..04aedcf0e83491c00b23b9328f490b1b4ecce01a 100644 (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);
 };
 
 
index 1489922598e3d7f2d6f5a9b4fa0b050cdf6a0457..3602556b081086a8890eb93681c2ac935abf9e75 100644 (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);
index ebbe17dc43a0a20c0b578724f2304d52748651cb..5b1054052db7ec77ace460719faf447ea4601bbb 100644 (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 */