Change in libosmo-abis[master]: e1_input: Add VTY command to enable PCAP debug output

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

tnt gerrit-no-reply at lists.osmocom.org
Fri May 8 07:45:05 UTC 2020


tnt has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/18114 )


Change subject: e1_input: Add VTY command to enable PCAP debug output
......................................................................

e1_input: Add VTY command to enable PCAP debug output

The command must be put first, since only lines created after it are
affected.

This limits the usefulness of changing at runtime or of the 'no' command
except to set it up properly before a 'write config'.

Signed-off-by: Sylvain Munaut <tnt at 246tNt.com>
Change-Id: I0b4251702aecd6721b9d63c320351ef6cb513454
---
M src/e1_input_vty.c
1 file changed, 42 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/14/18114/1

diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c
index 8d89d04..cdee672 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,39 @@
 	return CMD_SUCCESS;
 }
 
+static char *pcap_filename = NULL;
+
+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[1], VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	talloc_free(pcap_filename);
+	pcap_filename = talloc_strdup(NULL, argv[0]);
+
+	e1_set_pcap_fd(fd);
+
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_e1_no_pcap, cfg_e1_no_pcap_cmd,
+	NO_STR "pcap",
+	"Disable pcap recording of all E1 traffic\n")
+{
+	talloc_free(pcap_filename);
+	pcap_filename = NULL;
+	e1_set_pcap_fd(-1);
+	return CMD_SUCCESS;
+}
+
 DEFUN(cfg_e1inp, cfg_e1inp_cmd,
 	"e1_input",
 	"Configure E1/T1/J1 TDM input\n")
@@ -261,6 +297,9 @@
 
 	vty_out(vty, "e1_input%s", VTY_NEWLINE);
 
+	if (pcap_filename)
+		vty_out(vty, " pcap %s%s", pcap_filename, VTY_NEWLINE);
+
 	llist_for_each_entry(line, &e1inp_line_list, list) {
 		vty_out(vty, " e1_line %u driver %s%s", line->num,
 			line->driver->name, VTY_NEWLINE);
@@ -436,6 +475,9 @@
 	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);

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/18114
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I0b4251702aecd6721b9d63c320351ef6cb513454
Gerrit-Change-Number: 18114
Gerrit-PatchSet: 1
Gerrit-Owner: tnt <tnt at 246tNt.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200508/93727901/attachment.htm>


More information about the gerrit-log mailing list