lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

May 2023

  • 1 participants
  • 2583 discussions
[S] Change in osmocom-bb[master]: layer23: modem: pass SIM-stored PTMSI (signature) & RAI to GMM
by pespin 25 May '23

25 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32804 ) Change subject: layer23: modem: pass SIM-stored PTMSI (signature) & RAI to GMM ...................................................................... layer23: modem: pass SIM-stored PTMSI (signature) & RAI to GMM Depends: libosmo-gprs.git Change-Id Ia69b6f885d612c42ab015822031e4c7262f4714e Change-Id: If0eef0a60b310539f2e668238314481ad5b7a5fa --- M src/host/layer23/src/modem/gmm.c M src/host/layer23/src/modem/sm.c 2 files changed, 14 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/src/host/layer23/src/modem/gmm.c b/src/host/layer23/src/modem/gmm.c index d3851e0..5445672 100644 --- a/src/host/layer23/src/modem/gmm.c +++ b/src/host/layer23/src/modem/gmm.c @@ -193,10 +193,12 @@ gmm_prim = osmo_gprs_gmm_prim_alloc_gmmreg_attach_req(); gmm_prim->gmmreg.attach_req.attach_type = OSMO_GPRS_GMM_ATTACH_TYPE_GPRS; gmm_prim->gmmreg.attach_req.ptmsi = subscr->gprs.ptmsi; + gmm_prim->gmmreg.attach_req.ptmsi_sig = subscr->gprs.ptmsi_sig; gmm_prim->gmmreg.attach_req.attach_with_imsi = (subscr->gprs.ptmsi == GSM_RESERVED_TMSI); memcpy(gmm_prim->gmmreg.attach_req.imsi, subscr->imsi, ARRAY_SIZE(subscr->imsi)); memcpy(gmm_prim->gmmreg.attach_req.imei, ms->settings.imei, ARRAY_SIZE(ms->settings.imei)); memcpy(gmm_prim->gmmreg.attach_req.imeisv, ms->settings.imeisv, ARRAY_SIZE(ms->settings.imeisv)); + memcpy(&gmm_prim->gmmreg.attach_req.old_rai, &subscr->gprs.rai, sizeof(subscr->gprs.rai)); rc = osmo_gprs_gmm_prim_upper_down(gmm_prim); if (rc < 0) LOGP(DMM, LOGL_ERROR, "Failed submitting GMMREG-ATTACH.req\n"); diff --git a/src/host/layer23/src/modem/sm.c b/src/host/layer23/src/modem/sm.c index e6591a9..9b3a35b 100644 --- a/src/host/layer23/src/modem/sm.c +++ b/src/host/layer23/src/modem/sm.c @@ -258,9 +258,11 @@ sm_prim->smreg.pdp_act_req.pco_len = apn->pdp.pco_len; OSMO_STRLCPY_ARRAY(sm_prim->smreg.pdp_act_req.apn, apn->cfg.name); sm_prim->smreg.pdp_act_req.gmm.ptmsi = subscr->gprs.ptmsi; + sm_prim->smreg.pdp_act_req.gmm.ptmsi_sig = subscr->gprs.ptmsi; OSMO_STRLCPY_ARRAY(sm_prim->smreg.pdp_act_req.gmm.imsi, subscr->imsi); OSMO_STRLCPY_ARRAY(sm_prim->smreg.pdp_act_req.gmm.imei, ms->settings.imei); OSMO_STRLCPY_ARRAY(sm_prim->smreg.pdp_act_req.gmm.imeisv, ms->settings.imeisv); + memcpy(&sm_prim->smreg.pdp_act_req.gmm.old_rai, &subscr->gprs.rai, sizeof(subscr->gprs.rai)); rc = osmo_gprs_sm_prim_upper_down(sm_prim); if (rc < 0) -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32804 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: If0eef0a60b310539f2e668238314481ad5b7a5fa Gerrit-Change-Number: 32804 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in osmocom-bb[master]: layer23: subscriber: Implement LOCIGPRS read/write for simcard backend
by pespin 25 May '23

25 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32765 ) Change subject: layer23: subscriber: Implement LOCIGPRS read/write for simcard backend ...................................................................... layer23: subscriber: Implement LOCIGPRS read/write for simcard backend Change-Id: Ida5bcfc896c75c238e2eb2d0aee742ae36fb5e16 --- M src/host/layer23/include/osmocom/bb/common/subscriber.h M src/host/layer23/src/common/subscriber.c M src/host/layer23/src/modem/gmm.c M src/host/layer23/src/modem/sm.c 4 files changed, 182 insertions(+), 12 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/src/host/layer23/include/osmocom/bb/common/subscriber.h b/src/host/layer23/include/osmocom/bb/common/subscriber.h index 792df62..232018d 100644 --- a/src/host/layer23/include/osmocom/bb/common/subscriber.h +++ b/src/host/layer23/include/osmocom/bb/common/subscriber.h @@ -6,6 +6,7 @@ #include <osmocom/core/utils.h> #include <osmocom/gsm/protocol/gsm_23_003.h> #include <osmocom/gsm/gsm23003.h> +#include <osmocom/gsm/gsm48.h> /* GSM 04.08 4.1.2.2 SIM update status */ enum gsm_sub_sim_ustate { @@ -20,6 +21,18 @@ return get_value_string(gsm_sub_sim_ustate_names, val); } +/* 3GPP TS 24.008 4.1.3.2 GPRS update status */ +enum gsm_sub_sim_gustate { + GSM_SIM_GU0_NULL, + GSM_SIM_GU1_UPDATED, + GSM_SIM_GU2_NOT_UPDATED, + GSM_SIM_GU3_ROAMING_NA, +}; +extern const struct value_string gsm_sub_sim_gustate_names[]; +static inline const char *gsm_sub_sim_gustate_name(enum gsm_sub_sim_gustate val) +{ + return get_value_string(gsm_sub_sim_gustate_names, val); +} struct gsm_sub_plmn_list { struct llist_head entry; @@ -58,7 +71,6 @@ /* TMSI / LAI */ uint32_t tmsi; /* invalid tmsi: GSM_RESERVED_TMSI */ - uint32_t ptmsi; /* invalid tmsi: GSM_RESERVED_TMSI */ struct osmo_location_area_id lai; /* invalid lac: 0x0000 */ @@ -97,6 +109,14 @@ /* SMS */ char sms_sca[22]; + + struct { + uint8_t gu_state; /* GU, TS 24.008 */ + struct gprs_ra_id rai; + uint32_t ptmsi; /* invalid tmsi: GSM_RESERVED_TMSI */ + uint32_t ptmsi_sig; /* P-TMSI signature, 3 bytes */ + bool imsi_attached; + } gprs; }; int gsm_subscr_init(struct osmocom_ms *ms); @@ -109,6 +129,7 @@ int gsm_subscr_sim_pin(struct osmocom_ms *ms, const char *pin1, const char *pin2, int8_t mode); int gsm_subscr_write_loci(struct osmocom_ms *ms); +int gsm_subscr_write_locigprs(struct osmocom_ms *ms); int gsm_subscr_generate_kc(struct osmocom_ms *ms, uint8_t key_seq, const uint8_t *rand, bool no_sim); void new_sim_ustate(struct gsm_subscriber *subscr, int state); diff --git a/src/host/layer23/src/common/subscriber.c b/src/host/layer23/src/common/subscriber.c index dfd44dc..b6fc74d 100644 --- a/src/host/layer23/src/common/subscriber.c +++ b/src/host/layer23/src/common/subscriber.c @@ -45,6 +45,14 @@ { 0, NULL } }; +const struct value_string gsm_sub_sim_gustate_names[] = { + { GSM_SIM_GU0_NULL, "GU0_NULL" }, + { GSM_SIM_GU1_UPDATED, "GU1_UPDATED" }, + { GSM_SIM_GU2_NOT_UPDATED, "GU2_NOT_UPDATED" }, + { GSM_SIM_GU3_ROAMING_NA, "GU3_ROAMING_NA" }, + { 0, NULL } +}; + static int gsm_subscr_insert_simcard(struct osmocom_ms *ms); static int gsm_subscr_insert_testcard(struct osmocom_ms *ms); static int gsm_subscr_insert_sapcard(struct osmocom_ms *ms); @@ -58,6 +66,8 @@ static int gsm_subscr_write_loci_simcard(struct osmocom_ms *ms); +static int gsm_subscr_write_locigprs_simcard(struct osmocom_ms *ms); + static int gsm_subscr_sim_pin_simcard(struct osmocom_ms *ms, const char *pin1, const char *pin2, int8_t mode); @@ -105,7 +115,7 @@ /* set TMSI / LAC invalid */ subscr->tmsi = GSM_RESERVED_TMSI; - subscr->ptmsi = GSM_RESERVED_TMSI; + subscr->gprs.ptmsi = GSM_RESERVED_TMSI; subscr->lai.lac = 0x0000; /* set key invalid */ @@ -305,6 +315,29 @@ } } +/* update LOCIGPRS on SIM */ +int gsm_subscr_write_locigprs(struct osmocom_ms *ms) +{ + struct gsm_subscriber *subscr = &ms->subscr; + + /* skip, if no real valid SIM */ + if (subscr->sim_type == GSM_SIM_TYPE_NONE || !subscr->sim_valid) + return 0; + + LOGP(DMM, LOGL_INFO, "Updating LOCIGPRS on SIM\n"); + + switch (subscr->sim_type) { + case GSM_SIM_TYPE_L1PHY: + case GSM_SIM_TYPE_SAP: + return gsm_subscr_write_locigprs_simcard(ms); + case GSM_SIM_TYPE_TEST: + LOGP(DMM, LOGL_NOTICE, "Updating LOCIGPRS on test SIM: not implemented!\n"); + return 0; /* TODO */ + default: + OSMO_ASSERT(0); + } +} + /* update plmn not allowed list on SIM */ static int subscr_write_plmn_na(struct osmocom_ms *ms) { @@ -444,20 +477,44 @@ if (subscr->sms_sca[0]) print(priv, " SMS Service Center Address: %s\n", subscr->sms_sca); + print(priv, " Status: %s IMSI %s", gsm_sub_sim_ustate_name(subscr->ustate), (subscr->imsi_attached) ? "attached" : "detached"); if (subscr->tmsi != GSM_RESERVED_TMSI) print(priv, " TMSI 0x%08x", subscr->tmsi); - if (subscr->ptmsi != GSM_RESERVED_TMSI) - print(priv, " P-TMSI 0x%08x", subscr->ptmsi); if (subscr->lai.lac > 0x0000 && subscr->lai.lac < 0xfffe) { print(priv, "\n"); print(priv, " LAI: %s (%s, %s)\n", osmo_lai_name(&subscr->lai), gsm_get_mcc(subscr->lai.plmn.mcc), gsm_get_mnc(&subscr->lai.plmn)); - } else + } else { print(priv, " LAI: invalid\n"); + } + + print(priv, " GPRS Status: %s IMSI %s", gsm_sub_sim_gustate_name(subscr->gprs.gu_state), + (subscr->gprs.imsi_attached) ? "attached" : "detached"); + if (subscr->gprs.ptmsi != GSM_RESERVED_TMSI) + print(priv, " PTMSI 0x%08x", subscr->tmsi); + if (subscr->gprs.ptmsi != GSM_RESERVED_TMSI) + print(priv, " PTMSI-sig 0x%06x", subscr->gprs.ptmsi_sig); + if (subscr->gprs.rai.lac > 0x0000 && subscr->gprs.rai.lac < 0xfffe) { + struct osmo_plmn_id plmn = { + .mcc = subscr->gprs.rai.mcc, + .mnc = subscr->gprs.rai.mnc, + .mnc_3_digits = subscr->gprs.rai.mnc_3_digits, + }; + print(priv, "\n"); + print(priv, " RAI: %s (%s, %s)\n", + osmo_rai_name(&subscr->gprs.rai), + gsm_get_mcc(plmn.mcc), + gsm_get_mnc(&plmn)); + } else { + print(priv, " RAI: invalid\n"); + } + + if (subscr->gprs.ptmsi != GSM_RESERVED_TMSI) + print(priv, " P-TMSI 0x%08x", subscr->gprs.ptmsi); if (subscr->key_seq != 7) { print(priv, " Key: sequence %d ", subscr->key_seq); for (i = 0; i < sizeof(subscr->key); i++) @@ -525,7 +582,7 @@ memcpy(&subscr->lai.plmn, &set->test_sim.rplmn, sizeof(struct osmo_plmn_id)); subscr->lai.lac = set->test_sim.lac; subscr->tmsi = set->test_sim.tmsi; - subscr->ptmsi = GSM_RESERVED_TMSI; + subscr->gprs.ptmsi = GSM_RESERVED_TMSI; subscr->always_search_hplmn = set->test_sim.always_search_hplmn; subscr->t6m_hplmn = 1; /* try to find home network every 6 min */ OSMO_STRLCPY_ARRAY(subscr->imsi, set->test_sim.imsi); @@ -666,6 +723,42 @@ return 0; } +static int subscr_sim_locigprs(struct osmocom_ms *ms, uint8_t *data, + uint8_t length) +{ + struct gsm_subscriber *subscr = &ms->subscr; + struct gsm1111_ef_locigprs *locigprs; + + if (length < 11) + return -EINVAL; + locigprs = (struct gsm1111_ef_locigprs *) data; + + /* P-TMSI, P-TMSI signature */ + subscr->gprs.ptmsi = ntohl(locigprs->ptmsi); + subscr->gprs.ptmsi_sig = (((uint32_t)locigprs->ptmsi_sig_hi) << 8) | locigprs->ptmsi_sig_lo; + + /* RAI */ + gsm48_parse_ra(&subscr->gprs.rai, (uint8_t *)&locigprs->rai); + + /* routing area update status */ + switch (locigprs->rau_status & 0x07) { + case GSM1111_EF_LOCIGPRS_RAU_ST_UPDATED: + subscr->gprs.gu_state = GSM_SIM_GU1_UPDATED; /* TODO: use proper enums here */ + break; + case GSM1111_EF_LOCIGPRS_RAU_ST_PLMN_NOT_ALLOWED: + case GSM1111_EF_LOCIGPRS_RAU_ST_RA_NOT_ALLOWED: + subscr->gprs.gu_state = GSM_SIM_GU3_ROAMING_NA; + break; + default: + subscr->gprs.gu_state = GSM_SIM_GU2_NOT_UPDATED; + } + + LOGP(DMM, LOGL_INFO, "received LOCIGPRS from SIM (RAI=%s %s)\n", + osmo_rai_name(&subscr->gprs.rai), gsm_sub_sim_gustate_name(subscr->gprs.gu_state)); + + return 0; +} + static int subscr_sim_msisdn(struct osmocom_ms *ms, uint8_t *data, uint8_t length) { @@ -885,6 +978,7 @@ { 1, { 0 }, 0x2fe2, SIM_JOB_READ_BINARY, subscr_sim_iccid }, { 1, { 0x7f20, 0 }, 0x6f07, SIM_JOB_READ_BINARY, subscr_sim_imsi }, { 1, { 0x7f20, 0 }, 0x6f7e, SIM_JOB_READ_BINARY, subscr_sim_loci }, + { 1, { 0x7f20, 0 }, 0x6f53, SIM_JOB_READ_BINARY, subscr_sim_locigprs }, { 0, { 0x7f20, 0 }, 0x6f20, SIM_JOB_READ_BINARY, subscr_sim_kc }, { 0, { 0x7f20, 0 }, 0x6f30, SIM_JOB_READ_BINARY, subscr_sim_plmnsel }, { 0, { 0x7f20, 0 }, 0x6f31, SIM_JOB_READ_BINARY, subscr_sim_hpplmn }, @@ -1200,6 +1294,52 @@ return 0; } +/* update LOCIGPRS on SIM */ +int gsm_subscr_write_locigprs_simcard(struct osmocom_ms *ms) +{ + struct gsm_subscriber *subscr = &ms->subscr; + struct msgb *nmsg; + struct sim_hdr *nsh; + struct gsm1111_ef_locigprs *locigprs; + + LOGP(DMM, LOGL_INFO, "Updating LOCI on SIM\n"); + + /* write to SIM */ + nmsg = gsm_sim_msgb_alloc(subscr->sim_handle_update, + SIM_JOB_UPDATE_BINARY); + if (!nmsg) + return -ENOMEM; + nsh = (struct sim_hdr *) nmsg->data; + nsh->path[0] = 0x7f20; + nsh->path[1] = 0; + nsh->file = 0x6f53; + locigprs = (struct gsm1111_ef_locigprs *)msgb_put(nmsg, sizeof(*locigprs)); + + /* P-TMSI, P-TMSI signature */ + locigprs->ptmsi = htonl(subscr->gprs.ptmsi); + locigprs->ptmsi_sig_hi = htonl(subscr->gprs.ptmsi) >> 8; + locigprs->ptmsi_sig_lo = htonl(subscr->gprs.ptmsi) & 0xff; + + /* RAI */ + gsm48_encode_ra(&locigprs->rai, &subscr->gprs.rai); + + /* location update status */ + switch (subscr->gprs.gu_state) { + case GSM_SIM_GU1_UPDATED: + locigprs->rau_status = GSM1111_EF_LOCIGPRS_RAU_ST_UPDATED; + break; + case GSM_SIM_GU3_ROAMING_NA: + locigprs->rau_status = GSM1111_EF_LOCIGPRS_RAU_ST_RA_NOT_ALLOWED; + break; + default: + locigprs->rau_status = GSM1111_EF_LOCIGPRS_RAU_ST_NOT_UPDATED; + } + + sim_job(ms, nmsg); + + return 0; +} + static void subscr_sim_update_cb(struct osmocom_ms *ms, struct msgb *msg) { struct sim_hdr *sh = (struct sim_hdr *) msg->data; diff --git a/src/host/layer23/src/modem/gmm.c b/src/host/layer23/src/modem/gmm.c index dbdf82e..d3851e0 100644 --- a/src/host/layer23/src/modem/gmm.c +++ b/src/host/layer23/src/modem/gmm.c @@ -61,7 +61,7 @@ if (gmm_prim->gmmreg.attach_cnf.accepted) { LOGP(DGMM, LOGL_NOTICE, "%s(): Rx %s: Attach success P-TMSI=0x%08x\n", __func__, pdu_name, gmm_prim->gmmreg.attach_cnf.acc.allocated_ptmsi); - ms->subscr.ptmsi = gmm_prim->gmmreg.attach_cnf.acc.allocated_ptmsi; + ms->subscr.gprs.ptmsi = gmm_prim->gmmreg.attach_cnf.acc.allocated_ptmsi; ms->gmmlayer.tlli = gmm_prim->gmmreg.attach_cnf.acc.allocated_tlli; app_data.modem_state = MODEM_ST_ATTACHED; /* Activate APN if not yet already: */ @@ -192,8 +192,8 @@ gmm_prim = osmo_gprs_gmm_prim_alloc_gmmreg_attach_req(); gmm_prim->gmmreg.attach_req.attach_type = OSMO_GPRS_GMM_ATTACH_TYPE_GPRS; - gmm_prim->gmmreg.attach_req.ptmsi = subscr->ptmsi; - gmm_prim->gmmreg.attach_req.attach_with_imsi = (subscr->ptmsi == GSM_RESERVED_TMSI); + gmm_prim->gmmreg.attach_req.ptmsi = subscr->gprs.ptmsi; + gmm_prim->gmmreg.attach_req.attach_with_imsi = (subscr->gprs.ptmsi == GSM_RESERVED_TMSI); memcpy(gmm_prim->gmmreg.attach_req.imsi, subscr->imsi, ARRAY_SIZE(subscr->imsi)); memcpy(gmm_prim->gmmreg.attach_req.imei, ms->settings.imei, ARRAY_SIZE(ms->settings.imei)); memcpy(gmm_prim->gmmreg.attach_req.imeisv, ms->settings.imeisv, ARRAY_SIZE(ms->settings.imeisv)); @@ -210,7 +210,7 @@ int rc; gmm_prim = osmo_gprs_gmm_prim_alloc_gmmreg_detach_req(); - gmm_prim->gmmreg.detach_req.ptmsi = subscr->ptmsi; + gmm_prim->gmmreg.detach_req.ptmsi = subscr->gprs.ptmsi; gmm_prim->gmmreg.detach_req.detach_type = OSMO_GPRS_GMM_DETACH_MS_TYPE_GPRS; gmm_prim->gmmreg.detach_req.poweroff_type = OSMO_GPRS_GMM_DETACH_POWEROFF_TYPE_NORMAL; rc = osmo_gprs_gmm_prim_upper_down(gmm_prim); diff --git a/src/host/layer23/src/modem/sm.c b/src/host/layer23/src/modem/sm.c index 9724773..e6591a9 100644 --- a/src/host/layer23/src/modem/sm.c +++ b/src/host/layer23/src/modem/sm.c @@ -76,7 +76,7 @@ return 0; } - ms->subscr.ptmsi = sm_prim->smreg.pdp_act_cnf.acc.gmm.allocated_ptmsi; + ms->subscr.gprs.ptmsi = sm_prim->smreg.pdp_act_cnf.acc.gmm.allocated_ptmsi; ms->gmmlayer.tlli = sm_prim->smreg.pdp_act_cnf.acc.gmm.allocated_tlli; netdev = osmo_tundev_get_netdev(apn->tun); @@ -257,7 +257,7 @@ memcpy(sm_prim->smreg.pdp_act_req.pco, apn->pdp.pco, apn->pdp.pco_len); sm_prim->smreg.pdp_act_req.pco_len = apn->pdp.pco_len; OSMO_STRLCPY_ARRAY(sm_prim->smreg.pdp_act_req.apn, apn->cfg.name); - sm_prim->smreg.pdp_act_req.gmm.ptmsi = subscr->ptmsi; + sm_prim->smreg.pdp_act_req.gmm.ptmsi = subscr->gprs.ptmsi; OSMO_STRLCPY_ARRAY(sm_prim->smreg.pdp_act_req.gmm.imsi, subscr->imsi); OSMO_STRLCPY_ARRAY(sm_prim->smreg.pdp_act_req.gmm.imei, ms->settings.imei); OSMO_STRLCPY_ARRAY(sm_prim->smreg.pdp_act_req.gmm.imeisv, ms->settings.imeisv); -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32765 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ida5bcfc896c75c238e2eb2d0aee742ae36fb5e16 Gerrit-Change-Number: 32765 Gerrit-PatchSet: 4 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in osmocom-bb[master]: layer23: subscriber: Implement LOCIGPRS read/write for testcard backend
by pespin 25 May '23

