Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 1 | module NS_CodecPort { |
| 2 | |
| 3 | import from IPL4asp_PortType all; |
| 4 | import from IPL4asp_Types all; |
| 5 | import from BSSGP_Helper_Functions all; |
| 6 | import from NS_Types all; |
| 7 | |
| 8 | type record NS_RecvFrom { |
| 9 | ConnectionId connId, |
| 10 | HostName remName, |
| 11 | PortNumber remPort, |
| 12 | HostName locName, |
| 13 | PortNumber locPort, |
| 14 | NsPdu msg |
| 15 | } |
| 16 | |
| 17 | template NS_RecvFrom t_NS_RecvFrom(template NsPdu pdu) := { |
| 18 | connId := ?, |
| 19 | remName := ?, |
| 20 | remPort := ?, |
| 21 | locName := ?, |
| 22 | locPort := ?, |
| 23 | msg := pdu |
| 24 | }; |
| 25 | |
| 26 | type record NS_Send { |
| 27 | ConnectionId connId, |
| 28 | NsPdu msg |
| 29 | } |
| 30 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 31 | template NS_Send t_NS_Send(template ConnectionId connId, template NsPdu msg) := { |
| 32 | connId := connId, |
| 33 | msg := msg |
| 34 | } |
| 35 | |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 36 | private function IPL4_to_NS_RecvFrom(in ASP_RecvFrom pin, out NS_RecvFrom pout) { |
| 37 | pout.connId := pin.connId; |
| 38 | pout.remName := pin.remName; |
| 39 | pout.remPort := pin.remPort; |
| 40 | pout.locName := pin.locName; |
| 41 | pout.locPort := pin.locPort; |
| 42 | pout.msg := dec_NsPdu(f_NS_expand_len(pin.msg)); |
| 43 | } with { extension "prototype(fast)" }; |
| 44 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 45 | private function NS_to_IPL4_Send(in NS_Send pin, out ASP_Send pout) { |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 46 | pout.connId := pin.connId; |
| 47 | pout.proto := { udp := {} }; |
| 48 | pout.msg := f_NS_compact_len(enc_NsPdu(pin.msg)); |
| 49 | } with { extension "prototype(fast)" }; |
| 50 | |
| 51 | type port NS_CODEC_PT message { |
| 52 | out NS_Send; |
| 53 | in NS_RecvFrom, |
Harald Welte | 04d74cd | 2017-11-19 09:29:51 +0100 | [diff] [blame] | 54 | ASP_ConnId_ReadyToRelease, |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 55 | ASP_Event; |
| 56 | } with { extension "user IPL4asp_PT |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 57 | out(NS_Send -> ASP_Send: function(NS_to_IPL4_Send)) |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 58 | in(ASP_RecvFrom -> NS_RecvFrom: function(IPL4_to_NS_RecvFrom); |
Harald Welte | 04d74cd | 2017-11-19 09:29:51 +0100 | [diff] [blame] | 59 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 60 | ASP_Event -> ASP_Event: simple)" |
| 61 | } |
| 62 | } |