blob: 9b268005e11e0479a81a7f3027f0a3134749a0f2 [file] [log] [blame]
Harald Welte28d943e2017-11-25 15:00:50 +01001module BSC_Tests {
2
3import from Osmocom_Types all;
4
5import from IPL4asp_Types all;
6
7import from IPA_Emulation all;
8
9import from MTP3asp_Types all;
10
11import from SCCP_Types all;
12import from SCCPasp_Types all;
13import from SCCP_Emulation all;
14
15import from MSC_Simulation all;
Harald Welte696ddb62017-12-08 14:01:43 +010016import from BTS_Simulation all;
Harald Welte28d943e2017-11-25 15:00:50 +010017
18const integer NUM_MSC := 1;
Harald Welte696ddb62017-12-08 14:01:43 +010019const integer NUM_BTS := 1;
Harald Welte28d943e2017-11-25 15:00:50 +010020
21type record MscState {
22 MSC_CT MSC,
23 MSC_SCCP_MTP3_parameters sccp_pars,
24 SCCP_PAR_Address sccp_addr_own
25}
26
Harald Welte696ddb62017-12-08 14:01:43 +010027type record BtsState {
28 BTS_CT BTS
29}
30
Harald Welte28d943e2017-11-25 15:00:50 +010031type component test_CT {
32 var MscState msc[NUM_MSC];
Harald Welte696ddb62017-12-08 14:01:43 +010033 var BtsState bts[NUM_BTS];
Harald Welte28d943e2017-11-25 15:00:50 +010034
35 var boolean g_initialized := false;
36 var octetstring g_sio := '83'O;
37}
38
39modulepar {
40 PortNumber mp_msc_port := 5000;
41 charstring mp_msc_ip := "127.0.0.1";
42
43 charstring mp_sccp_service_type := "mtp3_itu";
44
45 integer mp_bsc_pc := 196;
46 integer mp_bsc_ssn := 254;
47
48 integer mp_msc_pc := 185; /* 0.23.1 */
49 integer mp_msc_ssn := 254;
Harald Welte696ddb62017-12-08 14:01:43 +010050
51 charstring mp_bsc_ip := "127.0.0.1";
52 integer mp_bsc_rsl_port := 3003;
Harald Welte28d943e2017-11-25 15:00:50 +010053}
54
55/* construct a SCCP_PAR_Address with just PC + SSN and no GT */
56template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn) := {
57 addressIndicator := {
58 pointCodeIndic := '1'B,
59 ssnIndicator := '1'B,
60 globalTitleIndic := '0000'B,
61 routingIndicator := '1'B
62 },
63 signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, '83'O),
64 //signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, g_sio),
65 subsystemNumber := ssn,
66 globalTitle := omit
67}
68
69template MTP3_Field_sio ts_sio(octetstring sio_in) := {
70 ni := substr(oct2bit(sio_in),0,2),
71 prio := substr(oct2bit(sio_in),2,2),
72 si := substr(oct2bit(sio_in),4,4)
73}
74
75template MSC_SCCP_MTP3_parameters ts_SCCP_Pars(octetstring sio, integer opc, integer dpc,
76 integer local_ssn) := {
77 sio := ts_sio(sio),
78 opc := opc,
79 dpc := dpc,
80 sls := 0,
81 sccp_serviceType := mp_sccp_service_type,
82 ssn := local_ssn
83};
84
85function f_init_MscState(inout MscState msc_st, integer opc, integer dpc, integer local_ssn, integer remote_ssn)
86runs on test_CT {
87 msc_st.sccp_pars := valueof(ts_SCCP_Pars(g_sio, opc, dpc, local_ssn));
88 msc_st.sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(opc, local_ssn));
89}
90
91function f_init() runs on test_CT {
92 var integer i;
93 var charstring id;
94
95 for (i := 0; i < NUM_MSC; i := i+1) {
96 f_init_MscState(msc[i], mp_msc_pc +i, mp_bsc_pc, mp_msc_ssn, mp_bsc_ssn);
97 msc[i].MSC := MSC_CT.create;
98 id := "MSC" & int2str(i);
99 msc[i].MSC.start(MSC_Simulation.main(mp_msc_ip, mp_msc_port + i, msc[i].sccp_pars, msc[i].sccp_addr_own, id));
100 }
101
Harald Welte696ddb62017-12-08 14:01:43 +0100102 for (i := 0; i < NUM_BTS; i := i+1) {
103 bts[i].BTS := BTS_CT.create;
104 id := "BTS" & int2str(i);
105 bts[i].BTS.start(BTS_Simulation.main(mp_bsc_ip, mp_bsc_rsl_port, id));
106 }
107
Harald Welte28d943e2017-11-25 15:00:50 +0100108}
109
110testcase TC_recv_dump() runs on test_CT {
111 var integer i;
112 timer T := 30.0;
113
114 f_init();
115
116 alt {
117 [] msc[0].MSC.done { }
118 [] T.timeout { setverdict(fail); }
119 }
120}
121
122control {
123 execute( TC_recv_dump() );
124}
125
126}