25 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32800 ) Change subject: layer23: subscriber: Implement LOCIGPRS read/write for testcard backend ...................................................................... layer23: subscriber: Implement LOCIGPRS read/write for testcard backend Change-Id: Ibcaaf430587a3a270398e9a9eeab6ee98514c3c8 --- M src/host/layer23/include/osmocom/bb/common/settings.h M src/host/layer23/include/osmocom/bb/common/sim.h M src/host/layer23/include/osmocom/bb/common/subscriber.h M src/host/layer23/src/common/subscriber.c M src/host/layer23/src/common/vty.c 5 files changed, 216 insertions(+), 5 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/src/host/layer23/include/osmocom/bb/common/settings.h b/src/host/layer23/include/osmocom/bb/common/settings.h index f24b006..56475e3 100644 --- a/src/host/layer23/include/osmocom/bb/common/settings.h +++ b/src/host/layer23/include/osmocom/bb/common/settings.h @@ -5,6 +5,9 @@ #include <osmocom/core/linuxlist.h> #include <osmocom/gsm/protocol/gsm_23_003.h> #include <osmocom/gsm/gsm23003.h> +#include <osmocom/gsm/gsm48.h> + +#include <osmocom/bb/common/sim.h> struct osmocom_ms; struct osmobb_apn; @@ -69,6 +72,14 @@ uint16_t lac; bool imsi_attached; bool always_search_hplmn; + struct { + bool valid; + uint32_t ptmsi; /* invalid tmsi: GSM_RESERVED_TMSI */ + uint32_t ptmsi_sig; /* P-TMSI signature, 3 bytes */ + struct gprs_ra_id rai; + enum gsm1111_ef_locigprs_rau_status gu_state; /* GU, TS 24.008 */ + bool imsi_attached; + } locigprs; }; struct gsm_settings { diff --git a/src/host/layer23/include/osmocom/bb/common/sim.h b/src/host/layer23/include/osmocom/bb/common/sim.h index 8d934d6..8aae1fc 100644 --- a/src/host/layer23/include/osmocom/bb/common/sim.h +++ b/src/host/layer23/include/osmocom/bb/common/sim.h @@ -20,6 +20,8 @@ #include <osmocom/gsm/protocol/gsm_04_08.h> #include <osmocom/core/endian.h> +struct osmocom_ms; + /* 9.2 commands */ #define GSM1111_CLASS_GSM 0xa0 #define GSM1111_INST_SELECT 0xa4 diff --git a/src/host/layer23/include/osmocom/bb/common/subscriber.h b/src/host/layer23/include/osmocom/bb/common/subscriber.h index 232018d..d36b4c6 100644 --- a/src/host/layer23/include/osmocom/bb/common/subscriber.h +++ b/src/host/layer23/include/osmocom/bb/common/subscriber.h @@ -112,6 +112,7 @@ struct { uint8_t gu_state; /* GU, TS 24.008 */ + bool rai_valid; struct gprs_ra_id rai; uint32_t ptmsi; /* invalid tmsi: GSM_RESERVED_TMSI */ uint32_t ptmsi_sig; /* P-TMSI signature, 3 bytes */ diff --git a/src/host/layer23/src/common/subscriber.c b/src/host/layer23/src/common/subscriber.c index b6fc74d..b4213c8 100644 --- a/src/host/layer23/src/common/subscriber.c +++ b/src/host/layer23/src/common/subscriber.c @@ -67,6 +67,7 @@ static int gsm_subscr_write_loci_simcard(struct osmocom_ms *ms); static int gsm_subscr_write_locigprs_simcard(struct osmocom_ms *ms); +static int gsm_subscr_write_locigprs_testcard(struct osmocom_ms *ms); static int gsm_subscr_sim_pin_simcard(struct osmocom_ms *ms, const char *pin1, const char *pin2, int8_t mode); @@ -331,8 +332,7 @@ case GSM_SIM_TYPE_SAP: return gsm_subscr_write_locigprs_simcard(ms); case GSM_SIM_TYPE_TEST: - LOGP(DMM, LOGL_NOTICE, "Updating LOCIGPRS on test SIM: not implemented!\n"); - return 0; /* TODO */ + return gsm_subscr_write_locigprs_testcard(ms); default: OSMO_ASSERT(0); } @@ -582,7 +582,6 @@ memcpy(&subscr->lai.plmn, &set->test_sim.rplmn, sizeof(struct osmo_plmn_id)); subscr->lai.lac = set->test_sim.lac; subscr->tmsi = set->test_sim.tmsi; - subscr->gprs.ptmsi = GSM_RESERVED_TMSI; subscr->always_search_hplmn = set->test_sim.always_search_hplmn; subscr->t6m_hplmn = 1; /* try to find home network every 6 min */ OSMO_STRLCPY_ARRAY(subscr->imsi, set->test_sim.imsi); @@ -592,13 +591,25 @@ else subscr->ustate = GSM_SIM_U2_NOT_UPDATED; - LOGP(DMM, LOGL_INFO, "(ms %s) Inserting test card (IMSI=%s %s, %s)\n", + /* GPRS related: */ + subscr->gprs.ptmsi = set->test_sim.locigprs.ptmsi; + subscr->gprs.ptmsi_sig = set->test_sim.locigprs.ptmsi_sig; + subscr->gprs.imsi_attached = set->test_sim.locigprs.imsi_attached; + subscr->gprs.rai_valid = set->test_sim.locigprs.valid; + memcpy(&subscr->gprs.rai, &set->test_sim.locigprs.rai, sizeof(subscr->gprs.rai)); + + if (subscr->gprs.imsi_attached && subscr->gprs.rai_valid) + subscr->ustate = GSM_SIM_U1_UPDATED; + else + subscr->ustate = GSM_SIM_U2_NOT_UPDATED; + + LOGP(DMM, LOGL_INFO, "(ms %s) Inserting test card (IMSI=%s, %s, %s)\n", ms->name, subscr->imsi, gsm_imsi_mcc(subscr->imsi), gsm_imsi_mnc(subscr->imsi)); if (subscr->plmn_valid) LOGP(DMM, LOGL_INFO, "-> Test card registered to %s" - "(%s, %s)\n", osmo_lai_name(&subscr->lai), + " (%s, %s)\n", osmo_lai_name(&subscr->lai), gsm_get_mcc(subscr->lai.plmn.mcc), gsm_get_mnc(&subscr->lai.plmn)); else @@ -606,6 +617,16 @@ if (subscr->imsi_attached) LOGP(DMM, LOGL_INFO, "-> Test card attached\n"); + + /* GPRS:*/ + if (subscr->gprs.rai_valid) + LOGP(DMM, LOGL_INFO, "-> Test card GPRS registered to %s\n", + osmo_rai_name(&subscr->gprs.rai)); + else + LOGP(DMM, LOGL_INFO, "-> Test card not GPRS registered\n"); + if (subscr->gprs.imsi_attached) + LOGP(DMM, LOGL_INFO, "-> Test card GPRS attached\n"); + /* insert card */ osmo_signal_dispatch(SS_L23_SUBSCR, S_L23_SUBSCR_SIM_ATTACHED, ms); return 0; @@ -642,6 +663,56 @@ return 0; } +/* update LOCIGPRS on test SIM */ +int gsm_subscr_write_locigprs_testcard(struct osmocom_ms *ms) +{ + struct gsm_subscriber *subscr = &ms->subscr; + struct msgb *nmsg; + struct sim_hdr *nsh; + struct gsm1111_ef_locigprs *locigprs; + + /* skip, if no real valid SIM */ + if (!GSM_SIM_IS_READER(subscr->sim_type) || !subscr->sim_valid) + return 0; + + LOGP(DMM, LOGL_INFO, "Updating LOCI on SIM\n"); + + /* write to SIM */ + nmsg = gsm_sim_msgb_alloc(subscr->sim_handle_update, + SIM_JOB_UPDATE_BINARY); + if (!nmsg) + return -ENOMEM; + nsh = (struct sim_hdr *) nmsg->data; + nsh->path[0] = 0x7f20; + nsh->path[1] = 0; + nsh->file = 0x6f53; + locigprs = (struct gsm1111_ef_locigprs *)msgb_put(nmsg, sizeof(*locigprs)); + + /* P-TMSI, P-TMSI signature */ + locigprs->ptmsi = htonl(subscr->gprs.ptmsi); + locigprs->ptmsi_sig_hi = htonl(subscr->gprs.ptmsi) >> 8; + locigprs->ptmsi_sig_lo = htonl(subscr->gprs.ptmsi) & 0xff; + + /* RAI */ + gsm48_encode_ra(&locigprs->rai, &subscr->gprs.rai); + + /* location update status */ + switch (subscr->gprs.gu_state) { + case GSM_SIM_GU1_UPDATED: + locigprs->rau_status = GSM1111_EF_LOCIGPRS_RAU_ST_UPDATED; + break; + case GSM_SIM_GU3_ROAMING_NA: + locigprs->rau_status = GSM1111_EF_LOCIGPRS_RAU_ST_RA_NOT_ALLOWED; + break; + default: + locigprs->rau_status = GSM1111_EF_LOCIGPRS_RAU_ST_NOT_UPDATED; + } + + sim_job(ms, nmsg); + + return 0; +} + /******************** * simcard backend ********************/ @@ -738,6 +809,7 @@ subscr->gprs.ptmsi_sig = (((uint32_t)locigprs->ptmsi_sig_hi) << 8) | locigprs->ptmsi_sig_lo; /* RAI */ + subscr->gprs.rai_valid = true; gsm48_parse_ra(&subscr->gprs.rai, (uint8_t *)&locigprs->rai); /* routing area update status */ diff --git a/src/host/layer23/src/common/vty.c b/src/host/layer23/src/common/vty.c index 44fc053..526db6f 100644 --- a/src/host/layer23/src/common/vty.c +++ b/src/host/layer23/src/common/vty.c @@ -1127,6 +1127,95 @@ return CMD_SUCCESS; } +static int _testsim_locigprs_cmd(struct vty *vty, int argc, const char *argv[], bool attached) +{ + struct osmocom_ms *ms = vty->index; + struct gsm_settings *set = &ms->settings; + struct osmo_plmn_id plmn; + + if (osmo_mcc_from_str(argv[0], &plmn.mcc) < 0) { + vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + if (osmo_mnc_from_str(argv[1], &plmn.mnc, &plmn.mnc_3_digits) < 0) { + vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + set->test_sim.locigprs.valid = true; + set->test_sim.locigprs.rai.mcc = plmn.mcc; + set->test_sim.locigprs.rai.mnc = plmn.mnc; + set->test_sim.locigprs.rai.mnc_3_digits = plmn.mnc_3_digits; + + if (argc >= 3) + set->test_sim.locigprs.rai.lac = strtoul(argv[2], NULL, 16); + else + set->test_sim.locigprs.rai.lac = 0xfffe; + + if (argc >= 4) + set->test_sim.locigprs.rai.rac = strtoul(argv[3], NULL, 16); + else + set->test_sim.locigprs.rai.rac = 0xff; + + if (argc >= 5) + set->test_sim.locigprs.ptmsi = strtoul(argv[4], NULL, 16); + else + set->test_sim.locigprs.ptmsi = GSM_RESERVED_TMSI; + + if (argc >= 6) + set->test_sim.locigprs.ptmsi_sig = strtoul(argv[5], NULL, 16); + else + set->test_sim.locigprs.ptmsi_sig = GSM_RESERVED_TMSI; + + set->test_sim.locigprs.imsi_attached = attached; + + l23_vty_restart_required_warn(vty, ms); + + return CMD_SUCCESS; +} + +DEFUN(cfg_testsim_no_locigprs, cfg_testsim_no_locigprs_cmd, "no locigprs", + NO_STR "Unset EF LOCIgprs\n") +{ + struct osmocom_ms *ms = vty->index; + struct gsm_settings *set = &ms->settings; + + set->test_sim.locigprs.valid = false; + set->test_sim.locigprs.ptmsi = GSM_RESERVED_TMSI; + set->test_sim.locigprs.ptmsi_sig = GSM_RESERVED_TMSI; + set->test_sim.locigprs.rai.mcc = 1; + set->test_sim.locigprs.rai.mnc = 1; + set->test_sim.locigprs.rai.mnc_3_digits = false; + set->test_sim.locigprs.rai.lac = 0x0000; + set->test_sim.locigprs.rai.rac = 0x0000; + + l23_vty_restart_required_warn(vty, ms); + + return CMD_SUCCESS; +} + +DEFUN(cfg_testsim_locigprs, cfg_testsim_locigprs_cmd, + "locigprs MCC MNC [LAC] [RAC] [PTMSI] [PTMSISIG]", + "Set EF LOCIgprs\nMobile Country Code\nMobile Network Code\n" + "Optionally set location area code\n" + "Optionally set routing area code\n" + "Optionally set current assigned P-TMSI\n" + "Optionally set current assigned P-TMSI signature\n") +{ + return _testsim_locigprs_cmd(vty, argc, argv, false); +} + +DEFUN(cfg_testsim_locigprs_att, cfg_testsim_locigprs_att_cmd, + "locigprs MCC MNC LAC RAC PTMSI PTMSISIG attached", + "Set EF LOCIgprs\nMobile Country Code\nMobile Network Code\n" + "Set location area code\n" + "Set routing area code\n" + "Set current assigned P-TMSI\n" + "Set current assigned P-TMSI signature\n" + "Indicate to MM that card is already attached\n") +{ + return _testsim_locigprs_cmd(vty, argc, argv, true); +} + static int l23_vty_config_write_gsmtap_node(struct vty *vty) { const char *chan_buf; @@ -1213,10 +1302,34 @@ } else if (!l23_vty_hide_default) vty_out(vty, "%s no rplmn%s", prefix, VTY_NEWLINE); + if (!l23_vty_hide_default || set->test_sim.always_search_hplmn) vty_out(vty, "%s hplmn-search %s%s", prefix, set->test_sim.always_search_hplmn ? "everywhere" : "foreign-country", VTY_NEWLINE); + + if (set->test_sim.locigprs.valid) { + vty_out(vty, "%s locigprs %s %s", prefix, + osmo_mcc_name(set->test_sim.locigprs.rai.mcc), + osmo_mnc_name(set->test_sim.locigprs.rai.mnc, + set->test_sim.locigprs.rai.mnc_3_digits)); + if (set->test_sim.locigprs.rai.lac > 0x0000 && set->test_sim.locigprs.rai.lac < 0xfffe) { + vty_out(vty, " 0x%04x", set->test_sim.locigprs.rai.lac); + if (set->test_sim.locigprs.rai.rac < 0xff) { + vty_out(vty, " 0x%02x", set->test_sim.locigprs.rai.rac); + if (set->test_sim.locigprs.ptmsi != GSM_RESERVED_TMSI) { + vty_out(vty, " 0x%08x 0x%06x", + set->test_sim.locigprs.ptmsi, + set->test_sim.locigprs.ptmsi_sig); + if (set->test_sim.locigprs.imsi_attached) + vty_out(vty, " attached"); + } + } + } + vty_out(vty, "%s", VTY_NEWLINE); + } else + if (!l23_vty_hide_default) + vty_out(vty, "%s no locigprs%s", prefix, VTY_NEWLINE); return CMD_SUCCESS; } @@ -1368,6 +1481,9 @@ install_element(TESTSIM_NODE, &cfg_testsim_rplmn_cmd); install_element(TESTSIM_NODE, &cfg_testsim_rplmn_att_cmd); install_element(TESTSIM_NODE, &cfg_testsim_hplmn_cmd); + install_element(TESTSIM_NODE, &cfg_testsim_no_locigprs_cmd); + install_element(TESTSIM_NODE, &cfg_testsim_locigprs_cmd); + install_element(TESTSIM_NODE, &cfg_testsim_locigprs_att_cmd); install_element(MS_NODE, &cfg_ms_shutdown_cmd); install_element(MS_NODE, &cfg_ms_shutdown_force_cmd); install_element(MS_NODE, &cfg_ms_no_shutdown_cmd); -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32800 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ibcaaf430587a3a270398e9a9eeab6ee98514c3c8 Gerrit-Change-Number: 32800 Gerrit-PatchSet: 5 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in osmocom-bb[master]: layer23: modem: pass SIM-stored PTMSI (signature) & RAI to GMM
by pespin 25 May '23

