fixeria has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/17709 )

Change subject: bts: fix send_gsmtap_rach(): properly pack 11 bit RA
......................................................................

bts: fix send_gsmtap_rach(): properly pack 11 bit RA

According to 3GPP TS 44.004, section 7.4a, two alternative RACH
block formats are specified: 8 bit (1 octet) and 11 bit. The
bit order is LSB (right to left), byte order is MSB.

In PCUIF RACH.ind structure (see gsm_pcu_if_rach_ind) we use
a field of type uint16_t to store RA values regardles of the
block format. Thus when packing it to bytes, we cannot just
cast uint16_t* to uint8_t*, we need to do some bit shifting.

Change-Id: I08a0a908f855b0d8a002df732e02781126d27dfb
---
M src/bts.cpp
1 file changed, 14 insertions(+), 2 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/bts.cpp b/src/bts.cpp
index 0482168..617cd78 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -434,9 +434,21 @@
                           const struct rach_ind_params *rip)
 {
        struct pcu_l1_meas meas;
+       uint8_t ra_buf[2];
+
+       /* 3GPP TS 44.004 defines 11 bit RA as follows: xxxx xxxx  .... .yyy
+        * On the PCUIF, we get 16 bit machne dependent number (LE/BE)
+        * Over GSMTAP we send the following:           xxxx xxxx  yyy. ....
+        * This simplifies parsing in Wireshark using its CSN.1 codec. */
+       if (rip->is_11bit) {
+               ra_buf[0] = (uint8_t) ((rip->ra >> 3) & 0xff);
+               ra_buf[1] = (uint8_t) ((rip->ra << 5) & 0xff);
+       } else {
+               ra_buf[0] = (uint8_t) (rip->ra & 0xff);
+       }
+
        send_gsmtap_meas(categ, true, rip->trx_nr, rip->ts_nr, channel,
-                        rfn_to_fn(rip->rfn), (uint8_t *) &rip->ra,
-                        /* TODO: properly pack 11 bit RA */
+                        rfn_to_fn(rip->rfn), ra_buf,
                         rip->is_11bit ? 2 : 1, &meas);
 }


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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I08a0a908f855b0d8a002df732e02781126d27dfb
Gerrit-Change-Number: 17709
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to