Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 1 | module SIP_Tests { |
| 2 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame^] | 3 | /* osmo-sip-connector test suite in TTCN-3 |
| 4 | * (C) 2018-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 | |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 13 | import from General_Types all; |
| 14 | import from Osmocom_Types all; |
| 15 | |
| 16 | import from Osmocom_CTRL_Functions all; |
| 17 | import from Osmocom_CTRL_Types all; |
| 18 | import from Osmocom_CTRL_Adapter all; |
| 19 | |
| 20 | import from TELNETasp_PortType all; |
| 21 | import from Osmocom_VTY_Functions all; |
| 22 | |
| 23 | import from MNCC_Emulation all; |
| 24 | import from MNCC_Types all; |
| 25 | |
| 26 | import from SDP_Types all; |
| 27 | |
| 28 | import from SIP_Emulation all; |
| 29 | import from SIPmsg_Types all; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 30 | import from SIP_Templates all; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 31 | |
| 32 | modulepar { |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 33 | charstring mp_local_host := "127.0.0.2"; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 34 | charstring mp_osmosip_host := "127.0.0.1"; |
| 35 | integer mp_osmosip_port_ctrl := -1; /* RFU */ |
| 36 | charstring mp_mncc := "/tmp/mncc"; |
| 37 | } |
| 38 | |
| 39 | type component test_CT extends CTRL_Adapter_CT { |
| 40 | var MNCC_Emulation_CT vc_MNCC; |
| 41 | var SIP_Emulation_CT vc_SIP; |
| 42 | |
| 43 | port TELNETasp_PT SIPVTY; |
| 44 | } |
| 45 | |
| 46 | type component ConnHdlr extends SIP_ConnHdlr, MNCC_ConnHdlr { |
| 47 | var ConnHdlrPars g_pars; |
| 48 | timer g_Tguard; |
| 49 | } |
| 50 | |
| 51 | type record ConnHdlrPars { |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 52 | float t_guard, |
| 53 | CallPars g_cp optional |
| 54 | } |
| 55 | |
| 56 | type record CallPars { |
| 57 | boolean is_mo, |
| 58 | charstring calling, |
| 59 | charstring called, |
| 60 | |
| 61 | uint32_t mncc_call_id optional, |
| 62 | |
| 63 | CallParsComputed comp optional |
| 64 | } |
| 65 | |
| 66 | type record CallParsComputed { |
| 67 | CallidString sip_call_id, |
| 68 | SipAddr sip_url_ext, |
| 69 | SipAddr sip_url_gsm, |
| 70 | charstring sip_body, |
| 71 | integer sip_seq_nr |
| 72 | } |
| 73 | |
| 74 | private template (value) CallPars t_CallPars(boolean is_mo) := { |
| 75 | is_mo := is_mo, |
| 76 | calling := "12345", |
| 77 | called := "98766", |
| 78 | mncc_call_id := omit, |
| 79 | comp := omit |
| 80 | } |
| 81 | |
| 82 | private function f_CallPars_compute(inout CallPars cp) { |
| 83 | if (cp.is_mo) { |
| 84 | cp.comp.sip_url_ext := valueof(ts_SipAddr(cp.called, mp_local_host, 5060)); |
| 85 | cp.comp.sip_url_gsm := valueof(ts_SipAddr(cp.calling, mp_osmosip_host, 5060)); |
| 86 | cp.mncc_call_id := f_rnd_int(429496725); |
| 87 | } else { |
| 88 | cp.comp.sip_url_ext := valueof(ts_SipAddr(cp.calling, mp_local_host, 5060)); |
| 89 | cp.comp.sip_url_gsm := valueof(ts_SipAddr(cp.called, mp_osmosip_host, 5060)); |
| 90 | cp.comp.sip_call_id := hex2str(f_rnd_hexstring(15)); |
| 91 | } |
| 92 | cp.comp.sip_seq_nr := f_rnd_int(4294967295); |
| 93 | cp.comp.sip_body := ""; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | |
| 97 | function f_init_mncc(charstring id) runs on test_CT { |
| 98 | id := id & "-MNCC"; |
| 99 | var MnccOps ops := { |
| 100 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 101 | unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback) |
| 102 | }; |
| 103 | |
| 104 | vc_MNCC := MNCC_Emulation_CT.create(id); |
| 105 | map(vc_MNCC:MNCC, system:MNCC_CODEC_PT); |
| 106 | vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_mncc, true)); |
| 107 | } |
| 108 | |
| 109 | function f_init() runs on test_CT { |
| 110 | //f_ipa_ctrl_start(mp_osmosip_host, mp_osmosip_port_ctrl); |
| 111 | f_init_mncc("SIP_Test"); |
| 112 | log("end of f_init_mncc"); |
| 113 | f_init_sip(vc_SIP, "SIP_Test"); |
| 114 | log("end of f_init_sip"); |
| 115 | |
| 116 | map(self:SIPVTY, system:SIPVTY); |
| 117 | f_vty_set_prompts(SIPVTY); |
| 118 | f_vty_transceive(SIPVTY, "enable"); |
| 119 | log("end of f_init"); |
| 120 | } |
| 121 | |
| 122 | type function void_fn(charstring id) runs on ConnHdlr; |
| 123 | |
| 124 | function f_start_handler(void_fn fn, ConnHdlrPars pars) |
| 125 | runs on test_CT return ConnHdlr { |
| 126 | var ConnHdlr vc_conn; |
| 127 | var charstring id := testcasename(); |
| 128 | |
| 129 | vc_conn := ConnHdlr.create(id); |
| 130 | |
| 131 | connect(vc_conn:SIP, vc_SIP:CLIENT); |
| 132 | connect(vc_conn:SIP_PROC, vc_SIP:CLIENT_PROC); |
| 133 | |
| 134 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 135 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
| 136 | |
| 137 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 138 | return vc_conn; |
| 139 | } |
| 140 | |
| 141 | private altstep as_Tguard() runs on ConnHdlr { |
| 142 | [] g_Tguard.timeout { |
| 143 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 144 | mtc.stop; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | |
| 148 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 149 | runs on ConnHdlr { |
| 150 | g_pars := pars; |
| 151 | g_Tguard.start(pars.t_guard); |
| 152 | activate(as_Tguard()); |
| 153 | |
| 154 | /* call the user-supied test case function */ |
| 155 | fn.apply(id); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | template (value) ConnHdlrPars t_Pars := { |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 160 | t_guard := 30.0, |
| 161 | g_cp := omit |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 162 | } |
| 163 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 164 | /* Establish a mobile terminated call described in 'cp' */ |
| 165 | function f_establish_mt(inout CallPars cp) runs on ConnHdlr { |
| 166 | var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm); |
| 167 | var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 168 | var PDU_SIP_Request sip_req; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 169 | var MNCC_PDU mncc; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 170 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 171 | /* Ask MNCC_Emulation to "expect" a call to the given called number */ |
| 172 | f_create_mncc_expect(cp.called); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 173 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 174 | /* OSC <- SIP: A party sends SIP invite for a MT-call into OSC */ |
| 175 | SIP.send(ts_SIP_INVITE(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm, |
| 176 | cp.comp.sip_seq_nr, cp.comp.sip_body)); |
| 177 | /* MSC <- OSC: OSC generates MNCC_SETUP_REQ from INVITE */ |
| 178 | MNCC.receive(tr_MNCC_SETUP_req) -> value mncc { |
| 179 | cp.mncc_call_id := mncc.u.signal.callref; |
| 180 | } |
| 181 | /* OSC -> SIP */ |
| 182 | SIP.receive(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *, |
| 183 | "INVITE", 100, ?, "Trying", *)); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 184 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 185 | /* MSC -> OSC: After MS sends CALL CONF in response to SETUP */ |
| 186 | MNCC.send(ts_MNCC_CALL_CONF_ind(cp.mncc_call_id)); |
| 187 | /* MSC <- OSC: OSC asks MSC to create RTP socket */ |
| 188 | MNCC.receive(tr_MNCC_RTP_CREATE(cp.mncc_call_id)); |
| 189 | MNCC.send(ts_MNCC_RTP_CREATE(cp.mncc_call_id)); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 190 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 191 | /* MSC -> OSC: After MS is ringing and sent CC ALERTING */ |
| 192 | MNCC.send(ts_MNCC_ALERT_ind(cp.mncc_call_id)); |
| 193 | SIP.clear; |
| 194 | SIP.receive(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *, |
| 195 | "INVITE", 180, ?, "Ringing", *)); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 196 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 197 | /* MSC -> OSC: After MT user has picked up and sent CC CONNECT */ |
| 198 | MNCC.send(ts_MNCC_SETUP_CNF(cp.mncc_call_id)); |
| 199 | |
| 200 | SIP.clear; |
| 201 | interleave { |
| 202 | /* MSC <- OSC: OSC asks MSC to connect its RTP stream to remote end */ |
| 203 | [] MNCC.receive(tr_MNCC_RTP_CONNECT(cp.mncc_call_id)) {} |
| 204 | /* OSC -> SIP: OSC confirms call establishment to SIP side */ |
| 205 | [] SIP.receive(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, ?, |
| 206 | "INVITE", 200, ?, "OK", ?)) {} |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 207 | } |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 208 | /* OSC <- SIP: SIP world acknowledges "200 OK" */ |
| 209 | SIP.send(ts_SIP_ACK(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm, |
| 210 | cp.comp.sip_seq_nr, omit)); |
| 211 | /* MSC <- OSC: OSC sends SETUP COMPL to MNCC (which triggers CC CONNECT ACK */ |
| 212 | MNCC.receive(tr_MNCC_SETUP_COMPL_req(cp.mncc_call_id)); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 213 | } |
| 214 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 215 | /* Establish a mobile originated call described in 'cp' */ |
| 216 | function f_establish_mo(inout CallPars cp) runs on ConnHdlr { |
| 217 | var MNCC_number dst := valueof(ts_MNCC_number(cp.called, GSM48_TON_UNKNOWN)); |
| 218 | var MNCC_number src := valueof(ts_MNCC_number(cp.calling, GSM48_TON_UNKNOWN)); |
| 219 | var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm); |
| 220 | var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext); |
| 221 | var PDU_SIP_Request sip_req; |
| 222 | var integer seq_nr; |
| 223 | |
| 224 | f_create_sip_expect(cp.comp.sip_url_ext.addr.nameAddr.addrSpec); |
| 225 | |
| 226 | /* MSC -> OSC: MSC sends SETUP.ind after CC SETUP was received from MS */ |
| 227 | MNCC.send(ts_MNCC_SETUP_ind(cp.mncc_call_id, dst, src, "262420123456789")); |
| 228 | /* MSC <- OSC: Create GSM side RTP socket */ |
| 229 | MNCC.receive(tr_MNCC_RTP_CREATE(cp.mncc_call_id)) { |
| 230 | var MNCC_PDU mncc := valueof(ts_MNCC_RTP_CREATE(cp.mncc_call_id)); |
| 231 | mncc.u.rtp.payload_msg_type := oct2int('0300'O); |
| 232 | MNCC.send(mncc); /* FIXME: port/ip */ |
| 233 | } |
| 234 | /* OSC -> SIP: Send INVITE with GSM side IP/Port in SDP */ |
| 235 | SIP.receive(tr_SIP_INVITE(?, sip_addr_gsm, sip_addr_ext, ?, ?)) -> value sip_req { |
| 236 | cp.comp.sip_url_gsm.params := sip_req.msgHeader.fromField.fromParams; |
| 237 | cp.comp.sip_call_id := sip_req.msgHeader.callId.callid; |
| 238 | seq_nr := sip_req.msgHeader.cSeq.seqNumber; |
| 239 | } |
| 240 | /* OSC <- SIP: Notify call is proceeding */ |
| 241 | SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext, |
| 242 | "INVITE", 100, seq_nr, "Trying", sip_req.msgHeader.via)); |
| 243 | /* MSC <- OSC: "100 Trying" translated to MNCC_CALL_PROC_REQ */ |
| 244 | MNCC.receive(tr_MNCC_CALL_PROC_req(cp.mncc_call_id)); |
| 245 | |
| 246 | /* OSC <- SIP: SIP-terminated user is ringing now */ |
| 247 | SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext, |
| 248 | "INVITE", 180, seq_nr, "Ringing", sip_req.msgHeader.via)); |
| 249 | |
| 250 | /* MSC <- OSC: "180 Ringing" translated to MNCC_ALERT_REQ */ |
| 251 | MNCC.receive(tr_MNCC_ALERT_req(cp.mncc_call_id)) {} |
| 252 | |
| 253 | /* OSC <- SIP: SIP-terminated user has accepted the call */ |
| 254 | SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext, |
| 255 | "INVITE", 200, seq_nr, "OK", sip_req.msgHeader.via, |
| 256 | cp.comp.sip_body)); |
| 257 | MNCC.receive(tr_MNCC_RTP_CONNECT(cp.mncc_call_id)); |
| 258 | /* MSC <- OSC: "200 OK" translated to MNCC_SETUP_RSP */ |
| 259 | MNCC.receive(tr_MNCC_SETUP_rsp(cp.mncc_call_id)); |
| 260 | |
| 261 | /* MSC -> OSC: CC CONNECT ACK was received from MS */ |
| 262 | MNCC.send(ts_MNCC_SETUP_COMPL_ind(cp.mncc_call_id)); |
| 263 | /* OSC -> SIP: Acknowledge the call */ |
| 264 | SIP.receive(tr_SIP_ACK(cp.comp.sip_call_id, sip_addr_gsm, sip_addr_ext, ?, omit)); |
| 265 | } |
| 266 | |
| 267 | /* Release call from the mobile side */ |
| 268 | function f_release_mobile(inout CallPars cp) runs on ConnHdlr { |
| 269 | var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm); |
| 270 | var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext); |
| 271 | var PDU_SIP_Request sip_req; |
| 272 | SIP.clear; |
| 273 | /* MSC -> OSC: Simulate a CC DISCONNET from the MT user */ |
| 274 | MNCC.send(ts_MNCC_DISC_ind(cp.mncc_call_id, ts_MNCC_cause(0))); |
| 275 | /* OSC -> SIP: Expect BYE from OSC to SIP side */ |
| 276 | SIP.receive(tr_SIP_BYE(cp.comp.sip_call_id, sip_addr_gsm, sip_addr_ext, ?, *)) -> value sip_req { |
| 277 | cp.comp.sip_url_gsm.params := sip_req.msgHeader.fromField.fromParams; |
| 278 | } |
| 279 | /* OSC <- SIP: Acknowledge the BYE */ |
| 280 | SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext, |
| 281 | "BYE", 200, sip_req.msgHeader.cSeq.seqNumber, "OK", |
| 282 | sip_req.msgHeader.via)); |
| 283 | /* MSC <- OSC: Send REL_REQ to MSC, triggers CC RELEASE REQ to MS */ |
| 284 | MNCC.receive(tr_MNCC_REL_req(cp.mncc_call_id)); // CAUSE? |
| 285 | /* MSC -> OSC: MS has responded with CC CLEAR COMPL, triggers MNCC_REL_CNF */ |
| 286 | MNCC.send(ts_MNCC_REL_cnf(cp.mncc_call_id, ts_MNCC_cause(0))); |
| 287 | } |
| 288 | |
| 289 | /* Release call from the SIP side */ |
| 290 | function f_release_sip(inout CallPars cp) runs on ConnHdlr { |
| 291 | var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm); |
| 292 | var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext); |
| 293 | /* OSC <- SIP: SIP-side sends a BYE to OSC */ |
| 294 | SIP.send(ts_SIP_BYE(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm, |
| 295 | cp.comp.sip_seq_nr, omit)); |
| 296 | /* MSC <- OSC: Expect OSC to cause MNCC Disconnect Request */ |
| 297 | MNCC.receive(tr_MNCC_DISC_req(cp.mncc_call_id)); |
| 298 | /* MSC -> OSC: Indicate GSM side release */ |
| 299 | MNCC.send(ts_MNCC_REL_ind(cp.mncc_call_id, ts_MNCC_cause(0))); |
| 300 | /* OSC -> SIP: Confirmation to SIP side */ |
| 301 | SIP.receive(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *, |
| 302 | "BYE", 200, cp.comp.sip_seq_nr, "OK", omit)); |
| 303 | } |
| 304 | |
| 305 | /* Successful MT Call, which is subsequently released by GSM side */ |
| 306 | private function f_TC_mt_success_rel_gsm(charstring id) runs on ConnHdlr { |
| 307 | var CallPars cp := valueof(t_CallPars(false)); |
| 308 | f_CallPars_compute(cp); |
| 309 | cp.comp.sip_body := "v=0\r\no=Osmocom 0 0 IN IP4 0.0.0.0\r\ns=GSM Call\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\nm=audio 0 RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
| 310 | f_sleep(3.0) |
| 311 | |
| 312 | f_establish_mt(cp); |
| 313 | /* now call is fully established */ |
| 314 | f_sleep(2.0); |
| 315 | f_release_mobile(cp); |
| 316 | setverdict(pass); |
| 317 | } |
| 318 | testcase TC_mt_success_rel_gsm() runs on test_CT { |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 319 | var ConnHdlrPars pars; |
| 320 | var ConnHdlr vc_conn; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 321 | f_init(); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 322 | pars := valueof(t_Pars); |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 323 | vc_conn := f_start_handler(refers(f_TC_mt_success_rel_gsm), pars); |
| 324 | vc_conn.done; |
| 325 | } |
| 326 | |
| 327 | /* Successful MT Call, which is subsequently released by SIP side */ |
| 328 | private function f_TC_mt_success_rel_sip(charstring id) runs on ConnHdlr { |
| 329 | var CallPars cp := valueof(t_CallPars(false)); |
| 330 | f_CallPars_compute(cp); |
| 331 | cp.comp.sip_body := "v=0\r\no=Osmocom 0 0 IN IP4 0.0.0.0\r\ns=GSM Call\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\nm=audio 0 RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
| 332 | f_sleep(3.0) |
| 333 | |
| 334 | f_establish_mt(cp); |
| 335 | /* now call is fully established */ |
| 336 | f_sleep(2.0); |
| 337 | f_release_sip(cp); |
| 338 | setverdict(pass); |
| 339 | } |
| 340 | testcase TC_mt_success_rel_sip() runs on test_CT { |
| 341 | var ConnHdlrPars pars; |
| 342 | var ConnHdlr vc_conn; |
| 343 | f_init(); |
| 344 | pars := valueof(t_Pars); |
| 345 | vc_conn := f_start_handler(refers(f_TC_mt_success_rel_sip), pars); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 346 | vc_conn.done; |
| 347 | } |
| 348 | |
| 349 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 350 | /* Successful MO Call, which is subsequently released by GSM side */ |
| 351 | private function f_TC_mo_success_rel_gsm(charstring id) runs on ConnHdlr { |
| 352 | var CallPars cp := valueof(t_CallPars(true)); |
| 353 | f_CallPars_compute(cp); |
| 354 | cp.comp.sip_body := "v=0\r\no=Osmocom 0 0 IN IP4 0.0.0.0\r\ns=GSM Call\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\nm=audio 0 RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
| 355 | f_sleep(3.0) |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 356 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 357 | f_establish_mo(cp); |
| 358 | /* now call is fully established */ |
| 359 | f_sleep(2.0); |
| 360 | f_release_mobile(cp); |
| 361 | setverdict(pass); |
| 362 | } |
| 363 | testcase TC_mo_success_rel_gsm() runs on test_CT { |
| 364 | var ConnHdlrPars pars; |
| 365 | var ConnHdlr vc_conn; |
| 366 | f_init(); |
| 367 | pars := valueof(t_Pars); |
| 368 | vc_conn := f_start_handler(refers(f_TC_mo_success_rel_gsm), pars); |
| 369 | vc_conn.done; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 370 | } |
| 371 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 372 | /* Successful MO Call, which is subsequently released by SIP side */ |
| 373 | private function f_TC_mo_success_rel_sip(charstring id) runs on ConnHdlr { |
| 374 | var CallPars cp := valueof(t_CallPars(true)); |
| 375 | f_CallPars_compute(cp); |
| 376 | cp.comp.sip_body := "v=0\r\no=Osmocom 0 0 IN IP4 0.0.0.0\r\ns=GSM Call\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\nm=audio 0 RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
| 377 | f_sleep(3.0) |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 378 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 379 | f_establish_mo(cp); |
| 380 | /* now call is fully established */ |
| 381 | f_sleep(2.0); |
| 382 | f_release_sip(cp); |
| 383 | setverdict(pass); |
| 384 | } |
| 385 | testcase TC_mo_success_rel_sip() runs on test_CT { |
| 386 | var ConnHdlrPars pars; |
| 387 | var ConnHdlr vc_conn; |
| 388 | f_init(); |
| 389 | pars := valueof(t_Pars); |
| 390 | vc_conn := f_start_handler(refers(f_TC_mo_success_rel_sip), pars); |
| 391 | vc_conn.done; |
| 392 | } |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 393 | |
Harald Welte | ddf011e | 2019-04-19 09:39:35 +0200 | [diff] [blame] | 394 | /* SETUP followed by DISC results in lingering B-leg (OS#3518)*/ |
| 395 | private function f_TC_mo_setup_disc_late_rtp(charstring id) runs on ConnHdlr { |
| 396 | var CallPars cp := valueof(t_CallPars(true)); |
| 397 | f_CallPars_compute(cp); |
| 398 | cp.comp.sip_body := "v=0\r\no=Osmocom 0 0 IN IP4 0.0.0.0\r\ns=GSM Call\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\nm=audio 0 RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
| 399 | f_sleep(3.0); |
| 400 | |
| 401 | var MNCC_number dst := valueof(ts_MNCC_number(cp.called, GSM48_TON_UNKNOWN)); |
| 402 | var MNCC_number src := valueof(ts_MNCC_number(cp.calling, GSM48_TON_UNKNOWN)); |
| 403 | var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm); |
| 404 | var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext); |
| 405 | |
| 406 | f_create_sip_expect(cp.comp.sip_url_ext.addr.nameAddr.addrSpec); |
| 407 | |
| 408 | /* MSC -> OSC: MSC sends SETUP.ind after CC SETUP was received from MS */ |
| 409 | MNCC.send(ts_MNCC_SETUP_ind(cp.mncc_call_id, dst, src, "262420123456789")); |
| 410 | |
| 411 | /* MSC -> OSC: Simulate a CC DISCONNET from the MT user *before* responding to the RTP_CREATE */ |
| 412 | MNCC.send(ts_MNCC_DISC_ind(cp.mncc_call_id, ts_MNCC_cause(0))); |
| 413 | |
| 414 | /* MSC <- OSC: Create GSM side RTP socket (too late) */ |
| 415 | MNCC.receive(tr_MNCC_RTP_CREATE(cp.mncc_call_id)) { |
| 416 | var MNCC_PDU mncc := valueof(ts_MNCC_RTP_CREATE(cp.mncc_call_id)); |
| 417 | mncc.u.rtp.payload_msg_type := oct2int('0300'O); |
| 418 | MNCC.send(mncc); /* FIXME: port/ip */ |
| 419 | } |
| 420 | |
| 421 | /* OSC -> SIP: We should never receive INVITE */ |
| 422 | timer T := 10.0; |
| 423 | T.start; |
| 424 | alt { |
| 425 | [] SIP.receive(tr_SIP_INVITE(?, sip_addr_gsm, sip_addr_ext, ?, ?)) { |
| 426 | setverdict(fail, "Received unexpected INVITE"); |
| 427 | } |
| 428 | [] T.timeout { |
| 429 | setverdict(pass); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | testcase TC_mo_setup_disc_late_rtp() runs on test_CT { |
| 434 | var ConnHdlrPars pars; |
| 435 | var ConnHdlr vc_conn; |
| 436 | f_init(); |
| 437 | pars := valueof(t_Pars); |
| 438 | vc_conn := f_start_handler(refers(f_TC_mo_setup_disc_late_rtp), pars); |
| 439 | vc_conn.done; |
| 440 | } |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 441 | |
| 442 | control { |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 443 | execute( TC_mt_success_rel_gsm() ); |
| 444 | execute( TC_mt_success_rel_sip() ); |
| 445 | execute( TC_mo_success_rel_gsm() ); |
| 446 | execute( TC_mo_success_rel_sip() ); |
Harald Welte | ddf011e | 2019-04-19 09:39:35 +0200 | [diff] [blame] | 447 | execute( TC_mo_setup_disc_late_rtp() ); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | |
| 451 | |
| 452 | } |