[PATCH] Add extended 'driver' command
Dmitry Shmidt
dimitrysh
Thu Apr 7 16:53:50 PDT 2011
Signed-off-by: Dmitry Shmidt <dimitrysh at google.com>
---
src/drivers/driver.h | 11 +++++++++++
wpa_supplicant/ctrl_iface.c | 15 +++++++++++++++
wpa_supplicant/driver_i.h | 8 ++++++++
3 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 8e19da1..22d90ba 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -2240,6 +2240,17 @@ struct wpa_driver_ops {
* @signal_info: Connection info structure
*/
int (*signal_poll)(void *priv, struct wpa_signal_info *signal_info);
+
+ /**
+ * driver_cmd - execute driver-specific command
+ * @priv: private driver interface data
+ * @cmd: command to execute
+ * @buf: return buffer
+ * @buf_len: buffer length
+ *
+ * Returns: 0 on success, -1 on failure
+ */
+ int (*driver_cmd)(void *priv, char *cmd, char *buf, size_t buf_len);
};
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 5488ea4..d5a74eb 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -2859,6 +2859,18 @@ static int wpa_supplicant_ctrl_iface_sta_autoconnect(
}
+static int wpa_supplicant_driver_cmd(struct wpa_supplicant *wpa_s, char *cmd,
+ char *buf, size_t buflen)
+{
+ int ret;
+
+ ret = wpa_drv_driver_cmd(wpa_s, cmd, buf, buflen);
+ if (ret == 0)
+ ret = sprintf(buf, "%s\n", "OK");
+ return ret;
+}
+
+
char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
char *buf, size_t *resp_len)
{
@@ -3239,6 +3251,9 @@ char * wpa_supplicant_ctrl_iface_process(struct
wpa_supplicant *wpa_s,
if (wpa_supplicant_ctrl_iface_tdls_teardown(wpa_s, buf + 14))
reply_len = -1;
#endif /* CONFIG_TDLS */
+ } else if (os_strncmp(buf, "DRIVER ", 7) == 0) {
+ reply_len = wpa_supplicant_driver_cmd(wpa_s, buf + 7, reply,
+ reply_size);
} else {
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
reply_len = 16;
diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h
index 0d436dd..b0c5ef0 100644
--- a/wpa_supplicant/driver_i.h
+++ b/wpa_supplicant/driver_i.h
@@ -704,4 +704,12 @@ static inline int wpa_drv_tdls_oper(struct
wpa_supplicant *wpa_s,
return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
}
+static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
+ char *cmd, char *buf, size_t buf_len)
+{
+ if (!wpa_s->driver->driver_cmd)
+ return -1;
+ return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
+}
+
#endif /* DRIVER_I_H */
--
1.7.3.1
More information about the Hostap
mailing list