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
[M] Change in libosmocore[master]: gsm0503_tch_hr_decode2(): new function, emits TS101318 format
by falconia 23 May '23

23 May '23
falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32962 ) Change subject: gsm0503_tch_hr_decode2(): new function, emits TS101318 format ...................................................................... gsm0503_tch_hr_decode2(): new function, emits TS101318 format The original design of gsm0503_tch_hr_{en,de}code() functions contains a mistake in that a pseudo-RFC5993 format was chosen for HR codec frame input and output, instead of "pure" (agnostic to outer RTP encoding) form of 14 bytes. We would like to change this design so that we can feed pure 14-byte HR codec frames to the channel coding function and get such frames back from the channel decoding function - however, we cannot break libosmocoding API for existing users. In the decoding direction, create a new function that emits TS 101 318 format, and turn the legacy gsm0503_tch_hr_decode() API into a wrapper function for backward compatibility. Related: OS#5688 Change-Id: If28ddb20789e8993b7558ca08020478615b4c708 --- M TODO-RELEASE M include/osmocom/coding/gsm0503_coding.h M src/coding/gsm0503_coding.c 3 files changed, 62 insertions(+), 10 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified fixeria: Looks good to me, approved diff --git a/TODO-RELEASE b/TODO-RELEASE index 7270257..ebda4c5 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -11,3 +11,5 @@ libosmocore ADD new defines in osmocom/gsm/protocol/gsm_04_08.h (old ones marked deprecated) libosmovty drop API drop struct vty_parent_node from public API, it should never have been public libosmocore ADD new API osmo_io_*() +libosmocoding ADD new gsm0503_tch_hr_decode2() public API, previous API + gsm0503_tch_hr_decode() marked as deprecated diff --git a/include/osmocom/coding/gsm0503_coding.h b/include/osmocom/coding/gsm0503_coding.h index 2afa049..2112b0f 100644 --- a/include/osmocom/coding/gsm0503_coding.h +++ b/include/osmocom/coding/gsm0503_coding.h @@ -50,6 +50,9 @@ int gsm0503_tch_hr_encode(ubit_t *bursts, const uint8_t *tch_data, int len); int gsm0503_tch_hr_decode(uint8_t *tch_data, const sbit_t *bursts, int odd, + int *n_errors, int *n_bits_total) + OSMO_DEPRECATED("Use gsm0503_tch_hr_decode2() instead"); +int gsm0503_tch_hr_decode2(uint8_t *tch_data, const sbit_t *bursts, int odd, int *n_errors, int *n_bits_total); int gsm0503_tch_afs_encode(ubit_t *bursts, const uint8_t *tch_data, int len, diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c index 4f1ac79..6f76824 100644 --- a/src/coding/gsm0503_coding.c +++ b/src/coding/gsm0503_coding.c @@ -1572,16 +1572,14 @@ } } -/* assemble a HR codec frame in format as used inside RTP */ +/* assemble a HR codec frame in the canonical format of ETSI TS 101 318 */ static void tch_hr_reassemble(uint8_t *tch_data, const ubit_t *b_bits) { - int i, j; + int i; - tch_data[0] = 0x00; /* F = 0, FT = 000 */ - memset(tch_data + 1, 0, 14); - - for (i = 0, j = 8; i < 112; i++, j++) - tch_data[j >> 3] |= (b_bits[i] << (7 - (j & 7))); + memset(tch_data, 0, GSM_HR_BYTES); + for (i = 0; i < 112; i++) + tch_data[i >> 3] |= (b_bits[i] << (7 - (i & 7))); } static void tch_hr_disassemble(ubit_t *b_bits, const uint8_t *tch_data) @@ -1977,13 +1975,13 @@ } /*! Perform channel decoding of a HR(v1) channel according TS 05.03 - * \param[out] tch_data Codec frame in RTP payload format + * \param[out] tch_data Codec frame in TS 101 318 canonical format * \param[in] bursts buffer containing the symbols of 8 bursts * \param[in] odd Odd (1) or even (0) frame number * \param[out] n_errors Number of detected bit errors * \param[out] n_bits_total Total number of bits * \returns length of bytes used in \a tch_data output buffer; negative on error */ -int gsm0503_tch_hr_decode(uint8_t *tch_data, const sbit_t *bursts, int odd, +int gsm0503_tch_hr_decode2(uint8_t *tch_data, const sbit_t *bursts, int odd, int *n_errors, int *n_bits_total) { sbit_t iB[912], cB[456], h; @@ -2050,7 +2048,35 @@ tch_hr_reassemble(tch_data, b); - return 15; + return GSM_HR_BYTES; +} + +/*! Perform channel decoding of a HR(v1) channel according TS 05.03, + * deprecated legacy API. + * \param[out] tch_data Codec frame in pseudo-RFC5993 format + * \param[in] bursts buffer containing the symbols of 8 bursts + * \param[in] odd Odd (1) or even (0) frame number + * \param[out] n_errors Number of detected bit errors + * \param[out] n_bits_total Total number of bits + * \returns length of bytes used in \a tch_data output buffer; negative on error + * + * The HR1 codec frame format returned by this function is pseudo-RFC5993, + * not true RFC 5993, as there is no SID classification being done + * and the FT bits in the ToC octet are always set to 0 - but this + * arguably-bogus format is the legacy public API. + */ +int gsm0503_tch_hr_decode(uint8_t *tch_data, const sbit_t *bursts, int odd, + int *n_errors, int *n_bits_total) +{ + int rc; + + rc = gsm0503_tch_hr_decode2(tch_data, bursts, odd, n_errors, + n_bits_total); + if (rc != GSM_HR_BYTES) + return rc; + memmove(tch_data + 1, tch_data, GSM_HR_BYTES); + tch_data[0] = 0x00; /* FT=0, note absence of SID classification */ + return GSM_HR_BYTES_RTP_RFC5993; } /*! Perform channel encoding on a TCH/HS channel according to TS 05.03 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32962 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: If28ddb20789e8993b7558ca08020478615b4c708 Gerrit-Change-Number: 32962 Gerrit-PatchSet: 3 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in libosmocore[master]: gsm0503_tch_hr_decode(): look at all 8 stealing bits
by falconia 23 May '23

