aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2018-08-07 17:50:04 +0200
committerlynxis lazus <lynxis@fe80.eu>2018-08-13 14:47:31 +0000
commitc503f0acd9668a50529f473492ce4c42de8b882a (patch)
treee11ac592f742e4c60713f2f2326cd74325c3cab3
parentd74fa3bf492d3e37cd0865263fd350892abd4002 (diff)
vty: add cmd "reset sgsn state"
Reset the SGSN internal state. Useful when testing the SGSN via TTCN3. Depends on the libosmocore commit: I29b6ad6742ddf9b0b58b4af37d9a1cf18e019325 Change-Id: I92096f3f6ea49e75676e30e9921d00210bac5382
-rw-r--r--src/gprs/sgsn_vty.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gprs/sgsn_vty.c b/src/gprs/sgsn_vty.c
index 8092158f..057be9f0 100644
--- a/src/gprs/sgsn_vty.c
+++ b/src/gprs/sgsn_vty.c
@@ -34,6 +34,7 @@
#include <osmocom/sgsn/debug.h>
#include <osmocom/sgsn/sgsn.h>
#include <osmocom/gprs/gprs_ns.h>
+#include <osmocom/sgsn/gprs_gmm.h>
#include <osmocom/sgsn/gprs_sgsn.h>
#include <osmocom/sgsn/vty.h>
#include <osmocom/sgsn/gsup_client.h>
@@ -44,6 +45,8 @@
#include <osmocom/crypt/gprs_cipher.h>
#include <osmocom/abis/ipa.h>
+#include <osmocom/gprs/gprs_bssgp.h>
+
#include <pdp.h>
#include <gtp.h>
@@ -796,6 +799,34 @@ static void subscr_dump_full_vty(struct vty *vty, struct gprs_subscr *gsub, int
vty_out(vty, " Use count: %u%s", gsub->use_count, VTY_NEWLINE);
}
+DEFUN_HIDDEN(reset_sgsn_state,
+ reset_sgsn_state_cmd,
+ "reset sgsn state",
+ "Remove all known subscriber, MM ctx and flush BSSGP queues Useful when running tests against the SGSN")
+{
+ struct gprs_subscr *subscr, *tmp_subscr;
+ struct sgsn_mm_ctx *mm, *tmp_mm;
+
+ llist_for_each_entry_safe(mm, tmp_mm, &sgsn_mm_ctxts, list)
+ {
+ gsm0408_gprs_access_cancelled(mm, SGSN_ERROR_CAUSE_NONE);
+ }
+ vty_out(vty, "Cancelled MM Ctx. %s", VTY_NEWLINE);
+
+ llist_for_each_entry_safe(subscr, tmp_subscr, gprs_subscribers, entry) {
+ gprs_subscr_get(subscr);
+ gprs_subscr_cancel(subscr);
+ gprs_subscr_put(subscr);
+ }
+ vty_out(vty, "Removed all gprs subscribers.%s", VTY_NEWLINE);
+
+ bssgp_flush_all_queues();
+ vty_out(vty, "Flushed all BSSGPs queues.%s", VTY_NEWLINE);
+
+ /* remove all queues to bssgp */
+ return CMD_SUCCESS;
+}
+
DEFUN(show_subscr_cache,
show_subscr_cache_cmd,
"show subscriber cache",
@@ -1310,6 +1341,7 @@ int sgsn_vty_init(struct sgsn_config *cfg)
install_element(ENABLE_NODE, &update_subscr_cancel_cmd);
install_element(ENABLE_NODE, &update_subscr_update_location_result_cmd);
install_element(ENABLE_NODE, &update_subscr_update_auth_info_cmd);
+ install_element(ENABLE_NODE, &reset_sgsn_state_cmd);
install_element(CONFIG_NODE, &cfg_sgsn_cmd);
install_node(&sgsn_node, config_write_sgsn);