Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 1 | /* (C) 2019 by Harald Welte <laforge@gnumonks.org> |
| 2 | * All Rights Reserved |
| 3 | * |
| 4 | * The idea is that these tests are executed against sccp_demo_user from |
| 5 | * libosmo-sccp.git in server mode. |
| 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 | module SCCP_Tests_RAW { |
| 14 | |
| 15 | import from General_Types all; |
| 16 | import from Osmocom_Types all; |
| 17 | |
| 18 | import from M3UA_Emulation all; |
| 19 | |
| 20 | import from SCCP_Types all; |
| 21 | import from SCCPasp_Types all; |
| 22 | import from SCCP_Templates all; |
| 23 | import from SCCP_Emulation all; |
| 24 | import from SCCP_CodecPort all; |
| 25 | |
| 26 | import from TELNETasp_PortType all; |
| 27 | import from Osmocom_VTY_Functions all; |
| 28 | |
| 29 | import from SCCP_Tests all; |
| 30 | |
| 31 | type component SCCP_Test_RAW_CT { |
| 32 | /* VTY to sccp_demo_user (not used yet) */ |
| 33 | port TELNETasp_PT SCCP_DEMO_USER_VTY; |
| 34 | |
| 35 | /* SCCP raw port runs on top of M3UA Emulation. |
| 36 | * "System Under Test" is libosmo-sccp's sccp_demo_user example program. */ |
| 37 | var M3UA_CT vc_M3UA; |
| 38 | port SCCP_CODEC_PT MTP3; |
| 39 | |
| 40 | var MSC_SCCP_MTP3_parameters g_param; |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 41 | |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 42 | var OCT3 g_own_lref := '000001'O |
| 43 | |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 44 | /*Configure T(tias) over VTY, seconds */ |
| 45 | var integer g_demo_sccp_timer_ias := 7 * 60; |
| 46 | /*Configure T(tiar) over VTY, seconds */ |
| 47 | var integer g_demo_sccp_timer_iar := 15 * 60; |
| 48 | } |
| 49 | |
| 50 | type record of charstring Commands; |
| 51 | private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {}) |
| 52 | { |
| 53 | f_vty_enter_cfg_cs7_inst(pt, 0); |
| 54 | for (var integer i := 0; i < sizeof(cmds); i := i+1) { |
| 55 | f_vty_transceive(pt, cmds[i]); |
| 56 | } |
| 57 | f_vty_transceive(pt, "end"); |
| 58 | } |
| 59 | |
| 60 | function f_init_vty() runs on SCCP_Test_RAW_CT { |
| 61 | if (SCCP_DEMO_USER_VTY.checkstate("Mapped")) { |
| 62 | /* skip initialization if already executed once */ |
| 63 | return; |
| 64 | } |
| 65 | map(self:SCCP_DEMO_USER_VTY, system:SCCP_DEMO_USER_VTY); |
| 66 | f_vty_set_prompts(SCCP_DEMO_USER_VTY); |
| 67 | f_vty_transceive(SCCP_DEMO_USER_VTY, "enable"); |
| 68 | f_cs7_inst_0_cfg(SCCP_DEMO_USER_VTY, {"sccp-timer ias " & int2str(g_demo_sccp_timer_ias), |
| 69 | "sccp-timer iar " & int2str(g_demo_sccp_timer_iar)}); |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | private function f_init_raw(SCCP_Configuration cfg) runs on SCCP_Test_RAW_CT { |
| 73 | g_param := { |
| 74 | sio := { |
| 75 | ni := substr(oct2bit(cfg.sio),0,2), |
| 76 | prio := substr(oct2bit(cfg.sio),2,2), |
| 77 | si := substr(oct2bit(cfg.sio),4,4) |
| 78 | }, |
| 79 | opc := cfg.own_pc, |
| 80 | dpc := cfg.peer_pc, |
| 81 | sls := 0, |
| 82 | sccp_serviceType := cfg.sccp_service_type, |
| 83 | ssn := cfg.own_ssn |
| 84 | }; |
| 85 | |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 86 | f_init_vty(); |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 87 | |
| 88 | /* Create and connect test components */ |
| 89 | vc_M3UA := M3UA_CT.create; |
| 90 | connect(self:MTP3, vc_M3UA:MTP3_SP_PORT); |
| 91 | map(vc_M3UA:SCTP_PORT, system:sctp); |
| 92 | |
| 93 | vc_M3UA.start(f_M3UA_Emulation(cfg.sctp_addr)); |
| 94 | } |
| 95 | |
| 96 | private function f_cleanup() runs on SCCP_Test_RAW_CT { |
| 97 | all component.stop; |
| 98 | unmap(vc_M3UA:SCTP_PORT, system:sctp); |
| 99 | disconnect(vc_M3UA:MTP3_SP_PORT, self:MTP3); |
| 100 | self.stop |
| 101 | } |
| 102 | |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 103 | private function f_send_sccp(template PDU_SCCP sccp) runs on SCCP_Test_RAW_CT { |
| 104 | var SCCP_MTP3_TRANSFERreq tx := { |
| 105 | sio := g_param.sio, |
| 106 | opc := g_param.opc, |
| 107 | dpc := g_param.dpc, |
| 108 | sls := g_param.sls, |
| 109 | data := valueof(sccp) |
| 110 | }; |
| 111 | MTP3.send(tx); |
| 112 | } |
| 113 | |
Pau Espin Pedrol | e30d543 | 2020-01-21 13:47:32 +0100 | [diff] [blame] | 114 | private function tr_SCCP_MTP3_TRANSFERind(template PDU_SCCP sccp) |
| 115 | runs on SCCP_Test_RAW_CT return template SCCP_MTP3_TRANSFERind { |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 116 | |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 117 | var template SCCP_MTP3_TRANSFERind exp := { |
| 118 | sio := g_param.sio, |
| 119 | opc := g_param.dpc, |
| 120 | dpc := g_param.opc, |
| 121 | sls := g_param.sls, |
| 122 | data := sccp |
| 123 | }; |
Pau Espin Pedrol | e30d543 | 2020-01-21 13:47:32 +0100 | [diff] [blame] | 124 | return exp; |
| 125 | } |
| 126 | |
| 127 | private function f_exp_sccp(template PDU_SCCP sccp) |
| 128 | runs on SCCP_Test_RAW_CT return SCCP_MTP3_TRANSFERind { |
| 129 | var template SCCP_MTP3_TRANSFERind exp := tr_SCCP_MTP3_TRANSFERind(sccp); |
| 130 | var SCCP_MTP3_TRANSFERind rx; |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 131 | timer T := 10.0; |
| 132 | T.start; |
| 133 | alt { |
| 134 | [] MTP3.receive(exp) -> value rx { |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 135 | return rx; |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 136 | } |
| 137 | [] MTP3.receive { |
| 138 | setverdict(fail, "Unexpected MTP/SCCP received"); |
Pau Espin Pedrol | 94b7a68 | 2020-01-20 19:30:07 +0100 | [diff] [blame] | 139 | self.stop |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 140 | } |
| 141 | [] T.timeout { |
| 142 | setverdict(fail, "Timeout waiting for ", exp); |
Pau Espin Pedrol | 94b7a68 | 2020-01-20 19:30:07 +0100 | [diff] [blame] | 143 | self.stop |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 144 | } |
| 145 | } |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 146 | return rx; |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 147 | } |
| 148 | |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 149 | private function f_establish_conn(SCCP_PAR_Address calling, SCCP_PAR_Address called) |
| 150 | runs on SCCP_Test_RAW_CT return OCT3 { |
| 151 | var SCCP_MTP3_TRANSFERind mtp3_rx; |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 152 | |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 153 | f_send_sccp(ts_SCCP_CR(g_own_lref, calling, called)); |
| 154 | mtp3_rx := f_exp_sccp(tr_SCCP_CC(?, g_own_lref)); |
| 155 | |
| 156 | return mtp3_rx.data.connconfirm.sourceLocRef; |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | private function f_tx_udt_exp(SCCP_PAR_Address calling, SCCP_PAR_Address called, octetstring data) runs on SCCP_Test_RAW_CT { |
| 160 | |
| 161 | f_send_sccp(ts_SCCP_UDT(calling, called, data)); |
| 162 | f_exp_sccp(tr_SCCP_UDT(called, calling, data)); |
| 163 | } |
| 164 | |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 165 | /* Verify sccp_demo_user answers a CR with a CC for PC and SSN set up to echo back */ |
| 166 | testcase TC_cr_cc() runs on SCCP_Test_RAW_CT { |
| 167 | var SCCP_PAR_Address calling, called; |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 168 | |
| 169 | f_init_raw(mp_sccp_cfg[0]); |
| 170 | f_sleep(1.0); |
| 171 | |
Pau Espin Pedrol | e187091 | 2020-01-17 17:30:19 +0100 | [diff] [blame] | 172 | called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn, |
| 173 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 174 | calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn, |
| 175 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 176 | f_establish_conn(calling, called); |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 177 | setverdict(pass); |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 178 | } |
| 179 | |
Pau Espin Pedrol | 1269b1b | 2020-01-21 12:58:48 +0100 | [diff] [blame] | 180 | /* Verify sccp_demo_user inactivty timers are not armed upon dealing with |
| 181 | /* connectionless data-unit messages. Since no connection exists. */ |
Pau Espin Pedrol | f7ba234 | 2020-01-20 20:19:47 +0100 | [diff] [blame] | 182 | testcase TC_udt_without_cr_cc() runs on SCCP_Test_RAW_CT { |
| 183 | var SCCP_PAR_Address calling, called; |
Pau Espin Pedrol | 1269b1b | 2020-01-21 12:58:48 +0100 | [diff] [blame] | 184 | var SCCP_MTP3_TRANSFERind rx; |
Pau Espin Pedrol | f7ba234 | 2020-01-20 20:19:47 +0100 | [diff] [blame] | 185 | var octetstring data := f_rnd_octstring(f_rnd_int(100)); |
| 186 | |
Pau Espin Pedrol | 1269b1b | 2020-01-21 12:58:48 +0100 | [diff] [blame] | 187 | /* Keep recommended ratio of T(iar) >= T(ias)*2, but anyway no IT |
| 188 | should be received in this case. */ |
| 189 | g_demo_sccp_timer_ias := 1; |
| 190 | g_demo_sccp_timer_iar := 3; |
Pau Espin Pedrol | f7ba234 | 2020-01-20 20:19:47 +0100 | [diff] [blame] | 191 | f_init_raw(mp_sccp_cfg[0]); |
| 192 | f_sleep(1.0); |
| 193 | |
| 194 | called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn, |
| 195 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 196 | calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn, |
| 197 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 198 | |
| 199 | f_tx_udt_exp(calling, called, data); |
Pau Espin Pedrol | 1269b1b | 2020-01-21 12:58:48 +0100 | [diff] [blame] | 200 | |
| 201 | /* Make sure no SCCP message is received at all, since no connection is active. */ |
| 202 | timer T := int2float(g_demo_sccp_timer_iar + 1); |
| 203 | T.start; |
| 204 | alt { |
| 205 | [] MTP3.receive { |
| 206 | setverdict(fail, "Unexpected MTP/SCCP received"); |
| 207 | self.stop; |
| 208 | } |
| 209 | [] T.timeout {} |
| 210 | } |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 211 | setverdict(pass); |
Pau Espin Pedrol | f7ba234 | 2020-01-20 20:19:47 +0100 | [diff] [blame] | 212 | } |
| 213 | |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 214 | /* Verify T(iar) triggers and releases the channel */ |
| 215 | testcase TC_tiar_timeout() runs on SCCP_Test_RAW_CT { |
| 216 | var SCCP_PAR_Address calling, called; |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 217 | var OCT3 remote_lref; |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 218 | var octetstring data := f_rnd_octstring(f_rnd_int(100)); |
| 219 | |
| 220 | /* Set T(iar) in sccp_demo_user low enough that it will trigger before other side |
| 221 | has time to keep alive with a T(ias). Keep recommended ratio of |
| 222 | T(iar) >= T(ias)*2 */ |
| 223 | g_demo_sccp_timer_ias := 2; |
| 224 | g_demo_sccp_timer_iar := 5; |
Pau Espin Pedrol | e187091 | 2020-01-17 17:30:19 +0100 | [diff] [blame] | 225 | f_init_raw(mp_sccp_cfg[0]); |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 226 | f_sleep(1.0); |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 227 | |
| 228 | called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn, |
| 229 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 230 | calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn, |
| 231 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 232 | remote_lref := f_establish_conn(calling, called); |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 233 | f_tx_udt_exp(calling, called, data); |
| 234 | |
| 235 | log("Waiting for first IT"); |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 236 | f_exp_sccp(tr_SCCP_IT(remote_lref, g_own_lref)); |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 237 | log("Waiting for second IT"); |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 238 | f_exp_sccp(tr_SCCP_IT(remote_lref, g_own_lref)); |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 239 | |
| 240 | log("Waiting for RLSD"); |
Pau Espin Pedrol | 392eaf3 | 2020-01-21 12:21:05 +0100 | [diff] [blame] | 241 | f_exp_sccp(tr_SCCP_RLSD(remote_lref, g_own_lref, hex2int('0D'H))); /* Cause: Expiration of Rx Inactivity Timer */ |
| 242 | f_send_sccp(ts_SCCP_RLC(g_own_lref, remote_lref)); |
| 243 | setverdict(pass); |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 244 | } |
| 245 | |
Pau Espin Pedrol | e30d543 | 2020-01-21 13:47:32 +0100 | [diff] [blame] | 246 | /* Verify T(iar) triggers and releases the channel */ |
| 247 | testcase TC_it_avoids_tiar() runs on SCCP_Test_RAW_CT { |
| 248 | var SCCP_PAR_Address calling, called; |
| 249 | var OCT3 remote_lref; |
| 250 | var boolean it_received := false; |
| 251 | |
| 252 | g_demo_sccp_timer_ias := 1; |
| 253 | g_demo_sccp_timer_iar := 3; |
| 254 | f_init_raw(mp_sccp_cfg[0]); |
| 255 | f_sleep(1.0); |
| 256 | |
| 257 | called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn, |
| 258 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 259 | calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn, |
| 260 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 261 | remote_lref := f_establish_conn(calling, called); |
| 262 | |
| 263 | timer T_total := 7.0; /* Higher than g_demo_sccp_timer_iar */ |
| 264 | timer T_tias := 1.0; /* Lower than g_demo_sccp_timer_iar */ |
| 265 | T_total.start; |
| 266 | T_tias.start; |
| 267 | alt { |
| 268 | [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_IT(remote_lref, g_own_lref))) { |
| 269 | it_received := true; |
| 270 | repeat; |
| 271 | } |
| 272 | [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_RLSD(remote_lref, g_own_lref, hex2int('0D'H)))) { |
| 273 | setverdict(fail, "Unexpected SCCP RLSD received"); |
| 274 | self.stop; |
| 275 | } |
| 276 | [] MTP3.receive { |
| 277 | setverdict(fail, "Unexpected MTP/SCCP received"); |
| 278 | self.stop; |
| 279 | } |
| 280 | [] T_tias.timeout { |
| 281 | f_send_sccp(ts_SCCP_IT(g_own_lref, remote_lref)); |
| 282 | T_tias.start; |
| 283 | repeat; |
| 284 | } |
| 285 | [] T_total.timeout { |
| 286 | /* We kept the connection alive only with IT messages for a while, cool! */ |
| 287 | T_tias.stop; |
| 288 | setverdict(pass); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | if (not it_received) { |
| 293 | setverdict(fail, "Didn't receive any IT (Tias) from peer"); |
| 294 | } |
| 295 | |
| 296 | /* After we stop sending IT, we should be receiving an RLSD triggered from T(iar) */ |
| 297 | log("Waiting for RLSD"); |
| 298 | alt { |
| 299 | [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_IT(remote_lref, g_own_lref))) { |
| 300 | repeat; |
| 301 | } |
| 302 | [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_RLSD(remote_lref, g_own_lref, hex2int('0D'H)))) { |
| 303 | f_send_sccp(ts_SCCP_RLC(g_own_lref, remote_lref)); |
| 304 | setverdict(pass); |
| 305 | } |
| 306 | [] MTP3.receive { |
| 307 | setverdict(fail, "Unexpected MTP/SCCP received"); |
| 308 | self.stop; |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
Harald Welte | 4038d4c | 2021-10-26 14:37:54 +0200 | [diff] [blame] | 313 | private function f_tx_xudt_exp(SCCP_PAR_Address calling, SCCP_PAR_Address called, octetstring data) runs on SCCP_Test_RAW_CT { |
| 314 | var template PDU_SCCP exp_rx; |
| 315 | f_send_sccp(ts_SCCP_XUDT(calling, called, data)); |
| 316 | exp_rx := (tr_SCCP_UDT(called, calling, data), tr_SCCP_XUDT(called, calling, data)); |
| 317 | f_exp_sccp(exp_rx); |
| 318 | } |
| 319 | |
| 320 | /* Test if the IUT SCCP code processes an XUDT [treat it like UDT] and answers back. */ |
| 321 | testcase TC_process_rx_xudt() runs on SCCP_Test_RAW_CT { |
| 322 | var SCCP_PAR_Address calling, called; |
| 323 | var octetstring data := f_rnd_octstring(f_rnd_int(100)); |
| 324 | |
| 325 | f_init_raw(mp_sccp_cfg[0]); |
| 326 | f_sleep(1.0); |
| 327 | |
| 328 | called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn, |
| 329 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 330 | calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn, |
| 331 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 332 | |
| 333 | /* Make sure an XUDT is echoed back just like an UDT */ |
| 334 | f_tx_xudt_exp(calling, called, data); |
| 335 | setverdict(pass); |
| 336 | } |
| 337 | |
Harald Welte | 24f921b | 2021-02-10 19:37:45 +0100 | [diff] [blame] | 338 | function f_scmg_xceive(SCCP_PAR_Address calling, SCCP_PAR_Address called, |
| 339 | template (value) PDU_SCMG_message tx, |
Harald Welte | aed9f94 | 2021-05-13 21:54:58 +0200 | [diff] [blame] | 340 | template (omit) PDU_SCMG_message rx_exp, |
| 341 | boolean accept_other_called_resp := false) runs on SCCP_Test_RAW_CT |
Harald Welte | 24f921b | 2021-02-10 19:37:45 +0100 | [diff] [blame] | 342 | { |
| 343 | var boolean exp_something := true; |
| 344 | timer T := 5.0; |
| 345 | |
| 346 | if (istemplatekind(rx_exp, "omit")) { |
| 347 | exp_something := false; |
| 348 | } |
| 349 | |
| 350 | MTP3.clear; |
| 351 | f_send_sccp(ts_SCCP_UDT(calling, called, enc_PDU_SCMG_message(valueof(tx)))); |
| 352 | T.start; |
| 353 | alt { |
| 354 | [exp_something] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, calling, decmatch rx_exp))) { |
| 355 | setverdict(pass); |
| 356 | } |
Harald Welte | aed9f94 | 2021-05-13 21:54:58 +0200 | [diff] [blame] | 357 | [exp_something and accept_other_called_resp] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, ?, decmatch rx_exp))) { |
| 358 | setverdict(pass); |
| 359 | } |
Harald Welte | 24f921b | 2021-02-10 19:37:45 +0100 | [diff] [blame] | 360 | [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, calling, ?))) { |
| 361 | setverdict(fail, "Received unexpected SCCP waiting for ", rx_exp); |
| 362 | } |
| 363 | [] MTP3.receive { |
| 364 | setverdict(fail, "Received unexpected waiting for ", rx_exp); |
| 365 | } |
| 366 | [exp_something] T.timeout { |
| 367 | setverdict(fail, "Timeout waiting for ", rx_exp); |
| 368 | } |
| 369 | [not exp_something] T.timeout { |
| 370 | setverdict(pass); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | } |
| 375 | |
| 376 | /* Test is SST(SSN=1) returns SSA */ |
| 377 | testcase TC_scmg_sst_ssn1() runs on SCCP_Test_RAW_CT { |
| 378 | var SCCP_PAR_Address calling, called; |
| 379 | var template (value) PDU_SCMG_message tx; |
| 380 | var template (present) PDU_SCMG_message rx_exp; |
| 381 | |
| 382 | f_init_raw(mp_sccp_cfg[0]); |
| 383 | f_sleep(1.0); |
| 384 | |
| 385 | called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, 1, |
| 386 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 387 | calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, 1, |
| 388 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 389 | |
| 390 | tx := ts_SCMG_SST(1, mp_sccp_cfg[0].peer_pc); |
| 391 | rx_exp := ts_SCMG_SSA(1, mp_sccp_cfg[0].peer_pc); |
| 392 | f_scmg_xceive(calling, called, tx, rx_exp); |
| 393 | } |
| 394 | |
| 395 | /* Test is SST(SSN=valid) returns SSA */ |
| 396 | testcase TC_scmg_sst_ssn_valid() runs on SCCP_Test_RAW_CT { |
| 397 | var SCCP_PAR_Address calling, called; |
| 398 | var template (value) PDU_SCMG_message tx; |
| 399 | var template (present) PDU_SCMG_message rx_exp; |
| 400 | |
| 401 | f_init_raw(mp_sccp_cfg[0]); |
| 402 | f_sleep(1.0); |
| 403 | |
| 404 | called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, 1, |
| 405 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 406 | calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, 1, |
| 407 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 408 | |
| 409 | tx := ts_SCMG_SST(mp_sccp_cfg[0].peer_ssn, mp_sccp_cfg[0].peer_pc); |
| 410 | rx_exp := ts_SCMG_SSA(mp_sccp_cfg[0].peer_ssn, mp_sccp_cfg[0].peer_pc); |
| 411 | f_scmg_xceive(calling, called, tx, rx_exp); |
| 412 | } |
| 413 | |
| 414 | |
| 415 | /* Test is SST(SSN=invalid) returns nothing */ |
| 416 | testcase TC_scmg_sst_ssn_invalid() runs on SCCP_Test_RAW_CT { |
| 417 | var SCCP_PAR_Address calling, called; |
| 418 | var template (value) PDU_SCMG_message tx; |
| 419 | var template (omit) PDU_SCMG_message rx_exp; |
| 420 | |
| 421 | f_init_raw(mp_sccp_cfg[0]); |
| 422 | f_sleep(1.0); |
| 423 | |
| 424 | called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, 1, |
| 425 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 426 | calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, 1, |
| 427 | mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type)); |
| 428 | |
| 429 | tx := ts_SCMG_SST(123, mp_sccp_cfg[0].peer_pc); |
| 430 | rx_exp := omit; |
| 431 | f_scmg_xceive(calling, called, tx, rx_exp); |
| 432 | } |
| 433 | |
Harald Welte | aed9f94 | 2021-05-13 21:54:58 +0200 | [diff] [blame] | 434 | /* Test CallingParty(only SSN) solicits response (OS#5146) */ |
| 435 | testcase TC_callingparty_ssn_only() runs on SCCP_Test_RAW_CT { |
| 436 | var SCCP_PAR_Address calling, called; |
| 437 | var template (value) PDU_SCMG_message tx; |
| 438 | var template (present) PDU_SCMG_message rx_exp; |
| 439 | |
| 440 | f_init_raw(mp_sccp_cfg[0]); |
| 441 | f_sleep(1.0); |
| 442 | |
| 443 | called := valueof(ts_SccpAddr_SSN(1)); |
| 444 | calling := valueof(ts_SccpAddr_SSN(1)); |
| 445 | |
| 446 | tx := ts_SCMG_SST(1, mp_sccp_cfg[0].peer_pc); |
| 447 | rx_exp := ts_SCMG_SSA(1, mp_sccp_cfg[0].peer_pc); |
| 448 | f_scmg_xceive(calling, called, tx, rx_exp, accept_other_called_resp:=true); |
| 449 | } |
Harald Welte | 24f921b | 2021-02-10 19:37:45 +0100 | [diff] [blame] | 450 | |
| 451 | |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 452 | control { |
| 453 | execute( TC_cr_cc() ); |
Pau Espin Pedrol | f7ba234 | 2020-01-20 20:19:47 +0100 | [diff] [blame] | 454 | execute( TC_udt_without_cr_cc() ); |
Pau Espin Pedrol | a2473da | 2020-01-20 13:20:58 +0100 | [diff] [blame] | 455 | execute( TC_tiar_timeout() ); |
Pau Espin Pedrol | e30d543 | 2020-01-21 13:47:32 +0100 | [diff] [blame] | 456 | execute( TC_it_avoids_tiar() ); |
Harald Welte | 4038d4c | 2021-10-26 14:37:54 +0200 | [diff] [blame] | 457 | execute( TC_process_rx_xudt() ); |
Harald Welte | 24f921b | 2021-02-10 19:37:45 +0100 | [diff] [blame] | 458 | |
| 459 | execute( TC_scmg_sst_ssn1() ); |
| 460 | execute( TC_scmg_sst_ssn_valid() ); |
| 461 | execute( TC_scmg_sst_ssn_invalid() ); |
Harald Welte | aed9f94 | 2021-05-13 21:54:58 +0200 | [diff] [blame] | 462 | |
| 463 | execute( TC_callingparty_ssn_only() ); |
Harald Welte | 9adf57b | 2020-01-10 12:33:44 +0100 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | |
| 467 | } |