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; |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 16 | import from BTS_Simulation all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 17 | |
| 18 | const integer NUM_MSC := 1; |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 19 | const integer NUM_BTS := 1; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 20 | |
| 21 | type record MscState { |
| 22 | MSC_CT MSC, |
| 23 | MSC_SCCP_MTP3_parameters sccp_pars, |
| 24 | SCCP_PAR_Address sccp_addr_own |
| 25 | } |
| 26 | |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 27 | type record BtsState { |
| 28 | BTS_CT BTS |
| 29 | } |
| 30 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 31 | type component test_CT { |
| 32 | var MscState msc[NUM_MSC]; |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 33 | var BtsState bts[NUM_BTS]; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 34 | |
| 35 | var boolean g_initialized := false; |
| 36 | var octetstring g_sio := '83'O; |
| 37 | } |
| 38 | |
| 39 | modulepar { |
| 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 Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 50 | |
| 51 | charstring mp_bsc_ip := "127.0.0.1"; |
| 52 | integer mp_bsc_rsl_port := 3003; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /* construct a SCCP_PAR_Address with just PC + SSN and no GT */ |
| 56 | template (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 | |
| 69 | template 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 | |
| 75 | template 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 | |
| 85 | function f_init_MscState(inout MscState msc_st, integer opc, integer dpc, integer local_ssn, integer remote_ssn) |
| 86 | runs 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 | |
| 91 | function 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 Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 102 | 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 Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | testcase 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 | |
| 122 | control { |
| 123 | execute( TC_recv_dump() ); |
| 124 | } |
| 125 | |
| 126 | } |