[osmo-pcu,1/2] gprs_rlcmac_pdch: Don't access private member structs
diff mbox

Message ID c96190177bfbb6094d4d0b27f7a3fe53f4070c9f.1401886570.git.daniel@totalueberwachung.de
State Accepted
Headers show

Commit Message

Daniel Willmann June 4, 2014, 12:56 p.m. UTC
This patch introduces methods to get ul and dl tbf by tfi and uses them
in gprs_rlcmac_sched.
---
 src/bts.cpp               | 14 ++++++++++++++
 src/bts.h                 |  3 +++
 src/gprs_rlcmac_sched.cpp |  4 ++--
 3 files changed, 19 insertions(+), 2 deletions(-)

Patch
diff mbox

diff --git a/src/bts.cpp b/src/bts.cpp
index 9003099..b383546 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -990,3 +990,17 @@  int gprs_rlcmac_pdch::rcv_block(uint8_t *data, uint8_t len, uint32_t fn, int8_t
 
 	return rc;
 }
+
+struct gprs_rlcmac_tbf *gprs_rlcmac_pdch::ul_tbf_by_tfi(uint8_t tfi)
+{
+	if (tfi >= ARRAY_SIZE(this->ul_tbf))
+		return NULL;
+	return this->ul_tbf[tfi];
+}
+
+struct gprs_rlcmac_tbf *gprs_rlcmac_pdch::dl_tbf_by_tfi(uint8_t tfi)
+{
+	if (tfi >= ARRAY_SIZE(this->dl_tbf))
+		return NULL;
+	return this->dl_tbf[tfi];
+}
diff --git a/src/bts.h b/src/bts.h
index 128b1e0..578c63d 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -61,6 +61,9 @@  struct gprs_rlcmac_pdch {
 	gprs_rlcmac_bts *bts_data() const;
 	BTS *bts() const;
 	uint8_t trx_no() const;
+
+	struct gprs_rlcmac_tbf *ul_tbf_by_tfi(uint8_t tfi);
+	struct gprs_rlcmac_tbf *dl_tbf_by_tfi(uint8_t tfi);
 #endif
 
 	uint8_t m_is_enabled; /* TS is enabled */
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index 123e375..92e97ec 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -81,7 +81,7 @@  static uint8_t sched_select_uplink(uint8_t trx, uint8_t ts, uint32_t fn,
 	/* select uplink resource */
 	for (i = 0, tfi = pdch->next_ul_tfi; i < 32;
 	     i++, tfi = (tfi + 1) & 31) {
-		tbf = pdch->ul_tbf[tfi];
+		tbf = pdch->ul_tbf_by_tfi(tfi);
 		/* no TBF for this tfi, go next */
 		if (!tbf)
 			continue;
@@ -169,7 +169,7 @@  static struct msgb *sched_select_downlink(struct gprs_rlcmac_bts *bts,
 	/* select downlink resource */
 	for (i = 0, tfi = pdch->next_dl_tfi; i < 32;
 	     i++, tfi = (tfi + 1) & 31) {
-		tbf = pdch->dl_tbf[tfi];
+		tbf = pdch->dl_tbf_by_tfi(tfi);
 		/* no TBF for this tfi, go next */
 		if (!tbf)
 			continue;