dexter has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/30922 )

Change subject: abis_rsl: fix frame number calculation
......................................................................

abis_rsl: fix frame number calculation

The formula that is used to recover the (relative) frame number from the
T1, T2, T3 parameters matches the definition in the spec, but since the
partial term t3-t2 can be negative special precaution is required when
performing the MOD 26 operation.  This is due to the truncated modulo
implementation in C/C++, which has a very specific understanding on how
to deal with negative input parameters.

The libosmocore gsm_gsmtime2fn(() offers a correct implementation, so
lets use it.

Change-Id: I5fb2b0ada8d409730ac22963741fb4ab0026abdd
Related: OS#5198
---
M src/osmo-bsc/abis_rsl.c
1 file changed, 7 insertions(+), 7 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved



diff --git a/src/osmo-bsc/abis_rsl.c b/src/osmo-bsc/abis_rsl.c
index 640ff4d..df8163c 100644
--- a/src/osmo-bsc/abis_rsl.c
+++ b/src/osmo-bsc/abis_rsl.c
@@ -1800,10 +1800,10 @@
 /* Handle packet channel rach requests */
 static int rsl_rx_pchan_rqd(struct chan_rqd *rqd)
 {
-       uint8_t t1, t2, t3;
        uint32_t fn;
        uint8_t rqd_ta;
        uint8_t is_11bit;
+       struct gsm_time gsm_time;

        /* Process rach request and forward contained information to PCU */
        if (rqd->ref.ra == 0x7F) {
@@ -1816,13 +1816,13 @@
                is_11bit = 0;
                rqd_ta = rqd->ta;

-               /* See also 3GPP TS 04.08, section 10.5.2.38 and 3GPP TS 08.58, 
section 9.3.8 */
-               t1 = rqd->ref.t1;
-               t2 = rqd->ref.t2;
-               t3 = rqd->ref.t3_low | (rqd->ref.t3_high << 3);
-               fn = (51 * ((t3-t2) % 26) + t3 + 51 * 26 * t1);
+               gsm_time.t1 = rqd->ref.t1;
+               gsm_time.t2 = rqd->ref.t2;
+               gsm_time.t3 = rqd->ref.t3_low | (rqd->ref.t3_high << 3);
+               fn = gsm_gsmtime2fn(&gsm_time);

-               LOG_BTS(rqd->bts, DRSL, LOGL_INFO, "CHAN RQD: 
fn(t1=%u,t3=%u,t2=%u) = %u\n", t1, t3, t2, fn);
+               LOG_BTS(rqd->bts, DRSL, LOGL_INFO, "CHAN RQD: 
fn(t1=%u,t3=%u,t2=%u) = %u\n",
+                       gsm_time.t1, gsm_time.t3, gsm_time.t2, fn);
        }

        return pcu_tx_rach_ind(rqd->bts, rqd_ta, rqd->ref.ra, fn, is_11bit,

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/30922
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I5fb2b0ada8d409730ac22963741fb4ab0026abdd
Gerrit-Change-Number: 30922
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to