Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 1 | module IPA_CodecPort { |
| 2 | |
| 3 | import from IPL4asp_PortType all; |
| 4 | import from IPL4asp_Types all; |
| 5 | import from IPA_Types all; |
| 6 | |
| 7 | type record IPA_RecvFrom { |
| 8 | ConnectionId connId, |
| 9 | IpaStreamId streamId, |
| 10 | octetstring msg |
| 11 | } |
| 12 | |
| 13 | type record IPA_Send { |
| 14 | ConnectionId connId, |
| 15 | IpaStreamId streamId, |
| 16 | octetstring msg |
| 17 | } |
| 18 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 19 | |
| 20 | /* 'stream' contains the octets received so far, we must return the total length */ |
| 21 | function f_IPA_getMsgLen(in octetstring stream, inout ro_integer args) return integer { |
| 22 | var integer stream_len := lengthof(stream); |
| 23 | var integer len; |
| 24 | if (stream_len < 2) { |
| 25 | /* insufficient length to determine the length */ |
| 26 | return -1; |
| 27 | } |
| 28 | len := 3 + oct2int(substr(stream, 0, 2)); |
| 29 | return len; |
| 30 | } |
| 31 | |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 32 | private function IPL4_to_IPA_RecvFrom(in ASP_RecvFrom pin, out IPA_RecvFrom pout) { |
| 33 | var PDU_IPA ipa := dec_PDU_IPA(pin.msg); |
| 34 | pout.connId := pin.connId; |
| 35 | pout.streamId := ipa.streamId |
| 36 | pout.msg := ipa.payloadData; |
| 37 | } with { extension "prototype(fast)" } |
| 38 | |
| 39 | private function IPA_to_IPL4_Send(in IPA_Send pin, out ASP_Send pout) { |
| 40 | var PDU_IPA ipa := { 0, pin.streamId, pin.msg }; |
| 41 | pout.connId := pin.connId; |
| 42 | pout.proto := { tcp := {} }; |
| 43 | pout.msg := enc_PDU_IPA(ipa); |
| 44 | } with { extension "prototype(fast)" } |
| 45 | |
| 46 | type port IPA_CODEC_PT message { |
| 47 | out IPA_Send; |
| 48 | in IPA_RecvFrom, |
| 49 | ASP_ConnId_ReadyToRelease, |
| 50 | ASP_Event; |
| 51 | } with { extension "user IPL4asp_PT |
| 52 | out(IPA_Send -> ASP_Send:function(IPA_to_IPL4_Send)) |
| 53 | in(ASP_RecvFrom -> IPA_RecvFrom: function(IPL4_to_IPA_RecvFrom); |
| 54 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
| 55 | ASP_Event -> ASP_Event: simple)" |
| 56 | } |
| 57 | } |