Refactor code rejecting UL-TBF upon rx of PktResourceReq

* Make it similar to the already existing TBF allocation procedures
* Pass pdch pointer instead of trx and ts numbers

Change-Id: I04b3b65942732cc652adeaa507529b849292ff61
diff --git a/src/gprs_ms.c b/src/gprs_ms.c
index c9eaf97..073dd4a 100644
--- a/src/gprs_ms.c
+++ b/src/gprs_ms.c
@@ -1160,6 +1160,22 @@
 	return ul_tbf;
 }
 
+/* Create a temporary dummy TBF to Tx a ImmAssReject if allocating a new one during
+ * packet resource Request failed. This is similar as ul_tbf_alloc() but without
+ * calling tbf->setup() (in charge of TFI/USF allocation), and reusing resources
+ * from Packet Resource Request we received. See TS 44.060 sec 7.1.3.2.1  */
+struct gprs_rlcmac_ul_tbf *ms_new_ul_tbf_rejected_pacch(struct GprsMs *ms, struct gprs_rlcmac_pdch *pdch)
+{
+	struct gprs_rlcmac_ul_tbf *ul_tbf;
+	ul_tbf = ul_tbf_alloc_rejected(ms->bts, ms, pdch);
+	if (!ul_tbf)
+		return NULL;
+	osmo_fsm_inst_dispatch(tbf_state_fi(ul_tbf_as_tbf(ul_tbf)), TBF_EV_ASSIGN_ADD_PACCH, NULL);
+	osmo_fsm_inst_dispatch(tbf_ul_ass_fi(ul_tbf_as_tbf(ul_tbf)), TBF_UL_ASS_EV_SCHED_ASS_REJ, NULL);
+
+	return ul_tbf;
+}
+
 /* A new DL-TBF is allocated and assigned through PACCH using "tbf".
  * "tbf" may be either a UL-TBF or a DL-TBF.
  * Note: This should be called only when MS is reachable, see ms_is_reachable_for_dl_ass().