summaryrefslogtreecommitdiffstats
path: root/library/Osmocom_CTRL_Adapter.ttcn
blob: 22195c89a38005146366ebd520c11f83a9fa8236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
module Osmocom_CTRL_Adapter {

/* Module that test suites can 'inherit' in order to have a CTRL connection to the IUT which they're testing */

import from IPL4asp_Types all;

import from IPA_Emulation all;
import from IPA_Types all;

import from Osmocom_CTRL_Functions all;
import from Osmocom_CTRL_Types all;


type component CTRL_Adapter_CT {
	var IPA_Emulation_CT vc_CTRL_IPA;
	/* test port for the CTRL interface of the BSC */
	port IPA_CTRL_PT IPA_CTRL;
}


/*! Start the CTRL connection to the specified BSC IP+Port */
function f_ipa_ctrl_start(charstring bsc_host, PortNumber bsc_port)
runs on CTRL_Adapter_CT {
	var charstring id := "IPA-CTRL"
	timer T := 10.0;

	vc_CTRL_IPA := IPA_Emulation_CT.create(id & "-IPA");

	map(vc_CTRL_IPA:IPA_PORT, system:IPA_CODEC_PT);
	connect(vc_CTRL_IPA:IPA_CTRL_PORT, self:IPA_CTRL);

	vc_CTRL_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", -1,
						    c_IPA_default_ccm_pars, false));

	/* wait for IPA CTRL link to connect and send UP */
	T.start;
	alt {
	[] IPA_CTRL.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP}) { }
	[] T.timeout {
		setverdict(fail, "Timeout CTRL waiting for ASP_IPA_EVENT_UP");
		self.stop;
		}
	}
}

function f_ipa_ctrl_stop() runs on CTRL_Adapter_CT {
	vc_CTRL_IPA.stop;
}


/* BSC specific CTRL helper functions */
function f_ctrl_get_bts(IPA_CTRL_PT pt, integer bts_nr, charstring suffix) return CtrlValue {
	return f_ctrl_get(pt, "bts." & int2str(bts_nr) & "." & suffix);
}

template charstring ts_bts(integer bts_nr) := "bts." & int2str(bts_nr) & ".";
template charstring ts_bts_trx(integer bts_nr, integer trx_nr ) :=
	valueof(ts_bts(bts_nr)) & "trx." & int2str(trx_nr) & ".";

function f_ctrl_get_exp_bts(IPA_CTRL_PT pt, integer bts_nr, CtrlVariable suffix, template CtrlValue exp) {
	f_ctrl_get_exp(pt, valueof(ts_bts(bts_nr)) & suffix, exp);
}

function f_ctrl_get_exp_trx(IPA_CTRL_PT pt, integer bts_nr, integer trx_nr, CtrlVariable suffix,
			    template CtrlValue exp)
{
	f_ctrl_get_exp(pt, valueof(ts_bts_trx(bts_nr, trx_nr)) & suffix, exp);
}


}