Harald Welte | 02acf82 | 2019-09-23 06:05:52 +0200 | [diff] [blame^] | 1 | module SABP_CodecPort { |
| 2 | |
| 3 | /* Simple SABP Codec Port, translating between raw TCP octetstring payload |
| 4 | * towards the IPL4asp port provider, and SABP primitives |
| 5 | * which carry the decoded SABP 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 | |
| 14 | |
| 15 | import from IPL4asp_PortType all; |
| 16 | import from IPL4asp_Types all; |
| 17 | import from SABP_PDU_Descriptions all; |
| 18 | import from SABP_Types all; |
| 19 | |
| 20 | type record SABP_RecvFrom { |
| 21 | ConnectionId connId, |
| 22 | SABP_PDU msg |
| 23 | } |
| 24 | |
| 25 | type record SABP_Send { |
| 26 | ConnectionId connId, |
| 27 | SABP_PDU msg |
| 28 | } |
| 29 | |
| 30 | template (value) SABP_Send ts_SABP_Send(ConnectionId conn_id, template (value) SABP_PDU msg) := { |
| 31 | connId := conn_id, |
| 32 | msg := msg |
| 33 | } |
| 34 | |
| 35 | template SABP_RecvFrom tr_SABP_Recv(template ConnectionId conn_id, template SABP_PDU msg) := { |
| 36 | connId := conn_id, |
| 37 | msg := msg |
| 38 | } |
| 39 | |
| 40 | private function IPL4_to_SABP_RecvFrom(in ASP_RecvFrom pin, out SABP_RecvFrom pout) { |
| 41 | pout.connId := pin.connId; |
| 42 | pout.msg := dec_SABP_PDU(pin.msg); |
| 43 | } with { extension "prototype(fast)" } |
| 44 | |
| 45 | private function SABP_to_IPL4_Send(in SABP_Send pin, out ASP_Send pout) { |
| 46 | pout.connId := pin.connId; |
| 47 | pout.proto := { tcp := {} }; |
| 48 | pout.msg := enc_SABP_PDU(pin.msg); |
| 49 | } with { extension "prototype(fast)" } |
| 50 | |
| 51 | type port SABP_CODEC_PT message { |
| 52 | out SABP_Send; |
| 53 | in SABP_RecvFrom, |
| 54 | ASP_ConnId_ReadyToRelease, |
| 55 | ASP_Event; |
| 56 | } with { extension "user IPL4asp_PT |
| 57 | out(SABP_Send -> ASP_Send: function(SABP_to_IPL4_Send)) |
| 58 | in(ASP_RecvFrom -> SABP_RecvFrom: function(IPL4_to_SABP_RecvFrom); |
| 59 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
| 60 | ASP_Event -> ASP_Event: simple)" |
| 61 | } |
| 62 | |
| 63 | |
| 64 | |
| 65 | } |