library: L1CTL: merge L1ctl{Ul,Dl}Message into L1ctlMessage

Currently we have two variants of the L1CTL PDU:

* L1ctlUlMessage: L23 -> L1 requests (*_REQ),
* L1ctlDlMessage: L1 -> L23 responses (*_IND, *_CONF).

The L1CTL_PT port is defined in a way that one can:

* Tx L1ctl{Ul,Dl}Message PDUs,
* Rx L1ctlDlMessage PDUs.

This means that the testsuite can act as the L23 talking to the L1
(e.g. trxcon or virtphy), but not vice-versa.  Adding an additional
Rx `UD_send_data -> L1ctlUlMessage` mapping is not an option,
because such a mapping would be ambiguous and would cause errors.

By merging the two L1CTL PDU variants into the one, we can achieve
the testsuite acting as the L1.  This will be useful for testing
the L23 applications in osmocom-bb.git, like the modem app.

Take a chance to reorder fields to match the order in L1ctlMsgType.

Change-Id: I1313068c5f02b65d3dbb05a1341a9d7286225f0c
Related: OS#5500
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index e1281bb..e08f243 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -929,7 +929,7 @@
 
 /* This altstep triggers on receipt of a L1CTL DATA.ind matching the given
  * RSL chan_nr/link_id and data templates.  Used as a base for other altsteps. */
-private altstep as_l1ctl_dl_msg(out L1ctlDlMessage msg,
+private altstep as_l1ctl_dl_msg(out L1ctlMessage msg,
 				template (present) octetstring tr_data := ?,
 				template (present) RslChannelNr chan_nr := ?,
 				template (present) RslLinkId link_id := ?)
@@ -945,7 +945,7 @@
 				  boolean do_repeat := true)
 runs on ConnHdlr {
 	template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, ''O);
