Use Timing Advance Index in UL assignments

Write TAI (if available) when generating Rest Octets for UL
Assignment. This should not affect actual PCU behavior because TAI is
not yet supported by upper layers but we have to adjust corresponding
tests anyway.

Change-Id: I8b17be78a46c0bc17516b7c90f35aa4768010ae4
diff --git a/src/encoding.cpp b/src/encoding.cpp
index e96894f..39cbe24 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -255,7 +255,9 @@
 		rc = write_alpha_gamma(dest, alpha, gamma);
 		check(rc);
 
-		set_0(dest); /* No TIMING_ADVANCE_INDEX */
+		rc = write_ta_index(dest, ta_idx);
+		check(rc);
+
 		set_0(dest); /* No TBF_STARTING_TIME */
 	} else {
 		set_0(dest); /* Single Block Allocation */
@@ -317,7 +319,9 @@
 		rc = write_alpha_gamma(dest, alpha, gamma);                 /* ALPHA and GAMMA */
 		check(rc);
 
-		set_0(dest);                                                /* No TIMING_ADVANCE_INDEX */
+		rc = write_ta_index(dest, ta_idx);
+		check(rc);
+
 		set_0(dest);                                                /* No TBF_STARTING_TIME */
 		bitvec_set_bit(dest, L);                                    /* No Additions for Rel-7 */
 	} else {
diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err
index b37d31e..da2c2dd 100644
--- a/tests/tbf/TbfTest.err
+++ b/tests/tbf/TbfTest.err
@@ -1561,7 +1561,7 @@
 TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x03, Fn=2654167  (17,25,9)
 TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=0 USF=0
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 03 8b 29 07 00 c8 00 00 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 03 8b 29 07 00 c8 00 00 1f 2b 2b 2b 2b 2b 2b 2b 
 Got RLC block, coding scheme: CS-1, length: 23 (23))
   UL data: 00 01 01 f1 22 33 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 Got CS-1 RLC block: R=0, SI=0, TFI=0, CPS=0, RSB=0, rc=184
@@ -2195,7 +2195,7 @@
 TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x03, Fn=2654275  (17,31,13)
 TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=0 USF=0
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 03 8b ed 07 00 c8 00 00 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 03 8b ed 07 00 c8 00 00 1f 2b 2b 2b 2b 2b 2b 2b 
 Got RLC block, coding scheme: CS-1, length: 23 (23))
   UL data: 00 01 01 f1 22 33 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 Got CS-1 RLC block: R=0, SI=0, TFI=0, CPS=0, RSB=0, rc=184
@@ -6871,7 +6871,7 @@
 TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x78, Fn=2654167  (17,25,9)
 TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=0 USF=0
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 78 8b 29 07 00 c8 00 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 78 8b 29 07 00 c8 00 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x79 Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -6896,7 +6896,7 @@
 TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x79, Fn=2654167  (17,25,9)
 TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=1 USF=1
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 79 8b 29 07 00 c8 42 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 79 8b 29 07 00 c8 42 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7a Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -6921,7 +6921,7 @@
 TBF(TFI=2 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x7a, Fn=2654167  (17,25,9)
 TBF(TFI=2 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=2 USF=2
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7a 8b 29 07 00 c8 84 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7a 8b 29 07 00 c8 84 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7b Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -6946,7 +6946,7 @@
 TBF(TFI=3 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x7b, Fn=2654167  (17,25,9)
 TBF(TFI=3 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=3 USF=3
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7b 8b 29 07 00 c8 c6 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7b 8b 29 07 00 c8 c6 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7c Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -6971,7 +6971,7 @@
 TBF(TFI=4 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x7c, Fn=2654167  (17,25,9)
 TBF(TFI=4 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=4 USF=4
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7c 8b 29 07 00 c9 08 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7c 8b 29 07 00 c9 08 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7d Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -6996,7 +6996,7 @@
 TBF(TFI=5 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x7d, Fn=2654167  (17,25,9)
 TBF(TFI=5 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=5 USF=5
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7d 8b 29 07 00 c9 4a 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7d 8b 29 07 00 c9 4a 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7e Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -7021,7 +7021,7 @@
 TBF(TFI=6 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x7e, Fn=2654167  (17,25,9)
 TBF(TFI=6 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=6 USF=6
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7e 8b 29 07 00 c9 8c 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7e 8b 29 07 00 c9 8c 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7f Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -9054,7 +9054,7 @@
 TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x78, Fn=2654167  (17,25,9)
 TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=0 USF=0
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 78 8b 29 07 00 c8 00 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 78 8b 29 07 00 c8 00 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x79 Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -9079,7 +9079,7 @@
 TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x79, Fn=2654167  (17,25,9)
 TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=1 USF=1
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 79 8b 29 07 00 c8 42 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 79 8b 29 07 00 c8 42 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7a Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -9104,7 +9104,7 @@
 TBF(TFI=2 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x7a, Fn=2654167  (17,25,9)
 TBF(TFI=2 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=2 USF=2
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7a 8b 29 07 00 c8 84 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7a 8b 29 07 00 c8 84 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7b Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -9129,7 +9129,7 @@
 TBF(TFI=3 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x7b, Fn=2654167  (17,25,9)
 TBF(TFI=3 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=3 USF=3
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7b 8b 29 07 00 c8 c6 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7b 8b 29 07 00 c8 c6 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7c Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -9154,7 +9154,7 @@
 TBF(TFI=4 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x7c, Fn=2654167  (17,25,9)
 TBF(TFI=4 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=4 USF=4
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7c 8b 29 07 00 c9 08 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7c 8b 29 07 00 c9 08 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7d Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -9179,7 +9179,7 @@
 TBF(TFI=5 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x7d, Fn=2654167  (17,25,9)
 TBF(TFI=5 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=5 USF=5
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7d 8b 29 07 00 c9 4a 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7d 8b 29 07 00 c9 4a 60 1f 2b 2b 2b 2b 2b 2b 2b 
 MS requests UL TBF on RACH, so we provide one: ra=0x7e Fn=2654167 qta=31 is_11bit=0:
 ********** UL-TBF starts here **********
 Allocating UL TBF: MS_CLASS=0/0
@@ -9204,7 +9204,7 @@
 TBF(TFI=6 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x7e, Fn=2654167  (17,25,9)
 TBF(TFI=6 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH)
  - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=6 USF=6
-Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7e 8b 29 07 00 c9 8c 60 0b 2b 2b 2b 2b 2b 2b 2b 
+Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7e 8b 29 07 00 c9 8c 60 1f 2b 2b 2b 2b 2b 2b 2b 
 Got RLC block, coding scheme: CS-1, length: 23 (23))
 +++++++++++++++++++++++++ RX : Uplink Control Block +++++++++++++++++++++++++
 ------------------------- RX : Uplink Control Block -------------------------