25 May '23
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32804 ) Change subject: layer23: modem: pass SIM-stored PTMSI (signature) & RAI to GMM ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32804 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: If0eef0a60b310539f2e668238314481ad5b7a5fa Gerrit-Change-Number: 32804 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Thu, 25 May 2023 09:00:12 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in osmocom-bb[master]: layer23: subscriber: Implement LOCIGPRS read/write for testcard backend
by pespin 25 May '23

25 May '23
Attention is currently required from: fixeria, dexter. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32800 ) Change subject: layer23: subscriber: Implement LOCIGPRS read/write for testcard backend ...................................................................... Patch Set 5: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32800 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ibcaaf430587a3a270398e9a9eeab6ee98514c3c8 Gerrit-Change-Number: 32800 Gerrit-PatchSet: 5 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Thu, 25 May 2023 09:00:07 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in osmocom-bb[master]: layer23: subscriber: Implement LOCIGPRS read/write for simcard backend
by pespin 25 May '23

25 May '23
Attention is currently required from: fixeria, dexter. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32765 ) Change subject: layer23: subscriber: Implement LOCIGPRS read/write for simcard backend ...................................................................... Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32765 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ida5bcfc896c75c238e2eb2d0aee742ae36fb5e16 Gerrit-Change-Number: 32765 Gerrit-PatchSet: 4 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Thu, 25 May 2023 09:00:05 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in libosmo-gprs[master]: gmm: Initial implementation of T3312
by pespin 25 May '23

