From 2c6dba145a8325a2359085a4500eb65d981ad0f7 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 16 Sep 2017 00:50:08 +0800 Subject: [PATCH] Introduce MGCP_CodecPort on top of UDP port --- mgw/MGCP_CodecPort.ttcn | 45 ++++++++++++++++++++++++ mgw/MGCP_CodecPort_CtrlFunct.ttcn | 44 +++++++++++++++++++++++ mgw/MGCP_CodecPort_CtrlFunctDef.cc | 56 ++++++++++++++++++++++++++++++ mgw/MGCP_Types.ttcn | 27 +++++++------- mgw/gen_links.sh | 12 +++++++ mgw/regen_makefile.sh | 4 +-- 6 files changed, 171 insertions(+), 17 deletions(-) create mode 100644 mgw/MGCP_CodecPort.ttcn create mode 100644 mgw/MGCP_CodecPort_CtrlFunct.ttcn create mode 100644 mgw/MGCP_CodecPort_CtrlFunctDef.cc diff --git a/mgw/MGCP_CodecPort.ttcn b/mgw/MGCP_CodecPort.ttcn new file mode 100644 index 000000000..22f71cf4b --- /dev/null +++ b/mgw/MGCP_CodecPort.ttcn @@ -0,0 +1,45 @@ +module MGCP_CodecPort { + + import from IPL4asp_PortType all; + import from IPL4asp_Types all; + import from MGCP_Types all; + + type record MGCP_RecvFrom { + ConnectionId connId, + HostName remName, + PortNumber remPort, + HostName locName, + PortNumber locPort, + MgcpMessage msg + } + + type record MGCP_Send { + ConnectionId connId, + MgcpMessage msg + } + + private function IPL4_to_MGCP_RecvFrom(in ASP_RecvFrom pin, out MGCP_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_MgcpMessage(oct2char(pin.msg)); + } with { extension "prototype(fast)" }; + + private function MGCP_to_IPL4_Send(in MGCP_Send pin, out ASP_Send pout) { + pout.connId := pin.connId; + pout.proto := { udp := {} }; + pout.msg := char2oct(enc_MgcpMessage(pin.msg)); + } with { extension "prototype(fast)" }; + + type port MGCP_CODEC_PT message { + out MGCP_Send; + in MGCP_RecvFrom, + ASP_Event; + } with { extension "user IPL4asp_PT + out(MGCP_Send -> ASP_Send:function(MGCP_to_IPL4_Send)) + in(ASP_RecvFrom -> MGCP_RecvFrom: function(IPL4_to_MGCP_RecvFrom); + ASP_Event -> ASP_Event: simple)" + } +} diff --git a/mgw/MGCP_CodecPort_CtrlFunct.ttcn b/mgw/MGCP_CodecPort_CtrlFunct.ttcn new file mode 100644 index 000000000..bc18a70b5 --- /dev/null +++ b/mgw/MGCP_CodecPort_CtrlFunct.ttcn @@ -0,0 +1,44 @@ +module MGCP_CodecPort_CtrlFunct { + + import from MGCP_CodecPort all; + import from IPL4asp_Types all; + + external function f_IPL4_listen( + inout MGCP_CODEC_PT portRef, + in HostName locName, + in PortNumber locPort, + in ProtoTuple proto, + in OptionList options := {} + ) return Result; + + external function f_IPL4_connect( + inout MGCP_CODEC_PT portRef, + in HostName remName, + in PortNumber remPort, + in HostName locName, + in PortNumber locPort, + in ConnectionId connId, + in ProtoTuple proto, + in OptionList options := {} + ) return Result; + + external function f_IPL4_close( + inout MGCP_CODEC_PT portRef, + in ConnectionId id, + in ProtoTuple proto := { unspecified := {} } + ) return Result; + + external function f_IPL4_setUserData( + inout MGCP_CODEC_PT portRef, + in ConnectionId id, + in UserData userData + ) return Result; + + external function f_IPL4_getUserData( + inout MGCP_CODEC_PT portRef, + in ConnectionId id, + out UserData userData + ) return Result; + +} + diff --git a/mgw/MGCP_CodecPort_CtrlFunctDef.cc b/mgw/MGCP_CodecPort_CtrlFunctDef.cc new file mode 100644 index 000000000..92dc6fc0c --- /dev/null +++ b/mgw/MGCP_CodecPort_CtrlFunctDef.cc @@ -0,0 +1,56 @@ +#include "IPL4asp_PortType.hh" +#include "MGCP_CodecPort.hh" +#include "IPL4asp_PT.hh" + +namespace MGCP__CodecPort__CtrlFunct { + + IPL4asp__Types::Result f__IPL4__listen( + MGCP__CodecPort::MGCP__CODEC__PT& portRef, + const IPL4asp__Types::HostName& locName, + const IPL4asp__Types::PortNumber& locPort, + const IPL4asp__Types::ProtoTuple& proto, + const IPL4asp__Types::OptionList& options) + { + return f__IPL4__PROVIDER__listen(portRef, locName, locPort, proto, options); + } + + IPL4asp__Types::Result f__IPL4__connect( + MGCP__CodecPort::MGCP__CODEC__PT& portRef, + const IPL4asp__Types::HostName& remName, + const IPL4asp__Types::PortNumber& remPort, + const IPL4asp__Types::HostName& locName, + const IPL4asp__Types::PortNumber& locPort, + const IPL4asp__Types::ConnectionId& connId, + const IPL4asp__Types::ProtoTuple& proto, + const IPL4asp__Types::OptionList& options) + { + return f__IPL4__PROVIDER__connect(portRef, remName, remPort, + locName, locPort, connId, proto, options); + } + + IPL4asp__Types::Result f__IPL4__close( + MGCP__CodecPort::MGCP__CODEC__PT& portRef, + const IPL4asp__Types::ConnectionId& connId, + const IPL4asp__Types::ProtoTuple& proto) + { + return f__IPL4__PROVIDER__close(portRef, connId, proto); + } + + IPL4asp__Types::Result f__IPL4__setUserData( + MGCP__CodecPort::MGCP__CODEC__PT& portRef, + const IPL4asp__Types::ConnectionId& connId, + const IPL4asp__Types::UserData& userData) + { + return f__IPL4__PROVIDER__setUserData(portRef, connId, userData); + } + + IPL4asp__Types::Result f__IPL4__getUserData( + MGCP__CodecPort::MGCP__CODEC__PT& portRef, + const IPL4asp__Types::ConnectionId& connId, + IPL4asp__Types::UserData& userData) + { + return f__IPL4__PROVIDER__getUserData(portRef, connId, userData); + } + +} + diff --git a/mgw/MGCP_Types.ttcn b/mgw/MGCP_Types.ttcn index 9b55659c5..13d1f8979 100644 --- a/mgw/MGCP_Types.ttcn +++ b/mgw/MGCP_Types.ttcn @@ -33,11 +33,6 @@ module MGCP_Types { variant "END('\r\n', '([\r\n])|(\r\n)')" } - external function enc_MgcpCommandLine(in MgcpCommandLine id) return charstring - with { extension "prototype(convert) encode(TEXT)" }; - external function dec_MgcpCommandLine(in charstring id) return MgcpCommandLine - with { extension "prototype(convert) decode(TEXT)" }; - type record MgcpParameter { MgcpInfoCode code, charstring val optional @@ -48,20 +43,10 @@ module MGCP_Types { variant "END('\r\n', '([\r\n])|(\r\n)')" } - external function enc_MgcpParameter(in MgcpParameter id) return charstring - with { extension "prototype(convert) encode(TEXT)" }; - external function dec_MgcpParameter(in charstring id) return MgcpParameter - with { extension "prototype(convert) decode(TEXT)" }; - type record of MgcpParameter MgcpParameterList with { variant "BEGIN('')" }; - external function enc_MgcpParameterList(in MgcpParameterList id) return charstring - with { extension "prototype(convert) encode(TEXT)" }; - external function dec_MgcpParameterList(in charstring id) return MgcpParameterList - with { extension "prototype(convert) decode(TEXT)" }; - type record MgcpCommand { MgcpCommandLine line, MgcpParameterList params optional, @@ -100,5 +85,17 @@ module MGCP_Types { external function dec_MgcpResponse(in charstring id) return MgcpResponse with { extension "prototype(convert) decode(TEXT)" }; + type union MgcpMessage { + MgcpCommand command, + MgcpResponse response + } with { + variant "BEGIN('')" + } + + external function enc_MgcpMessage(in MgcpMessage id) return charstring + with { extension "prototype(convert) encode(TEXT)" }; + external function dec_MgcpMessage(in charstring id) return MgcpMessage + with { extension "prototype(convert) decode(TEXT)" }; + } with { encode "TEXT" } diff --git a/mgw/gen_links.sh b/mgw/gen_links.sh index b60aeefec..4b4e2b916 100755 --- a/mgw/gen_links.sh +++ b/mgw/gen_links.sh @@ -15,6 +15,18 @@ gen_links() { #FILES="UD_PT.cc UD_PT.hh UD_PortType.ttcn UD_Types.ttcn" #gen_links $DIR $FILES +DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src +FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h" +gen_links $DIR $FILES + +DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src +FILES="Socket_API_Definitions.ttcn" +gen_links $DIR $FILES + +DIR=$BASEDIR/titan.TestPorts.IPL4asp/src +FILES="IPL4asp_Functions.ttcn IPL4asp_PT.cc IPL4asp_PT.hh IPL4asp_PortType.ttcn IPL4asp_Types.ttcn IPL4asp_discovery.cc IPL4asp_protocol_L234.hh" +gen_links $DIR $FILES + DIR=$BASEDIR/titan.ProtocolModules.SDP/src FILES="SDP_EncDec.cc SDP_Types.ttcn SDP_parse_.tab.c SDP_parse_.tab.h SDP_parse_parser.h SDP_parser.l SDP_parser.y lex.SDP_parse_.c" diff --git a/mgw/regen_makefile.sh b/mgw/regen_makefile.sh index 8b68b2f87..ffdbd11ec 100755 --- a/mgw/regen_makefile.sh +++ b/mgw/regen_makefile.sh @@ -1,9 +1,9 @@ #!/bin/sh -FILES="*.ttcn SDP_EncDec.cc *.c" +FILES="*.ttcn SDP_EncDec.cc *.c MGCP_CodecPort_CtrlFunctDef.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc" ttcn3_makefilegen -f MGCP_Test.ttcn $FILES sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile sed -i -e 's/LDFLAGS = /LDFLAGS = -L \/usr\/lib\/titan/' Makefile -sed -i -e 's/TTCN3_LIB = ttcn3-parallel/TTCN3_LIB = ttcn3/' Makefile +#sed -i -e 's/TTCN3_LIB = ttcn3-parallel/TTCN3_LIB = ttcn3/' Makefile sed -i -e 's/CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)\/include/CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)\/include -I\/usr\/include\/titan/' Makefile