pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/32739 )
Change subject: layer23: Support setting P-TMSI in test sim
......................................................................
layer23: Support setting P-TMSI in test sim
Change-Id: I77d28534bd21327fbbec8f1544238703558245cb
---
M src/host/layer23/include/osmocom/bb/common/settings.h
M src/host/layer23/include/osmocom/bb/common/subscriber.h
M src/host/layer23/src/common/settings.c
M src/host/layer23/src/common/subscriber.c
M src/host/layer23/src/common/vty.c
M src/host/layer23/src/mobile/app_mobile.c
M src/host/layer23/src/modem/app_modem.c
7 files changed, 46 insertions(+), 16 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/39/32739/1
diff --git a/src/host/layer23/include/osmocom/bb/common/settings.h
b/src/host/layer23/include/osmocom/bb/common/settings.h
index 38faa4b..ab85ea1 100644
--- a/src/host/layer23/include/osmocom/bb/common/settings.h
+++ b/src/host/layer23/include/osmocom/bb/common/settings.h
@@ -87,6 +87,7 @@
/* test card simulator settings */
char test_imsi[OSMO_IMSI_BUF_SIZE];
uint32_t test_tmsi;
+ uint32_t test_ptmsi;
uint8_t test_ki_type;
uint8_t test_ki[16]; /* 128 bit max */
uint8_t test_barr;
diff --git a/src/host/layer23/include/osmocom/bb/common/subscriber.h
b/src/host/layer23/include/osmocom/bb/common/subscriber.h
index 1dd1869..62c2ee8 100644
--- a/src/host/layer23/include/osmocom/bb/common/subscriber.h
+++ b/src/host/layer23/include/osmocom/bb/common/subscriber.h
@@ -90,7 +90,7 @@
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, uint8_t imsi_attached);
+ uint16_t lac, uint32_t tmsi, uint32_t ptmsi, uint8_t imsi_attached);
int gsm_subscr_sap_rsp_cb(struct osmocom_ms *ms, int res_code,
uint8_t res_type, uint16_t param_len, const uint8_t *param_val);
int gsm_subscr_sapcard(struct osmocom_ms *ms);
diff --git a/src/host/layer23/src/common/settings.c
b/src/host/layer23/src/common/settings.c
index 986d551..89c6881 100644
--- a/src/host/layer23/src/common/settings.c
+++ b/src/host/layer23/src/common/settings.c
@@ -71,6 +71,7 @@
set->test_rplmn_mcc = set->test_rplmn_mnc = 1;
set->test_lac = 0x0000;
set->test_tmsi = GSM_RESERVED_TMSI;
+ set->test_ptmsi = GSM_RESERVED_TMSI;
/* set all supported features */
set->sms_ptp = sup->sms_ptp;
diff --git a/src/host/layer23/src/common/subscriber.c
b/src/host/layer23/src/common/subscriber.c
index 0669598..e5b1593 100644
--- a/src/host/layer23/src/common/subscriber.c
+++ b/src/host/layer23/src/common/subscriber.c
@@ -137,7 +137,7 @@
/* 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, uint8_t imsi_attached)
+ uint16_t lac, uint32_t tmsi, uint32_t ptmsi, uint8_t imsi_attached)
{
struct gsm_settings *set = &ms->settings;
struct gsm_subscriber *subscr = &ms->subscr;
@@ -174,7 +174,7 @@
subscr->mnc = mnc;
subscr->lac = lac;
subscr->tmsi = tmsi;
- subscr->ptmsi = GSM_RESERVED_TMSI;
+ subscr->ptmsi = ptmsi;
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);
diff --git a/src/host/layer23/src/common/vty.c b/src/host/layer23/src/common/vty.c
index 4f9aa20..331e0f1 100644
--- a/src/host/layer23/src/common/vty.c
+++ b/src/host/layer23/src/common/vty.c
@@ -488,6 +488,7 @@
/* Initial testcard settings */
uint16_t mcc = 0x001, mnc = 0x01f, lac = 0x0000;
uint32_t tmsi = GSM_RESERVED_TMSI;
+ uint32_t ptmsi = GSM_RESERVED_TMSI;
ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
@@ -509,6 +510,9 @@
if (set->test_tmsi != GSM_RESERVED_TMSI)
tmsi = set->test_tmsi;
+
+ if (set->test_ptmsi != GSM_RESERVED_TMSI)
+ ptmsi = set->test_ptmsi;
}
if (argc == 2) {
@@ -534,7 +538,10 @@
if (argc >= 5)
tmsi = strtoul(argv[4], NULL, 16);
- rc = gsm_subscr_testcard(ms, mcc, mnc, lac, tmsi, attached);
+ if (argc >= 6)
+ ptmsi = strtoul(argv[4], NULL, 16);
+
+ rc = gsm_subscr_testcard(ms, mcc, mnc, lac, tmsi, ptmsi, attached);
if (rc < 0) {
vty_out(vty, "Attach test SIM card failed: %d%s", rc, VTY_NEWLINE);
return CMD_WARNING;
@@ -544,22 +551,24 @@
}
DEFUN(sim_test, sim_test_cmd,
- "sim testcard MS_NAME [MCC] [MNC] [LAC] [TMSI]",
+ "sim testcard MS_NAME [MCC] [MNC] [LAC] [TMSI] [PTMSI]",
"SIM actions\nAttach built 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")
+ "Optionally set current assigned TMSI\n"
+ "Optionally set current assigned P-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 testcard MS_NAME MCC MNC LAC TMSI PTMSI attached",
"SIM actions\nAttach built 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")
+ "Set current assigned P-TMSI\n"
+ "Indicate to MM that card is already attached\n")
{
return _sim_test_cmd(vty, argc, argv, 1);
}
@@ -1083,6 +1092,11 @@
else
set->test_tmsi = GSM_RESERVED_TMSI;
+ if (argc >= 5)
+ set->test_ptmsi = strtoul(argv[4], NULL, 16);
+ else
+ set->test_ptmsi = GSM_RESERVED_TMSI;
+
if (attached)
set->test_imsi_attached = 1;
else
@@ -1094,19 +1108,21 @@
}
DEFUN(cfg_test_rplmn, cfg_test_rplmn_cmd,
- "rplmn MCC MNC [LAC] [TMSI]",
+ "rplmn MCC MNC [LAC] [TMSI] [PTMSI]",
"Set Registered PLMN\nMobile Country Code\nMobile Network Code\n"
"Optionally set location area code\n"
- "Optionally set current assigned TMSI")
+ "Optionally set current assigned TMSI\n"
+ "Optionally set current assigned P-TMSI\n")
{
return _test_rplmn_cmd(vty, argc, argv, 0);
}
DEFUN(cfg_test_rplmn_att, cfg_test_rplmn_att_cmd,
- "rplmn MCC MNC LAC TMSI attached",
+ "rplmn MCC MNC LAC TMSI PTMSI 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")
+ "Set current assigned P-TMSI\n"
+ "Indicate to MM that card is already attached\n")
{
return _test_rplmn_cmd(vty, argc, argv, 1);
}
@@ -1211,8 +1227,11 @@
vty_out(vty, " 0x%04x", set->test_lac);
if (set->test_tmsi != GSM_RESERVED_TMSI) {
vty_out(vty, " 0x%08x", set->test_tmsi);
- if (set->test_imsi_attached)
- vty_out(vty, " attached");
+ if (set->test_ptmsi != GSM_RESERVED_TMSI) {
+ vty_out(vty, " 0x%08x", set->test_ptmsi);
+ if (set->test_imsi_attached)
+ vty_out(vty, " attached");
+ }
}
}
vty_out(vty, "%s", VTY_NEWLINE);
diff --git a/src/host/layer23/src/mobile/app_mobile.c
b/src/host/layer23/src/mobile/app_mobile.c
index e7caed2..0eee50d 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -169,7 +169,7 @@
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_imsi_attached);
+ set->test_tmsi, set->test_ptmsi, set->test_imsi_attached);
break;
case GSM_SIM_TYPE_SAP:
gsm_subscr_sapcard(ms);
diff --git a/src/host/layer23/src/modem/app_modem.c
b/src/host/layer23/src/modem/app_modem.c
index b657d8c..da677a6 100644
--- a/src/host/layer23/src/modem/app_modem.c
+++ b/src/host/layer23/src/modem/app_modem.c
@@ -215,7 +215,7 @@
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_imsi_attached);
+ set->test_tmsi, set->test_ptmsi, set->test_imsi_attached);
break;
case GSM_SIM_TYPE_SAP:
gsm_subscr_sapcard(ms);
--
To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/32739
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I77d28534bd21327fbbec8f1544238703558245cb
Gerrit-Change-Number: 32739
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange