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; |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 15 | import from Native_Functions all; |
| 16 | import from Misc_Helpers all; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 17 | |
| 18 | import from Osmocom_CTRL_Functions all; |
| 19 | import from Osmocom_CTRL_Types all; |
| 20 | import from Osmocom_CTRL_Adapter all; |
| 21 | |
| 22 | import from TELNETasp_PortType all; |
| 23 | import from Osmocom_VTY_Functions all; |
| 24 | |
| 25 | import from MNCC_Emulation all; |
| 26 | import from MNCC_Types all; |
| 27 | |
| 28 | import from SDP_Types all; |
Pau Espin Pedrol | f371375 | 2024-03-21 17:32:55 +0100 | [diff] [blame^] | 29 | import from SDP_Templates all; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 30 | |
| 31 | import from SIP_Emulation all; |
| 32 | import from SIPmsg_Types all; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 33 | import from SIP_Templates all; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 34 | |
| 35 | modulepar { |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 36 | charstring mp_local_host := "127.0.0.2"; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 37 | charstring mp_osmosip_host := "127.0.0.1"; |
| 38 | integer mp_osmosip_port_ctrl := -1; /* RFU */ |
| 39 | charstring mp_mncc := "/tmp/mncc"; |
| 40 | } |
| 41 | |
| 42 | type component test_CT extends CTRL_Adapter_CT { |
| 43 | var MNCC_Emulation_CT vc_MNCC; |
| 44 | var SIP_Emulation_CT vc_SIP; |
| 45 | |
| 46 | port TELNETasp_PT SIPVTY; |
| 47 | } |
| 48 | |
| 49 | type component ConnHdlr extends SIP_ConnHdlr, MNCC_ConnHdlr { |
| 50 | var ConnHdlrPars g_pars; |
| 51 | timer g_Tguard; |
| 52 | } |
| 53 | |
| 54 | type record ConnHdlrPars { |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 55 | float t_guard, |
| 56 | CallPars g_cp optional |
| 57 | } |
| 58 | |
| 59 | type record CallPars { |
| 60 | boolean is_mo, |
| 61 | charstring calling, |
| 62 | charstring called, |
| 63 | |
| 64 | uint32_t mncc_call_id optional, |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 65 | CallParsComputed comp optional, |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 66 | |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 67 | charstring sip_rtp_addr, |
| 68 | uint16_t sip_rtp_port, |
| 69 | charstring cn_rtp_addr, |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 70 | uint16_t cn_rtp_port, |
| 71 | |
| 72 | /* Send SDP to MNCC, and expect to receive SDP from MNCC. mncc_with_sdp := false tests legacy compatibility to |
| 73 | * the time when we did not include SDP in MNCC messages. mncc_with_sdp := true expects SDP to pass through the |
| 74 | * SUT osmo-sip-connector unchanged. */ |
| 75 | boolean mncc_with_sdp |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | type record CallParsComputed { |
| 79 | CallidString sip_call_id, |
| 80 | SipAddr sip_url_ext, |
| 81 | SipAddr sip_url_gsm, |
| 82 | charstring sip_body, |
| 83 | integer sip_seq_nr |
| 84 | } |
| 85 | |
Neels Hofmeyr | a0d015b | 2023-09-13 04:32:14 +0200 | [diff] [blame] | 86 | private template (value) CallPars t_CallPars(boolean is_mo, boolean mncc_with_sdp := true) := { |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 87 | is_mo := is_mo, |
| 88 | calling := "12345", |
| 89 | called := "98766", |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 90 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 91 | mncc_call_id := omit, |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 92 | comp := omit, |
| 93 | sip_rtp_addr := "1.2.3.4", |
| 94 | sip_rtp_port := 1234, |
| 95 | cn_rtp_addr := "5.6.7.8", |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 96 | cn_rtp_port := 5678, |
| 97 | mncc_with_sdp := mncc_with_sdp |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | private function f_CallPars_compute(inout CallPars cp) { |
| 101 | if (cp.is_mo) { |
| 102 | cp.comp.sip_url_ext := valueof(ts_SipAddr(cp.called, mp_local_host, 5060)); |
| 103 | cp.comp.sip_url_gsm := valueof(ts_SipAddr(cp.calling, mp_osmosip_host, 5060)); |
| 104 | cp.mncc_call_id := f_rnd_int(429496725); |
| 105 | } else { |
| 106 | cp.comp.sip_url_ext := valueof(ts_SipAddr(cp.calling, mp_local_host, 5060)); |
| 107 | cp.comp.sip_url_gsm := valueof(ts_SipAddr(cp.called, mp_osmosip_host, 5060)); |
| 108 | cp.comp.sip_call_id := hex2str(f_rnd_hexstring(15)); |
| 109 | } |
| 110 | cp.comp.sip_seq_nr := f_rnd_int(4294967295); |
| 111 | cp.comp.sip_body := ""; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 112 | } |
| 113 | |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 114 | function f_init_mncc(charstring id) runs on test_CT { |
| 115 | id := id & "-MNCC"; |
| 116 | var MnccOps ops := { |
| 117 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 118 | unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback) |
| 119 | }; |
| 120 | |
| 121 | vc_MNCC := MNCC_Emulation_CT.create(id); |
| 122 | map(vc_MNCC:MNCC, system:MNCC_CODEC_PT); |
| 123 | vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_mncc, true)); |
| 124 | } |
| 125 | |
| 126 | function f_init() runs on test_CT { |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 127 | //f_ipa_ctrl_start_client(mp_osmosip_host, mp_osmosip_port_ctrl); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 128 | f_init_mncc("SIP_Test"); |
| 129 | log("end of f_init_mncc"); |
| 130 | f_init_sip(vc_SIP, "SIP_Test"); |
| 131 | log("end of f_init_sip"); |
| 132 | |
| 133 | map(self:SIPVTY, system:SIPVTY); |
| 134 | f_vty_set_prompts(SIPVTY); |
| 135 | f_vty_transceive(SIPVTY, "enable"); |
| 136 | log("end of f_init"); |
| 137 | } |
| 138 | |
| 139 | type function void_fn(charstring id) runs on ConnHdlr; |
| 140 | |
| 141 | function f_start_handler(void_fn fn, ConnHdlrPars pars) |
| 142 | runs on test_CT return ConnHdlr { |
| 143 | var ConnHdlr vc_conn; |
| 144 | var charstring id := testcasename(); |
| 145 | |
| 146 | vc_conn := ConnHdlr.create(id); |
| 147 | |
| 148 | connect(vc_conn:SIP, vc_SIP:CLIENT); |
| 149 | connect(vc_conn:SIP_PROC, vc_SIP:CLIENT_PROC); |
| 150 | |
| 151 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 152 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
| 153 | |
| 154 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 155 | return vc_conn; |
| 156 | } |
| 157 | |
| 158 | private altstep as_Tguard() runs on ConnHdlr { |
| 159 | [] g_Tguard.timeout { |
| 160 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 161 | mtc.stop; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | |
| 165 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 166 | runs on ConnHdlr { |
| 167 | g_pars := pars; |
| 168 | g_Tguard.start(pars.t_guard); |
| 169 | activate(as_Tguard()); |
| 170 | |
| 171 | /* call the user-supied test case function */ |
| 172 | fn.apply(id); |
| 173 | } |
| 174 | |
| 175 | |
| 176 | template (value) ConnHdlrPars t_Pars := { |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 177 | t_guard := 30.0, |
| 178 | g_cp := omit |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 179 | } |
| 180 | |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 181 | altstep as_SIP_expect_resp(template PDU_SIP_Response sip_expect) runs on ConnHdlr |
| 182 | { |
| 183 | [] SIP.receive(sip_expect); |
| 184 | [] SIP.receive { |
| 185 | log("FAIL: expected SIP message ", sip_expect); |
| 186 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected SIP message"); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | function f_SIP_expect_req(template PDU_SIP_Request sip_expect) runs on ConnHdlr return PDU_SIP_Request |
| 191 | { |
| 192 | var PDU_SIP_Request rx; |
| 193 | alt { |
| 194 | [] SIP.receive(sip_expect) -> value rx; |
| 195 | [] SIP.receive { |
| 196 | log("FAIL: expected SIP message ", sip_expect); |
| 197 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected SIP message"); |
| 198 | } |
| 199 | } |
| 200 | return rx; |
| 201 | } |
| 202 | |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 203 | /* Update 'last_sdp', and match with expectation of what the current SDP should be. |
| 204 | * Useful to ensure that MNCC or SIP send and possibly resend only the expected SDP. |
| 205 | * last_sdp keeps the last non-empty rx_sdp, across multiple check_sdp() invocations. |
| 206 | * rx_sdp is the SDP charstring just received. If it is nonempty, update last_sdp to rx_sdp. |
| 207 | * After updating last_sdp as appropriate, match last_sdp with expect_sdp. */ |
| 208 | private function check_sdp(inout charstring last_sdp, |
| 209 | charstring rx_sdp, |
| 210 | template charstring expect_sdp) |
| 211 | { |
| 212 | /* If there is new SDP, store it. */ |
| 213 | if (lengthof(rx_sdp) > 0) { |
| 214 | if (last_sdp != rx_sdp) { |
| 215 | log("SDP update from ", last_sdp, " to ", rx_sdp); |
| 216 | } |
| 217 | |
| 218 | /* If MNCC sent SDP data, remember it as the last valid SDP */ |
| 219 | last_sdp := rx_sdp; |
| 220 | } |
| 221 | /* Validate expectations of the SDP data */ |
| 222 | if (not match(last_sdp, expect_sdp)) { |
| 223 | log("FAIL: expected SDP ", expect_sdp, " but got ", last_sdp); |
| 224 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unexpected SDP"); |
| 225 | } |
| 226 | } |
| 227 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 228 | /* Establish a mobile terminated call described in 'cp' */ |
| 229 | function f_establish_mt(inout CallPars cp) runs on ConnHdlr { |
| 230 | var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm); |
| 231 | var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext); |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 232 | var MNCC_PDU mncc; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 233 | |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 234 | /* The last SDP that the MSC received via MNCC from osmo-sip-connector */ |
| 235 | var charstring sdp_to_msc := ""; |
| 236 | /* At first, allow any empty and nonempty SDP. As the test progresses, this may expect specific SDP instead. */ |
| 237 | var template charstring expect_sdp_to_msc := *; |
| 238 | |
| 239 | /* If cp.mncc_with_sdp == true, expect SDP forwarding like this: |
| 240 | * |
| 241 | * SDP1: SIP agent's RTP and codec info |
| 242 | * SDP2: osmo-msc's RTP and codec info |
| 243 | * |
| 244 | * MNCC osmo-sip-connector SIP |
| 245 | * |<--SDP1----- SIP Invite |
| 246 | * |-----------> SIP (Invite) Trying |
| 247 | * <--SDP1-------| MNCC SETUP req |
| 248 | * ------------->| MNCC CALL CONF ind |
| 249 | * <-------------| MNCC RTP CREATE (SDP optional, still unchanged from SDP1) |
| 250 | * -------SDP2-->| MNCC RTP CREATE |
| 251 | * ------------->| MNCC ALERT ind |
| 252 | * |--------------> SIP (Invite) Ringing |
| 253 | * (MT picks up) | |
| 254 | * ------------->| MNCC SETUP CNF |
| 255 | * <-------------| MNCC RTP CONNECT (SDP optional, still unchanged from SDP1) |
| 256 | * |--------SDP2--> SIP (Invite) OK |
| 257 | * |<-------------- SIP ACK |
| 258 | * <-------------| MNCC SETUP COMPL (SDP optional, still unchanged from SDP1) |
| 259 | */ |
| 260 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 261 | /* Ask MNCC_Emulation to "expect" a call to the given called number */ |
| 262 | f_create_mncc_expect(cp.called); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 263 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 264 | /* OSC <- SIP: A party sends SIP invite for a MT-call into OSC */ |
| 265 | SIP.send(ts_SIP_INVITE(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm, |
| 266 | cp.comp.sip_seq_nr, cp.comp.sip_body)); |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 267 | if (cp.mncc_with_sdp) { |
| 268 | /* We just sent SDP via SIP, now expect the same SDP in MNCC to the MSC */ |
| 269 | expect_sdp_to_msc := cp.comp.sip_body; |
| 270 | } |
| 271 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 272 | /* OSC -> SIP */ |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 273 | as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *, |
| 274 | "INVITE", 100, ?, "Trying", *)); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 275 | |
Pau Espin Pedrol | 37cf408 | 2020-09-23 16:59:16 +0200 | [diff] [blame] | 276 | alt { |
| 277 | /* MSC <- OSC: OSC generates MNCC_SETUP_REQ from INVITE */ |
| 278 | [] MNCC.receive(tr_MNCC_SETUP_req) -> value mncc { |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 279 | cp.mncc_call_id := mncc.u.signal.callref; |
| 280 | /* Expect the SDP sent via SIP to arrive in MNCC */ |
| 281 | check_sdp(sdp_to_msc, mncc.u.signal.sdp, expect_sdp_to_msc); |
Pau Espin Pedrol | 37cf408 | 2020-09-23 16:59:16 +0200 | [diff] [blame] | 282 | } |
| 283 | [] SIP.receive { |
Neels Hofmeyr | baf0272 | 2023-09-12 02:10:11 +0200 | [diff] [blame] | 284 | setverdict(fail, "Received unexpected SIP response"); |
Pau Espin Pedrol | 37cf408 | 2020-09-23 16:59:16 +0200 | [diff] [blame] | 285 | SIP.send(ts_SIP_ACK(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm, |
| 286 | cp.comp.sip_seq_nr, omit)); |
| 287 | mtc.stop; |
| 288 | } |
| 289 | } |
| 290 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 291 | /* MSC -> OSC: After MS sends CALL CONF in response to SETUP */ |
| 292 | MNCC.send(ts_MNCC_CALL_CONF_ind(cp.mncc_call_id)); |
| 293 | /* MSC <- OSC: OSC asks MSC to create RTP socket */ |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 294 | MNCC.receive(tr_MNCC_RTP_CREATE(cp.mncc_call_id)) -> value mncc { |
| 295 | check_sdp(sdp_to_msc, mncc.u.rtp.sdp, expect_sdp_to_msc); |
| 296 | } |
| 297 | |
| 298 | /* MSC -> OSC: SDP that the MSC will send via MNCC */ |
| 299 | var charstring cn_sdp := "v=0\r\no=Osmocom 0 0 IN IP4 1.1.1.1\r\ns=GSM Call\r\nc=IN " & |
Pau Espin Pedrol | f371375 | 2024-03-21 17:32:55 +0100 | [diff] [blame^] | 300 | f_sdp_addr2addrtype(cp.cn_rtp_addr) & " " & cp.cn_rtp_addr & |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 301 | "\r\nt=0 0\r\nm=audio " & int2str(cp.cn_rtp_port) & |
| 302 | " RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
| 303 | /* OSC -> SIP: what SDP to expect in SIP from osmo-sip-connector */ |
| 304 | var template charstring expect_sdp_to_sip := pattern "*" & cp.cn_rtp_addr & "*"; |
| 305 | |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 306 | mncc := valueof(ts_MNCC_RTP_CREATE(cp.mncc_call_id)); |
| 307 | mncc.u.rtp.is_ipv6 := f_addr_is_ipv6(cp.cn_rtp_addr); |
| 308 | mncc.u.rtp.ip := f_addrstr2addr(cp.cn_rtp_addr); |
| 309 | mncc.u.rtp.rtp_port := cp.cn_rtp_port; |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 310 | if (cp.mncc_with_sdp) { |
| 311 | /* MSC -> OSC: tell OSC our RTP info in SDP form */ |
| 312 | mncc.u.rtp.sdp := cn_sdp; |
| 313 | /* OSC -> SIP: and expect it unchanged on SIP later, but allow osmo-sip-connector to append an |
| 314 | * "a=sendrecv;" */ |
| 315 | expect_sdp_to_sip := pattern cn_sdp & "*"; |
| 316 | } |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 317 | MNCC.send(mncc); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 318 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 319 | /* MSC -> OSC: After MS is ringing and sent CC ALERTING */ |
| 320 | MNCC.send(ts_MNCC_ALERT_ind(cp.mncc_call_id)); |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 321 | |
| 322 | /* Now expect SIP response "Ringing" back to MO, containing the same SDP information as in the MNCC RTP CREATE |
| 323 | * sent to OSC above */ |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 324 | SIP.clear; |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 325 | |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 326 | /* 180 Ringing should not contain any SDP. */ |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 327 | as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *, |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 328 | "INVITE", 180, ?, "Ringing", omit)); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 329 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 330 | /* MSC -> OSC: After MT user has picked up and sent CC CONNECT */ |
| 331 | MNCC.send(ts_MNCC_SETUP_CNF(cp.mncc_call_id)); |
| 332 | |
| 333 | SIP.clear; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 334 | /* MSC <- OSC: OSC asks MSC to connect its RTP stream to remote end */ |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 335 | MNCC.receive(tr_MNCC_RTP_CONNECT(cp.mncc_call_id, f_addrstr2addr(cp.sip_rtp_addr), cp.sip_rtp_port)) |
| 336 | -> value mncc { |
| 337 | check_sdp(sdp_to_msc, mncc.u.rtp.sdp, expect_sdp_to_msc); |
| 338 | } |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 339 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 340 | /* OSC -> SIP: OSC confirms call establishment to SIP side */ |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 341 | as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, contact_addr := ?, |
| 342 | method := "INVITE", status_code := 200, |
| 343 | seq_nr := ?, reason := "OK", |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 344 | body := expect_sdp_to_sip)); |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 345 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 346 | /* OSC <- SIP: SIP world acknowledges "200 OK" */ |
| 347 | SIP.send(ts_SIP_ACK(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm, |
| 348 | cp.comp.sip_seq_nr, omit)); |
| 349 | /* MSC <- OSC: OSC sends SETUP COMPL to MNCC (which triggers CC CONNECT ACK */ |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 350 | MNCC.receive(tr_MNCC_SETUP_COMPL_req(cp.mncc_call_id)) -> value mncc { |
| 351 | check_sdp(sdp_to_msc, mncc.u.signal.sdp, expect_sdp_to_msc); |
| 352 | } |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 353 | } |
| 354 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 355 | /* Establish a mobile originated call described in 'cp' */ |
| 356 | function f_establish_mo(inout CallPars cp) runs on ConnHdlr { |
| 357 | var MNCC_number dst := valueof(ts_MNCC_number(cp.called, GSM48_TON_UNKNOWN)); |
| 358 | var MNCC_number src := valueof(ts_MNCC_number(cp.calling, GSM48_TON_UNKNOWN)); |
| 359 | var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm); |
| 360 | var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext); |
| 361 | var PDU_SIP_Request sip_req; |
| 362 | var integer seq_nr; |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 363 | var MNCC_PDU mncc; |
| 364 | |
| 365 | /* The last SDP that the MSC received via MNCC from osmo-sip-connector */ |
| 366 | var charstring sdp_to_msc := ""; |
| 367 | /* At first, allow any empty and nonempty SDP. As the test progresses, this may expect specific SDP instead. */ |
| 368 | var template charstring expect_sdp_to_msc := *; |
| 369 | |
| 370 | /* If cp.mncc_with_sdp == true, expect SDP forwarding like this: |
| 371 | * |
| 372 | * SDP1: osmo-msc's RTP and codec info |
| 373 | * SDP2: SIP agent's RTP and codec info |
| 374 | * |
| 375 | * MNCC osmo-sip-connector SIP |
| 376 | * -------SDP1-->| MNCC SETUP ind |
| 377 | * <-------------| MNCC RTP CREATE (?) |
| 378 | * |-----SDP1--> SIP Invite |
| 379 | * |<----------- SIP (Invite) Trying |
| 380 | * <-------------| MNCC CALL PROC req |
| 381 | * |<----------- SIP (Invite) Ringing |
| 382 | * <-------------| MNCC ALERT req |
| 383 | * | (MT picks up) |
| 384 | * |<--SDP2----- SIP (Invite) OK |
| 385 | * <--SDP2-------| MNCC RTP CONNECT (SDP optional, still unchanged from SDP2) |
| 386 | * <-------------| MNCC SETUP rsp (SDP optional, still unchanged from SDP2) |
| 387 | * ------------->| MNCC SETUP COMPL ind (SDP optional, still unchanged from SDP1) |
| 388 | * |------------> SIP ACK |
| 389 | */ |
| 390 | |
| 391 | var charstring cn_sdp := "v=0\r\no=Osmocom 0 0 IN IP4 1.1.1.1\r\ns=GSM Call\r\nc=IN " & |
Pau Espin Pedrol | f371375 | 2024-03-21 17:32:55 +0100 | [diff] [blame^] | 392 | f_sdp_addr2addrtype(cp.cn_rtp_addr) & " " & cp.cn_rtp_addr & |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 393 | "\r\nt=0 0\r\nm=audio " & int2str(cp.cn_rtp_port) & |
| 394 | " RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 395 | |
| 396 | f_create_sip_expect(cp.comp.sip_url_ext.addr.nameAddr.addrSpec); |
| 397 | |
| 398 | /* MSC -> OSC: MSC sends SETUP.ind after CC SETUP was received from MS */ |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 399 | mncc := valueof(ts_MNCC_SETUP_ind(cp.mncc_call_id, dst, src, "262420123456789")); |
| 400 | if (cp.mncc_with_sdp) { |
| 401 | mncc.u.signal.sdp := cn_sdp; |
| 402 | } |
| 403 | MNCC.send(mncc); |
| 404 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 405 | /* MSC <- OSC: Create GSM side RTP socket */ |
| 406 | MNCC.receive(tr_MNCC_RTP_CREATE(cp.mncc_call_id)) { |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 407 | mncc := valueof(ts_MNCC_RTP_CREATE(cp.mncc_call_id)); |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 408 | mncc.u.rtp.payload_msg_type := oct2int('0300'O); |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 409 | /* FIXME: makes no sense to send cp.cn_rtp_addr back to the cn. */ |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 410 | mncc.u.rtp.is_ipv6 := f_addr_is_ipv6(cp.cn_rtp_addr); |
| 411 | mncc.u.rtp.ip := f_addrstr2addr(cp.cn_rtp_addr); |
| 412 | mncc.u.rtp.rtp_port := cp.cn_rtp_port; |
| 413 | MNCC.send(mncc); |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 414 | } |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 415 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 416 | /* OSC -> SIP: Send INVITE with GSM side IP/Port in SDP */ |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 417 | var template charstring expect_sdp_to_sip := ?; |
| 418 | if (cp.mncc_with_sdp) { |
| 419 | /* Expect the same SDP as sent to osmo-sip-connector in MNCC, and allow osmo-sip-connector to append an |
| 420 | * "a=sendrecv;" */ |
| 421 | expect_sdp_to_sip := pattern cn_sdp & "*"; |
| 422 | } |
| 423 | sip_req := f_SIP_expect_req(tr_SIP_INVITE(?, sip_addr_gsm, sip_addr_ext, ?, expect_sdp_to_sip)); |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 424 | cp.comp.sip_url_gsm.params := sip_req.msgHeader.fromField.fromParams; |
| 425 | cp.comp.sip_call_id := sip_req.msgHeader.callId.callid; |
| 426 | seq_nr := sip_req.msgHeader.cSeq.seqNumber; |
| 427 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 428 | /* OSC <- SIP: Notify call is proceeding */ |
| 429 | SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext, |
| 430 | "INVITE", 100, seq_nr, "Trying", sip_req.msgHeader.via)); |
| 431 | /* MSC <- OSC: "100 Trying" translated to MNCC_CALL_PROC_REQ */ |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 432 | MNCC.receive(tr_MNCC_CALL_PROC_req(cp.mncc_call_id)) -> value mncc { |
| 433 | check_sdp(sdp_to_msc, mncc.u.signal.sdp, ""); |
| 434 | } |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 435 | |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 436 | /* OSC <- SIP: SIP-terminated user is ringing now. 180 Ringing should not contain any SDP. */ |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 437 | SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext, |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 438 | "INVITE", 180, seq_nr, "Ringing", sip_req.msgHeader.via, omit)); |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 439 | |
| 440 | /* MSC <- OSC: "180 Ringing" translated to MNCC_ALERT_REQ */ |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 441 | MNCC.receive(tr_MNCC_ALERT_req(cp.mncc_call_id)) -> value mncc { |
| 442 | check_sdp(sdp_to_msc, mncc.u.signal.sdp, expect_sdp_to_msc); |
| 443 | } |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 444 | |
| 445 | /* OSC <- SIP: SIP-terminated user has accepted the call */ |
| 446 | SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext, |
| 447 | "INVITE", 200, seq_nr, "OK", sip_req.msgHeader.via, |
| 448 | cp.comp.sip_body)); |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 449 | |
| 450 | if (cp.mncc_with_sdp) { |
| 451 | /* If we expect SDP forwarding, from now on expect MNCC to reflect the SDP that we just sent on SIP. */ |
| 452 | expect_sdp_to_msc := cp.comp.sip_body; |
| 453 | } |
| 454 | /* If we don't expect SDP forwarding, just keep expect_sdp_to_msc := *. */ |
| 455 | |
| 456 | MNCC.receive(tr_MNCC_RTP_CONNECT(cp.mncc_call_id)) -> value mncc { |
| 457 | check_sdp(sdp_to_msc, mncc.u.rtp.sdp, expect_sdp_to_msc); |
| 458 | } |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 459 | /* MSC <- OSC: "200 OK" translated to MNCC_SETUP_RSP */ |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 460 | MNCC.receive(tr_MNCC_SETUP_rsp(cp.mncc_call_id)) -> value mncc { |
| 461 | check_sdp(sdp_to_msc, mncc.u.signal.sdp, expect_sdp_to_msc); |
| 462 | } |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 463 | |
| 464 | /* MSC -> OSC: CC CONNECT ACK was received from MS */ |
| 465 | MNCC.send(ts_MNCC_SETUP_COMPL_ind(cp.mncc_call_id)); |
| 466 | /* OSC -> SIP: Acknowledge the call */ |
| 467 | SIP.receive(tr_SIP_ACK(cp.comp.sip_call_id, sip_addr_gsm, sip_addr_ext, ?, omit)); |
| 468 | } |
| 469 | |
| 470 | /* Release call from the mobile side */ |
| 471 | function f_release_mobile(inout CallPars cp) runs on ConnHdlr { |
| 472 | var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm); |
| 473 | var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext); |
| 474 | var PDU_SIP_Request sip_req; |
| 475 | SIP.clear; |
| 476 | /* MSC -> OSC: Simulate a CC DISCONNET from the MT user */ |
| 477 | MNCC.send(ts_MNCC_DISC_ind(cp.mncc_call_id, ts_MNCC_cause(0))); |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 478 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 479 | /* OSC -> SIP: Expect BYE from OSC to SIP side */ |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 480 | sip_req := f_SIP_expect_req(tr_SIP_BYE(cp.comp.sip_call_id, sip_addr_gsm, sip_addr_ext, ?, *)); |
| 481 | cp.comp.sip_url_gsm.params := sip_req.msgHeader.fromField.fromParams; |
| 482 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 483 | /* OSC <- SIP: Acknowledge the BYE */ |
| 484 | SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext, |
| 485 | "BYE", 200, sip_req.msgHeader.cSeq.seqNumber, "OK", |
| 486 | sip_req.msgHeader.via)); |
| 487 | /* MSC <- OSC: Send REL_REQ to MSC, triggers CC RELEASE REQ to MS */ |
| 488 | MNCC.receive(tr_MNCC_REL_req(cp.mncc_call_id)); // CAUSE? |
| 489 | /* MSC -> OSC: MS has responded with CC CLEAR COMPL, triggers MNCC_REL_CNF */ |
| 490 | MNCC.send(ts_MNCC_REL_cnf(cp.mncc_call_id, ts_MNCC_cause(0))); |
| 491 | } |
| 492 | |
| 493 | /* Release call from the SIP side */ |
| 494 | function f_release_sip(inout CallPars cp) runs on ConnHdlr { |
| 495 | var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm); |
| 496 | var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext); |
| 497 | /* OSC <- SIP: SIP-side sends a BYE to OSC */ |
| 498 | SIP.send(ts_SIP_BYE(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm, |
| 499 | cp.comp.sip_seq_nr, omit)); |
| 500 | /* MSC <- OSC: Expect OSC to cause MNCC Disconnect Request */ |
| 501 | MNCC.receive(tr_MNCC_DISC_req(cp.mncc_call_id)); |
| 502 | /* MSC -> OSC: Indicate GSM side release */ |
| 503 | MNCC.send(ts_MNCC_REL_ind(cp.mncc_call_id, ts_MNCC_cause(0))); |
| 504 | /* OSC -> SIP: Confirmation to SIP side */ |
Neels Hofmeyr | c35b657 | 2023-09-12 02:16:43 +0200 | [diff] [blame] | 505 | as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *, |
| 506 | "BYE", 200, cp.comp.sip_seq_nr, "OK", omit)); |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | /* Successful MT Call, which is subsequently released by GSM side */ |
| 510 | private function f_TC_mt_success_rel_gsm(charstring id) runs on ConnHdlr { |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 511 | var CallPars cp := g_pars.g_cp; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 512 | f_CallPars_compute(cp); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 513 | cp.comp.sip_body := "v=0\r\no=Osmocom 0 0 IN IP4 1.1.1.1\r\ns=GSM Call\r\nc=IN " & |
Pau Espin Pedrol | f371375 | 2024-03-21 17:32:55 +0100 | [diff] [blame^] | 514 | f_sdp_addr2addrtype(cp.sip_rtp_addr) & " " & cp.sip_rtp_addr & |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 515 | "\r\nt=0 0\r\nm=audio " & int2str(cp.sip_rtp_port) & |
| 516 | " RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 517 | f_sleep(3.0) |
| 518 | |
| 519 | f_establish_mt(cp); |
| 520 | /* now call is fully established */ |
| 521 | f_sleep(2.0); |
| 522 | f_release_mobile(cp); |
| 523 | setverdict(pass); |
| 524 | } |
| 525 | testcase TC_mt_success_rel_gsm() runs on test_CT { |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 526 | var ConnHdlrPars pars; |
| 527 | var ConnHdlr vc_conn; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 528 | f_init(); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 529 | pars := valueof(t_Pars); |
Neels Hofmeyr | a0d015b | 2023-09-13 04:32:14 +0200 | [diff] [blame] | 530 | pars.g_cp := valueof(t_CallPars(false, false)); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 531 | vc_conn := f_start_handler(refers(f_TC_mt_success_rel_gsm), pars); |
| 532 | vc_conn.done; |
| 533 | } |
| 534 | testcase TC_mt_success_rel_gsm_ipv6() runs on test_CT { |
| 535 | var ConnHdlrPars pars; |
| 536 | var ConnHdlr vc_conn; |
| 537 | f_init(); |
| 538 | pars := valueof(t_Pars); |
Neels Hofmeyr | a0d015b | 2023-09-13 04:32:14 +0200 | [diff] [blame] | 539 | pars.g_cp := valueof(t_CallPars(false, false)); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 540 | pars.g_cp.sip_rtp_addr := "::1"; |
| 541 | pars.g_cp.cn_rtp_addr := "::2"; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 542 | vc_conn := f_start_handler(refers(f_TC_mt_success_rel_gsm), pars); |
| 543 | vc_conn.done; |
| 544 | } |
| 545 | |
| 546 | /* Successful MT Call, which is subsequently released by SIP side */ |
| 547 | private function f_TC_mt_success_rel_sip(charstring id) runs on ConnHdlr { |
Neels Hofmeyr | fb7f43b | 2023-09-13 05:42:41 +0200 | [diff] [blame] | 548 | var CallPars cp := g_pars.g_cp; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 549 | f_CallPars_compute(cp); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 550 | cp.comp.sip_body := "v=0\r\no=Osmocom 0 0 IN IP4 1.1.1.1\r\ns=GSM Call\r\nc=IN " & |
Pau Espin Pedrol | f371375 | 2024-03-21 17:32:55 +0100 | [diff] [blame^] | 551 | f_sdp_addr2addrtype(cp.sip_rtp_addr) & " " & cp.sip_rtp_addr & |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 552 | "\r\nt=0 0\r\nm=audio " & int2str(cp.sip_rtp_port) & |
| 553 | " RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 554 | f_sleep(3.0) |
| 555 | |
| 556 | f_establish_mt(cp); |
| 557 | /* now call is fully established */ |
| 558 | f_sleep(2.0); |
| 559 | f_release_sip(cp); |
| 560 | setverdict(pass); |
| 561 | } |
| 562 | testcase TC_mt_success_rel_sip() runs on test_CT { |
| 563 | var ConnHdlrPars pars; |
| 564 | var ConnHdlr vc_conn; |
| 565 | f_init(); |
| 566 | pars := valueof(t_Pars); |
Neels Hofmeyr | a0d015b | 2023-09-13 04:32:14 +0200 | [diff] [blame] | 567 | pars.g_cp := valueof(t_CallPars(false, false)); |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 568 | 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] | 569 | vc_conn.done; |
| 570 | } |
| 571 | |
| 572 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 573 | /* Successful MO Call, which is subsequently released by GSM side */ |
| 574 | private function f_TC_mo_success_rel_gsm(charstring id) runs on ConnHdlr { |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 575 | var CallPars cp := g_pars.g_cp; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 576 | f_CallPars_compute(cp); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 577 | cp.comp.sip_body := "v=0\r\no=Osmocom 0 0 IN IP4 1.1.1.1\r\ns=GSM Call\r\nc=IN " & |
Pau Espin Pedrol | f371375 | 2024-03-21 17:32:55 +0100 | [diff] [blame^] | 578 | f_sdp_addr2addrtype(cp.sip_rtp_addr) & " " & cp.sip_rtp_addr & |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 579 | "\r\nt=0 0\r\nm=audio " & int2str(cp.sip_rtp_port) & |
| 580 | " RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 581 | f_sleep(3.0) |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 582 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 583 | f_establish_mo(cp); |
| 584 | /* now call is fully established */ |
| 585 | f_sleep(2.0); |
| 586 | f_release_mobile(cp); |
| 587 | setverdict(pass); |
| 588 | } |
| 589 | testcase TC_mo_success_rel_gsm() runs on test_CT { |
| 590 | var ConnHdlrPars pars; |
| 591 | var ConnHdlr vc_conn; |
| 592 | f_init(); |
| 593 | pars := valueof(t_Pars); |
Neels Hofmeyr | a0d015b | 2023-09-13 04:32:14 +0200 | [diff] [blame] | 594 | pars.g_cp := valueof(t_CallPars(true, false)); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 595 | vc_conn := f_start_handler(refers(f_TC_mo_success_rel_gsm), pars); |
| 596 | vc_conn.done; |
| 597 | } |
| 598 | testcase TC_mo_success_rel_gsm_ipv6() runs on test_CT { |
| 599 | var ConnHdlrPars pars; |
| 600 | var ConnHdlr vc_conn; |
| 601 | f_init(); |
| 602 | pars := valueof(t_Pars); |
Neels Hofmeyr | a0d015b | 2023-09-13 04:32:14 +0200 | [diff] [blame] | 603 | pars.g_cp := valueof(t_CallPars(true, false)); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 604 | pars.g_cp.sip_rtp_addr := "::1"; |
| 605 | pars.g_cp.cn_rtp_addr := "::2"; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 606 | vc_conn := f_start_handler(refers(f_TC_mo_success_rel_gsm), pars); |
| 607 | vc_conn.done; |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 608 | } |
| 609 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 610 | /* Successful MO Call, which is subsequently released by SIP side */ |
| 611 | private function f_TC_mo_success_rel_sip(charstring id) runs on ConnHdlr { |
Neels Hofmeyr | fb7f43b | 2023-09-13 05:42:41 +0200 | [diff] [blame] | 612 | var CallPars cp := g_pars.g_cp; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 613 | f_CallPars_compute(cp); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 614 | cp.comp.sip_body := "v=0\r\no=Osmocom 0 0 IN IP4 1.1.1.1\r\ns=GSM Call\r\nc=IN " & |
Pau Espin Pedrol | f371375 | 2024-03-21 17:32:55 +0100 | [diff] [blame^] | 615 | f_sdp_addr2addrtype(cp.sip_rtp_addr) & " " & cp.sip_rtp_addr & |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 616 | "\r\nt=0 0\r\nm=audio " & int2str(cp.sip_rtp_port) & |
| 617 | " RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 618 | f_sleep(3.0) |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 619 | |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 620 | f_establish_mo(cp); |
| 621 | /* now call is fully established */ |
| 622 | f_sleep(2.0); |
| 623 | f_release_sip(cp); |
| 624 | setverdict(pass); |
| 625 | } |
| 626 | testcase TC_mo_success_rel_sip() runs on test_CT { |
| 627 | var ConnHdlrPars pars; |
| 628 | var ConnHdlr vc_conn; |
| 629 | f_init(); |
| 630 | pars := valueof(t_Pars); |
Neels Hofmeyr | a0d015b | 2023-09-13 04:32:14 +0200 | [diff] [blame] | 631 | pars.g_cp := valueof(t_CallPars(is_mo := true, mncc_with_sdp := false)); |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 632 | vc_conn := f_start_handler(refers(f_TC_mo_success_rel_sip), pars); |
| 633 | vc_conn.done; |
| 634 | } |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 635 | |
Harald Welte | ddf011e | 2019-04-19 09:39:35 +0200 | [diff] [blame] | 636 | /* SETUP followed by DISC results in lingering B-leg (OS#3518)*/ |
| 637 | private function f_TC_mo_setup_disc_late_rtp(charstring id) runs on ConnHdlr { |
Neels Hofmeyr | fb7f43b | 2023-09-13 05:42:41 +0200 | [diff] [blame] | 638 | var CallPars cp := g_pars.g_cp; |
Harald Welte | ddf011e | 2019-04-19 09:39:35 +0200 | [diff] [blame] | 639 | f_CallPars_compute(cp); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 640 | cp.comp.sip_body := "v=0\r\no=Osmocom 0 0 IN IP4 1.1.1.1\r\ns=GSM Call\r\nc=IN " & |
Pau Espin Pedrol | f371375 | 2024-03-21 17:32:55 +0100 | [diff] [blame^] | 641 | f_sdp_addr2addrtype(cp.sip_rtp_addr) & " " & cp.sip_rtp_addr & |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 642 | "\r\nt=0 0\r\nm=audio " & int2str(cp.sip_rtp_port) & |
| 643 | " RTP/AVP 0\r\na=rtpmap:0 GSM/8000\r\n"; |
Harald Welte | ddf011e | 2019-04-19 09:39:35 +0200 | [diff] [blame] | 644 | f_sleep(3.0); |
| 645 | |
| 646 | var MNCC_number dst := valueof(ts_MNCC_number(cp.called, GSM48_TON_UNKNOWN)); |
| 647 | var MNCC_number src := valueof(ts_MNCC_number(cp.calling, GSM48_TON_UNKNOWN)); |
| 648 | var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm); |
| 649 | var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext); |
| 650 | |
| 651 | f_create_sip_expect(cp.comp.sip_url_ext.addr.nameAddr.addrSpec); |
| 652 | |
| 653 | /* MSC -> OSC: MSC sends SETUP.ind after CC SETUP was received from MS */ |
| 654 | MNCC.send(ts_MNCC_SETUP_ind(cp.mncc_call_id, dst, src, "262420123456789")); |
| 655 | |
| 656 | /* MSC -> OSC: Simulate a CC DISCONNET from the MT user *before* responding to the RTP_CREATE */ |
| 657 | MNCC.send(ts_MNCC_DISC_ind(cp.mncc_call_id, ts_MNCC_cause(0))); |
| 658 | |
| 659 | /* MSC <- OSC: Create GSM side RTP socket (too late) */ |
| 660 | MNCC.receive(tr_MNCC_RTP_CREATE(cp.mncc_call_id)) { |
| 661 | var MNCC_PDU mncc := valueof(ts_MNCC_RTP_CREATE(cp.mncc_call_id)); |
| 662 | mncc.u.rtp.payload_msg_type := oct2int('0300'O); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 663 | mncc.u.rtp.is_ipv6 := f_addr_is_ipv6(cp.cn_rtp_addr); |
| 664 | mncc.u.rtp.ip := f_addrstr2addr(cp.cn_rtp_addr); |
| 665 | mncc.u.rtp.rtp_port := cp.cn_rtp_port; |
| 666 | MNCC.send(mncc); |
Harald Welte | ddf011e | 2019-04-19 09:39:35 +0200 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | /* OSC -> SIP: We should never receive INVITE */ |
| 670 | timer T := 10.0; |
| 671 | T.start; |
| 672 | alt { |
| 673 | [] SIP.receive(tr_SIP_INVITE(?, sip_addr_gsm, sip_addr_ext, ?, ?)) { |
| 674 | setverdict(fail, "Received unexpected INVITE"); |
| 675 | } |
| 676 | [] T.timeout { |
| 677 | setverdict(pass); |
| 678 | } |
| 679 | } |
| 680 | } |
| 681 | testcase TC_mo_setup_disc_late_rtp() runs on test_CT { |
| 682 | var ConnHdlrPars pars; |
| 683 | var ConnHdlr vc_conn; |
| 684 | f_init(); |
| 685 | pars := valueof(t_Pars); |
Neels Hofmeyr | a0d015b | 2023-09-13 04:32:14 +0200 | [diff] [blame] | 686 | pars.g_cp := valueof(t_CallPars(is_mo := true, mncc_with_sdp := false)); |
Harald Welte | ddf011e | 2019-04-19 09:39:35 +0200 | [diff] [blame] | 687 | vc_conn := f_start_handler(refers(f_TC_mo_setup_disc_late_rtp), pars); |
| 688 | vc_conn.done; |
| 689 | } |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 690 | |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 691 | testcase TC_mt_with_sdp() runs on test_CT { |
| 692 | var ConnHdlrPars pars; |
| 693 | var ConnHdlr vc_conn; |
| 694 | f_init(); |
| 695 | pars := valueof(t_Pars); |
| 696 | pars.g_cp := valueof(t_CallPars(is_mo := false, mncc_with_sdp := true)); |
| 697 | vc_conn := f_start_handler(refers(f_TC_mt_success_rel_gsm), pars); |
| 698 | vc_conn.done; |
| 699 | } |
| 700 | |
| 701 | testcase TC_mo_with_sdp() runs on test_CT { |
| 702 | var ConnHdlrPars pars; |
| 703 | var ConnHdlr vc_conn; |
| 704 | f_init(); |
| 705 | pars := valueof(t_Pars); |
| 706 | pars.g_cp := valueof(t_CallPars(is_mo := true, mncc_with_sdp := true)); |
| 707 | vc_conn := f_start_handler(refers(f_TC_mo_success_rel_sip), pars); |
| 708 | vc_conn.done; |
| 709 | } |
| 710 | |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 711 | control { |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 712 | execute( TC_mt_success_rel_gsm() ); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 713 | execute( TC_mt_success_rel_gsm_ipv6() ); |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 714 | execute( TC_mt_success_rel_sip() ); |
| 715 | execute( TC_mo_success_rel_gsm() ); |
Pau Espin Pedrol | bdd874a | 2020-09-10 19:09:47 +0200 | [diff] [blame] | 716 | execute( TC_mo_success_rel_gsm_ipv6() ); |
Harald Welte | b0d9360 | 2018-03-20 18:09:34 +0100 | [diff] [blame] | 717 | execute( TC_mo_success_rel_sip() ); |
Harald Welte | ddf011e | 2019-04-19 09:39:35 +0200 | [diff] [blame] | 718 | execute( TC_mo_setup_disc_late_rtp() ); |
Neels Hofmeyr | 2e3a0e2 | 2023-09-12 02:09:48 +0200 | [diff] [blame] | 719 | execute( TC_mt_with_sdp() ); |
| 720 | execute( TC_mo_with_sdp() ); |
Harald Welte | afec471 | 2018-03-19 22:52:17 +0100 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | |
| 724 | |
| 725 | } |