aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-25 23:05:26 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-26 21:00:51 +0100
commit4c06d9155c6e114a7b976aad5bba1749d7f42df4 (patch)
tree68d5a4ea6a43736a58d007aaeb42970439a0d780
parentc15d5cc2303aef3d4417453b680d42a69ff28fb0 (diff)
tbf: Move the extraction of the TLLI into a separate method
-rw-r--r--src/tbf.cpp85
-rw-r--r--src/tbf.h2
2 files changed, 49 insertions, 38 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 5f5ea33..0b9a194 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -1505,6 +1505,52 @@ void gprs_rlcmac_tbf::update_tlli(uint32_t tlli)
m_tlli = tlli;
}
+int gprs_rlcmac_tbf::extract_tlli(const uint8_t *data, const size_t len)
+{
+ struct gprs_rlcmac_tbf *dl_tbf, *ul_tbf;
+ struct rlc_ul_header *rh = (struct rlc_ul_header *)data;
+ uint32_t new_tlli;
+ int rc;
+
+ /* no TLLI yet */
+ if (!rh->ti) {
+ LOGP(DRLCMACUL, LOGL_NOTICE, "UL DATA TFI=%d without "
+ "TLLI, but no TLLI received yet\n", rh->tfi);
+ return 0;
+ }
+ rc = Decoding::tlli_from_ul_data(data, len, &new_tlli);
+ if (rc) {
+ bts->decode_error();
+ LOGP(DRLCMACUL, LOGL_NOTICE, "Failed to decode TLLI "
+ "of UL DATA TFI=%d.\n", rh->tfi);
+ return 0;
+ }
+ update_tlli(new_tlli);
+ LOGP(DRLCMACUL, LOGL_INFO, "Decoded premier TLLI=0x%08x of "
+ "UL DATA TFI=%d.\n", tlli(), rh->tfi);
+ if ((dl_tbf = bts->tbf_by_tlli(tlli(), GPRS_RLCMAC_DL_TBF))) {
+ LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from "
+ "TLLI=0x%08x while %s still exists. "
+ "Killing pending DL TBF\n", tlli(),
+ tbf_name(dl_tbf));
+ tbf_free(dl_tbf);
+ }
+ /* tbf_by_tlli will not find your TLLI, because it is not
+ * yet marked valid */
+ if ((ul_tbf = bts->tbf_by_tlli(tlli(), GPRS_RLCMAC_UL_TBF))) {
+ LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from "
+ "TLLI=0x%08x while %s still exists. "
+ "Killing pending UL TBF\n", tlli(),
+ tbf_name(ul_tbf));
+ tbf_free(ul_tbf);
+ }
+ /* mark TLLI valid now */
+ tlli_mark_valid();
+ /* store current timing advance */
+ bts->timing_advance()->remember(tlli(), ta);
+ return 1;
+}
+
int gprs_rlcmac_tbf::rcv_data_block_acknowledged(const uint8_t *data, size_t len, int8_t rssi)
{
uint16_t offset_v_r, index;
@@ -1526,45 +1572,8 @@ int gprs_rlcmac_tbf::rcv_data_block_acknowledged(const uint8_t *data, size_t len
/* get TLLI */
if (!this->is_tlli_valid()) {
- struct gprs_rlcmac_tbf *dl_tbf, *ul_tbf;
- uint32_t tlli;
-
- /* no TLLI yet */
- if (!rh->ti) {
- LOGP(DRLCMACUL, LOGL_NOTICE, "UL DATA TFI=%d without "
- "TLLI, but no TLLI received yet\n", rh->tfi);
+ if (!extract_tlli(data, len))
return 0;
- }
- rc = Decoding::tlli_from_ul_data(data, len, &tlli);
- if (rc) {
- bts->decode_error();
- LOGP(DRLCMACUL, LOGL_NOTICE, "Failed to decode TLLI "
- "of UL DATA TFI=%d.\n", rh->tfi);
- return 0;
- }
- this->update_tlli(tlli);
- LOGP(DRLCMACUL, LOGL_INFO, "Decoded premier TLLI=0x%08x of "
- "UL DATA TFI=%d.\n", this->tlli(), rh->tfi);
- if ((dl_tbf = bts->tbf_by_tlli(this->tlli(), GPRS_RLCMAC_DL_TBF))) {
- LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from "
- "TLLI=0x%08x while %s still exists. "
- "Killing pending DL TBF\n", this->tlli(),
- tbf_name(dl_tbf));
- tbf_free(dl_tbf);
- }
- /* tbf_by_tlli will not find your TLLI, because it is not
- * yet marked valid */
- if ((ul_tbf = bts->tbf_by_tlli(this->tlli(), GPRS_RLCMAC_UL_TBF))) {
- LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from "
- "TLLI=0x%08x while %s still exists. "
- "Killing pending UL TBF\n", this->tlli(),
- tbf_name(ul_tbf));
- tbf_free(ul_tbf);
- }
- /* mark TLLI valid now */
- this->tlli_mark_valid();
- /* store current timing advance */
- bts->timing_advance()->remember(this->tlli(), this->ta);
/* already have TLLI, but we stille get another one */
} else if (rh->ti) {
uint32_t tlli;
diff --git a/src/tbf.h b/src/tbf.h
index 4718707..4d7f64b 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -233,6 +233,8 @@ protected:
gprs_rlcmac_bts *bts_data() const;
bool dl_window_stalled() const;
+ int extract_tlli(const uint8_t *data, const size_t len);
+
int append_data(const uint8_t ms_class,
const uint16_t pdu_delay_csec,
const uint8_t *data, const uint16_t len);