blob: ce83ab4e44895bd560c87a0d3474b052f3ca9b01 [file] [log] [blame]
Pau Espin Pedrolb2c6b382019-05-14 13:40:49 +02001module OSMUX_CodecPort {
2
3/* Simple Osmux Codec Port, translating between raw UDP primitives with
4 * octetstring payload towards the IPL4asp provider, and Osmux primitives
5 * which carry the decoded abstract Osmux data types as payload.
6 *
7 * (C) 2019 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
8 * All rights reserved.
9 *
10 * Author: Pau Espin Pedrol <pespin@sysmocom.de>
11 *
12 * Released under the terms of GNU General Public License, Version 2 or
13 * (at your option) any later version.
14 */
15
16 import from IPL4asp_PortType all;
17 import from IPL4asp_Types all;
18 import from OSMUX_Types all;
19
20 type record Osmux_RecvFrom {
21 ConnectionId connId,
22 HostName remName,
23 PortNumber remPort,
24 HostName locName,
25 PortNumber locPort,
26 OSMUX_PDU msg
27 };
28
29 template Osmux_RecvFrom t_Osmux_RecvFrom(template OSMUX_PDU msg) := {
30 connId := ?,
31 remName := ?,
32 remPort := ?,
33 locName := ?,
34 locPort := ?,
35 msg := msg
36 }
37
38 type record Osmux_Send {
39 ConnectionId connId,
40 OSMUX_PDU msg
41 }
42
43 template Osmux_Send t_Osmux_Send(template ConnectionId connId, template OSMUX_PDU msg) := {
44 connId := connId,
45 msg := msg
46 }
47
48 private function IPL4_to_Osmux_RecvFrom(in ASP_RecvFrom pin, out Osmux_RecvFrom pout) {
49 pout.connId := pin.connId;
50 pout.remName := pin.remName;
51 pout.remPort := pin.remPort;
52 pout.locName := pin.locName;
53 pout.locPort := pin.locPort;
54 pout.msg := dec_OSMUX_PDU(pin.msg)
55 } with { extension "prototype(fast)" };
56
57 private function Osmux_to_IPL4_Send(in Osmux_Send pin, out ASP_Send pout) {
58 pout.connId := pin.connId;
59 pout.proto := { udp := {} };
60 pout.msg := enc_OSMUX_PDU(pin.msg);
61 } with { extension "prototype(fast)" };
62
63 type port OSMUX_CODEC_PT message {
64 out Osmux_Send;
65 in Osmux_RecvFrom,
66 ASP_ConnId_ReadyToRelease,
67 ASP_Event;
68 } with { extension "user IPL4asp_PT
69 out(Osmux_Send -> ASP_Send:function(Osmux_to_IPL4_Send))
70 in(ASP_RecvFrom -> Osmux_RecvFrom: function(IPL4_to_Osmux_RecvFrom);
71 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
72 ASP_Event -> ASP_Event: simple)"
73 }
74}