23 May '23
falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32960 ) Change subject: gsm0503_tch_hr_decode(): look at all 8 stealing bits ...................................................................... gsm0503_tch_hr_decode(): look at all 8 stealing bits This function needs to look at hl and hu stealing bits in order to decide if it should decode FACCH/H instead of TCH/HS traffic. However, out of the 8 (in total) hl and hu bits that get set when FACCH/H stealing takes place, the function only looked at 7 of them - one was missed. Fix this bug. Change-Id: I08c4358b26d69910190f89a53b654bc58c2efea9 --- M src/coding/gsm0503_coding.c 1 file changed, 16 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve fixeria: Looks good to me, approved diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c index 3fd440f..ce24650 100644 --- a/src/coding/gsm0503_coding.c +++ b/src/coding/gsm0503_coding.c @@ -1997,7 +1997,7 @@ steal -= h; } - for (i = 2; i < 5; i++) { + for (i = 2; i < 6; i++) { gsm0503_tch_burst_unmap(NULL, &bursts[i * 116], &h, 1); steal -= h; } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32960 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I08c4358b26d69910190f89a53b654bc58c2efea9 Gerrit-Change-Number: 32960 Gerrit-PatchSet: 1 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in libosmocore[master]: gsm0503_tch_hr_decode2(): new function, emits TS101318 format
by fixeria 23 May '23

23 May '23
Attention is currently required from: falconia, pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32962 ) Change subject: gsm0503_tch_hr_decode2(): new function, emits TS101318 format ...................................................................... Patch Set 3: Code-Review+2 (1 comment) File src/coding/gsm0503_coding.c: https://gerrit.osmocom.org/c/libosmocore/+/32962/comment/96b979e9_f29c0d7f PS3, Line 1979: symbols of 8 bursts Not related to this patch, but worth mentioning: this is incorrect and probably was copy-pasted from `gsm0503_tch_fr_decode()`. For TCH/H (to be precise, for FACCH/H) the interleaving buffer is 6 bursts wide. I will submit a patch fixing this on top of your patchset to avoid conflicts. -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32962 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: If28ddb20789e8993b7558ca08020478615b4c708 Gerrit-Change-Number: 32962 Gerrit-PatchSet: 3 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: falconia <falcon(a)freecalypso.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 23 May 2023 18:06:04 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in libosmocore[master]: gsm0503_tch_hr_encode(): accept both TS101318 and RFC5993 payloads
by fixeria 23 May '23

23 May '23
Attention is currently required from: falconia, pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32961 ) Change subject: gsm0503_tch_hr_encode(): accept both TS101318 and RFC5993 payloads ...................................................................... Patch Set 3: Code-Review+2 (2 comments) File src/coding/gsm0503_coding.c: https://gerrit.osmocom.org/c/libosmocore/+/32961/comment/2930de3d_9835b280 PS1, Line 1591: for (i = 0; i < 112; i++) > Yes, I am changing the internal static function to take unprefixed 14-byte payloads as input, rather […] Ack File src/coding/gsm0503_coding.c: https://gerrit.osmocom.org/c/libosmocore/+/32961/comment/c71c17d5_db61597a PS2, Line 2093: > I see your point - I'll make a new version without those spaces. Done -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32961 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I13eaad366f9f68615b9e9e4a5f87396a0e9dea0f Gerrit-Change-Number: 32961 Gerrit-PatchSet: 3 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: falconia <falcon(a)freecalypso.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 23 May 2023 17:53:45 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Comment-In-Reply-To: falconia <falcon(a)freecalypso.org> Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[S] Change in libosmocore[master]: gsm0503_tch_hr_decode(): look at all 8 stealing bits
by fixeria 23 May '23

23 May '23
Attention is currently required from: falconia. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32960 ) Change subject: gsm0503_tch_hr_decode(): look at all 8 stealing bits ...................................................................... Patch Set 1: (1 comment) Patchset: PS1: Good catch! Might be worth back-porting this patch to latest release. -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32960 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I08c4358b26d69910190f89a53b654bc58c2efea9 Gerrit-Change-Number: 32960 Gerrit-PatchSet: 1 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: falconia <falcon(a)freecalypso.org> Gerrit-Comment-Date: Tue, 23 May 2023 17:47:57 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[S] Change in libosmocore[master]: gsm0503_tch_hr_decode(): look at all 8 stealing bits
by fixeria 23 May '23

23 May '23
Attention is currently required from: falconia. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32960 ) Change subject: gsm0503_tch_hr_decode(): look at all 8 stealing bits ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32960 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I08c4358b26d69910190f89a53b654bc58c2efea9 Gerrit-Change-Number: 32960 Gerrit-PatchSet: 1 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: falconia <falcon(a)freecalypso.org> Gerrit-Comment-Date: Tue, 23 May 2023 17:46:57 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in libosmo-gprs[master]: sm: Forward forth and back the P-TMSI signature
by pespin 23 May '23

