Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 1 | module RSL_Emulation { |
| 2 | |
Harald Welte | 35bb716 | 2018-01-03 21:07:52 +0100 | [diff] [blame] | 3 | /* RSL Emulation, runs on top of IPA_Emulation. It multiplexes/demultiplexes |
| 4 | * the individual connections (logical channels), so there can be separate TTCN-3 components |
| 5 | * handling each of the connections. |
| 6 | * |
| 7 | * The RSL_Emulation.main() function processes RSL messages from the IPA demultiplex |
| 8 | * stack via the IPA_RSL_PT, and dispatches them to the per-connection components. |
| 9 | * |
| 10 | * Outbound RSL connections are initiated by sending a RSLDC_ChanRqd primitive |
| 11 | * to the component running the RSL_Emulation.main() function. |
| 12 | * |
| 13 | * (C) 2017 by Harald Welte <laforge@gnumonks.org> |
| 14 | * All rights reserved. |
| 15 | * |
| 16 | * Released under the terms of GNU General Public License, Version 2 or |
| 17 | * (at your option) any later version. |
| 18 | */ |
| 19 | |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 20 | import from General_Types all; |
| 21 | import from Osmocom_Types all; |
| 22 | import from GSM_Types all; |
| 23 | import from GSM_RR_Types all; |
| 24 | import from RSL_Types all; |
| 25 | import from IPA_Types all; |
| 26 | import from IPA_Emulation all; |
| 27 | |
| 28 | |
| 29 | /* General "base class" component definition, of which specific implementations |
| 30 | * derive themselves by means of the "extends" feature */ |
| 31 | type component RSL_DchanHdlr { |
| 32 | /* port facing up towards dedicated channel handler */ |
| 33 | port RSL_DCHAN_PT RSL; |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 34 | port RSLEM_PROC_PT RSL_PROC; |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 35 | var RslChannelNr g_chan_nr; |
Harald Welte | 421e4d4 | 2018-02-12 20:04:50 +0100 | [diff] [blame] | 36 | /* second BTS / DChan during hand-over */ |
| 37 | port RSL_DCHAN_PT RSL1; |
| 38 | port RSLEM_PROC_PT RSL1_PROC; |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | type record RSLDC_ChanRqd { |
| 42 | OCT1 ra, |
| 43 | GsmFrameNumber fn |
| 44 | }; |
| 45 | |
| 46 | template RSLDC_ChanRqd ts_RSLDC_ChanRqd(OCT1 ra, GsmFrameNumber fn) := { |
| 47 | ra := ra, |
| 48 | fn := fn |
| 49 | } |
| 50 | |
| 51 | type port RSL_DCHAN_PT message { |
| 52 | inout RSLDC_ChanRqd, RSL_Message; |
| 53 | } with { extension "internal" }; |
| 54 | |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 55 | signature RSLEM_register(uint8_t trx_nr, RslChannelNr chan_nr, RSL_DchanHdlr hdlr); |
Harald Welte | 1909f46 | 2018-01-29 22:29:29 +0100 | [diff] [blame] | 56 | signature RSLEM_unregister(uint8_t trx_nr, RslChannelNr chan_nr, RSL_DchanHdlr hdlr); |
Harald Welte | 70b52c9 | 2018-02-12 20:47:31 +0100 | [diff] [blame^] | 57 | signature RSLEM_suspend(boolean suspend); |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 58 | |
| 59 | type port RSLEM_PROC_PT procedure { |
Harald Welte | 70b52c9 | 2018-02-12 20:47:31 +0100 | [diff] [blame^] | 60 | inout RSLEM_register, RSLEM_unregister, RSLEM_suspend; |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 61 | } with { extension "internal" }; |
| 62 | |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 63 | /*********************************************************************** |
| 64 | * Client Component for a single dedicated channel |
| 65 | ***********************************************************************/ |
| 66 | |
| 67 | private function f_rx_or_fail(template RSL_Message exp_rx) runs on RSL_DchanHdlr return RSL_Message |
| 68 | { |
| 69 | var RSL_Message rx_rsl; |
| 70 | timer T := 10.0; |
| 71 | |
| 72 | /* request a channel to be established */ |
| 73 | T.start; |
| 74 | alt { |
| 75 | [] RSL.receive(exp_rx) -> value rx_rsl { |
| 76 | T.stop; |
| 77 | return rx_rsl; |
| 78 | } |
| 79 | [] RSL.receive { |
| 80 | setverdict(fail, "Unexpected RSL message on DCHAN"); |
| 81 | self.stop; |
| 82 | } |
| 83 | [] T.timeout { |
| 84 | setverdict(fail, "Timeout waiting for RSL on DCHAN"); |
| 85 | self.stop; |
| 86 | } |
| 87 | } |
| 88 | /* never reached */ |
| 89 | return rx_rsl; |
| 90 | } |
| 91 | |
| 92 | /* establish a dedicated channel using 'ra' */ |
| 93 | function f_chan_est(OCT1 ra, octetstring est_l3, template RslLinkId link_id, GsmFrameNumber fn := 23) |
| 94 | runs on RSL_DchanHdlr { |
| 95 | var RSL_Message rx_rsl; |
| 96 | var GsmRrMessage rr; |
| 97 | |
| 98 | /* request a channel to be established */ |
| 99 | RSL.send(ts_RSLDC_ChanRqd(ra, fn)); |
| 100 | /* expect immediate assignment */ |
| 101 | rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN); |
| 102 | rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload); |
| 103 | g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr; |
| 104 | RSL.send(ts_RSL_EST_IND(g_chan_nr, valueof(link_id), est_l3)); |
| 105 | } |
| 106 | |
| 107 | function f_deact_chan(RSL_Cause cause) runs on RSL_DchanHdlr |
| 108 | { |
| 109 | var RSL_Message rx_rsl; |
| 110 | |
| 111 | RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, cause)); |
| 112 | rx_rsl := f_rx_or_fail(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)); |
| 113 | /* FIXME RSL.send(ts_RSL_RF_CHAN_REL_ACK()) */ |
| 114 | } |
| 115 | |
| 116 | |
| 117 | |
| 118 | /*********************************************************************** |
| 119 | * Main Component |
| 120 | ***********************************************************************/ |
| 121 | |
| 122 | private type record ConnectionData { |
| 123 | /* component reference to the client component */ |
| 124 | RSL_DchanHdlr comp_ref, |
| 125 | /* RSL (dedicated) Channel number we're handling */ |
| 126 | uint8_t trx_nr optional, |
| 127 | IpaStreamId stream_id optional, |
| 128 | RslChannelNr chan_nr optional, |
| 129 | /* Random Reference */ |
| 130 | OCT1 ra optional, |
| 131 | GsmFrameNumber ra_fn optional |
| 132 | }; |
| 133 | |
| 134 | private function f_cid_by_comp_ref(RSL_DchanHdlr comp_ref) |
| 135 | runs on RSL_Emulation_CT return integer { |
| 136 | var integer i; |
| 137 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 138 | if (ispresent(ConnectionTable[i].comp_ref) and |
| 139 | ConnectionTable[i].comp_ref == comp_ref) { |
| 140 | return i; |
| 141 | } |
| 142 | } |
| 143 | log("No Dchan handler for ", comp_ref); |
| 144 | return -1; |
| 145 | } |
| 146 | |
| 147 | private function f_cid_by_chan_nr(uint8_t trx_nr, RslChannelNr chan_nr) |
| 148 | runs on RSL_Emulation_CT return integer { |
| 149 | var integer i; |
| 150 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 151 | if (ispresent(ConnectionTable[i].chan_nr) and |
| 152 | ConnectionTable[i].chan_nr == chan_nr and ConnectionTable[i].trx_nr == trx_nr) { |
| 153 | return i; |
| 154 | } |
| 155 | } |
| 156 | log("No Dchan handler for ", trx_nr, chan_nr); |
| 157 | return -1; |
| 158 | } |
| 159 | |
| 160 | private function f_cid_by_ra_fn(OCT1 ra, GsmFrameNumber fn) |
| 161 | runs on RSL_Emulation_CT return integer { |
| 162 | var integer i; |
| 163 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 164 | if (ispresent(ConnectionTable[i].ra) and |
| 165 | ConnectionTable[i].ra == ra and ConnectionTable[i].ra_fn == fn) { |
| 166 | return i; |
| 167 | } |
| 168 | } |
| 169 | log("No Dchan handler for ", ra, fn); |
| 170 | return -1; |
| 171 | } |
| 172 | |
| 173 | /* create an ew client with given RA and FN */ |
| 174 | private function f_cid_create(OCT1 ra, GsmFrameNumber fn, RSL_DchanHdlr comp_ref) |
| 175 | runs on RSL_Emulation_CT return integer { |
| 176 | var integer i; |
| 177 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 178 | if (not ispresent(ConnectionTable[i].ra) and |
| 179 | not ispresent(ConnectionTable[i].trx_nr)) { |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 180 | ConnectionTable[i].ra := ra; |
| 181 | ConnectionTable[i].ra_fn := fn; |
| 182 | ConnectionTable[i].comp_ref := comp_ref; |
| 183 | return i; |
| 184 | } |
| 185 | } |
| 186 | log("No free entry in conn table for ", ra, fn); |
| 187 | return -1; |
| 188 | } |
| 189 | |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 190 | /* create an ew client with given RA and FN */ |
| 191 | private function f_cid_create_cnr(uint8_t trx_nr, RslChannelNr chan_nr, RSL_DchanHdlr comp_ref) |
| 192 | runs on RSL_Emulation_CT return integer { |
| 193 | var integer i; |
| 194 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 195 | if (not ispresent(ConnectionTable[i].ra) and |
| 196 | not ispresent(ConnectionTable[i].trx_nr)) { |
| 197 | ConnectionTable[i].stream_id := f_streamId_by_trx(trx_nr); |
| 198 | ConnectionTable[i].trx_nr := trx_nr; |
| 199 | ConnectionTable[i].chan_nr := chan_nr; |
| 200 | ConnectionTable[i].comp_ref := comp_ref; |
| 201 | return i; |
| 202 | } |
| 203 | } |
| 204 | log("No free entry in conn table for ", trx_nr, chan_nr, comp_ref); |
| 205 | return -1; |
| 206 | } |
| 207 | |
| 208 | |
| 209 | /* create an ew client with given RA and FN */ |
| 210 | private function f_cid_delete_cnr(IpaStreamId stream_id, RslChannelNr chan_nr, RSL_DchanHdlr comp_ref) |
| 211 | runs on RSL_Emulation_CT return integer { |
| 212 | var integer i; |
| 213 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 214 | if (ConnectionTable[i].comp_ref == null) { |
| 215 | continue; |
| 216 | } |
| 217 | if (ConnectionTable[i].stream_id == stream_id and |
| 218 | ConnectionTable[i].chan_nr == chan_nr and |
| 219 | ConnectionTable[i].comp_ref == comp_ref) { |
| 220 | f_cid_clear(i); |
| 221 | } |
| 222 | } |
| 223 | log("Unable to find entry to delete for ", stream_id, chan_nr, comp_ref); |
| 224 | return -1; |
| 225 | } |
| 226 | |
| 227 | |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 228 | private function f_cid_clear(integer cid) |
| 229 | runs on RSL_Emulation_CT { |
| 230 | ConnectionTable[cid].ra := omit; |
| 231 | ConnectionTable[cid].ra_fn := omit; |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 232 | ConnectionTable[cid].trx_nr := omit; |
| 233 | ConnectionTable[cid].stream_id := omit; |
| 234 | ConnectionTable[cid].chan_nr := omit; |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 235 | ConnectionTable[cid].comp_ref := null; |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | type component RSL_Emulation_CT { |
| 239 | /* port facing down towards IPA emulation */ |
| 240 | port IPA_RSL_PT IPA_PT; |
| 241 | /* port facing up towards dedicated channel handler */ |
| 242 | port RSL_DCHAN_PT CLIENT_PT; |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 243 | port RSLEM_PROC_PT RSL_PROC; |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 244 | |
| 245 | /* state of all concurrent connections / dedicated channels */ |
| 246 | var ConnectionData ConnectionTable[64]; |
| 247 | } |
| 248 | |
| 249 | |
| 250 | /* template for an ASP_RSL_Unitdata as we receive it from the IPA_Emulateion component */ |
| 251 | private template ASP_RSL_Unitdata tr_RSL(template RSL_Message rsl, template IpaStreamId sid := ?) := { |
| 252 | streamId := sid, |
| 253 | rsl := rsl |
| 254 | } |
| 255 | |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 256 | private function f_trx_by_streamId(IpaStreamId id) return integer { |
| 257 | return enum2int(id); |
| 258 | } |
| 259 | |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 260 | private function f_streamId_by_trx(uint8_t trx_nr) return IpaStreamId { |
| 261 | select (trx_nr) { |
| 262 | case (0) { return IPAC_PROTO_RSL_TRX0; } |
| 263 | case (1) { return IPAC_PROTO_RSL_TRX1; } |
| 264 | case (2) { return IPAC_PROTO_RSL_TRX2; } |
| 265 | case (3) { return IPAC_PROTO_RSL_TRX3; } |
| 266 | } |
| 267 | self.stop; |
| 268 | } |
| 269 | |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 270 | |
| 271 | function main() runs on RSL_Emulation_CT { |
| 272 | var ASP_RSL_Unitdata rx_rsl; |
| 273 | var RSL_Message rx_rsl_msg; |
| 274 | var RSLDC_ChanRqd chan_rqd; |
| 275 | var RSL_DchanHdlr vc_conn; |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 276 | var RslChannelNr chan_nr; |
| 277 | var uint8_t trx_nr; |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 278 | var integer cid; |
| 279 | var integer i; |
Harald Welte | 70b52c9 | 2018-02-12 20:47:31 +0100 | [diff] [blame^] | 280 | /* special synchronization handling during hand-over */ |
| 281 | var boolean dchan_suspended := false; |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 282 | |
Daniel Willmann | 17f970f | 2018-01-17 12:03:19 +0100 | [diff] [blame] | 283 | f_conn_table_init(); |
| 284 | |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 285 | while (true) { |
| 286 | alt { |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 287 | [] IPA_PT.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP}) { |
| 288 | } |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 289 | [] IPA_PT.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_ID_ACK}) { |
Harald Welte | 7ae019e | 2017-12-09 00:54:15 +0100 | [diff] [blame] | 290 | IPA_PT.send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23))); |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 291 | } |
| 292 | [] IPA_PT.receive(tr_RSL(tr_RSL_IMM_ASSIGN)) -> value rx_rsl { |
| 293 | var GsmRrMessage rr; |
| 294 | var OCT1 ra; |
| 295 | var GsmFrameNumber fn; |
| 296 | log("IMM ASS INFO ", rx_rsl.rsl.ies[1].body); |
| 297 | rr := dec_GsmRrMessage(rx_rsl.rsl.ies[1].body.full_imm_ass_info.payload); |
| 298 | if (ischosen(rr.payload.imm_ass)) { |
| 299 | ra := bit2oct(rr.payload.imm_ass.req_ref.ra); |
| 300 | fn := 23; //FIXME(rr.payload.imm_ass); |
| 301 | /* lookup client based on RA+time, deliver to client */ |
| 302 | cid := f_cid_by_ra_fn(ra, fn); |
| 303 | if (cid == -1) { |
| 304 | setverdict(fail, "IMM ASS for unknown DChan"); |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 305 | self.stop; |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 306 | } |
| 307 | /* update client with trx_nr */ |
| 308 | ConnectionTable[cid].trx_nr := f_trx_by_streamId(rx_rsl.streamId); |
| 309 | ConnectionTable[cid].stream_id := rx_rsl.streamId; |
| 310 | /* update client with chan_nr */ |
| 311 | ConnectionTable[cid].chan_nr := rr.payload.imm_ass.chan_desc.chan_nr; |
| 312 | /* TODO: add timer to time-out ConnectionTable entries which |
| 313 | * never get followed-up to */ |
| 314 | CLIENT_PT.send(rx_rsl.rsl) to ConnectionTable[cid].comp_ref; |
| 315 | } else if (ischosen(rr.payload.imm_ass_rej)) { |
| 316 | for (i := 0; i < sizeof(rr.payload.imm_ass_rej.payload); i := i + 1) { |
| 317 | ra := bit2oct(rr.payload.imm_ass_rej.payload[i].req_ref.ra); |
| 318 | fn := 23; //FIXME(); |
| 319 | /* lookup client based on RA+time, deliver to client */ |
| 320 | cid := f_cid_by_ra_fn(ra, fn); |
| 321 | if (cid != -1) { |
| 322 | CLIENT_PT.send(rx_rsl.rsl) to ConnectionTable[cid].comp_ref; |
| 323 | /* delete ClientTable entry, as it failed */ |
| 324 | f_cid_clear(cid); |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | [] IPA_PT.receive(tr_RSL(tr_RSL_PAGING_CMD(?, ?))) -> value rx_rsl { |
| 331 | log("PAGING IDENTITY ", rx_rsl.rsl.ies[2].body.other); |
| 332 | /* broadcast to all clients? */ |
| 333 | for (i := 0; i < sizeof(ConnectionTable); i := i + 1) { |
| 334 | if (ispresent(ConnectionTable[i].comp_ref)) { |
| 335 | CLIENT_PT.send(rx_rsl.rsl) to ConnectionTable[i].comp_ref; |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | [] IPA_PT.receive(tr_RSL(tr_RSL_MsgTypeT(?))) -> value rx_rsl { |
| 341 | log("Ingnoring TRX Mgmt ", rx_rsl.rsl); |
| 342 | } |
| 343 | |
| 344 | [] IPA_PT.receive(tr_RSL(tr_RSL_MsgTypeC(?))) -> value rx_rsl { |
| 345 | log("Ignoring Common Channel Mgmt ", rx_rsl.rsl); |
| 346 | } |
| 347 | |
| 348 | /* blindly acknowledge all channel activations */ |
| 349 | [] IPA_PT.receive(tr_RSL(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) -> value rx_rsl { |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 350 | chan_nr := rx_rsl.rsl.ies[0].body.chan_nr; |
Harald Welte | 7ae019e | 2017-12-09 00:54:15 +0100 | [diff] [blame] | 351 | IPA_PT.send(ts_ASP_RSL_UD(rx_rsl.streamId, ts_RSL_CHAN_ACT_ACK(chan_nr, 23))); |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 352 | } |
| 353 | |
Harald Welte | 70b52c9 | 2018-02-12 20:47:31 +0100 | [diff] [blame^] | 354 | [not dchan_suspended] IPA_PT.receive(tr_RSL(tr_RSL_MsgTypeDR(?))) -> value rx_rsl { |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 355 | /* dispatch to channel based on ChanId */ |
| 356 | cid := f_cid_by_chan_nr(f_trx_by_streamId(rx_rsl.streamId), |
| 357 | rx_rsl.rsl.ies[0].body.chan_nr); |
| 358 | if (cid != -1) { |
| 359 | CLIENT_PT.send(rx_rsl.rsl) to ConnectionTable[cid].comp_ref; |
| 360 | } else { |
| 361 | setverdict(fail, "RSL for unknown Dchan"); |
| 362 | } |
| 363 | } |
| 364 | |
Harald Welte | 70b52c9 | 2018-02-12 20:47:31 +0100 | [diff] [blame^] | 365 | [not dchan_suspended] IPA_PT.receive { |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 366 | setverdict(fail, "Received unknown primitive from IPA"); |
| 367 | self.stop; |
| 368 | } |
| 369 | |
| 370 | [] CLIENT_PT.receive(RSLDC_ChanRqd:?) -> value chan_rqd sender vc_conn { |
| 371 | /* Store the knowledge that this sender has requested a certain RQ+time */ |
| 372 | f_cid_create(chan_rqd.ra, chan_rqd.fn, vc_conn); |
Harald Welte | 7ae019e | 2017-12-09 00:54:15 +0100 | [diff] [blame] | 373 | IPA_PT.send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 374 | ts_RSL_CHAN_RQD(chan_rqd.ra, chan_rqd.fn))); |
| 375 | } |
| 376 | |
| 377 | [] CLIENT_PT.receive(tr_RSL_MsgType(?)) -> value rx_rsl_msg sender vc_conn { |
| 378 | /* forward to BSC */ |
| 379 | cid := f_cid_by_comp_ref(vc_conn); |
Harald Welte | 7ae019e | 2017-12-09 00:54:15 +0100 | [diff] [blame] | 380 | IPA_PT.send(ts_ASP_RSL_UD(ConnectionTable[cid].stream_id, rx_rsl_msg)); |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 381 | } |
| 382 | |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 383 | /* explicit registration, e.g. in (non-immediate) assignment case */ |
| 384 | [] RSL_PROC.getcall(RSLEM_register:{?,?,?}) -> param(trx_nr, chan_nr, vc_conn) { |
| 385 | f_cid_create_cnr(trx_nr, chan_nr, vc_conn); |
| 386 | RSL_PROC.reply(RSLEM_register:{trx_nr, chan_nr, vc_conn}); |
| 387 | } |
| 388 | |
Harald Welte | 1909f46 | 2018-01-29 22:29:29 +0100 | [diff] [blame] | 389 | [] RSL_PROC.getcall(RSLEM_unregister:{?,?,?}) -> param(trx_nr, chan_nr, vc_conn) { |
| 390 | cid := f_cid_by_chan_nr(trx_nr, chan_nr); |
| 391 | f_cid_clear(cid); |
| 392 | RSL_PROC.reply(RSLEM_unregister:{trx_nr, chan_nr, vc_conn}); |
| 393 | } |
| 394 | |
Harald Welte | 70b52c9 | 2018-02-12 20:47:31 +0100 | [diff] [blame^] | 395 | [] RSL_PROC.getcall(RSLEM_suspend:{true}) { |
| 396 | log("Suspending DChan"); |
| 397 | dchan_suspended := true; |
| 398 | RSL_PROC.reply(RSLEM_suspend:{true}); |
| 399 | } |
| 400 | |
| 401 | [] RSL_PROC.getcall(RSLEM_suspend:{false}) { |
| 402 | log("Resuming DChan"); |
| 403 | dchan_suspended := false; |
| 404 | RSL_PROC.reply(RSLEM_suspend:{false}); |
| 405 | } |
Harald Welte | 1909f46 | 2018-01-29 22:29:29 +0100 | [diff] [blame] | 406 | |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
Daniel Willmann | 17f970f | 2018-01-17 12:03:19 +0100 | [diff] [blame] | 411 | private function f_conn_table_init() |
| 412 | runs on RSL_Emulation_CT { |
| 413 | var integer i; |
| 414 | |
| 415 | /* Initialize the ConnectionTable */ |
| 416 | for (i := 0; i < sizeof(ConnectionTable); i := i+1) { |
| 417 | f_cid_clear(i); |
| 418 | } |
| 419 | } |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 420 | |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 421 | /* client/conn_hdlr side function to use procedure port to register stream_id/chan_nr */ |
Harald Welte | 421e4d4 | 2018-02-12 20:04:50 +0100 | [diff] [blame] | 422 | function f_rslem_register(uint8_t trx_nr, RslChannelNr chan_nr, RSLEM_PROC_PT PT := RSL_PROC) |
| 423 | runs on RSL_DchanHdlr { |
| 424 | PT.call(RSLEM_register:{trx_nr, chan_nr, self}) { |
| 425 | [] PT.getreply(RSLEM_register:{?,?,?}) {}; |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 426 | } |
| 427 | } |
| 428 | |
Harald Welte | 1909f46 | 2018-01-29 22:29:29 +0100 | [diff] [blame] | 429 | /* client/conn_hdlr side function to use procedure port to unregister stream_id/chan_nr */ |
Harald Welte | 421e4d4 | 2018-02-12 20:04:50 +0100 | [diff] [blame] | 430 | function f_rslem_unregister(uint8_t trx_nr, RslChannelNr chan_nr, RSLEM_PROC_PT PT := RSL_PROC) |
| 431 | runs on RSL_DchanHdlr { |
| 432 | PT.call(RSLEM_unregister:{trx_nr, chan_nr, self}) { |
| 433 | [] PT.getreply(RSLEM_unregister:{?,?,?}) {}; |
Harald Welte | 1909f46 | 2018-01-29 22:29:29 +0100 | [diff] [blame] | 434 | } |
| 435 | } |
| 436 | |
Harald Welte | 70b52c9 | 2018-02-12 20:47:31 +0100 | [diff] [blame^] | 437 | /* resume handling of RSL DChan messages from IPA until f_rslem_resume() is called */ |
| 438 | function f_rslem_suspend(RSLEM_PROC_PT PT) |
| 439 | runs on RSL_DchanHdlr { |
| 440 | PT.call(RSLEM_suspend:{true}) { |
| 441 | [] PT.getreply(RSLEM_suspend:{true}) {}; |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | /* resume handling of RSL DChan messages after f_rslem_suspend() is called */ |
| 446 | function f_rslem_resume(RSLEM_PROC_PT PT) |
| 447 | runs on RSL_DchanHdlr { |
| 448 | PT.call(RSLEM_suspend:{false}) { |
| 449 | [] PT.getreply(RSLEM_suspend:{false}) {}; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | |
Harald Welte | 1909f46 | 2018-01-29 22:29:29 +0100 | [diff] [blame] | 454 | |
Harald Welte | 714ded9 | 2017-12-08 14:00:22 +0100 | [diff] [blame] | 455 | } |