Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame^] | 1 | module BSC_Tests { |
| 2 | |
| 3 | import from Osmocom_Types all; |
| 4 | |
| 5 | import from IPL4asp_Types all; |
| 6 | |
| 7 | import from IPA_Emulation all; |
| 8 | |
| 9 | import from MTP3asp_Types all; |
| 10 | |
| 11 | import from SCCP_Types all; |
| 12 | import from SCCPasp_Types all; |
| 13 | import from SCCP_Emulation all; |
| 14 | |
| 15 | import from MSC_Simulation all; |
| 16 | |
| 17 | const integer NUM_MSC := 1; |
| 18 | |
| 19 | type record MscState { |
| 20 | MSC_CT MSC, |
| 21 | MSC_SCCP_MTP3_parameters sccp_pars, |
| 22 | SCCP_PAR_Address sccp_addr_own |
| 23 | } |
| 24 | |
| 25 | type component test_CT { |
| 26 | var MscState msc[NUM_MSC]; |
| 27 | |
| 28 | var boolean g_initialized := false; |
| 29 | var octetstring g_sio := '83'O; |
| 30 | } |
| 31 | |
| 32 | modulepar { |
| 33 | PortNumber mp_msc_port := 5000; |
| 34 | charstring mp_msc_ip := "127.0.0.1"; |
| 35 | |
| 36 | charstring mp_sccp_service_type := "mtp3_itu"; |
| 37 | |
| 38 | integer mp_bsc_pc := 196; |
| 39 | integer mp_bsc_ssn := 254; |
| 40 | |
| 41 | integer mp_msc_pc := 185; /* 0.23.1 */ |
| 42 | integer mp_msc_ssn := 254; |
| 43 | } |
| 44 | |
| 45 | /* construct a SCCP_PAR_Address with just PC + SSN and no GT */ |
| 46 | template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn) := { |
| 47 | addressIndicator := { |
| 48 | pointCodeIndic := '1'B, |
| 49 | ssnIndicator := '1'B, |
| 50 | globalTitleIndic := '0000'B, |
| 51 | routingIndicator := '1'B |
| 52 | }, |
| 53 | signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, '83'O), |
| 54 | //signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, g_sio), |
| 55 | subsystemNumber := ssn, |
| 56 | globalTitle := omit |
| 57 | } |
| 58 | |
| 59 | template MTP3_Field_sio ts_sio(octetstring sio_in) := { |
| 60 | ni := substr(oct2bit(sio_in),0,2), |
| 61 | prio := substr(oct2bit(sio_in),2,2), |
| 62 | si := substr(oct2bit(sio_in),4,4) |
| 63 | } |
| 64 | |
| 65 | template MSC_SCCP_MTP3_parameters ts_SCCP_Pars(octetstring sio, integer opc, integer dpc, |
| 66 | integer local_ssn) := { |
| 67 | sio := ts_sio(sio), |
| 68 | opc := opc, |
| 69 | dpc := dpc, |
| 70 | sls := 0, |
| 71 | sccp_serviceType := mp_sccp_service_type, |
| 72 | ssn := local_ssn |
| 73 | }; |
| 74 | |
| 75 | function f_init_MscState(inout MscState msc_st, integer opc, integer dpc, integer local_ssn, integer remote_ssn) |
| 76 | runs on test_CT { |
| 77 | msc_st.sccp_pars := valueof(ts_SCCP_Pars(g_sio, opc, dpc, local_ssn)); |
| 78 | msc_st.sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(opc, local_ssn)); |
| 79 | } |
| 80 | |
| 81 | function f_init() runs on test_CT { |
| 82 | var integer i; |
| 83 | var charstring id; |
| 84 | |
| 85 | for (i := 0; i < NUM_MSC; i := i+1) { |
| 86 | f_init_MscState(msc[i], mp_msc_pc +i, mp_bsc_pc, mp_msc_ssn, mp_bsc_ssn); |
| 87 | msc[i].MSC := MSC_CT.create; |
| 88 | id := "MSC" & int2str(i); |
| 89 | msc[i].MSC.start(MSC_Simulation.main(mp_msc_ip, mp_msc_port + i, msc[i].sccp_pars, msc[i].sccp_addr_own, id)); |
| 90 | } |
| 91 | |
| 92 | } |
| 93 | |
| 94 | testcase TC_recv_dump() runs on test_CT { |
| 95 | var integer i; |
| 96 | timer T := 30.0; |
| 97 | |
| 98 | f_init(); |
| 99 | |
| 100 | alt { |
| 101 | [] msc[0].MSC.done { } |
| 102 | [] T.timeout { setverdict(fail); } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | control { |
| 107 | execute( TC_recv_dump() ); |
| 108 | } |
| 109 | |
| 110 | } |