From ac89a555fa73b24a77bb861811774a5af885bc84 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 29 Jun 2015 14:18:46 +0200 Subject: ms: Add tbf() method to get the TBF based on the direction To avoid the need for a switch or conditional statement when needing a TBF from an MS object in direction independant code, this method contains that case distinction. For additional flexibility, a reverse() function is added to get the opposite direction. Sponsored-by: On-Waves ehf --- src/gprs_ms.cpp | 9 +++++++++ src/gprs_ms.h | 2 ++ src/tbf.h | 5 +++++ 3 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/gprs_ms.cpp b/src/gprs_ms.cpp index 1014ea38..4c0ecfde 100644 --- a/src/gprs_ms.cpp +++ b/src/gprs_ms.cpp @@ -529,3 +529,12 @@ int GprsMs::first_common_ts() const return -1; } +gprs_rlcmac_tbf *GprsMs::tbf(enum gprs_rlcmac_tbf_direction dir) const +{ + switch (dir) { + case GPRS_RLCMAC_DL_TBF: return m_dl_tbf; + case GPRS_RLCMAC_UL_TBF: return m_ul_tbf; + } + + return NULL; +} diff --git a/src/gprs_ms.h b/src/gprs_ms.h index 17ee41bd..2c6061c6 100644 --- a/src/gprs_ms.h +++ b/src/gprs_ms.h @@ -26,6 +26,7 @@ struct gprs_rlcmac_ul_tbf; #include "cxx_linuxlist.h" #include "llc.h" +#include "tbf.h" #include "pcu_l1_if.h" extern "C" { @@ -60,6 +61,7 @@ public: gprs_rlcmac_ul_tbf *ul_tbf() const {return m_ul_tbf;} gprs_rlcmac_dl_tbf *dl_tbf() const {return m_dl_tbf;} + gprs_rlcmac_tbf *tbf(enum gprs_rlcmac_tbf_direction dir) const; uint32_t tlli() const; void set_tlli(uint32_t tlli); bool confirm_tlli(uint32_t tlli); diff --git a/src/tbf.h b/src/tbf.h index cf8cdfc6..840125a5 100644 --- a/src/tbf.h +++ b/src/tbf.h @@ -395,6 +395,11 @@ protected: void maybe_schedule_uplink_acknack(const rlc_ul_header *rh); }; +inline enum gprs_rlcmac_tbf_direction reverse(enum gprs_rlcmac_tbf_direction dir) +{ + return (enum gprs_rlcmac_tbf_direction) + ((int)GPRS_RLCMAC_UL_TBF - (int)dir + (int)GPRS_RLCMAC_DL_TBF); +} #endif #ifdef __cplusplus -- cgit v1.2.3