aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/osmo_server_network.c13
-rw-r--r--src/osmo_server_vty.c24
2 files changed, 31 insertions, 6 deletions
diff --git a/src/osmo_server_network.c b/src/osmo_server_network.c
index 7127401..d530ef7 100644
--- a/src/osmo_server_network.c
+++ b/src/osmo_server_network.c
@@ -62,6 +62,12 @@ static void restart_pcap(struct osmo_pcap_conn *conn)
conn->local_fd = -1;
}
+ /* omit any storing/creation of the file */
+ if (conn->no_store) {
+ conn->last_write = *tm;
+ return;
+ }
+
filename = talloc_asprintf(conn, "%s/trace-%s-%d%.2d%.2d_%.2d%.2d%.2d.pcap",
conn->server->base_path, conn->name,
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
@@ -103,7 +109,7 @@ static void link_data(struct osmo_pcap_conn *conn, struct osmo_pcap_data *data)
}
hdr = (struct pcap_file_header *) &data->data[0];
- if (conn->local_fd < 0) {
+ if (!conn->no_store && conn->local_fd < 0) {
conn->file_hdr = *hdr;
restart_pcap(conn);
} else if (memcmp(&conn->file_hdr, hdr, sizeof(*hdr)) != 0) {
@@ -121,6 +127,11 @@ static void write_data(struct osmo_pcap_conn *conn, struct osmo_pcap_data *data)
struct tm *tm = localtime(&now);
int rc;
+ if (conn->no_store) {
+ conn->last_write = *tm;
+ return;
+ }
+
if (conn->local_fd < -1) {
LOGP(DSERVER, LOGL_ERROR, "No file is open. close connection.\n");
close_connection(conn);
diff --git a/src/osmo_server_vty.c b/src/osmo_server_vty.c
index 2829620..8822bac 100644
--- a/src/osmo_server_vty.c
+++ b/src/osmo_server_vty.c
@@ -1,7 +1,7 @@
/*
* osmo-pcap-server code
*
- * (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2011-2016 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2011 by On-Waves
* All Rights Reserved
*
@@ -25,6 +25,8 @@
#include <osmocom/core/talloc.h>
+#include <unistd.h>
+
#define SERVER_STR "Server settings\n"
#define CLIENT_STR "Client\n"
@@ -51,8 +53,10 @@ static int config_write_server(struct vty *vty)
(unsigned long long) pcap_server->max_size, VTY_NEWLINE);
llist_for_each_entry(conn, &pcap_server->conn, entry) {
- vty_out(vty, " client %s %s%s",
- conn->name, conn->remote_host, VTY_NEWLINE);
+ vty_out(vty, " client %s %s%s%s",
+ conn->name, conn->remote_host,
+ conn->no_store ? " no-store" : "",
+ VTY_NEWLINE);
}
return CMD_SUCCESS;
@@ -107,8 +111,8 @@ DEFUN(cfg_server_max_size,
DEFUN(cfg_server_client,
cfg_server_client_cmd,
- "client NAME A.B.C.D",
- CLIENT_STR "Remote name used in filenames\n" "IP of the remote\n")
+ "client NAME A.B.C.D [no-store]",
+ CLIENT_STR "Remote name used in filenames\n" "IP of the remote\n" "Do not store traffic\n")
{
struct osmo_pcap_conn *conn;
conn = osmo_pcap_server_find(pcap_server, argv[0]);
@@ -121,6 +125,16 @@ DEFUN(cfg_server_client,
conn->remote_host = talloc_strdup(pcap_server, argv[1]);
inet_aton(argv[1], &conn->remote_addr);
+ /* Checking no-store and maybe closing a pcap file */
+ if (argc >= 3) {
+ if (conn->local_fd >= 0) {
+ close(conn->local_fd);
+ conn->local_fd = -1;
+ }
+ conn->no_store = 1;
+ } else
+ conn->no_store = 0;
+
return CMD_SUCCESS;
}