25 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32910 ) Change subject: gmm: Initial implementation of T3312 ...................................................................... gmm: Initial implementation of T3312 The RAU procedure triggered by T3312 expiration will be implemented in a follow-up patch. Change-Id: If1ca164b7a6c7f7750e2e2f0812d6fde828ed4a4 --- M include/osmocom/gprs/gmm/gmm_private.h M src/gmm/gmm.c M src/gmm/gmm_ms_fsm.c 3 files changed, 86 insertions(+), 10 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/include/osmocom/gprs/gmm/gmm_private.h b/include/osmocom/gprs/gmm/gmm_private.h index 0ae4df4..daa967f 100644 --- a/include/osmocom/gprs/gmm/gmm_private.h +++ b/include/osmocom/gprs/gmm/gmm_private.h @@ -66,7 +66,6 @@ char imei[GSM23003_IMEI_NUM_DIGITS + 1]; char imeisv[GSM23003_IMEISV_NUM_DIGITS+1]; - uint8_t ra_upd_timer; /* TS 24.008 10.5.7.3 */ uint8_t radio_prio; /* TS 24.008 10.5.7.2 */ struct gprs_ra_id ra; /* TS 24.008 10.5.5.15 (decoded) */ @@ -87,6 +86,8 @@ /* READY timer, TS 24.008 4.7.2.1.1 */ struct osmo_timer_list t3314; unsigned long t3314_assigned_sec; /* value assigned by the network */ + struct osmo_timer_list t3312; /* periodic RAU, in seconds */ + unsigned long t3312_assigned_sec; /* value assigned by the network */ }; /* gmm_prim.c: */ @@ -116,6 +117,8 @@ void gprs_gmm_gmme_ready_timer_start(struct gprs_gmm_entity *gmme); void gprs_gmm_gmme_ready_timer_stop(struct gprs_gmm_entity *gmme); bool gprs_gmm_gmme_ready_timer_running(const struct gprs_gmm_entity *gmme); +void gprs_gmm_gmme_t3312_start(struct gprs_gmm_entity *gmme); +void gprs_gmm_gmme_t3312_stop(struct gprs_gmm_entity *gmme); int gprs_gmm_rx(struct gprs_gmm_entity *gmme, struct gsm48_hdr *gh, unsigned int len); int gprs_gmm_tx_att_req(struct gprs_gmm_entity *gmme, enum osmo_gprs_gmm_attach_type attach_type, diff --git a/src/gmm/gmm.c b/src/gmm/gmm.c index 5a3b0c0..6184a01 100644 --- a/src/gmm/gmm.c +++ b/src/gmm/gmm.c @@ -79,6 +79,7 @@ }; static void t3314_ready_timer_cb(void *data); +static void t3312_periodic_rau_timer_cb(void *data); static void gprs_gmm_ctx_free(void) { @@ -176,6 +177,7 @@ gmme->t3346 = osmo_tdef_get(g_gmm_ctx->T_defs, 3346, OSMO_TDEF_S, -1); osmo_timer_setup(&gmme->t3314, t3314_ready_timer_cb, gmme); + osmo_timer_setup(&gmme->t3312, t3312_periodic_rau_timer_cb, gmme); llist_add(&gmme->list, &g_gmm_ctx->gmme_list); @@ -190,6 +192,8 @@ LOGGMME(gmme, LOGL_DEBUG, "free()\n"); if (osmo_timer_pending(&gmme->t3314)) osmo_timer_del(&gmme->t3314); + if (osmo_timer_pending(&gmme->t3312)) + osmo_timer_del(&gmme->t3312); gprs_gmm_ms_fsm_ctx_release(&gmme->ms_fsm); llist_del(&gmme->list); talloc_free(gmme); @@ -295,20 +299,23 @@ LOGGMME(gmme, LOGL_INFO, "READY timer started\n"); osmo_timer_schedule(&gmme->t3314, gmme->t3314_assigned_sec, 0); - /* TODO: "Timer T3312 is stopped and shall be set to its initial value - * for the next start when the READY timer is started." */ + /* "Timer T3312 is stopped and shall be set to its initial value + * for the next start when the READY timer is started.": */ + gprs_gmm_gmme_t3312_stop(gmme); } /* Ready timer is stopped: */ void gprs_gmm_gmme_ready_timer_stop(struct gprs_gmm_entity *gmme) { - /* TODO: "In A/Gb mode, the timer T3312 is reset and started with its - * initial value, when the READY timer is stopped or expires." - */ if (!osmo_timer_pending(&gmme->t3314)) return; LOGGMME(gmme, LOGL_INFO, "READY timer stopped\n"); osmo_timer_del(&gmme->t3314); + + /* "In A/Gb mode, the timer T3312 is reset and started with its + * initial value, when the READY timer is stopped or expires." + */ + gprs_gmm_gmme_t3312_start(gmme); } bool gprs_gmm_gmme_ready_timer_running(const struct gprs_gmm_entity *gmme) @@ -325,10 +332,54 @@ struct gprs_gmm_entity *gmme = (struct gprs_gmm_entity *)data; LOGGMME(gmme, LOGL_INFO, "READY timer expired\n"); - /* TODO: "In A/Gb mode, the timer T3312 is reset and started with its - *initial value, when the READY timer is stopped or expires." + /* "In A/Gb mode, the timer T3312 is reset and started with its + * initial value, when the READY timer is stopped or expires.": */ + gprs_gmm_gmme_t3312_start(gmme); +} +/* T3312 (Periodic RAU) is started: */ +void gprs_gmm_gmme_t3312_start(struct gprs_gmm_entity *gmme) +{ + unsigned long t3312_sec; + + t3312_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3312, OSMO_TDEF_S, -1); + if (t3312_sec == 0) + return; + + LOGGMME(gmme, LOGL_INFO, "T3312 started\n"); + osmo_timer_schedule(&gmme->t3312, t3312_sec, 0); +} + +/* T3312 (Periodic RAU) is stopped: */ +void gprs_gmm_gmme_t3312_stop(struct gprs_gmm_entity *gmme) +{ + if (!osmo_timer_pending(&gmme->t3312)) + return; + + LOGGMME(gmme, LOGL_INFO, "T3312 stopped\n"); + osmo_timer_del(&gmme->t3312); +} + +/* T3312 (Periodic RAU) timer expiration: */ +static void t3312_periodic_rau_timer_cb(void *data) +{ + struct gprs_gmm_entity *gmme = (struct gprs_gmm_entity *)data; + LOGGMME(gmme, LOGL_INFO, "T3312 Periodic RAU timer expired\n"); + + /* TODO: + * - "Initiation of the Periodic RAU procedure if the MS is not + * attached for emergency bearer services or T3323 started under the + * conditions as specified in subclause 4.7.2.2. + * - Implicit detach from network if the MS is attached for emergency + * bearer services." + * - "If the MS is in a state other than GMM-REGISTERED.NORMAL-SERVICE + * when timer T3312 expires, the periodic routing area updating procedure + * is delayed until the MS returns to GMM-REGISTERED.NORMAL-SERVICE." + * "If timer T3323 expires, the MS shall memorize that it has to initiate a + * routing area updating procedure when it returns to state + * GMM-REGISTERED.NORMAL-SERVICE." + */ } int gprs_gmm_submit_gmmreg_attach_cnf(struct gprs_gmm_entity *gmme, bool accepted, uint8_t cause) @@ -595,6 +646,7 @@ struct gsm48_attach_ack *aa; struct tlv_parsed tp; int rc; + int periodic_rau_sec; if (len < sizeof(*gh) + sizeof(*aa)) { LOGGMME(gmme, LOGL_ERROR, "Rx GMM ATTACH ACCEPT with wrong size %u\n", len); @@ -604,8 +656,11 @@ LOGGMME(gmme, LOGL_INFO, "Rx GMM ATTACH ACCEPT\n"); aa = (struct gsm48_attach_ack *)&gh->data[0]; - gmme->ra_upd_timer = aa->ra_upd_timer; + periodic_rau_sec = gprs_gmm_gprs_tmr_to_secs(aa->ra_upd_timer); gmme->radio_prio = aa->radio_prio; + gmme->t3312_assigned_sec = periodic_rau_sec >= 0 ? periodic_rau_sec : 0; + if (gmme->t3312_assigned_sec == 0) + gprs_gmm_gmme_t3312_stop(gmme); gsm48_parse_ra(&gmme->ra, (const uint8_t *)&aa->ra_id); if (len > sizeof(*gh) + sizeof(*aa)) { @@ -632,8 +687,13 @@ gmme->t3314_assigned_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3314, OSMO_TDEF_S, -1); } /* "If the negotiated READY timer value is set to zero, the READY timer shall be stopped immediately": */ - if (gmme->t3314_assigned_sec == 0) + if (gmme->t3314_assigned_sec == 0) { gprs_gmm_gmme_ready_timer_stop(gmme); + /* "If after a READY timer negotiation the READY timer + * value is set to zero, timer T3312 is reset and started + * with its initial value." */ + gprs_gmm_gmme_t3312_start(gmme); + } if (TLVP_PRESENT(&tp, GSM48_IE_GMM_ALLOC_PTMSI)) { struct osmo_mobile_identity mi; diff --git a/src/gmm/gmm_ms_fsm.c b/src/gmm/gmm_ms_fsm.c index fcaf0d6..889d82a 100644 --- a/src/gmm/gmm_ms_fsm.c +++ b/src/gmm/gmm_ms_fsm.c @@ -75,6 +75,7 @@ struct gprs_gmm_ms_fsm_ctx *ctx = (struct gprs_gmm_ms_fsm_ctx *)fi->priv; memset(&ctx->attach, 0, sizeof(ctx->attach)); + gprs_gmm_gmme_t3312_stop(ctx->gmme); } static void st_gmm_ms_deregistered(struct osmo_fsm_inst *fi, uint32_t event, void *data) -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32910 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: If1ca164b7a6c7f7750e2e2f0812d6fde828ed4a4 Gerrit-Change-Number: 32910 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in libosmo-gprs[master]: gmm: Initial implementation of READY timer
by pespin 25 May '23

25 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32909 ) Change subject: gmm: Initial implementation of READY timer ...................................................................... gmm: Initial implementation of READY timer Change-Id: I451ce08d80fb247c28819de065136e2e4d49f3f5 --- M include/osmocom/gprs/gmm/gmm_private.h M src/gmm/gmm.c M src/gmm/gmm_pdu.c M src/gmm/gmm_prim.c M tests/gmm/gmm_prim_test.ok 5 files changed, 99 insertions(+), 4 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/include/osmocom/gprs/gmm/gmm_private.h b/include/osmocom/gprs/gmm/gmm_private.h index 339753b..0ae4df4 100644 --- a/include/osmocom/gprs/gmm/gmm_private.h +++ b/include/osmocom/gprs/gmm/gmm_private.h @@ -10,6 +10,7 @@ #include <osmocom/core/msgb.h> #include <osmocom/core/logging.h> #include <osmocom/core/endian.h> +#include <osmocom/core/tdef.h> #include <osmocom/gsm/protocol/gsm_23_003.h> #include <osmocom/gprs/llc/llc_prim.h> @@ -83,6 +84,9 @@ unsigned long t3302; unsigned long t3346; + /* READY timer, TS 24.008 4.7.2.1.1 */ + struct osmo_timer_list t3314; + unsigned long t3314_assigned_sec; /* value assigned by the network */ }; /* gmm_prim.c: */ @@ -109,6 +113,9 @@ struct gprs_gmm_entity *gprs_gmm_find_gmme_by_tlli(uint32_t tlli); struct gprs_gmm_entity *gprs_gmm_find_gmme_by_sess_id(uint32_t id); uint32_t gprs_gmm_alloc_rand_tlli(void); +void gprs_gmm_gmme_ready_timer_start(struct gprs_gmm_entity *gmme); +void gprs_gmm_gmme_ready_timer_stop(struct gprs_gmm_entity *gmme); +bool gprs_gmm_gmme_ready_timer_running(const struct gprs_gmm_entity *gmme); int gprs_gmm_rx(struct gprs_gmm_entity *gmme, struct gsm48_hdr *gh, unsigned int len); int gprs_gmm_tx_att_req(struct gprs_gmm_entity *gmme, enum osmo_gprs_gmm_attach_type attach_type, diff --git a/src/gmm/gmm.c b/src/gmm/gmm.c index aef3571..5a3b0c0 100644 --- a/src/gmm/gmm.c +++ b/src/gmm/gmm.c @@ -78,6 +78,8 @@ { 0 } /* empty item at the end */ }; +static void t3314_ready_timer_cb(void *data); + static void gprs_gmm_ctx_free(void) { struct gprs_gmm_entity *gmme; @@ -173,6 +175,8 @@ gmme->t3302 = osmo_tdef_get(g_gmm_ctx->T_defs, 3302, OSMO_TDEF_S, -1); gmme->t3346 = osmo_tdef_get(g_gmm_ctx->T_defs, 3346, OSMO_TDEF_S, -1); + osmo_timer_setup(&gmme->t3314, t3314_ready_timer_cb, gmme); + llist_add(&gmme->list, &g_gmm_ctx->gmme_list); return gmme; @@ -184,6 +188,8 @@ return; LOGGMME(gmme, LOGL_DEBUG, "free()\n"); + if (osmo_timer_pending(&gmme->t3314)) + osmo_timer_del(&gmme->t3314); gprs_gmm_ms_fsm_ctx_release(&gmme->ms_fsm); llist_del(&gmme->list); talloc_free(gmme); @@ -280,6 +286,51 @@ return GPRS_GMM_TLLI_UNASSIGNED; } +/* TS 24.008 4.7.2.1.1 READY timer behaviour (A/Gb mode only) */ +/* Ready timer is started: */ +void gprs_gmm_gmme_ready_timer_start(struct gprs_gmm_entity *gmme) +{ + if (gmme->t3314_assigned_sec == 0) + return; + LOGGMME(gmme, LOGL_INFO, "READY timer started\n"); + osmo_timer_schedule(&gmme->t3314, gmme->t3314_assigned_sec, 0); + + /* TODO: "Timer T3312 is stopped and shall be set to its initial value + * for the next start when the READY timer is started." */ +} + +/* Ready timer is stopped: */ +void gprs_gmm_gmme_ready_timer_stop(struct gprs_gmm_entity *gmme) +{ + /* TODO: "In A/Gb mode, the timer T3312 is reset and started with its + * initial value, when the READY timer is stopped or expires." + */ + if (!osmo_timer_pending(&gmme->t3314)) + return; + LOGGMME(gmme, LOGL_INFO, "READY timer stopped\n"); + osmo_timer_del(&gmme->t3314); +} + +bool gprs_gmm_gmme_ready_timer_running(const struct gprs_gmm_entity *gmme) +{ + return osmo_timer_pending(&gmme->t3314); +} + +/* READY timer expiration: */ +static void t3314_ready_timer_cb(void *data) +{ + /* "When the READY timer has expired the MS shall perform the routing + * area updating procedure when a routing area border is crossed" + */ + struct gprs_gmm_entity *gmme = (struct gprs_gmm_entity *)data; + LOGGMME(gmme, LOGL_INFO, "READY timer expired\n"); + + /* TODO: "In A/Gb mode, the timer T3312 is reset and started with its + *initial value, when the READY timer is stopped or expires." + */ + +} + int gprs_gmm_submit_gmmreg_attach_cnf(struct gprs_gmm_entity *gmme, bool accepted, uint8_t cause) { struct osmo_gprs_gmm_prim *gmm_prim_tx; @@ -572,6 +623,18 @@ gmme->ptmsi_sig = GSM_RESERVED_TMSI; } + /* 10.5.7.3 Negotiated READY timer value */ + if (TLVP_PRESENT(&tp, GSM48_IE_GMM_TIMER_READY)) { + int secs = gprs_gmm_gprs_tmr_to_secs(*TLVP_VAL(&tp, GSM48_IE_GMM_TIMER_READY)); + gmme->t3314_assigned_sec = secs >= 0 ? secs : 0; + } else { + /* Apply the requested value: */ + gmme->t3314_assigned_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3314, OSMO_TDEF_S, -1); + } + /* "If the negotiated READY timer value is set to zero, the READY timer shall be stopped immediately": */ + if (gmme->t3314_assigned_sec == 0) + gprs_gmm_gmme_ready_timer_stop(gmme); + if (TLVP_PRESENT(&tp, GSM48_IE_GMM_ALLOC_PTMSI)) { struct osmo_mobile_identity mi; if (osmo_mobile_identity_decode(&mi, TLVP_VAL(&tp, GSM48_IE_GMM_ALLOC_PTMSI), diff --git a/src/gmm/gmm_pdu.c b/src/gmm/gmm_pdu.c index 28fd30f..c6c8118 100644 --- a/src/gmm/gmm_pdu.c +++ b/src/gmm/gmm_pdu.c @@ -181,6 +181,7 @@ uint8_t *l; int rc; struct gsm48_ra_id *raid_enc; + unsigned long t3314_sec; gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh)); gh->proto_discr = GSM48_PDISC_MM_GPRS; @@ -236,6 +237,10 @@ msgb_tv_fixed_put(msg, GSM48_IE_GMM_PTMSI_SIG, sizeof(ptmsi_sig), ptmsi_sig); } + /* 10.5.7.3 Requested READY timer value */ + t3314_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3314, OSMO_TDEF_S, -1); + msgb_tv_put(msg, GSM48_IE_GMM_TIMER_READY, gprs_gmm_secs_to_gprs_tmr_floor(t3314_sec)); + /* 9.4.1.13 P-TMSI type: The MS shall include this IE if the * type of identity in the Mobile identity IE is set to * "TMSI/P-TMSI/M-TMSI". */ diff --git a/src/gmm/gmm_prim.c b/src/gmm/gmm_prim.c index 7ca6535..34c9fe9 100644 --- a/src/gmm/gmm_prim.c +++ b/src/gmm/gmm_prim.c @@ -603,6 +603,18 @@ return rc; } +static int gprs_gmm_prim_handle_gmmrr_llc_transmitted_ind(struct osmo_gprs_gmm_prim *gmm_prim) +{ + struct gprs_gmm_entity *gmme = gprs_gmm_find_gmme_by_tlli(gmm_prim->gmmrr.tlli); + if (!gmme) { + LOGGMM(LOGL_NOTICE, "Rx %s: Unknown TLLI 0x%08x\n", + osmo_gprs_gmm_prim_name(gmm_prim), gmm_prim->gmmrr.tlli); + return -ENOENT; + } + gprs_gmm_gmme_ready_timer_start(gmme); + return 0; +} + static int gprs_gmm_prim_handle_gmmrr(struct osmo_gprs_gmm_prim *gmm_prim) { int rc = 0; @@ -612,8 +624,7 @@ rc = 1; break; case OSMO_PRIM(OSMO_GPRS_GMM_GMMRR_LLC_TRANSMITTED, PRIM_OP_INDICATION): - rc = gprs_gmm_prim_handle_unsupported(gmm_prim); - rc = 1; + rc = gprs_gmm_prim_handle_gmmrr_llc_transmitted_ind(gmm_prim); break; default: rc = gprs_gmm_prim_handle_unsupported(gmm_prim); diff --git a/tests/gmm/gmm_prim_test.ok b/tests/gmm/gmm_prim_test.ok index cfebbfa..068876b 100644 --- a/tests/gmm/gmm_prim_test.ok +++ b/tests/gmm/gmm_prim_test.ok @@ -1,5 +1,5 @@ ==== test_gmm_prim_ms_gmmreg() [start] ==== -test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 01 04 97 07 00 00 01 0a 00 05 f4 00 00 12 34 00 f0 00 00 00 00 00 19 55 66 77 e1 ] +test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 01 04 97 07 00 00 01 0a 00 05 f4 00 00 12 34 00 f0 00 00 00 00 00 19 55 66 77 17 16 e1 ] test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 16 08 42 32 24 43 32 24 43 f2 ] test_gmm_prim_up_cb(): Rx GMMREG-SIM_AUTH.indication ac_ref_nr=2 key_seq=0 rand=e2 a6 f3 f8 bb 9e a7 01 e0 ce 4f 33 64 a9 91 75 test_gmm_prim_llc_down_cb(): Rx LLGMM-ASSIGN.request old_TLLI=0xffffffff new_TLLI=0x80001234 @@ -13,7 +13,7 @@ test_gmm_prim_up_cb(): Rx GMMREG-DETACH.confirm detach_type='GPRS detach' ==== test_gmm_prim_ms_gmmreg() [end] ==== ==== test_gmm_prim_ms_gmmsm() [start] ==== -test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 01 04 97 07 00 00 01 0a 00 05 f4 00 00 12 34 00 f0 00 00 00 00 00 19 55 66 77 e1 ] +test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 01 04 97 07 00 00 01 0a 00 05 f4 00 00 12 34 00 f0 00 00 00 00 00 19 55 66 77 17 16 e1 ] test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 16 08 42 32 24 43 32 24 43 f2 ] test_gmm_prim_up_cb(): Rx GMMREG-SIM_AUTH.indication ac_ref_nr=2 key_seq=0 rand=e2 a6 f3 f8 bb 9e a7 01 e0 ce 4f 33 64 a9 91 75 test_gmm_prim_llc_down_cb(): Rx LLGMM-ASSIGN.request old_TLLI=0xffffffff new_TLLI=0x80001234 -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32909 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: I451ce08d80fb247c28819de065136e2e4d49f3f5 Gerrit-Change-Number: 32909 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in libosmo-gprs[master]: llc: Add APIs to submit LLGM-trigger/suspend/resume.req primitives
by pespin 25 May '23

