Harald Welte | 619b2a6 | 2019-11-22 00:35:52 +0100 | [diff] [blame] | 1 | module VPCD_CodecPort { |
| 2 | |
| 3 | /* Simple VPCD Codec Port, translating between raw TCP octetstring payload |
| 4 | * towards the IPL4asp port provider, and VPCD primitives |
| 5 | * which carry the decoded VPCD 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 VPCD_Types all; |
| 18 | |
| 19 | type record VPCD_RecvFrom { |
| 20 | ConnectionId connId, |
| 21 | VPCD_PDU msg |
| 22 | } |
| 23 | |
| 24 | type record VPCD_Send { |
| 25 | ConnectionId connId, |
| 26 | VPCD_PDU msg |
| 27 | } |
| 28 | |
| 29 | template (value) VPCD_Send ts_VPCD_Send(ConnectionId conn_id, template (value) VPCD_PDU msg) := { |
| 30 | connId := conn_id, |
| 31 | msg := msg |
| 32 | } |
| 33 | |
| 34 | template VPCD_RecvFrom tr_VPCD_Recv(template ConnectionId conn_id, template VPCD_PDU msg) := { |
| 35 | connId := conn_id, |
| 36 | msg := msg |
| 37 | } |
| 38 | |
| 39 | private function IPL4_to_VPCD_RecvFrom(in ASP_RecvFrom pin, out VPCD_RecvFrom pout) { |
| 40 | pout.connId := pin.connId; |
| 41 | pout.msg := dec_VPCD_PDU(pin.msg); |
| 42 | } with { extension "prototype(fast)" } |
| 43 | |
| 44 | private function VPCD_to_IPL4_Send(in VPCD_Send pin, out ASP_Send pout) { |
| 45 | pout.connId := pin.connId; |
| 46 | pout.proto := { tcp := {} }; |
| 47 | pout.msg := enc_VPCD_PDU(pin.msg); |
| 48 | } with { extension "prototype(fast)" } |
| 49 | |
| 50 | type port VPCD_CODEC_PT message { |
| 51 | out VPCD_Send; |
| 52 | in VPCD_RecvFrom, |
| 53 | ASP_ConnId_ReadyToRelease, |
| 54 | ASP_Event; |
| 55 | } with { extension "user IPL4asp_PT |
| 56 | out(VPCD_Send -> ASP_Send: function(VPCD_to_IPL4_Send)) |
| 57 | in(ASP_RecvFrom -> VPCD_RecvFrom: function(IPL4_to_VPCD_RecvFrom); |
| 58 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
| 59 | ASP_Event -> ASP_Event: simple)" |
| 60 | } |
| 61 | |
| 62 | |
| 63 | |
| 64 | } |