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 | |
| 45 | |
| 46 | /* copy+pasted from SCCP_Emulation.ttcn, where for some reason it is marked as "runs on SCCP_CT" |
| 47 | * without depending on anything of that component */ |
| 48 | function ConvertASPAddressToEncodedAddress_itu( in SCCP_PAR_Address pl_ASPAddress) |
| 49 | return SCCP_param_CPartyAddressEnc |
| 50 | { |
| 51 | |
| 52 | var SCCP_param_CPartyAddress_itu vl_PDUAddress; //structured fit to encoding |
| 53 | var SCCP_param_CPartyAddressEnc vl_PDUAddressEncoded; |
| 54 | |
| 55 | vl_PDUAddress.addressIndicator.pointCodeIndic:= |
| 56 | pl_ASPAddress.addressIndicator.pointCodeIndic; |
| 57 | |
| 58 | vl_PDUAddress.addressIndicator.ssnIndicator:= |
| 59 | pl_ASPAddress.addressIndicator.ssnIndicator; |
| 60 | |
| 61 | vl_PDUAddress.addressIndicator.globalTitleIndic:= |
| 62 | pl_ASPAddress.addressIndicator.globalTitleIndic; |
| 63 | |
| 64 | vl_PDUAddress.addressIndicator.routingIndicator:= |
| 65 | pl_ASPAddress.addressIndicator.routingIndicator; |
| 66 | |
| 67 | vl_PDUAddress.addressIndicator.reserved:='0'B; |
| 68 | // if (ischosen(pl_ASPAddress.signPointCode) ) not used because it is mandatory field (???) |
| 69 | |
| 70 | //----signPointCode handling |
| 71 | if ( ispresent( pl_ASPAddress.signPointCode )) { |
| 72 | vl_PDUAddress.signPointCode := |
| 73 | '00'B&pl_ASPAddress.signPointCode; |
| 74 | } else { |
| 75 | vl_PDUAddress.signPointCode := omit; |
| 76 | }; |
| 77 | |
| 78 | //----subsystemNumber handling |
| 79 | if ( ispresent( pl_ASPAddress.subsystemNumber ) ){ |
| 80 | vl_PDUAddress.subsystemNumber := pl_ASPAddress.subsystemNumber; |
| 81 | } else { |
| 82 | vl_PDUAddress.subsystemNumber :=omit; |
| 83 | }; |
| 84 | |
| 85 | // --- globalTitle handling-- |
| 86 | if ( ispresent(pl_ASPAddress.globalTitle)) |
| 87 | {//startif1 |
| 88 | |
| 89 | var SCCP_ASPfield_GlobalTitle tmpGT ; |
| 90 | tmpGT := pl_ASPAddress.globalTitle; |
| 91 | |
| 92 | if (ischosen(tmpGT.gti0001)) |
| 93 | { |
| 94 | vl_PDUAddress.globalTitle.gti0001.natureOfAddress:=tmpGT.gti0001.natureOfAddress; |
| 95 | vl_PDUAddress.globalTitle.gti0001.oddeven:=tmpGT.gti0001.oddeven; |
| 96 | vl_PDUAddress.globalTitle.gti0001.globalTitleAddress:=tmpGT.gti0001.globalTitleAddress; |
| 97 | } |
| 98 | else if (ischosen(tmpGT.gti0010)) |
| 99 | { |
| 100 | vl_PDUAddress.globalTitle.gti0010.translationType:=tmpGT.gti0010.translationType; |
| 101 | vl_PDUAddress.globalTitle.gti0010.globalTitleAddress:=tmpGT.gti0010.globalTitleAddress; |
| 102 | } |
| 103 | else if (ischosen(tmpGT.gti0011)) |
| 104 | { |
| 105 | vl_PDUAddress.globalTitle.gti0011.translationType:=tmpGT.gti0011.translationType; |
| 106 | vl_PDUAddress.globalTitle.gti0011.encodingScheme:=tmpGT.gti0011.encodingScheme; |
| 107 | vl_PDUAddress.globalTitle.gti0011.numberingPlan:=tmpGT.gti0011.numberingPlan; |
| 108 | vl_PDUAddress.globalTitle.gti0011.globalTitleAddress:=tmpGT.gti0011.globalTitleAddress; |
| 109 | } |
| 110 | else if (ischosen(tmpGT.gti0100)) |
| 111 | { |
| 112 | vl_PDUAddress.globalTitle.gti0100.translationType:=tmpGT.gti0100.translationType; |
| 113 | vl_PDUAddress.globalTitle.gti0100.encodingScheme:=tmpGT.gti0100.encodingScheme; |
| 114 | vl_PDUAddress.globalTitle.gti0100.numberingPlan:=tmpGT.gti0100.numberingPlan; |
| 115 | vl_PDUAddress.globalTitle.gti0100.natureOfAddress:=tmpGT.gti0100.natureOfAddress; |
| 116 | vl_PDUAddress.globalTitle.gti0100.reserved:='0'B; |
| 117 | vl_PDUAddress.globalTitle.gti0100.globalTitleAddress:=tmpGT.gti0100.globalTitleAddress; |
| 118 | } |
| 119 | } |
| 120 | else |
| 121 | { |
| 122 | vl_PDUAddress.globalTitle := omit; |
| 123 | }; |
| 124 | |
| 125 | vl_PDUAddressEncoded.addr:= enc_PDU_SCCP_Address_itu( vl_PDUAddress); |
| 126 | vl_PDUAddressEncoded.paramLength:= lengthof(vl_PDUAddressEncoded.addr); |
| 127 | |
| 128 | return vl_PDUAddressEncoded; |
| 129 | |
| 130 | } //ConvertASPAddressToEncodedAddress_itu |
| 131 | |
| 132 | template (value) PDU_SCCP ts_SCCP_UDT(SCCP_PAR_Address called, SCCP_PAR_Address calling, |
| 133 | template (value) octetstring data, |
| 134 | template (value) BIT4 msg_hdl := '0000'B) := { |
| 135 | unitdata := { |
| 136 | messageType := udt, |
| 137 | protClass := {'0000'B, msg_hdl}, |
| 138 | pointer1 := 0, |
| 139 | pointer2 := 0, |
| 140 | pointer3 := 0, |
| 141 | calledPAddress := ConvertASPAddressToEncodedAddress_itu(called), |
| 142 | callingPAddress := ConvertASPAddressToEncodedAddress_itu(calling), |
| 143 | data := { |
| 144 | paramLength := 0, |
| 145 | data := data |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | /* Test routing of SCCP between an M3UA and an IPA ASP */ |
| 151 | testcase TC_m3ua_to_ipa() runs on IPA_M3UA_CT { |
| 152 | var OCT4 rctx_sender := int2oct(1023, 4); |
| 153 | var OCT4 pc_sender := int2oct(23, 4); |
| 154 | var OCT4 pc_receiver := int2oct(5, 4); |
| 155 | |
| 156 | f_init_m3ua(); |
| 157 | f_init_ipa(); |
| 158 | |
| 159 | f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx |
| 160 | |
| 161 | /* send a well-formed, encoded SCCP message via M3UA */ |
| 162 | var octetstring data := f_rnd_octstring(f_rnd_int(100)); |
| 163 | var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H)); |
| 164 | var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H)); |
| 165 | var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data)); |
| 166 | var octetstring sccp_enc := enc_PDU_SCCP(sccp); |
| 167 | var template (value) M3UA_Protocol_Data tx_pd; |
| 168 | tx_pd := ts_M3UA_protocol_data(pc_sender, pc_receiver, c_M3UA_SI_SCCP, '00'O, '00'O, '00'O, sccp_enc); |
| 169 | f_M3UA_send(0, ts_M3UA_DATA(rctx_sender, tx_pd), 1); |
| 170 | |
| 171 | /* expect to receive it via IPA */ |
| 172 | f_IPA_exp(0, sccp_enc); |
Pau Espin Pedrol | 05726dd | 2019-11-06 15:55:57 +0100 | [diff] [blame] | 173 | |
| 174 | f_clear_m3ua(); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | /* test routing an SCCP message from IPA ASP to M3UA ASP */ |
| 178 | testcase TC_ipa_to_m3ua() runs on IPA_M3UA_CT { |
| 179 | var OCT4 pc_sender := int2oct(5, 4); |
| 180 | var OCT4 rctx_receiver := int2oct(1023, 4); |
| 181 | var OCT4 pc_receiver := int2oct(23, 4); |
| 182 | |
| 183 | f_init_common(); |
| 184 | f_vty_config2(VTY, {"cs7 instance 0", "as mahlzeit ipa"}, |
| 185 | "point-code override patch-sccp disabled"); |
| 186 | |
| 187 | f_init_m3ua(); |
| 188 | f_init_ipa(); |
| 189 | |
| 190 | f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx |
| 191 | |
| 192 | /* send a well-formed, encoded SCCP message via IPA */ |
| 193 | var octetstring data := f_rnd_octstring(f_rnd_int(100)); |
| 194 | var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H)); |
| 195 | var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H)); |
| 196 | var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data)); |
| 197 | var octetstring sccp_enc := enc_PDU_SCCP(sccp); |
| 198 | f_IPA_send(0, sccp_enc); |
| 199 | |
| 200 | /* expect to receive it via M3UA */ |
| 201 | var template (present) M3UA_Protocol_Data rx_pd; |
| 202 | rx_pd := tr_M3UA_protocol_data(pc_sender, pc_receiver, c_M3UA_SI_SCCP, '00'O, '00'O, '00'O, sccp_enc); |
| 203 | f_M3UA_exp(0, tr_M3UA_DATA(rctx_receiver, rx_pd)); |
Pau Espin Pedrol | 05726dd | 2019-11-06 15:55:57 +0100 | [diff] [blame] | 204 | |
| 205 | f_clear_m3ua(); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | /* test routing an SCCP message from IPA ASP to M3UA ASP while patching PC into SCCP addresses */ |
| 209 | testcase TC_ipa_to_m3ua_patch_sccp() runs on IPA_M3UA_CT { |
| 210 | var OCT4 pc_sender := int2oct(5, 4); |
| 211 | var OCT4 rctx_receiver := int2oct(1023, 4); |
| 212 | var OCT4 pc_receiver := int2oct(23, 4); |
| 213 | |
| 214 | f_init_common(); |
| 215 | f_vty_config2(VTY, {"cs7 instance 0", "as mahlzeit ipa"}, |
| 216 | "point-code override patch-sccp both"); |
| 217 | |
| 218 | f_init_m3ua(); |
| 219 | f_init_ipa(); |
| 220 | |
| 221 | f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx |
| 222 | |
| 223 | /* send a well-formed, encoded SCCP message via IPA */ |
| 224 | var octetstring data := f_rnd_octstring(f_rnd_int(100)); |
| 225 | var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H)); |
| 226 | var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H)); |
| 227 | var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data)); |
| 228 | f_IPA_send(0, enc_PDU_SCCP(sccp)); |
| 229 | |
| 230 | /* patch point codes into addresses */ |
| 231 | called := valueof(ts_SccpAddr_PC_GT(oct2int(pc_receiver), '83'O, "mtp3_itu", '1234'H)); |
| 232 | calling := valueof(ts_SccpAddr_PC_GT(oct2int(pc_sender), '83'O, "mtp3_itu", '5678'H)); |
| 233 | var PDU_SCCP sccp_exp := valueof(ts_SCCP_UDT(called, calling, data)); |
| 234 | |
| 235 | /* expect to receive it via M3UA */ |
| 236 | var template (present) M3UA_Protocol_Data rx_pd; |
| 237 | rx_pd := tr_M3UA_protocol_data(pc_sender, pc_receiver, c_M3UA_SI_SCCP, '00'O, '00'O, '00'O, |
| 238 | enc_PDU_SCCP(sccp_exp)); |
| 239 | f_M3UA_exp(0, tr_M3UA_DATA(rctx_receiver, rx_pd)); |
Pau Espin Pedrol | 05726dd | 2019-11-06 15:55:57 +0100 | [diff] [blame] | 240 | |
| 241 | f_clear_m3ua(); |
Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | |
| 245 | |
| 246 | control { |
| 247 | /* M3UA <-> IPA Tests */ |
| 248 | execute( TC_m3ua_to_ipa() ); |
| 249 | execute( TC_ipa_to_m3ua() ); |
| 250 | execute( TC_ipa_to_m3ua_patch_sccp() ); |
| 251 | } |
| 252 | |
| 253 | |
| 254 | |
| 255 | } |