Pau Espin Pedrol | 7c13cb7 | 2022-06-16 19:03:44 +0200 | [diff] [blame] | 1 | module SBC_AP_CodecPort { |
| 2 | |
| 3 | /* Simple SBC AP Codec Port, translating between raw SCTP primitives with |
| 4 | * octetstring payload towards the IPL4asp provider, and SBC-AP primitives |
| 5 | * which carry the decoded SBC-AP 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 SBC_AP_PDU_Descriptions all; |
| 19 | import from SBC_AP_Types all; |
| 20 | |
| 21 | type record SBC_AP_RecvFrom { |
| 22 | ConnectionId connId, |
| 23 | HostName remName, |
| 24 | PortNumber remPort, |
| 25 | HostName locName, |
| 26 | PortNumber locPort, |
| 27 | SBC_AP_PDU msg |
| 28 | }; |
| 29 | |
| 30 | type record SBC_AP_Send { |
| 31 | ConnectionId connId, |
| 32 | SBC_AP_PDU msg |
| 33 | }; |
| 34 | |
| 35 | template (value) SctpTuple ts_SBC_AP_SctpTuple := { |
| 36 | sinfo_stream := omit, |
| 37 | sinfo_ppid := c_SBC_AP_PPID, |
| 38 | remSocks := omit, |
| 39 | assocId := omit |
| 40 | }; |
| 41 | |
| 42 | template (value) SBC_AP_Send ts_SBC_AP_Send(ConnectionId connId, template (value) SBC_AP_PDU msg) := { |
| 43 | connId := connId, |
| 44 | msg := msg |
| 45 | } |
| 46 | |
| 47 | template (present) SBC_AP_RecvFrom tr_SBC_AP_Recv(template ConnectionId connId, template SBC_AP_PDU msg) := { |
| 48 | connId := connId, |
| 49 | remName := ?, |
| 50 | remPort := ?, |
| 51 | locName := ?, |
| 52 | locPort := ?, |
| 53 | msg := msg |
| 54 | } |
| 55 | |
| 56 | private function IPL4_to_SBC_AP_RecvFrom(in ASP_RecvFrom pin, out SBC_AP_RecvFrom pout) { |
| 57 | pout.connId := pin.connId; |
| 58 | pout.remName := pin.remName; |
| 59 | pout.remPort := pin.remPort; |
| 60 | pout.locName := pin.locName; |
| 61 | pout.locPort := pin.locPort; |
| 62 | pout.msg := dec_SBC_AP_PDU(pin.msg); |
| 63 | } with { extension "prototype(fast)" }; |
| 64 | |
| 65 | private function SBC_AP_to_IPL4_Send(in SBC_AP_Send pin, out ASP_Send pout) { |
| 66 | pout.connId := pin.connId; |
| 67 | pout.proto := { |
| 68 | sctp := valueof(ts_SBC_AP_SctpTuple) |
| 69 | }; |
| 70 | pout.msg := enc_SBC_AP_PDU(pin.msg); |
| 71 | } with { extension "prototype(fast)" }; |
| 72 | |
| 73 | type port SBC_AP_CODEC_PT message { |
| 74 | out SBC_AP_Send; |
| 75 | in SBC_AP_RecvFrom, |
| 76 | ASP_ConnId_ReadyToRelease, |
| 77 | ASP_Event; |
| 78 | } with { extension "user IPL4asp_PT |
| 79 | out(SBC_AP_Send -> ASP_Send:function(SBC_AP_to_IPL4_Send)) |
| 80 | in(ASP_RecvFrom -> SBC_AP_RecvFrom: function(IPL4_to_SBC_AP_RecvFrom); |
| 81 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
| 82 | ASP_Event -> ASP_Event: simple)" |
| 83 | } |
| 84 | } |