Handle packet access reject during EPDAN/PDAN with channel description

When PDAN/EPDAN with channel description is received, PCU will generate the
packet access reject if no resources are present. The encoding is done
based on section 7.1.3.2.1 and 8.1.2.5 of 44.060 version 7.27.0 Release 7.
This patch also includes the test case to validate the generated
packet access reject message.

This patch is integration tested on Osmo-trx setup with Ettus B210 board
and LG F70 MS with some simulation code changes in Osmo-pcu.

Change-Id: I096a3bb44a65533b9e9b091925dd5f70a8696d6
diff --git a/src/encoding.cpp b/src/encoding.cpp
index ca72b0f..e5a8605 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -1391,3 +1391,28 @@
 
 	return AR_NEED_MORE_BLOCKS;
 }
+
+/*
+ * Refer 44.060 version 7.27.0 Release 7
+ * section 7.1.3.2.1 On receipt of a PACKET RESOURCE REQUEST message
+ * 8.1.2.5 Establishment of uplink TBF
+ */
+void Encoding::write_packet_access_reject(
+	bitvec * dest, uint32_t tlli)
+{
+	unsigned wp = 0;
+
+	bitvec_write_field(dest, wp, 0x1, 2);  // Payload Type
+	bitvec_write_field(dest, wp, 0x0, 2);  // Uplink block with TDMA FN
+	bitvec_write_field(dest, wp, 0, 1);  // No Polling Bit
+	bitvec_write_field(dest, wp, 0x0, 3);  // Uplink state flag
+	bitvec_write_field(dest, wp,
+				MT_PACKET_ACCESS_REJECT, 6);  // MESSAGE TYPE
+	bitvec_write_field(dest, wp, 0, 2); // fixed 00
+	bitvec_write_field(dest, wp, 0x0, 1);  //  TLLI / G-RNTI : bit (32)
+	bitvec_write_field(dest, wp, tlli, 32); // CONTENTION_RESOLUTION_TLLI
+	bitvec_write_field(dest, wp, 1, 1);  //  WAIT_INDICATION size in seconds
+	/* TODO: make it configurable */
+	bitvec_write_field(dest, wp, 5, 8);  //  WAIT_INDICATION value
+	bitvec_write_field(dest, wp, 0, 1);  //  WAIT_INDICATION size in seconds
+}