Harald Welte | cd451ef | 2019-05-06 17:20:44 +0200 | [diff] [blame] | 1 | module CBSP_CodecPort { |
| 2 | |
| 3 | /* Simple CBSP Codec Port, translating between raw TCP octetstring payload |
| 4 | * towards the IPL4asp port provider, and CBSP primitives |
| 5 | * which carry the decoded CBSP data types as payload. |
| 6 | * |
| 7 | * (C) 2018 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 CBSP_Types all; |
| 18 | |
| 19 | type record CBSP_RecvFrom { |
| 20 | ConnectionId connId, |
| 21 | CBSP_PDU msg |
| 22 | } |
| 23 | |
| 24 | type record CBSP_Send { |
| 25 | ConnectionId connId, |
| 26 | CBSP_PDU msg |
| 27 | } |
| 28 | |
| 29 | template (value) CBSP_Send ts_CBSP_Send(ConnectionId conn_id, template (value) CBSP_PDU msg) := { |
| 30 | connId := conn_id, |
| 31 | msg := msg |
| 32 | } |
| 33 | |
| 34 | template CBSP_RecvFrom tr_CBSP_Recv(template ConnectionId conn_id, template CBSP_PDU msg) := { |
| 35 | connId := conn_id, |
| 36 | msg := msg |
| 37 | } |
| 38 | |
| 39 | private function IPL4_to_CBSP_RecvFrom(in ASP_RecvFrom pin, out CBSP_RecvFrom pout) { |
| 40 | pout.connId := pin.connId; |
| 41 | pout.msg := dec_CBSP_PDU(pin.msg); |
| 42 | } with { extension "prototype(fast)" } |
| 43 | |
| 44 | private function CBSP_to_IPL4_Send(in CBSP_Send pin, out ASP_Send pout) { |
| 45 | pout.connId := pin.connId; |
| 46 | pout.proto := { tcp := {} }; |
| 47 | pout.msg := enc_CBSP_PDU(pin.msg); |
| 48 | } with { extension "prototype(fast)" } |
| 49 | |
| 50 | type port CBSP_CODEC_PT message { |
| 51 | out CBSP_Send; |
| 52 | in CBSP_RecvFrom, |
| 53 | ASP_ConnId_ReadyToRelease, |
| 54 | ASP_Event; |
| 55 | } with { extension "user IPL4asp_PT |
| 56 | out(CBSP_Send -> ASP_Send: function(CBSP_to_IPL4_Send)) |
| 57 | in(ASP_RecvFrom -> CBSP_RecvFrom: function(IPL4_to_CBSP_RecvFrom); |
| 58 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
| 59 | ASP_Event -> ASP_Event: simple)" |
| 60 | } |
| 61 | |
| 62 | |
| 63 | |
| 64 | } |