summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-04-20 20:56:59 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-04-20 20:56:59 +0700
commit9b8b6a3eec794a84d5f223f01b049c7b565d9d20 (patch)
treed156739a6cd46c51659a2adeaa581573c7909fac
parent716942df1d746efc1ce481cf0ac8c6ce278adc2e (diff)
mobile/multi-imsi: add switch VTY command
-rw-r--r--src/host/layer23/src/mobile/subscriber.c15
-rw-r--r--src/host/layer23/src/mobile/vty_interface.c27
2 files changed, 42 insertions, 0 deletions
diff --git a/src/host/layer23/src/mobile/subscriber.c b/src/host/layer23/src/mobile/subscriber.c
index 12310ecf..1ab2132e 100644
--- a/src/host/layer23/src/mobile/subscriber.c
+++ b/src/host/layer23/src/mobile/subscriber.c
@@ -1322,6 +1322,21 @@ int multi_imsi_spoof(struct osmocom_ms *ms, struct gsm_subscriber_creds *src)
return 0;
}
+int multi_imsi_switch_imsi(struct osmocom_ms *ms, const char *imsi)
+{
+ struct gsm_subscriber_creds *imsi_entry;
+ struct gsm_settings *set = &ms->settings;
+
+ llist_for_each_entry(imsi_entry, &set->multi_imsi_list, entry) {
+ if (!strcmp(imsi_entry->imsi, imsi)) {
+ multi_imsi_spoof(ms, imsi_entry);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
int multi_imsi_work(struct osmocom_ms *ms)
{
struct gsm_subscriber *subscr = &ms->subscr;
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index 5ff0e758..a3eeba32 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -2609,6 +2609,32 @@ DEFUN(multi_imsi_update, multi_imsi_update_cmd, "multi-imsi MS_NAME update",
return CMD_SUCCESS;
}
+DEFUN(multi_imsi_switch, multi_imsi_switch_cmd, "multi-imsi MS_NAME switch IMSI",
+ "Multi-IMSI configuration\nMS name\n"
+ "Spoof some IMSI from list\nIMSI to spoof")
+{
+ char *error = gsm_check_imsi(argv[1]);
+ struct osmocom_ms *ms;
+ int rc;
+
+ ms = get_ms(argv[0], vty);
+ if (!ms)
+ return CMD_WARNING;
+
+ if (error) {
+ vty_out(vty, "%s%s", error, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ rc = multi_imsi_switch_imsi(ms, argv[1]);
+ if (rc) {
+ vty_out(vty, "IMSI not in list?%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ return CMD_SUCCESS;
+}
+
/* per testsim config */
DEFUN(cfg_ms_testsim, cfg_ms_testsim_cmd, "test-sim",
"Configure test SIM emulation")
@@ -2966,6 +2992,7 @@ int ms_vty_init(void)
install_element(ENABLE_NODE, &multi_imsi_add_cmd);
install_element(ENABLE_NODE, &multi_imsi_update_cmd);
+ install_element(ENABLE_NODE, &multi_imsi_switch_cmd);
install_element(ENABLE_NODE, &sim_test_cmd);
install_element(ENABLE_NODE, &sim_test_att_cmd);
install_element(ENABLE_NODE, &sim_sap_cmd);