blob: c8b82053414417b9610283d0a790e5d17fe5de03 [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
Harald Weltec76f29f2017-11-22 12:46:46 +010049 charstring mp_sccp_service_type := "mtp3_itu";
50
Harald Welteb3414b22017-11-23 18:22:10 +010051 integer mp_bsc_pc := 196;
52 integer mp_bsc_ssn := 254;
Harald Weltec76f29f2017-11-22 12:46:46 +010053
Harald Welteb3414b22017-11-23 18:22:10 +010054 integer mp_msc_pc := 185; /* 0.23.1 */
55 integer mp_msc_ssn := 254;
Harald Weltec76f29f2017-11-22 12:46:46 +010056}
Harald Welte00566f52017-11-21 16:43:49 +010057
Harald Welted86cdc62017-11-22 00:45:07 +010058/* construct a SCCP_PAR_Address with just PC + SSN and no GT */
59template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn) := {
60 addressIndicator := {
61 pointCodeIndic := '1'B,
62 ssnIndicator := '1'B,
63 globalTitleIndic := '0000'B,
64 routingIndicator := '1'B
65 },
66 signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, '83'O),
67 //signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, g_sio),
68 subsystemNumber := ssn,
69 globalTitle := omit
70}
71
Harald Welteb3414b22017-11-23 18:22:10 +010072template MTP3_Field_sio ts_sio(octetstring sio_in) := {
73 ni := substr(oct2bit(sio_in),0,2),
74 prio := substr(oct2bit(sio_in),2,2),
75 si := substr(oct2bit(sio_in),4,4)
Harald Weltec76f29f2017-11-22 12:46:46 +010076}
77
Harald Welteb3414b22017-11-23 18:22:10 +010078template MSC_SCCP_MTP3_parameters ts_SCCP_Pars(octetstring sio, integer opc, integer dpc,
79 integer local_ssn) := {
80 sio := ts_sio(sio),
81 opc := opc,
82 dpc := dpc,
83 sls := 0,
84 sccp_serviceType := mp_sccp_service_type,
85 ssn := local_ssn
86};
87
88function f_init_BscState(inout BscState bsc_st, integer opc, integer dpc, integer local_ssn, integer remote_ssn)
89runs on test_CT {
90 bsc_st.sccp_pars := valueof(ts_SCCP_Pars(g_sio, opc, dpc, local_ssn));
91 bsc_st.sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(opc, local_ssn));
92 bsc_st.sccp_addr_peer := valueof(ts_SccpAddr_PC_SSN(dpc, remote_ssn));
Harald Weltec76f29f2017-11-22 12:46:46 +010093}
94
Harald Welteb3414b22017-11-23 18:22:10 +010095function f_init_MscState(inout MscState msc_st, integer opc, integer dpc, integer local_ssn, integer remote_ssn)
96runs on test_CT {
97 msc_st.sccp_pars := valueof(ts_SCCP_Pars(g_sio, opc, dpc, local_ssn));
98 msc_st.sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(opc, local_ssn));
Harald Welted86cdc62017-11-22 00:45:07 +010099}
100
Harald Welteb3414b22017-11-23 18:22:10 +0100101function f_init() runs on test_CT {
102 var integer i;
Harald Welte00566f52017-11-21 16:43:49 +0100103
Harald Welteb3414b22017-11-23 18:22:10 +0100104 for (i := 0; i < NUM_MSC; i := i+1) {
105 f_init_MscState(msc[i], mp_msc_pc +i, mp_bsc_pc, mp_msc_ssn, mp_bsc_ssn);
106 msc[i].MSC := MSC_CT.create;
107 msc[i].MSC.start(MSC_Simulation.main(mp_msc_ip, mp_msc_port + i, msc[i].sccp_pars, msc[i].sccp_addr_own));
Harald Welte00566f52017-11-21 16:43:49 +0100108 }
109
Harald Welteb3414b22017-11-23 18:22:10 +0100110 for (i := 0; i < NUM_BSC; i := i+1) {
111 f_init_BscState(bsc[i], mp_bsc_pc +i, mp_msc_pc, mp_bsc_ssn, mp_msc_ssn);
112 bsc[i].BSC := BSC_CT.create;
113 bsc[i].BSC.start(BSC_MS_Simulation.main(mp_msc_ip, mp_msc_port, mp_bsc_ip, mp_bsc_port+i,
114 bsc[i].sccp_pars, bsc[i].sccp_addr_own,
115 bsc[i].sccp_addr_peer));
116 }
Harald Welte00566f52017-11-21 16:43:49 +0100117
Harald Weltec76f29f2017-11-22 12:46:46 +0100118}
119
120testcase TC_recv_dump() runs on test_CT {
121 f_init();
122
Harald Welteb3414b22017-11-23 18:22:10 +0100123 //var PDU_BSSAP bssap := f_gen_cl3();
124 //f_send_bssap_cc(bssap);
Harald Weltec76f29f2017-11-22 12:46:46 +0100125
126 while (true) {
Harald Welteb3414b22017-11-23 18:22:10 +0100127 //SCCP.receive;
Harald Welte00566f52017-11-21 16:43:49 +0100128 }
Harald Weltec76f29f2017-11-22 12:46:46 +0100129}
Harald Welte00566f52017-11-21 16:43:49 +0100130
Harald Weltec76f29f2017-11-22 12:46:46 +0100131control {
132 execute( TC_recv_dump() );
133}
134
Harald Welte00566f52017-11-21 16:43:49 +0100135}