-	var L1ctlDlMessage dl_msg;
+	var L1ctlMessage dl_msg;
 
 	[] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, chan_nr, link_id) {
 		if (do_repeat) {
@@ -960,7 +960,7 @@
 				    template (present) LapdmFrameAB tr_frame := ?,
 				    template (present) RslLinkId link_id := ?)
 runs on ConnHdlr {
-	var L1ctlDlMessage dl_msg;
+	var L1ctlMessage dl_msg;
 
 	[] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, g_chan_nr, link_id) {
 		frame := dec_LapdmFrameAB(dl_msg.payload.data_ind.payload);
@@ -974,7 +974,7 @@
 				     template (present) SacchL1Header tr_l1h := ?,
 			             template (present) GsmSapi sapi := ?)
 runs on ConnHdlr {
-	var L1ctlDlMessage dl_msg;
+	var L1ctlMessage dl_msg;
 	template (present) RslLinkId link_id := tr_RslLinkID_SACCH(sapi);
 	template (present) L1ctlDataReq tr_data := {
 		l1header := tr_l1h,
@@ -1208,7 +1208,7 @@
 private function f_sacch_present(template octetstring l3_exp,
 				 boolean do_fail := true)
 runs on ConnHdlr {
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 	timer T_sacch := 3.0;
 	L1CTL.clear;
 	T_sacch.start;
@@ -1234,7 +1234,7 @@
 
 /* verify that given SACCH payload is not present */
 private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 	timer T_sacch := 3.0;
 	L1CTL.clear;
 	T_sacch.start;
@@ -2048,7 +2048,7 @@
 private function f_TC_ho_physical_info(charstring id) runs on ConnHdlr {
 	var PDU_ML3_NW_MS dcch_pdu;
 	var integer count := 0;
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 	timer T;
 
 	f_l1_tune(L1CTL);
@@ -2162,7 +2162,7 @@
 /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
 private altstep as_l1_sacch() runs on ConnHdlr {
 	var template (value) LapdmFrameAB lb;
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 
 	[] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
 		log("SACCH received: ", l1_dl.payload.data_ind.payload);
@@ -2191,7 +2191,7 @@
 				boolean do_apply := true)
 runs on ConnHdlr
 {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 
 	[] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
 		/* Parse the L1 SACCH header (MS Power Level & Timing Advance) */
@@ -2206,7 +2206,7 @@
 }
 
 private altstep as_l1_dcch_loop() runs on ConnHdlr {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	[] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
 		log("DCCH received: ", l1_dl.payload.data_ind.payload);
 		var octetstring pl := '010301'O;
@@ -2217,7 +2217,7 @@
 }
 
 private altstep as_l1_tch_loop() runs on ConnHdlr {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	[] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl {
 		log("TCH received: ", l1_dl.payload.traffic_ind.data);
 
@@ -2773,7 +2773,7 @@
 
 /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */
 private function f_wait_ramp_up() runs on ConnHdlr return integer {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp;
 	timer Tup := 10.0;
 	Tup.start;
@@ -2798,7 +2798,7 @@
 
 /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */
 private function f_verify_ramp_up() runs on ConnHdlr {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	var integer initial_rx_lvl := -1;
 	var integer last_rx_lvl := -1;
 	var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp;
@@ -2860,7 +2860,7 @@
 
 /* verify BTS ramps power down to rx_level 0 */
 private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	var integer last_rx_lvl := max_rx_lvl;
 
 	timer Tdown := 5.0;
@@ -2907,7 +2907,7 @@
 
 /* verify BTS power down to rx_level 0 without ramping */
 private function f_verify_power_down(integer max_rx_lvl) runs on ConnHdlr {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	var boolean first_data_ind := true;
 
 	timer Tdown := 5.0;
@@ -2997,7 +2997,7 @@
  * + ramping up during ADM state LOCKED->UNLOCKED
  */
 private function f_TC_tx_power_ramp_adm_state_change(charstring id) runs on ConnHdlr {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	var integer last_rx_lvl;
 
 	f_connhdlr_init_vty_bsc();
@@ -4088,7 +4088,7 @@
 				   inout integer num_paging_rcv_ids,
 				   PagingTestCfg cfg)
 runs on test_CT {
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 	[] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
 		repeat;
 	}
@@ -4468,7 +4468,7 @@
 }
 
 private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	timer T := 10.0;
 	var integer num_tx := 0;
 	var integer num_rx := 0;
@@ -4890,7 +4890,7 @@
 return SystemInformationVectorPerTc {
 	timer T := duration;
 	var SystemInformationVectorPerTc si_per_tc;
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 
 	/* initialize all per-TC vectors empty */
 	for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
@@ -5561,7 +5561,7 @@
 			     boolean wait_rts := true)
 runs on test_CT {
 	timer T := 5.0;
-	var L1ctlDlMessage rx_dl;
+	var L1ctlMessage rx_dl;
 
 	PCU.clear;
 	if (wait_rts) {
@@ -5668,7 +5668,7 @@
 }
 
 testcase TC_pcu_ptcch() runs on test_CT {
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 	var octetstring data;
 	timer T;
 
@@ -6266,7 +6266,7 @@
 /* Ensure that GPRS capability is not advertised before PCU socket conncet */
 private function f_get_si(L1CTL_PT pt, RrMessageType si_type)
 runs on test_CT return SystemInformation {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	var SystemInformation si;
 	var integer rc;
 	timer T := 5.0;
@@ -7214,7 +7214,7 @@
 /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
 private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
 	var RllTestCase tc := g_pars.spec.rll;
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 	timer T := 3.0;
 
 	f_l1_tune(L1CTL);
@@ -7255,7 +7255,7 @@
 
 /* altstep to receive a LAPDm frame matching the given template */
 friend altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 	[] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
 		var LapdmFrame lapdm;
 		var octetstring l2 := dl.payload.data_ind.payload;
@@ -7571,7 +7571,7 @@
 	f_est_dchan(true);
 
 	/* now we actually need to transmit some data both ways to check if the encryption works */
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 
 	var octetstring l3 := f_rnd_octstring(20);
 	var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
@@ -7615,7 +7615,7 @@
 	f_est_dchan(true);
 
 	/* now we actually need to transmit some data both ways to check if the encryption works */
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 
 	var octetstring l3 := f_rnd_octstring(20);
 	var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
@@ -7831,7 +7831,7 @@
  * DTX Related (see GSM 05.08, section 8.3)
  ***********************************************************************/
 private function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 	var GsmFrameNumber first_fn;
 	var boolean is_first_frame := true;
 	var integer nfill_frames := 0;
@@ -7853,7 +7853,7 @@
 	f_est_dchan(false);
 
 	/* A template for matching dummy LAPDm func=UA frames */
-	var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND(
+	var template L1ctlMessage tr_fill_frame := tr_L1CTL_DATA_IND(
 		chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?),
 		l2_data := f_pad_oct('030301'O, 23, '2B'O));
 
@@ -7990,7 +7990,7 @@
 
 private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks)
 runs on ConnHdlr {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	var SacchL1Header l1h;
 	var octetstring l2;
 
@@ -8179,8 +8179,8 @@
 }
 
 private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr {
-	var template L1ctlDlMessage tr_bad_frame;
-	var L1ctlDlMessage l1_dl;
+	var template L1ctlMessage tr_bad_frame;
+	var L1ctlMessage l1_dl;
 	timer T := 8.0;
 
 	f_l1_tune(L1CTL);
@@ -8241,7 +8241,7 @@
 
 /* Verify handling of Downlink and Uplink speech frames */
 private function f_TC_speech_rtp(charstring id) runs on ConnHdlr {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	var PDU_RTP rtp_pdu;
 	var octetstring pl;
 	timer Td, Tu;
@@ -8348,7 +8348,7 @@
 
 /* Verify handling of Downlink and Uplink Osmux speech frames */
 private function f_TC_speech_osmux(charstring id) runs on ConnHdlr {
-	var L1ctlDlMessage l1_dl;
+	var L1ctlMessage l1_dl;
 	var OSMUX_PDU osmux_pdu;
 	var octetstring pl;
 	var octetstring exp_rtp_pl;
@@ -8484,7 +8484,7 @@
 
 	/* Do not expect the Immediate Assignment to show up on MS side yet. Even give it one second before the BSC
 	 * requests Chan Activ, to make sure the RR IMM ASS is held back. */
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 	var GsmRrMessage rr;
 
 	var template GsmRrMessage rr_imm_ass := tr_IMM_ASS(ra, fn);
@@ -8601,7 +8601,7 @@
 private function f_rxlev_match(template (present) RslLinkId link_id,
 			       template (present) GsmRxLev rxlev)
 runs on ConnHdlr {
-	var L1ctlDlMessage dl := f_L1CTL_rx_data(L1CTL, g_chan_nr, link_id);
+	var L1ctlMessage dl := f_L1CTL_rx_data(L1CTL, g_chan_nr, link_id);
 	if (not match(dl.dl_info.rx_level, rxlev)) {
 		setverdict(fail, "RxLev(", link_id, ") := ", dl.dl_info.rx_level,
 				 " does not match expected RxLev := ", rxlev);
@@ -8612,7 +8612,7 @@
 private function f_TC_acch_overpower(charstring id) runs on ConnHdlr {
 	var TopTestCase tc := g_pars.spec.top;
 	var GsmRxLev rxlev_dcch;
-	var L1ctlDlMessage dl;
+	var L1ctlMessage dl;
 
 	/* Wait for Pau ramping to complete */
 	f_sleep(6.0);