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