blob: 4e87fa68238537df9f0e36822f58c64ea1f1e4c1 [file] [log] [blame]
Harald Welte00566f52017-11-21 16:43:49 +01001module IPA_Test {
2
Harald Weltec76f29f2017-11-22 12:46:46 +01003import from IPL4asp_Types all;
Harald Welte00566f52017-11-21 16:43:49 +01004
Harald Weltec76f29f2017-11-22 12:46:46 +01005import from IPA_Emulation all;
Harald Welted86cdc62017-11-22 00:45:07 +01006
Harald Weltec76f29f2017-11-22 12:46:46 +01007import from SCCP_Types all;
8import from SCCPasp_Types all;
9import from SCCP_Emulation all;
Harald Welted86cdc62017-11-22 00:45:07 +010010
Harald Weltec76f29f2017-11-22 12:46:46 +010011import from MobileL3_Types all;
12import from MobileL3_CommonIE_Types all;
13import from L3_Templates all;
Harald Welted86cdc62017-11-22 00:45:07 +010014
Harald Weltec76f29f2017-11-22 12:46:46 +010015import from BSSAP_Types all;
16import from BSSMAP_Templates all;
Harald Welte00566f52017-11-21 16:43:49 +010017
Harald Weltec76f29f2017-11-22 12:46:46 +010018type component test_CT {
19 /* component references */
20 var IPA_Emulation_CT vc_IPA;
21 var SCCP_CT vc_SCCP;
22 /* test port to SCCP emulation */
23 port SCCPasp_PT SCCP;
Harald Welte00566f52017-11-21 16:43:49 +010024
Harald Weltec76f29f2017-11-22 12:46:46 +010025 var boolean g_initialized := false;
26 var octetstring g_sio;
27 var MSC_SCCP_MTP3_parameters g_sccp_pars;
28 var SCCP_PAR_Address g_sccp_addr_own, g_sccp_addr_peer;
Harald Welted86cdc62017-11-22 00:45:07 +010029
Harald Weltec76f29f2017-11-22 12:46:46 +010030 var ConnectionId g_ipa_conn_id := -1;
31}
Harald Welted86cdc62017-11-22 00:45:07 +010032
Harald Weltec76f29f2017-11-22 12:46:46 +010033modulepar {
34 PortNumber mp_local_port := 0;
35 charstring mp_local_ip := "127.0.0.1";
36 PortNumber mp_remote_port := 3002;
37 charstring mp_remote_ip := "127.0.0.1";
Harald Welted86cdc62017-11-22 00:45:07 +010038
Harald Weltec76f29f2017-11-22 12:46:46 +010039 charstring mp_sccp_service_type := "mtp3_itu";
40
41 integer mp_own_pc := 196;
42 integer mp_own_ssn := 254;
43
44 integer mp_peer_pc := 185; /* 0.23.1 */
45 integer mp_peer_ssn := 254;
46}
Harald Welte00566f52017-11-21 16:43:49 +010047
Harald Welted86cdc62017-11-22 00:45:07 +010048/* construct a SCCP_PAR_Address with just PC + SSN and no GT */
49template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn) := {
50 addressIndicator := {
51 pointCodeIndic := '1'B,
52 ssnIndicator := '1'B,
53 globalTitleIndic := '0000'B,
54 routingIndicator := '1'B
55 },
56 signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, '83'O),
57 //signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, g_sio),
58 subsystemNumber := ssn,
59 globalTitle := omit
60}
61
62
Harald Weltec76f29f2017-11-22 12:46:46 +010063function f_gen_cl3() return PDU_BSSAP {
64 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV('901770123456789'H));
65 var PDU_ML3_MS_NW l3 := valueof(ts_CM_SERV_REQ('0001'B, mi));
66 var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellID_LAC_CI(23, 42));
67 var PDU_BSSAP bssap := valueof(ts_BSSMAP_ComplL3(cell_id, enc_PDU_ML3_MS_NW(l3)));
68 return bssap;
69}
70
71function f_send_bssap_cc(PDU_BSSAP bssap) runs on test_CT {
72 var ASP_SCCP_N_CONNECT_req prim;
73 prim := valueof(t_ASP_N_CONNECT_req(g_sccp_addr_peer, g_sccp_addr_own, omit, omit,
74 enc_PDU_BSSAP(bssap), 23, omit));
75 SCCP.send(prim);
76}
77
Harald Welted86cdc62017-11-22 00:45:07 +010078function init_pars() runs on test_CT {
79 g_sio := '83'O;
80 g_sccp_pars := {
81 sio := {
82 ni := substr(oct2bit(g_sio),0,2),
83 prio := substr(oct2bit(g_sio),2,2),
84 si := substr(oct2bit(g_sio),4,4)
85 },
86 opc := mp_own_pc,
87 dpc := mp_peer_pc,
88 sls := 0,
89 sccp_serviceType := mp_sccp_service_type,
90 ssn := mp_own_ssn
91 };
92 g_sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(mp_own_pc, mp_own_ssn));
93 g_sccp_addr_peer := valueof(ts_SccpAddr_PC_SSN(mp_peer_pc, mp_peer_ssn));
94}
95
Harald Weltec76f29f2017-11-22 12:46:46 +010096private function f_init() runs on test_CT {
97 var Result res;
Harald Welte00566f52017-11-21 16:43:49 +010098
Harald Weltec76f29f2017-11-22 12:46:46 +010099 if (g_initialized == true) {
100 return;
Harald Welte00566f52017-11-21 16:43:49 +0100101 }
Harald Weltec76f29f2017-11-22 12:46:46 +0100102 g_initialized := true;
Harald Welte00566f52017-11-21 16:43:49 +0100103
Harald Weltec76f29f2017-11-22 12:46:46 +0100104 init_pars();
Harald Welte00566f52017-11-21 16:43:49 +0100105
Harald Weltec76f29f2017-11-22 12:46:46 +0100106 /* create components */
107 vc_IPA := IPA_Emulation_CT.create;
108 vc_SCCP := SCCP_CT.create;
109
110 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
111
112 /* connect MTP3 service provider (IPA) to lower side of SCCP */
113 connect(vc_IPA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT);
114
115 /* connect us to upper side of SCCP */
116 connect(self:SCCP, vc_SCCP:SCCP_SP_PORT);
117
118 vc_IPA.start(IPA_Emulation.ScanEvents());
119 vc_SCCP.start(SCCPStart(g_sccp_pars));
120
121 //IPA_Emulation.f_connect(mp_remote_ip, mp_remote_port, mp_local_ip, mp_local_port);
122}
123
124testcase TC_recv_dump() runs on test_CT {
125 f_init();
126
127 var PDU_BSSAP bssap := f_gen_cl3();
128 f_send_bssap_cc(bssap);
129
130 while (true) {
131 SCCP.receive;
Harald Welte00566f52017-11-21 16:43:49 +0100132 }
Harald Weltec76f29f2017-11-22 12:46:46 +0100133}
Harald Welte00566f52017-11-21 16:43:49 +0100134
Harald Weltec76f29f2017-11-22 12:46:46 +0100135control {
136 execute( TC_recv_dump() );
137}
138
Harald Welte00566f52017-11-21 16:43:49 +0100139}