tbf: Refactor parts of extract_tlli into set_tlli_from_ul

Currently gprs_rlcmac_tbf::extract_tlli takes care of decoding and
the TBF update. These are really different things and doing the
decoding in extract_tlli makes EGPRS support more complex.

This commit moves the TBF state related part into a new method
gprs_rlcmac_tbf::set_tlli_from_ul.

Sponsored-by: On-Waves ehf
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 590d115..556f6e8 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -992,31 +992,14 @@
 	return 0;
 }
 
-int gprs_rlcmac_tbf::extract_tlli(const uint8_t *data, const size_t len)
+int gprs_rlcmac_tbf::set_tlli_from_ul(uint32_t new_tlli)
 {
 	struct gprs_rlcmac_tbf *dl_tbf = NULL;
 	struct gprs_rlcmac_tbf *ul_tbf = NULL;
-	struct rlc_ul_header *rh = (struct rlc_ul_header *)data;
-	uint32_t new_tlli;
-	int rc;
 	GprsMs *old_ms;
 
 	OSMO_ASSERT(direction == GPRS_RLCMAC_UL_TBF);
 
-	/* 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;
-	}
-
 	old_ms = bts->ms_by_tlli(new_tlli);
 	/* Keep the old MS object for the update_ms() */
 	GprsMs::Guard guard(old_ms);
@@ -1036,8 +1019,6 @@
 
 	/* The TLLI has been taken from an UL message */
 	update_ms(new_tlli, GPRS_RLCMAC_UL_TBF);
-	LOGP(DRLCMACUL, LOGL_INFO, "Decoded premier TLLI=0x%08x of "
-		"UL DATA TFI=%d.\n", tlli(), rh->tfi);
 	if (dl_tbf && dl_tbf->ms() != ms()) {
 		LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from "
 			"TLLI=0x%08x while %s still exists. "
@@ -1057,6 +1038,33 @@
 	return 1;
 }
 
+int gprs_rlcmac_tbf::extract_tlli(const uint8_t *data, const size_t len)
+{
+	struct rlc_ul_header *rh = (struct rlc_ul_header *)data;
+	uint32_t new_tlli;
+	int rc;
+
+	OSMO_ASSERT(direction == GPRS_RLCMAC_UL_TBF);
+
+	/* 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;
+	}
+	LOGP(DRLCMACUL, LOGL_INFO, "Decoded premier TLLI=0x%08x of "
+		"UL DATA TFI=%d.\n", new_tlli, rh->tfi);
+
+	return set_tlli_from_ul(new_tlli);
+}
+
 const char *tbf_name(gprs_rlcmac_tbf *tbf)
 {
 	return tbf->name();