aboutsummaryrefslogtreecommitdiffstats
path: root/src/gb/gprs_ns2_vty.c
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2020-11-18 14:19:56 +0100
committerDaniel Willmann <dwillmann@sysmocom.de>2020-11-20 15:38:00 +0100
commitdbab714343709afb8d1b4a7384fa5bdbeb232632 (patch)
tree75be3bbfdd4e53ec04d6b654b921bfc7eedcb7e7 /src/gb/gprs_ns2_vty.c
parented0c9820791c539cf15e23d3cd8d2c546d53e1c4 (diff)
ns2: Add a VTY command to reset NSVC FSM
Mainly useful for testing so implemented as a hidden command Change-Id: I83b9cd7381c25da0e8aa847038a2d422c8dd63cf Related: SYS#5002
Diffstat (limited to 'src/gb/gprs_ns2_vty.c')
-rw-r--r--src/gb/gprs_ns2_vty.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 65fe88ee..63331b95 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -34,6 +34,7 @@
#include <osmocom/core/msgb.h>
#include <osmocom/core/byteswap.h>
+#include <osmocom/core/fsm.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
@@ -354,6 +355,36 @@ DEFUN(show_nse, show_nse_cmd, "show ns (nsei|nsvc) <0-65535> [stats]",
return CMD_SUCCESS;
}
+static int nsvc_force_unconf_cb(struct gprs_ns2_vc *nsvc, void *ctx)
+{
+ gprs_ns2_vc_force_unconfigured(nsvc);
+ return 0;
+}
+
+DEFUN_HIDDEN(nsvc_force_unconf, nsvc_force_unconf_cmd,
+ "nsvc nsei <0-65535> force-unconfigured",
+ "NS Virtual Connection\n"
+ "The NSEI\n"
+ "Reset the NSVCs back to initial state\n"
+ )
+{
+ struct gprs_ns2_inst *nsi = vty_nsi;
+ struct gprs_ns2_nse *nse;
+
+ uint16_t id = atoi(argv[0]);
+
+ nse = gprs_ns2_nse_by_nsei(nsi, id);
+ if (!nse) {
+ vty_out(vty, "Could not find NSE for NSEI %u%s", id, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ /* Perform the operation for all nsvc */
+ gprs_ns2_nse_foreach_nsvc(nse, nsvc_force_unconf_cb, NULL);
+
+ return CMD_SUCCESS;
+}
+
#define NSE_CMD_STR "Persistent NS Entity\n" "NS Entity ID (NSEI)\n"
DEFUN(cfg_nse_nsvc, cfg_nse_nsvci_cmd,
@@ -699,6 +730,8 @@ int gprs_ns2_vty_init(struct gprs_ns2_inst *nsi,
install_lib_element_ve(&show_nse_cmd);
install_lib_element_ve(&logging_fltr_nsvc_cmd);
+ install_lib_element(ENABLE_NODE, &nsvc_force_unconf_cmd);
+
install_lib_element(CFG_LOG_NODE, &logging_fltr_nsvc_cmd);
install_lib_element(CONFIG_NODE, &cfg_ns_cmd);