module NS_CodecPort {

	import from IPL4asp_PortType all;
	import from IPL4asp_Types all;
	import from NS_Types all;

	type record NS_RecvFrom {
		ConnectionId	connId,
		HostName	remName,
		PortNumber	remPort,
		HostName	locName,
		PortNumber	locPort,
		PDU_NS		msg
	}

	template NS_RecvFrom t_NS_RecvFrom(template PDU_NS pdu) := {
		connId := ?,
		remName := ?,
		remPort := ?,
		locName := ?,
		locPort := ?,
		msg := pdu
	};

	type record NS_Send {
		ConnectionId	connId,
		PDU_NS		msg
	}

	template NS_Send t_NS_Send(template ConnectionId connId, template PDU_NS msg) := {
		connId := connId,
		msg := msg
	}

	private function IPL4_to_NS_RecvFrom(in ASP_RecvFrom pin, out NS_RecvFrom pout) {
		pout.connId := pin.connId;
		pout.remName := pin.remName;
		pout.remPort := pin.remPort;
		pout.locName := pin.locName;
		pout.locPort := pin.locPort;
		pout.msg := dec_PDU_NS(pin.msg);
	} with { extension "prototype(fast)" };

	private function NS_to_IPL4_Send(in NS_Send pin, out ASP_Send pout) {
		pout.connId := pin.connId;
		pout.proto := { udp := {} };
		pout.msg := enc_PDU_NS(pin.msg);
	} with { extension "prototype(fast)" };

	type port NS_CODEC_PT message {
		out	NS_Send;
		in	NS_RecvFrom,
			ASP_ConnId_ReadyToRelease,
			ASP_Event;
	} with { extension "user IPL4asp_PT
		out(NS_Send -> ASP_Send: function(NS_to_IPL4_Send))
		in(ASP_RecvFrom -> NS_RecvFrom: function(IPL4_to_NS_RecvFrom);
		   ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
		   ASP_Event -> ASP_Event: simple)"
	}
}
