aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/wlantest.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2010-11-06 14:20:45 (GMT)
committerJouni Malinen <j@w1.fi>2010-11-07 21:29:00 (GMT)
commita149fcc77d3322bf23d1f53c2cd9fc84a1097c31 (patch)
tree50869affc977d98c872265f0493fa28bb10cb0bb /wlantest/wlantest.c
parent6fc58a89e1dc41a315b15c8e067dc50f30dd741e (diff)
downloadhostap-a149fcc77d3322bf23d1f53c2cd9fc84a1097c31.zip
hostap-a149fcc77d3322bf23d1f53c2cd9fc84a1097c31.tar.gz
hostap-a149fcc77d3322bf23d1f53c2cd9fc84a1097c31.tar.bz2
wlantest: Add preliminary version of IEEE 802.11 protocol testing tool
This tool can be used to capture IEEE 802.11 frames either from a monitor interface for realtime capturing or from pcap files for offline analysis. This version is only adding basic infrastructure for going through the frames and parsing their headers.
Diffstat (limited to 'wlantest/wlantest.c')
-rw-r--r--wlantest/wlantest.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/wlantest/wlantest.c b/wlantest/wlantest.c
new file mode 100644
index 0000000..9a2f70d
--- /dev/null
+++ b/wlantest/wlantest.c
@@ -0,0 +1,108 @@
+/*
+ * wlantest - IEEE 802.11 protocol monitoring and testing tool
+ * Copyright (c) 2010, Jouni Malinen <j@w1.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#include "utils/includes.h"
+
+#include "utils/common.h"
+#include "utils/eloop.h"
+#include "wlantest.h"
+
+
+extern int wpa_debug_level;
+
+
+static void wlantest_terminate(int sig, void *signal_ctx)
+{
+ eloop_terminate();
+}
+
+
+static void usage(void)
+{
+ printf("wlantest [-ddhqq] [-i<ifname>] [-r<pcap file>]\n");
+}
+
+
+int main(int argc, char *argv[])
+{
+ int c;
+ const char *read_file = NULL;
+ const char *ifname = NULL;
+ struct wlantest wt;
+
+ wpa_debug_level = MSG_INFO;
+
+ if (os_program_init())
+ return -1;
+
+ os_memset(&wt, 0, sizeof(wt));
+ wt.monitor_sock = -1;
+
+ for (;;) {
+ c = getopt(argc, argv, "dhi:r:q");
+ if (c < 0)
+ break;
+ switch (c) {
+ case 'd':
+ if (wpa_debug_level > 0)
+ wpa_debug_level--;
+ break;
+ case 'h':
+ usage();
+ return 0;
+ case 'i':
+ ifname = optarg;
+ break;
+ case 'q':
+ wpa_debug_level++;
+ break;
+ case 'r':
+ read_file = optarg;
+ break;
+ default:
+ usage();
+ return -1;
+ }
+ }
+
+ if (ifname == NULL && read_file == NULL) {
+ usage();
+ return 0;
+ }
+
+ if (eloop_init())
+ return -1;
+
+ if (read_file && read_cap_file(&wt, read_file) < 0)
+ return -1;
+
+ if (ifname && monitor_init(&wt, ifname) < 0)
+ return -1;
+
+ eloop_register_signal_terminate(wlantest_terminate, &wt);
+
+ eloop_run();
+
+ wpa_printf(MSG_INFO, "Processed: rx_mgmt=%u rx_ctrl=%u rx_data=%u "
+ "fcs_error=%u",
+ wt.rx_mgmt, wt.rx_ctrl, wt.rx_data, wt.fcs_error);
+
+ if (ifname)
+ monitor_deinit(&wt);
+
+ eloop_destroy();
+ os_program_deinit();
+
+ return 0;
+}