aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/ctrl.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2010-11-19 15:45:19 (GMT)
committerJouni Malinen <j@w1.fi>2010-11-19 15:45:19 (GMT)
commita16c859034e41ed17a7f2ed4e61a84b7ea99bf42 (patch)
treece56d5961028c6329b759d47ed894c2994372dfb /wlantest/ctrl.c
parent990153b4dd482e016914cd8d1f54045f7e9d5530 (diff)
downloadhostap-a16c859034e41ed17a7f2ed4e61a84b7ea99bf42.zip
hostap-a16c859034e41ed17a7f2ed4e61a84b7ea99bf42.tar.gz
hostap-a16c859034e41ed17a7f2ed4e61a84b7ea99bf42.tar.bz2
wlantest: Add command for fetching wlantest version
Diffstat (limited to 'wlantest/ctrl.c')
-rw-r--r--wlantest/ctrl.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/wlantest/ctrl.c b/wlantest/ctrl.c
index 6cbac0a..e2cd283 100644
--- a/wlantest/ctrl.c
+++ b/wlantest/ctrl.c
@@ -17,6 +17,7 @@
#include "utils/common.h"
#include "utils/eloop.h"
+#include "common/version.h"
#include "common/ieee802_11_defs.h"
#include "wlantest.h"
#include "wlantest_ctrl.h"
@@ -73,6 +74,23 @@ static int attr_get_int(u8 *buf, size_t buflen, enum wlantest_ctrl_attr attr)
}
+static u8 * attr_add_str(u8 *pos, u8 *end, enum wlantest_ctrl_attr attr,
+ const char *str)
+{
+ size_t len = os_strlen(str);
+
+ if (pos == NULL || end - pos < 8 + len)
+ return NULL;
+ WPA_PUT_BE32(pos, attr);
+ pos += 4;
+ WPA_PUT_BE32(pos, len);
+ pos += 4;
+ os_memcpy(pos, str, len);
+ pos += len;
+ return pos;
+}
+
+
static u8 * attr_add_be32(u8 *pos, u8 *end, enum wlantest_ctrl_attr attr,
u32 val)
{
@@ -655,6 +673,19 @@ static void ctrl_inject(struct wlantest *wt, int sock, u8 *cmd, size_t clen)
}
+static void ctrl_version(struct wlantest *wt, int sock)
+{
+ u8 buf[WLANTEST_CTRL_MAX_RESP_LEN], *pos;
+
+ pos = buf;
+ WPA_PUT_BE32(pos, WLANTEST_CTRL_SUCCESS);
+ pos += 4;
+ pos = attr_add_str(pos, buf + sizeof(buf), WLANTEST_ATTR_VERSION,
+ VERSION_STR);
+ ctrl_send(wt, sock, buf, pos - buf);
+}
+
+
static void ctrl_read(int sock, void *eloop_ctx, void *sock_ctx)
{
struct wlantest *wt = eloop_ctx;
@@ -717,6 +748,9 @@ static void ctrl_read(int sock, void *eloop_ctx, void *sock_ctx)
case WLANTEST_CTRL_INJECT:
ctrl_inject(wt, sock, buf + 4, len - 4);
break;
+ case WLANTEST_CTRL_VERSION:
+ ctrl_version(wt, sock);
+ break;
default:
ctrl_send_simple(wt, sock, WLANTEST_CTRL_UNKNOWN_CMD);
break;