Use final_ack_sent and contention_resolution_done to define ongoing UL TBF

Both flags can be used to determine wether assignment must be sent on PCH
or on AGCH. Before contention resolution is done, mobile will ignore
downlink assinment. When final uplink acknowledge was sent, the mobile
will go back to PCH after reception of akcnowledge.
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index c4d27e8..9b977f2 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -177,9 +177,8 @@
 
 		/* check for uplink data, so we copy our informations */
 		tbf = tbf_by_tlli(tlli, GPRS_RLCMAC_UL_TBF);
-		if (tbf && tbf->contention_resolution_done
-		 && (tbf->state != GPRS_RLCMAC_FINISHED
-		  || tbf->ul_ack_state != GPRS_RLCMAC_UL_ACK_WAIT_ACK)) {
+		if (tbf && tbf->dir.ul.contention_resolution_done
+		 && !tbf->dir.ul.final_ack_sent) {
 			use_trx = tbf->trx;
 			first_ts = tbf->first_ts;
 			ta = tbf->ta;
diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 7291f77..fc4173d 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -139,7 +139,6 @@
 	uint8_t tfi;
 	uint32_t tlli;
 	uint8_t tlli_valid;
-	uint8_t contention_resolution_done; /* set after done */
 	uint8_t trx;
 	uint16_t arfcn;
 	uint8_t tsc;
@@ -187,6 +186,8 @@
 			int32_t rx_counter; /* count all received blocks */
 			uint8_t n3103;	/* N3103 counter */
 			uint8_t usf[8];	/* list USFs per PDCH (timeslot) */
+			uint8_t contention_resolution_done; /* set after done */
+			uint8_t final_ack_sent; /* set if we sent final ack */
 		} ul;
 	} dir;
 	uint8_t rlc_block[RLC_MAX_SNS/2][RLC_MAX_LEN]; /* block history */
diff --git a/src/gprs_rlcmac_data.cpp b/src/gprs_rlcmac_data.cpp
index 58985e0..69cfe13 100644
--- a/src/gprs_rlcmac_data.cpp
+++ b/src/gprs_rlcmac_data.cpp
@@ -256,7 +256,7 @@
 			}
 			ul_tbf->tlli = tbf->tlli;
 			ul_tbf->tlli_valid = 1; /* no contention resolution */
-			ul_tbf->contention_resolution_done = 1;
+			ul_tbf->dir.ul.contention_resolution_done = 1;
 			ul_tbf->ta = tbf->ta; /* use current TA */
 			tbf_new_state(ul_tbf, GPRS_RLCMAC_ASSIGN);
 			tbf_timer_start(ul_tbf, 3169, bts->t3169, 0);
@@ -586,13 +586,14 @@
 
 	/* now we must set this flag, so we are allowed to assign downlink
 	 * TBF on PACCH. it is only allowed when TLLI is aknowledged. */
-	tbf->contention_resolution_done = 1;
+	tbf->dir.ul.contention_resolution_done = 1;
 
 	if (final) {
 		tbf->poll_state = GPRS_RLCMAC_POLL_SCHED;
 		tbf->poll_fn = (fn + 13) % 2715648;
 		/* waiting for final acknowledge */
 		tbf->ul_ack_state = GPRS_RLCMAC_UL_ACK_WAIT_ACK;
+		tbf->dir.ul.final_ack_sent = 1;
 	} else
 		tbf->ul_ack_state = GPRS_RLCMAC_UL_ACK_NONE;
 
@@ -1432,7 +1433,7 @@
 	if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
 		/* be sure to check first, if contention resolution is done,
 		 * otherwise we cannot send the assignment yet */
-		if (!tbf->contention_resolution_done) {
+		if (!tbf->dir.ul.contention_resolution_done) {
 			LOGP(DRLCMAC, LOGL_DEBUG, "Cannot assign DL TBF now, "
 				"because contention resolution is not "
 				"finished.\n");