Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 1 | module STP_Tests { |
| 2 | |
| 3 | /* Osmocom STP test suite in in TTCN-3 |
| 4 | * (C) 2019 Harald Welte <laforge@gnumonks.org> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Released under the terms of GNU General Public License, Version 2 or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 11 | */ |
| 12 | |
| 13 | import from General_Types all; |
| 14 | import from Osmocom_Types all; |
| 15 | import from IPL4asp_Types all; |
| 16 | |
| 17 | import from Osmocom_VTY_Functions all; |
| 18 | |
| 19 | import from M3UA_Types all; |
| 20 | import from M3UA_Templates all; |
| 21 | import from M3UA_CodecPort all; |
| 22 | import from M3UA_CodecPort_CtrlFunct all; |
| 23 | |
| 24 | import from M3UA_Emulation all; |
| 25 | import from MTP3asp_Types all; |
| 26 | import from MTP3asp_PortType all; |
| 27 | |
| 28 | import from SCCP_Types all; |
| 29 | import from SCCP_Templates all; |
| 30 | import from SCCPasp_Types all; |
| 31 | import from SCCP_Emulation all; |
| 32 | |
| 33 | import from IPA_Emulation all; |
| 34 | |
| 35 | import from STP_Tests_Common all; |
| 36 | import from STP_Tests_IPA all; |
| 37 | import from STP_Tests_M3UA all; |
| 38 | |
| 39 | |
| 40 | type component IPA_M3UA_CT extends RAW_M3UA_CT, IPA_CT { |
| 41 | }; |
| 42 | |
| 43 | const OCT1 c_M3UA_SI_SCCP := '03'O; |
| 44 | |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 45 | template (value) PDU_SCCP ts_SCCP_UDT(SCCP_PAR_Address called, SCCP_PAR_Address calling, |
| 46 | template (value) octetstring data, |
| 47 | template (value) BIT4 msg_hdl := '0000'B) := { |
| 48 | unitdata := { |
| 49 | messageType := udt, |
| 50 | protClass := {'0000'B, msg_hdl}, |
| 51 | pointer1 := 0, |
| 52 | pointer2 := 0, |
| 53 | pointer3 := 0, |
| 54 | calledPAddress := ConvertASPAddressToEncodedAddress_itu(called), |
| 55 | callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling), |
| 56 | data := { |
| 57 | paramLength := 0, |
| 58 | data := data |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /* Test routing of SCCP between an M3UA and an IPA ASP */ |
| 64 | testcase TC_m3ua_to_ipa() runs on IPA_M3UA_CT { |
| 65 | var OCT4 rctx_sender := int2oct(1023, 4); |
| 66 | var OCT4 pc_sender := int2oct(23, 4); |
| 67 | var OCT4 pc_receiver := int2oct(5, 4); |
| 68 | |
| 69 | f_init_m3ua(); |
| 70 | f_init_ipa(); |
| 71 | |
Pau Espin Pedrol | 01ec0bf | 2019-11-07 14:50:07 +0100 | [diff] [blame] | 72 | f_connect_ipa(3); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 73 | f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx |
| 74 | |
| 75 | /* send a well-formed, encoded SCCP message via M3UA */ |
Harald Welte | 67881ae | 2022-04-12 22:52:47 +0200 | [diff] [blame] | 76 | var octetstring data := f_rnd_octstring_rnd_len(100); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 77 | var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H)); |
| 78 | var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H)); |
| 79 | var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data)); |
| 80 | var octetstring sccp_enc := enc_PDU_SCCP(sccp); |
| 81 | var template (value) M3UA_Protocol_Data tx_pd; |
| 82 | tx_pd := ts_M3UA_protocol_data(pc_sender, pc_receiver, c_M3UA_SI_SCCP, '00'O, '00'O, '00'O, sccp_enc); |
| 83 | f_M3UA_send(0, ts_M3UA_DATA(rctx_sender, tx_pd), 1); |
| 84 | |
| 85 | /* expect to receive it via IPA */ |
Pau Espin Pedrol | 01ec0bf | 2019-11-07 14:50:07 +0100 | [diff] [blame] | 86 | f_IPA_exp(3, sccp_enc); |
Pau Espin Pedrol | 05726dd | 2019-11-06 15:55:57 +0100 | [diff] [blame] | 87 | |
| 88 | f_clear_m3ua(); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | /* test routing an SCCP message from IPA ASP to M3UA ASP */ |
| 92 | testcase TC_ipa_to_m3ua() runs on IPA_M3UA_CT { |
| 93 | var OCT4 pc_sender := int2oct(5, 4); |
| 94 | var OCT4 rctx_receiver := int2oct(1023, 4); |
| 95 | var OCT4 pc_receiver := int2oct(23, 4); |
| 96 | |
| 97 | f_init_common(); |
Pau Espin Pedrol | 01ec0bf | 2019-11-07 14:50:07 +0100 | [diff] [blame] | 98 | f_vty_config2(VTY, {"cs7 instance 0", "as ipa-as-dynamic-asp ipa"}, |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 99 | "point-code override patch-sccp disabled"); |
| 100 | |
| 101 | f_init_m3ua(); |
| 102 | f_init_ipa(); |
| 103 | |
Pau Espin Pedrol | 01ec0bf | 2019-11-07 14:50:07 +0100 | [diff] [blame] | 104 | f_connect_ipa(3); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 105 | f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx |
| 106 | |
| 107 | /* send a well-formed, encoded SCCP message via IPA */ |
Harald Welte | 67881ae | 2022-04-12 22:52:47 +0200 | [diff] [blame] | 108 | var octetstring data := f_rnd_octstring_rnd_len(100); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 109 | var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H)); |
| 110 | var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H)); |
| 111 | var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data)); |
| 112 | var octetstring sccp_enc := enc_PDU_SCCP(sccp); |
Pau Espin Pedrol | 01ec0bf | 2019-11-07 14:50:07 +0100 | [diff] [blame] | 113 | f_IPA_send(3, sccp_enc); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 114 | |
| 115 | /* expect to receive it via M3UA */ |
| 116 | var template (present) M3UA_Protocol_Data rx_pd; |
| 117 | rx_pd := tr_M3UA_protocol_data(pc_sender, pc_receiver, c_M3UA_SI_SCCP, '00'O, '00'O, '00'O, sccp_enc); |
| 118 | f_M3UA_exp(0, tr_M3UA_DATA(rctx_receiver, rx_pd)); |
Pau Espin Pedrol | 05726dd | 2019-11-06 15:55:57 +0100 | [diff] [blame] | 119 | |
| 120 | f_clear_m3ua(); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 121 | } |
| 122 | |
Harald Welte | 95e3d99 | 2021-04-25 14:27:44 +0200 | [diff] [blame] | 123 | /* test routing an SCCP message from IPA ASP to M3UA ASP using national network indicator */ |
| 124 | testcase TC_ipa_to_m3ua_ni() runs on IPA_M3UA_CT { |
| 125 | var OCT4 pc_sender := int2oct(5, 4); |
| 126 | var OCT4 rctx_receiver := int2oct(1023, 4); |
| 127 | var OCT4 pc_receiver := int2oct(23, 4); |
| 128 | |
| 129 | f_init_common(); |
| 130 | f_vty_config2(VTY, {"cs7 instance 0", "as ipa-as-dynamic-asp ipa"}, |
| 131 | "point-code override patch-sccp disabled"); |
| 132 | |
| 133 | f_init_m3ua(); |
| 134 | f_init_ipa(); |
| 135 | |
| 136 | f_connect_ipa(3); |
| 137 | f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx |
| 138 | |
| 139 | /* send a well-formed, encoded SCCP message via IPA */ |
Harald Welte | 67881ae | 2022-04-12 22:52:47 +0200 | [diff] [blame] | 140 | var octetstring data := f_rnd_octstring_rnd_len(100); |
Harald Welte | 95e3d99 | 2021-04-25 14:27:44 +0200 | [diff] [blame] | 141 | var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H)); |
| 142 | var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H)); |
| 143 | var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data)); |
| 144 | var octetstring sccp_enc := enc_PDU_SCCP(sccp); |
| 145 | f_vty_config2(VTY, {"cs7 instance 0"}, "network-indicator national"); |
| 146 | f_IPA_send(3, sccp_enc); |
| 147 | f_vty_config2(VTY, {"cs7 instance 0"}, "network-indicator international"); |
| 148 | |
| 149 | /* expect to receive it via M3UA */ |
| 150 | var template (present) M3UA_Protocol_Data rx_pd; |
| 151 | rx_pd := tr_M3UA_protocol_data(pc_sender, pc_receiver, c_M3UA_SI_SCCP, c_M3UA_NI_NATIONAL, |
| 152 | '00'O, '00'O, sccp_enc); |
| 153 | f_M3UA_exp(0, tr_M3UA_DATA(rctx_receiver, rx_pd)); |
| 154 | |
| 155 | f_clear_m3ua(); |
| 156 | } |
| 157 | |
| 158 | |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 159 | /* test routing an SCCP message from IPA ASP to M3UA ASP while patching PC into SCCP addresses */ |
| 160 | testcase TC_ipa_to_m3ua_patch_sccp() runs on IPA_M3UA_CT { |
| 161 | var OCT4 pc_sender := int2oct(5, 4); |
| 162 | var OCT4 rctx_receiver := int2oct(1023, 4); |
| 163 | var OCT4 pc_receiver := int2oct(23, 4); |
| 164 | |
| 165 | f_init_common(); |
Pau Espin Pedrol | 01ec0bf | 2019-11-07 14:50:07 +0100 | [diff] [blame] | 166 | f_vty_config2(VTY, {"cs7 instance 0", "as ipa-as-dynamic-asp ipa"}, |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 167 | "point-code override patch-sccp both"); |
| 168 | |
| 169 | f_init_m3ua(); |
| 170 | f_init_ipa(); |
| 171 | |
Pau Espin Pedrol | 01ec0bf | 2019-11-07 14:50:07 +0100 | [diff] [blame] | 172 | f_connect_ipa(3); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 173 | f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx |
| 174 | |
| 175 | /* send a well-formed, encoded SCCP message via IPA */ |
Harald Welte | 67881ae | 2022-04-12 22:52:47 +0200 | [diff] [blame] | 176 | var octetstring data := f_rnd_octstring_rnd_len(100); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 177 | var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H)); |
| 178 | var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H)); |
| 179 | var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data)); |
Pau Espin Pedrol | 01ec0bf | 2019-11-07 14:50:07 +0100 | [diff] [blame] | 180 | f_IPA_send(3, enc_PDU_SCCP(sccp)); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 181 | |
| 182 | /* patch point codes into addresses */ |
| 183 | called := valueof(ts_SccpAddr_PC_GT(oct2int(pc_receiver), '83'O, "mtp3_itu", '1234'H)); |
| 184 | calling := valueof(ts_SccpAddr_PC_GT(oct2int(pc_sender), '83'O, "mtp3_itu", '5678'H)); |
| 185 | var PDU_SCCP sccp_exp := valueof(ts_SCCP_UDT(called, calling, data)); |
| 186 | |
| 187 | /* expect to receive it via M3UA */ |
| 188 | var template (present) M3UA_Protocol_Data rx_pd; |
| 189 | rx_pd := tr_M3UA_protocol_data(pc_sender, pc_receiver, c_M3UA_SI_SCCP, '00'O, '00'O, '00'O, |
| 190 | enc_PDU_SCCP(sccp_exp)); |
| 191 | f_M3UA_exp(0, tr_M3UA_DATA(rctx_receiver, rx_pd)); |
Pau Espin Pedrol | 05726dd | 2019-11-06 15:55:57 +0100 | [diff] [blame] | 192 | |
| 193 | f_clear_m3ua(); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | |
| 197 | |
| 198 | control { |
| 199 | /* M3UA <-> IPA Tests */ |
| 200 | execute( TC_m3ua_to_ipa() ); |
| 201 | execute( TC_ipa_to_m3ua() ); |
Harald Welte | 95e3d99 | 2021-04-25 14:27:44 +0200 | [diff] [blame] | 202 | execute( TC_ipa_to_m3ua_ni() ); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 203 | execute( TC_ipa_to_m3ua_patch_sccp() ); |
| 204 | } |
| 205 | |
| 206 | |
| 207 | |
| 208 | } |