Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 1 | module MSC_ConnectionHandler { |
| 2 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 3 | /* MSC Connection HAndler of BSC Tests in TTCN-3 |
| 4 | * (C) 2017-2019 Harald Welte <laforge@gnumonks.org> |
| 5 | * contributions by sysmocom - s.f.m.c. GmbH |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | */ |
| 13 | |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 14 | import from Misc_Helpers all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 15 | import from General_Types all; |
| 16 | import from Osmocom_Types all; |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 17 | import from GSM_Types all; |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 18 | import from IPA_Emulation all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 19 | import from SCCPasp_Types all; |
| 20 | import from BSSAP_Types all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 21 | import from RAN_Emulation all; |
Harald Welte | 47cd0e3 | 2020-08-21 12:39:11 +0200 | [diff] [blame] | 22 | import from BSSAP_LE_Emulation all; |
| 23 | import from BSSAP_LE_Types all; |
| 24 | import from BSSMAP_LE_Templates all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 25 | import from BSSMAP_Templates all; |
| 26 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 27 | import from IPL4asp_Types all; |
| 28 | import from Native_Functions all; |
| 29 | |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 30 | import from MGCP_CodecPort all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 31 | import from MGCP_Types all; |
| 32 | import from MGCP_Templates all; |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 33 | import from MGCP_Emulation all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 34 | import from SDP_Types all; |
| 35 | |
Daniel Willmann | ebdecc0 | 2020-08-12 15:30:17 +0200 | [diff] [blame] | 36 | import from StatsD_Checker all; |
| 37 | |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 38 | import from RSL_Emulation all; |
| 39 | import from RSL_Types all; |
| 40 | |
| 41 | import from MobileL3_Types all; |
| 42 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 43 | import from MobileL3_RRM_Types all; |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 44 | import from L3_Templates all; |
| 45 | |
Harald Welte | c20b1c4 | 2018-02-12 20:50:08 +0100 | [diff] [blame] | 46 | import from TELNETasp_PortType all; |
| 47 | import from Osmocom_VTY_Functions all; |
Neels Hofmeyr | c2425cc | 2021-04-19 13:19:55 +0000 | [diff] [blame] | 48 | import from TCCConversion_Functions all; |
Harald Welte | c20b1c4 | 2018-02-12 20:50:08 +0100 | [diff] [blame] | 49 | |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 50 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 51 | /*********************************************************************** |
| 52 | * Media related handling |
| 53 | ***********************************************************************/ |
| 54 | |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 55 | /* TODO: import OSMUX_Types.ttcn */ |
| 56 | type INT1 OsmuxCID (0 .. 255); |
| 57 | |
Philipp Maier | 11a5894 | 2018-06-25 16:40:48 +0200 | [diff] [blame] | 58 | /* Get the matching payload type for a specified BSSAP codec type |
| 59 | * (see also: BSSAP_Types.ttcn */ |
| 60 | private function f_get_mgcp_pt(BSSMAP_FIELD_CodecType codecType) return SDP_FIELD_PayloadType { |
| 61 | if (codecType == GSM_FR) { |
| 62 | return PT_GSM; |
| 63 | } else if (codecType == GSM_HR) { |
| 64 | return PT_GSMHR; |
| 65 | } else if (codecType == GSM_EFR) { |
| 66 | return PT_GSMEFR; |
| 67 | } else if (codecType == FR_AMR or codecType == HR_AMR) { |
| 68 | return PT_AMR; |
| 69 | } else if (codecType == FR_AMR_WB or codecType == OHR_AMR or codecType == OFR_AMR_WB or codecType == OHR_AMR_WB) { |
| 70 | return PT_AMRWB; |
| 71 | } |
| 72 | |
| 73 | return PT_PCMU; |
| 74 | } |
| 75 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 76 | /* Tuple containing host/ip and port */ |
| 77 | type record HostPort { |
| 78 | HostName host, |
| 79 | PortNumber port_nr |
| 80 | }; |
| 81 | |
| 82 | /* State encapsulating one MGCP Connection */ |
| 83 | type record MgcpConnState { |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 84 | integer crcx_seen, /* Counts how many CRCX operations happend */ |
| 85 | integer mdcx_seen, /* Counts how many MDCX operations happend C */ |
| 86 | integer crcx_seen_exp, /* Sets the expected number of CRCX operations */ |
| 87 | integer mdcx_seen_exp, /* Sets the expected number of MDCX operations */ |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 88 | MgcpConnectionId conn_id, |
| 89 | charstring mime_type, /* e.g. AMR */ |
| 90 | integer sample_rate, /* 8000 */ |
| 91 | integer ptime, /* 20 */ |
| 92 | uint7_t rtp_pt, /* RTP Payload Type */ |
| 93 | HostPort mgw, /* MGW side */ |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 94 | HostPort peer, /* CA side */ |
| 95 | OsmuxCID local_osmux_cid optional, |
| 96 | OsmuxCID remote_osmux_cid optional |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | /* BTS media state */ |
| 100 | type record BtsMediaState { |
| 101 | boolean ipa_crcx_seen, |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 102 | boolean ipa_mdcx_seen, |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 103 | uint16_t conn_id, |
| 104 | uint7_t rtp_pt, |
| 105 | HostPort bts, |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 106 | HostPort peer, |
| 107 | OsmuxCID local_osmux_cid optional, |
| 108 | OsmuxCID remote_osmux_cid optional |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | type record MediaState { |
| 112 | MgcpEndpoint mgcp_ep, |
| 113 | MgcpConnState mgcp_conn[2], |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 114 | BtsMediaState bts, |
| 115 | BtsMediaState bts1 /* only during hand-over */ |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 116 | }; |
| 117 | |
Philipp Maier | 11a5894 | 2018-06-25 16:40:48 +0200 | [diff] [blame] | 118 | function f_MediaState_init(inout MediaState g_media, integer nr, HostName bts, HostName mgw, BSSMAP_FIELD_CodecType codecType) { |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 119 | /* BTS Side */ |
| 120 | g_media.bts := { |
| 121 | ipa_crcx_seen := false, |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 122 | ipa_mdcx_seen := false, |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 123 | conn_id := nr, |
| 124 | rtp_pt := 0, |
| 125 | bts := { |
| 126 | host := bts, |
| 127 | port_nr := 9000 + nr*2 |
| 128 | }, |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 129 | peer := -, |
| 130 | local_osmux_cid := nr, |
| 131 | remote_osmux_cid := omit |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 132 | } |
| 133 | |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 134 | g_media.bts1 := { |
| 135 | ipa_crcx_seen := false, |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 136 | ipa_mdcx_seen := false, |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 137 | conn_id := nr, |
| 138 | rtp_pt := 0, |
| 139 | bts := { |
| 140 | host := bts, /* FIXME */ |
| 141 | port_nr := 9000 + nr*2 |
| 142 | }, |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 143 | peer := -, |
| 144 | local_osmux_cid := nr, |
| 145 | remote_osmux_cid := omit |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 146 | } |
| 147 | |
Harald Welte | 363cb0a | 2018-01-30 19:35:53 +0100 | [diff] [blame] | 148 | g_media.mgcp_ep := "rtpbridge/" & int2str(nr) & "@mgw"; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 149 | |
| 150 | for (var integer i:= 0; i < sizeof(g_media.mgcp_conn); i := i+1) { |
Philipp Maier | 11a5894 | 2018-06-25 16:40:48 +0200 | [diff] [blame] | 151 | g_media.mgcp_conn[i].mime_type := f_encoding_name_from_pt(f_get_mgcp_pt(codecType)); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 152 | g_media.mgcp_conn[i].sample_rate := 8000; |
| 153 | g_media.mgcp_conn[i].ptime := 20; |
Philipp Maier | 11a5894 | 2018-06-25 16:40:48 +0200 | [diff] [blame] | 154 | g_media.mgcp_conn[i].rtp_pt := enum2int(f_get_mgcp_pt(codecType)); |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 155 | g_media.mgcp_conn[i].crcx_seen := 0; |
| 156 | g_media.mgcp_conn[i].mdcx_seen := 0; |
| 157 | g_media.mgcp_conn[i].crcx_seen_exp := 0; |
| 158 | g_media.mgcp_conn[i].mdcx_seen_exp := 0; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 159 | g_media.mgcp_conn[i].conn_id := f_mgcp_alloc_conn_id(); |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 160 | g_media.mgcp_conn[i].local_osmux_cid := i; |
| 161 | g_media.mgcp_conn[i].remote_osmux_cid := omit; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | g_media.mgcp_conn[0].mgw := { |
| 165 | host := mgw, |
| 166 | port_nr := 10000 + nr*2 |
| 167 | } |
| 168 | g_media.mgcp_conn[1].mgw := { |
| 169 | host := mgw, |
| 170 | port_nr := 11000 + nr*2 |
| 171 | } |
| 172 | } |
| 173 | |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 174 | /* Helper function to get the next free MGCP connection identifier. We can |
| 175 | * recognize free connection identifiers by the fact that no CRCX happend yet */ |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 176 | private function f_get_free_mgcp_conn() runs on MSC_ConnHdlr return integer { |
| 177 | for (var integer i:= 0; i < sizeof(g_media.mgcp_conn); i := i+1) { |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 178 | if (not g_media.mgcp_conn[i].crcx_seen >= 1) { |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 179 | return i; |
| 180 | } |
| 181 | } |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 182 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Only 2 Connections per EP!"); |
| 183 | /* Should never be reached */ |
| 184 | return -1; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 185 | } |
| 186 | |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 187 | /* Helper function to pick a specific connection by its cid. Since we reach out |
| 188 | * for a connection that is in-use we also check if there was already exactly |
| 189 | * one CRCX happening on that connection. */ |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 190 | private function f_get_mgcp_conn(MgcpConnectionId cid) runs on MSC_ConnHdlr return integer { |
| 191 | for (var integer i:= 0; i < sizeof(g_media.mgcp_conn); i := i+1) { |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 192 | if (g_media.mgcp_conn[i].conn_id == cid and g_media.mgcp_conn[i].crcx_seen == 1) { |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 193 | return i; |
| 194 | } |
| 195 | } |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 196 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No Connection for ID ", cid)); |
| 197 | /* Should not be reached */ |
| 198 | return -1; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 199 | } |
| 200 | |
Oliver Smith | bc392a8 | 2023-04-17 14:06:42 +0200 | [diff] [blame] | 201 | /* Verify that CSD CRCX/MDCX has the RSL_IE_IPAC_RTP_CSD_FMT IE, and that |
| 202 | * inside it the D value is set to RSL_IPA_RTP_CSD_TRAU_BTS. */ |
| 203 | private function f_ipacc_crcx_mdcx_check_rtp_pt_csd(RSL_Message rsl) runs on MSC_ConnHdlr { |
| 204 | var SDP_FIELD_PayloadType pt_csd := PT_CSD; |
| 205 | var RSL_IE_Body ie; |
| 206 | |
| 207 | if (g_media.bts.rtp_pt != enum2int(pt_csd)) { |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | if (f_rsl_find_ie(rsl, RSL_IE_IPAC_RTP_CSD_FMT, ie)) { |
| 212 | if (ie.ipa_rtp_csd_fmt.d != RSL_IPA_RTP_CSD_TRAU_BTS) { |
| 213 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 214 | "Rx unexpected IPAC CRCX for CSD with RTP_CSD_FMT IE"); |
| 215 | } |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 220 | "Rx unexpected IPAC CRCX for CSD without RTP_CSD_FMT IE"); |
| 221 | } |
| 222 | |
Philipp Maier | b242235 | 2018-07-11 10:36:57 +0200 | [diff] [blame] | 223 | /* altstep for handling of IPACC media related commands. Activated by as_Media() to test |
| 224 | * RSL level media handling */ |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 225 | altstep as_Media_ipacc(RSL_DCHAN_PT rsl_pt := RSL, RSL_DCHAN_PT rsl_pt_ho_target := RSL1) runs on MSC_ConnHdlr { |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 226 | var RSL_Message rsl; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 227 | var RSL_IE_Body ie; |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 228 | var boolean b_unused; |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 229 | [not g_media.bts.ipa_crcx_seen] rsl_pt.receive(tr_RSL_IPA_CRCX(g_chan_nr)) -> value rsl { |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 230 | /* Extract parameters from request + use in response */ |
| 231 | if (f_rsl_find_ie(rsl, RSL_IE_IPAC_RTP_PAYLOAD, ie)) { |
| 232 | g_media.bts.rtp_pt := ie.ipa_rtp_pt; |
| 233 | } |
| 234 | if (f_rsl_find_ie(rsl, RSL_IE_IPAC_RTP_PAYLOAD2, ie)) { |
| 235 | g_media.bts.rtp_pt := ie.ipa_rtp_pt2; |
| 236 | } |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 237 | if (f_rsl_find_ie(rsl, RSL_IE_OSMO_OSMUX_CID, ie)) { |
| 238 | if (not g_pars.use_osmux_bts) { |
| 239 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx unexpected IPAC CRCX with Osmux CID IE"); |
| 240 | } |
| 241 | g_media.bts.remote_osmux_cid := ie.osmux_cid.cid; |
| 242 | } else { |
| 243 | if (g_pars.use_osmux_bts) { |
| 244 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx unexpected IPAC CRCX without Osmux CID IE"); |
| 245 | } |
| 246 | g_media.bts.local_osmux_cid := omit; |
| 247 | g_media.bts.remote_osmux_cid := omit; |
| 248 | } |
Oliver Smith | bc392a8 | 2023-04-17 14:06:42 +0200 | [diff] [blame] | 249 | f_ipacc_crcx_mdcx_check_rtp_pt_csd(rsl); |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 250 | rsl_pt.send(ts_RSL_IPA_CRCX_ACK(g_chan_nr, g_media.bts.conn_id, |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 251 | f_inet_addr(g_media.bts.bts.host), |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 252 | g_media.bts.bts.port_nr, |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 253 | g_media.bts.rtp_pt, |
| 254 | g_media.bts.local_osmux_cid)); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 255 | g_media.bts.ipa_crcx_seen := true; |
| 256 | repeat; |
| 257 | } |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 258 | [g_media.bts.ipa_crcx_seen] rsl_pt.receive(tr_RSL_IPA_MDCX(g_chan_nr, ?)) -> value rsl{ |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 259 | /* Extract conn_id, ip, port, rtp_pt2 from request + use in response */ |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 260 | b_unused := f_rsl_find_ie(rsl, RSL_IE_IPAC_CONN_ID, ie); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 261 | if (g_media.bts.conn_id != ie.ipa_conn_id) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 262 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("IPA MDCX for unknown ConnId", rsl)); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 263 | } |
| 264 | /* mandatory */ |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 265 | b_unused := f_rsl_find_ie(rsl, RSL_IE_IPAC_REMOTE_IP, ie); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 266 | g_media.bts.peer.host := f_inet_ntoa(ie.ipa_remote_ip); |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 267 | b_unused := f_rsl_find_ie(rsl, RSL_IE_IPAC_REMOTE_PORT, ie); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 268 | g_media.bts.peer.port_nr := ie.ipa_remote_port; |
| 269 | /* optional */ |
| 270 | if (f_rsl_find_ie(rsl, RSL_IE_IPAC_RTP_PAYLOAD, ie)) { |
| 271 | g_media.bts.rtp_pt := ie.ipa_rtp_pt; |
| 272 | } |
| 273 | if (f_rsl_find_ie(rsl, RSL_IE_IPAC_RTP_PAYLOAD2, ie)) { |
| 274 | g_media.bts.rtp_pt := ie.ipa_rtp_pt2; |
| 275 | } |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 276 | if (f_rsl_find_ie(rsl, RSL_IE_OSMO_OSMUX_CID, ie)) { |
| 277 | if (not g_pars.use_osmux_bts) { |
| 278 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx unexpected IPAC MDCX with Osmux CID IE"); |
| 279 | } |
| 280 | g_media.bts.remote_osmux_cid := ie.osmux_cid.cid; |
| 281 | } else { |
| 282 | if (g_pars.use_osmux_bts) { |
| 283 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx unexpected IPAC MDCX without Osmux CID IE"); |
| 284 | } |
| 285 | g_media.bts.local_osmux_cid := omit; |
| 286 | g_media.bts.remote_osmux_cid := omit; |
| 287 | } |
Oliver Smith | bc392a8 | 2023-04-17 14:06:42 +0200 | [diff] [blame] | 288 | f_ipacc_crcx_mdcx_check_rtp_pt_csd(rsl); |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 289 | rsl_pt.send(ts_RSL_IPA_MDCX_ACK(g_chan_nr, g_media.bts.conn_id, |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 290 | f_inet_addr(g_media.bts.peer.host), |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 291 | g_media.bts.peer.port_nr, |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 292 | g_media.bts.rtp_pt, |
| 293 | g_media.bts.local_osmux_cid)); |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 294 | g_media.bts.ipa_mdcx_seen := true; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 295 | repeat; |
| 296 | } |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 297 | |
| 298 | /* on second (new) BTS during hand-over */ |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 299 | [not g_media.bts1.ipa_crcx_seen] rsl_pt_ho_target.receive(tr_RSL_IPA_CRCX(g_chan_nr)) -> value rsl { |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 300 | /* Extract parameters from request + use in response */ |
| 301 | if (f_rsl_find_ie(rsl, RSL_IE_IPAC_RTP_PAYLOAD, ie)) { |
| 302 | g_media.bts1.rtp_pt := ie.ipa_rtp_pt; |
| 303 | } |
| 304 | if (f_rsl_find_ie(rsl, RSL_IE_IPAC_RTP_PAYLOAD2, ie)) { |
| 305 | g_media.bts1.rtp_pt := ie.ipa_rtp_pt2; |
| 306 | } |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 307 | if (f_rsl_find_ie(rsl, RSL_IE_OSMO_OSMUX_CID, ie)) { |
| 308 | if (not g_pars.use_osmux_bts) { |
| 309 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx unexpected IPAC CRCX with Osmux CID IE"); |
| 310 | } |
| 311 | g_media.bts.remote_osmux_cid := ie.osmux_cid.cid; |
| 312 | } else { |
| 313 | if (g_pars.use_osmux_bts) { |
| 314 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx unexpected IPAC CRCX without Osmux CID IE"); |
| 315 | } |
| 316 | g_media.bts.local_osmux_cid := omit; |
| 317 | g_media.bts.remote_osmux_cid := omit; |
| 318 | } |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 319 | rsl_pt_ho_target.send(ts_RSL_IPA_CRCX_ACK(g_chan_nr, g_media.bts1.conn_id, |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 320 | f_inet_addr(g_media.bts1.bts.host), |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 321 | g_media.bts1.bts.port_nr, |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 322 | g_media.bts1.rtp_pt, |
| 323 | g_media.bts.local_osmux_cid)); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 324 | g_media.bts1.ipa_crcx_seen := true; |
| 325 | repeat; |
| 326 | } |
| 327 | /* on second (new) BTS during hand-over */ |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 328 | [g_media.bts1.ipa_crcx_seen] rsl_pt_ho_target.receive(tr_RSL_IPA_MDCX(g_chan_nr, ?)) -> value rsl{ |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 329 | /* Extract conn_id, ip, port, rtp_pt2 from request + use in response */ |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 330 | b_unused := f_rsl_find_ie(rsl, RSL_IE_IPAC_CONN_ID, ie); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 331 | if (g_media.bts1.conn_id != ie.ipa_conn_id) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 332 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("IPA MDCX for unknown ConnId", rsl)); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 333 | } |
| 334 | /* mandatory */ |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 335 | b_unused := f_rsl_find_ie(rsl, RSL_IE_IPAC_REMOTE_IP, ie); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 336 | g_media.bts1.peer.host := f_inet_ntoa(ie.ipa_remote_ip); |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 337 | b_unused := f_rsl_find_ie(rsl, RSL_IE_IPAC_REMOTE_PORT, ie); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 338 | g_media.bts1.peer.port_nr := ie.ipa_remote_port; |
| 339 | /* optional */ |
| 340 | if (f_rsl_find_ie(rsl, RSL_IE_IPAC_RTP_PAYLOAD, ie)) { |
| 341 | g_media.bts1.rtp_pt := ie.ipa_rtp_pt; |
| 342 | } |
| 343 | if (f_rsl_find_ie(rsl, RSL_IE_IPAC_RTP_PAYLOAD2, ie)) { |
| 344 | g_media.bts1.rtp_pt := ie.ipa_rtp_pt2; |
| 345 | } |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 346 | if (f_rsl_find_ie(rsl, RSL_IE_OSMO_OSMUX_CID, ie)) { |
| 347 | if (not g_pars.use_osmux_bts) { |
| 348 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx unexpected IPAC MDCX with Osmux CID IE"); |
| 349 | } |
| 350 | g_media.bts.remote_osmux_cid := ie.osmux_cid.cid; |
| 351 | } else { |
| 352 | if (g_pars.use_osmux_bts) { |
| 353 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx unexpected IPAC MDCX without Osmux CID IE"); |
| 354 | } |
| 355 | g_media.bts.local_osmux_cid := omit; |
| 356 | g_media.bts.remote_osmux_cid := omit; |
| 357 | } |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 358 | rsl_pt_ho_target.send(ts_RSL_IPA_MDCX_ACK(g_chan_nr, g_media.bts1.conn_id, |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 359 | f_inet_addr(g_media.bts1.peer.host), |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 360 | g_media.bts1.peer.port_nr, |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 361 | g_media.bts1.rtp_pt, |
| 362 | g_media.bts.local_osmux_cid)); |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 363 | g_media.bts1.ipa_mdcx_seen := true; |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 364 | repeat; |
| 365 | } |
| 366 | |
Philipp Maier | b242235 | 2018-07-11 10:36:57 +0200 | [diff] [blame] | 367 | |
| 368 | } |
| 369 | |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 370 | function f_rx_crcx(MgcpCommand mgcp_cmd) |
| 371 | runs on MSC_ConnHdlr return template MgcpResponse { |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 372 | var SDP_Message sdp; |
| 373 | var integer cid := f_get_free_mgcp_conn(); |
Philipp Maier | a208389 | 2020-09-21 14:18:36 +0200 | [diff] [blame] | 374 | var charstring local_rtp_addr; |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 375 | var MgcpOsmuxCID osmux_cid; |
Philipp Maier | a208389 | 2020-09-21 14:18:36 +0200 | [diff] [blame] | 376 | |
| 377 | if (g_pars.media_mgw_offer_ipv6 == true) { |
| 378 | local_rtp_addr := host_mgw_rtp_v6; /* Use IPv6 by default if no remote addr is provided by client */ |
| 379 | } else { |
| 380 | local_rtp_addr := host_mgw_rtp_v4; /* Use IPv4 by default if no remote addr is provided by client */ |
| 381 | } |
| 382 | |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 383 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { |
| 384 | if (cid != 0) { |
| 385 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "MGCP wildcard EP only works in first CRCX"); |
| 386 | } |
| 387 | /* we keep the endpoint name allocated during MediaState_init */ |
| 388 | } else { |
| 389 | /* Call Agent allocated endpoint, trust/use it always */ |
| 390 | g_media.mgcp_ep := mgcp_cmd.line.ep; |
| 391 | } |
| 392 | if (isvalue(mgcp_cmd.sdp)) { |
| 393 | sdp := mgcp_cmd.sdp; |
| 394 | g_media.mgcp_conn[cid].peer.host := sdp.connection.conn_addr.addr; |
| 395 | g_media.mgcp_conn[cid].peer.port_nr := sdp.media_list[0].media_field.ports.port_number; |
Pau Espin Pedrol | 0786663 | 2020-09-03 19:10:55 +0200 | [diff] [blame] | 396 | if (sdp.connection.addr_type == "IP6") { |
| 397 | local_rtp_addr := host_mgw_rtp_v6; |
| 398 | } else { |
| 399 | local_rtp_addr := host_mgw_rtp_v4; |
| 400 | } |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 401 | } |
| 402 | var MgcpConnState mgcp_conn := g_media.mgcp_conn[cid]; |
Pau Espin Pedrol | 0786663 | 2020-09-03 19:10:55 +0200 | [diff] [blame] | 403 | sdp := valueof(ts_SDP(mgcp_conn.mgw.host, local_rtp_addr, "foo", "21", |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 404 | mgcp_conn.mgw.port_nr, { int2str(mgcp_conn.rtp_pt) }, |
| 405 | {valueof(ts_SDP_rtpmap(mgcp_conn.rtp_pt, |
| 406 | mgcp_conn.mime_type & "/" & |
| 407 | int2str(mgcp_conn.sample_rate))), |
| 408 | valueof(ts_SDP_ptime(mgcp_conn.ptime)) } )); |
| 409 | var template MgcpResponse mgcp_resp; |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 410 | if ((g_pars.use_osmux_cn or g_pars.use_osmux_bts) and |
| 411 | f_MgcpCmd_contains_par(mgcp_cmd, "X-OSMUX")) { |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 412 | osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd); |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 413 | if (osmux_cid != -1) { |
| 414 | mgcp_conn.remote_osmux_cid := osmux_cid; |
| 415 | } |
| 416 | mgcp_resp := ts_CRCX_ACK_osmux(mgcp_cmd.line.trans_id, mgcp_conn.conn_id, mgcp_conn.local_osmux_cid, sdp); |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 417 | } else { |
| 418 | mgcp_resp := ts_CRCX_ACK(mgcp_cmd.line.trans_id, mgcp_conn.conn_id, sdp); |
| 419 | } |
| 420 | f_mgcp_par_append(mgcp_resp.params, ts_MgcpParSpecEP(g_media.mgcp_ep)); |
| 421 | g_media.mgcp_conn[cid].crcx_seen := g_media.mgcp_conn[cid].crcx_seen + 1; |
| 422 | return mgcp_resp; |
| 423 | } |
| 424 | |
| 425 | function f_rx_mdcx(MgcpCommand mgcp_cmd) |
| 426 | runs on MSC_ConnHdlr return template MgcpResponse { |
| 427 | var SDP_Message sdp; |
| 428 | var integer cid := f_get_mgcp_conn(f_MgcpCmd_extract_conn_id(mgcp_cmd)); |
Pau Espin Pedrol | 0786663 | 2020-09-03 19:10:55 +0200 | [diff] [blame] | 429 | var charstring local_rtp_addr; |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 430 | if (isvalue(mgcp_cmd.sdp)) { |
| 431 | sdp := mgcp_cmd.sdp; |
| 432 | g_media.mgcp_conn[cid].peer.host := sdp.connection.conn_addr.addr; |
| 433 | g_media.mgcp_conn[cid].peer.port_nr := sdp.media_list[0].media_field.ports.port_number; |
Pau Espin Pedrol | 0786663 | 2020-09-03 19:10:55 +0200 | [diff] [blame] | 434 | if (sdp.connection.addr_type == "IP6") { |
| 435 | local_rtp_addr := host_mgw_rtp_v6; |
| 436 | } else { |
| 437 | local_rtp_addr := host_mgw_rtp_v4; |
| 438 | } |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 439 | } else { |
| 440 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "MDCX has no [recognizable] SDP"); |
| 441 | } |
| 442 | var MgcpConnState mgcp_conn := g_media.mgcp_conn[cid]; |
Pau Espin Pedrol | 0786663 | 2020-09-03 19:10:55 +0200 | [diff] [blame] | 443 | sdp := valueof(ts_SDP(mgcp_conn.peer.host, local_rtp_addr, "foo", "21", |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 444 | mgcp_conn.peer.port_nr, { int2str(mgcp_conn.rtp_pt) }, |
| 445 | {valueof(ts_SDP_rtpmap(mgcp_conn.rtp_pt, |
| 446 | mgcp_conn.mime_type & "/" & |
| 447 | int2str(mgcp_conn.sample_rate))), |
| 448 | valueof(ts_SDP_ptime(mgcp_conn.ptime)) } )); |
| 449 | g_media.mgcp_conn[cid].mdcx_seen := g_media.mgcp_conn[cid].mdcx_seen + 1; |
| 450 | return ts_MDCX_ACK(mgcp_cmd.line.trans_id, mgcp_conn.conn_id, sdp); |
| 451 | } |
| 452 | |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 453 | function tr_MGCP_RecvFrom_any(template MgcpMessage msg) |
| 454 | runs on MSC_ConnHdlr return template MGCP_RecvFrom { |
| 455 | var template MGCP_RecvFrom mrf := { |
| 456 | connId := ?, |
| 457 | remName := ?, |
| 458 | remPort := ?, |
| 459 | locName := ?, |
| 460 | locPort := ?, |
| 461 | msg := msg |
| 462 | } |
| 463 | return mrf; |
| 464 | } |
| 465 | |
Philipp Maier | b242235 | 2018-07-11 10:36:57 +0200 | [diff] [blame] | 466 | /* altstep for handling of MGCP media related commands. Activated by as_Media() to test |
| 467 | * MGW level media handling */ |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 468 | |
Oliver Smith | 735b47c | 2023-02-15 16:03:54 +0100 | [diff] [blame] | 469 | altstep as_Media_mgw(boolean norepeat := false) runs on MSC_ConnHdlr { |
Philipp Maier | b242235 | 2018-07-11 10:36:57 +0200 | [diff] [blame] | 470 | var MgcpCommand mgcp_cmd; |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 471 | var template MgcpResponse mgcp_resp; |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 472 | var MGCP_RecvFrom mrf; |
| 473 | var template MgcpMessage msg_crcx := { |
| 474 | command := tr_CRCX |
| 475 | } |
| 476 | var template MgcpMessage msg_mdcx := { |
| 477 | command := tr_MDCX |
| 478 | } |
Neels Hofmeyr | 9b320c1 | 2022-04-07 00:19:01 +0200 | [diff] [blame] | 479 | var template MgcpMessage msg_dlcx := { |
| 480 | command := tr_DLCX |
| 481 | } |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 482 | var template MgcpMessage msg_resp; |
Philipp Maier | b242235 | 2018-07-11 10:36:57 +0200 | [diff] [blame] | 483 | |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 484 | [g_pars.aoip] MGCP.receive(tr_CRCX) -> value mgcp_cmd { |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 485 | mgcp_resp := f_rx_crcx(mgcp_cmd); |
Harald Welte | 363cb0a | 2018-01-30 19:35:53 +0100 | [diff] [blame] | 486 | MGCP.send(mgcp_resp); |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 487 | if(norepeat == false) { |
| 488 | repeat; |
| 489 | } |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 490 | } |
| 491 | |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 492 | [not g_pars.aoip] MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_crcx)) -> value mrf { |
| 493 | mgcp_resp := f_rx_crcx(mrf.msg.command); |
| 494 | msg_resp := { |
| 495 | response := mgcp_resp |
| 496 | } |
| 497 | MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp)); |
| 498 | if(norepeat == false) { |
| 499 | repeat; |
| 500 | } |
| 501 | } |
| 502 | |
Oliver Smith | 7a8594a | 2023-02-13 14:30:49 +0100 | [diff] [blame] | 503 | [g_pars.aoip and not g_pars.ignore_mgw_mdcx] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
Pau Espin Pedrol | 513b831 | 2019-06-18 17:37:36 +0200 | [diff] [blame] | 504 | mgcp_resp := f_rx_mdcx(mgcp_cmd); |
| 505 | MGCP.send(mgcp_resp); |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 506 | if(norepeat == false) { |
| 507 | repeat; |
| 508 | } |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 509 | } |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 510 | |
Oliver Smith | 7a8594a | 2023-02-13 14:30:49 +0100 | [diff] [blame] | 511 | [not g_pars.aoip and not g_pars.ignore_mgw_mdcx] |
| 512 | MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_mdcx)) -> value mrf { |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 513 | mgcp_resp := f_rx_mdcx(mrf.msg.command); |
| 514 | msg_resp := { |
| 515 | response := mgcp_resp |
| 516 | } |
| 517 | MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp)); |
| 518 | if(norepeat == false) { |
| 519 | repeat; |
| 520 | } |
| 521 | } |
Neels Hofmeyr | 9b320c1 | 2022-04-07 00:19:01 +0200 | [diff] [blame] | 522 | |
Oliver Smith | 735b47c | 2023-02-15 16:03:54 +0100 | [diff] [blame] | 523 | [g_pars.fail_on_dlcx and g_pars.aoip] MGCP.receive(tr_DLCX) { |
Neels Hofmeyr | 9b320c1 | 2022-04-07 00:19:01 +0200 | [diff] [blame] | 524 | setverdict(fail, "Unexpected DLCX received"); |
| 525 | } |
| 526 | |
Oliver Smith | 735b47c | 2023-02-15 16:03:54 +0100 | [diff] [blame] | 527 | [g_pars.fail_on_dlcx and not g_pars.aoip] MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) { |
Neels Hofmeyr | 9b320c1 | 2022-04-07 00:19:01 +0200 | [diff] [blame] | 528 | setverdict(fail, "Unexpected DLCX received"); |
| 529 | } |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 530 | } |
| 531 | |
Philipp Maier | b242235 | 2018-07-11 10:36:57 +0200 | [diff] [blame] | 532 | /* Altsteps for handling of media related commands. Can be activated by a given |
| 533 | * test case if it expects to see media related handling (i.e. voice calls) */ |
Oliver Smith | 735b47c | 2023-02-15 16:03:54 +0100 | [diff] [blame] | 534 | altstep as_Media() runs on MSC_ConnHdlr { |
Oliver Smith | 4eed06f | 2023-02-15 15:43:19 +0100 | [diff] [blame] | 535 | [not g_pars.ignore_ipa_media] as_Media_ipacc(); |
Oliver Smith | 735b47c | 2023-02-15 16:03:54 +0100 | [diff] [blame] | 536 | [] as_Media_mgw(); |
Philipp Maier | b242235 | 2018-07-11 10:36:57 +0200 | [diff] [blame] | 537 | } |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 538 | |
Neels Hofmeyr | d36a82f | 2021-07-20 22:10:49 +0200 | [diff] [blame] | 539 | type port Coord_PT message |
| 540 | { |
| 541 | inout charstring; |
| 542 | } with { extension "internal" }; |
| 543 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 544 | /* this component represents a single subscriber connection at the MSC. |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 545 | * There is a 1:1 mapping between SCCP connections and RAN_ConnHdlr components. |
| 546 | * We inherit all component variables, ports, functions, ... from RAN_ConnHdlr */ |
Harald Welte | 47cd0e3 | 2020-08-21 12:39:11 +0200 | [diff] [blame] | 547 | type component MSC_ConnHdlr extends RAN_ConnHdlr, RSL_DchanHdlr, MGCP_ConnHdlr, BSSAP_LE_ConnHdlr, StatsD_ConnHdlr { |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 548 | /* SCCP Connecction Identifier for the underlying SCCP connection */ |
| 549 | var integer g_sccp_conn_id; |
| 550 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 551 | /* procedure port back to our parent (RAN_Emulation_CT) for control */ |
| 552 | port RAN_PROC_PT RAN; |
Harald Welte | c20b1c4 | 2018-02-12 20:50:08 +0100 | [diff] [blame] | 553 | port TELNETasp_PT BSCVTY; |
Neels Hofmeyr | d36a82f | 2021-07-20 22:10:49 +0200 | [diff] [blame] | 554 | port Coord_PT COORD; |
Vadim Yanitskiy | 5f14d34 | 2022-02-07 14:18:38 +0600 | [diff] [blame] | 555 | port Coord_PT COORD2; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 556 | |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 557 | /* Proxy MGCP-over-IPA and MGCP-over-UDP */ |
| 558 | port IPA_MGCP_PT MGCP_MSC_CLIENT; |
| 559 | var integer g_trans_id := 0; |
| 560 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 561 | var MediaState g_media; |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 562 | var TestHdlrParams g_pars; |
Harald Welte | e97eab4 | 2018-03-21 18:46:06 +0100 | [diff] [blame] | 563 | |
Pau Espin Pedrol | 392963f | 2019-06-18 17:17:19 +0200 | [diff] [blame] | 564 | var charstring host_bts := "127.0.0.2"; |
Pau Espin Pedrol | 0786663 | 2020-09-03 19:10:55 +0200 | [diff] [blame] | 565 | var charstring host_mgw_mgcp := "127.0.0.3"; |
| 566 | var charstring host_mgw_rtp_v4 := "127.0.0.5"; |
| 567 | var charstring host_mgw_rtp_v6 := "::1"; |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 568 | var charstring host_msc := "127.0.0.4"; |
| 569 | |
Harald Welte | e97eab4 | 2018-03-21 18:46:06 +0100 | [diff] [blame] | 570 | var boolean g_vty_initialized := false; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 571 | } |
| 572 | |
Harald Welte | eddf0e9 | 2020-06-21 19:42:15 +0200 | [diff] [blame] | 573 | function f_MscConnHdlr_init_vty() runs on MSC_ConnHdlr { |
Harald Welte | e97eab4 | 2018-03-21 18:46:06 +0100 | [diff] [blame] | 574 | if (not g_vty_initialized) { |
| 575 | map(self:BSCVTY, system:BSCVTY); |
| 576 | f_vty_set_prompts(BSCVTY); |
| 577 | f_vty_transceive(BSCVTY, "enable"); |
| 578 | g_vty_initialized := true; |
| 579 | } |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 580 | } |
| 581 | |
Harald Welte | eddf0e9 | 2020-06-21 19:42:15 +0200 | [diff] [blame] | 582 | /* initialize all parameters */ |
| 583 | function f_MscConnHdlr_init(integer i, HostName bts, HostName mgw, BSSMAP_FIELD_CodecType codecType) runs on MSC_ConnHdlr { |
| 584 | f_MediaState_init(g_media, i, bts, mgw, codecType); |
| 585 | f_MscConnHdlr_init_vty(); |
| 586 | } |
| 587 | |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 588 | private function get_next_trans_id() runs on MSC_ConnHdlr return MgcpTransId { |
| 589 | var MgcpTransId tid := int2str(g_trans_id); |
| 590 | g_trans_id := g_trans_id + 1; |
| 591 | return tid; |
| 592 | } |
| 593 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 594 | /* Callback function from general RAN_Emulation whenever a connectionless |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 595 | * BSSMAP message arrives. Can retunr a PDU_BSSAP that should be sent in return */ |
| 596 | private function UnitdataCallback(PDU_BSSAP bssap) |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 597 | runs on RAN_Emulation_CT return template PDU_BSSAP { |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 598 | var template PDU_BSSAP resp := omit; |
Pau Espin Pedrol | 9554918 | 2019-06-06 16:17:30 +0200 | [diff] [blame] | 599 | var boolean append_osmux_support := g_ran_ops.use_osmux and |
| 600 | (g_ran_ops.transport == BSSAP_TRANSPORT_AoIP); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 601 | |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 602 | /* answer all RESET with a RESET ACK */ |
Pau Espin Pedrol | 9554918 | 2019-06-06 16:17:30 +0200 | [diff] [blame] | 603 | if (match(bssap, tr_BSSMAP_Reset(append_osmux_support))) { |
| 604 | resp := ts_BSSMAP_ResetAck(append_osmux_support); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | return resp; |
| 608 | } |
| 609 | |
Harald Welte | 47cd0e3 | 2020-08-21 12:39:11 +0200 | [diff] [blame] | 610 | /* Callback function from general BSSAP_LE_Emulation whenever a connectionless |
| 611 | * BSSAP_LE message arrives. Can return a PDU_BSSAP_LE that should be sent in return */ |
| 612 | private function BSSAP_LE_UnitdataCallback(PDU_BSSAP_LE bssap) |
| 613 | runs on BSSAP_LE_Emulation_CT return template PDU_BSSAP_LE { |
| 614 | var template PDU_BSSAP_LE resp := omit; |
| 615 | |
| 616 | /* answer all RESET with a RESET ACK */ |
| 617 | if (match(bssap, tr_BSSMAP_LE_Reset)) { |
| 618 | resp := ts_BSSMAP_LE_ResetAck; |
| 619 | } |
| 620 | |
| 621 | return resp; |
| 622 | } |
| 623 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 624 | const RanOps MSC_RanOps := { |
| 625 | create_cb := refers(RAN_Emulation.ExpectedCreateCallback), |
Harald Welte | 0b47606 | 2018-01-21 19:07:32 +0100 | [diff] [blame] | 626 | unitdata_cb := refers(UnitdataCallback), |
| 627 | decode_dtap := false, |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 628 | role_ms := false, |
Harald Welte | 2fce788 | 2019-04-15 11:48:05 +0200 | [diff] [blame] | 629 | protocol := RAN_PROTOCOL_BSSAP, |
Pau Espin Pedrol | c6b78ff | 2019-06-06 15:58:17 +0200 | [diff] [blame] | 630 | transport := BSSAP_TRANSPORT_AoIP, |
Pau Espin Pedrol | c6a53db | 2019-05-20 19:31:47 +0200 | [diff] [blame] | 631 | use_osmux := false, |
Eric Wild | 66448c1 | 2022-04-02 14:57:53 +0200 | [diff] [blame] | 632 | bssap_reset_retries := 1, |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 633 | sccp_addr_local := omit, |
| 634 | sccp_addr_peer := omit |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 635 | } |
| 636 | |
Harald Welte | 47cd0e3 | 2020-08-21 12:39:11 +0200 | [diff] [blame] | 637 | const BssapLeOps SMLC_BssapLeOps := { |
| 638 | create_cb := refers(BSSAP_LE_Emulation.ExpectedCreateCallback), |
| 639 | unitdata_cb := refers(BSSAP_LE_UnitdataCallback), |
| 640 | decode_dtap := false, |
| 641 | role_ms := false, |
| 642 | sccp_addr_local := omit, |
| 643 | sccp_addr_peer := omit |
| 644 | } |
| 645 | |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 646 | const MGCPOps MSC_MGCPOps := { |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 647 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 648 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 649 | } |
| 650 | |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 651 | /* register an expect with the BSSMAP core */ |
Neels Hofmeyr | 4f11841 | 2020-06-04 15:25:10 +0200 | [diff] [blame] | 652 | function f_create_bssmap_exp(octetstring l3_enc) runs on MSC_ConnHdlr { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 653 | RAN.call(RAN_register:{l3_enc, self}) { |
| 654 | [] RAN.getreply(RAN_register:{?, ?}) {}; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 655 | } |
| 656 | } |
| 657 | |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 658 | type record TestHdlrEncrParams { |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 659 | /* A mask of multiple encryption algorithms, for Encryption Information IE. */ |
| 660 | OCT1 enc_alg_permitted, |
| 661 | /* Expect this encryption algorithm in Channel Activation from the BSC. |
| 662 | * To expect no encryption, set to '01'O == A5/0. */ |
| 663 | OCT1 enc_alg_expect, |
| 664 | /* In BSSMAP, the Chosen Encryption Algorithm IE that the test sends to the BSC. |
| 665 | * When set to omit, the MSC will not send a Chosen Encryption Algorithm IE. */ |
| 666 | OCT1 enc_alg_chosen optional, |
Neels Hofmeyr | 6c388f2 | 2021-06-11 02:36:56 +0200 | [diff] [blame] | 667 | octetstring enc_key, |
| 668 | octetstring enc_kc128 optional |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 669 | }; |
| 670 | |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 671 | template (value) TestHdlrEncrParams t_EncrParams(OCT1 alg_permitted, |
| 672 | octetstring key, template (omit) octetstring kc128 := omit) := { |
| 673 | enc_alg_permitted := alg_permitted, |
| 674 | enc_alg_expect := alg_permitted, /* <- for compat with tests before enc_alg_expect was added */ |
| 675 | enc_alg_chosen := alg_permitted, /* <- for compat with tests before enc_alg_chosen was added */ |
Neels Hofmeyr | 6c388f2 | 2021-06-11 02:36:56 +0200 | [diff] [blame] | 676 | enc_key := key, |
| 677 | enc_kc128 := kc128 |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 678 | } |
| 679 | |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 680 | template (value) TestHdlrEncrParams t_EncrParams2(OCT1 alg_permitted, |
| 681 | OCT1 alg_expect, |
| 682 | template(omit) OCT1 alg_chosen, |
| 683 | octetstring key, |
| 684 | template (omit) octetstring kc128 := omit) := { |
| 685 | enc_alg_permitted := alg_permitted, |
| 686 | enc_alg_expect := alg_expect, |
| 687 | enc_alg_chosen := alg_chosen, |
| 688 | enc_key := key, |
| 689 | enc_kc128 := kc128 |
| 690 | } |
| 691 | |
| 692 | /* Convenience for common t_EncrParams2 usage. |
| 693 | * |
| 694 | * To test a scenario where only A5/3 is permitted: |
| 695 | * f_encr_params('08'O); |
| 696 | * To test a scenario where A5/3 is chosen from A5/0,A5/1,A5/3 (1 | 2 | 8 = 11 = 0xb): |
| 697 | * f_encr_params('0b'O, '08'O); |
| 698 | * To test the same, but the Chosen Encryption Algorithm IE should reflect A5/1: |
| 699 | * f_encr_params('0b'O, '08'O, '02'O); |
| 700 | * To test the same, but the MSC sends no Chosen Encryption Algorithm IE: |
| 701 | * f_encr_params('0b'O, '08'O, omit); |
| 702 | * |
| 703 | * Set alg_chosen and alg_expect magically when == '00'O: |
| 704 | * - enc_alg_expect is set to alg_chosen if present, else to alg_permitted. |
| 705 | * - enc_alg_chosen is set to alg_permitted. |
| 706 | * When only alg_permitted is given, alg_permitted must reflect only one algorithm, or f_cipher_mode_bssmap_to_rsl() |
| 707 | * will fail. |
| 708 | * When alg_chosen is passed as omit, the messages from the MSC will not contain a Chosen Encryption Algorithm IE. |
| 709 | */ |
| 710 | function f_encr_params(OCT1 alg_permitted, OCT1 alg_expect := '00'O, template (omit) OCT1 alg_chosen := '00'O, |
| 711 | boolean kc128 := false) |
| 712 | return TestHdlrEncrParams |
| 713 | { |
| 714 | if (not istemplatekind(alg_chosen, "omit")) { |
| 715 | if (valueof(alg_chosen) == '00'O) { |
| 716 | if (alg_expect != '00'O) { |
| 717 | alg_chosen := alg_expect; |
| 718 | } else { |
| 719 | /* In this case, alg_permitted should have only one permitted algo */ |
| 720 | alg_chosen := alg_permitted; |
| 721 | } |
| 722 | } |
| 723 | if (alg_expect == '00'O) { |
| 724 | alg_expect := valueof(alg_chosen); |
| 725 | } |
| 726 | } |
| 727 | if (alg_expect == '00'O) { |
| 728 | /* In this case, alg_permitted should have only one permitted algo */ |
| 729 | alg_expect := valueof(alg_permitted); |
| 730 | } |
Vadim Yanitskiy | 35c9a33 | 2022-03-16 20:26:35 +0300 | [diff] [blame] | 731 | var template (omit) octetstring kc := omit; |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 732 | if (kc128) { |
| 733 | kc := f_rnd_octstring(16); |
| 734 | } |
| 735 | return valueof(t_EncrParams2(alg_permitted, alg_expect, alg_chosen, f_rnd_octstring(8), kc)); |
| 736 | } |
| 737 | |
Harald Welte | cc0b014 | 2018-05-29 15:19:33 +0200 | [diff] [blame] | 738 | type record TestHdlrParamsLcls { |
| 739 | GlobalCallReferenceValue gcr optional, |
| 740 | /* LCLS Configuration */ |
| 741 | BIT4 cfg optional, |
| 742 | /* LCLS Connection Status Control */ |
| 743 | BIT4 csc optional, |
Max | 2eeb511 | 2018-11-06 19:21:41 +0100 | [diff] [blame] | 744 | BIT4 exp_sts optional, |
| 745 | /* Whether to adjust *cx_seen_exp for LCLS tests */ |
| 746 | boolean adjust_cx_exp |
Harald Welte | cc0b014 | 2018-05-29 15:19:33 +0200 | [diff] [blame] | 747 | } |
| 748 | |
Neels Hofmeyr | f246a92 | 2020-05-13 02:27:10 +0200 | [diff] [blame] | 749 | type record TestHdlrParamsMSCPool { |
Neels Hofmeyr | 4f11841 | 2020-06-04 15:25:10 +0200 | [diff] [blame] | 750 | integer bssap_idx, |
Neels Hofmeyr | 4f11841 | 2020-06-04 15:25:10 +0200 | [diff] [blame] | 751 | integer rsl_idx, |
| 752 | PDU_ML3_MS_NW l3_info optional |
Neels Hofmeyr | f246a92 | 2020-05-13 02:27:10 +0200 | [diff] [blame] | 753 | } |
| 754 | |
Harald Welte | 801ed1a | 2023-04-30 15:07:00 +1000 | [diff] [blame] | 755 | type record ASCITest { |
| 756 | boolean vgcs_setup_ok, |
| 757 | boolean vgcs_assign_ok, |
| 758 | boolean vgcs_assign_fail, |
| 759 | boolean vgcs_talker_req, |
| 760 | boolean vgcs_talker_est, |
Andreas Eversberg | 3587492 | 2023-07-07 13:44:04 +0200 | [diff] [blame] | 761 | boolean vgcs_talker_rel, |
| 762 | boolean vgcs_uplink_seized, |
| 763 | boolean vgcs_uplink_release |
Harald Welte | 801ed1a | 2023-04-30 15:07:00 +1000 | [diff] [blame] | 764 | }; |
| 765 | |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 766 | type record TestHdlrParams { |
| 767 | OCT1 ra, |
| 768 | GsmFrameNumber fn, |
Pau Espin Pedrol | b27653c | 2023-01-03 14:07:21 +0100 | [diff] [blame] | 769 | hexstring imsi optional, |
| 770 | hexstring imei optional, |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 771 | RslLinkId link_id, |
Harald Welte | cbe911c | 2018-06-01 18:23:07 +0200 | [diff] [blame] | 772 | integer media_nr, /* determins MGCP EP, port numbers */ |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 773 | BSSMAP_IE_SpeechCodecList ass_codec_list optional, |
Neels Hofmeyr | bcf62bc | 2018-07-04 00:24:33 +0200 | [diff] [blame] | 774 | RSL_IE_Body expect_mr_conf_ie optional, /* typically present for AMR codecs */ |
Philipp Maier | d0e64b0 | 2019-03-13 14:15:23 +0100 | [diff] [blame] | 775 | bitstring expect_mr_s0_s7 optional, /* typically present for AMR codecs */ |
Harald Welte | cc0b014 | 2018-05-29 15:19:33 +0200 | [diff] [blame] | 776 | TestHdlrEncrParams encr optional, |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 777 | TestHdlrParamsLcls lcls, |
Neels Hofmeyr | 90f8096 | 2020-06-12 16:16:55 +0200 | [diff] [blame] | 778 | SCCP_PAR_Address sccp_addr_msc optional, |
| 779 | SCCP_PAR_Address sccp_addr_bsc optional, |
Pau Espin Pedrol | f7630a6 | 2019-10-28 15:07:08 +0100 | [diff] [blame] | 780 | uint5_t exp_ms_power_level, |
Pau Espin Pedrol | 8f77363 | 2019-11-05 11:46:53 +0100 | [diff] [blame] | 781 | boolean exp_ms_power_params, |
Pau Espin Pedrol | c6a53db | 2019-05-20 19:31:47 +0200 | [diff] [blame] | 782 | boolean aoip, |
Pau Espin Pedrol | f967afc | 2022-08-08 18:17:20 +0200 | [diff] [blame] | 783 | boolean use_osmux_cn, |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 784 | boolean use_osmux_bts, |
Pau Espin Pedrol | 0786663 | 2020-09-03 19:10:55 +0200 | [diff] [blame] | 785 | charstring host_aoip_tla, |
Philipp Maier | a208389 | 2020-09-21 14:18:36 +0200 | [diff] [blame] | 786 | TestHdlrParamsMSCPool mscpool, |
Pau Espin Pedrol | 3c63053 | 2022-10-20 19:00:11 +0200 | [diff] [blame] | 787 | integer mgwpool_idx, /* MGCP_Emulation_CT (vc_MGCP) to use for this MSC ConnHdlr */ |
Pau Espin Pedrol | c08d552 | 2021-04-16 15:40:38 +0200 | [diff] [blame] | 788 | boolean media_mgw_offer_ipv6, |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 789 | OCT3 last_used_eutran_plmn optional, |
Pau Espin Pedrol | 9ae36d5 | 2021-06-15 17:29:43 +0200 | [diff] [blame] | 790 | boolean exp_fast_return, /* RR Release expected to contain CellSelectInd ? */ |
Neels Hofmeyr | b5b7a6e | 2021-06-04 19:03:45 +0200 | [diff] [blame] | 791 | boolean expect_channel_mode_modify, |
Pau Espin Pedrol | a8ef3be | 2022-02-16 16:21:17 +0100 | [diff] [blame] | 792 | uint3_t expect_tsc optional, |
Neels Hofmeyr | 907b23b | 2022-02-17 21:58:47 +0100 | [diff] [blame] | 793 | BSSMAP_IE_CellIdentifier cell_id_source, |
Neels Hofmeyr | a23f3b1 | 2022-03-02 19:57:12 +0100 | [diff] [blame] | 794 | boolean expect_ho_fail, |
Oliver Smith | 7a8594a | 2023-02-13 14:30:49 +0100 | [diff] [blame] | 795 | boolean expect_ho_fail_lchan_est, |
| 796 | boolean inter_bsc_ho_in__ho_req_in_initial_sccp_cr, |
Oliver Smith | 735b47c | 2023-02-15 16:03:54 +0100 | [diff] [blame] | 797 | boolean ignore_mgw_mdcx, |
Oliver Smith | 4eed06f | 2023-02-15 15:43:19 +0100 | [diff] [blame] | 798 | boolean fail_on_dlcx, |
Harald Welte | 801ed1a | 2023-04-30 15:07:00 +1000 | [diff] [blame] | 799 | boolean ignore_ipa_media, |
| 800 | ASCITest asci_test |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 801 | }; |
| 802 | |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 803 | /* Note: Do not use valueof() to get a value of this template, use |
| 804 | * f_gen_test_hdlr_pars() instead in order to get a configuration that is |
Pau Espin Pedrol | 8df1011 | 2020-01-09 18:21:53 +0100 | [diff] [blame] | 805 | * matched to the current test situation (aoip vs. sccplite) */ |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 806 | template (value) TestHdlrParams t_def_TestHdlrPars := { |
| 807 | ra := '23'O, |
| 808 | fn := 23, |
Pau Espin Pedrol | b27653c | 2023-01-03 14:07:21 +0100 | [diff] [blame] | 809 | imsi := omit, /* set to random in f_gen_test_hdlr_pars() */ |
| 810 | imei := omit, /* set to random in f_gen_test_hdlr_pars() */ |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 811 | link_id := valueof(ts_RslLinkID_DCCH(0)), |
Harald Welte | cbe911c | 2018-06-01 18:23:07 +0200 | [diff] [blame] | 812 | media_nr := 1, |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 813 | ass_codec_list := omit, |
Neels Hofmeyr | bcf62bc | 2018-07-04 00:24:33 +0200 | [diff] [blame] | 814 | expect_mr_conf_ie := omit, |
Philipp Maier | d0e64b0 | 2019-03-13 14:15:23 +0100 | [diff] [blame] | 815 | expect_mr_s0_s7 := omit, |
Harald Welte | cc0b014 | 2018-05-29 15:19:33 +0200 | [diff] [blame] | 816 | encr := omit, |
| 817 | lcls := { |
| 818 | gcr := omit, |
| 819 | cfg := omit, |
| 820 | csc := omit, |
Max | 2eeb511 | 2018-11-06 19:21:41 +0100 | [diff] [blame] | 821 | exp_sts := omit, |
| 822 | adjust_cx_exp := true |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 823 | }, |
Neels Hofmeyr | 90f8096 | 2020-06-12 16:16:55 +0200 | [diff] [blame] | 824 | sccp_addr_msc := omit, |
| 825 | sccp_addr_bsc := omit, |
Pau Espin Pedrol | f7630a6 | 2019-10-28 15:07:08 +0100 | [diff] [blame] | 826 | exp_ms_power_level := 7, /* calculated from osmo-bsc.cfg "ms max power" */ |
Pau Espin Pedrol | 8f77363 | 2019-11-05 11:46:53 +0100 | [diff] [blame] | 827 | exp_ms_power_params := false, |
Pau Espin Pedrol | c6a53db | 2019-05-20 19:31:47 +0200 | [diff] [blame] | 828 | aoip := true, |
Pau Espin Pedrol | f967afc | 2022-08-08 18:17:20 +0200 | [diff] [blame] | 829 | use_osmux_cn := false, |
Pau Espin Pedrol | 29c6dfb | 2022-08-08 18:37:56 +0200 | [diff] [blame] | 830 | use_osmux_bts := false, |
Pau Espin Pedrol | 0786663 | 2020-09-03 19:10:55 +0200 | [diff] [blame] | 831 | host_aoip_tla := "1.2.3.4", |
Neels Hofmeyr | f246a92 | 2020-05-13 02:27:10 +0200 | [diff] [blame] | 832 | mscpool := { |
Neels Hofmeyr | 4f11841 | 2020-06-04 15:25:10 +0200 | [diff] [blame] | 833 | bssap_idx := 0, |
Neels Hofmeyr | 4f11841 | 2020-06-04 15:25:10 +0200 | [diff] [blame] | 834 | rsl_idx := 0, |
| 835 | l3_info := omit |
Philipp Maier | a208389 | 2020-09-21 14:18:36 +0200 | [diff] [blame] | 836 | }, |
Pau Espin Pedrol | 3c63053 | 2022-10-20 19:00:11 +0200 | [diff] [blame] | 837 | mgwpool_idx := 0, |
Pau Espin Pedrol | c08d552 | 2021-04-16 15:40:38 +0200 | [diff] [blame] | 838 | media_mgw_offer_ipv6 := true, |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 839 | last_used_eutran_plmn := omit, |
Pau Espin Pedrol | 9ae36d5 | 2021-06-15 17:29:43 +0200 | [diff] [blame] | 840 | exp_fast_return := false, |
Neels Hofmeyr | b5b7a6e | 2021-06-04 19:03:45 +0200 | [diff] [blame] | 841 | expect_channel_mode_modify := false, |
Pau Espin Pedrol | a8ef3be | 2022-02-16 16:21:17 +0100 | [diff] [blame] | 842 | expect_tsc := omit, |
Neels Hofmeyr | 907b23b | 2022-02-17 21:58:47 +0100 | [diff] [blame] | 843 | cell_id_source := valueof(ts_CellID_LAC_CI(1, 1)), |
Neels Hofmeyr | a23f3b1 | 2022-03-02 19:57:12 +0100 | [diff] [blame] | 844 | expect_ho_fail := false, |
Oliver Smith | 7a8594a | 2023-02-13 14:30:49 +0100 | [diff] [blame] | 845 | expect_ho_fail_lchan_est := false, |
| 846 | inter_bsc_ho_in__ho_req_in_initial_sccp_cr := true, |
Oliver Smith | 735b47c | 2023-02-15 16:03:54 +0100 | [diff] [blame] | 847 | ignore_mgw_mdcx := false, |
Oliver Smith | 4eed06f | 2023-02-15 15:43:19 +0100 | [diff] [blame] | 848 | fail_on_dlcx := true, |
Harald Welte | 801ed1a | 2023-04-30 15:07:00 +1000 | [diff] [blame] | 849 | ignore_ipa_media := false, |
| 850 | asci_test := { |
| 851 | vgcs_setup_ok := false, |
| 852 | vgcs_assign_ok := false, |
| 853 | vgcs_assign_fail := false, |
| 854 | vgcs_talker_req := false, |
| 855 | vgcs_talker_est := false, |
Andreas Eversberg | 3587492 | 2023-07-07 13:44:04 +0200 | [diff] [blame] | 856 | vgcs_talker_rel := false, |
| 857 | vgcs_uplink_seized := false, |
| 858 | vgcs_uplink_release := false |
Harald Welte | 801ed1a | 2023-04-30 15:07:00 +1000 | [diff] [blame] | 859 | } |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 860 | } |
| 861 | |
Vadim Yanitskiy | a7fc5a6 | 2021-12-04 20:10:08 +0300 | [diff] [blame] | 862 | function f_create_chan_and_exp(template (present) PDU_BSSAP exp_l3_compl := ?) |
| 863 | runs on MSC_ConnHdlr { |
Pau Espin Pedrol | b27653c | 2023-01-03 14:07:21 +0100 | [diff] [blame] | 864 | var MobileIdentityLV mi; |
| 865 | var PDU_ML3_MS_NW l3_info; |
| 866 | var octetstring l3_enc; |
Neels Hofmeyr | b5b7a6e | 2021-06-04 19:03:45 +0200 | [diff] [blame] | 867 | var template uint3_t tsc := ?; |
Vadim Yanitskiy | a7fc5a6 | 2021-12-04 20:10:08 +0300 | [diff] [blame] | 868 | timer T; |
Neels Hofmeyr | b5b7a6e | 2021-06-04 19:03:45 +0200 | [diff] [blame] | 869 | |
Pau Espin Pedrol | b27653c | 2023-01-03 14:07:21 +0100 | [diff] [blame] | 870 | if (ispresent(g_pars.imsi)) { |
| 871 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 872 | } else if (ispresent(g_pars.imei)) { |
| 873 | mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
| 874 | } else { |
| 875 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 876 | "Either imsi or imei must be set!"); |
| 877 | } |
| 878 | l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
| 879 | l3_enc := enc_PDU_ML3_MS_NW(l3_info); |
| 880 | |
Neels Hofmeyr | b5b7a6e | 2021-06-04 19:03:45 +0200 | [diff] [blame] | 881 | if (not istemplatekind(g_pars.expect_tsc, "omit")) { |
| 882 | tsc := g_pars.expect_tsc; |
| 883 | } |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 884 | |
Vadim Yanitskiy | a7fc5a6 | 2021-12-04 20:10:08 +0300 | [diff] [blame] | 885 | if (istemplatekind(exp_l3_compl, "?")) { |
| 886 | if (g_pars.aoip == false) { |
| 887 | exp_l3_compl := tr_BSSMAP_ComplL3(l3_enc, codec_list := omit); |
| 888 | } else { |
| 889 | exp_l3_compl := tr_BSSMAP_ComplL3(l3_enc, codec_list := ?); |
| 890 | } |
| 891 | } |
| 892 | |
Neels Hofmeyr | d601f9c | 2021-06-04 22:46:06 +0200 | [diff] [blame] | 893 | f_create_bssmap_exp(l3_enc); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 894 | /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */ |
Neels Hofmeyr | b5b7a6e | 2021-06-04 19:03:45 +0200 | [diff] [blame] | 895 | RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc); |
Vadim Yanitskiy | a7fc5a6 | 2021-12-04 20:10:08 +0300 | [diff] [blame] | 896 | /* wait for a COMPL_L3 from the BSC to ensure that the SCCP connection is up */ |
| 897 | T.start(2.0); |
| 898 | alt { |
| 899 | [] BSSAP.receive(exp_l3_compl); |
| 900 | [] BSSAP.receive(tr_BSSMAP_ComplL3) { |
| 901 | setverdict(fail, "Received non-matching COMPLETE LAYER 3 INFORMATION"); |
| 902 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 903 | } |
| 904 | [] T.timeout { |
| 905 | setverdict(fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION"); |
| 906 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 907 | } |
| 908 | } |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 909 | } |
| 910 | |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 911 | function f_rsl_send_l3(template PDU_ML3_MS_NW l3, template (omit) RslLinkId link_id := omit, |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 912 | template (omit) RslChannelNr chan_nr := omit, RSL_DCHAN_PT rsl_pt := RSL) runs on MSC_ConnHdlr { |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 913 | if (not isvalue(link_id)) { |
| 914 | link_id := ts_RslLinkID_DCCH(0); |
| 915 | } |
| 916 | if (not isvalue(chan_nr)) { |
| 917 | chan_nr := g_chan_nr; |
| 918 | } |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 919 | rsl_pt.send(ts_RSL_DATA_IND(valueof(chan_nr), valueof(link_id), enc_PDU_ML3_MS_NW(valueof(l3)))); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 920 | } |
| 921 | |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 922 | function f_rsl_reply(template PDU_ML3_MS_NW l3, RSL_Message orig, RSL_DCHAN_PT rsl_pt := RSL) runs on MSC_ConnHdlr { |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 923 | var RslChannelNr chan_nr := orig.ies[0].body.chan_nr; |
Harald Welte | 1a40de6 | 2017-12-23 02:28:34 +0100 | [diff] [blame] | 924 | var RslLinkId link_id; |
Harald Welte | 8d5eead | 2017-12-17 18:56:45 +0100 | [diff] [blame] | 925 | if (orig.msg_type == RSL_MT_ENCR_CMD) { |
| 926 | link_id := orig.ies[2].body.link_id; |
| 927 | } else { |
| 928 | link_id := orig.ies[1].body.link_id; |
| 929 | } |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 930 | f_rsl_send_l3(l3, link_id, chan_nr, rsl_pt := rsl_pt); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 931 | } |
| 932 | |
Oliver Smith | 598e1ed | 2021-07-09 10:28:40 +0200 | [diff] [blame] | 933 | /* Convert the cipher representation on BSSMAP to the representation used on RSL */ |
| 934 | function f_cipher_mode_bssmap_to_rsl(OCT1 alg_bssmap) return RSL_AlgId |
Philipp Maier | b20c3dc | 2018-02-07 18:36:25 +0100 | [diff] [blame] | 935 | { |
Vadim Yanitskiy | 4483a22 | 2022-03-14 22:07:43 +0300 | [diff] [blame] | 936 | select (alg_bssmap) { |
| 937 | case ('01'O) { return RSL_ALG_ID_A5_0; } |
| 938 | case ('02'O) { return RSL_ALG_ID_A5_1; } |
| 939 | case ('04'O) { return RSL_ALG_ID_A5_2; } |
| 940 | case ('08'O) { return RSL_ALG_ID_A5_3; } |
| 941 | case ('10'O) { return RSL_ALG_ID_A5_4; } |
| 942 | case ('20'O) { return RSL_ALG_ID_A5_5; } |
| 943 | case ('40'O) { return RSL_ALG_ID_A5_6; } |
| 944 | case ('80'O) { return RSL_ALG_ID_A5_7; } |
| 945 | case else { |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 946 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected Encryption Algorithm: " & |
| 947 | oct2str(alg_bssmap)); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 948 | return RSL_ALG_ID_A5_0; |
Vadim Yanitskiy | 4483a22 | 2022-03-14 22:07:43 +0300 | [diff] [blame] | 949 | } |
Philipp Maier | b20c3dc | 2018-02-07 18:36:25 +0100 | [diff] [blame] | 950 | } |
| 951 | } |
| 952 | |
Vadim Yanitskiy | af2972e | 2022-03-14 22:27:57 +0300 | [diff] [blame] | 953 | /* Convert the cipher representation on BSSMAP to the one used on RR (3GPP TS 44.018) */ |
| 954 | function f_cipher_mode_bssmap_to_rr(OCT1 alg_bssmap) return BIT3 |
| 955 | { |
| 956 | select (alg_bssmap) { |
| 957 | case ('01'O) /* A5/0 */ { return '000'B; } /* SC=0 */ |
| 958 | case ('02'O) /* A5/1 */ { return '000'B; } /* SC=1 */ |
| 959 | case ('04'O) /* A5/2 */ { return '001'B; } /* SC=1 */ |
| 960 | case ('08'O) /* A5/3 */ { return '010'B; } /* SC=1 */ |
| 961 | case ('10'O) /* A5/4 */ { return '011'B; } /* SC=1 */ |
| 962 | case ('20'O) /* A5/5 */ { return '100'B; } /* SC=1 */ |
| 963 | case ('40'O) /* A5/6 */ { return '101'B; } /* SC=1 */ |
| 964 | case ('80'O) /* A5/7 */ { return '110'B; } /* SC=1 */ |
| 965 | case else { |
| 966 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected Encryption Algorithm: " & |
| 967 | oct2str(alg_bssmap)); |
| 968 | return '000'B; |
| 969 | } |
| 970 | } |
| 971 | } |
| 972 | |
Neels Hofmeyr | 58ffceb | 2021-06-21 02:17:30 +0200 | [diff] [blame] | 973 | function f_verify_encr_info(RSL_Message rsl) runs on MSC_ConnHdlr { |
| 974 | var RSL_IE_Body encr_info; |
| 975 | var RSL_AlgId alg_rsl; |
| 976 | var template octetstring expect_kc; |
| 977 | |
| 978 | /* If no encryption is enabled, then make sure there is no RSL_IE_ENCR_INFO */ |
| 979 | if (not ispresent(g_pars.encr)) { |
| 980 | if (f_rsl_find_ie(rsl, RSL_IE_ENCR_INFO, encr_info)) { |
| 981 | setverdict(fail, "Found Encryption IE, but expected no encryption in ", rsl.msg_type); |
| 982 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 983 | return; |
| 984 | } |
| 985 | setverdict(pass); |
| 986 | return; |
| 987 | } |
| 988 | |
| 989 | /* RSL uses a different representation of the encryption algorithm, |
| 990 | * so we need to convert first */ |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 991 | alg_rsl := f_cipher_mode_bssmap_to_rsl(g_pars.encr.enc_alg_expect); |
Neels Hofmeyr | 58ffceb | 2021-06-21 02:17:30 +0200 | [diff] [blame] | 992 | |
| 993 | if (alg_rsl == RSL_ALG_ID_A5_4 and ispresent(g_pars.encr.enc_kc128)) { |
| 994 | expect_kc := g_pars.encr.enc_kc128; |
| 995 | } else if (alg_rsl == RSL_ALG_ID_A5_0) { |
| 996 | /* When A5/0 is chosen, no encryption is active, so technically, no key is needed. However, 3GPP TS |
| 997 | * 48.058 9.3.7 Encryption Information stays quite silent about presence or absence of a key for A5/0. |
| 998 | * The only thing specified is how to indicate the length of the key; the possibility that the key may |
| 999 | * be zero length is not explicitly mentioned. So it seems that we should always send the key along, |
| 1000 | * even for A5/0. Still, let's also allow a zero length key for A5/0. */ |
| 1001 | expect_kc := (g_pars.encr.enc_key, ''O); |
| 1002 | } else { |
| 1003 | expect_kc := g_pars.encr.enc_key; |
| 1004 | } |
| 1005 | log("for encryption algo ", alg_rsl, " expect kc = ", expect_kc); |
| 1006 | |
| 1007 | if (not f_rsl_find_ie(rsl, RSL_IE_ENCR_INFO, encr_info)) { |
| 1008 | if (alg_rsl == RSL_ALG_ID_A5_0) { |
| 1009 | /* For A5/0, encryption is not active. It is fine to omit the Encryption Information in this |
| 1010 | * case. Note that the first channel may see an RSL Encryption Command with A5/0 indicated, and |
| 1011 | * a subsequent handover may activate a new channel without any Encryption Information. */ |
| 1012 | setverdict(pass); |
| 1013 | return; |
| 1014 | } |
| 1015 | setverdict(fail, "Missing Encryption Information IE in ", rsl.msg_type); |
| 1016 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1017 | return; |
| 1018 | } |
| 1019 | |
| 1020 | if (not match(encr_info, tr_EncrInfo(alg_rsl, expect_kc))) { |
| 1021 | setverdict(fail, "Unexpected Kc in Encryption Information IE in ", rsl.msg_type); |
| 1022 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1023 | return; |
| 1024 | } |
| 1025 | setverdict(pass); |
| 1026 | } |
| 1027 | |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1028 | function f_cipher_mode(TestHdlrEncrParams enc, boolean exp_fail := false, |
| 1029 | RSL_DCHAN_PT rsl_pt := RSL, RSLEM_PROC_PT rsl_proc_pt := RSL_PROC) |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1030 | runs on MSC_ConnHdlr { |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1031 | var PDU_BSSAP bssap; |
| 1032 | var RSL_Message rsl; |
| 1033 | |
Neels Hofmeyr | 6c388f2 | 2021-06-11 02:36:56 +0200 | [diff] [blame] | 1034 | if (isvalue(enc.enc_kc128)) { |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 1035 | BSSAP.send(ts_BSSMAP_CipherModeCmdKc128(enc.enc_alg_permitted, enc.enc_key, valueof(enc.enc_kc128))); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1036 | } else { |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 1037 | BSSAP.send(ts_BSSMAP_CipherModeCmd(enc.enc_alg_permitted, enc.enc_key)); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1038 | } |
Philipp Maier | b20c3dc | 2018-02-07 18:36:25 +0100 | [diff] [blame] | 1039 | |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1040 | alt { |
| 1041 | /* RSL/UE Side */ |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1042 | [] rsl_pt.receive(tr_RSL_ENCR_CMD(g_chan_nr)) -> value rsl { |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1043 | var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[3].body.l3_info.payload); |
| 1044 | log("Rx L3 from net: ", l3); |
Neels Hofmeyr | 7274934 | 2021-06-11 02:41:37 +0200 | [diff] [blame] | 1045 | |
Neels Hofmeyr | 58ffceb | 2021-06-21 02:17:30 +0200 | [diff] [blame] | 1046 | f_verify_encr_info(rsl); |
| 1047 | |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1048 | if (ischosen(l3.msgs.rrm.cipheringModeCommand)) { |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1049 | f_rsl_reply(ts_RRM_CiphModeCompl, rsl, rsl_pt := rsl_pt); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1050 | } |
| 1051 | repeat; |
| 1052 | } |
| 1053 | [] BSSAP.receive(tr_BSSMAP_CipherModeCompl) -> value bssap { |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1054 | if (exp_fail == true) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1055 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected Cipher Mode Complete"); |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1056 | } else { |
| 1057 | setverdict(pass); |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 1058 | var RSL_AlgId alg_rsl := f_cipher_mode_bssmap_to_rsl(g_pars.encr.enc_alg_expect); |
Neels Hofmeyr | 5e31cfc | 2021-06-11 02:42:11 +0200 | [diff] [blame] | 1059 | if (oct2int(bssap.pdu.bssmap.cipherModeComplete.chosenEncryptionAlgorithm.algorithmIdentifier) != enum2int(alg_rsl)) { |
| 1060 | setverdict(fail, "Unexpected Encryption Algorithm ID in BSSMAP Cipher Mode Complete"); |
| 1061 | } |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1062 | } |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1063 | } |
| 1064 | [] BSSAP.receive(tr_BSSMAP_CipherModeRej) -> value bssap { |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1065 | if (exp_fail == false) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1066 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Ciphering Mode Reject"); |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1067 | } else { |
| 1068 | setverdict(pass); |
| 1069 | } |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1070 | } |
| 1071 | } |
| 1072 | } |
| 1073 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1074 | /* Convert from Ericsson ChanDesc2 format to Osmocom RslChannelNr format */ |
| 1075 | function f_ChDesc2RslChanNr(ChannelDescription2_V ch_desc, out RslChannelNr chan_nr, out GsmArfcn arfcn) { |
| 1076 | var BIT5 inp := ch_desc.channelTypeandTDMAOffset; |
Harald Welte | 6fa1f73 | 2018-03-21 22:46:16 +0100 | [diff] [blame] | 1077 | var uint3_t tn := bit2int(ch_desc.timeslotNumber); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1078 | |
Vadim Yanitskiy | 2bcea3d | 2021-11-18 19:13:48 +0300 | [diff] [blame] | 1079 | select (inp) { |
| 1080 | case ('00001'B) { /* TCH/F */ |
Harald Welte | 6fa1f73 | 2018-03-21 22:46:16 +0100 | [diff] [blame] | 1081 | chan_nr := valueof(t_RslChanNr_Bm(tn)); |
Vadim Yanitskiy | 2bcea3d | 2021-11-18 19:13:48 +0300 | [diff] [blame] | 1082 | } |
| 1083 | case ('11101'B) { /* VAMOS TCH/F */ |
Neels Hofmeyr | 9c3b82f | 2021-05-27 00:38:59 +0200 | [diff] [blame] | 1084 | chan_nr := valueof(t_RslChanNr_Osmo_VAMOS_Bm(tn)); |
Vadim Yanitskiy | 2bcea3d | 2021-11-18 19:13:48 +0300 | [diff] [blame] | 1085 | } |
| 1086 | case ('0001?'B) { /* TCH/H */ |
Harald Welte | 6fa1f73 | 2018-03-21 22:46:16 +0100 | [diff] [blame] | 1087 | chan_nr := valueof(t_RslChanNr_Lm(tn, bit2int(substr(inp, 4, 1)))); |
Vadim Yanitskiy | 2bcea3d | 2021-11-18 19:13:48 +0300 | [diff] [blame] | 1088 | } |
| 1089 | case ('1111?'B) { /* VAMOS TCH/H */ |
Neels Hofmeyr | 9c3b82f | 2021-05-27 00:38:59 +0200 | [diff] [blame] | 1090 | chan_nr := valueof(t_RslChanNr_Osmo_VAMOS_Lm(tn, bit2int(substr(inp, 4, 1)))); |
Vadim Yanitskiy | 2bcea3d | 2021-11-18 19:13:48 +0300 | [diff] [blame] | 1091 | } |
| 1092 | case ('001??'B) { /* SDCCH/4 */ |
Harald Welte | 6fa1f73 | 2018-03-21 22:46:16 +0100 | [diff] [blame] | 1093 | chan_nr := valueof(t_RslChanNr_SDCCH4(tn, bit2int(substr(inp, 3, 2)))); |
Vadim Yanitskiy | 2bcea3d | 2021-11-18 19:13:48 +0300 | [diff] [blame] | 1094 | } |
| 1095 | case ('01???'B) { /* SDCCH/8 */ |
Harald Welte | 6fa1f73 | 2018-03-21 22:46:16 +0100 | [diff] [blame] | 1096 | chan_nr := valueof(t_RslChanNr_SDCCH8(tn, bit2int(substr(inp, 2, 3)))); |
Vadim Yanitskiy | 2bcea3d | 2021-11-18 19:13:48 +0300 | [diff] [blame] | 1097 | } |
| 1098 | case else { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1099 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown ChDesc!"); |
Vadim Yanitskiy | 2bcea3d | 2021-11-18 19:13:48 +0300 | [diff] [blame] | 1100 | } |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | if (ch_desc.octet3 and4b '10'O == '10'O) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1104 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No support for Hopping"); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1105 | } else { |
| 1106 | var OCT2 concat := ch_desc.octet3 & ch_desc.octet4; |
| 1107 | arfcn := oct2int(concat); |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | type record AssignmentState { |
| 1112 | /* global */ |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1113 | boolean rtp_stream, |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1114 | boolean is_assignment, |
| 1115 | /* Assignment related bits */ |
| 1116 | boolean rr_ass_cmpl_seen, |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 1117 | boolean old_lchan_deact_sacch_seen, |
| 1118 | boolean old_lchan_rll_rel_req_seen, |
Harald Welte | 2158308 | 2018-01-29 22:28:26 +0100 | [diff] [blame] | 1119 | boolean assignment_done, |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1120 | RslChannelNr old_chan_nr, |
| 1121 | /* Modify related bits */ |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1122 | PDU_ML3_NW_MS rr_channel_mode_modify_msg optional, |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1123 | boolean rr_modify_seen, |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1124 | RSL_Message rsl_mode_modify_msg optional, |
Harald Welte | 2158308 | 2018-01-29 22:28:26 +0100 | [diff] [blame] | 1125 | boolean modify_done |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1126 | } |
| 1127 | |
| 1128 | template (value) AssignmentState ts_AssignmentStateInit := { |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1129 | rtp_stream := false, |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1130 | is_assignment := false, |
| 1131 | rr_ass_cmpl_seen := false, |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 1132 | old_lchan_deact_sacch_seen := false, |
| 1133 | old_lchan_rll_rel_req_seen := false, |
Harald Welte | 2158308 | 2018-01-29 22:28:26 +0100 | [diff] [blame] | 1134 | assignment_done := false, |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1135 | old_chan_nr := -, |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1136 | rr_channel_mode_modify_msg := omit, |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1137 | rr_modify_seen := false, |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1138 | rsl_mode_modify_msg := omit, |
Harald Welte | 2158308 | 2018-01-29 22:28:26 +0100 | [diff] [blame] | 1139 | modify_done := false |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1140 | } |
| 1141 | |
Harald Welte | 8a9bf6f | 2018-05-10 22:00:49 +0200 | [diff] [blame] | 1142 | private template RSL_IE_Body tr_EncrInfo(template RSL_AlgId alg, template octetstring key) := { |
| 1143 | encr_info := { |
| 1144 | len := ?, |
| 1145 | alg_id := alg, |
| 1146 | key := key |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | /* ensure the RSL CHAN ACT (during assignment) contains values we expect depending on test case */ |
| 1151 | private function f_check_chan_act(AssignmentState st, RSL_Message chan_act) runs on MSC_ConnHdlr { |
| 1152 | var RSL_IE_Body encr_info; |
Pau Espin Pedrol | 3d008ae | 2019-10-28 13:35:46 +0100 | [diff] [blame] | 1153 | var RSL_IE_Body ms_power_param; |
Pau Espin Pedrol | f7630a6 | 2019-10-28 15:07:08 +0100 | [diff] [blame] | 1154 | var RSL_IE_Body ms_power; |
Pau Espin Pedrol | 3d008ae | 2019-10-28 13:35:46 +0100 | [diff] [blame] | 1155 | |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 1156 | if (ispresent(g_pars.encr) and g_pars.encr.enc_alg_permitted != '01'O) { |
Harald Welte | 8a9bf6f | 2018-05-10 22:00:49 +0200 | [diff] [blame] | 1157 | if (not f_rsl_find_ie(chan_act, RSL_IE_ENCR_INFO, encr_info)) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1158 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Missing Encryption IE in CHAN ACT"); |
Harald Welte | 8a9bf6f | 2018-05-10 22:00:49 +0200 | [diff] [blame] | 1159 | } else { |
Neels Hofmeyr | d23e8a0 | 2022-02-17 01:55:59 +0100 | [diff] [blame] | 1160 | var RSL_AlgId alg := f_cipher_mode_bssmap_to_rsl(g_pars.encr.enc_alg_expect); |
Neels Hofmeyr | 0588cad | 2021-06-11 01:38:18 +0200 | [diff] [blame] | 1161 | var octetstring expect_key; |
| 1162 | if (alg == RSL_ALG_ID_A5_4) { |
| 1163 | expect_key := g_pars.encr.enc_kc128; |
| 1164 | } else { |
| 1165 | expect_key := g_pars.encr.enc_key; |
| 1166 | } |
| 1167 | if (not match(encr_info, tr_EncrInfo(alg, expect_key))) { |
| 1168 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1169 | "Unexpected Kc in Encryption IE in RSL ENCR CMD"); |
Harald Welte | 8a9bf6f | 2018-05-10 22:00:49 +0200 | [diff] [blame] | 1170 | } |
| 1171 | } |
| 1172 | } else { |
| 1173 | if (f_rsl_find_ie(chan_act, RSL_IE_ENCR_INFO, encr_info)) { |
| 1174 | if (encr_info.encr_info.alg_id != RSL_ALG_ID_A5_0) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1175 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected Encryption in CHAN ACT"); |
Harald Welte | 8a9bf6f | 2018-05-10 22:00:49 +0200 | [diff] [blame] | 1176 | } |
| 1177 | } |
| 1178 | } |
| 1179 | /* FIXME: validate RSL_IE_ACT_TYPE, RSL_IE_CHAN_MODE, RSL_IE_CHAN_IDENT, RSL_IE_BS_POWER, |
Pau Espin Pedrol | 7a9ccf8 | 2019-11-05 11:33:33 +0100 | [diff] [blame] | 1180 | * RSL_IE_TIMING_ADVANCE */ |
Pau Espin Pedrol | 3d008ae | 2019-10-28 13:35:46 +0100 | [diff] [blame] | 1181 | |
Pau Espin Pedrol | 8f77363 | 2019-11-05 11:46:53 +0100 | [diff] [blame] | 1182 | if (g_pars.exp_ms_power_params and not f_rsl_find_ie(chan_act, RSL_IE_MS_POWER_PARAM, ms_power_param)) { |
Pau Espin Pedrol | 3d008ae | 2019-10-28 13:35:46 +0100 | [diff] [blame] | 1183 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "IE MS Power Parameters not found in CHAN ACT"); |
| 1184 | } |
| 1185 | |
Pau Espin Pedrol | f7630a6 | 2019-10-28 15:07:08 +0100 | [diff] [blame] | 1186 | if (not f_rsl_find_ie(chan_act, RSL_IE_MS_POWER, ms_power)) { |
| 1187 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "IE MS Power not found in CHAN ACT"); |
| 1188 | } else { |
| 1189 | if (not match(ms_power.ms_power, tr_RSL_IE_MS_Power(g_pars.exp_ms_power_level, false))) { |
Pau Espin Pedrol | 7a9ccf8 | 2019-11-05 11:33:33 +0100 | [diff] [blame] | 1190 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Wrong MS Power IE in CHAN ACT, ", ms_power.ms_power.power_level, " vs exp ", g_pars.exp_ms_power_level)); |
Pau Espin Pedrol | f7630a6 | 2019-10-28 15:07:08 +0100 | [diff] [blame] | 1191 | } |
| 1192 | } |
| 1193 | |
Harald Welte | 8a9bf6f | 2018-05-10 22:00:49 +0200 | [diff] [blame] | 1194 | } |
| 1195 | |
Neels Hofmeyr | 6a955cc | 2021-10-02 14:53:48 +0200 | [diff] [blame] | 1196 | function rr_chan_desc_tsc(ChannelDescription2_V cd2) |
Neels Hofmeyr | b5b7a6e | 2021-06-04 19:03:45 +0200 | [diff] [blame] | 1197 | return uint3_t |
| 1198 | { |
| 1199 | var uint3_t tsc := oct2int(cd2.octet3); |
| 1200 | tsc := tsc / 32; /* shl 5 */ |
| 1201 | return tsc; |
| 1202 | } |
| 1203 | |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1204 | altstep as_assignment(inout AssignmentState st, RSL_DCHAN_PT rsl_pt := RSL, RSLEM_PROC_PT rsl_proc_pt := RSL_PROC) runs on MSC_ConnHdlr { |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1205 | var RSL_Message rsl; |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1206 | [not st.rr_ass_cmpl_seen] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl { |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1207 | var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload); |
| 1208 | log("Rx L3 from net: ", l3); |
| 1209 | if (ischosen(l3.msgs.rrm.assignmentCommand)) { |
| 1210 | var RslChannelNr new_chan_nr; |
| 1211 | var GsmArfcn arfcn; |
Neels Hofmeyr | b5b7a6e | 2021-06-04 19:03:45 +0200 | [diff] [blame] | 1212 | |
| 1213 | if (not istemplatekind(g_pars.expect_tsc, "omit")) { |
| 1214 | var uint3_t got_tsc := rr_chan_desc_tsc(l3.msgs.rrm.assignmentCommand.descrOf1stChAfterTime); |
| 1215 | if (not match(got_tsc, g_pars.expect_tsc)) { |
| 1216 | setverdict(fail, "RR Assignment: unexpected TSC in Channel Description: expected ", |
| 1217 | g_pars.expect_tsc, " got ", got_tsc); |
| 1218 | mtc.stop; |
| 1219 | } |
| 1220 | } |
| 1221 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1222 | f_ChDesc2RslChanNr(l3.msgs.rrm.assignmentCommand.descrOf1stChAfterTime, |
| 1223 | new_chan_nr, arfcn); |
| 1224 | /* FIXME: Determine TRX NR by ARFCN, instead of hard-coded TRX0! */ |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1225 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1226 | /* register our component for this channel number at the RSL Emulation */ |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1227 | f_rslem_register(0, new_chan_nr, PT := rsl_proc_pt); |
Vadim Yanitskiy | 539e630 | 2020-06-22 03:11:54 +0700 | [diff] [blame] | 1228 | /* dispatch queued messages for this channel (if any) */ |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1229 | f_rslem_dchan_queue_dispatch(PT := rsl_proc_pt); |
Vadim Yanitskiy | 539e630 | 2020-06-22 03:11:54 +0700 | [diff] [blame] | 1230 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1231 | var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_AssignmentComplete('00'O)); |
| 1232 | /* send assignment complete over the new channel */ |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1233 | rsl_pt.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)), |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1234 | enc_PDU_ML3_MS_NW(l3_tx))); |
| 1235 | /* by default, send via the new channel from now */ |
| 1236 | st.old_chan_nr := g_chan_nr; |
| 1237 | g_chan_nr := new_chan_nr; |
| 1238 | st.rr_ass_cmpl_seen := true; |
Harald Welte | 8a9bf6f | 2018-05-10 22:00:49 +0200 | [diff] [blame] | 1239 | /* obtain channel activation from RSL_Emulation for new channel */ |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1240 | var RSL_Message chan_act := f_rslem_get_last_act(rsl_proc_pt, 0, g_chan_nr); |
Harald Welte | 8a9bf6f | 2018-05-10 22:00:49 +0200 | [diff] [blame] | 1241 | /* check it (e.g. for correct ciphering parameters) */ |
| 1242 | f_check_chan_act(st, chan_act); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1243 | repeat; |
| 1244 | } else { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1245 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected L3 received", l3)); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1246 | } |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1247 | } |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1248 | [st.rr_ass_cmpl_seen] rsl_pt.receive(tr_RSL_DEACT_SACCH(st.old_chan_nr)) { |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 1249 | st.old_lchan_deact_sacch_seen := true; |
Neels Hofmeyr | 861a4c1 | 2018-11-07 01:23:17 +0100 | [diff] [blame] | 1250 | repeat; |
| 1251 | } |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1252 | [st.rr_ass_cmpl_seen] rsl_pt.receive(tr_RSL_REL_REQ(st.old_chan_nr, tr_RslLinkID_DCCH(0))) { |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 1253 | st.old_lchan_rll_rel_req_seen := true; |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1254 | rsl_pt.send(ts_RSL_REL_CONF(st.old_chan_nr, valueof(ts_RslLinkID_DCCH(0)))); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1255 | repeat; |
| 1256 | } |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1257 | [st.rr_ass_cmpl_seen] rsl_pt.receive(tr_RSL_RF_CHAN_REL(st.old_chan_nr)) { |
| 1258 | rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(st.old_chan_nr)); |
Harald Welte | 1909f46 | 2018-01-29 22:29:29 +0100 | [diff] [blame] | 1259 | /* unregister for old channel number in RSL emulation */ |
| 1260 | /* FIXME: Determine TRX NR by ARFCN, instead of hard-coded TRX0! */ |
Neels Hofmeyr | 3222e0e | 2021-07-20 22:25:38 +0200 | [diff] [blame] | 1261 | f_rslem_unregister(0, st.old_chan_nr, PT := rsl_proc_pt); |
Harald Welte | 2158308 | 2018-01-29 22:28:26 +0100 | [diff] [blame] | 1262 | st.assignment_done := true; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1263 | repeat; |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | altstep as_modify(inout AssignmentState st) runs on MSC_ConnHdlr { |
| 1268 | /* no assignment, just mode modify */ |
| 1269 | var RSL_Message rsl; |
| 1270 | |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1271 | [st.rtp_stream and not st.rr_modify_seen] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl { |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1272 | var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload); |
| 1273 | log("Rx L3 from net: ", l3); |
| 1274 | if (ischosen(l3.msgs.rrm.channelModeModify)) { |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1275 | st.rr_channel_mode_modify_msg := l3; |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1276 | f_rsl_reply(ts_RRM_ModeModifyAck(l3.msgs.rrm.channelModeModify.channelDescription, |
| 1277 | l3.msgs.rrm.channelModeModify.channelMode), rsl); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1278 | st.rr_modify_seen := true; |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1279 | } |
| 1280 | repeat; |
| 1281 | } |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1282 | [st.rtp_stream and st.rr_modify_seen] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_MODE_MODIFY_REQ)) -> value rsl { |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1283 | st.rsl_mode_modify_msg := rsl; |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1284 | RSL.send(ts_RSL_MODE_MODIFY_ACK(g_chan_nr)); |
Harald Welte | 2158308 | 2018-01-29 22:28:26 +0100 | [diff] [blame] | 1285 | st.modify_done := true; |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1286 | repeat; |
| 1287 | } |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1288 | } |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 1289 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1290 | /* Determine if given rsl_chan_nr is compatible with given BSSMAP ChannelType */ |
| 1291 | function f_channel_compatible(BSSMAP_IE_ChannelType bssmap, RslChannelNr rsl_chan_nr) |
| 1292 | return boolean { |
| 1293 | select (bssmap.speechOrDataIndicator) { |
| 1294 | case ('0011'B) { /* Signalling */ |
| 1295 | /* all channels support signalling */ |
| 1296 | return true; |
| 1297 | } |
| 1298 | case else { /* Speech, Speech+CTM or CSD */ |
| 1299 | select (bssmap.channelRateAndType) { |
| 1300 | case ('08'O) { /* TCH/F */ |
| 1301 | select (rsl_chan_nr) { |
| 1302 | case (t_RslChanNr_Bm(?)) { return true; } |
| 1303 | } |
| 1304 | } |
| 1305 | case ('09'O) { /* TCH/H */ |
| 1306 | select (rsl_chan_nr) { |
| 1307 | case (t_RslChanNr_Lm(?, ?)) { return true; } |
| 1308 | } |
| 1309 | } |
| 1310 | case else { /* full or half-rate */ |
| 1311 | select (rsl_chan_nr) { |
| 1312 | case (t_RslChanNr_Bm(?)) { return true; } |
| 1313 | case (t_RslChanNr_Lm(?, ?)) { return true; } |
| 1314 | } |
| 1315 | } |
| 1316 | } |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1317 | } |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1318 | } |
| 1319 | return false; |
| 1320 | } |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 1321 | |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1322 | /* Determine if the channel mode specified within rsl_chan_nr requires a |
| 1323 | * MODE MODIFY in to match the channel mode specified by given BSSMAP |
| 1324 | * ChannelType */ |
Neels Hofmeyr | c2425cc | 2021-04-19 13:19:55 +0000 | [diff] [blame] | 1325 | function f_channel_needs_modify(TELNETasp_PT vty, BSSMAP_IE_ChannelType bssmap, RslChannelNr rsl_chan_nr) |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1326 | return boolean { |
| 1327 | |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1328 | var boolean current_signalling := false; |
| 1329 | var boolean desired_signalling := false; |
| 1330 | |
| 1331 | select (rsl_chan_nr) { |
| 1332 | case (t_RslChanNr_SDCCH4(?, ?)) { current_signalling := true; } |
| 1333 | case (t_RslChanNr_SDCCH8(?, ?)) { current_signalling := true; } |
Neels Hofmeyr | c2425cc | 2021-04-19 13:19:55 +0000 | [diff] [blame] | 1334 | case (t_RslChanNr_Bm(?)) { |
| 1335 | /* TCH/F, always subslot 0 */ |
| 1336 | var charstring res := f_vty_transceive_ret(vty, "show lchan 0 0 " & int2str(rsl_chan_nr.tn) & " 0"); |
| 1337 | if (f_strstr(res, "Channel Mode / Codec: SIGNALLING", 0) >= 0) { |
| 1338 | current_signalling := true; |
| 1339 | } |
| 1340 | } |
| 1341 | case (t_RslChanNr_Lm(?, ?)) { |
| 1342 | /* TCH/H */ |
| 1343 | var charstring res := f_vty_transceive_ret(vty, "show lchan 0 0 " & int2str(rsl_chan_nr.tn) |
| 1344 | & " " & int2str(rsl_chan_nr.u.lm.sub_chan)); |
| 1345 | if (f_strstr(res, "Channel Mode / Codec: SIGNALLING", 0) >= 0) { |
| 1346 | current_signalling := true; |
| 1347 | } |
| 1348 | } |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1349 | } |
| 1350 | |
| 1351 | if (bssmap.speechOrDataIndicator == '0011'B) { |
| 1352 | desired_signalling := true; |
| 1353 | } |
| 1354 | |
| 1355 | if (current_signalling == desired_signalling) { |
| 1356 | /* The desired channel mode is equal to the one we currently |
| 1357 | * have, there is no mode modification needed or expected */ |
| 1358 | return false; |
| 1359 | } else { |
| 1360 | /* The desired channel mode and the current channel mode do |
| 1361 | * not match. A mode modification is required */ |
| 1362 | return true; |
| 1363 | } |
| 1364 | } |
| 1365 | |
Harald Welte | cc0b014 | 2018-05-29 15:19:33 +0200 | [diff] [blame] | 1366 | /* patch an BSSMAP ASS REQ with LCLS related IEs, depending on g_params */ |
| 1367 | function f_ass_patch_lcls(inout template (omit) PDU_BSSAP ass_tpl, |
| 1368 | inout template PDU_BSSAP ass_cpl) runs on MSC_ConnHdlr { |
| 1369 | if (istemplatekind(ass_tpl, "omit")) { |
| 1370 | return; |
| 1371 | } |
| 1372 | if (ispresent(g_pars.lcls.gcr)) { |
| 1373 | ass_tpl.pdu.bssmap.assignmentRequest.globalCallReference := ts_BSSMAP_IE_GCR(g_pars.lcls.gcr); |
| 1374 | } |
| 1375 | if (ispresent(g_pars.lcls.cfg)) { |
| 1376 | ass_tpl.pdu.bssmap.assignmentRequest.lCLS_Configuration := ts_BSSMAP_IE_LclsCfg(g_pars.lcls.cfg); |
| 1377 | } |
| 1378 | if (ispresent(g_pars.lcls.csc)) { |
| 1379 | ass_tpl.pdu.bssmap.assignmentRequest.lCLS_ConnectionStatusControl := ts_BSSMAP_IE_LclsCsc(g_pars.lcls.csc); |
| 1380 | } |
Harald Welte | 343b774 | 2018-06-05 23:41:37 +0200 | [diff] [blame] | 1381 | if (ischosen(ass_cpl.pdu.bssmap.assignmentComplete)) { |
| 1382 | if (ispresent(g_pars.lcls.exp_sts)) { |
| 1383 | ass_cpl.pdu.bssmap.assignmentComplete.lCLS_BSS_Status := tr_BSSMAP_IE_LclsSts(g_pars.lcls.exp_sts); |
| 1384 | } else { |
| 1385 | ass_cpl.pdu.bssmap.assignmentComplete.lCLS_BSS_Status := omit; |
| 1386 | } |
Harald Welte | cc0b014 | 2018-05-29 15:19:33 +0200 | [diff] [blame] | 1387 | } |
| 1388 | } |
| 1389 | |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 1390 | /* Send a MGCP request through MGCP-over-IPA from MSC side and receive a (matching!) response */ |
| 1391 | function mgcp_transceive_mgw(template MgcpCommand cmd, template MgcpResponse resp := ?) runs on MSC_ConnHdlr { |
| 1392 | template MgcpResponse resp_any := ? |
| 1393 | var MgcpResponse resp_val; |
| 1394 | resp.line.trans_id := cmd.line.trans_id; |
| 1395 | timer T := 5.0; |
| 1396 | |
| 1397 | BSSAP.send(cmd); |
| 1398 | T.start; |
| 1399 | alt { |
| 1400 | [] as_Media_mgw(); |
| 1401 | [] BSSAP.receive(resp) -> value resp_val { } |
| 1402 | [] BSSAP.receive(resp_any) { |
| 1403 | setverdict(fail, "Response didn't match template"); |
| 1404 | mtc.stop; |
| 1405 | } |
| 1406 | [] BSSAP.receive { repeat; } |
| 1407 | [] T.timeout { |
| 1408 | setverdict(fail, "Timeout waiting for response to ", cmd); |
| 1409 | mtc.stop; |
| 1410 | } |
| 1411 | } |
| 1412 | T.stop; |
| 1413 | } |
| 1414 | |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 1415 | /* Helper function to check if the activity on the MGCP matches what we |
| 1416 | * expected */ |
| 1417 | function f_check_mgcp_expectations() runs on MSC_ConnHdlr { |
| 1418 | for (var integer i:= 0; i < sizeof(g_media.mgcp_conn); i := i+1) { |
Philipp Maier | 0a5d7e7 | 2018-07-16 15:13:11 +0200 | [diff] [blame] | 1419 | log(testcasename(), ": Check MGCP test expectations for g_media.mgcp_conn[", i , "]:", |
| 1420 | " crcx_seen=", g_media.mgcp_conn[i].crcx_seen, ", crcx_seen_exp=", g_media.mgcp_conn[i].crcx_seen_exp, |
| 1421 | ", mdcx_seen=", g_media.mgcp_conn[i].mdcx_seen, ", mdcx_seen_exp=", g_media.mgcp_conn[i].mdcx_seen_exp); |
| 1422 | |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 1423 | if(g_media.mgcp_conn[i].crcx_seen != g_media.mgcp_conn[i].crcx_seen_exp) { |
Max | 4b0f496 | 2018-11-06 19:20:24 +0100 | [diff] [blame] | 1424 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unexpected number of MGW-CRCX transactions on g_media.mgcp_conn[" & int2str(i) & "]"); |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 1425 | } |
| 1426 | if(g_media.mgcp_conn[i].mdcx_seen != g_media.mgcp_conn[i].mdcx_seen_exp) { |
Max | 4b0f496 | 2018-11-06 19:20:24 +0100 | [diff] [blame] | 1427 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unexpected number of MGW-MDCX transactions on g_media.mgcp_conn[" & int2str(i) & "]"); |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 1428 | } |
| 1429 | } |
| 1430 | } |
| 1431 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1432 | /* establish a channel fully, expecting an assignment matching 'exp' */ |
Harald Welte | 7a14fd5 | 2018-05-10 22:26:55 +0200 | [diff] [blame] | 1433 | function f_establish_fully(template (omit) PDU_BSSAP ass_tpl, template PDU_BSSAP exp_ass_cpl) |
| 1434 | runs on MSC_ConnHdlr { |
Philipp Maier | 11a5894 | 2018-06-25 16:40:48 +0200 | [diff] [blame] | 1435 | |
| 1436 | var BSSMAP_FIELD_CodecType codecType; |
Philipp Maier | 48aeeec | 2018-09-14 18:20:04 +0200 | [diff] [blame] | 1437 | timer T := 10.0; |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 1438 | |
Philipp Maier | 4ce978c | 2020-08-11 22:54:07 +0200 | [diff] [blame] | 1439 | if (not istemplatekind(ass_tpl, "omit") and isvalue(ass_tpl.pdu.bssmap.assignmentRequest.codecList)) { |
Philipp Maier | 11a5894 | 2018-06-25 16:40:48 +0200 | [diff] [blame] | 1440 | codecType := valueof(ass_tpl.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType); |
| 1441 | } else { |
| 1442 | /* Make sure a meaningful default is assigned in case the |
| 1443 | * codecList is not populated */ |
| 1444 | codecType := FR_AMR; |
| 1445 | } |
| 1446 | |
Pau Espin Pedrol | 0786663 | 2020-09-03 19:10:55 +0200 | [diff] [blame] | 1447 | f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType); |
Harald Welte | 7a14fd5 | 2018-05-10 22:26:55 +0200 | [diff] [blame] | 1448 | |
Harald Welte | cc0b014 | 2018-05-29 15:19:33 +0200 | [diff] [blame] | 1449 | /* patch in the LCLS related items, as needed */ |
| 1450 | f_ass_patch_lcls(ass_tpl, exp_ass_cpl); |
| 1451 | |
Harald Welte | 7a14fd5 | 2018-05-10 22:26:55 +0200 | [diff] [blame] | 1452 | f_create_chan_and_exp(); |
Harald Welte | 7a14fd5 | 2018-05-10 22:26:55 +0200 | [diff] [blame] | 1453 | |
| 1454 | /* start ciphering, if requested */ |
| 1455 | if (ispresent(g_pars.encr)) { |
Neels Hofmeyr | 6c388f2 | 2021-06-11 02:36:56 +0200 | [diff] [blame] | 1456 | f_cipher_mode(g_pars.encr); |
Harald Welte | 7a14fd5 | 2018-05-10 22:26:55 +0200 | [diff] [blame] | 1457 | } |
| 1458 | |
| 1459 | /* bail out early if no assignment requested */ |
| 1460 | if (istemplatekind(ass_tpl, "omit")) { |
| 1461 | return; |
| 1462 | } |
| 1463 | |
| 1464 | var PDU_BSSAP ass_cmd := valueof(ass_tpl); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1465 | var PDU_BSSAP bssap; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1466 | var boolean exp_compl := ischosen(exp_ass_cpl.pdu.bssmap.assignmentComplete); |
Philipp Maier | 86f3920 | 2018-02-07 14:40:09 +0100 | [diff] [blame] | 1467 | var boolean exp_fail := ischosen(exp_ass_cpl.pdu.bssmap.assignmentFailure); |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1468 | var boolean exp_modify; |
Philipp Maier | 48aeeec | 2018-09-14 18:20:04 +0200 | [diff] [blame] | 1469 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1470 | var ExpectCriteria mgcpcrit := { |
| 1471 | connid := omit, |
| 1472 | endpoint := omit, |
| 1473 | transid := omit |
| 1474 | }; |
| 1475 | var AssignmentState st := valueof(ts_AssignmentStateInit); |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1476 | /* if the channel type is SIGNAL, we're not handling an rtp stream */ |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1477 | if (ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechOrDataIndicator != '0011'B) { |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1478 | st.rtp_stream := true; |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1479 | exp_modify := true; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1480 | } |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1481 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1482 | /* determine if the current channel can support the given service or not */ |
| 1483 | if (not f_channel_compatible(ass_cmd.pdu.bssmap.assignmentRequest.channelType, g_chan_nr)) { |
| 1484 | st.is_assignment := true; |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1485 | |
| 1486 | /* We decided to assign a new channel, so we do not expect |
| 1487 | * any mode modify messages on RSL */ |
| 1488 | exp_modify := false; |
| 1489 | } else { |
| 1490 | /* We will continue working with the currently assigned |
| 1491 | * channel, we must now check if the mode of the current |
| 1492 | * channel is compatible. If not we expect the BSC to modify |
| 1493 | * the mode */ |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1494 | st.is_assignment := false; |
Neels Hofmeyr | c2425cc | 2021-04-19 13:19:55 +0000 | [diff] [blame] | 1495 | exp_modify := f_channel_needs_modify(BSCVTY, ass_cmd.pdu.bssmap.assignmentRequest.channelType, g_chan_nr); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1496 | } |
| 1497 | |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 1498 | /* Some test situations will involve MGCP transactions on a media |
| 1499 | * gateway. Depending on the situation, we set up how many of each MGCP |
| 1500 | * message type are expected to be exchanged. */ |
| 1501 | if (isbound(exp_ass_cpl.pdu.bssmap.assignmentFailure)) { |
| 1502 | /* For tests that expect the assignment to fail, assume that |
| 1503 | * there will be no MGW communication as well. */ |
| 1504 | g_media.mgcp_conn[0].crcx_seen_exp := 0; |
| 1505 | g_media.mgcp_conn[0].mdcx_seen_exp := 0; |
| 1506 | g_media.mgcp_conn[1].crcx_seen_exp := 0; |
| 1507 | g_media.mgcp_conn[1].mdcx_seen_exp := 0; |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1508 | } else if (st.rtp_stream) { |
| 1509 | /* For RTP streams we expect the following MGCP activity */ |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 1510 | g_media.mgcp_conn[0].crcx_seen_exp := 1; |
| 1511 | g_media.mgcp_conn[0].mdcx_seen_exp := 1; |
| 1512 | g_media.mgcp_conn[1].crcx_seen_exp := 1; |
| 1513 | g_media.mgcp_conn[1].mdcx_seen_exp := 0; |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 1514 | } |
| 1515 | |
Vadim Yanitskiy | 539e630 | 2020-06-22 03:11:54 +0700 | [diff] [blame] | 1516 | /* On receipt of the BSSAP Assignment Command, the IUT (osmo-bsc) will allocate |
| 1517 | * a channel and send us RR Assignment Command together with ip.access CRCX. |
| 1518 | * There is a risk that the RSL Emulation component would dequeue and process |
| 1519 | * ip.access CRCX faster than we process the Assignment Command and register |
| 1520 | * the corresponding handler for the indicated RSL channel number. This would |
| 1521 | * result in a failure, because at that moment there will be no handler for |
| 1522 | * ip.access CRCX. Let's guard against this and enable additional queueing. */ |
| 1523 | f_rslem_dchan_queue_enable(); |
| 1524 | |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1525 | f_create_mgcp_expect(mgcpcrit); |
| 1526 | BSSAP.send(ass_cmd); |
| 1527 | |
| 1528 | T.start; |
| 1529 | alt { |
| 1530 | /* assignment related bits */ |
| 1531 | [st.is_assignment] as_assignment(st); |
| 1532 | |
| 1533 | /* modify related bits */ |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1534 | [not st.is_assignment and exp_modify] as_modify(st); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1535 | |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1536 | /* RTP stream related bits (IPA CRCX/MDCX + MGCP) */ |
| 1537 | [st.rtp_stream] as_Media(); |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1538 | |
| 1539 | /* if we receive exactly what we expected, always return + pass */ |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1540 | [st.is_assignment and st.assignment_done or (not st.is_assignment and (st.modify_done or not exp_modify))] BSSAP.receive(exp_ass_cpl) -> value bssap { |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1541 | setverdict(pass); |
| 1542 | } |
Philipp Maier | 86f3920 | 2018-02-07 14:40:09 +0100 | [diff] [blame] | 1543 | [exp_fail] BSSAP.receive(exp_ass_cpl) -> value bssap { |
| 1544 | setverdict(pass); |
| 1545 | } |
Harald Welte | 2158308 | 2018-01-29 22:28:26 +0100 | [diff] [blame] | 1546 | [(st.is_assignment and st.assignment_done or |
Philipp Maier | 8ef527e | 2018-05-18 11:12:50 +0200 | [diff] [blame] | 1547 | (not st.is_assignment and (st.modify_done or not exp_modify))) and |
Harald Welte | 2158308 | 2018-01-29 22:28:26 +0100 | [diff] [blame] | 1548 | exp_compl] BSSAP.receive(tr_BSSMAP_AssignmentComplete) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1549 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching ASSIGNMENT COMPLETE"); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1550 | } |
| 1551 | [exp_compl] BSSAP.receive(tr_BSSMAP_AssignmentFail) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1552 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected ASSIGNMENT FAIL"); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1553 | } |
| 1554 | [not exp_compl] BSSAP.receive(tr_BSSMAP_AssignmentComplete) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1555 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected ASSIGNMENT COMPLETE"); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1556 | } |
| 1557 | [not exp_compl] BSSAP.receive(tr_BSSMAP_AssignmentFail) { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1558 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching ASSIGNMENT FAIL"); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1559 | } |
| 1560 | [] T.timeout { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1561 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASSIGNMENT COMPLETE"); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1562 | } |
| 1563 | } |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1564 | log("g_media ", g_media); |
| 1565 | if (not isbound(bssap)) { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1566 | mtc.stop; |
Harald Welte | 211219e | 2018-01-29 22:03:36 +0100 | [diff] [blame] | 1567 | } |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 1568 | |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1569 | if (exp_modify) { |
| 1570 | /* Verify that the RR Channel Mode Modify and RSL MODE MODIFY message asked for the expected channel |
| 1571 | * mode. */ |
| 1572 | /* TODO: more precisely expect the different types of speech? */ |
| 1573 | var OCT1 rr_channel_mode := st.rr_channel_mode_modify_msg.msgs.rrm.channelModeModify.channelMode.mode; |
| 1574 | |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1575 | if (st.rtp_stream and rr_channel_mode == '00'O) { |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1576 | setverdict(fail, "f_establish_fully(): Expected RR Channel Mode Modify", |
| 1577 | " to a speech mode, but got channelMode == ", rr_channel_mode); |
| 1578 | mtc.stop; |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1579 | } else if (not st.rtp_stream and rr_channel_mode != '00'O) { |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1580 | setverdict(fail, "f_establish_fully(): Expected RR Channel Mode Modify", |
| 1581 | " to signalling mode, but got channelMode == ", rr_channel_mode); |
| 1582 | mtc.stop; |
| 1583 | } |
| 1584 | |
| 1585 | var RSL_IE_Body chan_mode_ie; |
| 1586 | if (not f_rsl_find_ie(st.rsl_mode_modify_msg, RSL_IE_CHAN_MODE, chan_mode_ie)) { |
| 1587 | setverdict(fail, "RSL MODE MODIFY message lacks a Channel Mode IE"); |
| 1588 | mtc.stop; |
| 1589 | } |
| 1590 | var RSL_SpeechDataInd rsl_spd_ind := chan_mode_ie.chan_mode.spd_ind; |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1591 | if (st.rtp_stream and rsl_spd_ind != RSL_SPDI_SPEECH) { |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1592 | setverdict(fail, "f_establish_fully(): Expected RSL MODE MODIFY", |
| 1593 | " to a speech mode, but got spd_ind == ", rsl_spd_ind); |
| 1594 | mtc.stop; |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1595 | } else if (not st.rtp_stream and rsl_spd_ind != RSL_SPDI_SIGN) { |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1596 | setverdict(fail, "f_establish_fully(): Expected RSL MODE MODIFY", |
| 1597 | " to signalling mode, but got spd_ind == ", rsl_spd_ind); |
| 1598 | mtc.stop; |
| 1599 | } |
Neels Hofmeyr | b5b7a6e | 2021-06-04 19:03:45 +0200 | [diff] [blame] | 1600 | |
| 1601 | if (not istemplatekind(g_pars.expect_tsc, "omit")) { |
| 1602 | var uint3_t got_tsc := rr_chan_desc_tsc(st.rr_channel_mode_modify_msg.msgs.rrm.channelModeModify.channelDescription); |
| 1603 | if (not match(got_tsc, g_pars.expect_tsc)) { |
| 1604 | setverdict(fail, "RR Channel Mode Modify: unexpected TSC in Channel Description: expected ", |
| 1605 | g_pars.expect_tsc, " got ", got_tsc); |
| 1606 | mtc.stop; |
| 1607 | } |
| 1608 | } |
| 1609 | |
| 1610 | } else { |
| 1611 | /* not exp_modify, so this did a Channel Activate */ |
| 1612 | |
| 1613 | /* Check the TSC */ |
| 1614 | if (not istemplatekind(g_pars.expect_tsc, "omit")) { |
| 1615 | var RSL_Message chan_act := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr); |
| 1616 | var RSL_IE_Body ie; |
| 1617 | if (f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, ie)) { |
| 1618 | var uint3_t got_tsc := ie.chan_ident.ch_desc.v.tsc; |
| 1619 | if (not match(got_tsc, g_pars.expect_tsc)) { |
| 1620 | setverdict(fail, "RSL CHANnel ACTIVation: unexpected TSC in Channel Description: expected ", |
| 1621 | g_pars.expect_tsc, " got ", got_tsc); |
| 1622 | mtc.stop; |
| 1623 | } |
| 1624 | } |
| 1625 | } |
Neels Hofmeyr | 559d5d0 | 2021-04-16 16:50:49 +0200 | [diff] [blame] | 1626 | } |
| 1627 | |
Philipp Maier | a0976e9 | 2018-07-16 15:19:42 +0200 | [diff] [blame] | 1628 | /* When the BSC detects that LCLS is possible it will cross the |
| 1629 | * connetions that point to the PBX side of the MGW. In our case this |
| 1630 | * is mgcp_conn[1]. The BSC performs this operation already before the |
| 1631 | * assignment complete is generated. This means we expect another MDCX |
| 1632 | * at mgcp_conn[1] when LCLS is expected. */ |
Max | 2eeb511 | 2018-11-06 19:21:41 +0100 | [diff] [blame] | 1633 | if (g_pars.lcls.adjust_cx_exp and ispresent(exp_ass_cpl.pdu.bssmap.assignmentComplete.lCLS_BSS_Status.lCLS_BSS_StatusValue)) { |
Philipp Maier | a0976e9 | 2018-07-16 15:19:42 +0200 | [diff] [blame] | 1634 | if (valueof(exp_ass_cpl.pdu.bssmap.assignmentComplete.lCLS_BSS_Status.lCLS_BSS_StatusValue) == LCLS_STS_locally_switched) { |
| 1635 | g_media.mgcp_conn[1].mdcx_seen_exp := g_media.mgcp_conn[1].mdcx_seen_exp + 1; |
| 1636 | |
| 1637 | } |
| 1638 | } |
| 1639 | |
Oliver Smith | ce2dd69 | 2023-04-17 10:25:50 +0200 | [diff] [blame] | 1640 | if (not exp_fail and st.rtp_stream and not g_pars.aoip) { |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 1641 | /* With SCCPLite, connect to BSC-located MGW using a CRCX + SDP. |
| 1642 | It is sent in MGCP over IPA in the BSC<->MSC (BSC-NAT) |
| 1643 | connection. BSC will forward it to its MGW. */ |
| 1644 | var template MgcpCommand cmd; |
| 1645 | var template MgcpResponse resp; |
| 1646 | var integer cic := f_bssmap_ie_cic_2_int(ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode); |
| 1647 | var MgcpEndpoint ep := int2str(cic) & "@mgw"; /* 1: matches value configured in BSC_Tests.ttcn pass in AssignReq */ |
| 1648 | var MgcpCallId call_id := '51234'H; |
| 1649 | var SDP_attribute_list attributes := { valueof(ts_SDP_ptime(20)) }; |
Pau Espin Pedrol | f967afc | 2022-08-08 18:17:20 +0200 | [diff] [blame] | 1650 | if (g_pars.use_osmux_cn) { |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 1651 | cmd := ts_CRCX_osmux(get_next_trans_id(), ep, "sendrecv", call_id, cic); |
| 1652 | resp := tr_CRCX_ACK_osmux; |
| 1653 | } else { |
| 1654 | cmd := ts_CRCX(get_next_trans_id(), ep, "sendrecv", call_id); |
| 1655 | resp := tr_CRCX_ACK; |
| 1656 | } |
Pau Espin Pedrol | 0786663 | 2020-09-03 19:10:55 +0200 | [diff] [blame] | 1657 | cmd.sdp := ts_SDP(host_msc, host_mgw_rtp_v4, "23", "42", |
Pau Espin Pedrol | fd02ad4 | 2019-06-18 17:45:20 +0200 | [diff] [blame] | 1658 | 14000, { int2str(g_media.mgcp_conn[1].rtp_pt) }, |
| 1659 | { valueof(ts_SDP_ptime(20)) }); |
| 1660 | mgcp_transceive_mgw(cmd, resp); |
| 1661 | } |
| 1662 | |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 1663 | f_check_mgcp_expectations(); |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 1664 | |
| 1665 | if (st.is_assignment and st.assignment_done) { |
| 1666 | if (not st.old_lchan_deact_sacch_seen) { |
| 1667 | setverdict(fail, "f_establish_fully(): Assignment completed, but the old lchan was not", |
| 1668 | " released properly: expected a Deact SACCH on the old lchan, but saw none."); |
| 1669 | } |
| 1670 | if (st.old_lchan_rll_rel_req_seen) { |
| 1671 | setverdict(fail, "f_establish_fully(): Assignment completed, but the old lchan was not", |
| 1672 | " released properly: saw an RLL Release on the old lchan, but expecting none."); |
| 1673 | } |
| 1674 | } |
Neels Hofmeyr | 9d68630 | 2021-04-25 19:02:29 +0000 | [diff] [blame] | 1675 | |
| 1676 | var charstring lchan_info := f_vty_transceive_ret(BSCVTY, "show lchan 0 0 " & int2str(g_chan_nr.tn) & " 0"); |
| 1677 | if (f_strstr(lchan_info, "State: ESTABLISHED") < 0) { |
| 1678 | log("after f_establish_fully(), 'show lchan' replied: ", lchan_info); |
| 1679 | setverdict(fail, "lchan is not in state ESTABLISHED"); |
| 1680 | mtc.stop; |
| 1681 | } |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 1682 | } |
| 1683 | |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1684 | type record HandoverState { |
| 1685 | /* Assignment related bits */ |
| 1686 | boolean rr_ho_cmpl_seen, |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 1687 | integer mdcx_seen_before_ho, |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1688 | boolean handover_done, |
Neels Hofmeyr | c741fcb | 2021-10-02 14:52:28 +0200 | [diff] [blame] | 1689 | RslChannelNr old_chan_nr, |
| 1690 | uint3_t expect_target_tsc optional |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1691 | }; |
| 1692 | |
| 1693 | altstep as_handover(inout HandoverState st) runs on MSC_ConnHdlr { |
| 1694 | var RSL_Message rsl; |
| 1695 | [not st.rr_ho_cmpl_seen] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl { |
| 1696 | var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload); |
| 1697 | log("Rx L3 from net: ", l3); |
| 1698 | if (ischosen(l3.msgs.rrm.handoverCommand)) { |
| 1699 | var RslChannelNr new_chan_nr; |
| 1700 | var GsmArfcn arfcn; |
| 1701 | f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2, |
| 1702 | new_chan_nr, arfcn); |
| 1703 | /* FIXME: Determine TRX NR by ARFCN, instead of hard-coded TRX0! */ |
| 1704 | |
Neels Hofmeyr | c741fcb | 2021-10-02 14:52:28 +0200 | [diff] [blame] | 1705 | /* Verify correct TSC in handoverCommand */ |
| 1706 | if (ispresent(st.expect_target_tsc)) { |
| 1707 | var uint3_t got_tsc := rr_chan_desc_tsc(l3.msgs.rrm.handoverCommand.channelDescription2); |
| 1708 | if (not match(got_tsc, st.expect_target_tsc)) { |
| 1709 | setverdict(fail, "RR Handover Command: unexpected TSC in Channel Description: expected ", |
| 1710 | st.expect_target_tsc, " got ", got_tsc); |
| 1711 | mtc.stop; |
| 1712 | } else { |
| 1713 | log("handoverCommand: verified TSC = ", got_tsc, " (matches ", |
| 1714 | st.expect_target_tsc, ")"); |
| 1715 | } |
| 1716 | } |
| 1717 | |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1718 | /* register our component for this channel number at the RSL Emulation */ |
| 1719 | f_rslem_register(0, new_chan_nr, RSL1_PROC); |
| 1720 | |
| 1721 | /* resume processing of RSL DChan messages, which was temporarily suspended |
| 1722 | * before performing a hand-over */ |
| 1723 | f_rslem_resume(RSL1_PROC); |
| 1724 | |
Neels Hofmeyr | 378a49c | 2018-06-15 22:18:43 +0200 | [diff] [blame] | 1725 | /* send handover detect */ |
| 1726 | RSL1.send(ts_RSL_HANDO_DET(new_chan_nr)); |
| 1727 | f_sleep(0.3); |
| 1728 | |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1729 | /* send handover complete over the new channel */ |
| 1730 | var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O)); |
Neels Hofmeyr | d07ee13 | 2018-07-14 22:28:29 +0200 | [diff] [blame] | 1731 | RSL1.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)), |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1732 | enc_PDU_ML3_MS_NW(l3_tx))); |
| 1733 | /* by default, send via the new channel from now */ |
| 1734 | st.old_chan_nr := g_chan_nr; |
| 1735 | g_chan_nr := new_chan_nr; |
| 1736 | st.rr_ho_cmpl_seen := true; |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 1737 | |
| 1738 | /* Memorize how many MDCX we have seen before. We need this number to detect |
| 1739 | * that we have received the handover related MDCX */ |
| 1740 | st.mdcx_seen_before_ho := g_media.mgcp_conn[0].mdcx_seen; |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1741 | repeat; |
| 1742 | } else { |
Daniel Willmann | 0c9e3fa | 2018-10-29 15:55:12 +0100 | [diff] [blame] | 1743 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected L3 received", l3)); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1744 | } |
| 1745 | } |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 1746 | [st.rr_ho_cmpl_seen] as_Media_ipacc(); |
Philipp Maier | 09f1c6d | 2020-09-14 21:28:52 +0200 | [diff] [blame] | 1747 | [st.rr_ho_cmpl_seen] as_Media_mgw(); |
Neels Hofmeyr | 861a4c1 | 2018-11-07 01:23:17 +0100 | [diff] [blame] | 1748 | [st.rr_ho_cmpl_seen] RSL.receive(tr_RSL_DEACT_SACCH(st.old_chan_nr)) { |
| 1749 | repeat; |
| 1750 | } |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1751 | [st.rr_ho_cmpl_seen] RSL.receive(tr_RSL_REL_REQ(st.old_chan_nr, tr_RslLinkID_DCCH(0))) { |
| 1752 | RSL.send(ts_RSL_REL_CONF(st.old_chan_nr, valueof(ts_RslLinkID_DCCH(0)))); |
| 1753 | repeat; |
| 1754 | } |
| 1755 | [st.rr_ho_cmpl_seen] RSL.receive(tr_RSL_RF_CHAN_REL(st.old_chan_nr)) { |
| 1756 | RSL.send(ts_RSL_RF_CHAN_REL_ACK(st.old_chan_nr)); |
| 1757 | /* unregister for old channel number in RSL emulation */ |
| 1758 | /* FIXME: Determine TRX NR by ARFCN, instead of hard-coded TRX0! */ |
| 1759 | f_rslem_unregister(0, st.old_chan_nr); |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 1760 | |
| 1761 | /* The channel release must not necessarly be synchronized to the RSL handover |
| 1762 | * procedure since those events may happen independently nearly at the same |
| 1763 | * time. When we receive the RSL_RF_CHAN_REL command the media negotiation on |
| 1764 | * IPACC or MGCP level may be still in progress. In order to make sure that |
| 1765 | * we do only stop when we have seen an MDCX on MGCP level and another a CRCX |
Neels Hofmeyr | ffd2ef1 | 2020-10-12 18:45:58 +0000 | [diff] [blame] | 1766 | * as well as an MDCX on IPACC level. |
| 1767 | * If ipa_crcx_seen is false, this is not a voice channel and we need not check MGCP at all.. */ |
| 1768 | if (g_media.bts.ipa_crcx_seen |
| 1769 | and (g_media.mgcp_conn[0].mdcx_seen <= st.mdcx_seen_before_ho or |
| 1770 | g_media.bts1.ipa_mdcx_seen == false or g_media.bts1.ipa_crcx_seen == false)) { |
Philipp Maier | c1e95c8 | 2018-07-18 16:03:00 +0200 | [diff] [blame] | 1771 | repeat; |
| 1772 | } else { |
| 1773 | st.handover_done := true; |
| 1774 | } |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1775 | } |
| 1776 | } |
| 1777 | |
| 1778 | |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1779 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 1780 | } |