Harald Welte | 1733a38 | 2017-07-23 17:26:17 +0200 | [diff] [blame] | 1 | module BSSGP_Emulation { |
Harald Welte | 1733a38 | 2017-07-23 17:26:17 +0200 | [diff] [blame] | 2 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 3 | /* BSSGP Emulation in TTCN-3 |
Harald Welte | f536524 | 2021-01-17 13:46:57 +0100 | [diff] [blame] | 4 | * (C) 2018-2021 Harald Welte <laforge@gnumonks.org> |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 5 | * All rights reserved. |
| 6 | * |
| 7 | * Released under the terms of GNU General Public License, Version 2 or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * SPDX-License-Identifier: GPL-2.0-or-later |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 11 | * |
| 12 | * This code implements BSSGP asa hierarchy of components: |
| 13 | * - the main BSSGP_CT which runs on top of a NSE (NS Entity). |
| 14 | * - demultiplex based on BVCI. BVCI=0 is handled to a user port |
| 15 | * - a per-BVC BSSGP_BVC_CT which runs on top of BSSGP_CT, it handles |
| 16 | * one PTP BVCI (i.e. one cell) |
| 17 | * - demultiplex based on TLLI |
| 18 | * - a per-TLLI BSSGP_Client_CT which runs on top of BSSGP_BVC_CT |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 19 | */ |
| 20 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 21 | import from General_Types all; |
| 22 | import from Osmocom_Types all; |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 23 | import from NS_Types all; |
| 24 | import from NS_Emulation all; |
| 25 | import from BSSGP_Types all; |
| 26 | import from Osmocom_Gb_Types all; |
| 27 | import from IPL4asp_Types all; |
Pau Espin Pedrol | 011e32f | 2021-02-05 12:07:04 +0100 | [diff] [blame] | 28 | import from Misc_Helpers all; |
Harald Welte | 1733a38 | 2017-07-23 17:26:17 +0200 | [diff] [blame] | 29 | |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 30 | #ifdef BSSGP_EM_L3 |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 31 | import from MobileL3_GMM_SM_Types all; |
| 32 | import from MobileL3_Types all; |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 33 | #endif |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 34 | |
| 35 | import from LLC_Types all; |
| 36 | import from LLC_Templates all; |
| 37 | |
Harald Welte | a2526a8 | 2018-02-18 19:03:36 +0100 | [diff] [blame] | 38 | import from SNDCP_Types all; |
| 39 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 40 | /*********************************************************************** |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 41 | * Communication between Client Components and per-BVC component |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 42 | ***********************************************************************/ |
| 43 | |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 44 | type record BssgpStatusIndication { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 45 | Nsei nsei optional, |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 46 | BssgpBvci bvci, |
| 47 | BvcState state |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | type record BssgpResetIndication { |
| 51 | BssgpBvci bvci |
| 52 | }; |
| 53 | |
| 54 | template (value) BssgpStatusIndication |
| 55 | ts_BssgpStsInd(template (omit) Nsei nsei, template (value) BssgpBvci bvci, |
| 56 | template (value) BvcState state) := { |
| 57 | nsei := nsei, |
| 58 | bvci := bvci, |
| 59 | state := state |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 60 | } |
| 61 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 62 | template (present) BssgpStatusIndication |
| 63 | tr_BssgpStsInd(template Nsei nsei, template (present) BssgpBvci bvci, |
| 64 | template (present) BvcState state) := { |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 65 | nsei := nsei, |
| 66 | bvci := bvci, |
| 67 | state := state |
| 68 | } |
| 69 | |
| 70 | type enumerated BvcState { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 71 | /* SGSN role: waiting to be reset by the peer */ |
| 72 | BVC_S_WAIT_RESET, |
| 73 | /* PCU role: waiting for NS_ALIVE_UNBLOCKED */ |
| 74 | BVC_S_WAIT_NS_ALIVE_UNBLOCKED, |
| 75 | /* BVC-BLOCKED state */ |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 76 | BVC_S_BLOCKED, |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 77 | /* BVC-UNBLOCKED state */ |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 78 | BVC_S_UNBLOCKED |
| 79 | }; |
| 80 | |
| 81 | /* port from our (internal) point of view */ |
| 82 | type port BSSGP_SP_PT message { |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 83 | in PDU_BSSGP, |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 84 | PDU_LLC |
| 85 | #ifdef BSSGP_EM_L3 |
| 86 | , |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 87 | PDU_L3_MS_SGSN, |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 88 | PDU_L3_SGSN_MS |
| 89 | #endif |
| 90 | ; |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 91 | out PDU_BSSGP, |
| 92 | PDU_LLC, |
| 93 | PDU_SN, |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 94 | NsStatusIndication, |
| 95 | BssgpStatusIndication, |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 96 | ASP_Event |
| 97 | #ifdef BSSGP_EM_L3 |
| 98 | , |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 99 | PDU_L3_MS_SGSN, |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 100 | PDU_L3_SGSN_MS |
| 101 | #endif |
| 102 | ; |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 103 | } with { extension "internal" }; |
| 104 | |
| 105 | /* port from the user point of view */ |
| 106 | type port BSSGP_PT message { |
| 107 | in ASP_Event, |
| 108 | NsStatusIndication, |
| 109 | BssgpStatusIndication, |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 110 | PDU_BSSGP, |
| 111 | PDU_LLC, |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 112 | PDU_SN |
| 113 | #ifdef BSSGP_EM_L3 |
| 114 | , |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 115 | PDU_L3_MS_SGSN, |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 116 | PDU_L3_SGSN_MS |
| 117 | #endif |
| 118 | ; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 119 | out PDU_BSSGP, |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 120 | PDU_LLC |
| 121 | #ifdef BSSGP_EM_L3 |
| 122 | , |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 123 | PDU_L3_SGSN_MS, |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 124 | PDU_L3_MS_SGSN |
| 125 | #endif |
| 126 | ; |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 127 | } with { extension "internal" }; |
| 128 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 129 | signature BSSGP_register_client(hexstring imsi, OCT4 tlli); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 130 | signature BSSGP_unregister_client(hexstring imsi); |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 131 | signature BSSGP_llgmm_assign(OCT4 tlli_old, OCT4 tlli); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 132 | |
| 133 | type port BSSGP_PROC_PT procedure { |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 134 | inout BSSGP_register_client, BSSGP_unregister_client, BSSGP_llgmm_assign; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 135 | } with { extension "internal" }; |
| 136 | |
| 137 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 138 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 139 | /*********************************************************************** |
| 140 | * Client Component for a single MS/TLLI |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 141 | *********************************************************************** |
| 142 | * This is what most users will want to derive their test cases from. It |
| 143 | * provides a set of three different ports (PTP, signaling, procedure) |
| 144 | * for (currently up to 3) different Cells. Those ports are all connected |
| 145 | * to one or multiple different per-BVC compoennts, depending on whether |
| 146 | * they share the same BSS or not. |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 147 | ***********************************************************************/ |
| 148 | |
| 149 | type component BSSGP_Client_CT { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 150 | /* one port array for each client; allows talking to up to 3 BVC/Cell (handover, ...) */ |
| 151 | port BSSGP_PT BSSGP[3]; /* PTP-BVC */ |
| 152 | port BSSGP_PT BSSGP_SIG[3]; /* Signaling BVC */ |
Harald Welte | 9b461a9 | 2020-12-10 23:41:14 +0100 | [diff] [blame] | 153 | port BSSGP_PT BSSGP_GLOBAL[3]; /* Signaling BVC */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 154 | port BSSGP_PROC_PT BSSGP_PROC[3]; /* registration / deregistration */ |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 155 | }; |
| 156 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 157 | function f_bssgp_client_register(hexstring imsi, OCT4 tlli, BSSGP_PROC_PT PT := BSSGP_PROC[0]) |
| 158 | runs on BSSGP_Client_CT { |
| 159 | PT.call(BSSGP_register_client:{imsi, tlli}) { |
| 160 | [] PT.getreply(BSSGP_register_client:{imsi, tlli}) {}; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | function f_bssgp_client_unregister(hexstring imsi, BSSGP_PROC_PT PT := BSSGP_PROC[0]) |
| 165 | runs on BSSGP_Client_CT { |
| 166 | PT.call(BSSGP_unregister_client:{imsi}) { |
| 167 | [] PT.getreply(BSSGP_unregister_client:{imsi}) {}; |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | /* TS 44.064 7.2.1.1 LLGMM-ASSIGN */ |
| 172 | function f_bssgp_client_llgmm_assign(OCT4 tlli_old, OCT4 tlli_new, BSSGP_PROC_PT PT := BSSGP_PROC[0]) |
| 173 | runs on BSSGP_Client_CT { |
| 174 | PT.call(BSSGP_llgmm_assign:{tlli_old, tlli_new}) { |
| 175 | [] PT.getreply(BSSGP_llgmm_assign:{tlli_old, tlli_new}) {}; |
| 176 | } |
| 177 | } |
| 178 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 179 | /*********************************************************************** |
| 180 | * Main Component |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 181 | *********************************************************************** |
| 182 | * This component exists once, and it runs on to of the NS_Emulation. |
| 183 | * It handles the BVC-RESET for the signaling BVCI, and dispatches messages |
| 184 | * to the per-BVC components running above it. Messages are routed by: |
| 185 | * - PTP BVCI in NS header (if non-0) |
| 186 | * - BVCI IE in messages on BVCI=0 in NS header |
| 187 | * Messages for which no unique BVC can be identified (like paging without |
| 188 | * a BVCI IE set) are broadcast to all BVC components. |
| 189 | * We also broadcast state changes (BssgpStatusIndication) and reset events |
| 190 | * (BssgpResetIndication) of the signaling BVC to all per-BVC components. |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 191 | ***********************************************************************/ |
| 192 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 193 | function BssgpStart(BssgpConfig cfg, charstring id) runs on BSSGP_CT { |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 194 | g_cfg := cfg; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 195 | |
| 196 | /* create the per-BVC components based on the configuration */ |
| 197 | for (var integer i := 0; i < lengthof(g_cfg.bvc); i := i+1) { |
| 198 | var BssgpBvcConfig bvc_cfg := g_cfg.bvc[i]; |
| 199 | var charstring bvc_id := id & "-BVCI" & int2str(bvc_cfg.bvci); |
| 200 | /* create, connect and start the BVC component */ |
Pau Espin Pedrol | ee57d1c | 2022-02-22 15:53:48 +0100 | [diff] [blame] | 201 | var BSSGP_BVC_CT bvc_ct := BSSGP_BVC_CT.create(bvc_id) alive; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 202 | connect(bvc_ct:BVC, self:BVC); |
Harald Welte | fba7afd | 2020-11-24 23:12:31 +0100 | [diff] [blame] | 203 | bvc_ct.start(f_bssgp_bvc_main(bvc_cfg, g_cfg.sgsn_role, g_cfg.nsei, bvc_id)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 204 | /* populate the BVC state table */ |
| 205 | BvcTable[i] := { |
| 206 | bvci := bvc_cfg.bvci, |
| 207 | cell_id := bvc_cfg.cell_id, |
| 208 | comp_ref := bvc_ct |
| 209 | }; |
| 210 | } |
| 211 | |
| 212 | if (g_cfg.sgsn_role) { |
| 213 | /* The SGSN side waits for an inbound BVC-RESET on the signaling BVC */ |
| 214 | f_sign_change_state(BVC_S_WAIT_RESET); |
| 215 | } else { |
| 216 | /* The BSS/PCU side waits for an inbound NsStatusIndication to Tx BVC-RESET */ |
| 217 | f_sign_change_state(BVC_S_WAIT_NS_ALIVE_UNBLOCKED); |
| 218 | } |
| 219 | |
| 220 | /* main loop */ |
| 221 | f_bssgp_ScanEvents(); |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 222 | } |
| 223 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 224 | /* master component, exists once per BSSGP instance (NSE) */ |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 225 | type component BSSGP_CT { |
Stefan Sperling | f82bbb6 | 2018-05-03 19:14:28 +0200 | [diff] [blame] | 226 | /* UDP ports towards the bottom (IUT) */ |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 227 | port NS_PT BSCP; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 228 | |
| 229 | /* control by the user */ |
| 230 | port BSSGP_CT_PROC_PT PROC; |
| 231 | |
Harald Welte | 57de220 | 2020-11-24 18:15:02 +0100 | [diff] [blame] | 232 | /* global port for procedures without any relation to a BVC |
| 233 | * (currently only) SUSPEND/RESUME */ |
| 234 | port BSSGP_SP_PT GLOBAL; |
| 235 | |
Harald Welte | 0083ea6 | 2020-12-02 21:30:44 +0100 | [diff] [blame] | 236 | /* RAN INFORMATION MGMT */ |
| 237 | port BSSGP_SP_PT RIM; |
| 238 | |
Harald Welte | bdf96d8 | 2020-11-27 18:58:46 +0100 | [diff] [blame] | 239 | /* port to a management instance */ |
| 240 | port BSSGP_BVC_MGMT_SP_PT MGMT; |
| 241 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 242 | var BssgpConfig g_cfg; |
| 243 | |
| 244 | /* Signaling BVC (BVCI=0) */ |
| 245 | var BvcState g_sign_bvc_state := BVC_S_WAIT_RESET; |
| 246 | timer g_T2 := 60.0; |
| 247 | |
| 248 | /* port to per-BVC components */ |
| 249 | port BSSGP_BVC_SP_PT BVC; |
| 250 | /* per-BVC state table */ |
Harald Welte | 633805b | 2021-02-03 17:47:18 +0100 | [diff] [blame] | 251 | var BvcEntity BvcTable[64]; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 252 | }; |
| 253 | |
| 254 | /* one element in the per-BVC state table */ |
| 255 | type record BvcEntity { |
| 256 | /* PTP BVCI of this BVC/Cell */ |
| 257 | BssgpBvci bvci, |
| 258 | /* Cell Identity of this cell */ |
| 259 | BssgpCellId cell_id, |
| 260 | /* reference to the per-BVC/cell component */ |
| 261 | BSSGP_BVC_CT comp_ref |
| 262 | }; |
| 263 | |
| 264 | /* find the per-BVC component for a given BVCI */ |
| 265 | private function f_comp_for_bvci(BssgpBvci bvci) runs on BSSGP_CT return BSSGP_BVC_CT { |
| 266 | var integer i; |
| 267 | |
| 268 | for (i := 0; i < lengthof(BvcTable); i := i+1) { |
| 269 | if (BvcTable[i].bvci == bvci) { |
| 270 | return BvcTable[i].comp_ref; |
| 271 | } |
| 272 | } |
| 273 | return null; |
| 274 | } |
| 275 | |
| 276 | /* We are in BVC_S_WAIT_RSET state (only happens in SGSN role) */ |
| 277 | altstep as_sig_wait_reset() runs on BSSGP_CT { |
| 278 | var NsUnitdataIndication udi; |
| 279 | |
| 280 | /* Respond to RESET for signalling BVCI 0 */ |
| 281 | [] BSCP.receive(f_BnsUdInd(tr_BVC_RESET(?, 0, omit), 0)) -> value udi { |
| 282 | log("Rx BVC-RESET for Signaling BVCI=0"); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 283 | f_sign_change_state(BVC_S_UNBLOCKED); |
Harald Welte | bdf96d8 | 2020-11-27 18:58:46 +0100 | [diff] [blame] | 284 | if (MGMT.checkstate("Connected")) { |
| 285 | MGMT.send(BssgpResetIndication:{0}); |
| 286 | } |
| 287 | BSCP.send(f_BnsUdReq(ts_BVC_RESET_ACK(0, omit), 0, 0)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 288 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Harald Welte | 27a70cc | 2020-12-09 11:57:41 +0100 | [diff] [blame] | 291 | private template PDU_BSSGP tr_GLOBAL_SIG := ( |
Harald Welte | 57de220 | 2020-11-24 18:15:02 +0100 | [diff] [blame] | 292 | {pDU_BSSGP_SUSPEND:=?}, {pDU_BSSGP_SUSPEND_ACK:=?}, {pDU_BSSGP_SUSPEND_NACK:=?}, |
Harald Welte | f8e5c5d | 2020-11-27 22:37:23 +0100 | [diff] [blame] | 293 | {pDU_BSSGP_RESUME:=?}, {pDU_BSSGP_RESUME_ACK:=?}, {pDU_BSSGP_RESUME_NACK:=?}, |
Harald Welte | f536524 | 2021-01-17 13:46:57 +0100 | [diff] [blame] | 294 | {pDU_BSSGP_SGSN_INVOKE_TRACE:=?}, {pDU_BSSGP_OVERLOAD:=?}, {pDU_BSSGP_STATUS:=?} |
Harald Welte | 57de220 | 2020-11-24 18:15:02 +0100 | [diff] [blame] | 295 | ); |
| 296 | |
Harald Welte | 0083ea6 | 2020-12-02 21:30:44 +0100 | [diff] [blame] | 297 | /* BSSGP messages that should arrive on the RIM port */ |
| 298 | private template PDU_BSSGP tr_RIM := ( |
| 299 | {pDU_BSSGP_RAN_INFORMATION:=?}, {pDU_BSSGP_RAN_INFORMATION_REQUEST:=?}, |
| 300 | {pDU_BSSGP_RAN_INFORMATION_ACK:=?}, {pDU_BSSGP_RAN_INFORMATION_ERROR:=?}, |
| 301 | {pDU_BSSGP_RAN_INFORMATION_APPLICATION_ERROR:=?} |
| 302 | ); |
| 303 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 304 | /* We are in BVC_S_UNBLOCKED state */ |
| 305 | altstep as_sig_unblocked() runs on BSSGP_CT { |
| 306 | var BSSGP_BVC_CT bvc_comp_ref; |
| 307 | var BSSGP_Client_CT vc_conn; |
| 308 | var NsUnitdataIndication udi; |
| 309 | var NsUnitdataRequest udr; |
Harald Welte | 57de220 | 2020-11-24 18:15:02 +0100 | [diff] [blame] | 310 | var PDU_BSSGP bssgp; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 311 | |
| 312 | /* Messages PTP BVCI in BVCI field of NS: dispatch by that */ |
| 313 | [] BSCP.receive(f_BnsUdInd(?, (2..65535))) -> value udi { |
| 314 | bvc_comp_ref := f_comp_for_bvci(valueof(udi.bvci)); |
| 315 | if (isbound(bvc_comp_ref) and bvc_comp_ref != null) { |
| 316 | /* dispatch to BVC component */ |
| 317 | BVC.send(udi) to bvc_comp_ref; |
| 318 | } else { |
| 319 | setverdict(fail, "Rx BSSGP for unknown PTP BVCI ", udi.bvci, ": ", udi.bssgp); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 320 | BSCP.send(f_BnsUdReq(ts_BSSGP_STATUS(udi.bvci, BSSGP_CAUSE_BVCI_UNKNOWN, udi.bssgp), udi.bvci, 0)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | |
| 324 | /* Messages with BVCI = 0 (Signaling) in BVCI field of NS */ |
Harald Welte | 27a70cc | 2020-12-09 11:57:41 +0100 | [diff] [blame] | 325 | [] BSCP.receive(f_BnsUdInd(tr_GLOBAL_SIG, 0)) -> value udi { |
Daniel Willmann | c5bbcc6 | 2021-09-24 13:17:20 +0200 | [diff] [blame] | 326 | if (GLOBAL.checkstate("Connected")) { |
| 327 | GLOBAL.send(udi.bssgp); |
| 328 | } |
Harald Welte | 57de220 | 2020-11-24 18:15:02 +0100 | [diff] [blame] | 329 | } |
Harald Welte | 0083ea6 | 2020-12-02 21:30:44 +0100 | [diff] [blame] | 330 | [] BSCP.receive(f_BnsUdInd(tr_RIM, 0)) -> value udi { |
| 331 | if (RIM.checkstate("Connected")) { |
| 332 | RIM.send(udi.bssgp); |
| 333 | } |
| 334 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 335 | |
Daniel Willmann | ef8e50e | 2021-11-26 11:41:50 +0100 | [diff] [blame] | 336 | /* Broadcast FLUSH_LL_ACK no matter the BVCI */ |
| 337 | [] BSCP.receive(f_BnsUdInd(tr_BSSGP_FLUSH_LL_ACK(?, ?, ?), 0)) -> value udi { |
| 338 | log("Rx FLUSH_LL_ACK: broadcasting"); |
| 339 | for (var integer i := 0; i < lengthof(BvcTable); i := i+1) { |
| 340 | if (isbound(BvcTable[i].comp_ref) and BvcTable[i].comp_ref != null) { |
| 341 | BVC.send(udi) to BvcTable[i].comp_ref; |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 346 | /* Route based on PTP BVCI in payload/IE of signaling PDU */ |
| 347 | [] BSCP.receive(f_BnsUdInd(?, 0)) -> value udi { |
| 348 | var template (omit) BssgpBvci ptp_bvci := f_BSSGP_BVCI_get(udi.bssgp); |
| 349 | if (istemplatekind(ptp_bvci, "omit")) { |
| 350 | log("Rx on SIG BVCI without PTP BVCI: broadcasting"); |
| 351 | for (var integer i := 0; i < lengthof(BvcTable); i := i+1) { |
| 352 | if (isbound(BvcTable[i].comp_ref) and BvcTable[i].comp_ref != null) { |
| 353 | BVC.send(udi) to BvcTable[i].comp_ref; |
| 354 | } |
| 355 | } |
| 356 | } else { |
| 357 | bvc_comp_ref := f_comp_for_bvci(valueof(ptp_bvci)); |
| 358 | if (isbound(bvc_comp_ref) and bvc_comp_ref != null) { |
| 359 | /* dispatch to BVC component */ |
| 360 | BVC.send(udi) to bvc_comp_ref; |
| 361 | } else { |
| 362 | setverdict(fail, "Rx SIG BSSGP for unknown PTP BVCI ", ptp_bvci, ": ", udi.bssgp); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 363 | BSCP.send(f_BnsUdReq(ts_BSSGP_STATUS(udi.bvci, BSSGP_CAUSE_BVCI_UNKNOWN, udi.bssgp), 0, 0)); |
Pau Espin Pedrol | 847a165 | 2021-02-05 12:08:04 +0100 | [diff] [blame] | 364 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 365 | } |
| 366 | } |
| 367 | |
| 368 | /* Handle PS-PAGING on SIGN BVCI with no conditional BVCI IE */ |
| 369 | [] BSCP.receive(f_BnsUdInd(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}, 0)) -> value udi { |
| 370 | /* FIXME: use LA, RA or BSS Area to dispatch instead of broadcast */ |
| 371 | for (var integer i := 0; i < lengthof(BvcTable); i := i+1) { |
| 372 | if (isbound(BvcTable[i].comp_ref) and BvcTable[i].comp_ref != null) { |
| 373 | BVC.send(udi) to BvcTable[i].comp_ref; |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | /* Handle CS-PAGING on SIGN BVCI with no conditional BVCI IE */ |
| 378 | [] BSCP.receive(f_BnsUdInd(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}, 0)) -> value udi { |
| 379 | /* FIXME: use LA, RA or BSS Area to dispatch instead of broadcast */ |
| 380 | for (var integer i := 0; i < lengthof(BvcTable); i := i+1) { |
| 381 | if (isbound(BvcTable[i].comp_ref) and BvcTable[i].comp_ref != null) { |
| 382 | BVC.send(udi) to BvcTable[i].comp_ref; |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | /* per-BVC component sends us something; forward to NS without any validation */ |
| 388 | [] BVC.receive(NsUnitdataRequest:?) -> value udr { |
| 389 | /* patch in the NSEI, as the per-BVC components have no idea about it */ |
| 390 | udr.nsei := g_cfg.nsei; |
| 391 | BSCP.send(udr); |
| 392 | } |
Harald Welte | 57de220 | 2020-11-24 18:15:02 +0100 | [diff] [blame] | 393 | |
Harald Welte | 27a70cc | 2020-12-09 11:57:41 +0100 | [diff] [blame] | 394 | [] GLOBAL.receive(tr_GLOBAL_SIG) -> value bssgp { |
Harald Welte | 57de220 | 2020-11-24 18:15:02 +0100 | [diff] [blame] | 395 | BSCP.send(f_BnsUdReq(bssgp, 0, 0)); |
| 396 | } |
Harald Welte | 0083ea6 | 2020-12-02 21:30:44 +0100 | [diff] [blame] | 397 | |
| 398 | [] RIM.receive(tr_RIM) -> value bssgp { |
| 399 | BSCP.send(f_BnsUdReq(bssgp, 0, 0)); |
| 400 | } |
| 401 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | /* We are in BVC_S_WAIT_NS_ALIVE_UNBLOCKED (only happens in BSS role) */ |
| 405 | altstep as_sig_wait_ns_alive_unblocked() runs on BSSGP_CT { |
| 406 | var NsStatusIndication nsi; |
Harald Welte | dc0a090 | 2020-11-10 21:03:29 +0100 | [diff] [blame] | 407 | [] BSCP.receive(NsStatusIndication:{g_cfg.nsei,?, complement (NSVC_S_ALIVE_UNBLOCKED), NSVC_S_ALIVE_UNBLOCKED, true}) -> value nsi { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 408 | /* if we just became NS-unblocked, send a BCC-RESET */ |
| 409 | if (g_cfg.sgsn_role == false) { |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 410 | BSCP.send(f_BnsUdReq(ts_BVC_RESET(BSSGP_CAUSE_OM_INTERVENTION, 0, omit), 0, 0)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 411 | g_T2.start; |
| 412 | /* The BVC_RESET_ACK is handled in the as_sig_allstate() below */ |
| 413 | } |
| 414 | /* Idea: We could send BVC-UNBLOCK here like some SGSN do */ |
| 415 | } |
| 416 | |
| 417 | } |
| 418 | |
Harald Welte | e588792 | 2020-11-27 19:04:46 +0100 | [diff] [blame] | 419 | /* handling of events irrespective of BVC state (before state-specific handling) */ |
| 420 | altstep as_sig_allstate_pre() runs on BSSGP_CT { |
| 421 | var NsUnitdataIndication udi; |
| 422 | |
| 423 | /* Respond to RESET for signalling BVCI 0 */ |
| 424 | [] BSCP.receive(f_BnsUdInd(tr_BVC_RESET(?, 0, omit), 0)) -> value udi { |
| 425 | log("Rx BVC-RESET for Signaling BVCI=0"); |
| 426 | if (MGMT.checkstate("Connected")) { |
| 427 | MGMT.send(BssgpResetIndication:{0}); |
| 428 | } |
| 429 | BSCP.send(f_BnsUdReq(ts_BVC_RESET_ACK(0, omit), 0, 0)); |
| 430 | for (var integer i := 0; i < sizeof(BvcTable); i := i+1) { |
| 431 | if (isbound(BvcTable[i].comp_ref) and BvcTable[i].comp_ref != null) { |
| 432 | BVC.send(BssgpResetIndication:{0}) to BvcTable[i].comp_ref; |
| 433 | } |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | /* any BLOCK or UNBLOCK for the SIGNALING BVCI are illegal */ |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 438 | [] BSCP.receive(f_BnsUdInd(tr_BVC_BLOCK(0, ?), 0)) -> value udi { |
Harald Welte | e588792 | 2020-11-27 19:04:46 +0100 | [diff] [blame] | 439 | setverdict(fail, "Rx BVC-BLOCK illegal for BVCI=0: ", udi); |
| 440 | } |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 441 | [] BSCP.receive(f_BnsUdInd(tr_BVC_UNBLOCK(0), 0)) -> value udi { |
Harald Welte | e588792 | 2020-11-27 19:04:46 +0100 | [diff] [blame] | 442 | setverdict(fail, "Rx BVC-UNBLOCK illegal for BVCI=0: ", udi); |
| 443 | } |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 444 | [] BSCP.receive(f_BnsUdInd(tr_BVC_BLOCK_ACK(0), 0)) -> value udi { |
Harald Welte | e588792 | 2020-11-27 19:04:46 +0100 | [diff] [blame] | 445 | setverdict(fail, "Rx BVC-BLOCK-ACK illegal for BVCI=0: ", udi); |
| 446 | } |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 447 | [] BSCP.receive(f_BnsUdInd(tr_BVC_UNBLOCK_ACK(0), 0)) -> value udi { |
Harald Welte | e588792 | 2020-11-27 19:04:46 +0100 | [diff] [blame] | 448 | setverdict(fail, "Rx BVC-UNBLOCK-ACK illegal for BVCI=0: ", udi); |
| 449 | } |
| 450 | |
| 451 | /* BVC-RESET-ACK for BVCI=0 while T2 is running: Answer to a BVC-RESET we sent earlier */ |
| 452 | [g_T2.running] BSCP.receive(f_BnsUdInd(tr_BVC_RESET_ACK(0, omit), 0)) -> value udi { |
| 453 | log("BVCI(0) Rx BVC-RESET-ACK"); |
| 454 | g_T2.stop; |
| 455 | f_sign_change_state(BVC_S_UNBLOCKED); |
| 456 | for (var integer i := 0; i < sizeof(BvcTable); i := i+1) { |
| 457 | if (isbound(BvcTable[i].comp_ref) and BvcTable[i].comp_ref != null) { |
| 458 | BVC.send(BssgpResetIndication:{0}) to BvcTable[i].comp_ref; |
| 459 | } |
| 460 | } |
| 461 | } |
Pau Espin Pedrol | 8afdee1 | 2022-02-22 15:30:26 +0100 | [diff] [blame] | 462 | [g_T2.running] g_T2.timeout { |
Harald Welte | e588792 | 2020-11-27 19:04:46 +0100 | [diff] [blame] | 463 | setverdict(fail, "Timeout waiting for BVC-RESET-ACK on BVCI=0"); |
| 464 | BSCP.send(f_BnsUdReq(ts_BSSGP_STATUS(udi.bvci, BSSGP_CAUSE_BVCI_UNKNOWN, udi.bssgp), 0, 0)); |
| 465 | g_T2.start; |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | /* handling of events irrespective of BVC state (after state-specific handling) */ |
| 470 | altstep as_sig_allstate_post() runs on BSSGP_CT { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 471 | var BSSGP_Client_CT vc_conn; |
| 472 | var NsUnitdataIndication udi; |
| 473 | var NsStatusIndication nsi; |
| 474 | var ASP_Event evt; |
| 475 | var BSSGP_BVC_CT bvc_comp_ref; |
| 476 | var BssgpBvci bvci; |
Harald Welte | e588792 | 2020-11-27 19:04:46 +0100 | [diff] [blame] | 477 | var BssgpResetRequest brr; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 478 | |
| 479 | /* Respond to RESET for signalling BVCI 0 */ |
| 480 | [] BSCP.receive(f_BnsUdInd(tr_BVC_RESET(?, 0, omit), 0)) -> value udi { |
| 481 | log("Rx BVC-RESET for Signaling BVCI=0"); |
Harald Welte | bdf96d8 | 2020-11-27 18:58:46 +0100 | [diff] [blame] | 482 | if (MGMT.checkstate("Connected")) { |
| 483 | MGMT.send(BssgpResetIndication:{0}); |
| 484 | } |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 485 | BSCP.send(f_BnsUdReq(ts_BVC_RESET_ACK(0, omit), 0, 0)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 486 | for (var integer i := 0; i < sizeof(BvcTable); i := i+1) { |
| 487 | if (isbound(BvcTable[i].comp_ref) and BvcTable[i].comp_ref != null) { |
| 488 | BVC.send(BssgpResetIndication:{0}) to BvcTable[i].comp_ref; |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | /* any BLOCK or UNBLOCK for the SIGNALING BVCI are illegal */ |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 494 | [] BSCP.receive(f_BnsUdInd(tr_BVC_BLOCK(0, ?), 0)) -> value udi { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 495 | setverdict(fail, "Rx BVC-BLOCK illegal for BVCI=0: ", udi); |
| 496 | } |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 497 | [] BSCP.receive(f_BnsUdInd(tr_BVC_UNBLOCK(0), 0)) -> value udi { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 498 | setverdict(fail, "Rx BVC-UNBLOCK illegal for BVCI=0: ", udi); |
| 499 | } |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 500 | [] BSCP.receive(f_BnsUdInd(tr_BVC_BLOCK_ACK(0), 0)) -> value udi { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 501 | setverdict(fail, "Rx BVC-BLOCK-ACK illegal for BVCI=0: ", udi); |
| 502 | } |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 503 | [] BSCP.receive(f_BnsUdInd(tr_BVC_UNBLOCK_ACK(0), 0)) -> value udi { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 504 | setverdict(fail, "Rx BVC-UNBLOCK-ACK illegal for BVCI=0: ", udi); |
| 505 | } |
| 506 | |
| 507 | /* Respond to BLOCK for wrong BVCI */ |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 508 | [] BSCP.receive(f_BnsUdInd(tr_BVC_BLOCK(?, ?), 0)) -> value udi { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 509 | setverdict(fail, "Rx BVC-BLOCK for unknown BVCI"); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 510 | BSCP.send(f_BnsUdReq(ts_BSSGP_STATUS(0, BSSGP_CAUSE_BVCI_UNKNOWN, udi.bssgp), 0, 0)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | /* Respond to RESET with wrong BVCI */ |
| 514 | [] BSCP.receive(f_BnsUdInd(tr_BVC_RESET(?, ?, ?), 0)) -> value udi { |
| 515 | var BssgpBvci ptp_bvci := oct2int(udi.bssgp.pDU_BSSGP_BVC_RESET.bVCI.unstructured_value); |
| 516 | setverdict(fail, "Rx BVC-RESET for unknown BVCI ", ptp_bvci); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 517 | BSCP.send(f_BnsUdReq(ts_BSSGP_STATUS(ptp_bvci, BSSGP_CAUSE_BVCI_UNKNOWN, udi.bssgp), 0, 0)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 518 | } |
| 519 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 520 | /* Forwarding of ASP_Event to per-BVC components */ |
| 521 | [] BSCP.receive(ASP_Event:?) -> value evt { |
| 522 | for (var integer i := 0; i < sizeof(BvcTable); i := i+1) { |
| 523 | if (isbound(BvcTable[i].comp_ref) and BvcTable[i].comp_ref != null) { |
| 524 | BVC.send(evt) to BvcTable[i].comp_ref; |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | /* Keep NS Status Indicaitons to us; no need to inform per-BVC components [for now?] */ |
Harald Welte | dc0a090 | 2020-11-10 21:03:29 +0100 | [diff] [blame] | 529 | [] BSCP.receive(tr_NsStsInd(g_cfg.nsei)) -> value nsi { } |
Harald Welte | 445fc61 | 2020-11-10 19:15:30 +0100 | [diff] [blame] | 530 | /* We should never see any different NSEI: There's one BSSGP_CT per NSE */ |
Harald Welte | dc0a090 | 2020-11-10 21:03:29 +0100 | [diff] [blame] | 531 | [] BSCP.receive(tr_NsStsInd(?)) -> value nsi { |
Harald Welte | 445fc61 | 2020-11-10 19:15:30 +0100 | [diff] [blame] | 532 | setverdict(fail, "Rx NsStatusInd for wrong NSEI ", nsi); |
| 533 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 534 | |
| 535 | /* Procedure port request to resolve the per-BVC component for a given ptp BVCI */ |
| 536 | [] PROC.getcall(BSSGP_get_bvci_ct:{?}) -> param(bvci) sender vc_conn { |
| 537 | for (var integer i := 0; i < sizeof(BvcTable); i := i+1) { |
| 538 | if (BvcTable[i].bvci == bvci) { |
| 539 | PROC.reply(BSSGP_get_bvci_ct:{bvci} value BvcTable[i].comp_ref) to vc_conn; |
| 540 | return; |
| 541 | } |
| 542 | } |
| 543 | } |
Harald Welte | e588792 | 2020-11-27 19:04:46 +0100 | [diff] [blame] | 544 | |
| 545 | /* default case of handling unknown PDUs */ |
| 546 | [] BSCP.receive(f_BnsUdInd(?, ?)) -> value udi { |
| 547 | setverdict(fail, "Rx Unexpected BSSGP PDU ", udi.bssgp," in state ", g_sign_bvc_state); |
| 548 | BSCP.send(f_BnsUdReq(ts_BSSGP_STATUS(0, BSSGP_CAUSE_PDU_NOT_COMPATIBLE_WITH_PROTOCOL_STATE, udi.bssgp), 0, 0)); |
| 549 | } |
| 550 | |
| 551 | [] MGMT.receive(BssgpResetRequest:?) -> value brr { |
| 552 | BSCP.send(f_BnsUdReq(ts_BVC_RESET(brr.cause, 0, omit), 0, 0)); |
| 553 | g_T2.start; |
| 554 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | /* send the highest decoded layer of the message through given port */ |
| 558 | private function f_send_bssgp_dec(BssgpDecoded dec, BSSGP_Client_CT vc_conn, BSSGP_SP_PT pt) { |
| 559 | #ifdef BSSGP_EM_L3 |
| 560 | if (ispresent(dec.l3_mt)) { |
| 561 | pt.send(dec.l3_mt) to vc_conn; |
| 562 | } else if (ispresent(dec.l3_mo)) { |
| 563 | pt.send(dec.l3_mo) to vc_conn; |
| 564 | } else |
| 565 | #endif |
| 566 | if (ispresent(dec.sndcp)) { |
| 567 | pt.send(dec.sndcp) to vc_conn; |
| 568 | } else if (ispresent(dec.llc)) { |
| 569 | pt.send(dec.llc) to vc_conn; |
| 570 | } else { |
| 571 | pt.send(dec.bssgp) to vc_conn; |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | |
| 576 | function f_llc_get_n_u_tx(inout LLC_Entity llc) return uint9_t { |
| 577 | var uint9_t ret := llc.n_u_tx_next; |
| 578 | llc.n_u_tx_next := llc.n_u_tx_next + 1; |
| 579 | return ret; |
| 580 | } |
| 581 | |
| 582 | #ifdef BSSGP_EM_L3 |
| 583 | function f_llc_sapi_by_l3_mo(PDU_L3_MS_SGSN l3_mo) return BIT4 { |
| 584 | if (ischosen(l3_mo.msgs.gprs_mm)) { |
| 585 | return c_LLC_SAPI_LLGMM; |
| 586 | } else if (ischosen(l3_mo.msgs.gprs_sm)) { |
| 587 | return c_LLC_SAPI_LLGMM; |
| 588 | } else if (ischosen(l3_mo.msgs.sms)) { |
| 589 | return c_LLC_SAPI_LLSMS; |
| 590 | } |
Pau Espin Pedrol | 011e32f | 2021-02-05 12:07:04 +0100 | [diff] [blame] | 591 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No LLC SAPI for ", l3_mo)); |
| 592 | return '0000'B; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | private function f_llc_sapi_by_l3_mt(PDU_L3_SGSN_MS l3_mt) return BIT4 { |
| 596 | if (ischosen(l3_mt.msgs.gprs_mm)) { |
| 597 | return c_LLC_SAPI_LLGMM; |
| 598 | } else if (ischosen(l3_mt.msgs.gprs_sm)) { |
| 599 | return c_LLC_SAPI_LLGMM; |
| 600 | } else if (ischosen(l3_mt.msgs.sms)) { |
| 601 | return c_LLC_SAPI_LLSMS; |
| 602 | } |
Pau Espin Pedrol | 011e32f | 2021-02-05 12:07:04 +0100 | [diff] [blame] | 603 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No LLC SAPI for ", l3_mt)); |
| 604 | return '0000'B; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 605 | } |
| 606 | #endif |
| 607 | |
| 608 | /* main loop of BSSGP_CT */ |
| 609 | private function f_bssgp_ScanEvents() runs on BSSGP_CT { |
| 610 | while (true) { |
| 611 | alt { |
| 612 | [g_sign_bvc_state == BVC_S_WAIT_RESET] as_sig_wait_reset(); |
Harald Welte | e588792 | 2020-11-27 19:04:46 +0100 | [diff] [blame] | 613 | [] as_sig_allstate_pre(); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 614 | [g_sign_bvc_state == BVC_S_WAIT_NS_ALIVE_UNBLOCKED] as_sig_wait_ns_alive_unblocked(); |
| 615 | [g_sign_bvc_state == BVC_S_UNBLOCKED] as_sig_unblocked(); |
Harald Welte | e588792 | 2020-11-27 19:04:46 +0100 | [diff] [blame] | 616 | [g_sign_bvc_state == BVC_S_WAIT_RESET] as_sig_wait_reset(); |
| 617 | [] as_sig_allstate_post(); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 618 | } |
| 619 | } /* while */ |
| 620 | } |
| 621 | |
| 622 | /* generate a send template. Cannot be a real template as we want to use g_cfg.nsei */ |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 623 | private function f_BnsUdReq(template PDU_BSSGP pdu, BssgpBvci bvci, integer lsp) |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 624 | runs on BSSGP_CT return NsUnitdataRequest { |
| 625 | var NsUnitdataRequest udr := { |
| 626 | bvci := bvci, |
| 627 | nsei := g_cfg.nsei, |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 628 | lsp := lsp, |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 629 | /* for some weird reason we get "Dynamic test case error: Text encoder: Encoding an |
| 630 | * unbound integer value." when trying to send the reocrd rather than the octetstring */ |
| 631 | //sdu := omit, |
| 632 | //bssgp := valueof(pdu) |
| 633 | sdu := enc_PDU_BSSGP(valueof(pdu)), |
| 634 | bssgp := omit |
| 635 | } |
| 636 | return udr; |
| 637 | } |
| 638 | |
| 639 | /* generate a receive template. Cannot be a real template as we want to use g_cfg.nsei */ |
| 640 | private function f_BnsUdInd(template PDU_BSSGP pdu, template BssgpBvci bvci) |
| 641 | runs on BSSGP_CT return template (present) NsUnitdataIndication { |
| 642 | var template (present) NsUnitdataIndication udi := { |
| 643 | bvci := bvci, |
| 644 | nsei := g_cfg.nsei, |
Harald Welte | 80a249a | 2020-11-17 19:57:40 +0100 | [diff] [blame] | 645 | nsvci := ?, |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 646 | sdu := *, |
| 647 | bssgp := pdu |
| 648 | } |
| 649 | return udi; |
| 650 | } |
| 651 | |
| 652 | /* change state of signaling BVCI; notify per-BVC components */ |
| 653 | private function f_sign_change_state(BvcState new_state) runs on BSSGP_CT { |
| 654 | if (new_state == g_sign_bvc_state) { |
| 655 | return; |
| 656 | } |
| 657 | log("BVCI(0) State Transition: ", g_sign_bvc_state, " -> ", new_state); |
| 658 | g_sign_bvc_state := new_state; |
| 659 | for (var integer i := 0; i < sizeof(BvcTable); i := i+1) { |
| 660 | if (isbound(BvcTable[i].comp_ref) and BvcTable[i].comp_ref != null) { |
| 661 | BVC.send(ts_BssgpStsInd(g_cfg.nsei, 0, g_sign_bvc_state)) to BvcTable[i].comp_ref; |
| 662 | } |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | /* User wants to get per-BVC component reference from BSSGP_CT */ |
| 667 | signature BSSGP_get_bvci_ct(BssgpBvci bvci) return BSSGP_BVC_CT; |
| 668 | |
| 669 | type port BSSGP_CT_PROC_PT procedure { |
| 670 | inout BSSGP_get_bvci_ct |
| 671 | } with { extension "internal" }; |
| 672 | |
| 673 | /* convenience wrapper function for user */ |
| 674 | function f_bssgp_get_bvci_ct(BssgpBvci bvci, BSSGP_CT_PROC_PT PT) return BSSGP_BVC_CT { |
| 675 | var BSSGP_BVC_CT res; |
| 676 | PT.call(BSSGP_get_bvci_ct:{bvci}) { |
| 677 | [] PT.getreply(BSSGP_get_bvci_ct:{bvci})-> value res { |
| 678 | return res; |
| 679 | } |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | /*********************************************************************** |
| 684 | * per-BVC (Cell) Component |
| 685 | *********************************************************************** |
| 686 | * Any number of these components runs on top of the BSSGP_CT, each |
| 687 | * representing one PTP BVC within this NSE. Users (test cases) can |
| 688 | * register with TLLI and/or IMSI via the procedure port. |
| 689 | ***********************************************************************/ |
| 690 | |
| 691 | /* per-BVC component. Exists once per cell within a BSSGP_CT */ |
| 692 | type component BSSGP_BVC_CT { |
| 693 | /* port towards the underlying BSSGP_CT */ |
| 694 | port BSSGP_BVC_PT BVC; |
| 695 | |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 696 | /* port to a management instance */ |
| 697 | port BSSGP_BVC_MGMT_SP_PT MGMT; |
| 698 | |
Harald Welte | 71449b0 | 2020-12-09 11:58:23 +0100 | [diff] [blame] | 699 | /* per-BVC global port for e.g. BVC Flow Control */ |
| 700 | port BSSGP_SP_PT GLOBAL; |
| 701 | |
| 702 | /* BSSGP-User SAP towards the user (per-TLLI, Client) */ |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 703 | port BSSGP_SP_PT BSSGP_SP; |
Stefan Sperling | f82bbb6 | 2018-05-03 19:14:28 +0200 | [diff] [blame] | 704 | port BSSGP_SP_PT BSSGP_SP_SIG; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 705 | port BSSGP_PROC_PT BSSGP_PROC; |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 706 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 707 | var BssgpBvcConfig g_cfg; |
| 708 | var boolean g_sgsn_role; |
Harald Welte | fba7afd | 2020-11-24 23:12:31 +0100 | [diff] [blame] | 709 | var Nsei g_nsei; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 710 | |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 711 | /* default Link Selector Parameter for this BVC (for traffic unrelated to a TLLI) */ |
| 712 | var integer g_bvc_lsp; |
| 713 | |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 714 | var BvcState g_ptp_bvc_state := BVC_S_BLOCKED; |
| 715 | timer g_T1 := 15.0; |
| 716 | timer g_T2 := 60.0; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 717 | var boolean g_t1_waits_for_block_ack := false; |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 718 | /* for re-transmissions */ |
| 719 | var BssgpCause g_last_block_cause; |
| 720 | var BssgpCause g_last_reset_cause; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 721 | |
Harald Welte | 633805b | 2021-02-03 17:47:18 +0100 | [diff] [blame] | 722 | var ClientEntity ClientTable[64]; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 723 | }; |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 724 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 725 | /* port between global BSSGP_CT and per-BVC BSSGP_BVC_CT */ |
| 726 | type port BSSGP_BVC_SP_PT message { |
| 727 | in NsUnitdataRequest; |
| 728 | out ASP_Event, |
| 729 | BssgpStatusIndication, |
| 730 | BssgpResetIndication, |
| 731 | NsUnitdataIndication; |
| 732 | } with { extension "internal" }; |
| 733 | type port BSSGP_BVC_PT message { |
| 734 | in ASP_Event, |
| 735 | BssgpStatusIndication, |
| 736 | BssgpResetIndication, |
| 737 | NsUnitdataIndication; |
| 738 | out NsUnitdataRequest; |
| 739 | } with { extension "internal" }; |
Alexander Couzens | 6b449fb | 2018-07-31 14:19:36 +0200 | [diff] [blame] | 740 | |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 741 | /* port between BSSGP_BVC_CT and a management instance */ |
| 742 | type port BSSGP_BVC_MGMT_SP_PT message { |
| 743 | in BssgpResetRequest, |
| 744 | BssgpBlockRequest, |
| 745 | BssgpUnblockRequest; |
| 746 | out BssgpStatusIndication, |
| 747 | BssgpResetIndication; |
| 748 | } with { extension "internal" }; |
| 749 | type port BSSGP_BVC_MGMT_PT message { |
| 750 | in BssgpStatusIndication, |
| 751 | BssgpResetIndication; |
| 752 | out BssgpResetRequest, |
| 753 | BssgpBlockRequest, |
| 754 | BssgpUnblockRequest; |
| 755 | } with { extension "internal" }; |
| 756 | |
| 757 | type record BssgpResetRequest { |
| 758 | BssgpCause cause |
| 759 | }; |
| 760 | type record BssgpBlockRequest { |
| 761 | BssgpCause cause |
| 762 | }; |
| 763 | type record BssgpUnblockRequest { |
| 764 | }; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 765 | |
| 766 | /* one element in the per-TLLI state table */ |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 767 | type record ClientEntity { |
| 768 | OCT4 tlli, |
| 769 | OCT4 tlli_old optional, |
| 770 | hexstring imsi, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 771 | BSSGP_Client_CT comp_ref, |
| 772 | /* LLC entities, one for each SAPI */ |
| 773 | LLC_Entity llc[16] |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 774 | }; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 775 | type record LLC_Entity { |
| 776 | boolean sgsn_role, |
| 777 | /* N(U) on transmit side for next PDU */ |
| 778 | uint9_t n_u_tx_next, |
| 779 | /* N(U) on receive side, last PDU */ |
| 780 | uint9_t n_u_rx_last optional |
| 781 | }; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 782 | type record length(16) of LLC_Entity LLC_Entities; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 783 | |
Harald Welte | f536524 | 2021-01-17 13:46:57 +0100 | [diff] [blame] | 784 | private template PDU_BSSGP tr_GLOBAL_PTP := ( |
| 785 | {pDU_BSSGP_STATUS:=?} |
| 786 | ); |
| 787 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 788 | function f_llc_create(boolean sgsn_role := false) return LLC_Entities { |
| 789 | var LLC_Entities llc; |
| 790 | for (var integer i := 0; i < 16; i := i+1) { |
| 791 | llc[i] := valueof(t_LLC_init(sgsn_role)); |
| 792 | } |
| 793 | return llc; |
| 794 | } |
| 795 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 796 | private template LLC_Entity t_LLC_init(boolean sgsn_role := false) := { |
| 797 | sgsn_role := sgsn_role, |
| 798 | n_u_tx_next := 0, |
| 799 | n_u_rx_last := - |
| 800 | } |
| 801 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 802 | /* configuration of BSSGP_CT */ |
| 803 | type record BssgpConfig { |
| 804 | Nsvci nsei, |
| 805 | boolean sgsn_role, |
| 806 | BssgpBvcConfigs bvc |
| 807 | }; |
| 808 | /* Configuration of one BVC (Cell) BSSGP_BVC_CT */ |
| 809 | type record BssgpBvcConfig { |
| 810 | BssgpBvci bvci, |
| 811 | BssgpCellId cell_id, |
Harald Welte | 4d112c9 | 2020-11-12 19:48:31 +0100 | [diff] [blame] | 812 | BssgpDecodeDepth depth, |
| 813 | BssgpCreateCallback create_cb |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 814 | }; |
| 815 | type record of BssgpBvcConfig BssgpBvcConfigs; |
Oliver Smith | aac9b9c | 2019-09-02 08:36:36 +0200 | [diff] [blame] | 816 | type enumerated BssgpDecodeDepth { |
| 817 | BSSGP_DECODE_DEPTH_BSSGP, |
| 818 | BSSGP_DECODE_DEPTH_LLC, |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 819 | BSSGP_DECODE_DEPTH_SNDCP |
| 820 | #ifdef BSSGP_EM_L3 |
| 821 | , |
Oliver Smith | aac9b9c | 2019-09-02 08:36:36 +0200 | [diff] [blame] | 822 | BSSGP_DECODE_DEPTH_L3 |
Harald Welte | 93331e7 | 2020-09-12 20:51:05 +0200 | [diff] [blame] | 823 | #endif |
Oliver Smith | aac9b9c | 2019-09-02 08:36:36 +0200 | [diff] [blame] | 824 | }; |
Harald Welte | 4d112c9 | 2020-11-12 19:48:31 +0100 | [diff] [blame] | 825 | /* call-back function type: Called for inbound BSSGP for unknown TLLIs; could create BSSGP_ClienT_CT */ |
| 826 | type function BssgpCreateCallback(BssgpBvci bvci, BssgpCellId cell_id, OCT4 tlli, BssgpDecoded dec) runs on BSSGP_BVC_CT; |
| 827 | |
| 828 | /* Default Create Callback function: Fail and terminate */ |
| 829 | function DefaultCreateCallback(BssgpBvci bvci, BssgpCellId cell_id, OCT4 tlli, BssgpDecoded dec) runs on BSSGP_BVC_CT { |
Pau Espin Pedrol | 011e32f | 2021-02-05 12:07:04 +0100 | [diff] [blame] | 830 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Couldn't find Component for TLLI ", tlli)); |
Harald Welte | 4d112c9 | 2020-11-12 19:48:31 +0100 | [diff] [blame] | 831 | } |
Oliver Smith | aac9b9c | 2019-09-02 08:36:36 +0200 | [diff] [blame] | 832 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 833 | /* |
| 834 | private function f_tbl_init() runs on BSSGP_BVC_CT { |
| 835 | var integer i; |
| 836 | for (i := 0; i < sizeof(ImsiTable); i := i+1) { |
| 837 | ImsiTable[i] := -; |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 838 | } |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 839 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 840 | for (i := 0; i < sizeof(TlliTable); i := i+1) { |
| 841 | TlliTable[i] := -; |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 842 | } |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 843 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 844 | */ |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 845 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 846 | private function f_tbl_client_add(hexstring imsi, OCT4 tlli, BSSGP_Client_CT vc_conn) |
| 847 | runs on BSSGP_BVC_CT { |
| 848 | var integer i; |
| 849 | for (i := 0; i < sizeof(ClientTable); i := i+1) { |
| 850 | if (not isvalue(ClientTable[i].comp_ref)) { |
| 851 | log("Adding Client=", vc_conn, ", IMSI=", imsi, ", TLLI=", tlli, ", index=", i); |
| 852 | ClientTable[i] := { |
| 853 | tlli := tlli, |
| 854 | tlli_old := omit, |
| 855 | imsi := imsi, |
| 856 | comp_ref := vc_conn, |
| 857 | llc := - |
| 858 | }; |
| 859 | for (var integer j := 0; j < sizeof(ClientTable[i].llc); j := j+1) { |
| 860 | ClientTable[i].llc[j] := valueof(t_LLC_init(g_sgsn_role)); |
| 861 | } |
| 862 | return; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 863 | } |
| 864 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 865 | testcase.stop("Client Table full"); |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 866 | } |
| 867 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 868 | private function f_tbl_client_del(hexstring imsi, BSSGP_Client_CT vc_conn) runs on BSSGP_BVC_CT { |
| 869 | var integer i; |
| 870 | for (i := 0; i < sizeof(ClientTable); i := i+1) { |
| 871 | if (isvalue(ClientTable[i].imsi) and ClientTable[i].imsi == imsi) { |
| 872 | if (ClientTable[i].comp_ref != vc_conn) { |
Pau Espin Pedrol | 011e32f | 2021-02-05 12:07:04 +0100 | [diff] [blame] | 873 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 874 | log2str("Cannot unregister index=", i, " IMSI ", |
| 875 | imsi, " registred to ", ClientTable[i].comp_ref, |
| 876 | " from ", vc_conn)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 877 | } |
| 878 | log("Removing Client IMSI=", imsi, ", index=", i); |
| 879 | ClientTable[i] := { |
| 880 | tlli := -, |
| 881 | tlli_old := omit, |
| 882 | imsi := ''H, |
| 883 | comp_ref := null, |
| 884 | llc := - }; |
| 885 | return; |
| 886 | } |
| 887 | } |
| 888 | log("Warning: Could not find client for IMSI ", imsi); |
| 889 | return; |
| 890 | } |
| 891 | |
| 892 | /* TS 44.064 7.2.1.1 LLGMM-ASSIGN */ |
| 893 | private function f_tbl_client_llgmm_assign(OCT4 tlli_old, OCT4 tlli_new, BSSGP_Client_CT vc_conn) |
| 894 | runs on BSSGP_BVC_CT { |
| 895 | var integer i := f_tbl_idx_by_comp(vc_conn); |
| 896 | |
| 897 | if (tlli_old == 'FFFFFFFF'O and tlli_new != 'FFFFFFFF'O) { |
| 898 | /* TLLI assignment */ |
| 899 | ClientTable[i].tlli := tlli_new; |
| 900 | ClientTable[i].tlli_old := omit; |
| 901 | } else if (tlli_old != 'FFFFFFFF'O and tlli_new != 'FFFFFFFF'O) { |
| 902 | /* TLLI change: both active */ |
| 903 | ClientTable[i].tlli := tlli_new; |
| 904 | ClientTable[i].tlli_old := tlli_old; |
| 905 | } else if (tlli_old != 'FFFFFFFF'O and tlli_new == 'FFFFFFFF'O) { |
| 906 | /* TLLI unassignment: old shall be unassigned; new stays */ |
| 907 | ClientTable[i].tlli_old := omit; |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | private function f_tbl_comp_by_imsi(hexstring imsi) runs on BSSGP_BVC_CT return BSSGP_Client_CT { |
| 912 | var integer i; |
| 913 | for (i := 0; i < sizeof(ClientTable); i := i+1) { |
| 914 | if (isvalue(ClientTable[i].imsi) and isvalue(ClientTable[i].comp_ref) |
| 915 | and ClientTable[i].imsi == imsi) { |
| 916 | return ClientTable[i].comp_ref; |
| 917 | } |
| 918 | } |
Pau Espin Pedrol | 011e32f | 2021-02-05 12:07:04 +0100 | [diff] [blame] | 919 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Couldn't find Component for IMSI ", imsi)); |
| 920 | return ClientTable[0].comp_ref; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 921 | } |
| 922 | |
| 923 | private function f_tbl_comp_by_tlli(OCT4 tlli) runs on BSSGP_BVC_CT return BSSGP_Client_CT { |
| 924 | var integer i; |
| 925 | for (i := 0; i < sizeof(ClientTable); i := i+1) { |
| 926 | if (isvalue(ClientTable[i].comp_ref) and |
| 927 | (isvalue(ClientTable[i].tlli) and (ClientTable[i].tlli == tlli or |
| 928 | isvalue(ClientTable[i].tlli_old) and ClientTable[i].tlli_old == tlli) )) { |
| 929 | return ClientTable[i].comp_ref; |
| 930 | } |
| 931 | } |
Harald Welte | 4d112c9 | 2020-11-12 19:48:31 +0100 | [diff] [blame] | 932 | return null; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | private function f_tbl_idx_by_comp(BSSGP_Client_CT comp_ref) runs on BSSGP_BVC_CT return integer { |
| 936 | var integer i; |
| 937 | for (i := 0; i < sizeof(ClientTable); i := i+1) { |
| 938 | if (isvalue(ClientTable[i].comp_ref) and ClientTable[i].comp_ref == comp_ref) { |
| 939 | return i; |
| 940 | } |
| 941 | } |
Pau Espin Pedrol | 011e32f | 2021-02-05 12:07:04 +0100 | [diff] [blame] | 942 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Couldn't find Client for Component ", comp_ref)); |
| 943 | return 1; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 944 | } |
| 945 | |
| 946 | private function f_tbl_tlli_by_comp(BSSGP_Client_CT comp_ref) runs on BSSGP_BVC_CT return OCT4 { |
| 947 | var integer i; |
| 948 | for (i := 0; i < sizeof(ClientTable); i := i+1) { |
| 949 | if (isvalue(ClientTable[i].tlli) and isvalue(ClientTable[i].comp_ref) |
| 950 | and ClientTable[i].comp_ref == comp_ref) { |
| 951 | return ClientTable[i].tlli; |
| 952 | } |
| 953 | } |
Pau Espin Pedrol | 011e32f | 2021-02-05 12:07:04 +0100 | [diff] [blame] | 954 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Couldn't find TLLI for Component ", comp_ref)); |
| 955 | return '00000000'O; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | /* PDU_BSSGP enhanced with LLC and possibly L3 decoded payloads */ |
| 959 | type record BssgpDecoded { |
| 960 | PDU_BSSGP bssgp, |
| 961 | PDU_LLC llc optional, |
| 962 | #ifdef BSSGP_EM_L3 |
| 963 | PDU_L3_MS_SGSN l3_mo optional, |
| 964 | PDU_L3_SGSN_MS l3_mt optional, |
| 965 | #endif |
| 966 | PDU_SN sndcp optional |
| 967 | } |
| 968 | |
| 969 | /* Decode a PDU_BSSGP into a BssgpDecoded (i.e. with LLC/L3 decoded, as applicable) */ |
| 970 | private function f_dec_bssgp(PDU_BSSGP bssgp) runs on BSSGP_BVC_CT return BssgpDecoded { |
| 971 | var BssgpDecoded dec := { |
| 972 | bssgp := bssgp, |
| 973 | llc := omit, |
| 974 | #ifdef BSSGP_EM_L3 |
| 975 | l3_mo := omit, |
| 976 | l3_mt := omit, |
| 977 | #endif |
| 978 | sndcp := omit |
| 979 | }; |
| 980 | |
| 981 | /* Decode LLC, if it is a PDU that contains LLC */ |
| 982 | if (g_cfg.depth >= BSSGP_DECODE_DEPTH_LLC) { |
| 983 | if (ischosen(bssgp.pDU_BSSGP_DL_UNITDATA)) { |
| 984 | dec.llc := dec_PDU_LLC(bssgp.pDU_BSSGP_DL_UNITDATA.lLC_PDU.lLC_PDU); |
| 985 | } else if (ischosen(bssgp.pDU_BSSGP_UL_UNITDATA)) { |
| 986 | dec.llc := dec_PDU_LLC(bssgp.pDU_BSSGP_UL_UNITDATA.lLC_PDU.lLC_PDU); |
| 987 | } |
| 988 | } |
| 989 | |
| 990 | /* Decode SNDCP, if it is a LLC PDU containing user plane data */ |
| 991 | if (g_cfg.depth >= BSSGP_DECODE_DEPTH_SNDCP) { |
| 992 | if (isvalue(dec.llc) and match(dec.llc, tr_LLC_UI_USER)) { |
| 993 | dec.sndcp := dec_PDU_SN(dec.llc.pDU_LLC_UI.information_field_UI); |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | #ifdef BSSGP_EM_L3 |
| 998 | /* Decode L3, if it is a LLC PDU containing L3 */ |
| 999 | if (g_cfg.depth >= BSSGP_DECODE_DEPTH_L3) { |
| 1000 | if (isvalue(dec.llc) and match(dec.llc, tr_LLC_UI_L3)) { |
| 1001 | if (g_sgsn_role) { |
| 1002 | dec.l3_mo := dec_PDU_L3_MS_SGSN(dec.llc.pDU_LLC_UI.information_field_UI); |
| 1003 | } else { |
| 1004 | dec.l3_mt := dec_PDU_L3_SGSN_MS(dec.llc.pDU_LLC_UI.information_field_UI); |
| 1005 | } |
| 1006 | } |
| 1007 | } |
| 1008 | #endif |
| 1009 | |
| 1010 | return dec; |
| 1011 | } |
| 1012 | |
| 1013 | private function f_ptp_sendUnblock() runs on BSSGP_BVC_CT { |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 1014 | BVC.send(ts_ptp_BnsUdReq(ts_BVC_UNBLOCK(g_cfg.bvci), 0, g_bvc_lsp)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1015 | g_t1_waits_for_block_ack := false; |
| 1016 | g_T1.start; |
| 1017 | } |
| 1018 | |
| 1019 | private function f_ptp_sendBlock(BssgpCause cause) runs on BSSGP_BVC_CT { |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 1020 | BVC.send(ts_ptp_BnsUdReq(ts_BVC_BLOCK(g_cfg.bvci, cause), 0, g_bvc_lsp)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1021 | g_t1_waits_for_block_ack := true; |
| 1022 | g_T1.start; |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1023 | g_last_block_cause := cause; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | private function f_ptp_sendStatus(BssgpCause cause, PDU_BSSGP pdu) runs on BSSGP_BVC_CT { |
| 1027 | /* FIXME: Make sure correct Signaling or PTP BVCI is used! */ |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1028 | BVC.send(ts_ptp_BnsUdReq(ts_BSSGP_STATUS(g_cfg.bvci, cause, pdu), g_cfg.bvci, g_bvc_lsp)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1029 | } |
| 1030 | |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1031 | private function f_ptp_sendReset(BssgpCause cause := BSSGP_CAUSE_OM_INTERVENTION) runs on BSSGP_BVC_CT { |
Harald Welte | c967d0e | 2020-09-14 16:07:26 +0200 | [diff] [blame] | 1032 | var PDU_BSSGP pdu; |
| 1033 | |
| 1034 | /* The Cell Identifier IE is mandatory in the BVC-RESET PDU sent from BSS to |
| 1035 | * SGSN in order to reset a BVC corresponding to a PTP functional entity. The |
| 1036 | * Cell Identifier IE shall not be used in any other BVC-RESET PDU. */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1037 | if (g_sgsn_role) { |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1038 | pdu := valueof(ts_BVC_RESET(cause, g_cfg.bvci, omit)); |
Harald Welte | c967d0e | 2020-09-14 16:07:26 +0200 | [diff] [blame] | 1039 | } else { |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1040 | pdu := valueof(ts_BVC_RESET(cause, g_cfg.bvci, g_cfg.cell_id)); |
Harald Welte | c967d0e | 2020-09-14 16:07:26 +0200 | [diff] [blame] | 1041 | } |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 1042 | |
| 1043 | /* BVC-RESET is always sent via the SIGNALLING BVCI, see Table 5.4.1 */ |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1044 | BVC.send(ts_ptp_BnsUdReq(pdu, 0, g_bvc_lsp)); |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 1045 | g_T2.start; |
| 1046 | //f_change_state(BVC_S_WAIT_RESET); |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1047 | g_last_reset_cause := cause; |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 1048 | } |
| 1049 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1050 | /* PTP-BVC is in BVC_S_BLOCKED state */ |
| 1051 | private altstep as_ptp_blocked() runs on BSSGP_BVC_CT { |
| 1052 | var NsUnitdataIndication udi; |
| 1053 | |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 1054 | [g_T1.running and not g_t1_waits_for_block_ack] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_UNBLOCK_ACK(g_cfg.bvci), 0)) { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1055 | g_T1.stop; |
| 1056 | f_ptp_change_state(BVC_S_UNBLOCKED); |
| 1057 | } |
| 1058 | |
Harald Welte | ddfc667 | 2020-11-24 23:13:01 +0100 | [diff] [blame] | 1059 | /* Inbound BVC-UNBLOCK from peer */ |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 1060 | [g_sgsn_role] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_UNBLOCK(g_cfg.bvci), 0)) { |
| 1061 | BVC.send(ts_ptp_BnsUdReq(ts_BVC_UNBLOCK_ACK(g_cfg.bvci), 0, g_bvc_lsp)); |
Harald Welte | ddfc667 | 2020-11-24 23:13:01 +0100 | [diff] [blame] | 1062 | f_ptp_change_state(BVC_S_UNBLOCKED); |
| 1063 | } |
| 1064 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1065 | /* RESET-ACK before T2 timeout: reset successful. In SGSN role, CellID must be present */ |
| 1066 | [g_T2.running and g_sgsn_role] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_RESET_ACK(g_cfg.bvci, g_cfg.cell_id), 0)) -> value udi { |
| 1067 | g_T2.stop; |
| 1068 | f_ptp_change_state(BVC_S_UNBLOCKED); |
| 1069 | } |
| 1070 | /* RESET-ACK before T2 timeout: reset successful. In BSS role, CellID must be absent */ |
| 1071 | [g_T2.running and not g_sgsn_role] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_RESET_ACK(g_cfg.bvci, omit), 0)) -> value udi { |
| 1072 | g_T2.stop; |
| 1073 | f_ptp_change_state(BVC_S_UNBLOCKED); |
| 1074 | } |
| 1075 | |
Harald Welte | ab50cc2 | 2020-11-25 17:11:08 +0100 | [diff] [blame] | 1076 | [] as_ptp_handle_inbound_reset(); |
| 1077 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1078 | [] g_T2.timeout { |
| 1079 | /* BVC-RESET-ACK PDU was not received within T2: retransmit */ |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1080 | f_ptp_sendReset(g_last_reset_cause); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1081 | } |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1082 | |
| 1083 | [] MGMT.receive(BssgpUnblockRequest:?) { |
| 1084 | f_ptp_sendUnblock(); |
| 1085 | } |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 1086 | } |
| 1087 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1088 | /* PTP-BVC is in UNBLOCKED state */ |
| 1089 | private altstep as_ptp_unblocked() runs on BSSGP_BVC_CT { |
| 1090 | var NsUnitdataIndication udi; |
| 1091 | var NsStatusIndication nsi; |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1092 | var BssgpBlockRequest bbr; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1093 | var BSSGP_Client_CT vc_conn; |
| 1094 | var ASP_Event evt; |
| 1095 | var PDU_BSSGP bs_pdu; |
| 1096 | var PDU_LLC llc; |
| 1097 | #ifdef BSSGP_EM_L3 |
| 1098 | var PDU_L3_MS_SGSN l3_mo; |
| 1099 | var PDU_L3_SGSN_MS l3_mt; |
| 1100 | #endif |
| 1101 | |
| 1102 | /* bogus unblock, just respond with ACK */ |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 1103 | [] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_UNBLOCK(g_cfg.bvci), 0)) -> value udi { |
| 1104 | BVC.send(ts_ptp_BnsUdReq(ts_BVC_UNBLOCK_ACK(g_cfg.bvci), 0, g_bvc_lsp)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1105 | } |
| 1106 | /* Respond to BLOCK with BLOCK-ACK + change state */ |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 1107 | [] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_BLOCK(g_cfg.bvci, ?), 0)) -> value udi { |
| 1108 | BVC.send(ts_ptp_BnsUdReq(ts_BVC_BLOCK_ACK(g_cfg.bvci), 0, g_bvc_lsp)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1109 | g_T1.stop; |
| 1110 | f_ptp_change_state(BVC_S_BLOCKED); |
| 1111 | } |
| 1112 | /* BLOCK-ACK before T1 timeout: mark as blocked */ |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 1113 | [g_T1.running and g_t1_waits_for_block_ack] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_BLOCK_ACK(g_cfg.bvci), 0)) -> value udi { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1114 | g_T1.stop; |
| 1115 | f_ptp_change_state(BVC_S_BLOCKED); |
| 1116 | } |
| 1117 | /* Re-transmit BLOCK / UNBLOCK on T1 timeout */ |
| 1118 | [not g_t1_waits_for_block_ack] g_T1.timeout { |
| 1119 | f_ptp_sendUnblock(); |
| 1120 | } |
| 1121 | [g_t1_waits_for_block_ack] g_T1.timeout { |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1122 | f_ptp_sendBlock(g_last_block_cause); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1123 | } |
| 1124 | |
Harald Welte | ab50cc2 | 2020-11-25 17:11:08 +0100 | [diff] [blame] | 1125 | [] as_ptp_handle_inbound_reset(); |
| 1126 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1127 | [g_sgsn_role] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_FC_BVC, g_cfg.bvci)) -> value udi { |
Harald Welte | 71449b0 | 2020-12-09 11:58:23 +0100 | [diff] [blame] | 1128 | if (GLOBAL.checkstate("Connected")) { |
| 1129 | GLOBAL.send(udi.bssgp); |
| 1130 | } else { |
| 1131 | /* simply acknowledge all per-BVC Flow Control Messages */ |
| 1132 | var OCT1 tag := udi.bssgp.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value; |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 1133 | BVC.send(ts_ptp_BnsUdReq(ts_BVC_FC_BVC_ACK(tag), g_cfg.bvci, g_bvc_lsp)); |
Harald Welte | 71449b0 | 2020-12-09 11:58:23 +0100 | [diff] [blame] | 1134 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1135 | } |
Harald Welte | 71449b0 | 2020-12-09 11:58:23 +0100 | [diff] [blame] | 1136 | |
Pau Espin Pedrol | 6ee0126 | 2021-02-05 13:05:06 +0100 | [diff] [blame] | 1137 | [not g_sgsn_role] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_FC_BVC_ACK(?), g_cfg.bvci)) -> value udi { |
Harald Welte | 71449b0 | 2020-12-09 11:58:23 +0100 | [diff] [blame] | 1138 | if (GLOBAL.checkstate("Connected")) { |
| 1139 | GLOBAL.send(udi.bssgp); |
| 1140 | } else { |
| 1141 | /* ignore any incoming flow control ACK */ |
| 1142 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1143 | } |
Harald Welte | 71449b0 | 2020-12-09 11:58:23 +0100 | [diff] [blame] | 1144 | |
Harald Welte | f536524 | 2021-01-17 13:46:57 +0100 | [diff] [blame] | 1145 | [] BVC.receive(tr_ptp_BnsUdInd(tr_GLOBAL_PTP, g_cfg.bvci)) -> value udi { |
| 1146 | if (GLOBAL.checkstate("Connected")) { |
| 1147 | GLOBAL.send(udi.bssgp); |
| 1148 | } else { |
| 1149 | setverdict(fail, "Received BSSGP STATUS ", udi.bssgp); |
| 1150 | } |
| 1151 | } |
| 1152 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1153 | /* Any other PTP BSSGP message: If it has TLLI, route to component; otherwise broadcast */ |
| 1154 | [] BVC.receive(tr_ptp_BnsUdInd(?, g_cfg.bvci)) -> value udi { |
| 1155 | var BssgpDecoded dec := f_dec_bssgp(udi.bssgp); |
| 1156 | var template OCT4 tlli := f_bssgp_get_tlli(udi.bssgp); |
| 1157 | if (isvalue(tlli)) { |
| 1158 | vc_conn := f_tbl_comp_by_tlli(valueof(tlli)); |
Harald Welte | 4d112c9 | 2020-11-12 19:48:31 +0100 | [diff] [blame] | 1159 | if (vc_conn == null) { |
| 1160 | g_cfg.create_cb.apply(g_cfg.bvci, g_cfg.cell_id, valueof(tlli), dec); |
| 1161 | } else { |
| 1162 | f_send_bssgp_dec(dec, vc_conn, BSSGP_SP); |
| 1163 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1164 | } else { |
| 1165 | log("No TLLI: Broadcasting ", dec); |
| 1166 | /* broadcast this message to all components */ |
| 1167 | // TITAN DOESN'T DO THIS, *SIGH*: "BSSGP_SP.send(dec) to all component;" |
| 1168 | for (var integer i := 0; i < sizeof(ClientTable); i := i+1) { |
| 1169 | if (isbound(ClientTable[i].comp_ref) and ClientTable[i].comp_ref != null) { |
| 1170 | f_send_bssgp_dec(dec, ClientTable[i].comp_ref, BSSGP_SP); |
| 1171 | } |
| 1172 | } |
| 1173 | } |
| 1174 | } |
| 1175 | |
Daniel Willmann | ef8e50e | 2021-11-26 11:41:50 +0100 | [diff] [blame] | 1176 | [] BVC.receive(tr_ptp_BnsUdInd(tr_BSSGP_FLUSH_LL_ACK(?, ?, ?), 0)) -> value udi { |
| 1177 | var BssgpDecoded dec := f_dec_bssgp(udi.bssgp); |
| 1178 | |
| 1179 | log("Broadcasting FLUSH_LL_ACK ", dec); |
| 1180 | /* broadcast this message to all components */ |
| 1181 | // TITAN DOESN'T DO THIS, *SIGH*: "BSSGP_SP.send(dec) to all component;" |
| 1182 | for (var integer i := 0; i < sizeof(ClientTable); i := i+1) { |
| 1183 | if (isbound(ClientTable[i].comp_ref) and ClientTable[i].comp_ref != null) { |
| 1184 | f_send_bssgp_dec(dec, ClientTable[i].comp_ref, BSSGP_SP_SIG); |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1189 | /* Any other SIG BSSGP message: If it has TLLI, route to component; otherwise broadcast */ |
| 1190 | [] BVC.receive(tr_ptp_BnsUdInd(?, 0)) -> value udi { |
| 1191 | var BssgpDecoded dec := f_dec_bssgp(udi.bssgp); |
| 1192 | var template OCT4 tlli := f_bssgp_get_tlli(udi.bssgp); |
| 1193 | if (isvalue(tlli)) { |
| 1194 | vc_conn := f_tbl_comp_by_tlli(valueof(tlli)); |
Harald Welte | 4d112c9 | 2020-11-12 19:48:31 +0100 | [diff] [blame] | 1195 | if (vc_conn == null) { |
| 1196 | g_cfg.create_cb.apply(g_cfg.bvci, g_cfg.cell_id, valueof(tlli), dec); |
| 1197 | } else { |
| 1198 | f_send_bssgp_dec(dec, vc_conn, BSSGP_SP_SIG); |
| 1199 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1200 | } else { |
| 1201 | log("No TLLI: Broadcasting ", dec); |
| 1202 | /* broadcast this message to all components */ |
| 1203 | // TITAN DOESN'T DO THIS, *SIGH*: "BSSGP_SP.send(dec) to all component;" |
| 1204 | for (var integer i := 0; i < sizeof(ClientTable); i := i+1) { |
| 1205 | if (isbound(ClientTable[i].comp_ref) and ClientTable[i].comp_ref != null) { |
| 1206 | f_send_bssgp_dec(dec, ClientTable[i].comp_ref, BSSGP_SP_SIG); |
| 1207 | } |
| 1208 | } |
| 1209 | } |
| 1210 | } |
| 1211 | |
| 1212 | /* ConnHdlr sends BSSGP on BVCI=0 port: forward it to BSSGP_CT */ |
| 1213 | [] BSSGP_SP_SIG.receive(PDU_BSSGP:?)-> value bs_pdu sender vc_conn { |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1214 | BVC.send(ts_ptp_BnsUdReq(bs_pdu, 0, g_bvc_lsp)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1215 | } |
| 1216 | |
| 1217 | /* ConnHdlr sends BSSGP on BVCI=PTP port: forward it to BSSGP_CT */ |
| 1218 | [] BSSGP_SP.receive(PDU_BSSGP:?)-> value bs_pdu sender vc_conn { |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1219 | BVC.send(ts_ptp_BnsUdReq(bs_pdu, g_cfg.bvci, g_bvc_lsp)); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1220 | } |
| 1221 | |
| 1222 | #ifdef BSSGP_EM_L3 |
| 1223 | /* ConnHdlr sends L3: Encode and send as UL_UD / DL_UD */ |
| 1224 | [g_sgsn_role] BSSGP_SP.receive(PDU_L3_SGSN_MS:?) -> value l3_mt sender vc_conn { |
| 1225 | var integer idx := f_tbl_idx_by_comp(vc_conn); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1226 | var OCT4 tlli := ClientTable[idx].tlli; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1227 | var octetstring l3_enc := enc_PDU_L3_SGSN_MS(l3_mt); |
| 1228 | var BIT4 sapi := f_llc_sapi_by_l3_mt(l3_mt); |
| 1229 | var integer n_u := f_llc_get_n_u_tx(ClientTable[idx].llc[bit2int(sapi)]); |
| 1230 | var octetstring llc_enc := enc_PDU_LLC(valueof(ts_LLC_UI(l3_enc, sapi, '1'B, n_u))); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1231 | BVC.send(ts_ptp_BnsUdReq(ts_BSSGP_DL_UD(tlli, llc_enc), g_cfg.bvci, oct2int(tlli))); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1232 | } |
| 1233 | [not g_sgsn_role] BSSGP_SP.receive(PDU_L3_MS_SGSN:?) -> value l3_mo sender vc_conn { |
| 1234 | var integer idx := f_tbl_idx_by_comp(vc_conn); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1235 | var OCT4 tlli := ClientTable[idx].tlli; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1236 | var octetstring l3_enc := enc_PDU_L3_MS_SGSN(l3_mo); |
| 1237 | var BIT4 sapi := f_llc_sapi_by_l3_mo(l3_mo); |
| 1238 | var integer n_u := f_llc_get_n_u_tx(ClientTable[idx].llc[bit2int(sapi)]); |
| 1239 | var octetstring llc_enc := enc_PDU_LLC(valueof(ts_LLC_UI(l3_enc, sapi, '1'B, n_u))); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1240 | BVC.send(ts_ptp_BnsUdReq(ts_BSSGP_UL_UD(tlli, g_cfg.cell_id, llc_enc), g_cfg.bvci, oct2int(tlli))); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1241 | } |
| 1242 | #endif |
| 1243 | |
| 1244 | /* ConnHdlr sends raw LLC: Encode and send as UL_UD / DL_UD */ |
| 1245 | [not g_sgsn_role] BSSGP_SP.receive(PDU_LLC:?) -> value llc sender vc_conn { |
| 1246 | var integer idx := f_tbl_idx_by_comp(vc_conn); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1247 | var OCT4 tlli := ClientTable[idx].tlli; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1248 | var octetstring llc_enc := enc_PDU_LLC(llc); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1249 | BVC.send(ts_ptp_BnsUdReq(ts_BSSGP_UL_UD(tlli, g_cfg.cell_id, llc_enc), g_cfg.bvci, oct2int(tlli))); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1250 | } |
| 1251 | [g_sgsn_role] BSSGP_SP.receive(PDU_LLC:?) -> value llc sender vc_conn { |
| 1252 | var integer idx := f_tbl_idx_by_comp(vc_conn); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1253 | var OCT4 tlli := ClientTable[idx].tlli; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1254 | var octetstring llc_enc := enc_PDU_LLC(llc); |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1255 | BVC.send(ts_ptp_BnsUdReq(ts_BSSGP_DL_UD(tlli, llc_enc), g_cfg.bvci, oct2int(tlli))); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1256 | } |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1257 | |
Harald Welte | 71449b0 | 2020-12-09 11:58:23 +0100 | [diff] [blame] | 1258 | /* Testcase sends us BSSGP on global port */ |
| 1259 | [] GLOBAL.receive(PDU_BSSGP:?)-> value bs_pdu sender vc_conn { |
| 1260 | BVC.send(ts_ptp_BnsUdReq(bs_pdu, g_cfg.bvci, g_bvc_lsp)); |
| 1261 | } |
| 1262 | |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1263 | [] MGMT.receive(BssgpBlockRequest:?) -> value bbr { |
| 1264 | f_ptp_sendBlock(bbr.cause); |
| 1265 | } |
Harald Welte | 853c0ad | 2018-02-15 17:45:29 +0100 | [diff] [blame] | 1266 | } |
| 1267 | |
Harald Welte | ab50cc2 | 2020-11-25 17:11:08 +0100 | [diff] [blame] | 1268 | private altstep as_ptp_handle_inbound_reset() runs on BSSGP_BVC_CT { |
| 1269 | var NsUnitdataIndication udi; |
| 1270 | /* we are a SGSN: BSS/PCU-originated RESET must have a cell ID */ |
| 1271 | [g_sgsn_role] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_RESET(?, g_cfg.bvci, g_cfg.cell_id), 0)) -> value udi { |
| 1272 | log("Rx BVC-RESET from BVCI=", g_cfg.bvci); |
Harald Welte | 3c90515 | 2020-11-26 20:56:09 +0100 | [diff] [blame] | 1273 | if (MGMT.checkstate("Connected")) { |
| 1274 | MGMT.send(BssgpResetIndication:{g_cfg.bvci}); |
| 1275 | } |
Harald Welte | ab50cc2 | 2020-11-25 17:11:08 +0100 | [diff] [blame] | 1276 | /* Respond to RESET with correct BVCI but without CellID */ |
| 1277 | BVC.send(ts_ptp_BnsUdReq(ts_BVC_RESET_ACK(g_cfg.bvci, omit), 0, g_bvc_lsp)); |
| 1278 | /* FIXME: reset all state? What about clients? */ |
| 1279 | f_ptp_change_state(BVC_S_UNBLOCKED); |
| 1280 | } |
| 1281 | /* we are a BSS/PCU: SGSN-originated RESET must not have a cell ID */ |
| 1282 | [not g_sgsn_role] BVC.receive(tr_ptp_BnsUdInd(tr_BVC_RESET(?, g_cfg.bvci, omit), 0)) -> value udi { |
| 1283 | log("Rx BVC-RESET from BVCI=", g_cfg.bvci); |
Harald Welte | 3c90515 | 2020-11-26 20:56:09 +0100 | [diff] [blame] | 1284 | if (MGMT.checkstate("Connected")) { |
| 1285 | MGMT.send(BssgpResetIndication:{g_cfg.bvci}); |
| 1286 | } |
Harald Welte | ab50cc2 | 2020-11-25 17:11:08 +0100 | [diff] [blame] | 1287 | /* Respond to RESET with correct BVCI with CellID */ |
| 1288 | BVC.send(ts_ptp_BnsUdReq(ts_BVC_RESET_ACK(g_cfg.bvci, g_cfg.cell_id), 0, g_bvc_lsp)); |
| 1289 | /* FIXME: reset all state? What about clients? */ |
| 1290 | f_ptp_change_state(BVC_S_UNBLOCKED); |
| 1291 | } |
| 1292 | } |
| 1293 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1294 | /* Events permitted in all states */ |
| 1295 | private altstep as_ptp_allstate() runs on BSSGP_BVC_CT { |
| 1296 | var NsUnitdataIndication udi; |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1297 | var BssgpResetRequest brr; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1298 | var BSSGP_Client_CT vc_conn; |
| 1299 | var OCT4 tlli, tlli_old; |
| 1300 | var hexstring imsi; |
| 1301 | |
| 1302 | /* Signaling BVC was reset */ |
| 1303 | [] BVC.receive(BssgpResetIndication:{0}) { |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1304 | if (MGMT.checkstate("Connected")) { |
| 1305 | MGMT.send(BssgpResetIndication:{0}); |
| 1306 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1307 | if (not g_sgsn_role) { |
| 1308 | f_ptp_change_state(BVC_S_BLOCKED); |
| 1309 | /* when the BSS side signaling PTP is RESET, all PTP BVC must start the |
| 1310 | * reset procedure */ |
| 1311 | f_ptp_sendReset(); |
| 1312 | } else { |
| 1313 | f_ptp_change_state(BVC_S_UNBLOCKED); |
| 1314 | } |
| 1315 | } |
| 1316 | |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1317 | /* Ignore those for now */ |
| 1318 | [] BVC.receive(ASP_Event:?) { } |
| 1319 | [] BVC.receive(BssgpStatusIndication:?) { } |
| 1320 | |
| 1321 | /* catch-all */ |
| 1322 | [] BVC.receive(tr_ptp_BnsUdInd(?, 0)) -> value udi { |
| 1323 | setverdict(fail, "Received unexpected NS (SIG): ", udi); |
| 1324 | } |
| 1325 | [] BVC.receive(tr_ptp_BnsUdInd(?, ?)) -> value udi { |
| 1326 | setverdict(fail, "Received unexpected NS (PTP): ", udi); |
| 1327 | } |
| 1328 | [] BVC.receive { |
| 1329 | setverdict(fail, "Received unexpected message from BSSGP_CT"); |
| 1330 | } |
| 1331 | |
| 1332 | /* registration/deregistration of Clients (per-TLLI components) */ |
| 1333 | [] BSSGP_PROC.getcall(BSSGP_register_client:{?,?}) -> param(imsi, tlli) sender vc_conn { |
| 1334 | f_tbl_client_add(imsi, tlli, vc_conn); |
| 1335 | BSSGP_PROC.reply(BSSGP_register_client:{imsi, tlli}) to vc_conn; |
| 1336 | } |
| 1337 | [] BSSGP_PROC.getcall(BSSGP_unregister_client:{?}) -> param(imsi) sender vc_conn { |
| 1338 | f_tbl_client_del(imsi, vc_conn); |
| 1339 | BSSGP_PROC.reply(BSSGP_unregister_client:{imsi}) to vc_conn; |
| 1340 | } |
| 1341 | [] BSSGP_PROC.getcall(BSSGP_llgmm_assign:{?,?}) -> param(tlli_old, tlli) sender vc_conn { |
| 1342 | f_tbl_client_llgmm_assign(tlli_old, tlli, vc_conn); |
| 1343 | BSSGP_PROC.reply(BSSGP_llgmm_assign:{tlli_old, tlli}) to vc_conn; |
| 1344 | } |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1345 | |
| 1346 | [] MGMT.receive(BssgpResetRequest:?) -> value brr { |
Harald Welte | 52cecbb | 2020-11-25 21:57:31 +0100 | [diff] [blame] | 1347 | f_ptp_change_state(BVC_S_BLOCKED); |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1348 | f_ptp_sendReset(brr.cause); |
| 1349 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1350 | } |
| 1351 | |
| 1352 | /* main loop for per-BVC component */ |
| 1353 | private function f_bssgp_bvc_ScanEvents() runs on BSSGP_BVC_CT { |
| 1354 | while (true) { |
| 1355 | alt { |
| 1356 | [g_ptp_bvc_state == BVC_S_BLOCKED] as_ptp_blocked(); |
| 1357 | [g_ptp_bvc_state == BVC_S_UNBLOCKED] as_ptp_unblocked(); |
| 1358 | [] as_ptp_allstate(); |
| 1359 | } |
| 1360 | } |
| 1361 | } |
| 1362 | |
| 1363 | /* main function for per-BVC Component */ |
Harald Welte | fba7afd | 2020-11-24 23:12:31 +0100 | [diff] [blame] | 1364 | private function f_bssgp_bvc_main(BssgpBvcConfig cfg, boolean sgsn_role, Nsei nsei, charstring id) runs on BSSGP_BVC_CT { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1365 | g_cfg := cfg; |
Harald Welte | fba7afd | 2020-11-24 23:12:31 +0100 | [diff] [blame] | 1366 | g_nsei := nsei; |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1367 | g_bvc_lsp := cfg.bvci; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1368 | g_sgsn_role := sgsn_role; |
| 1369 | f_bssgp_bvc_ScanEvents(); |
| 1370 | } |
| 1371 | |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1372 | template (value) NsUnitdataRequest ts_ptp_BnsUdReq(template (value) PDU_BSSGP pdu, template (value) BssgpBvci bvci, |
| 1373 | template (value) integer lsp) := { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1374 | bvci := bvci, |
| 1375 | nsei := 0, // overwritten in BSSGP_CT |
Harald Welte | c450552 | 2020-11-11 18:55:09 +0100 | [diff] [blame] | 1376 | lsp := lsp, |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1377 | /* for some weird reason we get "Dynamic test case error: Text encoder: Encoding an |
| 1378 | * unbound integer value." when trying to send the reocrd rather than the octetstring */ |
| 1379 | //sdu := omit, |
| 1380 | //bssgp := valueof(pdu) |
| 1381 | sdu := enc_PDU_BSSGP(valueof(pdu)), |
| 1382 | bssgp := omit |
| 1383 | } |
| 1384 | |
| 1385 | template (present) NsUnitdataIndication tr_ptp_BnsUdInd(template (present) PDU_BSSGP pdu, template (present) BssgpBvci bvci) := { |
| 1386 | bvci := bvci, |
| 1387 | nsei := ?, |
Harald Welte | 80a249a | 2020-11-17 19:57:40 +0100 | [diff] [blame] | 1388 | nsvci := ?, |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1389 | sdu := *, |
| 1390 | bssgp := pdu |
| 1391 | } |
| 1392 | |
| 1393 | /* change state of PTP BVC; broadcast state change to clients */ |
| 1394 | private function f_ptp_change_state(BvcState new_state) runs on BSSGP_BVC_CT { |
| 1395 | if (new_state == g_ptp_bvc_state) { |
| 1396 | return; |
| 1397 | } |
| 1398 | log("BVCI(", g_cfg.bvci, ") State Transition: ", g_ptp_bvc_state, " -> ", new_state); |
| 1399 | g_ptp_bvc_state := new_state; |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1400 | if (MGMT.checkstate("Connected")) { |
Harald Welte | fba7afd | 2020-11-24 23:12:31 +0100 | [diff] [blame] | 1401 | MGMT.send(ts_BssgpStsInd(g_nsei, g_cfg.bvci, g_ptp_bvc_state)); |
Harald Welte | 199f386 | 2020-11-15 22:37:45 +0100 | [diff] [blame] | 1402 | } |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1403 | for (var integer i := 0; i < sizeof(ClientTable); i := i+1) { |
| 1404 | if (isbound(ClientTable[i].comp_ref) and ClientTable[i].comp_ref != null) { |
Harald Welte | fba7afd | 2020-11-24 23:12:31 +0100 | [diff] [blame] | 1405 | BSSGP_SP.send(ts_BssgpStsInd(g_nsei, g_cfg.bvci, g_ptp_bvc_state)) to ClientTable[i].comp_ref; |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1406 | } |
| 1407 | } |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 1408 | } |
| 1409 | |
| 1410 | /* attempt to extract the TLLI from a BSSGP PDU */ |
| 1411 | function f_bssgp_get_tlli(PDU_BSSGP bssgp) return template OCT4 { |
| 1412 | if (ischosen(bssgp.pDU_BSSGP_DL_UNITDATA)) { |
| 1413 | return bssgp.pDU_BSSGP_DL_UNITDATA.tLLI_current; |
| 1414 | } else if (ischosen(bssgp.pDU_BSSGP_UL_UNITDATA)) { |
| 1415 | return bssgp.pDU_BSSGP_UL_UNITDATA.tLLI; |
| 1416 | } else if (ischosen(bssgp.pDU_BSSGP_RA_CAPABILITY)) { |
| 1417 | return bssgp.pDU_BSSGP_RA_CAPABILITY.tLLI.tLLI_Value; |
| 1418 | } else if (ischosen(bssgp.pDU_BSSGP_RA_CAPABILITY_UPDATE)) { |
| 1419 | return bssgp.pDU_BSSGP_RA_CAPABILITY_UPDATE.tLLI.tLLI_Value; |
| 1420 | } else if (ischosen(bssgp.pDU_BSSGP_RA_CAPABILITY_UPDATE_ACK)) { |
| 1421 | return bssgp.pDU_BSSGP_RA_CAPABILITY_UPDATE_ACK.tLLI.tLLI_Value; |
Harald Welte | 650bd72 | 2021-01-17 10:58:56 +0100 | [diff] [blame] | 1422 | } else if (ischosen(bssgp.pDU_BSSGP_RADIO_STATUS) and |
| 1423 | ispresent(bssgp.pDU_BSSGP_RADIO_STATUS.tLLI)) { |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 1424 | return bssgp.pDU_BSSGP_RADIO_STATUS.tLLI.tLLI_Value; |
| 1425 | } else if (ischosen(bssgp.pDU_BSSGP_SUSPEND)) { |
| 1426 | return bssgp.pDU_BSSGP_SUSPEND.tLLI.tLLI_Value; |
| 1427 | } else if (ischosen(bssgp.pDU_BSSGP_SUSPEND_ACK)) { |
| 1428 | return bssgp.pDU_BSSGP_SUSPEND_ACK.tLLI.tLLI_Value; |
| 1429 | } else if (ischosen(bssgp.pDU_BSSGP_SUSPEND_NACK)) { |
| 1430 | return bssgp.pDU_BSSGP_SUSPEND_NACK.tLLI.tLLI_Value; |
| 1431 | } else if (ischosen(bssgp.pDU_BSSGP_RESUME)) { |
| 1432 | return bssgp.pDU_BSSGP_RESUME.tLLI.tLLI_Value; |
| 1433 | } else if (ischosen(bssgp.pDU_BSSGP_RESUME_ACK)) { |
| 1434 | return bssgp.pDU_BSSGP_RESUME_ACK.tLLI.tLLI_Value; |
| 1435 | } else if (ischosen(bssgp.pDU_BSSGP_RESUME_NACK)) { |
| 1436 | return bssgp.pDU_BSSGP_RESUME_NACK.tLLI.tLLI_Value; |
| 1437 | } else if (ischosen(bssgp.pDU_BSSGP_FLUSH_LL)) { |
| 1438 | return bssgp.pDU_BSSGP_FLUSH_LL.tLLI.tLLI_Value; |
| 1439 | } else if (ischosen(bssgp.pDU_BSSGP_FLUSH_LL_ACK)) { |
| 1440 | return bssgp.pDU_BSSGP_FLUSH_LL_ACK.tLLI.tLLI_Value; |
| 1441 | } else if (ischosen(bssgp.pDU_BSSGP_LLC_DISCARDED)) { |
| 1442 | return bssgp.pDU_BSSGP_LLC_DISCARDED.tLLI.tLLI_Value; |
| 1443 | } else if (ischosen(bssgp.pDU_BSSGP_LLC_DISCARDED)) { |
| 1444 | return bssgp.pDU_BSSGP_LLC_DISCARDED.tLLI.tLLI_Value; |
| 1445 | } else if (ischosen(bssgp.pDU_BSSGP_PAGING_CS) and |
| 1446 | isvalue(bssgp.pDU_BSSGP_PAGING_CS.tLLI)) { |
| 1447 | return bssgp.pDU_BSSGP_PAGING_CS.tLLI.tLLI_Value; |
| 1448 | } else if (ischosen(bssgp.pDU_BSSGP_FLOW_CONTROL_MS)) { |
| 1449 | return bssgp.pDU_BSSGP_FLOW_CONTROL_MS.tLLI.tLLI_Value; |
| 1450 | } else if (ischosen(bssgp.pDU_BSSGP_FLOW_CONTROL_MS_ACK)) { |
| 1451 | return bssgp.pDU_BSSGP_FLOW_CONTROL_MS_ACK.tLLI.tLLI_Value; |
| 1452 | } |
| 1453 | /* TODO: Handover, PFC, LCS */ |
| 1454 | return omit; |
| 1455 | } |
| 1456 | |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 1457 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 1458 | |
Harald Welte | 1733a38 | 2017-07-23 17:26:17 +0200 | [diff] [blame] | 1459 | } |