23 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32803 ) Change subject: sm: Forward forth and back the P-TMSI signature ...................................................................... sm: Forward forth and back the P-TMSI signature Change-Id: Ia69b6f885d612c42ab015822031e4c7262f4714e --- M include/osmocom/gprs/sm/sm_prim.h M include/osmocom/gprs/sm/sm_private.h M src/sm/sm.c M src/sm/sm_prim.c 4 files changed, 16 insertions(+), 0 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/sm/sm_prim.h b/include/osmocom/gprs/sm/sm_prim.h index d9be348..d4e17a4 100644 --- a/include/osmocom/gprs/sm/sm_prim.h +++ b/include/osmocom/gprs/sm/sm_prim.h @@ -65,6 +65,7 @@ uint8_t pco_len; struct { uint32_t ptmsi; + uint32_t ptmsi_sig; bool attach_with_imsi; char imsi[OSMO_IMSI_BUF_SIZE]; char imei[GSM23003_IMEI_NUM_DIGITS + 1]; @@ -89,6 +90,7 @@ uint8_t qos_len; struct { uint32_t allocated_ptmsi; + uint32_t allocated_ptmsi_sig; uint32_t allocated_tlli; struct gprs_ra_id rai; } gmm; diff --git a/include/osmocom/gprs/sm/sm_private.h b/include/osmocom/gprs/sm/sm_private.h index 6bf456f..98eaf79 100644 --- a/include/osmocom/gprs/sm/sm_private.h +++ b/include/osmocom/gprs/sm/sm_private.h @@ -127,6 +127,7 @@ struct { uint32_t ptmsi; + uint32_t ptmsi_sig; uint32_t tlli; char imsi[OSMO_IMSI_BUF_SIZE]; char imei[GSM23003_IMEI_NUM_DIGITS + 1]; diff --git a/src/sm/sm.c b/src/sm/sm.c index c5520bf..79fbc7d 100644 --- a/src/sm/sm.c +++ b/src/sm/sm.c @@ -193,6 +193,7 @@ gmm_prim_tx->gmmsm.establish_req.attach_type = OSMO_GPRS_GMM_ATTACH_TYPE_GPRS; gmm_prim_tx->gmmsm.establish_req.attach_with_imsi = (ms->gmm.ptmsi == GSM_RESERVED_TMSI); gmm_prim_tx->gmmsm.establish_req.ptmsi = ms->gmm.ptmsi; + gmm_prim_tx->gmmsm.establish_req.ptmsi_sig = ms->gmm.ptmsi_sig; OSMO_STRLCPY_ARRAY(gmm_prim_tx->gmmsm.establish_req.imsi, ms->gmm.imsi); OSMO_STRLCPY_ARRAY(gmm_prim_tx->gmmsm.establish_req.imei, ms->gmm.imei); OSMO_STRLCPY_ARRAY(gmm_prim_tx->gmmsm.establish_req.imeisv, ms->gmm.imeisv); @@ -224,6 +225,7 @@ if (sme->qos_len) memcpy(sm_prim_tx->smreg.pdp_act_cnf.acc.qos, &sme->qos, sme->qos_len); sm_prim_tx->smreg.pdp_act_cnf.acc.gmm.allocated_ptmsi = sme->ms->gmm.ptmsi; + sm_prim_tx->smreg.pdp_act_cnf.acc.gmm.allocated_ptmsi_sig = sme->ms->gmm.ptmsi_sig; sm_prim_tx->smreg.pdp_act_cnf.acc.gmm.allocated_tlli = sme->ms->gmm.tlli; memcpy(&sm_prim_tx->smreg.pdp_act_cnf.acc.gmm.rai, &sme->ms->gmm.ra, sizeof(sme->ms->gmm.ra)); } else { diff --git a/src/sm/sm_prim.c b/src/sm/sm_prim.c index ea84d3e..158959e 100644 --- a/src/sm/sm_prim.c +++ b/src/sm/sm_prim.c @@ -270,6 +270,7 @@ /* Info required to establish GMM: */ ms->gmm.ptmsi = sm_prim->smreg.pdp_act_req.gmm.ptmsi; + ms->gmm.ptmsi_sig = sm_prim->smreg.pdp_act_req.gmm.ptmsi_sig; if (sm_prim->smreg.pdp_act_req.gmm.imsi[0] != '\0') OSMO_STRLCPY_ARRAY(ms->gmm.imsi, sm_prim->smreg.pdp_act_req.gmm.imsi); if (sm_prim->smreg.pdp_act_req.gmm.imei[0] != '\0') @@ -479,6 +480,7 @@ /* Update allocated PTMSI: */ if (gmm_prim->gmmsm.establish_cnf.acc.allocated_ptmsi != GSM_RESERVED_TMSI) sme->ms->gmm.ptmsi = gmm_prim->gmmsm.establish_cnf.acc.allocated_ptmsi; + sme->ms->gmm.ptmsi_sig = gmm_prim->gmmsm.establish_cnf.acc.allocated_ptmsi_sig; /* Set allocated TLLI: */ sme->ms->gmm.tlli = gmm_prim->gmmsm.establish_cnf.acc.allocated_tlli; /* Set the current RAI: */ -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32803 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: Ia69b6f885d612c42ab015822031e4c7262f4714e Gerrit-Change-Number: 32803 Gerrit-PatchSet: 2 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]: gmmrr: Add new LLC_TRANSMITTED.ind
by pespin 23 May '23

23 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32905 ) Change subject: gmmrr: Add new LLC_TRANSMITTED.ind ...................................................................... gmmrr: Add new LLC_TRANSMITTED.ind This event doesn't show up as an explicit primitive in TS 24.007 GMMRR SAP, but it is clearly needed to (re)arm the READY timer in GMM layer as per TS 24.008 section 4.7.2.1.1: """ The READY timer is started: - in the MS when the GMM entity receives an indication from lower layers that an LLC frame other than LLC NULL frame has been transmitted on the radio interface; """ Change-Id: I9fd4047cfae4a12ad3be41860032eeda263d3276 --- M include/osmocom/gprs/gmm/gmm_prim.h M include/osmocom/gprs/rlcmac/rlcmac_prim.h M include/osmocom/gprs/rlcmac/rlcmac_private.h M src/gmm/gmm_prim.c M src/rlcmac/rlcmac_prim.c M src/rlcmac/tbf_ul.c M tests/rlcmac/rlcmac_prim_test.ok 7 files changed, 62 insertions(+), 0 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_prim.h b/include/osmocom/gprs/gmm/gmm_prim.h index 3b2ee70..4b8657f 100644 --- a/include/osmocom/gprs/gmm/gmm_prim.h +++ b/include/osmocom/gprs/gmm/gmm_prim.h @@ -161,11 +161,13 @@ }; /* TS 24.007 Section 9.3.2 "Service primitives for GMMRR-SAP (GSM only)" + * OSMO_GPRS_GMM_GMMRR_LLC_TRANSMITTED: addition implementing TS 24.008 4.7.2.1.1 * Same as enum osmo_gprs_rlcmac_gmmrr_prim_type. */ enum osmo_gprs_gmm_gmmrr_prim_type { OSMO_GPRS_GMM_GMMRR_ASSIGN, /* Req: newTLLI */ OSMO_GPRS_GMM_GMMRR_PAGE, /* Ind: TLLI */ + OSMO_GPRS_GMM_GMMRR_LLC_TRANSMITTED, /* Ind: TLLI */ }; extern const struct value_string osmo_gprs_gmm_gmmrr_prim_type_names[]; static inline const char *osmo_gprs_gmm_gmmrr_prim_type_name(enum osmo_gprs_gmm_gmmrr_prim_type val) @@ -187,6 +189,9 @@ /* OSMO_GPRS_GMM_GMMRR_PAGE | Ind */ struct { } page_ind; + /* OSMO_GPRS_GMM_GMMRR_LLC_TRANSMITTED | Ind */ + struct { + } llc_transmitted_ind; }; }; diff --git a/include/osmocom/gprs/rlcmac/rlcmac_prim.h b/include/osmocom/gprs/rlcmac/rlcmac_prim.h index ae6c0d1..c44de22 100644 --- a/include/osmocom/gprs/rlcmac/rlcmac_prim.h +++ b/include/osmocom/gprs/rlcmac/rlcmac_prim.h @@ -66,10 +66,12 @@ }; /* TS 24.007 Section 9.3.2 "Service primitives for GMMRR-SAP (GSM only)" + * OSMO_GPRS_RLCMAC_GMMRR_LLC_TRANSMITTED: addition implementing TS 24.008 4.7.2.1.1 * Same as enum osmo_gprs_gmm_gmmrr_prim_type. */ enum osmo_gprs_rlcmac_gmmrr_prim_type { OSMO_GPRS_RLCMAC_GMMRR_ASSIGN, /* Req: newTLLI */ + OSMO_GPRS_RLCMAC_GMMRR_LLC_TRANSMITTED, /* Ind: TLLI */ OSMO_GPRS_RLCMAC_GMMRR_PAGE, /* Ind: TLLI */ }; @@ -93,6 +95,9 @@ /* OSMO_GPRS_RLCMAC_GMMRR_PAGE | Ind */ struct { } page_ind; + /* OSMO_GPRS_RLCMAC_GMMRR_LLC_TRANSMITTED | Ind */ + struct { + } llc_transmitted_ind; }; }; diff --git a/include/osmocom/gprs/rlcmac/rlcmac_private.h b/include/osmocom/gprs/rlcmac/rlcmac_private.h index da7ba67..e73d23e 100644 --- a/include/osmocom/gprs/rlcmac/rlcmac_private.h +++ b/include/osmocom/gprs/rlcmac/rlcmac_private.h @@ -100,6 +100,7 @@ struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_grr_unitdata_ind( uint32_t tlli, uint8_t *ll_pdu, size_t ll_pdu_len); struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_gmmrr_page_ind(uint32_t tlli); +struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_gmmrr_llc_transmitted_ind(uint32_t tlli); struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_l1ctl_rach8_req(uint8_t ra); struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_l1ctl_rach11_req(uint16_t ra11, uint8_t synch_seq); diff --git a/src/gmm/gmm_prim.c b/src/gmm/gmm_prim.c index b2f1fdc..7ca6535 100644 --- a/src/gmm/gmm_prim.c +++ b/src/gmm/gmm_prim.c @@ -56,6 +56,7 @@ const struct value_string osmo_gprs_gmm_gmmrr_prim_type_names[] = { { OSMO_GPRS_GMM_GMMRR_ASSIGN, "ASSIGN" }, { OSMO_GPRS_GMM_GMMRR_PAGE, "PAGE" }, + { OSMO_GPRS_GMM_GMMRR_LLC_TRANSMITTED, "LLC_TRANSMITTED" }, { 0, NULL } }; @@ -610,6 +611,10 @@ rc = gprs_gmm_prim_handle_unsupported(gmm_prim); 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; + break; default: rc = gprs_gmm_prim_handle_unsupported(gmm_prim); rc = 1; diff --git a/src/rlcmac/rlcmac_prim.c b/src/rlcmac/rlcmac_prim.c index 3a05d4e..7337647 100644 --- a/src/rlcmac/rlcmac_prim.c +++ b/src/rlcmac/rlcmac_prim.c @@ -59,6 +59,7 @@ const struct value_string osmo_gprs_rlcmac_gmmrr_prim_type_names[] = { { OSMO_GPRS_RLCMAC_GMMRR_ASSIGN, "ASSIGN" }, { OSMO_GPRS_RLCMAC_GMMRR_PAGE, "PAGE" }, + { OSMO_GPRS_RLCMAC_GMMRR_LLC_TRANSMITTED, "LLC_TRANSMITTED" }, { 0, NULL } }; @@ -222,6 +223,16 @@ return rlcmac_prim; } +/* TS 24.008 4.7.2.1.1: indication towards GMM that an LLC frame other than LLC + * NULL frame has been transmitted on the radio interface */ +struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_gmmrr_llc_transmitted_ind(uint32_t tlli) +{ + struct osmo_gprs_rlcmac_prim *rlcmac_prim; + rlcmac_prim = rlcmac_prim_gmmrr_alloc(OSMO_GPRS_RLCMAC_GMMRR_LLC_TRANSMITTED, PRIM_OP_INDICATION, 0); + rlcmac_prim->gmmrr.tlli = tlli; + return rlcmac_prim; +} + /* L1CTL-RACH.req (8bit) */ struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_l1ctl_rach8_req(uint8_t ra) { diff --git a/src/rlcmac/tbf_ul.c b/src/rlcmac/tbf_ul.c index 8e03207..40e993c 100644 --- a/src/rlcmac/tbf_ul.c +++ b/src/rlcmac/tbf_ul.c @@ -330,6 +330,8 @@ void gprs_rlcmac_ul_tbf_schedule_next_llc_frame(struct gprs_rlcmac_ul_tbf *ul_tbf) { + struct osmo_gprs_rlcmac_prim *rlcmac_prim_tx; + if (ul_tbf->llc_tx_msg && msgb_length(ul_tbf->llc_tx_msg)) return; @@ -342,6 +344,14 @@ LOGPTBFUL(ul_tbf, LOGL_DEBUG, "Dequeue next LLC (len=%d)\n", msgb_length(ul_tbf->llc_tx_msg)); ul_tbf->last_ul_drained_fn = -1; + + /* TS 24.008 section 4.7.2.1.1: "The READY timer is started in the MS + * when the GMM entity receives an indication from lower layers that an LLC frame + * other than LLC NULL frame has been transmitted on the radio interface". + * hence, signal here to GMM the event. + */ + rlcmac_prim_tx = gprs_rlcmac_prim_alloc_gmmrr_llc_transmitted_ind(ul_tbf->tbf.gre->tlli); + gprs_rlcmac_prim_call_up_cb(rlcmac_prim_tx); } static int create_new_bsn(struct gprs_rlcmac_ul_tbf *ul_tbf, const struct gprs_rlcmac_rts_block_ind *bi, enum gprs_rlcmac_coding_scheme cs) diff --git a/tests/rlcmac/rlcmac_prim_test.ok b/tests/rlcmac/rlcmac_prim_test.ok index 71b9888..24abafa 100644 --- a/tests/rlcmac/rlcmac_prim_test.ok +++ b/tests/rlcmac/rlcmac_prim_test.ok @@ -2,6 +2,7 @@ sys={0.000000}, mono={0.000000}: clock_override_set test_rlcmac_prim_down_cb(): Rx L1CTL-RACH.request ra=0x7e test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0x80 +test_rlcmac_prim_up_cb(): Rx GMMRR-LLC_TRANSMITTED.indication TLLI=0x00002342 test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=4 ts=7 data_len=34 data=[3c 01 01 00 00 23 42 01 c0 00 08 01 01 d5 71 00 00 08 29 26 24 00 00 00 00 71 62 f2 24 6c 84 44 04 00 ] test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=8 ts=7 data_len=34 data=[00 01 02 1d 00 00 23 42 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 ] test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0x00 @@ -34,6 +35,7 @@ sys={0.000000}, mono={0.000000}: clock_override_set test_rlcmac_prim_down_cb(): Rx L1CTL-RACH.request ra=0x7a test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0x80 +test_rlcmac_prim_up_cb(): Rx GMMRR-LLC_TRANSMITTED.indication TLLI=0x00002342 test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=4 ts=7 data_len=34 data=[3c 01 01 00 00 23 42 01 c0 00 08 01 01 d5 71 00 00 08 29 26 24 00 00 00 00 71 62 f2 24 6c 84 44 04 00 ] sys={5.000000}, mono={5.000000}: clock_override_add sys={5.000000}, mono={5.000000}: Expect T3166 timeout @@ -62,6 +64,7 @@ test_rlcmac_prim_down_cb(): Rx L1CTL-RACH.request ra=0x7a test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0x80 RTS 0: FN=8 +test_rlcmac_prim_up_cb(): Rx GMMRR-LLC_TRANSMITTED.indication TLLI=0x00002342 test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=8 ts=7 data_len=34 data=[3c 01 01 00 00 23 42 01 c0 00 08 01 01 d5 71 00 00 08 29 26 24 00 00 00 00 71 62 f2 24 6c 84 44 04 00 ] RTS 1: FN=13 test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=13 ts=7 data_len=34 data=[00 01 02 1d 00 00 23 42 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 ] @@ -88,6 +91,7 @@ sys={0.000000}, mono={0.000000}: clock_override_set test_rlcmac_prim_down_cb(): Rx L1CTL-RACH.request ra=0x7a test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0x80 +test_rlcmac_prim_up_cb(): Rx GMMRR-LLC_TRANSMITTED.indication TLLI=0x00002342 test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=4 ts=7 data_len=34 data=[3c 01 01 00 00 23 42 01 c0 00 08 01 01 d5 71 00 00 08 29 26 24 00 00 00 00 71 62 f2 24 6c 84 44 04 00 ] test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=8 ts=7 data_len=34 data=[00 00 02 1d 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 ] sys={5.000000}, mono={5.000000}: clock_override_add @@ -98,6 +102,7 @@ sys={0.000000}, mono={0.000000}: clock_override_set test_rlcmac_prim_down_cb(): Rx L1CTL-RACH.request ra=0x7b test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0x80 +test_rlcmac_prim_up_cb(): Rx GMMRR-LLC_TRANSMITTED.indication TLLI=0x00002342 test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=4 ts=7 data_len=34 data=[3c 01 01 00 00 23 42 01 c0 00 08 01 01 d5 71 00 00 08 29 26 24 00 00 00 00 71 62 f2 24 6c 84 44 04 00 ] test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=8 ts=7 data_len=34 data=[00 00 02 1d 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 ] RTS 0: FN=13 @@ -114,6 +119,7 @@ sys={0.000000}, mono={0.000000}: clock_override_set test_rlcmac_prim_down_cb(): Rx L1CTL-RACH.request ra=0x7b test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0x80 +test_rlcmac_prim_up_cb(): Rx GMMRR-LLC_TRANSMITTED.indication TLLI=0x00002342 test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=4 ts=7 data_len=34 data=[00 01 00 39 00 00 23 42 01 c0 00 08 01 01 d5 71 00 00 08 29 26 24 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 ] test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0x00 test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=17 ts=7 data_len=23 data=[40 16 40 00 08 d0 a0 bc 00 00 00 00 00 00 70 00 38 00 00 2b 2b 2b 2b ] @@ -132,6 +138,7 @@ test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=21 ts=7 data_len=23 data=[40 08 10 20 00 00 00 00 00 00 00 30 40 00 00 00 00 03 2b 2b 2b 2b 2b ] test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0xc0 test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=43 ts=7 data_len=23 data=[40 04 00 00 00 04 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b ] +test_rlcmac_prim_up_cb(): Rx GMMRR-LLC_TRANSMITTED.indication TLLI=0x00000001 test_rlcmac_prim_down_cb(): Rx L1CTL-PDCH_DATA.request fn=47 ts=6 data_len=34 data=[00 06 00 39 01 c0 00 08 01 01 d5 71 00 00 08 29 26 24 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 ] === test_dl_tbf_ccch_assign_requests_ul_tbf_pacch end === test_rlcmac_prim_down_cb(): Rx L1CTL-CFG_UL_TBF.request ul_tbf_nr=0 ul_slotmask=0x00 -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32905 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: I9fd4047cfae4a12ad3be41860032eeda263d3276 Gerrit-Change-Number: 32905 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
[S] Change in libosmo-gprs[master]: gmm: Forward forth and back the P-TMSI signature
by pespin 23 May '23

