From f72baf40d5e647ca2d2bb56c4b846d7eb68c471b Mon Sep 17 00:00:00 2001 From: "Andreas.Eversberg" Date: Sat, 20 Nov 2010 08:32:32 +0000 Subject: [layer23] Adding LAC and TMSI (both optional) to test card (rplmn) --- .../layer23/include/osmocom/bb/mobile/settings.h | 2 + .../layer23/include/osmocom/bb/mobile/subscriber.h | 3 +- src/host/layer23/src/mobile/app_mobile.c | 3 +- src/host/layer23/src/mobile/settings.c | 2 + src/host/layer23/src/mobile/subscriber.c | 14 +++++-- src/host/layer23/src/mobile/vty_interface.c | 46 ++++++++++++++++------ 6 files changed, 53 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/host/layer23/include/osmocom/bb/mobile/settings.h b/src/host/layer23/include/osmocom/bb/mobile/settings.h index d0848a82..f666f378 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/settings.h +++ b/src/host/layer23/include/osmocom/bb/mobile/settings.h @@ -25,11 +25,13 @@ struct gsm_settings { /* test card simulator settings */ char test_imsi[20]; /* just in case... */ + uint32_t test_tmsi; uint8_t test_ki_type; uint8_t test_ki[16]; /* 128 bit max */ uint8_t test_barr; uint8_t test_rplmn_valid; uint16_t test_rplmn_mcc, test_rplmn_mnc; + uint16_t test_lac; 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 15af5d06..c6cf57a0 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/subscriber.h +++ b/src/host/layer23/include/osmocom/bb/mobile/subscriber.h @@ -79,7 +79,8 @@ 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); +int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc, + uint16_t lac, uint32_t tmsi); 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 1461e3bb..822ea640 100644 --- a/src/host/layer23/src/mobile/app_mobile.c +++ b/src/host/layer23/src/mobile/app_mobile.c @@ -100,7 +100,8 @@ int mobile_signal_cb(unsigned int subsys, unsigned int signal, break; case GSM_SIM_TYPE_TEST: gsm_subscr_testcard(ms, set->test_rplmn_mcc, - set->test_rplmn_mnc); + set->test_rplmn_mnc, set->test_lac, + set->test_tmsi); break; default: /* no SIM, trigger PLMN selection process */ diff --git a/src/host/layer23/src/mobile/settings.c b/src/host/layer23/src/mobile/settings.c index 89672a25..a5a91ce1 100644 --- a/src/host/layer23/src/mobile/settings.c +++ b/src/host/layer23/src/mobile/settings.c @@ -50,6 +50,8 @@ int gsm_settings_init(struct osmocom_ms *ms) /* test SIM */ strcpy(set->test_imsi, "001010000000000"); set->test_rplmn_mcc = set->test_rplmn_mnc = 1; + set->test_lac = 0x0000; + set->test_tmsi = 0xffffffff; /* set all supported features */ set->sms_ptp = sup->sms_ptp; diff --git a/src/host/layer23/src/mobile/subscriber.c b/src/host/layer23/src/mobile/subscriber.c index 00d823cb..3ba78f3f 100644 --- a/src/host/layer23/src/mobile/subscriber.c +++ b/src/host/layer23/src/mobile/subscriber.c @@ -153,7 +153,8 @@ 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) +int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc, + uint16_t lac, uint32_t tmsi) { struct gsm_settings *set = &ms->settings; struct gsm_subscriber *subscr = &ms->subscr; @@ -185,6 +186,10 @@ int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc) subscr->plmn_valid = set->test_rplmn_valid; subscr->plmn_mcc = mcc; subscr->plmn_mnc = mnc; + subscr->mcc = mcc; + subscr->mnc = mnc; + subscr->lac = lac; + subscr->tmsi = tmsi; subscr->always_search_hplmn = set->test_always; subscr->t6m_hplmn = 1; /* try to find home network every 6 min */ strcpy(subscr->imsi, set->test_imsi); @@ -194,9 +199,10 @@ int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc) gsm_imsi_mnc(subscr->imsi)); if (subscr->plmn_valid) - LOGP(DMM, LOGL_INFO, "-> Test card registered to %s %s " - "(%s, %s)\n", gsm_print_mcc(mcc), gsm_print_mnc(mnc), - gsm_get_mcc(mcc), gsm_get_mnc(mcc, mnc)); + LOGP(DMM, LOGL_INFO, "-> Test card registered to %s %s 0x%04x" + "(%s, %s)\n", gsm_print_mcc(mcc), + gsm_print_mnc(mnc), lac, gsm_get_mcc(mcc), + gsm_get_mnc(mcc, mnc)); else LOGP(DMM, LOGL_INFO, "-> Test card not registered\n"); diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 4a164eb2..59ff76cf 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -424,12 +424,14 @@ 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]", +DEFUN(sim_test, sim_test_cmd, "sim testcard MS_NAME [mcc] [mnc] [lac] [tmsi]", "SIM actions\nInsert test card\nName of MS (see \"show ms\")\n" - "Mobile Country Code of RPLMN\nMobile Network Code of RPLMN") + "Mobile Country Code of RPLMN\nMobile Network Code of RPLMN\n" + "Optionally locatio area code\nOptionally current assigned TMSI") { struct osmocom_ms *ms; - uint16_t mcc = 0x001, mnc = 0x01f; + uint16_t mcc = 0x001, mnc = 0x01f, lac = 0x0000; + uint32_t tmsi = 0xffffffff; ms = get_ms(argv[0], vty); if (!ms) @@ -454,7 +456,13 @@ DEFUN(sim_test, sim_test_cmd, "sim testcard MS_NAME [mcc] [mnc]", } } - gsm_subscr_testcard(ms, mcc, mnc); + if (argc >= 4) + lac = strtoul(argv[3], NULL, 16); + + if (argc >= 5) + tmsi = strtoul(argv[4], NULL, 16); + + gsm_subscr_testcard(ms, mcc, mnc, lac, tmsi); return CMD_SUCCESS; } @@ -1140,12 +1148,16 @@ static void config_write_ms_single(struct vty *vty, struct osmocom_ms *ms) } vty_out(vty, " %sbarred-access%s", (set->test_barr) ? "" : "no ", VTY_NEWLINE); - if (set->test_rplmn_valid) - vty_out(vty, " rplmn %s %s%s", + if (set->test_rplmn_valid) { + vty_out(vty, " rplmn %s %s", gsm_print_mcc(set->test_rplmn_mcc), - gsm_print_mnc(set->test_rplmn_mnc), - VTY_NEWLINE); - else + gsm_print_mnc(set->test_rplmn_mnc)); + 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); + vty_out(vty, "%s", VTY_NEWLINE); + } else vty_out(vty, " no rplmn%s", VTY_NEWLINE); vty_out(vty, " hplmn-search %s%s", (set->test_always) ? "everywhere" : "foreign-country", VTY_NEWLINE); @@ -2024,8 +2036,10 @@ 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", - "Set Registered PLMN\nMobile Country Code\nMobile Network Code") +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") { struct osmocom_ms *ms = vty->index; struct gsm_settings *set = &ms->settings; @@ -2044,6 +2058,16 @@ DEFUN(cfg_test_rplmn, cfg_test_rplmn_cmd, "rplmn MCC MNC", set->test_rplmn_mcc = mcc; set->test_rplmn_mnc = mnc; + if (argc >= 3) + set->test_lac = strtoul(argv[2], NULL, 16); + else + set->test_lac = 0xfffe; + + if (argc >= 4) + set->test_tmsi = strtoul(argv[3], NULL, 16); + else + set->test_tmsi = 0xffffffff; + vty_restart(vty, ms); return CMD_SUCCESS; } -- cgit v1.2.3