aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-03-03 14:45:55 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-03-06 19:25:53 +0100
commitadcdf150a63b3fe13dd933fca9f51974f40aeede (patch)
treef272f903d7b8fae6a0b0df3c9327d58cf456bac7
parenta41a71e2d4fd02a941dff5cc504c064f60c7e234 (diff)
tbf: Add name() method and put the buf into the tbf
Currently tbf_name() must not be used twice in a printf statement with different TBFs, since the same baffer will be used for each. This commit puts the text buffer into struct gprs_rlcmac_tbf to avoid this problem. Sponsored-by: On-Waves ehf
-rw-r--r--src/tbf.cpp21
-rw-r--r--src/tbf.h5
-rw-r--r--tests/tbf/TbfTest.err8
3 files changed, 22 insertions, 12 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 05b61404..6f4f15c7 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -827,14 +827,19 @@ int gprs_rlcmac_tbf::extract_tlli(const uint8_t *data, const size_t len)
const char *tbf_name(gprs_rlcmac_tbf *tbf)
{
- static char buf[60];
- snprintf(buf, sizeof(buf), "TBF(TFI=%d TLLI=0x%08x DIR=%s STATE=%s)",
- tbf->m_tfi, tbf->m_tlli,
- tbf->direction == GPRS_RLCMAC_UL_TBF ? "UL" : "DL",
- tbf->state_name()
- );
- buf[sizeof(buf) - 1] = '\0';
- return buf;
+ return tbf->name();
+}
+
+const char *gprs_rlcmac_tbf::name() const
+{
+ snprintf(m_name_buf, sizeof(m_name_buf) - 1,
+ "TBF(TFI=%d TLLI=0x%08x DIR=%s STATE=%s)",
+ m_tfi, m_tlli,
+ direction == GPRS_RLCMAC_UL_TBF ? "UL" : "DL",
+ state_name()
+ );
+ m_name_buf[sizeof(m_name_buf) - 1] = '\0';
+ return m_name_buf;
}
void gprs_rlcmac_tbf::rotate_in_list()
diff --git a/src/tbf.h b/src/tbf.h
index 1bea31d9..29959b95 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -117,6 +117,8 @@ struct gprs_rlcmac_tbf {
void set_state(enum gprs_rlcmac_tbf_state new_state);
const char *state_name() const;
+ const char *name() const;
+
struct msgb *create_dl_ass(uint32_t fn);
struct msgb *create_ul_ass(uint32_t fn);
@@ -226,6 +228,9 @@ protected:
int extract_tlli(const uint8_t *data, const size_t len);
static const char *tbf_state_name[6];
+
+private:
+ mutable char m_name_buf[60];
};
diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err
index ca522ecb..39d6807e 100644
--- a/tests/tbf/TbfTest.err
+++ b/tests/tbf/TbfTest.err
@@ -72,12 +72,12 @@ Slot Allocation (Algorithm A) for class 45
- Assign downlink TS=4
TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) Trigger dowlink assignment on PACCH, because another LLC PDU has arrived in between
Send dowlink assignment on PACCH, because TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) exists
-TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) m_new_tbf is already assigned to TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE), overwriting the old value with TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE)
+TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) m_new_tbf is already assigned to TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE), overwriting the old value with TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL)
TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) changes state from NULL to ASSIGN
TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=ASSIGN) starting timer 0.
DL packet loss of IMSI= / TLLI=0x00000000: 0%
TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) free
-TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) New TBF TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) still exists, detaching
+TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) New TBF TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=ASSIGN) still exists, detaching
********** TBF ends here **********
TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=ASSIGN) free
TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=ASSIGN) stopping timer 0.
@@ -139,12 +139,12 @@ Slot Allocation (Algorithm A) for class 45
- Assign downlink TS=4
TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) Trigger dowlink assignment on PACCH, because another LLC PDU has arrived in between
Send dowlink assignment on PACCH, because TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) exists
-TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) m_new_tbf is already assigned to TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE), overwriting the old value with TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE)
+TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) m_new_tbf is already assigned to TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE), overwriting the old value with TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL)
TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) changes state from NULL to ASSIGN
TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=ASSIGN) starting timer 0.
TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=ASSIGN) free
TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=ASSIGN) stopping timer 0.
-TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=ASSIGN) Old TBF TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=ASSIGN) still exists, detaching
+TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=ASSIGN) Old TBF TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) still exists, detaching
********** TBF ends here **********
DL packet loss of IMSI= / TLLI=0x00000000: 0%
TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=WAIT RELEASE) free