blob: 2305b7b29373c5475203c03384e7f5e5f1179cd6 [file] [log] [blame]
Harald Welted86cdc62017-11-22 00:45:07 +01001module IPA_Emulation {
2
Harald Weltebdb63702017-12-09 01:15:44 +01003/* This module implements the IPA multiplex protocol on top of TCP, using the IPL4asp
4 * test-port as provider. It implements both client and server roles, as well was the CCM
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005 * handshake for establishing the identity of the client to the server.
Harald Welte35bb7162018-01-03 21:07:52 +01006 *
7 * It already knows certain well-known sub-protocols such as A-bis RSL, MGCP and SCCP and
8 * GSUP. IT hence transcodes messages so the user can work with abstract data types rather
9 * than binary messages. It handles multiple packets inside one TCP segment.
10 *
Harald Welte34b5a952019-05-27 11:54:11 +020011 * (C) 2017-2019 by Harald Welte <laforge@gnumonks.org>
12 * contributions by sysmocom - s.f.m.c. GmbH
Harald Welte35bb7162018-01-03 21:07:52 +010013 * All rights reserved.
14 *
15 * Released under the terms of GNU General Public License, Version 2 or
16 * (at your option) any later version.
Harald Welte34b5a952019-05-27 11:54:11 +020017 *
18 * SPDX-License-Identifier: GPL-2.0-or-later
Harald Welte35bb7162018-01-03 21:07:52 +010019 */
Harald Weltebdb63702017-12-09 01:15:44 +010020
Harald Welted86cdc62017-11-22 00:45:07 +010021import from IPA_Types all;
22import from IPA_CodecPort all;
23import from IPA_CodecPort_CtrlFunct all;
24import from IPL4asp_Types all;
Harald Welte12188832017-11-29 11:47:13 +010025import from IPL4asp_PortType all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010026import from Socket_API_Definitions all;
Harald Welted86cdc62017-11-22 00:45:07 +010027
Harald Weltedf277252018-02-20 15:49:30 +010028#ifdef IPA_EMULATION_SCCP
29import from MTP3asp_Types all;
30import from MTP3asp_PortType all;
31#endif
32
33#ifdef IPA_EMULATION_RSL
34import from RSL_Types all;
35#endif
36
Harald Weltec6826662019-02-06 22:26:46 +010037#ifdef IPA_EMULATION_OML
38import from AbisOML_Types all;
39#endif
40
Harald Weltedf277252018-02-20 15:49:30 +010041#ifdef IPA_EMULATION_MGCP
Harald Weltec82eef42017-11-24 20:40:12 +010042import from MGCP_Types all;
Harald Weltedf277252018-02-20 15:49:30 +010043#endif
44
45#ifdef IPA_EMULATION_GSUP
Harald Weltedf327232017-12-28 22:51:51 +010046import from GSUP_Types all;
Harald Weltedf277252018-02-20 15:49:30 +010047#endif
Harald Weltec82eef42017-11-24 20:40:12 +010048
Harald Welte7460a722018-10-10 12:28:27 +020049#ifdef IPA_EMULATION_RSPRO
50import from RSPRO all;
51import from RSPRO_Types all;
52#endif
53
54
Harald Weltea76c4bb2017-12-09 02:06:07 +010055import from Osmocom_CTRL_Types all;
56
Harald Welted86cdc62017-11-22 00:45:07 +010057modulepar {
Harald Welte92632e12017-11-25 02:31:20 +010058 /* Use Osmocom extended IPA mux header */
59 boolean mp_ipa_mgcp_uses_osmo_ext := true;
Harald Welted86cdc62017-11-22 00:45:07 +010060}
Harald Welted86cdc62017-11-22 00:45:07 +010061
Harald Welteb3414b22017-11-23 18:22:10 +010062type enumerated IpaMode {
63 IPA_MODE_CLIENT,
64 IPA_MODE_SERVER
65}
66
Neels Hofmeyr3bf31d22018-08-24 14:44:32 +020067type enumerated IpaInitBehavior {
68 IPA_INIT_SEND_IPA_ID_GET,
69 IPA_INIT_SEND_IPA_ID_ACK
70}
71
Harald Weltec76f29f2017-11-22 12:46:46 +010072type record ASP_IPA_Unitdata {
73 IpaStreamId streamId,
Harald Weltec82eef42017-11-24 20:40:12 +010074 IpaExtStreamId streamIdExt optional,
Harald Weltec76f29f2017-11-22 12:46:46 +010075 octetstring payload
76}
77
Harald Welte0d846a72017-12-07 17:58:28 +010078type enumerated ASP_IPA_EventUpDown {
79 ASP_IPA_EVENT_DOWN,
80 ASP_IPA_EVENT_UP,
81 ASP_IPA_EVENT_ID_ACK
82}
83
Harald Weltebdb63702017-12-09 01:15:44 +010084/* an event indicating us whether or not a connection is physically up or down,
85 * and whether we have received an ID_ACK */
Harald Welte0d846a72017-12-07 17:58:28 +010086type union ASP_IPA_Event {
87 ASP_IPA_EventUpDown up_down
88}
89
90template ASP_IPA_Event t_ASP_IPA_EVT_UD(ASP_IPA_EventUpDown ud) := {
91 up_down := ud
92}
93
Harald Welte1dd8f372017-11-25 02:25:27 +010094template ASP_IPA_Unitdata t_ASP_IPA_UD(IpaStreamId sid, octetstring pl,
95 template IpaExtStreamId esid := omit) := {
96 streamId := sid,
97 streamIdExt := esid,
98 payload := pl
99}
100
Harald Weltedf277252018-02-20 15:49:30 +0100101#ifdef IPA_EMULATION_RSL
Harald Weltebdb63702017-12-09 01:15:44 +0100102/* like ASP_IPA_Unitdata, but with RSL_Message abstract type instead of octetstring */
Harald Welte0d846a72017-12-07 17:58:28 +0100103type record ASP_RSL_Unitdata {
104 IpaStreamId streamId,
105 RSL_Message rsl
106};
107
Harald Welte7ae019e2017-12-09 00:54:15 +0100108template ASP_RSL_Unitdata ts_ASP_RSL_UD(IpaStreamId sid, template RSL_Message rsl) := {
Harald Welte0d846a72017-12-07 17:58:28 +0100109 streamId := sid,
110 rsl := valueof(rsl)
111}
112
Harald Welte7ae019e2017-12-09 00:54:15 +0100113template ASP_RSL_Unitdata tr_ASP_RSL_UD(IpaStreamId sid, template RSL_Message rsl) := {
114 streamId := sid,
115 rsl := rsl
116}
117
Harald Welte0d846a72017-12-07 17:58:28 +0100118template IpaStreamId t_IpaSidRSL := ( IPAC_PROTO_RSL_TRX0, IPAC_PROTO_RSL_TRX1,
119 IPAC_PROTO_RSL_TRX2, IPAC_PROTO_RSL_TRX3 );
Harald Weltedf277252018-02-20 15:49:30 +0100120#endif
Harald Welte0d846a72017-12-07 17:58:28 +0100121
Harald Weltec6826662019-02-06 22:26:46 +0100122
Harald Weltebdb63702017-12-09 01:15:44 +0100123/* Client port for general IPA messages, not further decoded */
Harald Weltec76f29f2017-11-22 12:46:46 +0100124type port IPA_SP_PT message {
Harald Welte0d846a72017-12-07 17:58:28 +0100125 inout ASP_IPA_Unitdata, ASP_IPA_Event;
Harald Weltec76f29f2017-11-22 12:46:46 +0100126} with { extension "internal" }
127
Harald Weltedf277252018-02-20 15:49:30 +0100128#ifdef IPA_EMULATION_MGCP
Harald Weltebdb63702017-12-09 01:15:44 +0100129/* Client port for MGCP inside IPA */
Harald Weltec82eef42017-11-24 20:40:12 +0100130type port IPA_MGCP_PT message {
131 inout MgcpCommand, MgcpResponse;
132} with { extension "internal" }
Harald Weltedf277252018-02-20 15:49:30 +0100133#endif
Harald Weltec82eef42017-11-24 20:40:12 +0100134
Harald Weltedf277252018-02-20 15:49:30 +0100135#ifdef IPA_EMULATION_RSL
Harald Weltebdb63702017-12-09 01:15:44 +0100136/* Client port for A-bis RSL inside IPA */
Harald Welte0d846a72017-12-07 17:58:28 +0100137type port IPA_RSL_PT message {
138 inout ASP_RSL_Unitdata, ASP_IPA_Event;
139} with { extension "internal" }
Harald Weltedf277252018-02-20 15:49:30 +0100140#endif
Harald Welte0d846a72017-12-07 17:58:28 +0100141
Harald Weltec6826662019-02-06 22:26:46 +0100142#ifdef IPA_EMULATION_OML
143/* Client port for A-bis OML inside IPA */
144type port IPA_OML_PT message {
145 inout OML_PDU, octetstring, ASP_IPA_Event;
146} with { extension "internal" }
147#endif
148
Harald Weltea76c4bb2017-12-09 02:06:07 +0100149/* Client port for CTRL inside IPA */
150type port IPA_CTRL_PT message {
151 inout CtrlMessage, ASP_IPA_Event;
152} with { extension "internal" }
153
Harald Weltedf277252018-02-20 15:49:30 +0100154#ifdef IPA_EMULATION_GSUP
Harald Weltedf327232017-12-28 22:51:51 +0100155/* Client port for CTRL inside IPA */
156type port IPA_GSUP_PT message {
157 inout GSUP_PDU, ASP_IPA_Event;
158} with { extension "internal" }
Harald Weltedf277252018-02-20 15:49:30 +0100159#endif
Harald Weltedf327232017-12-28 22:51:51 +0100160
Harald Welte7460a722018-10-10 12:28:27 +0200161#ifdef IPA_EMULATION_RSPRO
162type port IPA_RSPRO_PT message {
163 inout RsproPDU, ASP_IPA_Event;
164} with { extension "internal" }
165#endif
166
167
168
Harald Weltedf327232017-12-28 22:51:51 +0100169
Harald Welted86cdc62017-11-22 00:45:07 +0100170type component IPA_Emulation_CT {
171 /* down-facing port to IPA codec port */
172 port IPA_CODEC_PT IPA_PORT;
Harald Weltedf277252018-02-20 15:49:30 +0100173#ifdef IPA_EMULATION_SCCP
Harald Welted86cdc62017-11-22 00:45:07 +0100174 /* up-facing port to SCCP */
175 port MTP3asp_SP_PT MTP3_SP_PORT;
Harald Weltedf277252018-02-20 15:49:30 +0100176#endif
177#ifdef IPA_EMULATION_MGCP
Harald Weltec82eef42017-11-24 20:40:12 +0100178 /* up-facing port for MGCP */
179 port IPA_MGCP_PT IPA_MGCP_PORT;
Harald Weltedf277252018-02-20 15:49:30 +0100180#endif
181#ifdef IPA_EMULATION_RSL
Harald Welte0d846a72017-12-07 17:58:28 +0100182 /* up-facing port for RSL */
183 port IPA_RSL_PT IPA_RSL_PORT;
Harald Weltedf277252018-02-20 15:49:30 +0100184#endif
Harald Weltec6826662019-02-06 22:26:46 +0100185#ifdef IPA_EMULATION_OML
186 /* up-facing port for OML */
187 port IPA_OML_PT IPA_OML_PORT;
188#endif
Pau Espin Pedrolacc51192019-06-11 15:35:19 +0200189#ifdef IPA_EMULATION_CTRL
Harald Weltea76c4bb2017-12-09 02:06:07 +0100190 /* up-facing port for CTRL */
191 port IPA_CTRL_PT IPA_CTRL_PORT;
Pau Espin Pedrolacc51192019-06-11 15:35:19 +0200192#endif
Harald Weltedf277252018-02-20 15:49:30 +0100193#ifdef IPA_EMULATION_GSUP
Harald Weltedf327232017-12-28 22:51:51 +0100194 /* up-facing port for GSUP */
195 port IPA_GSUP_PT IPA_GSUP_PORT;
Harald Weltedf277252018-02-20 15:49:30 +0100196#endif
Harald Welte7460a722018-10-10 12:28:27 +0200197#ifdef IPA_EMULATION_RSPRO
198 /* up-facing port for RSPRO */
199 port IPA_RSPRO_PT IPA_RSPRO_PORT;
200#endif
Harald Weltedf327232017-12-28 22:51:51 +0100201
Harald Weltec76f29f2017-11-22 12:46:46 +0100202 /* up-facing port for other streams */
203 port IPA_SP_PT IPA_SP_PORT;
Harald Welted86cdc62017-11-22 00:45:07 +0100204
205 var boolean g_initialized := false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100206 var IPL4asp_Types.ConnectionId g_ipa_conn_id := -1;
Harald Weltec82eef42017-11-24 20:40:12 +0100207 /* Are we a BSC/MGW (truel) or MSC (false) */
208 var boolean g_is_bsc_mgw;
Harald Welteb3414b22017-11-23 18:22:10 +0100209
210 var IpaMode g_mode;
Harald Welte2d86aff2018-04-17 11:23:04 +0200211 var boolean g_ccm_enabled;
Neels Hofmeyr3bf31d22018-08-24 14:44:32 +0200212 var IpaInitBehavior g_init_behavior;
Harald Weltee09921f2017-12-07 17:49:00 +0100213 var IPA_CCM_Parameters g_ccm_pars := c_IPA_default_ccm_pars;
Harald Welted86cdc62017-11-22 00:45:07 +0100214}
215
Harald Weltee21096d2017-12-04 20:45:12 +0100216type record IPA_CCM_Parameters {
217 charstring ser_nr optional,
218 charstring name optional,
219 charstring location1 optional,
220 charstring location2 optional,
221 charstring equip_version optional,
222 charstring sw_version optional,
223 charstring ip_addr optional,
224 charstring mac_addr optional,
225 charstring unit_id optional,
226 charstring osmo_rand optional
227}
228
Harald Weltee09921f2017-12-07 17:49:00 +0100229const IPA_CCM_Parameters c_IPA_default_ccm_pars := {
230 ser_nr := "",
Harald Weltee21096d2017-12-04 20:45:12 +0100231 name := "mahlzeit",
Harald Weltee09921f2017-12-07 17:49:00 +0100232 location1 := "",
233 location2 := "",
234 equip_version := "",
235 sw_version := "",
236 ip_addr := "",
237 mac_addr := "",
Harald Weltee21096d2017-12-04 20:45:12 +0100238 unit_id := "0/1/2",
Harald Weltee09921f2017-12-07 17:49:00 +0100239 osmo_rand := ""
Harald Weltee21096d2017-12-04 20:45:12 +0100240};
241
Harald Weltebdb63702017-12-09 01:15:44 +0100242/* Function to use to connect as client to a remote IPA Server */
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100243function f_connect(charstring remote_host, IPL4asp_Types.PortNumber remote_port,
244 charstring local_host, IPL4asp_Types.PortNumber local_port,
Harald Weltee09921f2017-12-07 17:49:00 +0100245 IPA_CCM_Parameters ccm_pars := c_IPA_default_ccm_pars) runs on IPA_Emulation_CT {
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100246 var IPL4asp_Types.Result res;
Harald Welted86cdc62017-11-22 00:45:07 +0100247 res := IPA_CodecPort_CtrlFunct.f_IPL4_connect(IPA_PORT, remote_host, remote_port,
248 local_host, local_port, 0, { tcp:={} });
Harald Welte9220f632018-05-23 20:27:02 +0200249 if (not ispresent(res.connId)) {
Stefan Sperling6a90be42018-08-31 15:05:39 +0200250 setverdict(fail, "Could not connect IPA socket from ", local_host, " port ", local_port,
251 " to ", remote_host, " port ", remote_port, "; check your configuration");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200252 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +0200253 }
Harald Welted86cdc62017-11-22 00:45:07 +0100254 g_ipa_conn_id := res.connId;
Harald Weltee21096d2017-12-04 20:45:12 +0100255 g_ccm_pars := ccm_pars;
Harald Weltec82eef42017-11-24 20:40:12 +0100256 g_is_bsc_mgw := true;
Harald Welted86cdc62017-11-22 00:45:07 +0100257}
258
Harald Weltebdb63702017-12-09 01:15:44 +0100259/* Function to use to bind to a local port as IPA server, accepting remote clients */
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100260function f_bind(charstring local_host, IPL4asp_Types.PortNumber local_port,
Harald Weltee09921f2017-12-07 17:49:00 +0100261 IPA_CCM_Parameters ccm_pars := c_IPA_default_ccm_pars) runs on IPA_Emulation_CT {
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100262 var IPL4asp_Types.Result res;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +0200263 res := IPA_CodecPort_CtrlFunct.f_IPL4_listen(IPA_PORT,
Harald Welteb3414b22017-11-23 18:22:10 +0100264 local_host, local_port, { tcp:={} });
Harald Welte9220f632018-05-23 20:27:02 +0200265 if (not ispresent(res.connId)) {
Maxb7aae8b2019-03-11 15:22:02 +0100266 setverdict(fail, "Could not listen IPA socket ", local_host, ":", local_port, ", check your configuration");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200267 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +0200268 }
Harald Welteb3414b22017-11-23 18:22:10 +0100269 g_ipa_conn_id := res.connId;
Harald Weltee21096d2017-12-04 20:45:12 +0100270 g_ccm_pars := ccm_pars;
Harald Weltec82eef42017-11-24 20:40:12 +0100271 g_is_bsc_mgw := false;
Harald Welteb3414b22017-11-23 18:22:10 +0100272}
273
Harald Weltedf277252018-02-20 15:49:30 +0100274#ifdef IPA_EMULATION_SCCP
Harald Welted86cdc62017-11-22 00:45:07 +0100275template ASP_MTP3_TRANSFERind ts_MTP3_XFER_ind(integer opc, octetstring data) := {
276 sio := { '10'B, '00'B, '0011'B },
277 opc := opc,
278 dpc := 0,
279 sls := 0,
280 data := data
281}
Harald Weltedf277252018-02-20 15:49:30 +0100282#endif
Harald Welted86cdc62017-11-22 00:45:07 +0100283
284
285private template IpaCcmRespPart t_IdRespPart(IpaCcmIdTag tag, charstring payload) := {
286 len := 0, /* overwritten by codec */
287 tag := tag,
Harald Welte95686e02018-08-02 15:05:43 +0200288 data := char2oct(payload) & '00'O
Harald Welted86cdc62017-11-22 00:45:07 +0100289}
290
Harald Welte0d846a72017-12-07 17:58:28 +0100291private function f_send_IPA_EVT(template ASP_IPA_Event evt) runs on IPA_Emulation_CT {
Harald Welte2e32e432018-05-24 20:00:00 +0200292 if (IPA_SP_PORT.checkstate("Connected")) {
293 IPA_SP_PORT.send(evt);
294 }
Harald Weltedf277252018-02-20 15:49:30 +0100295#ifdef IPA_EMULATION_RSL
Harald Welte5819b552017-12-09 02:55:46 +0100296 if (IPA_RSL_PORT.checkstate("Connected")) {
297 IPA_RSL_PORT.send(evt);
298 }
Harald Weltedf277252018-02-20 15:49:30 +0100299#endif
Harald Weltec6826662019-02-06 22:26:46 +0100300#ifdef IPA_EMULATION_OML
301 if (IPA_OML_PORT.checkstate("Connected")) {
302 IPA_OML_PORT.send(evt);
303 }
304#endif
Pau Espin Pedrolacc51192019-06-11 15:35:19 +0200305#ifdef IPA_EMULATION_CTRL
Harald Welte5819b552017-12-09 02:55:46 +0100306 if (IPA_CTRL_PORT.checkstate("Connected")) {
307 IPA_CTRL_PORT.send(evt);
308 }
Pau Espin Pedrolacc51192019-06-11 15:35:19 +0200309#endif
Harald Weltedf277252018-02-20 15:49:30 +0100310#ifdef IPA_EMULATION_GSUP
Harald Weltedf327232017-12-28 22:51:51 +0100311 if (IPA_GSUP_PORT.checkstate("Connected")) {
312 IPA_GSUP_PORT.send(evt);
313 }
Harald Weltedf277252018-02-20 15:49:30 +0100314#endif
Harald Welte7460a722018-10-10 12:28:27 +0200315#ifdef IPA_EMULATION_RSPRO
316 if (IPA_RSPRO_PORT.checkstate("Connected")) {
317 IPA_RSPRO_PORT.send(evt);
318 }
319#endif
Harald Welte0d846a72017-12-07 17:58:28 +0100320 /* FIXME: to other ports */
321}
322
Harald Welted86cdc62017-11-22 00:45:07 +0100323/* build IPA CCM ID RESP response from IPA CCM GET */
Harald Weltee21096d2017-12-04 20:45:12 +0100324private function f_ccm_make_id_resp(PDU_IPA_CCM get) runs on IPA_Emulation_CT return PDU_IPA_CCM {
Harald Welted86cdc62017-11-22 00:45:07 +0100325 var integer i;
326 var PDU_IPA_CCM resp := {
327 msg_type := IPAC_MSGT_ID_RESP,
328 u := {
329 resp := {}
330 }
331 }
332
333 for (i := 0; i < sizeof(get.u.get); i := i + 1) {
334 var IpaCcmIdTag tag := get.u.get[i].tag;
335 var charstring foo;
336 select (tag) {
Harald Weltee21096d2017-12-04 20:45:12 +0100337 case (IPAC_IDTAG_SERNR) {
338 foo := g_ccm_pars.ser_nr;
Harald Welted86cdc62017-11-22 00:45:07 +0100339 }
340 case (IPAC_IDTAG_UNITNAME) {
Harald Weltee21096d2017-12-04 20:45:12 +0100341 foo := g_ccm_pars.name;
342 }
343 case (IPAC_IDTAG_LOCATION1) {
344 foo := g_ccm_pars.location1;
345 }
346 case (IPAC_IDTAG_LOCATION2) {
347 foo := g_ccm_pars.location2;
348 }
349 case (IPAC_IDTAG_EQUIPVERS) {
350 foo := g_ccm_pars.equip_version;
351 }
352 case (IPAC_IDTAG_SWVERSION) {
353 foo := g_ccm_pars.sw_version;
354 }
355 case (IPAC_IDTAG_IPADDR) {
356 foo := g_ccm_pars.ip_addr;
357 }
358 case (IPAC_IDTAG_MACADDR) {
359 foo := g_ccm_pars.mac_addr;
360 }
361 case (IPAC_IDTAG_UNIT) {
362 foo := g_ccm_pars.unit_id;
363 }
364 case (IPAC_IDTAG_OSMO_RAND) {
365 foo := g_ccm_pars.osmo_rand;
Harald Welted86cdc62017-11-22 00:45:07 +0100366 }
367 case else {
Harald Weltee21096d2017-12-04 20:45:12 +0100368 foo := "unknown";
Harald Welted86cdc62017-11-22 00:45:07 +0100369 }
370 }
371 resp.u.resp[sizeof(resp.u.resp)] := valueof(t_IdRespPart(tag, foo));
372 }
373
374 return resp;
375}
376
377/* transmit IPA CCM message */
378private function f_ccm_tx(PDU_IPA_CCM ccm) runs on IPA_Emulation_CT {
Harald Weltec82eef42017-11-24 20:40:12 +0100379 var IPA_Send ipa_tx := valueof(t_IPA_Send(g_ipa_conn_id, IPAC_PROTO_CCM, enc_PDU_IPA_CCM(ccm)));
Harald Welted86cdc62017-11-22 00:45:07 +0100380 log("CCM Tx:", ccm);
381 IPA_PORT.send(ipa_tx);
382}
383
384template PDU_IPA_CCM ts_IPA_PONG := {
385 msg_type := IPAC_MSGT_PONG,
386 u := omit
387}
388
389template PDU_IPA_CCM ts_IPA_ACK := {
390 msg_type := IPAC_MSGT_ID_ACK,
391 u := omit
392}
393
Harald Welteb3414b22017-11-23 18:22:10 +0100394template PDU_IPA_CCM ts_IPA_ID_GET := {
395 msg_type := IPAC_MSGT_ID_GET,
396 u := {
397 get := {
398 { 1, IPAC_IDTAG_UNITNAME }
399 }
400 }
401}
402
Harald Welted86cdc62017-11-22 00:45:07 +0100403/* receive IPA CCM message */
Harald Welte2d86aff2018-04-17 11:23:04 +0200404private function f_ccm_rx_client(PDU_IPA_CCM ccm) runs on IPA_Emulation_CT {
Harald Welted86cdc62017-11-22 00:45:07 +0100405 select (ccm.msg_type) {
406 case (IPAC_MSGT_PING) {
407 f_ccm_tx(valueof(ts_IPA_PONG));
408 }
409 case (IPAC_MSGT_ID_ACK) {
Harald Welte2d86aff2018-04-17 11:23:04 +0200410 f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_ID_ACK));
Harald Welted86cdc62017-11-22 00:45:07 +0100411 }
412 case (IPAC_MSGT_ID_GET) {
413 f_ccm_tx(f_ccm_make_id_resp(ccm));
414 }
Harald Welte2d86aff2018-04-17 11:23:04 +0200415 case else {
416 log("Unknown/unsupported IPA CCM message type", ccm);
417 }
418 }
419}
420
421private function f_ccm_rx_server(PDU_IPA_CCM ccm) runs on IPA_Emulation_CT {
422 select (ccm.msg_type) {
423 case (IPAC_MSGT_PING) {
424 f_ccm_tx(valueof(ts_IPA_PONG));
425 }
426 case (IPAC_MSGT_ID_ACK) {
427 /* the IPA server should at some point receive an ID_ACK from the client,
428 * in case of RSL/OML from nanoBTS, this is actually the first message after
429 * the TCP connection is established. Other implementations may differ.
430 * We currently ignore it completely - but actually we should make sure that
431 * one ID_ACK is received by the server at some point */
Harald Welte2e32e432018-05-24 20:00:00 +0200432 f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_ID_ACK));
Harald Welte2d86aff2018-04-17 11:23:04 +0200433 }
Harald Welte3bc387f2018-02-21 12:18:46 +0100434 case (IPAC_MSGT_ID_RESP) {
435 log("IPA ID RESP: ", ccm.u.resp);
Harald Welte2d86aff2018-04-17 11:23:04 +0200436 /* acknowledge any identity that the client may have sent */
437 f_ccm_tx(valueof(ts_IPA_ACK));
Harald Welte3bc387f2018-02-21 12:18:46 +0100438 }
Harald Welted86cdc62017-11-22 00:45:07 +0100439 case else {
440 log("Unknown/unsupported IPA CCM message type", ccm);
441 }
442 }
443}
444
Harald Weltec76f29f2017-11-22 12:46:46 +0100445private function f_to_asp(IPA_RecvFrom ipa_rx) return ASP_IPA_Unitdata {
446 var ASP_IPA_Unitdata ret := {
447 streamId := ipa_rx.streamId,
Harald Welte2a8f8472017-11-23 21:11:34 +0100448 streamIdExt := ipa_rx.streamIdExt,
Harald Weltec76f29f2017-11-22 12:46:46 +0100449 payload := ipa_rx.msg
450 }
451 return ret;
452}
453
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100454private function f_from_asp(IPL4asp_Types.ConnectionId connId, ASP_IPA_Unitdata ipa_tx) return IPA_Send {
Harald Weltec82eef42017-11-24 20:40:12 +0100455 var IPA_Send ret := valueof(t_IPA_Send(connId, ipa_tx.streamId, ipa_tx.payload,
456 ipa_tx.streamIdExt));
Harald Weltec76f29f2017-11-22 12:46:46 +0100457 return ret;
458}
Harald Welted86cdc62017-11-22 00:45:07 +0100459
Harald Weltedf277252018-02-20 15:49:30 +0100460#ifdef IPA_EMULATION_RSL
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100461private function f_from_rsl(IPL4asp_Types.ConnectionId connId, ASP_RSL_Unitdata rsl_tx) return IPA_Send {
Harald Welte0d846a72017-12-07 17:58:28 +0100462 var octetstring payload := enc_RSL_Message(rsl_tx.rsl);
463 var IPA_Send ret := valueof(t_IPA_Send(connId, rsl_tx.streamId, payload));
464 return ret;
465}
Harald Weltedf277252018-02-20 15:49:30 +0100466#endif
Harald Welte0d846a72017-12-07 17:58:28 +0100467
Harald Weltec6826662019-02-06 22:26:46 +0100468#ifdef IPA_EMULATION_OML
469private function f_from_oml(IPL4asp_Types.ConnectionId connId, OML_PDU oml_tx) return IPA_Send {
470 var octetstring payload := enc_OML_PDU(oml_tx);
471 var IPA_Send ret := valueof(t_IPA_Send(connId, IPAC_PROTO_OML, payload));
472 return ret;
473}
474#endif
475
Harald Weltebdb63702017-12-09 01:15:44 +0100476/* main function to use for a client-side IPA implementation */
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100477function main_client(charstring remote_host, IPL4asp_Types.PortNumber remote_port,
478 charstring local_host, IPL4asp_Types.PortNumber local_port,
Harald Welte2d86aff2018-04-17 11:23:04 +0200479 IPA_CCM_Parameters ccm_pars := c_IPA_default_ccm_pars,
480 boolean ccm_enabled := true) runs on IPA_Emulation_CT {
Harald Welteb3414b22017-11-23 18:22:10 +0100481 g_mode := IPA_MODE_CLIENT;
Harald Welte2d86aff2018-04-17 11:23:04 +0200482 g_ccm_enabled := ccm_enabled;
Harald Weltee09921f2017-12-07 17:49:00 +0100483 f_connect(remote_host, remote_port, local_host, local_port, ccm_pars);
Harald Welte2d86aff2018-04-17 11:23:04 +0200484 if (g_ccm_enabled) {
485 /* we're a client: Send ID_ACK immediately after connect */
486 f_ccm_tx(valueof(ts_IPA_ACK));
487 }
Harald Welte03c0e562017-12-09 02:55:12 +0100488 f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP));
Harald Welteb3414b22017-11-23 18:22:10 +0100489 ScanEvents();
490}
491
Harald Weltebdb63702017-12-09 01:15:44 +0100492/* main function to use for a server-side IPA implementation */
Harald Welte2d86aff2018-04-17 11:23:04 +0200493function main_server(charstring local_host, IPL4asp_Types.PortNumber local_port,
Neels Hofmeyr3bf31d22018-08-24 14:44:32 +0200494 boolean ccm_enabled := true,
495 IpaInitBehavior init_behavior := IPA_INIT_SEND_IPA_ID_GET)
496runs on IPA_Emulation_CT {
Harald Welteb3414b22017-11-23 18:22:10 +0100497 g_mode := IPA_MODE_SERVER;
Harald Welte2d86aff2018-04-17 11:23:04 +0200498 g_ccm_enabled := ccm_enabled;
Neels Hofmeyr3bf31d22018-08-24 14:44:32 +0200499 g_init_behavior := init_behavior;
Harald Welteb3414b22017-11-23 18:22:10 +0100500 f_bind(local_host, local_port);
501 ScanEvents();
502}
503
Pau Espin Pedrolacc51192019-06-11 15:35:19 +0200504#ifdef IPA_EMULATION_CTRL
Harald Weltedf277252018-02-20 15:49:30 +0100505private function f_ctrl_to_user(octetstring msg) runs on IPA_Emulation_CT {
506 var charstring msg_ch := oct2char(msg);
507 IPA_CTRL_PORT.send(dec_CtrlMessage(msg_ch));
508}
Pau Espin Pedrolacc51192019-06-11 15:35:19 +0200509#endif
Harald Weltedf277252018-02-20 15:49:30 +0100510
511#ifdef IPA_EMULATION_GSUP
512private function f_gsup_to_user(octetstring msg) runs on IPA_Emulation_CT {
513 var GSUP_PDU gsup := dec_GSUP_PDU(msg);
514 f_gsup_postprocess_decoded(gsup);
515 IPA_GSUP_PORT.send(gsup);
516}
517#endif
518
Harald Welte7460a722018-10-10 12:28:27 +0200519#ifdef IPA_EMULATION_RSPRO
520private function f_rspro_to_user(octetstring msg) runs on IPA_Emulation_CT {
521 var RsproPDU rspro := dec_RsproPDU(msg);
522 IPA_RSPRO_PORT.send(rspro);
523}
524#endif
525
Harald Weltedf277252018-02-20 15:49:30 +0100526#ifdef IPA_EMULATION_MGCP
Harald Weltec82eef42017-11-24 20:40:12 +0100527private function f_mgcp_to_user(octetstring msg) runs on IPA_Emulation_CT {
528 var charstring msg_ch := oct2char(msg);
529 if (g_is_bsc_mgw) {
530 log("============");
531 log(msg_ch);
532 IPA_MGCP_PORT.send(dec_MgcpCommand(msg_ch));
533 } else {
534 IPA_MGCP_PORT.send(dec_MgcpResponse(msg_ch));
535 }
536}
537
Harald Welte92632e12017-11-25 02:31:20 +0100538private function f_mgcp_to_ud(octetstring payload) runs on IPA_Emulation_CT return ASP_IPA_Unitdata {
539 if (mp_ipa_mgcp_uses_osmo_ext) {
540 return valueof(t_ASP_IPA_UD(IPAC_PROTO_MGCP_OLD, payload));
541 } else {
542 return valueof(t_ASP_IPA_UD(IPAC_PROTO_OSMO, payload, IPAC_PROTO_EXT_MGCP));
543 }
544}
Harald Weltedf277252018-02-20 15:49:30 +0100545#endif
Harald Welte92632e12017-11-25 02:31:20 +0100546
Harald Weltebdb63702017-12-09 01:15:44 +0100547/* main loop function for both client and server. 'thread' of the component */
Harald Welteb3414b22017-11-23 18:22:10 +0100548private function ScanEvents() runs on IPA_Emulation_CT {
Harald Welted86cdc62017-11-22 00:45:07 +0100549 var IPA_RecvFrom ipa_rx;
Harald Welteb3414b22017-11-23 18:22:10 +0100550 var ASP_Event asp_evt;
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100551 var Socket_API_Definitions.PortEvent port_evt;
Harald Weltedf277252018-02-20 15:49:30 +0100552 var octetstring payload;
553 var CtrlMessage ctrl_msg;
554 var ASP_IPA_Unitdata ipa_ud;
555#ifdef IPA_EMULATION_SCCP
556 var ASP_MTP3_TRANSFERreq mtp_req;
557#endif
558#ifdef IPA_EMULATION_MGCP
Harald Weltec82eef42017-11-24 20:40:12 +0100559 var MgcpCommand mgcp_cmd;
560 var MgcpResponse mgcp_rsp;
Harald Weltedf277252018-02-20 15:49:30 +0100561#endif
562#ifdef IPA_EMULATION_GSUP
Harald Weltedf327232017-12-28 22:51:51 +0100563 var GSUP_PDU gsup_msg;
Harald Weltedf277252018-02-20 15:49:30 +0100564#endif
565#ifdef IPA_EMULATION_RSL
Harald Welte0d846a72017-12-07 17:58:28 +0100566 var ASP_RSL_Unitdata rsl;
Harald Weltedf277252018-02-20 15:49:30 +0100567#endif
Harald Weltec6826662019-02-06 22:26:46 +0100568#ifdef IPA_EMULATION_OML
569 var OML_PDU oml;
570#endif
Harald Welte7460a722018-10-10 12:28:27 +0200571#ifdef IPA_EMULATION_RSPRO
572 var RsproPDU rspro;
573#endif
Harald Welted86cdc62017-11-22 00:45:07 +0100574
Harald Welte3e6ad892017-12-12 14:39:46 +0100575 /* Set function for dissecting the binary */
576 var f_IPL4_getMsgLen vl_f := refers(f_IPL4_fixedMsgLen);
577 IPA_CodecPort_CtrlFunct.f_IPL4_setGetMsgLen(IPA_PORT, g_ipa_conn_id, vl_f, {0, 2, 3, 1, 0});
578
Harald Welted86cdc62017-11-22 00:45:07 +0100579 while (true) {
580 alt {
581 /* Received IPA -> up into SCCP stack */
Harald Welte2d86aff2018-04-17 11:23:04 +0200582 [g_ccm_enabled] IPA_PORT.receive(IPA_RecvFrom:{?,IPAC_PROTO_CCM,omit,?}) -> value ipa_rx {
583 var PDU_IPA_CCM ccm := dec_PDU_IPA_CCM(ipa_rx.msg);
584 log("CCM Rx:", ccm);
585 select (g_mode) {
586 case (IPA_MODE_CLIENT) {
587 f_ccm_rx_client(ccm);
588 }
589 case (IPA_MODE_SERVER) {
590 f_ccm_rx_server(ccm);
591 }
592 case else {
593 setverdict(fail, "Unknown mode");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200594 mtc.stop;
Harald Welte2d86aff2018-04-17 11:23:04 +0200595 }
Harald Weltedf277252018-02-20 15:49:30 +0100596 }
Harald Welte2d86aff2018-04-17 11:23:04 +0200597 }
598 [] IPA_PORT.receive(IPA_RecvFrom:?) -> value ipa_rx {
599 select (ipa_rx.streamId) {
Harald Weltedf277252018-02-20 15:49:30 +0100600#ifdef IPA_EMULATION_SCCP
601 case (IPAC_PROTO_SCCP) {
Harald Welted86cdc62017-11-22 00:45:07 +0100602 var ASP_MTP3_TRANSFERind mtp;
603 mtp := valueof(ts_MTP3_XFER_ind(0, ipa_rx.msg));
604 MTP3_SP_PORT.send(mtp);
Harald Weltedf277252018-02-20 15:49:30 +0100605 }
606#endif
607#ifdef IPA_EMULATION_MGCP
608 case (IPAC_PROTO_MGCP_OLD) {
Harald Weltec82eef42017-11-24 20:40:12 +0100609 f_mgcp_to_user(ipa_rx.msg);
Harald Weltedf277252018-02-20 15:49:30 +0100610 }
611#endif
612#ifdef IPA_EMULATION_RSL
613 case (t_IpaSidRSL) {
Harald Welte0d846a72017-12-07 17:58:28 +0100614 rsl := {
615 streamId := ipa_rx.streamId,
616 rsl := dec_RSL_Message(ipa_rx.msg)
617 };
618 IPA_RSL_PORT.send(rsl);
Harald Weltedf277252018-02-20 15:49:30 +0100619 }
620#endif
Harald Weltec6826662019-02-06 22:26:46 +0100621#ifdef IPA_EMULATION_OML
622 case (IPAC_PROTO_OML) {
623 oml := dec_OML_PDU(ipa_rx.msg)
624 IPA_OML_PORT.send(oml);
625 }
626#endif
Harald Weltedf277252018-02-20 15:49:30 +0100627 case (IPAC_PROTO_OSMO) {
Harald Weltec82eef42017-11-24 20:40:12 +0100628 select (ipa_rx.streamIdExt) {
Harald Weltedf277252018-02-20 15:49:30 +0100629#ifdef IPA_EMULATION_MGCP
Harald Weltec82eef42017-11-24 20:40:12 +0100630 case (IPAC_PROTO_EXT_MGCP) {
631 f_mgcp_to_user(ipa_rx.msg);
Harald Weltedf277252018-02-20 15:49:30 +0100632 }
633#endif
634 case (IPAC_PROTO_EXT_CTRL) {
Harald Weltea76c4bb2017-12-09 02:06:07 +0100635 f_ctrl_to_user(ipa_rx.msg);
Harald Weltedf277252018-02-20 15:49:30 +0100636 }
637#ifdef IPA_EMULATION_GSUP
638 case (IPAC_PROTO_EXT_GSUP) {
Harald Weltedf327232017-12-28 22:51:51 +0100639 f_gsup_to_user(ipa_rx.msg);
Harald Weltedf277252018-02-20 15:49:30 +0100640 }
641#endif
Harald Welte7460a722018-10-10 12:28:27 +0200642#ifdef IPA_EMULATION_RSPRO
643 case (IPAC_PROTO_EXT_RSPRO) {
644 f_rspro_to_user(ipa_rx.msg);
645 }
646#endif
Harald Weltedf277252018-02-20 15:49:30 +0100647 case else {
Harald Weltec82eef42017-11-24 20:40:12 +0100648 IPA_SP_PORT.send(f_to_asp(ipa_rx));
649 }
Harald Welted86cdc62017-11-22 00:45:07 +0100650 }
Harald Weltedf277252018-02-20 15:49:30 +0100651 }
652 case else {
Harald Weltec76f29f2017-11-22 12:46:46 +0100653 IPA_SP_PORT.send(f_to_asp(ipa_rx));
Harald Welted86cdc62017-11-22 00:45:07 +0100654 }
655 }
656 }
657
Harald Welteb3414b22017-11-23 18:22:10 +0100658 /* server only */
659 [] IPA_PORT.receive(ASP_Event:{connOpened:=?}) -> value asp_evt {
660 log("IPA: Connected");
661 g_ipa_conn_id := asp_evt.connOpened.connId;
Harald Welte0d846a72017-12-07 17:58:28 +0100662 f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP));
Harald Welte2d86aff2018-04-17 11:23:04 +0200663 if (g_mode == IPA_MODE_SERVER and g_ccm_enabled) {
Neels Hofmeyr3bf31d22018-08-24 14:44:32 +0200664 select (g_init_behavior) {
665 case (IPA_INIT_SEND_IPA_ID_GET) {
666 f_ccm_tx(valueof(ts_IPA_ID_GET));
667 }
668 case (IPA_INIT_SEND_IPA_ID_ACK) {
669 f_ccm_tx(valueof(ts_IPA_ACK));
670 }
671 }
Harald Welteb3414b22017-11-23 18:22:10 +0100672 }
673 }
674
675 [] IPA_PORT.receive(ASP_Event:{connClosed:=?}) -> value asp_evt {
676 log("IPA: Closed");
677 g_ipa_conn_id := -1;
Harald Welte0d846a72017-12-07 17:58:28 +0100678 f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_DOWN));
Harald Welteb3414b22017-11-23 18:22:10 +0100679 self.stop;
680 }
681
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100682 [] IPA_PORT.receive(Socket_API_Definitions.PortEvent:{result:={errorCode:=ERROR_SOCKET, connId:=?, os_error_code:=?, os_error_text:=?}}) -> value port_evt {
683 log("PortEvent: ERROR_SOCKET: ", port_evt);
684 g_ipa_conn_id := -1;
685 f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_DOWN));
686 self.stop;
687 }
688
Harald Weltedf277252018-02-20 15:49:30 +0100689#ifdef IPA_EMULATION_SCCP
Harald Welted86cdc62017-11-22 00:45:07 +0100690 /* Received SCCP -> down into IPA */
691 [] MTP3_SP_PORT.receive(ASP_MTP3_TRANSFERreq: ?) -> value mtp_req {
Harald Weltec82eef42017-11-24 20:40:12 +0100692 var IPA_Send ipa_tx := valueof(t_IPA_Send(g_ipa_conn_id, IPAC_PROTO_SCCP,
693 mtp_req.data));
Harald Welted86cdc62017-11-22 00:45:07 +0100694 IPA_PORT.send(ipa_tx);
695 }
Harald Weltedf277252018-02-20 15:49:30 +0100696#endif
Harald Weltec76f29f2017-11-22 12:46:46 +0100697
Harald Weltedf277252018-02-20 15:49:30 +0100698#ifdef IPA_EMULATION_MGCP
Harald Weltec82eef42017-11-24 20:40:12 +0100699 /* Received MGCP -> down into IPA */
700 [] IPA_MGCP_PORT.receive(MgcpCommand:?) -> value mgcp_cmd {
Harald Welte92632e12017-11-25 02:31:20 +0100701 payload := char2oct(enc_MgcpCommand(mgcp_cmd));
702 ipa_ud := f_mgcp_to_ud(payload);
Harald Weltec82eef42017-11-24 20:40:12 +0100703 IPA_PORT.send(f_from_asp(g_ipa_conn_id, ipa_ud));
704 }
705 [] IPA_MGCP_PORT.receive(MgcpResponse:?) -> value mgcp_rsp {
Harald Welte1dd8f372017-11-25 02:25:27 +0100706 payload := char2oct(enc_MgcpResponse(mgcp_rsp));
Harald Welte92632e12017-11-25 02:31:20 +0100707 ipa_ud := f_mgcp_to_ud(payload);
Harald Weltec82eef42017-11-24 20:40:12 +0100708 IPA_PORT.send(f_from_asp(g_ipa_conn_id, ipa_ud));
709 }
Harald Weltedf277252018-02-20 15:49:30 +0100710#endif
Harald Weltec82eef42017-11-24 20:40:12 +0100711
Pau Espin Pedrolacc51192019-06-11 15:35:19 +0200712#ifdef IPA_EMULATION_CTRL
Harald Weltea76c4bb2017-12-09 02:06:07 +0100713 [] IPA_CTRL_PORT.receive(CtrlMessage:?) -> value ctrl_msg {
714 payload := char2oct(enc_CtrlMessage(ctrl_msg));
715 ipa_ud := valueof(t_ASP_IPA_UD(IPAC_PROTO_OSMO, payload, IPAC_PROTO_EXT_CTRL));
716 IPA_PORT.send(f_from_asp(g_ipa_conn_id, ipa_ud));
717 }
Pau Espin Pedrolacc51192019-06-11 15:35:19 +0200718#endif
Harald Weltea76c4bb2017-12-09 02:06:07 +0100719
Harald Weltedf277252018-02-20 15:49:30 +0100720#ifdef IPA_EMULATION_GSUP
Harald Weltedf327232017-12-28 22:51:51 +0100721 [] IPA_GSUP_PORT.receive(GSUP_PDU:?) -> value gsup_msg {
Harald Welte2f562b12018-01-24 20:52:38 +0100722 f_gsup_preprocess_encoded(gsup_msg);
Harald Weltedf327232017-12-28 22:51:51 +0100723 payload := enc_GSUP_PDU(gsup_msg);
724 ipa_ud := valueof(t_ASP_IPA_UD(IPAC_PROTO_OSMO, payload, IPAC_PROTO_EXT_GSUP));
725 IPA_PORT.send(f_from_asp(g_ipa_conn_id, ipa_ud));
726 }
Harald Weltedf277252018-02-20 15:49:30 +0100727#endif
Harald Weltedf327232017-12-28 22:51:51 +0100728
Harald Welte7460a722018-10-10 12:28:27 +0200729#ifdef IPA_EMULATION_RSPRO
730 [] IPA_RSPRO_PORT.receive(RsproPDU:?) -> value rspro {
731 payload := enc_RsproPDU(rspro);
732 ipa_ud := valueof(t_ASP_IPA_UD(IPAC_PROTO_OSMO, payload, IPAC_PROTO_EXT_RSPRO));
733 IPA_PORT.send(f_from_asp(g_ipa_conn_id, ipa_ud));
734 }
735#endif
736
Harald Weltedf277252018-02-20 15:49:30 +0100737#ifdef IPA_EMULATION_RSL
Harald Welte0d846a72017-12-07 17:58:28 +0100738 /* Received RSL -> down into IPA */
739 [] IPA_RSL_PORT.receive(ASP_RSL_Unitdata:?) -> value rsl {
740 IPA_PORT.send(f_from_rsl(g_ipa_conn_id, rsl));
741 }
Harald Weltedf277252018-02-20 15:49:30 +0100742#endif
Harald Weltec6826662019-02-06 22:26:46 +0100743#ifdef IPA_EMULATION_OML
744 /* Received OML -> down into IPA */
745 [] IPA_OML_PORT.receive(OML_PDU:?) -> value oml {
746 IPA_PORT.send(f_from_oml(g_ipa_conn_id, oml));
747 }
748 [] IPA_OML_PORT.receive(octetstring:?) -> value payload {
749 IPA_PORT.send(t_IPA_Send(g_ipa_conn_id, IPAC_PROTO_OML, payload));
750 }
751#endif
Harald Welte0d846a72017-12-07 17:58:28 +0100752 /* Received MISC (OML/CTRL) -> down into IPA */
Harald Weltec76f29f2017-11-22 12:46:46 +0100753 [] IPA_SP_PORT.receive(ASP_IPA_Unitdata: ?) -> value ipa_ud {
754 IPA_PORT.send(f_from_asp(g_ipa_conn_id, ipa_ud));
755 }
756
757
Harald Welted86cdc62017-11-22 00:45:07 +0100758 }
759 }
760}
761
Harald Welte2e32e432018-05-24 20:00:00 +0200762/***********************************************************************
763 * IPA Event waiter component. Wait for ASP_IPA_EVENT_ID_ACK
764 ***********************************************************************/
765
766type component IPA_EventWaiter_CT {
767 port IPA_SP_PT IPA_SP_PORT;
768}
769
770function waiter_main(template ASP_IPA_Event wait_for := t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_ID_ACK))
771runs on IPA_EventWaiter_CT {
772
773 alt {
774 [] IPA_SP_PORT.receive(wait_for) {
775 setverdict(pass);
776 }
777 [] IPA_SP_PORT.receive { repeat; }
778 }
779}
780
781
Harald Welted86cdc62017-11-22 00:45:07 +0100782}