From 173555dab71d2bcd1e1984a2608e1dd7f0e77dc5 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 30 Sep 2018 14:50:39 +0200 Subject: Fix computing CCCH block number from frame number The existing implementation used a simplistic macro, which was wrong in many ways: 1) it returned a negative value for "fn % 51 < 5" conditions without raising any error message or asserting 2) it returned a wrong block number for many different input frame numbers, as it didn't account properly for the FCCH/SCH gaps between the blocks Let's replace the simplistic macro with a proper lookup table based on TS 05.02, and let's OSMO_ASSERT() if this is ever called with non-CCCH frame numbers. Change-Id: I11fd6cc558bb61c40c2019e46f56c1fe78ef39f5 Closes: OS#3024 --- include/osmo-bts/l1sap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h index 3225a60f..e2c92fa2 100644 --- a/include/osmo-bts/l1sap.h +++ b/include/osmo-bts/l1sap.h @@ -29,7 +29,7 @@ #define L1SAP_IS_PACKET_RACH(ra) ((ra & 0xf0) == 0x70 && (ra & 0x0f) != 0x0f) /* CCCH block from frame number */ -#define L1SAP_FN2CCCHBLOCK(fn) ((fn % 51) / 5 - 1) +unsigned int l1sap_fn2ccch_block(uint32_t fn); /* PTCH layout from frame number */ #define L1SAP_FN2MACBLOCK(fn) ((fn % 52) / 4) -- cgit v1.2.3