[PATCH] openbsc[master]: bsc_vty: Add VTY command to test CTRL TRAP feature

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Jul 18 17:16:46 UTC 2017


Review at  https://gerrit.osmocom.org/3278

bsc_vty: Add VTY command to test CTRL TRAP feature

Using this new command (introduced in OsmoBSC + OsmoNITB), you can
simulate the generation of TRAP events for testin purposes.

start the control interface monitor as an example client program:
	./openbsc/contrib/bsc_control.py -m -d localhost -p 4249

then start OsmoBSC or OsmoNITB, telnet to the VTY and enter 'enable'
mode and issue the following (example) command:
	ctrl-interface generate-trap my.foo.var 2342

As a result, on the bsc_control.py you will see:
	Got message: TRAP 0 my.foo.var 2342

Change-Id: Ib1d2ec38290dc94797c1b365d9b733e5215ab7d1
---
M openbsc/src/libbsc/bsc_vty.c
1 file changed, 16 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/78/3278/1

diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 91a90c1..6472e9d 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -30,6 +30,7 @@
 #include <osmocom/vty/misc.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 #include <osmocom/gsm/gsm0502.h>
+#include <osmocom/ctrl/control_if.h>
 
 #include <arpa/inet.h>
 
@@ -4122,6 +4123,20 @@
 	rsl_ipacc_mdcx(lchan, ntohl(ia.s_addr), port, 0);
 	return CMD_SUCCESS;
 }
+
+DEFUN(ctrl_trap, ctrl_trap_cmd,
+	"ctrl-interface generate-trap TRAP VALUE",
+	"Commands related to the CTRL Interface\n"
+	"Generate a TRAP for test purpose\n"
+	"Identity/Name of the TRAP variable\n"
+	"Value of the TRAP variable\n")
+{
+	struct gsm_network *net = gsmnet_from_vty(vty);
+
+	ctrl_cmd_send_trap(net->ctrl, argv[0], (char *) argv[1]);
+	return CMD_SUCCESS;
+}
+
 extern int bsc_vty_init_extra(void);
 
 int bsc_vty_init(struct gsm_network *network)
@@ -4325,6 +4340,7 @@
 	install_element(ENABLE_NODE, &lchan_act_cmd);
 	install_element(ENABLE_NODE, &lchan_mdcx_cmd);
 	install_element(ENABLE_NODE, &smscb_cmd_cmd);
+	install_element(ENABLE_NODE, &ctrl_trap_cmd);
 
 	abis_nm_vty_init();
 	abis_om2k_vty_init();

-- 
To view, visit https://gerrit.osmocom.org/3278
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib1d2ec38290dc94797c1b365d9b733e5215ab7d1
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list