[PATCH 1/2] Fix bug in uplink header type 1 parsing

Bhargava Abhyankar Bhargava.Abhyankar at radisys.com
Thu Apr 7 11:57:54 UTC 2016


Fix bug in extraction of E and TI header fields in parsing of uplink
header type 1 RLC data block. Test suite for the same is also updated.
---
 src/decoding.cpp        | 15 ++++++++-------
 tests/edge/EdgeTest.cpp | 16 +++++++---------
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/decoding.cpp b/src/decoding.cpp
index 6844856..b8e453e 100644
--- a/src/decoding.cpp
+++ b/src/decoding.cpp
@@ -513,9 +513,9 @@ int Decoding::rlc_parse_ul_data_header_egprs_type_1(
 	offs = rlc->data_offs_bits[0] / 8;
 	OSMO_ASSERT(rlc->data_offs_bits[0] % 8 == 0);
 
-	e_ti_header = (data[offs-1] + (data[offs] << 8)) >> 7;
-	rlc->block_info[0].e   = !!(e_ti_header & 0x01);
-	rlc->block_info[0].ti  = !!(e_ti_header & 0x02);
+	e_ti_header = (data[offs - 1] & (0xc0)) >> 6;
+	rlc->block_info[0].e   = (e_ti_header & 0x01);
+	rlc->block_info[0].ti  = (e_ti_header & 0x02);
 	cur_bit += 2;
 
 	rlc->block_info[1].cv  = egprs1->cv;
@@ -524,20 +524,21 @@ int Decoding::rlc_parse_ul_data_header_egprs_type_1(
 		((egprs1->bsn2_a << 0) | (egprs1->bsn2_b << 2));
 	rlc->block_info[1].bsn = rlc->block_info[1].bsn &  (RLC_EGPRS_SNS - 1);
 
-	cur_bit += rlc->data_offs_bits[1] - 2;
+	cur_bit = rlc->data_offs_bits[1] - 2;
 
 	offs = rlc->data_offs_bits[1] / 8;
 	OSMO_ASSERT(rlc->data_offs_bits[1] % 8 == 2);
 
-	e_ti_header = (data[offs-1] + (data[offs] << 8)) >> 7;
-	rlc->block_info[1].e   = !!(e_ti_header & 0x01);
-	rlc->block_info[1].ti  = !!(e_ti_header & 0x02);
+	e_ti_header = (data[offs] & (0x03));
+	rlc->block_info[1].e   = (e_ti_header & 0x01);
+	rlc->block_info[1].ti  = (e_ti_header & 0x02);
 	cur_bit += 2;
 	/* skip data area */
 	cur_bit += cs.maxDataBlockBytes() * 8;
 
 	return cur_bit;
 }
+
 /**
  * \brief Copy LSB bitstream RLC data block to byte aligned buffer.
  *
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index ff080f9..9b4a1a5 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -1376,18 +1376,16 @@ static gprs_rlcmac_ul_tbf *uplink_header_parsing_test(BTS *the_bts,
 	egprs1->r = 1;
 	egprs1->cv = 7;
 	egprs1->tfi_a = tfi & (~((~0) << 2));
-	egprs1->tfi_b = tfi & (~((~0) << 3)) << 2;
-	egprs1->bsn1_a = 10;
-	egprs1->bsn1_b = 17;
-	egprs1->bsn2_a = 0;
-	egprs1->bsn2_b = 25;
+	egprs1->tfi_b = (tfi & (~((~0) << 3)) << 2) >> 2;
+	egprs1->bsn1_a = 0;
+	egprs1->bsn1_b = 0;
+	egprs1->bsn2_a = 1;
+	egprs1->bsn2_b = 0;
 	egprs1->cps = 15;
 	egprs1->rsb = 0;
 	egprs1->pi = 0;
-	data[6] = 1;
-	data[6 + 68] = 1;
-	data[75] = 1;
-	data[75 + 68] = 1;
+	data[5] = 0x40;
+	data[5 + 69] = 1;
 	pdch = &the_bts->bts_data()->trx[trx_no].pdch[ts_no];
 	pdch->rcv_block(&data[0], 143, *fn, &meas);
 }
-- 
2.5.0




More information about the osmocom-net-gprs mailing list