Harald Welte | 0db4413 | 2019-10-17 11:09:05 +0200 | [diff] [blame] | 1 | module M3UA_CodecPort { |
| 2 | |
| 3 | /* Simple M3UA Codec Port, translating between raw SCTP primitives with |
| 4 | * octetstring payload towards the IPL4asp provider, and M3UA primitives |
| 5 | * which carry the decoded M3UA data types as payload. |
| 6 | * |
| 7 | * (C) 2019 by Harald Welte <laforge@gnumonks.org> |
| 8 | * All rights reserved. |
| 9 | * |
| 10 | * Released under the terms of GNU General Public License, Version 2 or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 14 | */ |
| 15 | |
| 16 | import from IPL4asp_PortType all; |
| 17 | import from IPL4asp_Types all; |
| 18 | import from M3UA_Types all; |
| 19 | |
| 20 | type record M3UA_RecvFrom { |
| 21 | ConnectionId connId, |
| 22 | HostName remName, |
| 23 | PortNumber remPort, |
| 24 | HostName locName, |
| 25 | PortNumber locPort, |
| 26 | PDU_M3UA msg |
| 27 | }; |
| 28 | |
| 29 | template M3UA_RecvFrom t_M3UA_RecvFrom(template PDU_M3UA msg) := { |
| 30 | connId := ?, |
| 31 | remName := ?, |
| 32 | remPort := ?, |
| 33 | locName := ?, |
| 34 | locPort := ?, |
| 35 | msg := msg |
| 36 | } |
| 37 | |
| 38 | type record M3UA_Send { |
| 39 | ConnectionId connId, |
| 40 | integer stream, |
| 41 | PDU_M3UA msg |
| 42 | } |
| 43 | |
| 44 | template M3UA_Send t_M3UA_Send(template ConnectionId connId, template PDU_M3UA msg, |
| 45 | template (omit) integer stream := omit) := { |
| 46 | connId := connId, |
| 47 | stream := stream, |
| 48 | msg := msg |
| 49 | } |
| 50 | |
| 51 | private function IPL4_to_M3UA_RecvFrom(in ASP_RecvFrom pin, out M3UA_RecvFrom pout) { |
| 52 | pout.connId := pin.connId; |
| 53 | pout.remName := pin.remName; |
| 54 | pout.remPort := pin.remPort; |
| 55 | pout.locName := pin.locName; |
| 56 | pout.locPort := pin.locPort; |
| 57 | pout.msg := dec_PDU_M3UA(pin.msg); |
| 58 | } with { extension "prototype(fast)" }; |
| 59 | |
| 60 | private function M3UA_to_IPL4_Send(in M3UA_Send pin, out ASP_Send pout) { |
| 61 | pout.connId := pin.connId; |
| 62 | pout.proto := { |
| 63 | sctp := { |
| 64 | sinfo_stream := pin.stream, |
| 65 | sinfo_ppid := 3, |
| 66 | remSocks := omit, |
| 67 | assocId := omit |
| 68 | } |
| 69 | }; |
| 70 | pout.msg := enc_PDU_M3UA(pin.msg); |
| 71 | } with { extension "prototype(fast)" }; |
| 72 | |
| 73 | type port M3UA_CODEC_PT message { |
| 74 | out M3UA_Send; |
| 75 | in M3UA_RecvFrom, |
| 76 | ASP_ConnId_ReadyToRelease, |
| 77 | ASP_Event; |
| 78 | } with { extension "user IPL4asp_PT |
| 79 | out(M3UA_Send -> ASP_Send:function(M3UA_to_IPL4_Send)) |
| 80 | in(ASP_RecvFrom -> M3UA_RecvFrom: function(IPL4_to_M3UA_RecvFrom); |
| 81 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
| 82 | ASP_Event -> ASP_Event: simple)" |
| 83 | } |
| 84 | } |