blob: c248a35d4c77515b1e14c27b97521f45c18b8620 [file] [log] [blame]
Harald Welte00566f52017-11-21 16:43:49 +01001module IPA_Test {
2
Harald Welteb3414b22017-11-23 18:22:10 +01003import from Osmocom_Types all;
4
Harald Weltec76f29f2017-11-22 12:46:46 +01005import from IPL4asp_Types all;
Harald Welte00566f52017-11-21 16:43:49 +01006
Harald Weltec76f29f2017-11-22 12:46:46 +01007import from IPA_Emulation all;
Harald Welted86cdc62017-11-22 00:45:07 +01008
Harald Welteb3414b22017-11-23 18:22:10 +01009import from MTP3asp_Types all;
10
Harald Weltec76f29f2017-11-22 12:46:46 +010011import from SCCP_Types all;
12import from SCCPasp_Types all;
13import from SCCP_Emulation all;
Harald Welted86cdc62017-11-22 00:45:07 +010014
Harald Welteb3414b22017-11-23 18:22:10 +010015import from MSC_Simulation all;
16import from BSC_MS_Simulation all;
Harald Welted86cdc62017-11-22 00:45:07 +010017
Harald Welteb3414b22017-11-23 18:22:10 +010018const integer NUM_MSC := 1;
19const integer NUM_BSC := 1;
20
21type record BscState {
22 BSC_CT BSC,
23 MSC_SCCP_MTP3_parameters sccp_pars,
24 SCCP_PAR_Address sccp_addr_own,
25 SCCP_PAR_Address sccp_addr_peer
26}
27
28type record MscState {
29 MSC_CT MSC,
30 MSC_SCCP_MTP3_parameters sccp_pars,
31 SCCP_PAR_Address sccp_addr_own
32}
Harald Welte00566f52017-11-21 16:43:49 +010033
Harald Weltec76f29f2017-11-22 12:46:46 +010034type component test_CT {
Harald Welteb3414b22017-11-23 18:22:10 +010035 var MscState msc[NUM_MSC];
36 var BscState bsc[NUM_BSC];
Harald Welte00566f52017-11-21 16:43:49 +010037
Harald Weltec76f29f2017-11-22 12:46:46 +010038 var boolean g_initialized := false;
Harald Welteb3414b22017-11-23 18:22:10 +010039 var octetstring g_sio := '83'O;
Harald Weltec76f29f2017-11-22 12:46:46 +010040}
Harald Welted86cdc62017-11-22 00:45:07 +010041
Harald Weltec76f29f2017-11-22 12:46:46 +010042modulepar {
Harald Welteb3414b22017-11-23 18:22:10 +010043 PortNumber mp_bsc_port := 49999;
44 charstring mp_bsc_ip := "127.0.0.1";
45
46 PortNumber mp_msc_port := 5000;
47 charstring mp_msc_ip := "127.0.0.1";
Harald Welted86cdc62017-11-22 00:45:07 +010048
Daniel Willmannfd338332017-11-24 17:23:23 +010049 PortNumber mp_nat_port := 5000;
50 charstring mp_nat_ip := "127.0.0.1";
51
Harald Weltec76f29f2017-11-22 12:46:46 +010052 charstring mp_sccp_service_type := "mtp3_itu";
53
Harald Welteb3414b22017-11-23 18:22:10 +010054 integer mp_bsc_pc := 196;
55 integer mp_bsc_ssn := 254;
Harald Weltec76f29f2017-11-22 12:46:46 +010056
Harald Welteb3414b22017-11-23 18:22:10 +010057 integer mp_msc_pc := 185; /* 0.23.1 */
58 integer mp_msc_ssn := 254;
Harald Weltec76f29f2017-11-22 12:46:46 +010059}
Harald Welte00566f52017-11-21 16:43:49 +010060
Harald Welted86cdc62017-11-22 00:45:07 +010061/* construct a SCCP_PAR_Address with just PC + SSN and no GT */
62template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn) := {
63 addressIndicator := {
64 pointCodeIndic := '1'B,
65 ssnIndicator := '1'B,
66 globalTitleIndic := '0000'B,
67 routingIndicator := '1'B
68 },
69 signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, '83'O),
70 //signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, g_sio),
71 subsystemNumber := ssn,
72 globalTitle := omit
73}
74
Harald Welteb3414b22017-11-23 18:22:10 +010075template MTP3_Field_sio ts_sio(octetstring sio_in) := {
76 ni := substr(oct2bit(sio_in),0,2),
77 prio := substr(oct2bit(sio_in),2,2),
78 si := substr(oct2bit(sio_in),4,4)
Harald Weltec76f29f2017-11-22 12:46:46 +010079}
80
Harald Welteb3414b22017-11-23 18:22:10 +010081template MSC_SCCP_MTP3_parameters ts_SCCP_Pars(octetstring sio, integer opc, integer dpc,
82 integer local_ssn) := {
83 sio := ts_sio(sio),
84 opc := opc,
85 dpc := dpc,
86 sls := 0,
87 sccp_serviceType := mp_sccp_service_type,
88 ssn := local_ssn
89};
90
91function f_init_BscState(inout BscState bsc_st, integer opc, integer dpc, integer local_ssn, integer remote_ssn)
92runs on test_CT {
93 bsc_st.sccp_pars := valueof(ts_SCCP_Pars(g_sio, opc, dpc, local_ssn));
94 bsc_st.sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(opc, local_ssn));
95 bsc_st.sccp_addr_peer := valueof(ts_SccpAddr_PC_SSN(dpc, remote_ssn));
Harald Weltec76f29f2017-11-22 12:46:46 +010096}
97
Harald Welteb3414b22017-11-23 18:22:10 +010098function f_init_MscState(inout MscState msc_st, integer opc, integer dpc, integer local_ssn, integer remote_ssn)
99runs on test_CT {
100 msc_st.sccp_pars := valueof(ts_SCCP_Pars(g_sio, opc, dpc, local_ssn));
101 msc_st.sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(opc, local_ssn));
Harald Welted86cdc62017-11-22 00:45:07 +0100102}
103
Harald Welteb3414b22017-11-23 18:22:10 +0100104function f_init() runs on test_CT {
105 var integer i;
Harald Weltebe620f62017-11-25 00:23:54 +0100106 var charstring id;
Harald Welte00566f52017-11-21 16:43:49 +0100107
Harald Welteb3414b22017-11-23 18:22:10 +0100108 for (i := 0; i < NUM_MSC; i := i+1) {
109 f_init_MscState(msc[i], mp_msc_pc +i, mp_bsc_pc, mp_msc_ssn, mp_bsc_ssn);
110 msc[i].MSC := MSC_CT.create;
Harald Weltebe620f62017-11-25 00:23:54 +0100111 id := "MSC" & int2str(i);
112 msc[i].MSC.start(MSC_Simulation.main(mp_msc_ip, mp_msc_port + i, msc[i].sccp_pars, msc[i].sccp_addr_own, id));
Harald Welte00566f52017-11-21 16:43:49 +0100113 }
114
Harald Welteb3414b22017-11-23 18:22:10 +0100115 for (i := 0; i < NUM_BSC; i := i+1) {
116 f_init_BscState(bsc[i], mp_bsc_pc +i, mp_msc_pc, mp_bsc_ssn, mp_msc_ssn);
117 bsc[i].BSC := BSC_CT.create;
Harald Weltebe620f62017-11-25 00:23:54 +0100118 id := "BSC" & int2str(i);
Daniel Willmannfd338332017-11-24 17:23:23 +0100119 bsc[i].BSC.start(BSC_MS_Simulation.main(mp_nat_ip, mp_nat_port, mp_bsc_ip, mp_bsc_port+i,
Harald Welteb3414b22017-11-23 18:22:10 +0100120 bsc[i].sccp_pars, bsc[i].sccp_addr_own,
Harald Weltebe620f62017-11-25 00:23:54 +0100121 bsc[i].sccp_addr_peer, id));
Harald Welteb3414b22017-11-23 18:22:10 +0100122 }
Harald Welte00566f52017-11-21 16:43:49 +0100123
Harald Weltec76f29f2017-11-22 12:46:46 +0100124}
125
126testcase TC_recv_dump() runs on test_CT {
127 f_init();
128
Harald Welteb3414b22017-11-23 18:22:10 +0100129 //var PDU_BSSAP bssap := f_gen_cl3();
130 //f_send_bssap_cc(bssap);
Harald Weltec76f29f2017-11-22 12:46:46 +0100131
132 while (true) {
Harald Welteb3414b22017-11-23 18:22:10 +0100133 //SCCP.receive;
Harald Welte00566f52017-11-21 16:43:49 +0100134 }
Harald Weltec76f29f2017-11-22 12:46:46 +0100135}
Harald Welte00566f52017-11-21 16:43:49 +0100136
Harald Weltec76f29f2017-11-22 12:46:46 +0100137control {
138 execute( TC_recv_dump() );
139}
140
Harald Welte00566f52017-11-21 16:43:49 +0100141}