| module IPA_CodecPort { |
| |
| import from IPL4asp_PortType all; |
| import from IPL4asp_Types all; |
| import from IPA_Types all; |
| |
| type record IPA_RecvFrom { |
| ConnectionId connId, |
| IpaStreamId streamId, |
| IpaExtStreamId streamIdExt optional, |
| octetstring msg |
| } |
| |
| type record IPA_Send { |
| ConnectionId connId, |
| IpaStreamId streamId, |
| IpaExtStreamId streamIdExt optional, |
| octetstring msg |
| } |
| |
| |
| /* 'stream' contains the octets received so far, we must return the total length */ |
| function f_IPA_getMsgLen(in octetstring stream, inout ro_integer args) return integer { |
| var integer stream_len := lengthof(stream); |
| var integer len; |
| if (stream_len < 2) { |
| /* insufficient length to determine the length */ |
| return -1; |
| } |
| len := 3 + oct2int(substr(stream, 0, 2)); |
| return len; |
| } |
| |
| private function IPL4_to_IPA_RecvFrom(in ASP_RecvFrom pin, out IPA_RecvFrom pout) { |
| var PDU_IPA ipa := dec_PDU_IPA(pin.msg); |
| pout.connId := pin.connId; |
| pout.streamId := ipa.streamId |
| pout.streamIdExt := ipa.streamIdExt |
| pout.msg := ipa.payloadData; |
| } with { extension "prototype(fast)" } |
| |
| private function IPA_to_IPL4_Send(in IPA_Send pin, out ASP_Send pout) { |
| var PDU_IPA ipa := { 0, pin.streamId, pin.streamIdExt, pin.msg }; |
| pout.connId := pin.connId; |
| pout.proto := { tcp := {} }; |
| pout.msg := enc_PDU_IPA(ipa); |
| } with { extension "prototype(fast)" } |
| |
| type port IPA_CODEC_PT message { |
| out IPA_Send; |
| in IPA_RecvFrom, |
| ASP_ConnId_ReadyToRelease, |
| ASP_Event; |
| } with { extension "user IPL4asp_PT |
| out(IPA_Send -> ASP_Send:function(IPA_to_IPL4_Send)) |
| in(ASP_RecvFrom -> IPA_RecvFrom: function(IPL4_to_IPA_RecvFrom); |
| ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
| ASP_Event -> ASP_Event: simple)" |
| } |
| } |