IuUP: Encode Initialization according to cfg

Change-Id: I1dec3a8dcc829ad2c308636b697b089e873fd824
diff --git a/library/IuUP_Emulation.ttcn b/library/IuUP_Emulation.ttcn
index 899ba50..1bb2bb2 100644
--- a/library/IuUP_Emulation.ttcn
+++ b/library/IuUP_Emulation.ttcn
@@ -35,6 +35,7 @@
 
 template (value) IuUP_RabFlowCombination t_IuUP_RFC_AMR_12_2(IuUP_RFCI rfci) := t_IuUP_RFC(rfci, {81, 103, 60}, 1);
 template (value) IuUP_RabFlowCombination t_IuUP_RFC_AMR_SID(IuUP_RFCI rfci) := t_IuUP_RFC(rfci, {34, 0, 0}, 7);
+template (value) IuUP_RabFlowCombination t_IuUP_RFC_AMR_NO_DATA(IuUP_RFCI rfci) := t_IuUP_RFC(rfci, {0, 0, 0}, 1);
 
 type record IuUP_Config {
 	/* actively send INIT (true) or only passively respond (false) */
@@ -63,7 +64,7 @@
 	cfg := {
 		active_init := act_init,
 		data_pdu_type_0 := true,
-		rab_flow_combs := { t_IuUP_RFC_AMR_12_2(0), t_IuUP_RFC_AMR_SID(1) }
+		rab_flow_combs := { t_IuUP_RFC_AMR_12_2(0), t_IuUP_RFC_AMR_SID(1), t_IuUP_RFC_AMR_NO_DATA(2) }
 	},
 	state := ST_INIT,
 	tx_next_frame_nr := 0,
@@ -120,6 +121,48 @@
 	self.stop;
 }
 
+private function f_ts_IuUP_INIT(inout IuUP_Entity st) return IuUP_PDU
+{
+	var IuUP_PDU pdu;
+	var uint4_t data_pdu_type;
+	var template (omit) IuUP_InitRfci rfci := omit;
+	var IuUP_IPTI_List IPTIs := {};
+	var uint4_t num_rfci := lengthof(st.cfg.rab_flow_combs);
+
+	if (st.cfg.data_pdu_type_0 == true) {
+		data_pdu_type := 0;
+	} else {
+		data_pdu_type := 1;
+	}
+
+	/* Build RFCI list: */
+	for (var integer remain := num_rfci; remain > 0; remain := remain - 1) {
+		var IuUP_RabFlowCombination comb := st.cfg.rab_flow_combs[remain - 1];
+		var boolean lri := false;
+		if (remain == num_rfci) {
+			lri := true;
+		}
+		rfci := ts_IuUP_InitRfci(lri, false, comb.rfci, comb.sub_flow_bits, omit, rfci)
+	}
+
+	/* Build IPTI list: */
+	for (var integer i := 0; i < num_rfci; i := i + 1) {
+		IPTIs := IPTIs & { st.cfg.rab_flow_combs[i].ipti };
+	}
+
+	template (value) IuUP_PDU14_ProcSending_INIT tpl := ts_IuUP_PDU14_ProcSending_INIT(
+		ti := true,
+		subflows_per_rfci := num_rfci,
+		chain_ind := false,
+		rfci := rfci,
+		IPTIs := IPTIs,
+		versions_supported := '0000000000000001'B,
+		data_pdu_type := data_pdu_type
+		);
+	pdu := valueof(ts_IuUP_INIT(tpl));
+	return pdu;
+}
+
 function f_IuUP_Em_tx_encap(inout IuUP_Entity st, in octetstring payload) return octetstring {
 	var IuUP_PDU pdu;
 	select (st.state) {
@@ -127,7 +170,7 @@
 			if (st.cfg.active_init) {
 				if (not isvalue(st.pending_tx_pdu)) {
 					/* send INIT */
-					pdu := valueof(ts_IuUP_INIT(ts_IuUP_PDU14_ProcSending_INIT));
+					pdu := f_ts_IuUP_INIT(st);
 					st.pending_tx_pdu := pdu;
 				} /* else: wait for INIT-ACK return ''O at the end */