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