tbf,bts: Keep track of new TBF for dl/ul assignment in m_new_tbf

There are a couple of possibilities where one TBF is used to assign a
new one:

1. Assign a DL TBF from a UL TBF
2. Assign a UL TBF from a DL TBF
3. Assign a DL TBF from a DL TBF which is in wait-release state (T3193 is
   running)

In these cases the assignment is sent on the existing TBF and triggers
the assignement of the new TBF (with different TFI/direction).

The current code detects these situations by looking at dl/ul_ass_state
and then chosing the TBF with the opposite direction (DL/UL) that has
the same TLLI. This does not work in the case 3 above where a new DL TBF
is triggered for a DL TBF. The current code reuses the old TBF (and
TFI), but this violates the spec.

This patch introduces a m_new_tbf member which is set to the new TBF to
be assigned. When receiving a control ack the code looks up the
n_new_tbf member of the tbf that requested the control ack and completes
the ul/dl assignment. If the old TBF was in the wait release state
(T3193 is running) it is released.

From 3GPP TS 04.60 9.3.2.6:
"""
If the network has received the PACKET DOWNLINK ACK/NACK message with
the Final Ack Indicator bit set to '1' and has new data to transmit for
the mobile station, the network may establish a new downlink TBF for the
mobile station by sending the PACKET DOWNLINK ASSIGNMENT or PACKET
TIMESLOT RECONFIGURE message with the Control Ack bit set to '1' on
PACCH. In case the network establishes a new downlink TBF for the mobile
station, the network shall stop timer T3193.
"""

reuse_tbf() is modified to allocate a new TBF with a new TFI and trigger
a dl assignment for that TBF on the old TBF. All pending data is moved
to the new TBF.

Ticket: SYS#382
Sponsored-by: On-Waves ehf
diff --git a/src/tbf.h b/src/tbf.h
index c0f976d..69f1f05 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -142,6 +142,9 @@
 	const char *imsi() const;
 	void assign_imsi(const char *imsi);
 
+	void set_new_tbf(gprs_rlcmac_tbf *tbf);
+	gprs_rlcmac_tbf *new_tbf() const;
+
 	time_t created_ts() const;
 
 	/* attempt to make things a bit more fair */
@@ -165,6 +168,8 @@
 	enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state;
 	enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
 
+	gprs_rlcmac_tbf *m_new_tbf;
+
 	enum gprs_rlcmac_tbf_poll_state poll_state;
 	uint32_t poll_fn; /* frame number to poll */
 
@@ -289,6 +294,11 @@
 	return m_imsi;
 }
 
+inline gprs_rlcmac_tbf *gprs_rlcmac_tbf::new_tbf() const
+{
+	return m_new_tbf;
+}
+
 inline time_t gprs_rlcmac_tbf::created_ts() const
 {
 	return m_created_ts;