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