aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2020-05-08 09:42:51 +0200
committerSylvain Munaut <tnt@246tNt.com>2020-05-09 10:45:20 +0200
commiteb55e2f8d95f83379b209c4390543b64895a5253 (patch)
treefe967d4762e323461c15d28f1f5da7cfdc9d72f8
parent4b45e9d1a6fcb0a56cecd561f0c4353d9c2bbb2a (diff)
e1_input: Add VTY command to enable PCAP debug output
This command is also usable at run-time to dynamically enable / disable e1 tracing on all active lines Signed-off-by: Sylvain Munaut <tnt@246tNt.com> Change-Id: I0b4251702aecd6721b9d63c320351ef6cb513454
-rw-r--r--src/e1_input_vty.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c
index 8d89d04..15f325f 100644
--- a/src/e1_input_vty.c
+++ b/src/e1_input_vty.c
@@ -20,9 +20,12 @@
*/
#include "internal.h"
+#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <sys/un.h>
#include <osmocom/core/linuxlist.h>
@@ -232,6 +235,32 @@ DEFUN(cfg_e1line_name, cfg_e1_line_name_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_e1_pcap, cfg_e1_pcap_cmd,
+ "pcap .FILE",
+ "Setup a pcap recording of all E1 traffic\n"
+ "Filename to save the packets to\n")
+{
+ int fd;
+
+ fd = open(argv[0], O_WRONLY | O_CREAT | O_TRUNC, 0660);
+ if (fd < 0) {
+ vty_out(vty, "Failed to setup E1 pcap recording to %s.%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ e1_set_pcap_fd(fd);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_e1_no_pcap, cfg_e1_no_pcap_cmd,
+ "no pcap",
+ NO_STR "Disable pcap recording of all E1 traffic\n")
+{
+ e1_set_pcap_fd(-1);
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_e1inp, cfg_e1inp_cmd,
"e1_input",
"Configure E1/T1/J1 TDM input\n")
@@ -436,6 +465,9 @@ int e1inp_vty_init(void)
install_element(CONFIG_NODE, &cfg_e1inp_cmd);
install_node(&e1inp_node, e1inp_config_write);
+ install_element(L_E1INP_NODE, &cfg_e1_pcap_cmd);
+ install_element(L_E1INP_NODE, &cfg_e1_no_pcap_cmd);
+
install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd);
install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd);
install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd);