diff options
-rw-r--r-- | src/host/layer23/include/osmocom/bb/mobile/settings.h | 1 | ||||
-rw-r--r-- | src/host/layer23/include/osmocom/bb/mobile/subscriber.h | 2 | ||||
-rw-r--r-- | src/host/layer23/src/mobile/app_mobile.c | 2 | ||||
-rw-r--r-- | src/host/layer23/src/mobile/subscriber.c | 10 | ||||
-rw-r--r-- | src/host/layer23/src/mobile/vty_interface.c | 74 |
5 files changed, 73 insertions, 16 deletions
diff --git a/src/host/layer23/include/osmocom/bb/mobile/settings.h b/src/host/layer23/include/osmocom/bb/mobile/settings.h index fae12202..f3ac7969 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/settings.h +++ b/src/host/layer23/include/osmocom/bb/mobile/settings.h @@ -35,6 +35,7 @@ struct gsm_settings { uint8_t test_rplmn_valid; uint16_t test_rplmn_mcc, test_rplmn_mnc; uint16_t test_lac; + uint8_t test_imsi_attached; uint8_t test_always; /* ...search hplmn... */ /* call related settings */ diff --git a/src/host/layer23/include/osmocom/bb/mobile/subscriber.h b/src/host/layer23/include/osmocom/bb/mobile/subscriber.h index 3e50e29d..79a2ecca 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/subscriber.h +++ b/src/host/layer23/include/osmocom/bb/mobile/subscriber.h @@ -85,7 +85,7 @@ struct gsm_subscriber { int gsm_subscr_init(struct osmocom_ms *ms); int gsm_subscr_exit(struct osmocom_ms *ms); int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc, - uint16_t lac, uint32_t tmsi); + uint16_t lac, uint32_t tmsi, uint8_t imsi_attached); int gsm_subscr_simcard(struct osmocom_ms *ms); void gsm_subscr_sim_pin(struct osmocom_ms *ms, char *pin1, char *pin2, int8_t mode); diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c index 67aba05a..841e39b3 100644 --- a/src/host/layer23/src/mobile/app_mobile.c +++ b/src/host/layer23/src/mobile/app_mobile.c @@ -112,7 +112,7 @@ int mobile_signal_cb(unsigned int subsys, unsigned int signal, case GSM_SIM_TYPE_TEST: gsm_subscr_testcard(ms, set->test_rplmn_mcc, set->test_rplmn_mnc, set->test_lac, - set->test_tmsi); + set->test_tmsi, set->test_imsi_attached); break; default: /* no SIM, trigger PLMN selection process */ diff --git a/src/host/layer23/src/mobile/subscriber.c b/src/host/layer23/src/mobile/subscriber.c index cefc8556..c2a0af7f 100644 --- a/src/host/layer23/src/mobile/subscriber.c +++ b/src/host/layer23/src/mobile/subscriber.c @@ -161,7 +161,7 @@ int gsm_subscr_exit(struct osmocom_ms *ms) /* Attach test card, no SIM must be currently attached */ int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc, - uint16_t lac, uint32_t tmsi) + uint16_t lac, uint32_t tmsi, uint8_t imsi_attached) { struct gsm_settings *set = &ms->settings; struct gsm_subscriber *subscr = &ms->subscr; @@ -187,7 +187,11 @@ int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc, subscr->sim_type = GSM_SIM_TYPE_TEST; sprintf(subscr->sim_name, "test"); subscr->sim_valid = 1; - subscr->ustate = GSM_SIM_U2_NOT_UPDATED; + if (imsi_attached && set->test_rplmn_valid) { + subscr->imsi_attached = imsi_attached; + subscr->ustate = GSM_SIM_U1_UPDATED; + } else + subscr->ustate = GSM_SIM_U2_NOT_UPDATED; subscr->acc_barr = set->test_barr; /* we may access barred cell */ subscr->acc_class = 0xffff; /* we have any access class */ subscr->plmn_valid = set->test_rplmn_valid; @@ -212,6 +216,8 @@ int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc, gsm_get_mnc(mcc, mnc)); else LOGP(DMM, LOGL_INFO, "-> Test card not registered\n"); + if (subscr->imsi_attached) + LOGP(DMM, LOGL_INFO, "-> Test card attached\n"); /* insert card */ nmsg = gsm48_mmr_msgb_alloc(GSM48_MMR_REG_REQ); diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 95653c78..22ef7ae5 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -467,10 +467,8 @@ DEFUN(no_monitor_network, no_monitor_network_cmd, "no monitor network MS_NAME", return CMD_SUCCESS; } -DEFUN(sim_test, sim_test_cmd, "sim testcard MS_NAME [MCC] [MNC] [LAC] [TMSI]", - "SIM actions\nAttach bulit in test SIM\nName of MS (see \"show ms\")\n" - "Mobile Country Code of RPLMN\nMobile Network Code of RPLMN\n" - "Optionally location area code\nOptionally current assigned TMSI") +static int _sim_test_cmd(struct vty *vty, int argc, const char *argv[], + int attached) { struct osmocom_ms *ms; uint16_t mcc = 0x001, mnc = 0x01f, lac = 0x0000; @@ -486,6 +484,10 @@ DEFUN(sim_test, sim_test_cmd, "sim testcard MS_NAME [MCC] [MNC] [LAC] [TMSI]", return CMD_WARNING; } + if (argc == 2) { + vty_out(vty, "Give MNC together with MCC%s", VTY_NEWLINE); + return CMD_WARNING; + } if (argc >= 3) { mcc = gsm_input_mcc((char *)argv[1]); mnc = gsm_input_mnc((char *)argv[2]); @@ -505,11 +507,32 @@ DEFUN(sim_test, sim_test_cmd, "sim testcard MS_NAME [MCC] [MNC] [LAC] [TMSI]", if (argc >= 5) tmsi = strtoul(argv[4], NULL, 16); - gsm_subscr_testcard(ms, mcc, mnc, lac, tmsi); + gsm_subscr_testcard(ms, mcc, mnc, lac, tmsi, attached); return CMD_SUCCESS; } +DEFUN(sim_test, sim_test_cmd, + "sim testcard MS_NAME [MCC] [MNC] [LAC] [TMSI]", + "SIM actions\nAttach bulit in test SIM\nName of MS (see \"show ms\")\n" + "Optionally set mobile Country Code of RPLMN\n" + "Optionally set mobile Network Code of RPLMN\n" + "Optionally set location area code of RPLMN\n" + "Optionally set current assigned TMSI") +{ + return _sim_test_cmd(vty, argc, argv, 0); +} + +DEFUN(sim_test_att, sim_test_att_cmd, + "sim testcard MS_NAME MCC MNC LAC TMSI attached", + "SIM actions\nAttach bulit in test SIM\nName of MS (see \"show ms\")\n" + "Set mobile Country Code of RPLMN\nSet mobile Network Code of RPLMN\n" + "Set location area code\nSet current assigned TMSI\n" + "Indicate to MM that card is already attached") +{ + return _sim_test_cmd(vty, argc, argv, 1); +} + DEFUN(sim_reader, sim_reader_cmd, "sim reader MS_NAME", "SIM actions\nAttach SIM from reader\nName of MS (see \"show ms\")") { @@ -1446,10 +1469,14 @@ static void config_write_ms(struct vty *vty, struct osmocom_ms *ms) vty_out(vty, " rplmn %s %s", gsm_print_mcc(set->test_rplmn_mcc), gsm_print_mnc(set->test_rplmn_mnc)); - if (set->test_lac > 0x0000 && set->test_lac < 0xfffe) + if (set->test_lac > 0x0000 && set->test_lac < 0xfffe) { vty_out(vty, " 0x%04x", set->test_lac); - if (set->test_tmsi != 0xffffffff) - vty_out(vty, " 0x%08x", set->test_tmsi); + if (set->test_tmsi != 0xffffffff) { + vty_out(vty, " 0x%08x", set->test_tmsi); + if (set->test_imsi_attached) + vty_out(vty, " attached"); + } + } vty_out(vty, "%s", VTY_NEWLINE); } else if (!hide_default) @@ -2542,10 +2569,8 @@ DEFUN(cfg_test_no_rplmn, cfg_test_no_rplmn_cmd, "no rplmn", return CMD_SUCCESS; } -DEFUN(cfg_test_rplmn, cfg_test_rplmn_cmd, "rplmn MCC MNC [LAC] [TMSI]", - "Set Registered PLMN\nMobile Country Code\nMobile Network Code\n" - "Optionally set locatio area code\n" - "Optionally set current assigned TMSI") +static int _test_rplmn_cmd(struct vty *vty, int argc, const char *argv[], + int attached) { struct osmocom_ms *ms = vty->index; struct gsm_settings *set = &ms->settings; @@ -2574,11 +2599,34 @@ DEFUN(cfg_test_rplmn, cfg_test_rplmn_cmd, "rplmn MCC MNC [LAC] [TMSI]", else set->test_tmsi = 0xffffffff; + if (attached) + set->test_imsi_attached = 1; + else + set->test_imsi_attached = 0; + vty_restart_if_started(vty, ms); return CMD_SUCCESS; } +DEFUN(cfg_test_rplmn, cfg_test_rplmn_cmd, + "rplmn MCC MNC [LAC] [TMSI]", + "Set Registered PLMN\nMobile Country Code\nMobile Network Code\n" + "Optionally set location area code\n" + "Optionally set current assigned TMSI") +{ + return _test_rplmn_cmd(vty, argc, argv, 0); +} + +DEFUN(cfg_test_rplmn_att, cfg_test_rplmn_att_cmd, + "rplmn MCC MNC LAC TMSI attached", + "Set Registered PLMN\nMobile Country Code\nMobile Network Code\n" + "Set location area code\nSet current assigned TMSI\n" + "Indicate to MM that card is already attached") +{ + return _test_rplmn_cmd(vty, argc, argv, 1); +} + DEFUN(cfg_test_hplmn, cfg_test_hplmn_cmd, "hplmn-search (everywhere|foreign-country)", "Set Home PLMN search mode\n" "Search for HPLMN when on any other network\n" @@ -2752,6 +2800,7 @@ int ms_vty_init(void) install_element(ENABLE_NODE, &off_cmd); install_element(ENABLE_NODE, &sim_test_cmd); + install_element(ENABLE_NODE, &sim_test_att_cmd); install_element(ENABLE_NODE, &sim_reader_cmd); install_element(ENABLE_NODE, &sim_remove_cmd); install_element(ENABLE_NODE, &sim_pin_cmd); @@ -2901,6 +2950,7 @@ int ms_vty_init(void) install_element(TESTSIM_NODE, &cfg_test_no_barr_cmd); install_element(TESTSIM_NODE, &cfg_test_no_rplmn_cmd); install_element(TESTSIM_NODE, &cfg_test_rplmn_cmd); + install_element(TESTSIM_NODE, &cfg_test_rplmn_att_cmd); install_element(TESTSIM_NODE, &cfg_test_hplmn_cmd); install_element(MS_NODE, &cfg_ms_shutdown_cmd); install_element(MS_NODE, &cfg_ms_shutdown_force_cmd); |