blob: cb8b763d11ca9694d76c6af3bbc77397ca75aedc [file] [log] [blame]
Harald Welte714ded92017-12-08 14:00:22 +01001module RSL_Emulation {
2
Harald Welte35bb7162018-01-03 21:07:52 +01003/* 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 *
Harald Weltead2647b2018-03-22 19:53:55 +010013 * in case we're emulating the BTS-side of RSL: We have no clue as to which particular logical
14 * channel the BSC may decide to activate at which point, so we have to blindly acknowledge all
15 * channel activations. Still, a test case might be interested in the exact assignment message to
16 * determine the type of activation, encryption, codec flags etc. at some later point, when it's
17 * clear for which transaction this activation happened. We keep this in the LastChanAct table.
18 *
19 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte35bb7162018-01-03 21:07:52 +010020 * All rights reserved.
21 *
22 * Released under the terms of GNU General Public License, Version 2 or
23 * (at your option) any later version.
Harald Welte34b5a952019-05-27 11:54:11 +020024 *
25 * SPDX-License-Identifier: GPL-2.0-or-later
Harald Welte35bb7162018-01-03 21:07:52 +010026 */
27
Pau Espin Pedrola07cfd92018-10-22 15:54:41 +020028import from Misc_Helpers all;
Harald Welte714ded92017-12-08 14:00:22 +010029import from General_Types all;
30import from Osmocom_Types all;
31import from GSM_Types all;
32import from GSM_RR_Types all;
33import from RSL_Types all;
34import from IPA_Types all;
35import from IPA_Emulation all;
36
Harald Welte714ded92017-12-08 14:00:22 +010037/* General "base class" component definition, of which specific implementations
38 * derive themselves by means of the "extends" feature */
39type component RSL_DchanHdlr {
40 /* port facing up towards dedicated channel handler */
41 port RSL_DCHAN_PT RSL;
Harald Weltef70df652018-01-29 22:00:23 +010042 port RSLEM_PROC_PT RSL_PROC;
Harald Welte714ded92017-12-08 14:00:22 +010043 var RslChannelNr g_chan_nr;
Harald Welte421e4d42018-02-12 20:04:50 +010044 /* second BTS / DChan during hand-over */
45 port RSL_DCHAN_PT RSL1;
46 port RSLEM_PROC_PT RSL1_PROC;
Neels Hofmeyr91401012019-07-11 00:42:35 +020047 port RSL_DCHAN_PT RSL2;
48 port RSLEM_PROC_PT RSL2_PROC;
Harald Welte714ded92017-12-08 14:00:22 +010049};
50
51type record RSLDC_ChanRqd {
52 OCT1 ra,
Pau Espin Pedrol6451b042018-10-24 20:36:16 +020053 GsmFrameNumber fn optional
Harald Welte714ded92017-12-08 14:00:22 +010054};
55
Pau Espin Pedrol6451b042018-10-24 20:36:16 +020056template (value) RSLDC_ChanRqd ts_RSLDC_ChanRqd(OCT1 ra, GsmFrameNumber fn) := {
Harald Welte714ded92017-12-08 14:00:22 +010057 ra := ra,
58 fn := fn
59}
60
Pau Espin Pedrol6451b042018-10-24 20:36:16 +020061template (value) RSLDC_ChanRqd ts_RSLDC_ChanRqd_anyFN(OCT1 ra) := {
62 ra := ra,
63 fn := omit
64}
65
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +070066type enumerated RSLEm_EventType {
67 RSLEM_EV_TRX_UP,
68 RSLEM_EV_TRX_DOWN
69};
70
71type record RSLEm_Event {
72 RSLEm_EventType ev_type,
73 IpaStreamId sid
74};
75
76template (value) RSLEm_Event ts_RSLEm_EV(RSLEm_EventType ev_type,
77 IpaStreamId sid) := {
78 ev_type := ev_type,
79 sid := sid
80};
81template RSLEm_Event tr_RSLEm_EV(template RSLEm_EventType ev_type,
82 template IpaStreamId sid := ?) := {
83 ev_type := ev_type,
84 sid := sid
85};
86
Harald Welte714ded92017-12-08 14:00:22 +010087type port RSL_DCHAN_PT message {
88 inout RSLDC_ChanRqd, RSL_Message;
89} with { extension "internal" };
90
Harald Welte1c02fd12018-02-19 19:20:47 +010091type port RSL_CCHAN_PT message {
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +070092 inout ASP_RSL_Unitdata, RSLEm_Event;
Harald Welte1c02fd12018-02-19 19:20:47 +010093} with { extension "internal" };
94
95
Harald Weltef70df652018-01-29 22:00:23 +010096signature RSLEM_register(uint8_t trx_nr, RslChannelNr chan_nr, RSL_DchanHdlr hdlr);
Harald Welte1909f462018-01-29 22:29:29 +010097signature RSLEM_unregister(uint8_t trx_nr, RslChannelNr chan_nr, RSL_DchanHdlr hdlr);
Harald Welte70b52c92018-02-12 20:47:31 +010098signature RSLEM_suspend(boolean suspend);
Vadim Yanitskiye9c06352020-06-20 01:30:58 +070099signature RSLEM_wait_queue(boolean enable);
Harald Weltead2647b2018-03-22 19:53:55 +0100100signature RSLEM_get_last_act(in uint8_t trx_nr, in RslChannelNr chan_nr, out RSL_Message chan_act);
Harald Weltef70df652018-01-29 22:00:23 +0100101
102type port RSLEM_PROC_PT procedure {
Vadim Yanitskiye9c06352020-06-20 01:30:58 +0700103 inout RSLEM_register, RSLEM_unregister,
104 RSLEM_suspend, RSLEM_wait_queue,
105 RSLEM_get_last_act;
Harald Weltef70df652018-01-29 22:00:23 +0100106} with { extension "internal" };
107
Harald Welte714ded92017-12-08 14:00:22 +0100108/***********************************************************************
109 * Client Component for a single dedicated channel
110 ***********************************************************************/
111
112private function f_rx_or_fail(template RSL_Message exp_rx) runs on RSL_DchanHdlr return RSL_Message
113{
114 var RSL_Message rx_rsl;
115 timer T := 10.0;
116
117 /* request a channel to be established */
118 T.start;
119 alt {
120 [] RSL.receive(exp_rx) -> value rx_rsl {
121 T.stop;
122 return rx_rsl;
123 }
124 [] RSL.receive {
125 setverdict(fail, "Unexpected RSL message on DCHAN");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200126 mtc.stop;
Harald Welte714ded92017-12-08 14:00:22 +0100127 }
128 [] T.timeout {
129 setverdict(fail, "Timeout waiting for RSL on DCHAN");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200130 mtc.stop;
Harald Welte714ded92017-12-08 14:00:22 +0100131 }
132 }
133 /* never reached */
134 return rx_rsl;
135}
136
137/* establish a dedicated channel using 'ra' */
138function f_chan_est(OCT1 ra, octetstring est_l3, template RslLinkId link_id, GsmFrameNumber fn := 23)
139runs on RSL_DchanHdlr {
140 var RSL_Message rx_rsl;
141 var GsmRrMessage rr;
142
143 /* request a channel to be established */
144 RSL.send(ts_RSLDC_ChanRqd(ra, fn));
145 /* expect immediate assignment */
146 rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
147 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
148 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
149 RSL.send(ts_RSL_EST_IND(g_chan_nr, valueof(link_id), est_l3));
150}
151
152function f_deact_chan(RSL_Cause cause) runs on RSL_DchanHdlr
153{
154 var RSL_Message rx_rsl;
155
156 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, cause));
157 rx_rsl := f_rx_or_fail(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL));
158 /* FIXME RSL.send(ts_RSL_RF_CHAN_REL_ACK()) */
159}
160
161
162
163/***********************************************************************
164 * Main Component
165 ***********************************************************************/
166
167private type record ConnectionData {
168 /* component reference to the client component */
169 RSL_DchanHdlr comp_ref,
170 /* RSL (dedicated) Channel number we're handling */
171 uint8_t trx_nr optional,
172 IpaStreamId stream_id optional,
173 RslChannelNr chan_nr optional,
174 /* Random Reference */
175 OCT1 ra optional,
176 GsmFrameNumber ra_fn optional
177};
178
179private function f_cid_by_comp_ref(RSL_DchanHdlr comp_ref)
180runs on RSL_Emulation_CT return integer {
181 var integer i;
182 for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
Pau Espin Pedrol70965092020-06-23 14:29:56 +0200183 if (ispresent(ConnectionTable[i].comp_ref) and
Harald Welte714ded92017-12-08 14:00:22 +0100184 ConnectionTable[i].comp_ref == comp_ref) {
185 return i;
186 }
187 }
Vadim Yanitskiyf79d9362020-06-03 04:06:18 +0700188 log("No Dchan handler for comp_ref=", comp_ref);
Harald Welte714ded92017-12-08 14:00:22 +0100189 return -1;
190}
191
192private function f_cid_by_chan_nr(uint8_t trx_nr, RslChannelNr chan_nr)
193runs on RSL_Emulation_CT return integer {
194 var integer i;
195 for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
Pau Espin Pedrol70965092020-06-23 14:29:56 +0200196 if (ispresent(ConnectionTable[i].chan_nr) and
Harald Welte714ded92017-12-08 14:00:22 +0100197 ConnectionTable[i].chan_nr == chan_nr and ConnectionTable[i].trx_nr == trx_nr) {
198 return i;
199 }
200 }
Vadim Yanitskiyf79d9362020-06-03 04:06:18 +0700201 log("No Dchan handler for trx_nr=", trx_nr, " and chan_nr=", chan_nr);
Harald Welte714ded92017-12-08 14:00:22 +0100202 return -1;
203}
204
205private function f_cid_by_ra_fn(OCT1 ra, GsmFrameNumber fn)
206runs on RSL_Emulation_CT return integer {
207 var integer i;
208 for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
209 if (ispresent(ConnectionTable[i].ra) and
210 ConnectionTable[i].ra == ra and ConnectionTable[i].ra_fn == fn) {
211 return i;
212 }
213 }
Vadim Yanitskiyf79d9362020-06-03 04:06:18 +0700214 log("No Dchan handler for ra=", ra, " and fn=", fn);
Harald Welte714ded92017-12-08 14:00:22 +0100215 return -1;
216}
217
Pau Espin Pedrol6451b042018-10-24 20:36:16 +0200218/* Matches by only RA if FN is ommited in one of the connections allocated */
219private function f_cid_by_ra_fn2(OCT1 ra, RSL_IE_FrameNumber fn)
220runs on RSL_Emulation_CT return integer {
221 var integer i;
222 for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
223 if (ispresent(ConnectionTable[i].ra) and
224 ConnectionTable[i].ra == ra) {
225 if (not ispresent(ConnectionTable[i].ra_fn) or
226 fn == valueof(ts_RSL_IE_FrameNumber(ConnectionTable[i].ra_fn))) {
227 return i;
228 }
229 }
230 }
Vadim Yanitskiyf79d9362020-06-03 04:06:18 +0700231 log("No Dchan handler for ra=", ra, " and fn=", fn);
Pau Espin Pedrol6451b042018-10-24 20:36:16 +0200232 return -1;
233}
234
Harald Welte714ded92017-12-08 14:00:22 +0100235/* create an ew client with given RA and FN */
Pau Espin Pedrol6451b042018-10-24 20:36:16 +0200236private function f_cid_create(OCT1 ra, template (omit) GsmFrameNumber fn, RSL_DchanHdlr comp_ref)
Harald Welte930d0a72018-03-22 22:08:40 +0100237runs on RSL_Emulation_CT {
Harald Welte714ded92017-12-08 14:00:22 +0100238 var integer i;
239 for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
Harald Weltef70df652018-01-29 22:00:23 +0100240 if (not ispresent(ConnectionTable[i].ra) and
241 not ispresent(ConnectionTable[i].trx_nr)) {
Harald Welte714ded92017-12-08 14:00:22 +0100242 ConnectionTable[i].ra := ra;
Pau Espin Pedrol6451b042018-10-24 20:36:16 +0200243 if (ispresent(fn)) {
244 ConnectionTable[i].ra_fn := valueof(fn);
245 } else {
246 ConnectionTable[i].ra_fn := omit;
247 }
Harald Welte714ded92017-12-08 14:00:22 +0100248 ConnectionTable[i].comp_ref := comp_ref;
Harald Welte930d0a72018-03-22 22:08:40 +0100249 return;
Harald Welte714ded92017-12-08 14:00:22 +0100250 }
251 }
Daniel Willmann8273fb92018-07-05 17:31:20 +0200252 testcase.stop("No free entry in conn table for ", ra, fn);
Harald Welte714ded92017-12-08 14:00:22 +0100253}
254
Vadim Yanitskiyefc94132020-05-24 04:26:45 +0700255/* create a new client with given RA and FN */
Harald Weltef70df652018-01-29 22:00:23 +0100256private function f_cid_create_cnr(uint8_t trx_nr, RslChannelNr chan_nr, RSL_DchanHdlr comp_ref)
Harald Welte930d0a72018-03-22 22:08:40 +0100257runs on RSL_Emulation_CT {
Harald Weltef70df652018-01-29 22:00:23 +0100258 var integer i;
259 for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
260 if (not ispresent(ConnectionTable[i].ra) and
261 not ispresent(ConnectionTable[i].trx_nr)) {
262 ConnectionTable[i].stream_id := f_streamId_by_trx(trx_nr);
263 ConnectionTable[i].trx_nr := trx_nr;
264 ConnectionTable[i].chan_nr := chan_nr;
265 ConnectionTable[i].comp_ref := comp_ref;
Harald Welte930d0a72018-03-22 22:08:40 +0100266 return;
Harald Weltef70df652018-01-29 22:00:23 +0100267 }
268 }
Daniel Willmann8273fb92018-07-05 17:31:20 +0200269 testcase.stop("No free entry in conn table for ", trx_nr, chan_nr, comp_ref);
Harald Weltef70df652018-01-29 22:00:23 +0100270}
271
272
Vadim Yanitskiyefc94132020-05-24 04:26:45 +0700273/* delete client with given RA and FN */
Harald Weltef70df652018-01-29 22:00:23 +0100274private function f_cid_delete_cnr(IpaStreamId stream_id, RslChannelNr chan_nr, RSL_DchanHdlr comp_ref)
275runs on RSL_Emulation_CT return integer {
276 var integer i;
277 for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
278 if (ConnectionTable[i].comp_ref == null) {
279 continue;
280 }
281 if (ConnectionTable[i].stream_id == stream_id and
282 ConnectionTable[i].chan_nr == chan_nr and
283 ConnectionTable[i].comp_ref == comp_ref) {
284 f_cid_clear(i);
285 }
286 }
287 log("Unable to find entry to delete for ", stream_id, chan_nr, comp_ref);
288 return -1;
289}
290
291
Harald Welte714ded92017-12-08 14:00:22 +0100292private function f_cid_clear(integer cid)
293runs on RSL_Emulation_CT {
294 ConnectionTable[cid].ra := omit;
295 ConnectionTable[cid].ra_fn := omit;
Harald Welte714ded92017-12-08 14:00:22 +0100296 ConnectionTable[cid].trx_nr := omit;
297 ConnectionTable[cid].stream_id := omit;
298 ConnectionTable[cid].chan_nr := omit;
Harald Weltef70df652018-01-29 22:00:23 +0100299 ConnectionTable[cid].comp_ref := null;
Harald Welte714ded92017-12-08 14:00:22 +0100300}
301
Harald Weltead2647b2018-03-22 19:53:55 +0100302/* last activation for a given channel number */
303type record LastActData {
304 uint8_t trx_nr optional,
305 RslChannelNr chan_nr optional,
306 RSL_Message chan_act optional
307}
308
309private function f_store_last_act_data(uint8_t trx_nr, RslChannelNr chan_nr, RSL_Message chan_act)
310runs on RSL_Emulation_CT {
311 for (var integer i := 0; i < sizeof(LastActTable); i := i+1) {
312 if (not ispresent(LastActTable[i].chan_nr) or
313 (LastActTable[i].chan_nr == chan_nr and LastActTable[i].trx_nr == trx_nr)) {
314 LastActTable[i].trx_nr := trx_nr;
315 LastActTable[i].chan_nr := chan_nr;
316 LastActTable[i].chan_act := chan_act;
317 return;
318 }
319 }
Daniel Willmann8273fb92018-07-05 17:31:20 +0200320 testcase.stop("No space left in LastActTable to store chan_act for ", chan_nr);
Harald Weltead2647b2018-03-22 19:53:55 +0100321}
322
323private function f_lookup_last_act(uint8_t trx_nr, RslChannelNr chan_nr)
324runs on RSL_Emulation_CT return RSL_Message {
325 for (var integer i := 0; i < sizeof(LastActTable); i := i+1) {
326 if (ispresent(LastActTable[i].chan_nr) and LastActTable[i].chan_nr == chan_nr
327 and LastActTable[i].trx_nr == trx_nr) {
328 return LastActTable[i].chan_act;
329 }
330 }
Daniel Willmann8273fb92018-07-05 17:31:20 +0200331 testcase.stop("No LastActTable entry found for TRX ", trx_nr, " ", chan_nr);
Harald Weltead2647b2018-03-22 19:53:55 +0100332}
333
334private function f_last_act_table_init() runs on RSL_Emulation_CT {
335 for (var integer i := 0; i < sizeof(LastActTable); i := i+1) {
336 LastActTable[i] := { omit, omit, omit };
337 }
338}
339
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700340private function f_trx_conn_map_init()
341runs on RSL_Emulation_CT {
342 for (var integer i := 0; i < sizeof(TrxConnMap); i := i + 1) {
343 TrxConnMap[i] := -1;
344 }
345}
346
347private function f_trx_conn_map_register(integer conn_id, in IpaCcmIdResp id_resp)
348runs on RSL_Emulation_CT return IpaStreamId {
349 var template charstring unit_id_fmt := pattern "(\d+)/(\d+)/(\d+)";
350 var charstring unit_id;
351 var integer trx_nr;
352 var integer idx;
353
354 /* Check if we have room for a new connection */
355 if (TrxConnNum >= sizeof(TrxConnMap)) {
356 testcase.stop("We cannot handle more than ", sizeof(TrxConnMap), " transceivers");
357 }
358
359 /* Find IPAC_IDTAG_UNITID in the IPA IDENTITY RESPONSE */
360 idx := f_ipa_id_resp_find_ie(id_resp, IPAC_IDTAG_UNITID);
361 if (idx < 0) {
362 testcase.stop("IPA IDENTITY RESPONSE contains no unit-id");
363 }
364
365 /* Make sure that IPA unit-id is valid */
366 unit_id := oct2char(id_resp[idx].data);
367 if (not match(unit_id, unit_id_fmt)) {
368 testcase.stop("IPA unit-id has unknown/unexpected format");
369 }
370
371 /* Parse transceiver number (site/bts/trx).
372 * TODO: implement and use declaratice types. */
373 unit_id := regexp(unit_id, unit_id_fmt, 2);
374 trx_nr := str2int(unit_id);
375
376 if (trx_nr >= sizeof(TrxConnMap)) {
377 testcase.stop("Transceiver #", trx_nr, " does not fit");
378 } else if (TrxConnMap[trx_nr] != -1) {
379 testcase.stop("Transceiver #", trx_nr, " is already connected?!?");
380 }
381
382 /* Finally, store the connection ID */
383 log("Mapped TRX#", trx_nr, " to TCP/IP conn_id=", conn_id);
384 TrxConnMap[trx_nr] := conn_id;
385 TrxConnNum := TrxConnNum + 1;
386
387 return f_streamId_by_trx(trx_nr);
388}
389
Pau Espin Pedrolabcdf782020-06-23 14:29:24 +0200390private function f_trx_conn_map_unregister(integer conn_id)
391runs on RSL_Emulation_CT return IpaStreamId {
392
393 for (var integer i := 0; i < sizeof(TrxConnMap); i := i + 1) {
394 if (conn_id == TrxConnMap[i]) {
395 TrxConnMap[i] := -1;
396 TrxConnNum := TrxConnNum - 1;
397 return f_streamId_by_trx(i);
398 }
399 }
400
401 testcase.stop("Trying to unregister an unknown conn_id=", conn_id);
402}
403
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700404private function f_trx_conn_map_resolve(IpaStreamId id)
405runs on RSL_Emulation_CT return integer {
406 var integer trx_nr := f_trx_by_streamId(id);
407
408 if (TrxConnMap[trx_nr] == -1) {
409 testcase.stop("Transceiver #", trx_nr, " is not connected");
410 }
411
412 return TrxConnMap[trx_nr];
413}
414
Vadim Yanitskiye9c06352020-06-20 01:30:58 +0700415private type record of ASP_RSL_Unitdata ASP_RSL_UDList;
416
Harald Welte714ded92017-12-08 14:00:22 +0100417type component RSL_Emulation_CT {
418 /* port facing down towards IPA emulation */
419 port IPA_RSL_PT IPA_PT;
420 /* port facing up towards dedicated channel handler */
421 port RSL_DCHAN_PT CLIENT_PT;
Harald Weltef70df652018-01-29 22:00:23 +0100422 port RSLEM_PROC_PT RSL_PROC;
Harald Welte714ded92017-12-08 14:00:22 +0100423
Harald Welte1c02fd12018-02-19 19:20:47 +0100424 /* port for Common Channel / TRX Management */
425 port RSL_CCHAN_PT CCHAN_PT;
426
Harald Welte714ded92017-12-08 14:00:22 +0100427 /* state of all concurrent connections / dedicated channels */
428 var ConnectionData ConnectionTable[64];
Harald Weltead2647b2018-03-22 19:53:55 +0100429
Vadim Yanitskiye9c06352020-06-20 01:30:58 +0700430 /* RSL messages for which no handler is currently registered */
431 var ASP_RSL_UDList WaitingQueue := { };
432
Harald Weltead2647b2018-03-22 19:53:55 +0100433 /* last RSL CHAN ACT for each chan_nr */
434 var LastActData LastActTable[64];
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700435
436 /* IPA stream ID -> TCP/IP connection ID mapping for transceivers */
437 var integer TrxConnNum := 0; /* number of connected transceivers */
438 var integer TrxConnMap[4]; /* up to 4 transceivers for now */
Harald Welte714ded92017-12-08 14:00:22 +0100439}
440
441
Harald Welte714ded92017-12-08 14:00:22 +0100442private function f_trx_by_streamId(IpaStreamId id) return integer {
443 return enum2int(id);
444}
445
Harald Weltef70df652018-01-29 22:00:23 +0100446private function f_streamId_by_trx(uint8_t trx_nr) return IpaStreamId {
447 select (trx_nr) {
448 case (0) { return IPAC_PROTO_RSL_TRX0; }
449 case (1) { return IPAC_PROTO_RSL_TRX1; }
450 case (2) { return IPAC_PROTO_RSL_TRX2; }
451 case (3) { return IPAC_PROTO_RSL_TRX3; }
452 }
Daniel Willmanna6ea2ef2018-07-24 09:55:52 +0200453 setverdict(fail, "Unknown stream ID ", trx_nr);
454 mtc.stop;
Harald Weltef70df652018-01-29 22:00:23 +0100455}
456
Harald Welte714ded92017-12-08 14:00:22 +0100457
Harald Welte1c02fd12018-02-19 19:20:47 +0100458function main(boolean bts_role := true) runs on RSL_Emulation_CT {
Harald Weltebb6aed32018-02-21 12:19:18 +0100459 var ASP_IPA_Event evt;
Harald Welte714ded92017-12-08 14:00:22 +0100460 var ASP_RSL_Unitdata rx_rsl;
461 var RSL_Message rx_rsl_msg;
462 var RSLDC_ChanRqd chan_rqd;
463 var RSL_DchanHdlr vc_conn;
Harald Weltef70df652018-01-29 22:00:23 +0100464 var RslChannelNr chan_nr;
465 var uint8_t trx_nr;
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700466 var integer conn_id;
Harald Welte714ded92017-12-08 14:00:22 +0100467 var integer cid;
468 var integer i;
Harald Welte70b52c92018-02-12 20:47:31 +0100469 /* special synchronization handling during hand-over */
470 var boolean dchan_suspended := false;
Vadim Yanitskiye9c06352020-06-20 01:30:58 +0700471 /* Whether to keep RSL messages, for which no handler is found in ConnectionTable,
472 * in a queue. These messages will remain in the queue until the appropriate
473 * connection handler is registered. */
474 var boolean wait_queue_enabled := false;
Harald Welte714ded92017-12-08 14:00:22 +0100475
Daniel Willmann17f970f2018-01-17 12:03:19 +0100476 f_conn_table_init();
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700477 f_trx_conn_map_init();
Harald Weltead2647b2018-03-22 19:53:55 +0100478 f_last_act_table_init();
Daniel Willmann17f970f2018-01-17 12:03:19 +0100479
Harald Welte714ded92017-12-08 14:00:22 +0100480 while (true) {
481 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700482 [bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) {
Harald Weltebb6aed32018-02-21 12:19:18 +0100483 }
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700484 [not bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) -> value evt {
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700485 log("A new IPA/RSL connection has been established (conn_id=",
486 evt.conn_id, "), waiting for IDENTITY RESPONSE...");
487 }
488 [not bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_RESP)) -> value evt {
489 log("Got IDENTITY RESPONSE (conn_id=", evt.conn_id, "): ", evt.id_resp);
490 /* Update [ IPA stream ID -> TCP/IP connection ID ] mapping */
491 var IpaStreamId sid := f_trx_conn_map_register(evt.conn_id, evt.id_resp);
492 /* Notify the upper layers about a new connection */
493 CCHAN_PT.send(ts_RSLEm_EV(RSLEM_EV_TRX_UP, sid));
Harald Welte624f9632017-12-16 19:26:04 +0100494 }
Pau Espin Pedrolabcdf782020-06-23 14:29:24 +0200495 [bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) -> value evt {
496 log("Lost IPA connection! (conn_id=", evt.conn_id, "): ", evt.id_resp);
497 /* Notify the upper layers about lost connection */
498 var IpaStreamId sid := f_trx_conn_map_unregister(evt.conn_id);
499 CCHAN_PT.send(ts_RSLEm_EV(RSLEM_EV_TRX_DOWN, sid));
Pau Espin Pedrola07cfd92018-10-22 15:54:41 +0200500 }
Pau Espin Pedrolabcdf782020-06-23 14:29:24 +0200501 [not bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) -> value evt {
502 log("Lost IPA connection! (conn_id=", evt.conn_id, ")");
503 /* Notify the upper layers about lost connection */
504 var IpaStreamId sid := f_trx_conn_map_unregister(evt.conn_id);
505 CCHAN_PT.send(ts_RSLEm_EV(RSLEM_EV_TRX_DOWN, sid));
Pau Espin Pedrola07cfd92018-10-22 15:54:41 +0200506 }
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700507 [bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700508 IPA_PT.send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welte714ded92017-12-08 14:00:22 +0100509 }
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700510 [not bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) { }
Vadim Yanitskiya60e5cf2020-05-26 01:46:31 +0700511 [bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN, sid := ?)) -> value rx_rsl {
Harald Welte714ded92017-12-08 14:00:22 +0100512 var GsmRrMessage rr;
513 var OCT1 ra;
514 var GsmFrameNumber fn;
Harald Welte714ded92017-12-08 14:00:22 +0100515 rr := dec_GsmRrMessage(rx_rsl.rsl.ies[1].body.full_imm_ass_info.payload);
516 if (ischosen(rr.payload.imm_ass)) {
517 ra := bit2oct(rr.payload.imm_ass.req_ref.ra);
518 fn := 23; //FIXME(rr.payload.imm_ass);
519 /* lookup client based on RA+time, deliver to client */
520 cid := f_cid_by_ra_fn(ra, fn);
521 if (cid == -1) {
522 setverdict(fail, "IMM ASS for unknown DChan");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200523 mtc.stop;
Harald Welte714ded92017-12-08 14:00:22 +0100524 }
525 /* update client with trx_nr */
526 ConnectionTable[cid].trx_nr := f_trx_by_streamId(rx_rsl.streamId);
527 ConnectionTable[cid].stream_id := rx_rsl.streamId;
528 /* update client with chan_nr */
529 ConnectionTable[cid].chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
530 /* TODO: add timer to time-out ConnectionTable entries which
531 * never get followed-up to */
532 CLIENT_PT.send(rx_rsl.rsl) to ConnectionTable[cid].comp_ref;
533 } else if (ischosen(rr.payload.imm_ass_rej)) {
534 for (i := 0; i < sizeof(rr.payload.imm_ass_rej.payload); i := i + 1) {
535 ra := bit2oct(rr.payload.imm_ass_rej.payload[i].req_ref.ra);
536 fn := 23; //FIXME();
537 /* lookup client based on RA+time, deliver to client */
538 cid := f_cid_by_ra_fn(ra, fn);
539 if (cid != -1) {
540 CLIENT_PT.send(rx_rsl.rsl) to ConnectionTable[cid].comp_ref;
541 /* delete ClientTable entry, as it failed */
542 f_cid_clear(cid);
543 }
544 }
545 }
546 }
Vadim Yanitskiya60e5cf2020-05-26 01:46:31 +0700547 [not bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?), sid := ?)) -> value rx_rsl {
Pau Espin Pedrol6451b042018-10-24 20:36:16 +0200548 var RSL_IE_RequestRef req_ref;
549 req_ref := rx_rsl.rsl.ies[1].body.req_ref;
550 cid := f_cid_by_ra_fn2(req_ref.ra, req_ref.frame_nr);
551 if (cid != -1) {
552 CLIENT_PT.send(rx_rsl.rsl) to ConnectionTable[cid].comp_ref;
553 f_cid_clear(cid);
554 } else {
555 CCHAN_PT.send(rx_rsl);
556 }
557 }
Harald Welte714ded92017-12-08 14:00:22 +0100558
Vadim Yanitskiya60e5cf2020-05-26 01:46:31 +0700559 [bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?, ?), sid := ?)) -> value rx_rsl {
Harald Welte714ded92017-12-08 14:00:22 +0100560 /* broadcast to all clients? */
561 for (i := 0; i < sizeof(ConnectionTable); i := i + 1) {
Neels Hofmeyrd7eabd62020-06-08 22:30:54 +0200562 if (ispresent(ConnectionTable[i].comp_ref) and ConnectionTable[i].comp_ref != null) {
Harald Welte714ded92017-12-08 14:00:22 +0100563 CLIENT_PT.send(rx_rsl.rsl) to ConnectionTable[i].comp_ref;
564 }
565 }
566 }
567
Harald Welte1c02fd12018-02-19 19:20:47 +0100568 /* Forward common channel management to the special port for it */
Vadim Yanitskiya60e5cf2020-05-26 01:46:31 +0700569 [] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeT(?), sid := ?)) -> value rx_rsl {
Harald Welte1c02fd12018-02-19 19:20:47 +0100570 CCHAN_PT.send(rx_rsl);
Harald Welte714ded92017-12-08 14:00:22 +0100571 }
572
Harald Welte1c02fd12018-02-19 19:20:47 +0100573 /* Forward common channel management to the special port for it */
Vadim Yanitskiya60e5cf2020-05-26 01:46:31 +0700574 [] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeC(?), sid := ?)) -> value rx_rsl {
Harald Welte1c02fd12018-02-19 19:20:47 +0100575 CCHAN_PT.send(rx_rsl);
Harald Welte714ded92017-12-08 14:00:22 +0100576 }
577
578 /* blindly acknowledge all channel activations */
Vadim Yanitskiya60e5cf2020-05-26 01:46:31 +0700579 [bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV), sid := ?)) -> value rx_rsl {
Harald Weltef70df652018-01-29 22:00:23 +0100580 chan_nr := rx_rsl.rsl.ies[0].body.chan_nr;
Harald Weltead2647b2018-03-22 19:53:55 +0100581 trx_nr := f_trx_by_streamId(rx_rsl.streamId);
582 f_store_last_act_data(trx_nr, chan_nr, rx_rsl.rsl);
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700583 IPA_PT.send(ts_ASP_RSL_UD(ts_RSL_CHAN_ACT_ACK(chan_nr, 23), rx_rsl.streamId));
Harald Welte714ded92017-12-08 14:00:22 +0100584 }
585
Vadim Yanitskiya60e5cf2020-05-26 01:46:31 +0700586 [not dchan_suspended] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeDR(?), sid := ?)) -> value rx_rsl {
Harald Welte714ded92017-12-08 14:00:22 +0100587 /* dispatch to channel based on ChanId */
588 cid := f_cid_by_chan_nr(f_trx_by_streamId(rx_rsl.streamId),
589 rx_rsl.rsl.ies[0].body.chan_nr);
590 if (cid != -1) {
591 CLIENT_PT.send(rx_rsl.rsl) to ConnectionTable[cid].comp_ref;
Vadim Yanitskiye9c06352020-06-20 01:30:58 +0700592 } else if (wait_queue_enabled) {
593 log("Storing an RSL message in the waiting queue");
594 WaitingQueue := WaitingQueue & { rx_rsl };
Harald Welte714ded92017-12-08 14:00:22 +0100595 } else {
596 setverdict(fail, "RSL for unknown Dchan");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200597 mtc.stop;
Harald Welte714ded92017-12-08 14:00:22 +0100598 }
599 }
600
Harald Welte70b52c92018-02-12 20:47:31 +0100601 [not dchan_suspended] IPA_PT.receive {
Harald Welte714ded92017-12-08 14:00:22 +0100602 setverdict(fail, "Received unknown primitive from IPA");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200603 mtc.stop;
Harald Welte714ded92017-12-08 14:00:22 +0100604 }
605
Harald Welte1c02fd12018-02-19 19:20:47 +0100606 [bts_role] CLIENT_PT.receive(RSLDC_ChanRqd:?) -> value chan_rqd sender vc_conn {
Harald Welte714ded92017-12-08 14:00:22 +0100607 /* Store the knowledge that this sender has requested a certain RQ+time */
608 f_cid_create(chan_rqd.ra, chan_rqd.fn, vc_conn);
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700609 IPA_PT.send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD(chan_rqd.ra, chan_rqd.fn)));
Harald Welte714ded92017-12-08 14:00:22 +0100610 }
611
Pau Espin Pedrol6451b042018-10-24 20:36:16 +0200612 [not bts_role] CLIENT_PT.receive(RSLDC_ChanRqd:?) -> value chan_rqd sender vc_conn {
613 /* Store the knowledge that this sender has requested a certain RQ+time */
614 f_cid_create(chan_rqd.ra, chan_rqd.fn, vc_conn);
615 }
616
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700617 /* RSL message from a component that runs on RSL_DchanHdlr */
618 [bts_role] CLIENT_PT.receive(tr_RSL_MsgType(?)) -> value rx_rsl_msg sender vc_conn {
Harald Welte714ded92017-12-08 14:00:22 +0100619 cid := f_cid_by_comp_ref(vc_conn);
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700620 IPA_PT.send(ts_ASP_RSL_UD(rx_rsl_msg, ConnectionTable[cid].stream_id));
Harald Welte714ded92017-12-08 14:00:22 +0100621 }
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700622 [not bts_role] CLIENT_PT.receive(tr_RSL_MsgType(?)) -> value rx_rsl_msg sender vc_conn {
623 cid := f_cid_by_comp_ref(vc_conn);
624 conn_id := f_trx_conn_map_resolve(ConnectionTable[cid].stream_id);
625 IPA_PT.send(ts_ASP_RSL_UD(rx_rsl_msg, ConnectionTable[cid].stream_id, conn_id));
626 }
Harald Welte714ded92017-12-08 14:00:22 +0100627
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700628 /* RSL message from MTC */
629 [bts_role] CCHAN_PT.receive(tr_ASP_RSL_UD(?, sid := ?)) -> value rx_rsl {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700630 IPA_PT.send(ts_ASP_RSL_UD(rx_rsl.rsl, rx_rsl.streamId));
Harald Welte34252c52018-02-24 04:51:50 +0100631 }
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700632 [not bts_role] CCHAN_PT.receive(tr_ASP_RSL_UD(?, sid := ?)) -> value rx_rsl {
633 conn_id := f_trx_conn_map_resolve(rx_rsl.streamId);
634 IPA_PT.send(ts_ASP_RSL_UD(rx_rsl.rsl, rx_rsl.streamId, conn_id));
635 }
Harald Welte34252c52018-02-24 04:51:50 +0100636
Harald Weltef70df652018-01-29 22:00:23 +0100637 /* explicit registration, e.g. in (non-immediate) assignment case */
638 [] RSL_PROC.getcall(RSLEM_register:{?,?,?}) -> param(trx_nr, chan_nr, vc_conn) {
639 f_cid_create_cnr(trx_nr, chan_nr, vc_conn);
Harald Weltee32ad992018-05-31 22:17:46 +0200640 RSL_PROC.reply(RSLEM_register:{trx_nr, chan_nr, vc_conn}) to vc_conn;
Harald Weltef70df652018-01-29 22:00:23 +0100641 }
642
Harald Welte1909f462018-01-29 22:29:29 +0100643 [] RSL_PROC.getcall(RSLEM_unregister:{?,?,?}) -> param(trx_nr, chan_nr, vc_conn) {
644 cid := f_cid_by_chan_nr(trx_nr, chan_nr);
645 f_cid_clear(cid);
Harald Weltee32ad992018-05-31 22:17:46 +0200646 RSL_PROC.reply(RSLEM_unregister:{trx_nr, chan_nr, vc_conn}) to vc_conn;
Harald Welte1909f462018-01-29 22:29:29 +0100647 }
648
Harald Weltee32ad992018-05-31 22:17:46 +0200649 [] RSL_PROC.getcall(RSLEM_suspend:{true}) -> sender vc_conn {
Harald Welte70b52c92018-02-12 20:47:31 +0100650 log("Suspending DChan");
651 dchan_suspended := true;
Harald Weltee32ad992018-05-31 22:17:46 +0200652 RSL_PROC.reply(RSLEM_suspend:{true}) to vc_conn;
Harald Welte70b52c92018-02-12 20:47:31 +0100653 }
654
Harald Weltee32ad992018-05-31 22:17:46 +0200655 [] RSL_PROC.getcall(RSLEM_suspend:{false}) -> sender vc_conn {
Harald Welte70b52c92018-02-12 20:47:31 +0100656 log("Resuming DChan");
657 dchan_suspended := false;
Harald Weltee32ad992018-05-31 22:17:46 +0200658 RSL_PROC.reply(RSLEM_suspend:{false}) to vc_conn;
Harald Welte70b52c92018-02-12 20:47:31 +0100659 }
Harald Welte1909f462018-01-29 22:29:29 +0100660
Vadim Yanitskiye9c06352020-06-20 01:30:58 +0700661 [not wait_queue_enabled] RSL_PROC.getcall(RSLEM_wait_queue:{true}) -> sender vc_conn {
662 wait_queue_enabled := true;
663 log("Enabled queueing of DChan messages");
664 RSL_PROC.reply(RSLEM_wait_queue:{wait_queue_enabled}) to vc_conn;
665 }
666
667 [wait_queue_enabled] RSL_PROC.getcall(RSLEM_wait_queue:{false}) -> sender vc_conn {
668 /* Dispatch stalled messages (if any) */
669 f_WaitingQueue_dispatch();
670
671 wait_queue_enabled := false;
672 log("Disabled queueing of DChan messages");
673 RSL_PROC.reply(RSLEM_wait_queue:{wait_queue_enabled}) to vc_conn;
674 }
675
676 [] RSL_PROC.getcall(RSLEM_wait_queue:{?}) -> sender vc_conn {
677 log("Queueing of DChan messages is already enabled/disabled");
678 RSL_PROC.reply(RSLEM_wait_queue:{wait_queue_enabled}) to vc_conn;
679 }
680
Harald Weltee32ad992018-05-31 22:17:46 +0200681 [] RSL_PROC.getcall(RSLEM_get_last_act:{?,?,?}) -> param(trx_nr, chan_nr) sender vc_conn {
Harald Weltead2647b2018-03-22 19:53:55 +0100682 var RSL_Message last_chan_act := f_lookup_last_act(trx_nr, chan_nr);
Harald Weltee32ad992018-05-31 22:17:46 +0200683 RSL_PROC.reply(RSLEM_get_last_act:{trx_nr, chan_nr, last_chan_act}) to vc_conn;
Harald Weltead2647b2018-03-22 19:53:55 +0100684 }
Harald Welte714ded92017-12-08 14:00:22 +0100685 }
686 }
687}
688
Daniel Willmann17f970f2018-01-17 12:03:19 +0100689private function f_conn_table_init()
690runs on RSL_Emulation_CT {
691 var integer i;
692
693 /* Initialize the ConnectionTable */
694 for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
695 f_cid_clear(i);
696 }
697}
Harald Welte714ded92017-12-08 14:00:22 +0100698
Vadim Yanitskiye9c06352020-06-20 01:30:58 +0700699private function f_WaitingQueue_dispatch()
700runs on RSL_Emulation_CT {
701 var integer cid;
702
703 for (var integer i := 0; i < lengthof(WaitingQueue); i := i + 1) {
704 cid := f_cid_by_chan_nr(f_trx_by_streamId(WaitingQueue[i].streamId),
705 WaitingQueue[i].rsl.ies[0].body.chan_nr);
706 if (cid == -1) {
707 setverdict(fail, "No Dchan handler found for: ", WaitingQueue[i]);
708 mtc.stop;
Vadim Yanitskiye9c06352020-06-20 01:30:58 +0700709 }
710
711 /* Dispatch a stalled message to the appropriate handler */
712 CLIENT_PT.send(WaitingQueue[i].rsl) to ConnectionTable[cid].comp_ref;
713 }
714
715 /* All messages dispatched, clear the queue */
716 WaitingQueue := { };
717}
718
Harald Weltef70df652018-01-29 22:00:23 +0100719/* client/conn_hdlr side function to use procedure port to register stream_id/chan_nr */
Harald Welte421e4d42018-02-12 20:04:50 +0100720function f_rslem_register(uint8_t trx_nr, RslChannelNr chan_nr, RSLEM_PROC_PT PT := RSL_PROC)
721runs on RSL_DchanHdlr {
722 PT.call(RSLEM_register:{trx_nr, chan_nr, self}) {
723 [] PT.getreply(RSLEM_register:{?,?,?}) {};
Harald Weltef70df652018-01-29 22:00:23 +0100724 }
725}
726
Harald Welte1909f462018-01-29 22:29:29 +0100727/* client/conn_hdlr side function to use procedure port to unregister stream_id/chan_nr */
Harald Welte421e4d42018-02-12 20:04:50 +0100728function f_rslem_unregister(uint8_t trx_nr, RslChannelNr chan_nr, RSLEM_PROC_PT PT := RSL_PROC)
729runs on RSL_DchanHdlr {
730 PT.call(RSLEM_unregister:{trx_nr, chan_nr, self}) {
731 [] PT.getreply(RSLEM_unregister:{?,?,?}) {};
Harald Welte1909f462018-01-29 22:29:29 +0100732 }
733}
734
Vadim Yanitskiya38c2652020-06-21 19:47:00 +0700735/* suspend handling of RSL DChan messages from IPA until f_rslem_resume() is called */
Harald Welte70b52c92018-02-12 20:47:31 +0100736function f_rslem_suspend(RSLEM_PROC_PT PT)
737runs on RSL_DchanHdlr {
738 PT.call(RSLEM_suspend:{true}) {
739 [] PT.getreply(RSLEM_suspend:{true}) {};
740 }
741}
742
743/* resume handling of RSL DChan messages after f_rslem_suspend() is called */
744function f_rslem_resume(RSLEM_PROC_PT PT)
745runs on RSL_DchanHdlr {
746 PT.call(RSLEM_suspend:{false}) {
747 [] PT.getreply(RSLEM_suspend:{false}) {};
748 }
749}
750
Vadim Yanitskiye9c06352020-06-20 01:30:58 +0700751/* Enable queueing of RSL DChan messages from IPA until f_rslem_dchan_queue_disable() is called. */
752function f_rslem_dchan_queue_enable(RSLEM_PROC_PT PT := RSL_PROC)
753runs on RSL_DchanHdlr {
754 PT.call(RSLEM_wait_queue:{true}) {
755 [] PT.getreply(RSLEM_wait_queue:{true}) {};
756 }
757}
758
759/* Disable queueing of RSL DChan messages after f_rslem_dchan_queue_enable() is called.
760 * Dispatch all stalled messages to the registered handlers. Make sure that no
761 * messages for which there is no handler are left in the queue (mtc.stop if so). */
762function f_rslem_dchan_queue_dispatch(RSLEM_PROC_PT PT := RSL_PROC)
763runs on RSL_DchanHdlr {
764 PT.call(RSLEM_wait_queue:{false}) {
765 [] PT.getreply(RSLEM_wait_queue:{false}) {};
766 }
767}
768
Harald Weltead2647b2018-03-22 19:53:55 +0100769/* obtain the last RSL_CHAN_ACT message for the given chan_nr */
770function f_rslem_get_last_act(RSLEM_PROC_PT PT, uint8_t trx_nr, RslChannelNr chan_nr)
771runs on RSL_DchanHdlr return RSL_Message {
772 var RSL_Message chan_act;
773 PT.call(RSLEM_get_last_act:{trx_nr, chan_nr, -}) {
774 [] PT.getreply(RSLEM_get_last_act:{trx_nr, chan_nr, ?}) -> param(chan_act) {};
775 }
776 return chan_act;
777}
778
779
Harald Welte70b52c92018-02-12 20:47:31 +0100780
Harald Welte1909f462018-01-29 22:29:29 +0100781
Harald Welte714ded92017-12-08 14:00:22 +0100782}