aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-11-17 19:11:35 (GMT)
committerJouni Malinen <j@w1.fi>2013-11-17 19:39:22 (GMT)
commitc99a721e5b803bc6710aac0583121ef80df38d1a (patch)
tree44617b9d9f20c8af559db87f8adde7fc20448bd1 /wlantest
parent0e91337d543ce6d1d26e1fc4590e758ef102bfd3 (diff)
downloadhostap-c99a721e5b803bc6710aac0583121ef80df38d1a.zip
hostap-c99a721e5b803bc6710aac0583121ef80df38d1a.tar.gz
hostap-c99a721e5b803bc6710aac0583121ef80df38d1a.tar.bz2
wlantest: Add RELOG command to reopen log/capture files
This can be used similarly to the wpa_supplicant RELOG command to rotate log and capture files. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wlantest')
-rw-r--r--wlantest/ctrl.c13
-rw-r--r--wlantest/wlantest.c34
-rw-r--r--wlantest/wlantest.h7
-rw-r--r--wlantest/wlantest_cli.c7
-rw-r--r--wlantest/wlantest_ctrl.h3
5 files changed, 54 insertions, 10 deletions
diff --git a/wlantest/ctrl.c b/wlantest/ctrl.c
index bed5d6c..86bd672 100644
--- a/wlantest/ctrl.c
+++ b/wlantest/ctrl.c
@@ -1,6 +1,6 @@
/*
* wlantest control interface
- * Copyright (c) 2010, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2010-2013, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -1187,6 +1187,14 @@ static void ctrl_send_(struct wlantest *wt, int sock, u8 *cmd, size_t clen)
}
+static void ctrl_relog(struct wlantest *wt, int sock)
+{
+ int res = wlantest_relog(wt);
+ ctrl_send_simple(wt, sock, res ? WLANTEST_CTRL_FAILURE :
+ WLANTEST_CTRL_SUCCESS);
+}
+
+
static void ctrl_read(int sock, void *eloop_ctx, void *sock_ctx)
{
struct wlantest *wt = eloop_ctx;
@@ -1270,6 +1278,9 @@ static void ctrl_read(int sock, void *eloop_ctx, void *sock_ctx)
case WLANTEST_CTRL_SEND:
ctrl_send_(wt, sock, buf + 4, len - 4);
break;
+ case WLANTEST_CTRL_RELOG:
+ ctrl_relog(wt, sock);
+ break;
default:
ctrl_send_simple(wt, sock, WLANTEST_CTRL_UNKNOWN_CMD);
break;
diff --git a/wlantest/wlantest.c b/wlantest/wlantest.c
index 5b691fa..2966458 100644
--- a/wlantest/wlantest.c
+++ b/wlantest/wlantest.c
@@ -1,6 +1,6 @@
/*
* wlantest - IEEE 802.11 protocol monitoring and testing tool
- * Copyright (c) 2010-2011, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2010-2013, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -245,15 +245,35 @@ size_t notes_len(struct wlantest *wt, size_t hdrlen)
}
+int wlantest_relog(struct wlantest *wt)
+{
+ int ret = 0;
+
+ wpa_printf(MSG_INFO, "Re-open log/capture files");
+
+ if (wt->write_file) {
+ write_pcap_deinit(wt);
+ if (write_pcap_init(wt, wt->write_file) < 0)
+ ret = -1;
+ }
+
+ if (wt->pcapng_file) {
+ write_pcapng_deinit(wt);
+ if (write_pcapng_init(wt, wt->pcapng_file) < 0)
+ ret = -1;
+ }
+
+ return ret;
+}
+
+
int main(int argc, char *argv[])
{
int c;
const char *read_file = NULL;
const char *read_wired_file = NULL;
- const char *write_file = NULL;
const char *ifname = NULL;
const char *ifname_wired = NULL;
- const char *pcapng_file = NULL;
struct wlantest wt;
int ctrl_iface = 0;
@@ -294,7 +314,7 @@ int main(int argc, char *argv[])
ifname_wired = optarg;
break;
case 'n':
- pcapng_file = optarg;
+ wt.pcapng_file = optarg;
break;
case 'p':
add_passphrase(&wt, optarg);
@@ -312,7 +332,7 @@ int main(int argc, char *argv[])
read_wired_file = optarg;
break;
case 'w':
- write_file = optarg;
+ wt.write_file = optarg;
break;
case 'W':
if (add_wep(&wt, optarg) < 0)
@@ -333,10 +353,10 @@ int main(int argc, char *argv[])
if (eloop_init())
return -1;
- if (write_file && write_pcap_init(&wt, write_file) < 0)
+ if (wt.write_file && write_pcap_init(&wt, wt.write_file) < 0)
return -1;
- if (pcapng_file && write_pcapng_init(&wt, pcapng_file) < 0)
+ if (wt.pcapng_file && write_pcapng_init(&wt, wt.pcapng_file) < 0)
return -1;
if (read_wired_file && read_wired_cap_file(&wt, read_wired_file) < 0)
diff --git a/wlantest/wlantest.h b/wlantest/wlantest.h
index 1ff3229..6146830 100644
--- a/wlantest/wlantest.h
+++ b/wlantest/wlantest.h
@@ -1,6 +1,6 @@
/*
* wlantest - IEEE 802.11 protocol monitoring and testing tool
- * Copyright (c) 2010, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2010-2013, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -188,6 +188,9 @@ struct wlantest {
char *notes[MAX_NOTES];
size_t num_notes;
+
+ const char *write_file;
+ const char *pcapng_file;
};
void add_note(struct wlantest *wt, int level, const char *fmt, ...)
@@ -286,4 +289,6 @@ int wlantest_inject(struct wlantest *wt, struct wlantest_bss *bss,
struct wlantest_sta *sta, u8 *frame, size_t len,
enum wlantest_inject_protection prot);
+int wlantest_relog(struct wlantest *wt);
+
#endif /* WLANTEST_H */
diff --git a/wlantest/wlantest_cli.c b/wlantest/wlantest_cli.c
index fe81bfc..afe38c4 100644
--- a/wlantest/wlantest_cli.c
+++ b/wlantest/wlantest_cli.c
@@ -740,6 +740,12 @@ static char ** complete_get_bss_counter(int s, const char *str, int pos)
}
+static int cmd_relog(int s, int argc, char *argv[])
+{
+ return cmd_simple(s, WLANTEST_CTRL_RELOG);
+}
+
+
struct tdls_counters {
const char *name;
enum wlantest_tdls_counter num;
@@ -1496,6 +1502,7 @@ static const struct wlantest_cli_cmd wlantest_cli_commands[] = {
{ "get_bss_counter", cmd_get_bss_counter,
"<counter> <BSSID> = get BSS counter value",
complete_get_bss_counter },
+ { "relog", cmd_relog, "= re-open log-file (allow rolling logs)", NULL },
{ NULL, NULL, NULL, NULL }
};
diff --git a/wlantest/wlantest_ctrl.h b/wlantest/wlantest_ctrl.h
index 618cf8c..41b6583 100644
--- a/wlantest/wlantest_ctrl.h
+++ b/wlantest/wlantest_ctrl.h
@@ -1,6 +1,6 @@
/*
* wlantest control interface
- * Copyright (c) 2010, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2010-2013, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -35,6 +35,7 @@ enum wlantest_ctrl_cmd {
WLANTEST_CTRL_SEND,
WLANTEST_CTRL_CLEAR_TDLS_COUNTERS,
WLANTEST_CTRL_GET_TDLS_COUNTER,
+ WLANTEST_CTRL_RELOG,
};
enum wlantest_ctrl_attr {