23 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32802 ) Change subject: gmm: Forward forth and back the P-TMSI signature ...................................................................... gmm: Forward forth and back the P-TMSI signature Change-Id: Ibf12589e7d3029f80b4ced99992155deb9dba036 --- M include/osmocom/gprs/gmm/gmm_prim.h 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.c M tests/gmm/gmm_prim_test.ok 7 files changed, 42 insertions(+), 5 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_prim.h b/include/osmocom/gprs/gmm/gmm_prim.h index e5eada0..3b2ee70 100644 --- a/include/osmocom/gprs/gmm/gmm_prim.h +++ b/include/osmocom/gprs/gmm/gmm_prim.h @@ -105,6 +105,7 @@ struct { enum osmo_gprs_gmm_attach_type attach_type; uint32_t ptmsi; + uint32_t ptmsi_sig; bool attach_with_imsi; char imsi[OSMO_IMSI_BUF_SIZE]; char imei[GSM23003_IMEI_NUM_DIGITS + 1]; @@ -119,6 +120,7 @@ struct { /* PLMNs MT-caps, attach-type. */ uint32_t allocated_ptmsi; + uint32_t allocated_ptmsi_sig; uint32_t allocated_tlli; struct gprs_ra_id rai; } acc; @@ -211,6 +213,7 @@ struct { enum osmo_gprs_gmm_attach_type attach_type; uint32_t ptmsi; + uint32_t ptmsi_sig; bool attach_with_imsi; char imsi[OSMO_IMSI_BUF_SIZE]; char imei[GSM23003_IMEI_NUM_DIGITS + 1]; @@ -225,6 +228,7 @@ struct { /* PLMNs MT-caps, attach-type. */ uint32_t allocated_ptmsi; + uint32_t allocated_ptmsi_sig; uint32_t allocated_tlli; struct gprs_ra_id rai; } acc; diff --git a/include/osmocom/gprs/gmm/gmm_private.h b/include/osmocom/gprs/gmm/gmm_private.h index 57658e9..e715723 100644 --- a/include/osmocom/gprs/gmm/gmm_private.h +++ b/include/osmocom/gprs/gmm/gmm_private.h @@ -56,6 +56,7 @@ struct gprs_gmm_ms_fsm_ctx ms_fsm; uint32_t sess_id; /* Used to identify the GMME in GMMSM SAP */ + uint32_t ptmsi_sig; /* 3 bytes */ uint32_t ptmsi; uint32_t old_ptmsi; uint32_t tlli; diff --git a/src/gmm/gmm.c b/src/gmm/gmm.c index 385da4f..aef3571 100644 --- a/src/gmm/gmm.c +++ b/src/gmm/gmm.c @@ -150,6 +150,7 @@ } gmme->sess_id = GPRS_GMM_SESS_ID_UNASSIGNED; + gmme->ptmsi_sig = GSM_RESERVED_TMSI; gmme->ptmsi = ptmsi; gmme->old_ptmsi = GSM_RESERVED_TMSI; gmme->old_tlli = GPRS_GMM_TLLI_UNASSIGNED; @@ -288,6 +289,7 @@ gmm_prim_tx->gmmreg.attach_cnf.accepted = accepted; if (accepted) { gmm_prim_tx->gmmreg.attach_cnf.acc.allocated_ptmsi = gmme->ptmsi; + gmm_prim_tx->gmmreg.attach_cnf.acc.allocated_ptmsi_sig = gmme->ptmsi_sig; gmm_prim_tx->gmmreg.attach_cnf.acc.allocated_tlli = gmme->tlli; memcpy(&gmm_prim_tx->gmmreg.attach_cnf.acc.rai, &gmme->ra, sizeof(gmme->ra)); } else { @@ -333,6 +335,7 @@ gmm_prim_tx = gprs_gmm_prim_alloc_gmmsm_establish_cnf(gmme->sess_id, cause); if (accepted) { gmm_prim_tx->gmmsm.establish_cnf.acc.allocated_ptmsi = gmme->ptmsi; + gmm_prim_tx->gmmsm.establish_cnf.acc.allocated_ptmsi_sig = gmme->ptmsi_sig; gmm_prim_tx->gmmsm.establish_cnf.acc.allocated_tlli = gmme->tlli; memcpy(&gmm_prim_tx->gmmsm.establish_cnf.acc.rai, &gmme->ra, sizeof(gmme->ra)); } @@ -562,6 +565,13 @@ goto rejected; } + 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; + } + 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 1182482..28fd30f 100644 --- a/src/gmm/gmm_pdu.c +++ b/src/gmm/gmm_pdu.c @@ -230,6 +230,12 @@ /* TODO: optional fields */ + /* 10.5.5.8 Old P-TMSI signature: */ + if (!attach_with_imsi && gmme->ptmsi != 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); + } + /* 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 4951651..b2f1fdc 100644 --- a/src/gmm/gmm_prim.c +++ b/src/gmm/gmm_prim.c @@ -386,6 +386,7 @@ if (gmm_prim->gmmreg.attach_req.imeisv[0] != '\0') OSMO_STRLCPY_ARRAY(gmme->imeisv, gmm_prim->gmmreg.attach_req.imeisv); memcpy(&gmme->ra, &gmm_prim->gmmreg.attach_req.old_rai, sizeof(gmme->ra)); + gmme->ptmsi_sig = gmm_prim->gmmreg.attach_req.ptmsi_sig; rc = gprs_gmm_ms_fsm_ctx_request_attach(&gmme->ms_fsm, gmm_prim->gmmreg.attach_req.attach_type, @@ -488,6 +489,7 @@ OSMO_ASSERT(gmme); /* Identify this GMME with this sess_id in GMMSM SAP from now on: */ gmme->sess_id = gmm_prim->gmmsm.sess_id; + gmme->ptmsi_sig = gmm_prim->gmmsm.establish_req.ptmsi_sig; if (gmme->ms_fsm.fi->state == GPRS_GMM_MS_ST_REGISTERED) { rc = gprs_gmm_submit_gmmsm_establish_cnf(gmme, true, 0); diff --git a/tests/gmm/gmm_prim_test.c b/tests/gmm/gmm_prim_test.c index 1b14b38..b403829 100644 --- a/tests/gmm/gmm_prim_test.c +++ b/tests/gmm/gmm_prim_test.c @@ -157,9 +157,10 @@ switch (OSMO_PRIM_HDR(&gmm_prim->oph)) { case OSMO_PRIM(OSMO_GPRS_GMM_GMMREG_ATTACH, PRIM_OP_CONFIRM): if (gmm_prim->gmmreg.attach_cnf.accepted) { - printf("%s(): Rx %s accepted=%u allocated_ptmsi=0x%08x\n", __func__, pdu_name, + printf("%s(): Rx %s accepted=%u allocated_ptmsi=0x%08x allocated_ptmsi_sig=0x%06x\n", __func__, pdu_name, gmm_prim->gmmreg.attach_cnf.accepted, - gmm_prim->gmmreg.attach_cnf.acc.allocated_ptmsi); + gmm_prim->gmmreg.attach_cnf.acc.allocated_ptmsi, + gmm_prim->gmmreg.attach_cnf.acc.allocated_ptmsi_sig); } else { printf("%s(): Rx %s accepted=%u rej_cause=%u\n", __func__, pdu_name, gmm_prim->gmmreg.attach_cnf.accepted, @@ -283,6 +284,7 @@ struct osmo_gprs_llc_prim *llc_prim; int rc; uint32_t ptmsi = 0x00001234; + uint32_t ptmsi_sig = 0x556677; uint32_t rand_tlli = 0x80001234; char *imsi = "1234567890"; char *imei = "42342342342342"; @@ -303,6 +305,7 @@ OSMO_ASSERT(gmm_prim); gmm_prim->gmmreg.attach_req.attach_type = OSMO_GPRS_GMM_ATTACH_TYPE_GPRS; gmm_prim->gmmreg.attach_req.ptmsi = ptmsi; + gmm_prim->gmmreg.attach_req.ptmsi_sig = ptmsi_sig; OSMO_STRLCPY_ARRAY(gmm_prim->gmmreg.attach_req.imsi, imsi); OSMO_STRLCPY_ARRAY(gmm_prim->gmmreg.attach_req.imei, imei); OSMO_STRLCPY_ARRAY(gmm_prim->gmmreg.attach_req.imeisv, imeisv); @@ -366,6 +369,7 @@ struct osmo_gprs_llc_prim *llc_prim; int rc; uint32_t ptmsi = 0x00001234; + uint32_t ptmsi_sig = 0x556677; uint32_t rand_tlli = 0x80001234; char *imsi = "1234567890"; char *imei = "42342342342342"; @@ -388,6 +392,7 @@ OSMO_ASSERT(gmm_prim); gmm_prim->gmmsm.establish_req.attach_type = OSMO_GPRS_GMM_ATTACH_TYPE_GPRS; gmm_prim->gmmsm.establish_req.ptmsi = ptmsi; + gmm_prim->gmmsm.establish_req.ptmsi_sig = ptmsi_sig; OSMO_STRLCPY_ARRAY(gmm_prim->gmmsm.establish_req.imsi, imsi); OSMO_STRLCPY_ARRAY(gmm_prim->gmmsm.establish_req.imei, imei); OSMO_STRLCPY_ARRAY(gmm_prim->gmmsm.establish_req.imeisv, imeisv); diff --git a/tests/gmm/gmm_prim_test.ok b/tests/gmm/gmm_prim_test.ok index 80d9a2d..cfebbfa 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 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 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 @@ -7,13 +7,13 @@ test_gmm_prim_llc_down_cb(): Rx LLGMM-ASSIGN.request old_TLLI=0x80001234 new_TLLI=0xea711b41 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 +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 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 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 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/+/32802 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: Ibf12589e7d3029f80b4ced99992155deb9dba036 Gerrit-Change-Number: 32802 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> 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]: gmm: Introduce APIs & unit test to enc/dec GPRS Timer IE
by pespin 23 May '23

23 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32906 ) Change subject: gmm: Introduce APIs & unit test to enc/dec GPRS Timer IE ...................................................................... gmm: Introduce APIs & unit test to enc/dec GPRS Timer IE enc/dec implementation and unit test are imported from osmo-sgsn.git b83aabaa95695c61a64e5e990944f8e55934a976. Change-Id: Ia3b903e8bc7890489390dcc5b2d4b60efd55dc2c --- M include/osmocom/gprs/gmm/gmm_private.h M src/gmm/misc.c M tests/gmm/Makefile.am A tests/gmm/gmm_misc_test.c A tests/gmm/gmm_misc_test.err A tests/gmm/gmm_misc_test.ok M tests/testsuite.at 7 files changed, 226 insertions(+), 0 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 e715723..339753b 100644 --- a/include/osmocom/gprs/gmm/gmm_private.h +++ b/include/osmocom/gprs/gmm/gmm_private.h @@ -122,6 +122,10 @@ int gprs_gmm_submit_gmmsm_establish_cnf(struct gprs_gmm_entity *gmme, bool accepted, uint8_t cause); int gprs_gmm_submit_llgmm_assing_req(const struct gprs_gmm_entity *gmme); +/* misc.c */ +int gprs_gmm_gprs_tmr_to_secs(uint8_t gprs_tmr); +uint8_t gprs_gmm_secs_to_gprs_tmr_floor(int secs); + #define LOGGMME(gmme, level, fmt, args...) \ LOGGMM(level, "GMME(IMSI-%s:PTMSI-%08x:TLLI-%08x) " fmt, \ gmme->imsi, \ diff --git a/src/gmm/misc.c b/src/gmm/misc.c index dec0c78..c54bf3c 100644 --- a/src/gmm/misc.c +++ b/src/gmm/misc.c @@ -20,6 +20,8 @@ #include <osmocom/core/logging.h> #include <osmocom/core/utils.h> +#include <osmocom/gsm/protocol/gsm_04_08_gprs.h> + #include <osmocom/gprs/gmm/gmm.h> #include <osmocom/gprs/gmm/gmm_ms_fsm.h> @@ -32,3 +34,48 @@ gprs_gmm_ms_fsm_set_log_cat(logc_num); } + + +/* 3GPP TS 24.008, 10.5.7.3 GPRS Timer */ +int gprs_gmm_gprs_tmr_to_secs(uint8_t gprs_tmr) +{ + switch (gprs_tmr & GPRS_TMR_UNIT_MASK) { + case GPRS_TMR_2SECONDS: + return 2 * (gprs_tmr & GPRS_TMR_FACT_MASK); + default: + case GPRS_TMR_MINUTE: + return 60 * (gprs_tmr & GPRS_TMR_FACT_MASK); + case GPRS_TMR_6MINUTE: + return 360 * (gprs_tmr & GPRS_TMR_FACT_MASK); + case GPRS_TMR_DEACTIVATED: + return -1; + } +} + +/* This functions returns a tmr value such that + * - f is monotonic + * - f(s) <= s + * - f(s) == s if a tmr exists with s = gprs_tmr_to_secs(tmr) + * - the best possible resolution is used + * where + * f(s) = gprs_tmr_to_secs(gprs_secs_to_tmr_floor(s)) + */ +uint8_t gprs_gmm_secs_to_gprs_tmr_floor(int secs) +{ + if (secs < 0) + return GPRS_TMR_DEACTIVATED; + if (secs < 2 * 32) + return GPRS_TMR_2SECONDS | (secs / 2); + if (secs < 60 * 2) + /* Ensure monotonicity */ + return GPRS_TMR_2SECONDS | GPRS_TMR_FACT_MASK; + if (secs < 60 * 32) + return GPRS_TMR_MINUTE | (secs / 60); + if (secs < 360 * 6) + /* Ensure monotonicity */ + return GPRS_TMR_MINUTE | GPRS_TMR_FACT_MASK; + if (secs < 360 * 32) + return GPRS_TMR_6MINUTE | (secs / 360); + + return GPRS_TMR_6MINUTE | GPRS_TMR_FACT_MASK; +} diff --git a/tests/gmm/Makefile.am b/tests/gmm/Makefile.am index c4adb2d..d066c5e 100644 --- a/tests/gmm/Makefile.am +++ b/tests/gmm/Makefile.am @@ -13,14 +13,30 @@ $(NULL) check_PROGRAMS = \ + gmm_misc_test \ gmm_prim_test \ $(NULL) EXTRA_DIST = \ + gmm_misc_test.err \ + gmm_misc_test.ok \ gmm_prim_test.err \ gmm_prim_test.ok \ $(NULL) +# libosmo-gprs-gmm.a is used below to access non-exported private symbols used in the test: +gmm_misc_test_SOURCES = gmm_misc_test.c +gmm_misc_test_LDADD = \ + $(top_builddir)/src/gmm/.libs/libosmo-gprs-gmm.a \ + $(top_builddir)/src/llc/.libs/libosmo-gprs-llc.a \ + $(LIBOSMOGSM_LIBS) \ + $(LIBOSMOCORE_LIBS) \ + $(NULL) + +gmm_misc_test_LDFLAGS = \ + -no-install \ + $(NULL) + # libosmo-gprs-llc.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 = \ diff --git a/tests/gmm/gmm_misc_test.c b/tests/gmm/gmm_misc_test.c new file mode 100644 index 0000000..b760017 --- /dev/null +++ b/tests/gmm/gmm_misc_test.c @@ -0,0 +1,130 @@ +/* gmm_prim tests + * + * (C) 2023 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * Author: Pau espin Pedrol <pespin(a)sysmocom.de> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <stdint.h> +#include <stdio.h> + +#include <osmocom/core/application.h> +#include <osmocom/core/logging.h> +#include <osmocom/core/utils.h> +#include <osmocom/core/fsm.h> +#include <osmocom/core/msgb.h> +#include <osmocom/gsm/protocol/gsm_04_08_gprs.h> + +#include <osmocom/gprs/gmm/gmm_private.h> + +static void *tall_ctx = NULL; + +/* Test: TS 24.008 10.5.7.3 GPRS Timer */ +static void test_gprs_timer_enc_dec(void) +{ + int i, u, secs, tmr; + const int upper_secs_test_limit = 12000; + int dec_secs, last_dec_secs = -1; + + printf("==== %s() [start] ====\n", __func__); + + /* Check gprs_gmm_gprs_tmr_to_secs() with all 256 encoded values */ + for (u = 0; u <= GPRS_TMR_DEACTIVATED; u += 32) { + fprintf(stderr, "Testing decoding with timer value unit %u\n", + u / 32); + for (i = 0; i < 32; i++) { + switch (u) { + case GPRS_TMR_2SECONDS: + OSMO_ASSERT(gprs_gmm_gprs_tmr_to_secs(u + i) == 2 * i); + break; + + default: + case GPRS_TMR_MINUTE: + OSMO_ASSERT(gprs_gmm_gprs_tmr_to_secs(u + i) == 60 * i); + break; + + case GPRS_TMR_6MINUTE: + OSMO_ASSERT(gprs_gmm_gprs_tmr_to_secs(u + i) == 360 * i); + break; + + case GPRS_TMR_DEACTIVATED: + OSMO_ASSERT(gprs_gmm_gprs_tmr_to_secs(u + i) == -1); + break; + } + + OSMO_ASSERT(gprs_gmm_gprs_tmr_to_secs(u + i) < upper_secs_test_limit); + } + } + + /* Check gprs_secs_to_tmr_floor for secs that can exactly be + * represented as GPRS timer values */ + for (i = 0; i < GPRS_TMR_DEACTIVATED; i++) { + int j; + secs = gprs_gmm_gprs_tmr_to_secs(i); + tmr = gprs_gmm_secs_to_gprs_tmr_floor(secs); + OSMO_ASSERT(secs == gprs_gmm_gprs_tmr_to_secs(tmr)); + + /* Check that the highest resolution is used */ + for (j = 0; j < tmr; j++) + OSMO_ASSERT(secs != gprs_gmm_gprs_tmr_to_secs(j)); + } + OSMO_ASSERT(GPRS_TMR_DEACTIVATED == gprs_gmm_secs_to_gprs_tmr_floor(-1)); + + /* Check properties of gprs_secs_to_tmr_floor */ + for (secs = 0; secs <= upper_secs_test_limit; secs++) { + int tmr = gprs_gmm_secs_to_gprs_tmr_floor(secs); + int delta_secs = gprs_gmm_gprs_tmr_to_secs((tmr & ~0x1f) | 1); + dec_secs = gprs_gmm_gprs_tmr_to_secs(tmr); + + /* Check floor */ + OSMO_ASSERT(dec_secs <= secs); + /* Check monotonicity */ + OSMO_ASSERT(dec_secs >= last_dec_secs); + /* Check max distance (<= resolution) */ + OSMO_ASSERT(dec_secs - last_dec_secs <= delta_secs); + + last_dec_secs = dec_secs; + } + + printf("==== %s() [end] ====\n", __func__); +} + +static const struct log_info_cat test_log_categories[] = { }; +static const struct log_info test_log_info = { + .cat = test_log_categories, + .num_cat = ARRAY_SIZE(test_log_categories), +}; + +int main(int argc, char *argv[]) +{ + tall_ctx = talloc_named_const(NULL, 1, __FILE__); + + osmo_init_logging2(tall_ctx, &test_log_info); + log_parse_category_mask(osmo_stderr_target, "DLGLOBAL,1:"); + osmo_fsm_log_addr(false); + + log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE); + log_set_print_category_hex(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + log_set_print_level(osmo_stderr_target, 1); + log_set_use_color(osmo_stderr_target, 0); + + test_gprs_timer_enc_dec(); + + talloc_free(tall_ctx); +} diff --git a/tests/gmm/gmm_misc_test.err b/tests/gmm/gmm_misc_test.err new file mode 100644 index 0000000..d6cc62c --- /dev/null +++ b/tests/gmm/gmm_misc_test.err @@ -0,0 +1,8 @@ +Testing decoding with timer value unit 0 +Testing decoding with timer value unit 1 +Testing decoding with timer value unit 2 +Testing decoding with timer value unit 3 +Testing decoding with timer value unit 4 +Testing decoding with timer value unit 5 +Testing decoding with timer value unit 6 +Testing decoding with timer value unit 7 diff --git a/tests/gmm/gmm_misc_test.ok b/tests/gmm/gmm_misc_test.ok new file mode 100644 index 0000000..927fd3c --- /dev/null +++ b/tests/gmm/gmm_misc_test.ok @@ -0,0 +1,2 @@ +==== test_gprs_timer_enc_dec() [start] ==== +==== test_gprs_timer_enc_dec() [end] ==== diff --git a/tests/testsuite.at b/tests/testsuite.at index 55a54d7..74fd43a 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -1,6 +1,13 @@ AT_INIT AT_BANNER([Regression tests]) +AT_SETUP([gmm/gmm_misc]) +AT_KEYWORDS([gmm gmm_misc]) +cat $abs_srcdir/gmm/gmm_misc_test.ok > expout +cat $abs_srcdir/gmm/gmm_misc_test.err > experr +AT_CHECK([$abs_top_builddir/tests/gmm/gmm_misc_test], [0], [expout], [experr]) +AT_CLEANUP + AT_SETUP([gmm/gmm_prim]) AT_KEYWORDS([gmm gmm_prim]) cat $abs_srcdir/gmm/gmm_prim_test.ok > expout -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32906 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: Ia3b903e8bc7890489390dcc5b2d4b60efd55dc2c Gerrit-Change-Number: 32906 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
  • ← Newer
  • 1
  • ...
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • ...
  • 259
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.