library/L1CTL_PortType: refactor L1CTL channel establishment

  - Get rid of f_L1CTL_DM_EST_REQ, it's not really needed.
  - Derive ts_L1CTL_DM_EST_REQ_H0 from ts_L1CTL_DM_EST_REQ.
    - Turn all its params into (value) templates.
    - Turn it into a (value) template itself.
  - Pass GsmArfcn directly to ts_L1CTL_DM_EST_REQ_H0.

Change-Id: I4f275e22d4309a23b4ed301a0779c4ecb92023a8
Related: OS#4546
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 6811e38..0f89ec6 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -1093,7 +1093,7 @@
 	f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC);
 	/* don't perform immediate assignment here, as we're testing non-IA case */
 	/* enable dedicated mode */
-	f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
+	L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
 
 	/* Verify that no DL SACCH is being received */
 	f_sacch_missing(?);
@@ -1111,7 +1111,7 @@
 	f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
 	/* don't perform immediate assignment here, as we're testing non-IA case */
 	/* enable dedicated mode */
-	f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
+	L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
 
 	/* Verify that DL SACCH is being received */
 	f_sacch_present(si5);
@@ -1149,7 +1149,7 @@
 	f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC);
 	/* don't perform immediate assignment here, as we're testing non-IA case */
 	/* enable dedicated mode */
-	f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
+	L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
 
 	/* Verify that no DL SACCH is being received */
 	f_sacch_missing(?);
@@ -1167,7 +1167,7 @@
 	f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
 	/* don't perform immediate assignment here, as we're testing non-IA case */
 	/* enable dedicated mode */
-	f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
+	L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
 
 	/* Verify that no DL SACCH is being received */
 	f_sacch_missing(?);
@@ -1185,7 +1185,7 @@
 	f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
 	/* don't perform immediate assignment here, as we're testing non-IA case */
 	/* enable dedicated mode */
-	f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
+	L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
 
 	/* Verify that no DL SACCH is being received */
 	f_sacch_missing(?);
@@ -1204,7 +1204,7 @@
 	f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
 	/* don't perform immediate assignment here, as we're testing non-IA case */
 	/* enable dedicated mode */
-	f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
+	L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
 
 	/* Verify that DL SACCH is being received */
 	f_sacch_present(si5);
@@ -1538,7 +1538,7 @@
 
 	/* Switch the MS side (e.g. trxcon) to a dedicated channel without
 	 * waiting for Immediate Assignment and sending Access Burst */
-	f_L1CTL_DM_EST_REQ(L1CTL, { false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
+	L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
 
 	/* Send handover Access Burst */
 	fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
@@ -4312,9 +4312,7 @@
 	f_TC_pcu_act_req(0, 0, 7, true);
 
 	/* Tune trxcon to that PDCH channel */
-	L1CTL.send(ts_L1CTL_DM_EST_REQ(arfcn := { false, mp_trx0_arfcn },
-				       chan_nr := valueof(ts_RslChanNr_PDCH(7)),
-				       tsc := 7));
+	L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(ts_RslChanNr_PDCH(7), 7, mp_trx0_arfcn));
 
 	/* Verify PTCCH/U: send several access bursts, make sure they're received */
 	for (var integer i := 0; i < 16; i := i + 1) {
@@ -4575,8 +4573,7 @@
 	f_TC_pcu_act_req(0, 0, 7, true);
 
 	/* Tune trxcon to that PDCH channel on TS7 */
-	f_L1CTL_DM_EST_REQ(L1CTL, { false, mp_trx0_arfcn },
-			   valueof(ts_RslChanNr_PDCH(7)), 7);
+	L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(ts_RslChanNr_PDCH(7), 7, mp_trx0_arfcn));
 
 	/* C/I in centiBels, test range: -256 .. +1280, step 128 */
 	for (var int16_t i := -256; i <= 1280; i := i + 128) {
diff --git a/library/L1CTL_PortType.ttcn b/library/L1CTL_PortType.ttcn
index c595b03..cc2ff93 100644
--- a/library/L1CTL_PortType.ttcn
+++ b/library/L1CTL_PortType.ttcn
@@ -201,14 +201,12 @@
 		}
 		T.stop;
 	}
-	function f_L1CTL_DM_EST_REQ(L1CTL_PT pt, Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) {
-		pt.send(ts_L1CTL_DM_EST_REQ(arfcn, chan_nr, tsc));
-	}
 
 	/* Send DM_EST_REQ from parameters derived from IMM ASS */
 	function f_L1CTL_DM_EST_REQ_IA(L1CTL_PT pt, ImmediateAssignment imm_ass) {
-		f_L1CTL_DM_EST_REQ(pt, { false, imm_ass.chan_desc.arfcn }, imm_ass.chan_desc.chan_nr,
-				   imm_ass.chan_desc.tsc);
+		pt.send(ts_L1CTL_DM_EST_REQ_H0(imm_ass.chan_desc.chan_nr,
+					       imm_ass.chan_desc.tsc,
+					       imm_ass.chan_desc.arfcn));
 	}
 
 	/* Send DM_REL_REQ from parameters derived from IMM ASS */
diff --git a/library/L1CTL_Types.ttcn b/library/L1CTL_Types.ttcn
index e939f72..0870a20 100644
--- a/library/L1CTL_Types.ttcn
+++ b/library/L1CTL_Types.ttcn
@@ -548,7 +548,9 @@
 		}
 	}
 
-	template L1ctlUlMessage ts_L1CTL_DM_EST_REQ(Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) := {
+	/* Base template to be inherited by ts_L1CTL_DM_EST_REQ_H0 and ts_L1CTL_DM_EST_REQ_H1 */
+	private template (value) L1ctlUlMessage ts_L1CTL_DM_EST_REQ(template (value) RslChannelNr chan_nr,
+								    template (value) GsmTsc tsc) := {
 		header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
 		ul_info := {
 			chan_nr := chan_nr,
@@ -560,15 +562,25 @@
 		payload := {
 			dm_est_req := {
 				tsc := tsc,
-				h := 0,
-				arfcn := arfcn,
-				hopping := omit,
 				tch_mode := 0,
 				audio_mode := t_L1CTL_AudioModeNone
 			}
 		}
 	}
 
+	template (value) L1ctlUlMessage ts_L1CTL_DM_EST_REQ_H0(template (value) RslChannelNr chan_nr,
+							       template (value) GsmTsc tsc,
+							       template (value) GsmArfcn arfcn)
+	modifies ts_L1CTL_DM_EST_REQ := {
+		payload := {
+			dm_est_req := {
+				h := 0,
+				arfcn := { false, arfcn },
+				hopping := omit
+			}
+		}
+	}
+
 	template L1ctlUlMessage ts_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := {
 		header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
 		ul_info := {
diff --git a/library/LAPDm_RAW_PT.ttcn b/library/LAPDm_RAW_PT.ttcn
index 75d18d9..394deab 100644
--- a/library/LAPDm_RAW_PT.ttcn
+++ b/library/LAPDm_RAW_PT.ttcn
@@ -246,7 +246,7 @@
 		set_ph_state(PH_STATE_TUNING_DCH);
 		/* store/save channel description */
 		chan_desc.chan_nr := chan_nr;
-		f_L1CTL_DM_EST_REQ(L1CTL,arfcn, chan_nr, tsc);
+		L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(chan_nr, tsc, arfcn.arfcn));
 		set_ph_state(PH_STATE_DCH);
 	}