#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"
}
+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)
{
}
+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;
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;
}
+static int cmd_version(int s, int argc, char *argv[])
+{
+ u8 resp[WLANTEST_CTRL_MAX_RESP_LEN];
+ u8 buf[4];
+ char *version;
+ size_t len;
+ int rlen, i;
+
+ WPA_PUT_BE32(buf, WLANTEST_CTRL_VERSION);
+ rlen = cmd_send_and_recv(s, buf, sizeof(buf), resp, sizeof(resp));
+ if (rlen < 0)
+ return -1;
+
+ version = (char *) attr_get(resp + 4, rlen - 4, WLANTEST_ATTR_VERSION,
+ &len);
+ if (version == NULL)
+ return -1;
+
+ for (i = 0; i < len; i++)
+ putchar(version[i]);
+ printf("\n");
+
+ return 0;
+}
+
+
struct wlantest_cli_cmd {
const char *cmd;
int (*handler)(int s, int argc, char *argv[]);
"<counter> <BSSID> = get BSS counter value" },
{ "inject", cmd_inject,
"<frame> <prot> <sender> <BSSID> <STA/ff:ff:ff:ff:ff:ff>" },
+ { "version", cmd_version, "= get wlantest version" },
{ NULL, NULL, NULL }
};
WLANTEST_CTRL_GET_STA_COUNTER,
WLANTEST_CTRL_GET_BSS_COUNTER,
WLANTEST_CTRL_INJECT,
+ WLANTEST_CTRL_VERSION,
};
enum wlantest_ctrl_attr {
WLANTEST_ATTR_INJECT_FRAME,
WLANTEST_ATTR_INJECT_SENDER_AP,
WLANTEST_ATTR_INJECT_PROTECTION,
+ WLANTEST_ATTR_VERSION,
};
enum wlantest_bss_counter {