Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 1 | module IPA_Test { |
| 2 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 3 | import from Osmocom_Types all; |
| 4 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 5 | import from IPL4asp_Types all; |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 6 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 7 | import from IPA_Emulation all; |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 8 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 9 | import from MTP3asp_Types all; |
| 10 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 11 | import from SCCP_Types all; |
| 12 | import from SCCPasp_Types all; |
| 13 | import from SCCP_Emulation all; |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 14 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 15 | import from MSC_Simulation all; |
| 16 | import from BSC_MS_Simulation all; |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 17 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 18 | const integer NUM_MSC := 1; |
| 19 | const integer NUM_BSC := 1; |
| 20 | |
| 21 | type 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 | |
| 28 | type record MscState { |
| 29 | MSC_CT MSC, |
| 30 | MSC_SCCP_MTP3_parameters sccp_pars, |
| 31 | SCCP_PAR_Address sccp_addr_own |
| 32 | } |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 33 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 34 | type component test_CT { |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 35 | var MscState msc[NUM_MSC]; |
| 36 | var BscState bsc[NUM_BSC]; |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 37 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 38 | var boolean g_initialized := false; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 39 | var octetstring g_sio := '83'O; |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 40 | } |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 41 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 42 | modulepar { |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 43 | 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 Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 48 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 49 | charstring mp_sccp_service_type := "mtp3_itu"; |
| 50 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 51 | integer mp_bsc_pc := 196; |
| 52 | integer mp_bsc_ssn := 254; |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 53 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 54 | integer mp_msc_pc := 185; /* 0.23.1 */ |
| 55 | integer mp_msc_ssn := 254; |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 56 | } |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 57 | |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 58 | /* construct a SCCP_PAR_Address with just PC + SSN and no GT */ |
| 59 | template (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 Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 72 | template 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 Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 76 | } |
| 77 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 78 | template 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 | |
| 88 | function f_init_BscState(inout BscState bsc_st, integer opc, integer dpc, integer local_ssn, integer remote_ssn) |
| 89 | runs 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 Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 93 | } |
| 94 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 95 | function f_init_MscState(inout MscState msc_st, integer opc, integer dpc, integer local_ssn, integer remote_ssn) |
| 96 | runs 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 Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 99 | } |
| 100 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 101 | function f_init() runs on test_CT { |
| 102 | var integer i; |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 103 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 104 | 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 Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 108 | } |
| 109 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 110 | 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 Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 117 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | testcase TC_recv_dump() runs on test_CT { |
| 121 | f_init(); |
| 122 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 123 | //var PDU_BSSAP bssap := f_gen_cl3(); |
| 124 | //f_send_bssap_cc(bssap); |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 125 | |
| 126 | while (true) { |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 127 | //SCCP.receive; |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 128 | } |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 129 | } |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 130 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 131 | control { |
| 132 | execute( TC_recv_dump() ); |
| 133 | } |
| 134 | |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 135 | } |