25 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32959 ) Change subject: llc: Add APIs to submit LLGM-trigger/suspend/resume.req primitives ...................................................................... llc: Add APIs to submit LLGM-trigger/suspend/resume.req primitives This commit also adds an initial implementation of LLGM-suspend/resume.req. Change-Id: I890c7a4ace6fb8ca362ec41bd18e9c229191a587 --- M include/osmocom/gprs/llc/llc_prim.h M include/osmocom/gprs/llc/llc_private.h M src/llc/llc_ll.c M src/llc/llc_llgmm.c 4 files changed, 98 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/include/osmocom/gprs/llc/llc_prim.h b/include/osmocom/gprs/llc/llc_prim.h index d5a424d..904e9fa 100644 --- a/include/osmocom/gprs/llc/llc_prim.h +++ b/include/osmocom/gprs/llc/llc_prim.h @@ -300,6 +300,9 @@ /* Alloc primitive for LLGMM SAP: */ struct osmo_gprs_llc_prim *osmo_gprs_llc_prim_alloc_llgm_assign_req(uint32_t tlli); struct osmo_gprs_llc_prim *osmo_gprs_llc_prim_alloc_llgm_reset_req(uint32_t tlli); +struct osmo_gprs_llc_prim *osmo_gprs_llc_prim_alloc_llgm_trigger_req(uint32_t tlli, uint8_t cause); +struct osmo_gprs_llc_prim *osmo_gprs_llc_prim_alloc_llgm_suspend_req(uint32_t tlli); +struct osmo_gprs_llc_prim *osmo_gprs_llc_prim_alloc_llgm_resume_req(uint32_t tlli); /* Alloc primitive for LL SAP: */ struct osmo_gprs_llc_prim *osmo_gprs_llc_prim_alloc_ll_establish_req(uint32_t tlli, enum osmo_gprs_llc_sapi ll_sapi, diff --git a/include/osmocom/gprs/llc/llc_private.h b/include/osmocom/gprs/llc/llc_private.h index 994acd8..ed68c7b 100644 --- a/include/osmocom/gprs/llc/llc_private.h +++ b/include/osmocom/gprs/llc/llc_private.h @@ -254,6 +254,10 @@ /* Internal management */ uint32_t age_timestamp; + + /* TS 44.064 § C.2: "In addition, all states should observe the suspended + * operation (reception of LLGMM-SUSPEND-REQ) restrictions" */ + bool suspended; }; static inline struct gprs_llc_lle *gprs_llc_llme_get_lle(struct gprs_llc_llme *llme, diff --git a/src/llc/llc_ll.c b/src/llc/llc_ll.c index 43a0951..a13a7f5 100644 --- a/src/llc/llc_ll.c +++ b/src/llc/llc_ll.c @@ -277,9 +277,15 @@ lle = gprs_llc_llme_get_lle(llme, llc_prim->ll.sapi); } + if (lle->llme->suspended && llc_prim->ll.sapi != OSMO_GPRS_LLC_SAPI_GMM) { + LOGLLE(lle, LOGL_NOTICE, "Dropping frame to transmit, LLME is suspended\n"); + goto ret_free; + } + rc = gprs_llc_lle_tx_ui(lle, llc_prim->ll.l3_pdu, llc_prim->ll.l3_pdu_len, llc_prim->ll.unitdata_req.apply_gea); +ret_free: msgb_free(llc_prim->oph.msg); return rc; } diff --git a/src/llc/llc_llgmm.c b/src/llc/llc_llgmm.c index 5834041..7b09a69 100644 --- a/src/llc/llc_llgmm.c +++ b/src/llc/llc_llgmm.c @@ -100,7 +100,7 @@ return llc_prim; } -/* 7.2.1.2 LLGMM-RESET.cnf (SGSN):*/ +/* 7.2.1.2 LLGMM-RESET.cnf (SGSN): */ struct osmo_gprs_llc_prim *osmo_gprs_llc_prim_alloc_llgm_reset_cnf(uint32_t tlli) { struct osmo_gprs_llc_prim *llc_prim; @@ -109,6 +109,34 @@ return llc_prim; } +/* 7.2.1.3 LLGMM-TRIGGER.req (MS): */ +struct osmo_gprs_llc_prim *osmo_gprs_llc_prim_alloc_llgm_trigger_req(uint32_t tlli, uint8_t cause) +{ + struct osmo_gprs_llc_prim *llc_prim; + llc_prim = llc_prim_llgmm_alloc(OSMO_GPRS_LLC_LLGMM_TRIGGER, PRIM_OP_REQUEST, 0); + llc_prim->llgmm.tlli = tlli; + llc_prim->llgmm.trigger_req.cause = cause; + return llc_prim; +} + +/* 7.2.1.4 LLGMM-SUSPEND.req (MS/SGSN): */ +struct osmo_gprs_llc_prim *osmo_gprs_llc_prim_alloc_llgm_suspend_req(uint32_t tlli) +{ + struct osmo_gprs_llc_prim *llc_prim; + llc_prim = llc_prim_llgmm_alloc(OSMO_GPRS_LLC_LLGMM_SUSPEND, PRIM_OP_REQUEST, 0); + llc_prim->llgmm.tlli = tlli; + return llc_prim; +} + +/* 7.2.1.5 LLGMM-RESUME.req (MS/SGSN):*/ +struct osmo_gprs_llc_prim *osmo_gprs_llc_prim_alloc_llgm_resume_req(uint32_t tlli) +{ + struct osmo_gprs_llc_prim *llc_prim; + llc_prim = llc_prim_llgmm_alloc(OSMO_GPRS_LLC_LLGMM_RESUME, PRIM_OP_REQUEST, 0); + llc_prim->llgmm.tlli = tlli; + return llc_prim; +} + /******************************** * Handling from upper layers: ********************************/ @@ -246,6 +274,48 @@ return rc; } +/* 7.2.1.4 LLGMM-SUSPEND.req (MS/SGSN):*/ +static int llc_prim_handle_llgm_suspend_req(struct osmo_gprs_llc_prim *llc_prim) +{ + int rc = 0; + struct gprs_llc_llme *llme = gprs_llc_find_llme_by_tlli(llc_prim->llgmm.tlli); + + if (!llme) { + LOGLLC(LOGL_NOTICE, "Rx %s: Unknown TLLI 0x%08x\n", + osmo_gprs_llc_prim_name(llc_prim), llc_prim->llgmm.tlli); + rc = -ENOKEY; + goto ret_free; + } + LOGLLME(llme, LOGL_INFO, "%s\n", osmo_gprs_llc_prim_name(llc_prim)); + + llme->suspended = true; + +ret_free: + msgb_free(llc_prim->oph.msg); + return rc; +} + +/* 7.2.1.5 LLGMM-RESUME.req (MS/SGSN):*/ +static int llc_prim_handle_llgm_resume_req(struct osmo_gprs_llc_prim *llc_prim) +{ + int rc = 0; + struct gprs_llc_llme *llme = gprs_llc_find_llme_by_tlli(llc_prim->llgmm.tlli); + + if (!llme) { + LOGLLC(LOGL_NOTICE, "Rx %s: Unknown TLLI 0x%08x\n", + osmo_gprs_llc_prim_name(llc_prim), llc_prim->llgmm.tlli); + rc = -ENOKEY; + goto ret_free; + } + LOGLLME(llme, LOGL_INFO, "%s\n", osmo_gprs_llc_prim_name(llc_prim)); + + llme->suspended = false; + +ret_free: + msgb_free(llc_prim->oph.msg); + return rc; +} + /* LLC higher layers push LLC primitive down to LLC layer: */ int gprs_llc_prim_llgmm_upper_down(struct osmo_gprs_llc_prim *llc_prim) { @@ -267,12 +337,12 @@ case OSMO_PRIM(OSMO_GPRS_LLC_LLGMM_SUSPEND, PRIM_OP_REQUEST): OSMO_ASSERT(g_llc_ctx->location == OSMO_GPRS_LLC_LOCATION_MS || g_llc_ctx->location == OSMO_GPRS_LLC_LOCATION_SGSN); - rc = gprs_llc_prim_handle_unsupported(llc_prim); + rc = llc_prim_handle_llgm_suspend_req(llc_prim); break; case OSMO_PRIM(OSMO_GPRS_LLC_LLGMM_RESUME, PRIM_OP_REQUEST): OSMO_ASSERT(g_llc_ctx->location == OSMO_GPRS_LLC_LOCATION_MS || g_llc_ctx->location == OSMO_GPRS_LLC_LOCATION_SGSN); - rc = gprs_llc_prim_handle_unsupported(llc_prim); + rc = llc_prim_handle_llgm_resume_req(llc_prim); break; case OSMO_PRIM(OSMO_GPRS_LLC_LLGMM_IOV, PRIM_OP_REQUEST): OSMO_ASSERT(g_llc_ctx->location == OSMO_GPRS_LLC_LOCATION_SGSN); -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32959 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: I890c7a4ace6fb8ca362ec41bd18e9c229191a587 Gerrit-Change-Number: 32959 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[L] Change in libosmo-gprs[master]: gmm: Implement periodic RAU procedure
by pespin 25 May '23

25 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32925 ) Change subject: gmm: Implement periodic RAU procedure ...................................................................... gmm: Implement periodic RAU procedure Related: OS#5501 Change-Id: Ie7cba8a2fe3b97bebc558c957cc1bcbe3cc81dbc --- M include/osmocom/gprs/gmm/gmm_ms_fsm.h M include/osmocom/gprs/gmm/gmm_pdu.h M include/osmocom/gprs/gmm/gmm_private.h M src/gmm/gmm.c M src/gmm/gmm_ms_fsm.c M src/gmm/gmm_pdu.c M tests/gmm/Makefile.am M tests/gmm/gmm_prim_test.c M tests/gmm/gmm_prim_test.err M tests/gmm/gmm_prim_test.ok 10 files changed, 571 insertions(+), 15 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/include/osmocom/gprs/gmm/gmm_ms_fsm.h b/include/osmocom/gprs/gmm/gmm_ms_fsm.h index 078c535..1ebc53c 100644 --- a/include/osmocom/gprs/gmm/gmm_ms_fsm.h +++ b/include/osmocom/gprs/gmm/gmm_ms_fsm.h @@ -5,6 +5,20 @@ struct gprs_gmm_entity; +/* Update type 10.5.5.18 */ +enum gprs_gmm_upd_type { + GPRS_GMM_UPD_TYPE_RA = 0, + GPRS_GMM_UPD_TYPE_COMBINED_RA_LA = 1, + GPRS_GMM_UPD_TYPE_COMBINED_RA_LA_IMSI = 2, + GPRS_GMM_UPD_TYPE_PERIODIC = 3, + /* others: reserved */ +}; +extern const struct value_string gprs_gmm_upd_type_names[]; +static inline const char *gprs_gmm_upd_type_name(enum gprs_gmm_upd_type val) +{ + return get_value_string(gprs_gmm_upd_type_names, val); +} + /* 3GPP TS 24.008 § 4.1.3.1 GMM states in the MS */ enum gprs_gmm_ms_fsm_states { GPRS_GMM_MS_ST_NULL, /* 4.1.3.1.1.1 */ @@ -58,12 +72,20 @@ enum osmo_gprs_gmm_detach_poweroff_type poweroff_type; }; +/* Info about last initiated RAU: */ +struct gprs_gmm_ms_fsm_rau_ctx { + enum gprs_gmm_upd_type type; + /* Retransmission of RAU REQUEST (4.7.5.1.5) */ + uint8_t req_attempts; +}; + struct gprs_gmm_ms_fsm_ctx { struct osmo_fsm_inst *fi; struct gprs_gmm_entity *gmme; struct gprs_gmm_ms_fsm_attach_ctx attach; struct gprs_gmm_ms_fsm_detach_ctx detach; + struct gprs_gmm_ms_fsm_rau_ctx rau; }; int gprs_gmm_ms_fsm_init(void); @@ -81,3 +103,5 @@ enum osmo_gprs_gmm_detach_ms_type detach_type, enum osmo_gprs_gmm_detach_poweroff_type poweroff_type); +int gprs_gmm_ms_fsm_ctx_request_rau(struct gprs_gmm_ms_fsm_ctx *ctx, + enum gprs_gmm_upd_type rau_type); diff --git a/include/osmocom/gprs/gmm/gmm_pdu.h b/include/osmocom/gprs/gmm/gmm_pdu.h index 323b2c7..a0a840f 100644 --- a/include/osmocom/gprs/gmm/gmm_pdu.h +++ b/include/osmocom/gprs/gmm/gmm_pdu.h @@ -5,6 +5,7 @@ #include <osmocom/gsm/tlv.h> struct gprs_gmm_entity; +enum gprs_gmm_upd_type; #define GPRS_GMM_ALLOC_SIZE 2048 #define GPRS_GMM_ALLOC_HEADROOM 256 @@ -36,3 +37,9 @@ enum osmo_gprs_gmm_detach_ms_type detach_type, enum osmo_gprs_gmm_detach_poweroff_type poweroff_type, struct msgb *msg); + +int gprs_gmm_build_rau_req(struct gprs_gmm_entity *gmme, + enum gprs_gmm_upd_type rau_type, + struct msgb *msg); + +int gprs_gmm_build_rau_compl(struct gprs_gmm_entity *gmme, struct msgb *msg); diff --git a/include/osmocom/gprs/gmm/gmm_private.h b/include/osmocom/gprs/gmm/gmm_private.h index daa967f..d93f724 100644 --- a/include/osmocom/gprs/gmm/gmm_private.h +++ b/include/osmocom/gprs/gmm/gmm_private.h @@ -126,6 +126,7 @@ int gprs_gmm_tx_detach_req(struct gprs_gmm_entity *gmme, enum osmo_gprs_gmm_detach_ms_type detach_type, enum osmo_gprs_gmm_detach_poweroff_type poweroff_type); +int gprs_gmm_tx_rau_req(struct gprs_gmm_entity *gmme, enum gprs_gmm_upd_type rau_type); int gprs_gmm_tx_ciph_auth_resp(const struct gprs_gmm_entity *gmme, const uint8_t *sres); int gprs_gmm_submit_gmmreg_attach_cnf(struct gprs_gmm_entity *gmme, bool accepted, uint8_t cause); diff --git a/src/gmm/gmm.c b/src/gmm/gmm.c index 6184a01..38ebc98 100644 --- a/src/gmm/gmm.c +++ b/src/gmm/gmm.c @@ -78,6 +78,14 @@ { 0 } /* empty item at the end */ }; +const struct value_string gprs_gmm_upd_type_names[] = { + { GPRS_GMM_UPD_TYPE_RA, "RA updating" }, + { GPRS_GMM_UPD_TYPE_COMBINED_RA_LA, "Combined RA/LA updating" }, + { GPRS_GMM_UPD_TYPE_COMBINED_RA_LA_IMSI, "Combined RA/LA updating with IMSI attac" }, + { GPRS_GMM_UPD_TYPE_PERIODIC, "Periodic updating" }, + { 0, NULL } +}; + static void t3314_ready_timer_cb(void *data); static void t3312_periodic_rau_timer_cb(void *data); @@ -296,7 +304,7 @@ { if (gmme->t3314_assigned_sec == 0) return; - LOGGMME(gmme, LOGL_INFO, "READY timer started\n"); + LOGGMME(gmme, LOGL_INFO, "READY timer started (expires in %lu seconds)\n", gmme->t3314_assigned_sec); osmo_timer_schedule(&gmme->t3314, gmme->t3314_assigned_sec, 0); /* "Timer T3312 is stopped and shall be set to its initial value @@ -341,14 +349,11 @@ /* T3312 (Periodic RAU) is started: */ void gprs_gmm_gmme_t3312_start(struct gprs_gmm_entity *gmme) { - unsigned long t3312_sec; - - t3312_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3312, OSMO_TDEF_S, -1); - if (t3312_sec == 0) + if (gmme->t3312_assigned_sec == 0) return; - LOGGMME(gmme, LOGL_INFO, "T3312 started\n"); - osmo_timer_schedule(&gmme->t3312, t3312_sec, 0); + LOGGMME(gmme, LOGL_INFO, "T3312 started (expires in %lu seconds)\n", gmme->t3312_assigned_sec); + osmo_timer_schedule(&gmme->t3312, gmme->t3312_assigned_sec, 0); } /* T3312 (Periodic RAU) is stopped: */ @@ -380,6 +385,8 @@ * routing area updating procedure when it returns to state * GMM-REGISTERED.NORMAL-SERVICE." */ + gprs_gmm_ms_fsm_ctx_request_rau(&gmme->ms_fsm, GPRS_GMM_UPD_TYPE_PERIODIC); + } int gprs_gmm_submit_gmmreg_attach_cnf(struct gprs_gmm_entity *gmme, bool accepted, uint8_t cause) @@ -641,6 +648,71 @@ return rc; } +/* Tx GMM Routing area update request, 9.4.14 */ +int gprs_gmm_tx_rau_req(struct gprs_gmm_entity *gmme, + enum gprs_gmm_upd_type rau_type) +{ + struct osmo_gprs_llc_prim *llc_prim; + int rc; + struct msgb *msg; + + LOGGMME(gmme, LOGL_INFO, "Tx GMM RAU REQUEST\n"); + llc_prim = osmo_gprs_llc_prim_alloc_ll_unitdata_req( + gmme->tlli, OSMO_GPRS_LLC_SAPI_GMM, NULL, GPRS_GMM_ALLOC_SIZE); + msg = llc_prim->oph.msg; + msg->l3h = msg->tail; + rc = gprs_gmm_build_rau_req(gmme, rau_type, msg); + if (rc < 0) { + msgb_free(msg); + return -EBADMSG; + } + llc_prim->ll.l3_pdu = msg->l3h; + llc_prim->ll.l3_pdu_len = msgb_l3len(msg); + /* TODO: + llc_prim->ll.qos_params.*; + llc_prim->ll.radio_prio; + llc_prim->ll.apply_gea; + llc_prim->ll.apply_gia; + */ + + rc = gprs_gmm_prim_call_llc_down_cb(llc_prim); + + return rc; +} + +/* Tx GMM Routing area update complete, 9.4.16 */ +static int gprs_gmm_tx_rau_compl(struct gprs_gmm_entity *gmme) +{ + struct osmo_gprs_llc_prim *llc_prim; + int rc; + struct msgb *msg; + + LOGGMME(gmme, LOGL_INFO, "Tx GMM RAU COMPL\n"); + + llc_prim = osmo_gprs_llc_prim_alloc_ll_unitdata_req( + gmme->tlli, OSMO_GPRS_LLC_SAPI_GMM, NULL, GPRS_GMM_ALLOC_SIZE); + msg = llc_prim->oph.msg; + msg->l3h = msg->tail; + rc = gprs_gmm_build_rau_compl(gmme, msg); + if (rc < 0) { + msgb_free(msg); + return -EBADMSG; + } + llc_prim->ll.l3_pdu = msg->l3h; + llc_prim->ll.l3_pdu_len = msgb_l3len(msg); + /* TODO: + llc_prim->ll.qos_params.*; + llc_prim->ll.radio_prio; + llc_prim->ll.apply_gea; + llc_prim->ll.apply_gia; + */ + + rc = gprs_gmm_prim_call_llc_down_cb(llc_prim); + if (rc < 0) + return rc; + return rc; +} + static int gprs_gmm_rx_att_ack(struct gprs_gmm_entity *gmme, struct gsm48_hdr *gh, unsigned int len) { struct gsm48_attach_ack *aa; @@ -815,6 +887,130 @@ return -EINVAL; /* TODO: what to do on error? */ } +/* Rx Routing area update accept, 9.4.15 */ +static int gprs_gmm_rx_rau_acc(struct gprs_gmm_entity *gmme, struct gsm48_hdr *gh, unsigned int len) +{ + struct gsm48_ra_upd_ack *raack; + struct tlv_parsed tp; + int rc; + int periodic_rau_sec; + + if (len < sizeof(*gh) + sizeof(*raack)) { + LOGGMME(gmme, LOGL_ERROR, "Rx GMM RAU ACCEPT with wrong size %u\n", len); + goto rejected; + } + + raack = (struct gsm48_ra_upd_ack *)&gh->data[0]; + LOGGMME(gmme, LOGL_INFO, "Rx GMM RAU ACCEPT upd_result=0x%02x\n", raack->upd_result); + + /* TODO: check raack->upd_result */ + + periodic_rau_sec = gprs_gmm_gprs_tmr_to_secs(raack->ra_upd_timer); + gmme->t3312_assigned_sec = periodic_rau_sec >= 0 ? periodic_rau_sec : 0; + if (gmme->t3312_assigned_sec == 0) + gprs_gmm_gmme_t3312_stop(gmme); + gsm48_parse_ra(&gmme->ra, (const uint8_t *)&raack->ra_id); + + if (len > sizeof(*gh) + sizeof(*raack)) { + rc = gprs_gmm_tlv_parse(&tp, &raack->data[0], + len - (sizeof(*gh) + sizeof(*raack))); + if (rc < 0) { + LOGGMME(gmme, LOGL_ERROR, "Rx GMM RAU ACCEPT: failed to parse TLVs %d\n", rc); + goto rejected; + } + + /* 10.5.5.8 P-TMSI signature */ + if (TLVP_PRESENT(&tp, GSM48_IE_GMM_PTMSI_SIG)) { + const uint8_t *ptmsi_sig = TLVP_VAL(&tp, GSM48_IE_GMM_PTMSI_SIG); + gmme->ptmsi_sig = (ptmsi_sig[0] << 8) | (ptmsi_sig[1] << 4) | ptmsi_sig[2]; + } else { + gmme->ptmsi_sig = GSM_RESERVED_TMSI; + } + + /* 10.5.1.4 Allocated P-TMSI */ + if (TLVP_PRESENT(&tp, GSM48_IE_GMM_ALLOC_PTMSI)) { + struct osmo_mobile_identity mi; + if (osmo_mobile_identity_decode(&mi, TLVP_VAL(&tp, GSM48_IE_GMM_ALLOC_PTMSI), + TLVP_LEN(&tp, GSM48_IE_GMM_ALLOC_PTMSI), false) + || mi.type != GSM_MI_TYPE_TMSI) { + LOGGMME(gmme, LOGL_ERROR, "Cannot decode P-TMSI\n"); + goto rejected; + } + gmme->old_ptmsi = gmme->ptmsi; + gmme->ptmsi = mi.tmsi; + /* TS 24.008 4.7.1.4.1:"Upon receipt of the assigned P-TMSI, the MS + * shall derive the local TLLI from this P-TMSI and shall use it for + * addressing at lower layers": */ + gmme->old_tlli = gmme->tlli; + gmme->tlli = gprs_tmsi2tlli(gmme->ptmsi, TLLI_LOCAL); + } + /* FIXME! what to do it PTMSI changes? probably need to update other layers... Check GPRS ATTACH ACCEPT func */ + + /* 10.5.1.4 MS identity */ + if (TLVP_PRESENT(&tp, GSM48_IE_GMM_IMEISV)) { + struct osmo_mobile_identity mi; + if (osmo_mobile_identity_decode(&mi, TLVP_VAL(&tp, GSM48_IE_GMM_IMEISV), + TLVP_LEN(&tp, GSM48_IE_GMM_IMEISV), false) + || mi.type != GSM_MI_TYPE_IMEISV) { + LOGGMME(gmme, LOGL_ERROR, "Cannot decode IMEISV\n"); + goto rejected; + } + /* TODO: */ + } + + /* 10.5.5.11 List of Receive N-PDU Numbers: TODO */ + + /* 10.5.7.3 Negotiated READY timer value */ + if (TLVP_PRESENT(&tp, GSM48_IE_GMM_TIMER_READY)) { + int secs = gprs_gmm_gprs_tmr_to_secs(*TLVP_VAL(&tp, GSM48_IE_GMM_TIMER_READY)); + gmme->t3314_assigned_sec = secs >= 0 ? secs : 0; + } else { + /* Apply the requested value: */ + gmme->t3314_assigned_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3314, OSMO_TDEF_S, -1); + } + /* "If the negotiated READY timer value is set to zero, the READY timer shall be stopped immediately": */ + if (gmme->t3314_assigned_sec == 0) { + gprs_gmm_gmme_ready_timer_stop(gmme); + /* "If after a READY timer negotiation the READY timer + * value is set to zero, timer T3312 is reset and started + * with its initial value." */ + gprs_gmm_gmme_t3312_start(gmme); + } + + /* 10.5.5.14 GMM cause: TODO */ + + /* 10.5.7.4 T3302 value */ + if (TLVP_PRES_LEN(&tp, GSM48_IE_GMM_TIMER_T3302, 1)) + gmme->t3302 = *TLVP_VAL(&tp, GSM48_IE_GMM_TIMER_T3302); + + /* 10.5.1.13 Equivalent PLMNs: TODO */ + /* 10.5.7.1 PDP context status: TODO */ + + /* TODO: lots more Optional IEs */ + } + + /* Submit LLGMM-ASSIGN-REQ as per TS 24.007 Annex C.1 */ + rc = gprs_gmm_submit_llgmm_assing_req(gmme); + if (rc < 0) + goto rejected; + + /* Submit GMMRR-ASSIGN-REQ as per TS 24.007 Annex C.1 */ + rc = gprs_gmm_submit_gmmrr_assing_req(gmme); + if (rc < 0) + goto rejected; + + rc = gprs_gmm_tx_rau_compl(gmme); + if (rc < 0) + goto rejected; + + rc = osmo_fsm_inst_dispatch(gmme->ms_fsm.fi, GPRS_GMM_MS_EV_RAU_ACCEPTED, NULL); + + return rc; + +rejected: + return -EINVAL; /* TODO: what to do on error? */ +} + /* Rx GMM Identity Request, 9.2.10 */ static int gprs_gmm_rx_id_req(struct gprs_gmm_entity *gmme, struct gsm48_hdr *gh, unsigned int len) { @@ -916,6 +1112,9 @@ case GSM48_MT_GMM_DETACH_ACK: rc = gprs_gmm_rx_detach_accept(gmme, gh, len); break; + case GSM48_MT_GMM_RA_UPD_ACK: + rc = gprs_gmm_rx_rau_acc(gmme, gh, len); + break; case GSM48_MT_GMM_ID_REQ: rc = gprs_gmm_rx_id_req(gmme, gh, len); break; diff --git a/src/gmm/gmm_ms_fsm.c b/src/gmm/gmm_ms_fsm.c index 889d82a..a6714ff 100644 --- a/src/gmm/gmm_ms_fsm.c +++ b/src/gmm/gmm_ms_fsm.c @@ -35,7 +35,7 @@ [GPRS_GMM_MS_ST_REGISTERED_INITIATED] = { .T = 3310 }, [GPRS_GMM_MS_ST_REGISTERED] = {}, [GPRS_GMM_MS_ST_DEREGISTERED_INITIATED] = {}, - [GPRS_GMM_MS_ST_RAU_INITIATED] = {}, + [GPRS_GMM_MS_ST_RAU_INITIATED] = { .T = 3330 }, [GPRS_GMM_MS_ST_SR_INITIATED] = {}, }; @@ -59,6 +59,19 @@ ctx->attach.with_imsi); } +static int reinit_rau_proc(struct gprs_gmm_ms_fsm_ctx *ctx) +{ + unsigned long val_sec; + + OSMO_ASSERT(ctx->fi->state == GPRS_GMM_MS_ST_RAU_INITIATED); + + /* Rearm T3330 */ + OSMO_ASSERT(ctx->fi->T == 3330); + val_sec = osmo_tdef_get(g_gmm_ctx->T_defs, ctx->fi->T, OSMO_TDEF_S, -1); + osmo_timer_schedule(&ctx->fi->timer, val_sec, 0); + return gprs_gmm_tx_rau_req(ctx->gmme, ctx->rau.type); +} + static void st_gmm_ms_null(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { @@ -168,11 +181,24 @@ static void st_gmm_ms_registered(struct osmo_fsm_inst *fi, uint32_t event, void *data) { + struct gprs_gmm_ms_fsm_ctx *ctx = (struct gprs_gmm_ms_fsm_ctx *)fi->priv; + struct osmo_gprs_llc_prim *llc_prim_tx; + int rc; + switch (event) { case GPRS_GMM_MS_EV_SR_REQUESTED: gmm_ms_fsm_state_chg(fi, GPRS_GMM_MS_ST_REGISTERED); break; case GPRS_GMM_MS_EV_RAU_REQUESTED: + /* TS 24.007 C.15: submit LLGMM-SUSPEND-REQ */ + llc_prim_tx = osmo_gprs_llc_prim_alloc_llgm_suspend_req(ctx->gmme->tlli); + OSMO_ASSERT(llc_prim_tx); + rc = gprs_gmm_prim_call_llc_down_cb(llc_prim_tx); + /* Transmit RAU Requested to SGSN: */ + rc = gprs_gmm_tx_rau_req(ctx->gmme, + ctx->rau.type); + if (rc < 0) + return; gmm_ms_fsm_state_chg(fi, GPRS_GMM_MS_ST_RAU_INITIATED); break; case GPRS_GMM_MS_EV_DETACH_REQUESTED: @@ -200,6 +226,9 @@ static void st_gmm_ms_rau_initiated(struct osmo_fsm_inst *fi, uint32_t event, void *data) { + struct gprs_gmm_ms_fsm_ctx *ctx = (struct gprs_gmm_ms_fsm_ctx *)fi->priv; + struct osmo_gprs_llc_prim *llc_prim_tx; + switch (event) { case GPRS_GMM_MS_EV_RAU_REJECTED: // causes #13, #15, #25 @@ -208,6 +237,10 @@ //mm_ms_fsm_state_chg(fi, GPRS_GMM_MS_ST_DEREGISTERED_INITIATED); break; case GPRS_GMM_MS_EV_RAU_ACCEPTED: + /* TS 24.007 C.15: submit LLGM-RESUME-REQ */ + llc_prim_tx = osmo_gprs_llc_prim_alloc_llgm_resume_req(ctx->gmme->tlli); + OSMO_ASSERT(llc_prim_tx); + gprs_gmm_prim_call_llc_down_cb(llc_prim_tx); gmm_ms_fsm_state_chg(fi, GPRS_GMM_MS_ST_REGISTERED); break; default: @@ -347,7 +380,7 @@ switch (fi->T) { case 3310: - /* TS 23.008 clause 4.7.3.1.5 c) */ + /* TS 24.008 clause 4.7.3.1.5 c) */ ctx->attach.req_attempts++; LOGPFSML(ctx->fi, LOGL_INFO, "T3310 timeout attempts=%u\n", ctx->attach.req_attempts); OSMO_ASSERT(fi->state == GPRS_GMM_MS_ST_REGISTERED_INITIATED); @@ -360,6 +393,20 @@ } reinit_attach_proc(ctx); break; + case 3330: + /* TS 24.008 clause 4.7.5.1.5 c) */ + ctx->rau.req_attempts++; + LOGPFSML(ctx->fi, LOGL_INFO, "T3330 timeout attempts=%u\n", ctx->rau.req_attempts); + OSMO_ASSERT(fi->state == GPRS_GMM_MS_ST_RAU_INITIATED); + if (ctx->rau.req_attempts == 4) { + /* "On the fifth expiry of timer T3330, the MS shall + * abort the GPRS attach procedure" */ + LOGPFSML(ctx->fi, LOGL_NOTICE, "GPRS RAU procedure failure (T3330 timeout attempts=%u)\n", ctx->rau.req_attempts); + osmo_fsm_inst_dispatch(ctx->fi, GPRS_GMM_MS_EV_LOW_LVL_FAIL, NULL); + return 0; + } + reinit_rau_proc(ctx); + break; default: OSMO_ASSERT(0); } @@ -449,3 +496,14 @@ rc = gprs_gmm_tx_detach_req(ctx->gmme, detach_type, poweroff_type); return rc; } + +int gprs_gmm_ms_fsm_ctx_request_rau(struct gprs_gmm_ms_fsm_ctx *ctx, + enum gprs_gmm_upd_type rau_type) +{ + int rc = 0; + + ctx->rau.type = rau_type; + rc = osmo_fsm_inst_dispatch(ctx->fi, GPRS_GMM_MS_EV_RAU_REQUESTED, NULL); + + return rc; +} diff --git a/src/gmm/gmm_pdu.c b/src/gmm/gmm_pdu.c index c6c8118..ae0baef 100644 --- a/src/gmm/gmm_pdu.c +++ b/src/gmm/gmm_pdu.c @@ -151,6 +151,26 @@ }, }; +static int encode_ms_net_cap(struct gprs_gmm_entity *gmme, struct msgb *msg) +{ + int rc; + uint8_t *l; /* len */ + struct bitvec bv = { + .data = msg->tail, + .data_len = GSM_MACBLOCK_LEN, + }; + + msgb_put_u8(msg, GSM48_IE_GMM_MS_NET_CAPA); + + l = msgb_put(msg, 1); /* len */ + + /* TODO: we hardcode a MS Net Cap for now. We may want to pass it from the app at some point: */ + rc = bitvec_unhex(&bv, "e5e0"); + *l = OSMO_BYTES_FOR_BITS(bv.cur_bit); + msgb_put(msg, *l); + return rc; +} + static int encode_ms_ra_acc_cap(struct gprs_gmm_entity *gmme, struct msgb *msg) { int rc; @@ -264,6 +284,68 @@ return 0; } +/* Chapter 9.4.14: Routing area update request */ +int gprs_gmm_build_rau_req(struct gprs_gmm_entity *gmme, + enum gprs_gmm_upd_type rau_type, + struct msgb *msg) +{ + struct gsm48_hdr *gh; + uint8_t byte, cksn; + int rc; + struct gsm48_ra_id *raid_enc; + unsigned long t3314_sec; + uint8_t ptmsi_type_native = 1; /* Table 10.5.5.29.1 */ + + gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh)); + gh->proto_discr = GSM48_PDISC_MM_GPRS; + gh->msg_type = GSM48_MT_GMM_RA_UPD_REQ; + + /* 10.5.5.18 Update type */ + cksn = gmme->auth_ciph.req.key_seq; + byte = (cksn << 4) | (((uint8_t)rau_type) & 0x07); + msgb_put_u8(msg, byte); + + /* Old routing area identification 0.5.5.15 */ + raid_enc = (struct gsm48_ra_id *)msgb_put(msg, sizeof(struct gsm48_ra_id)); + gsm48_encode_ra(raid_enc, &gmme->ra); + + /* MS Radio Access capability 10.5.5.12a */ + rc = encode_ms_ra_acc_cap(gmme, msg); + if (rc < 0) + return -EINVAL; + + /* 10.5.5.8 Old P-TMSI signature: */ + if (gmme->ptmsi_sig != GSM_RESERVED_TMSI) { + uint8_t ptmsi_sig[3] = { gmme->ptmsi_sig >> 16, gmme->ptmsi_sig >> 8, gmme->ptmsi_sig }; + msgb_tv_fixed_put(msg, GSM48_IE_GMM_PTMSI_SIG, sizeof(ptmsi_sig), ptmsi_sig); + } + + /* 10.5.7.3 Requested READY timer value */ + t3314_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3314, OSMO_TDEF_S, -1); + msgb_tv_put(msg, GSM48_IE_GMM_TIMER_READY, gprs_gmm_secs_to_gprs_tmr_floor(t3314_sec)); + + /* DRX parameter 10.5.5.6 */ + memcpy(msgb_put(msg, sizeof(drx_param_def)), + &drx_param_def, + sizeof(drx_param_def)); + + /* 9.4.14.6 MS network capability */ + rc = encode_ms_net_cap(gmme, msg); + if (rc < 0) + return -EINVAL; + + /* 9.4.14.7 PDP context status */ + /* TODO: implement. Table 9.4.14/3GPP TS 24.00 states it is optional (O) but 9.4.14.7 states: + * "This IE shall be included by the MS." */ + + /* 9.4.14.17 P-TMSI type */ + /* Table 9.4.14/3GPP TS 24.00 states it is optional (O) but 9.4.14.17 states: + * "This IE shall be included by the MS." */ + msgb_v_put(msg, (GSM48_IE_GMM_PTMSI_TYPE << 4) | (ptmsi_type_native & 0x01)); + + return 0; +} + /* 9.2.11 Identity response */ int gprs_gmm_build_identity_resp(struct gprs_gmm_entity *gmme, uint8_t mi_type, @@ -394,3 +476,15 @@ /* TODO: optional fields: P-TMSI signature 10.5.5.8a */ return 0; } + +int gprs_gmm_build_rau_compl(struct gprs_gmm_entity *gmme, struct msgb *msg) +{ + struct gsm48_hdr *gh; + + gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh)); + gh->proto_discr = GSM48_PDISC_MM_GPRS; + gh->msg_type = GSM48_MT_GMM_RA_UPD_COMPL; + + /* TODO: Add optional IEs */ + return 0; +} diff --git a/tests/gmm/Makefile.am b/tests/gmm/Makefile.am index d066c5e..83517e5 100644 --- a/tests/gmm/Makefile.am +++ b/tests/gmm/Makefile.am @@ -38,10 +38,13 @@ $(NULL) # libosmo-gprs-llc.a is used below to access non-exported private symbols used in the test: +# libosmo-gprs-rlcmac.a is used below to access non-exported private symbols used in the test: gmm_prim_test_SOURCES = gmm_prim_test.c gmm_prim_test_LDADD = \ $(top_builddir)/src/gmm/libosmo-gprs-gmm.la \ $(top_builddir)/src/llc/.libs/libosmo-gprs-llc.a \ + $(top_builddir)/src/rlcmac/.libs/libosmo-gprs-rlcmac.a \ + $(top_builddir)/src/csn1/libosmo-csn1.la \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(NULL) diff --git a/tests/gmm/gmm_prim_test.c b/tests/gmm/gmm_prim_test.c index b403829..7eefc73 100644 --- a/tests/gmm/gmm_prim_test.c +++ b/tests/gmm/gmm_prim_test.c @@ -28,7 +28,11 @@ #include <osmocom/core/utils.h> #include <osmocom/core/fsm.h> #include <osmocom/core/msgb.h> +#include <osmocom/core/timer.h> +#include <osmocom/core/timer_compat.h> +#include <osmocom/core/select.h> +#include <osmocom/gprs/rlcmac/rlcmac_private.h> #include <osmocom/gprs/llc/llc_prim.h> #include <osmocom/gprs/llc/llc_private.h> #include <osmocom/gprs/gmm/gmm.h> @@ -133,6 +137,46 @@ 0xea, 0x71, 0x1b, 0x41 }; +/* +GSM A-I/F DTAP - Routing Area Update Accept + Protocol Discriminator: GPRS mobility management messages (8) + .... 1000 = Protocol discriminator: GPRS mobility management messages (0x8) + 0000 .... = Skip Indicator: No indication of selected PLMN (0) + DTAP GPRS Mobility Management Message Type: Routing Area Update Accept (0x09) + Force to Standby + .... 0... = Spare bit(s): 0 + .... .000 = Force to standby: Force to standby not indicated (0) + Update Result + .000 .... = Update Result: RA updated (0) + GPRS Timer - Periodic RA update timer + GPRS Timer: 10 sec + 000. .... = Unit: value is incremented in multiples of 2 seconds (0) + ...0 0101 = Timer value: 5 + Routing Area Identification - RAI: 234-70-5-0 + Routing area identification: 234-70-5-0 + Mobile Country Code (MCC): United Kingdom (234) + Mobile Network Code (MNC): AMSUK Limited (70) + Location Area Code (LAC): 0x0005 (5) + Routing Area Code (RAC): 0x00 (0) + Mobile Identity - Allocated P-TMSI - TMSI/P-TMSI (0xec999002) + Element ID: 0x18 + Length: 5 + 1111 .... = Unused: 0xf + .... 0... = Odd/even indication: Even number of identity digits + .... .100 = Mobile Identity Type: TMSI/P-TMSI/M-TMSI (4) + TMSI/P-TMSI/M-TMSI/5G-TMSI: 3969486850 (0xec999002) + GPRS Timer - Negotiated Ready Timer + Element ID: 0x17 + GPRS Timer: 10 sec + 000. .... = Unit: value is incremented in multiples of 2 seconds (0) + ...0 0101 = Timer value: 5 +*/ +static uint8_t pdu_gmm_rau_acc[] = { +0x08, 0x09, 0x00, 0x05, 0x32, 0xf4, 0x07, 0x00, +0x05, 0x00, 0x18, 0x05, 0xf4, 0xec, 0x99, 0x90, +0x02, 0x17, 0x05 +}; + static uint8_t pdu_gmm_detach_acc[] = { 0x08, 0x06, 0x00 }; @@ -145,6 +189,42 @@ return 0; } +#define clock_debug(fmt, args...) \ + do { \ + struct timespec ts; \ + struct timeval tv; \ + osmo_clock_gettime(CLOCK_MONOTONIC, &ts); \ + osmo_gettimeofday(&tv, NULL); \ + fprintf(stdout, "sys={%lu.%06lu}, mono={%lu.%06lu}: " fmt "\n", \ + tv.tv_sec, tv.tv_usec, ts.tv_sec, ts.tv_nsec/1000, ##args); \ + } while (0) + +static void clock_override_enable(bool enable) +{ + osmo_gettimeofday_override = enable; + osmo_clock_override_enable(CLOCK_MONOTONIC, enable); +} + +static void clock_override_set(long sec, long usec) +{ + struct timespec *mono; + osmo_gettimeofday_override_time.tv_sec = sec; + osmo_gettimeofday_override_time.tv_usec = usec; + mono = osmo_clock_override_gettimespec(CLOCK_MONOTONIC); + mono->tv_sec = sec; + mono->tv_nsec = usec*1000; + + clock_debug("clock_override_set"); +} + +static void clock_override_add_debug(long sec, long usec, bool dbg) +{ + osmo_gettimeofday_override_add(sec, usec); + osmo_clock_override_add(CLOCK_MONOTONIC, sec, usec*1000); + if (dbg) + clock_debug("clock_override_add"); +} +#define clock_override_add(sec, usec) clock_override_add_debug(sec, usec, true) int test_gmm_prim_up_cb(struct osmo_gprs_gmm_prim *gmm_prim, void *user_data) { @@ -252,6 +332,7 @@ int test_gmm_prim_llc_down_cb(struct osmo_gprs_llc_prim *llc_prim, void *user_data) { const char *pdu_name = osmo_gprs_llc_prim_name(llc_prim); + struct osmo_gprs_gmm_prim *gmm_prim_tx; switch (llc_prim->oph.sap) { case OSMO_GPRS_LLC_SAP_LLGMM: @@ -269,6 +350,15 @@ printf("%s(): Rx %s TLLI=0x%08x SAPI=%s l3=[%s]\n", __func__, pdu_name, llc_prim->ll.tlli, osmo_gprs_llc_sapi_name(llc_prim->ll.sapi), osmo_hexdump(llc_prim->ll.l3_pdu, llc_prim->ll.l3_pdu_len)); + switch (OSMO_PRIM_HDR(&llc_prim->oph)) { + case OSMO_PRIM(OSMO_GPRS_LLC_LL_UNITDATA, PRIM_OP_REQUEST): + /* Immediately notify GMM that it was transmitted over the air: */ + gmm_prim_tx = (struct osmo_gprs_gmm_prim *)gprs_rlcmac_prim_alloc_gmmrr_llc_transmitted_ind(llc_prim->ll.tlli); + gmm_prim_tx->oph.sap = OSMO_GPRS_GMM_SAP_GMMRR; + gmm_prim_tx->oph.primitive = OSMO_GPRS_GMM_GMMRR_LLC_TRANSMITTED; + osmo_gprs_gmm_prim_lower_up(gmm_prim_tx); + break; + } break; default: printf("%s(): Unexpected Rx %s\n", __func__, pdu_name); @@ -286,12 +376,15 @@ uint32_t ptmsi = 0x00001234; uint32_t ptmsi_sig = 0x556677; uint32_t rand_tlli = 0x80001234; + uint32_t tlli; char *imsi = "1234567890"; char *imei = "42342342342342"; char *imeisv = "4234234234234275"; printf("==== %s() [start] ====\n", __func__); + clock_override_set(0, 0); + rc = osmo_gprs_gmm_init(OSMO_GPRS_GMM_LOCATION_MS); OSMO_ASSERT(rc == 0); osmo_gprs_gmm_enable_gprs(true); @@ -338,9 +431,31 @@ OSMO_ASSERT(llc_prim); rc = osmo_gprs_gmm_prim_llc_lower_up(llc_prim); OSMO_ASSERT(rc == 0); + /* update the used ptmsi to align with what was assigned from the network: */ + ptmsi = 0xea711b41; + tlli = gprs_tmsi2tlli(ptmsi, TLLI_LOCAL); /* As a result, MS answers GMM Attach Complete */ /* As a result, MS submits GMMREG ATTACH.cnf */ + /* Wait for READY timer to expire: */ + clock_override_add(44, 0); /* 44: See GMM Attach Accept (pdu_gmm_att_acc) feed above */ + clock_debug("Expect T3314 (READY) timeout"); + osmo_select_main(0); + + clock_override_add(10*60, 0); /* 44: See GMM Attach Accept (pdu_gmm_att_acc) feed above */ + clock_debug("Expect T3312 (periodic RAU) timeout"); + osmo_select_main(0); + + /* Network sends GMM RAU Accept */ + llc_prim = gprs_llc_prim_alloc_ll_unitdata_ind(tlli, OSMO_GPRS_LLC_SAPI_GMM, (uint8_t *)pdu_gmm_rau_acc, sizeof(pdu_gmm_rau_acc)); + OSMO_ASSERT(llc_prim); + rc = osmo_gprs_gmm_prim_llc_lower_up(llc_prim); + OSMO_ASSERT(rc == 0); + /* update the used ptmsi to align with what was assigned from the network: */ + ptmsi = 0xea711b41; + tlli = gprs_tmsi2tlli(ptmsi, TLLI_LOCAL); + /* As a result, MS answers GMM RAU Complete */ + /* ... */ /* DETACH */ @@ -353,7 +468,7 @@ OSMO_ASSERT(rc == 0); /* Network sends GMM Detach Accept */ - llc_prim = gprs_llc_prim_alloc_ll_unitdata_ind(rand_tlli, OSMO_GPRS_LLC_SAPI_GMM, (uint8_t *)pdu_gmm_detach_acc, sizeof(pdu_gmm_detach_acc)); + llc_prim = gprs_llc_prim_alloc_ll_unitdata_ind(tlli, OSMO_GPRS_LLC_SAPI_GMM, (uint8_t *)pdu_gmm_detach_acc, sizeof(pdu_gmm_detach_acc)); OSMO_ASSERT(llc_prim); rc = osmo_gprs_gmm_prim_llc_lower_up(llc_prim); OSMO_ASSERT(rc == 0); @@ -379,6 +494,8 @@ printf("==== %s() [start] ====\n", __func__); + clock_override_set(0, 0); + rc = osmo_gprs_gmm_init(OSMO_GPRS_GMM_LOCATION_MS); OSMO_ASSERT(rc == 0); osmo_gprs_gmm_enable_gprs(true); @@ -460,6 +577,8 @@ log_set_print_level(osmo_stderr_target, 1); log_set_use_color(osmo_stderr_target, 0); + clock_override_enable(true); + test_gmm_prim_ms_gmmreg(); test_gmm_prim_ms_gmmsm(); diff --git a/tests/gmm/gmm_prim_test.err b/tests/gmm/gmm_prim_test.err index 7aca515..6720d69 100644 --- a/tests/gmm/gmm_prim_test.err +++ b/tests/gmm/gmm_prim_test.err @@ -4,28 +4,50 @@ DLGLOBAL INFO GMM_MS{Null}: state_chg to Deregistered DLGLOBAL INFO GMM_MS{Deregistered}: Received Event ATTACH_REQUESTED DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Tx GMM ATTACH REQUEST (new TLLI=0x80001234) +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication DLGLOBAL INFO GMM_MS{Deregistered}: state_chg to RegisteredInitiated DLGLOBAL INFO Rx from lower layers: LL-UNITDATA.indication DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Rx GMM IDENTITY REQUEST mi_type=IMEI DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Tx GMM IDENTITY RESPONSE +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication DLGLOBAL INFO Rx from lower layers: LL-UNITDATA.indication DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Rx GMM AUTHENTICATION AND CIPHERING REQUEST DLGLOBAL INFO Rx from upper layers: GMMREG-SIM_AUTH.response DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Tx GMM GMM AUTHENTICATION AND CIPHERING RESPONSE +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication DLGLOBAL INFO Rx from lower layers: LL-UNITDATA.indication DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Rx GMM ATTACH ACCEPT DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) Tx GMM ATTACH COMPL +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) READY timer started (expires in 44 seconds) DLGLOBAL INFO GMM_MS{RegisteredInitiated}: Received Event ATTACH_ACCEPTED DLGLOBAL INFO GMM_MS{RegisteredInitiated}: state_chg to Registered +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) READY timer expired +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) T3312 started (expires in 600 seconds) +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) T3312 Periodic RAU timer expired +DLGLOBAL INFO GMM_MS{Registered}: Received Event RAU_REQUESTED +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) Tx GMM RAU REQUEST +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) READY timer started (expires in 44 seconds) +DLGLOBAL INFO GMM_MS{Registered}: state_chg to RAUInitidated +DLGLOBAL INFO Rx from lower layers: LL-UNITDATA.indication +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) Rx GMM RAU ACCEPT upd_result=0x00 +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ec999002:TLLI-ec999002) Tx GMM RAU COMPL +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ec999002:TLLI-ec999002) READY timer started (expires in 10 seconds) +DLGLOBAL INFO GMM_MS{RAUInitidated}: Received Event RAU_ACCEPTED +DLGLOBAL INFO GMM_MS{RAUInitidated}: state_chg to Registered DLGLOBAL INFO Rx from upper layers: GMMREG-DETACH.request DLGLOBAL INFO GMM_MS{Registered}: Received Event DETACH_REQUESTED DLGLOBAL INFO GMM_MS{Registered}: state_chg to DeregisteredInitiated -DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) Tx GMM DETACH REQUEST (MO) +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ec999002:TLLI-ec999002) Tx GMM DETACH REQUEST (MO) +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ec999002:TLLI-ec999002) READY timer started (expires in 10 seconds) DLGLOBAL INFO Rx from lower layers: LL-UNITDATA.indication -DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) Rx GMM DETACH ACCEPT (MO) force_standby_indicated=false +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ec999002:TLLI-ec999002) Rx GMM DETACH ACCEPT (MO) force_standby_indicated=false DLGLOBAL INFO GMM_MS{DeregisteredInitiated}: Received Event DETACH_ACCEPTED DLGLOBAL INFO GMM_MS{DeregisteredInitiated}: state_chg to Deregistered -DLGLOBAL DEBUG GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ffffffff) free() +DLGLOBAL DEBUG GMME(IMSI-1234567890:PTMSI-ec999002:TLLI-ffffffff) free() DLGLOBAL INFO GMM_MS{Deregistered}: Deallocated DLGLOBAL INFO Rx from upper layers: GMMSM-ESTABLISH.request DLGLOBAL INFO GMM_MS{Null}: Allocated @@ -33,18 +55,25 @@ DLGLOBAL INFO GMM_MS{Null}: state_chg to Deregistered DLGLOBAL INFO GMM_MS{Deregistered}: Received Event ATTACH_REQUESTED DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Tx GMM ATTACH REQUEST (new TLLI=0x80001234) +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication DLGLOBAL INFO GMM_MS{Deregistered}: state_chg to RegisteredInitiated DLGLOBAL INFO Rx from lower layers: LL-UNITDATA.indication DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Rx GMM IDENTITY REQUEST mi_type=IMEI DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Tx GMM IDENTITY RESPONSE +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication DLGLOBAL INFO Rx from lower layers: LL-UNITDATA.indication DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Rx GMM AUTHENTICATION AND CIPHERING REQUEST DLGLOBAL INFO Rx from upper layers: GMMREG-SIM_AUTH.response DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Tx GMM GMM AUTHENTICATION AND CIPHERING RESPONSE +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication DLGLOBAL INFO Rx from lower layers: LL-UNITDATA.indication DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-00001234:TLLI-80001234) Rx GMM ATTACH ACCEPT DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) Tx GMM ATTACH COMPL +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) READY timer started (expires in 44 seconds) DLGLOBAL INFO GMM_MS{RegisteredInitiated}: Received Event ATTACH_ACCEPTED DLGLOBAL INFO GMM_MS{RegisteredInitiated}: state_chg to Registered DLGLOBAL INFO Rx from upper layers: GMMSM-UNITDATA.request +DLGLOBAL INFO Rx from lower layers: GMRR-LLC_TRANSMITTED.indication +DLGLOBAL INFO GMME(IMSI-1234567890:PTMSI-ea711b41:TLLI-ea711b41) READY timer started (expires in 44 seconds) DLGLOBAL INFO Rx from lower layers: LL-UNITDATA.indication diff --git a/tests/gmm/gmm_prim_test.ok b/tests/gmm/gmm_prim_test.ok index 068876b..870d58f 100644 --- a/tests/gmm/gmm_prim_test.ok +++ b/tests/gmm/gmm_prim_test.ok @@ -1,4 +1,5 @@ ==== test_gmm_prim_ms_gmmreg() [start] ==== +sys={0.000000}, mono={0.000000}: clock_override_set test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 01 04 97 07 00 00 01 0a 00 05 f4 00 00 12 34 00 f0 00 00 00 00 00 19 55 66 77 17 16 e1 ] test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 16 08 42 32 24 43 32 24 43 f2 ] test_gmm_prim_up_cb(): Rx GMMREG-SIM_AUTH.indication ac_ref_nr=2 key_seq=0 rand=e2 a6 f3 f8 bb 9e a7 01 e0 ce 4f 33 64 a9 91 75 @@ -8,11 +9,22 @@ test_gmm_prim_down_cb(): Rx GMRR-ASSIGN.request old_tlli=0x80001234 new_tlli=0xea711b41 test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0xea711b41 SAPI=GMM l3=[08 03 ] test_gmm_prim_up_cb(): Rx GMMREG-ATTACH.confirm accepted=1 allocated_ptmsi=0xea711b41 allocated_ptmsi_sig=0xffffffff -test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0xea711b41 SAPI=GMM l3=[08 05 20 0a 00 05 f4 ea 71 1b 41 ] -test_gmm_prim_llc_down_cb(): Rx LLGMM-ASSIGN.request old_TLLI=0xea711b41 new_TLLI=0xffffffff +sys={44.000000}, mono={44.000000}: clock_override_add +sys={44.000000}, mono={44.000000}: Expect T3314 (READY) timeout +sys={644.000000}, mono={644.000000}: clock_override_add +sys={644.000000}, mono={644.000000}: Expect T3312 (periodic RAU) timeout +test_gmm_prim_llc_down_cb(): Rx LLGMM-SUSPEND.request TLLI=0xea711b41 +test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0xea711b41 SAPI=GMM l3=[08 08 03 32 f4 07 00 05 00 00 17 16 0a 00 e5 02 00 00 e1 ] +test_gmm_prim_llc_down_cb(): Rx LLGMM-ASSIGN.request old_TLLI=0xea711b41 new_TLLI=0xec999002 +test_gmm_prim_down_cb(): Rx GMRR-ASSIGN.request old_tlli=0xea711b41 new_tlli=0xec999002 +test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0xec999002 SAPI=GMM l3=[08 0a ] +test_gmm_prim_llc_down_cb(): Rx LLGMM-RESUME.request TLLI=0xec999002 +test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0xec999002 SAPI=GMM l3=[08 05 20 0a 00 05 f4 ec 99 90 02 ] +test_gmm_prim_llc_down_cb(): Rx LLGMM-ASSIGN.request old_TLLI=0xec999002 new_TLLI=0xffffffff test_gmm_prim_up_cb(): Rx GMMREG-DETACH.confirm detach_type='GPRS detach' ==== test_gmm_prim_ms_gmmreg() [end] ==== ==== test_gmm_prim_ms_gmmsm() [start] ==== +sys={0.000000}, mono={0.000000}: clock_override_set test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 01 04 97 07 00 00 01 0a 00 05 f4 00 00 12 34 00 f0 00 00 00 00 00 19 55 66 77 17 16 e1 ] test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 16 08 42 32 24 43 32 24 43 f2 ] test_gmm_prim_up_cb(): Rx GMMREG-SIM_AUTH.indication ac_ref_nr=2 key_seq=0 rand=e2 a6 f3 f8 bb 9e a7 01 e0 ce 4f 33 64 a9 91 75 -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32925 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: Ie7cba8a2fe3b97bebc558c957cc1bcbe3cc81dbc Gerrit-Change-Number: 32925 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • ...
  • 259
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.