Loading codec/c++/Makefile +1 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ T3DK_CXX_SOURCES = $(wildcard *.cpp) T3DK_CDGEN_HEADER = codec.h #T3DK_CODETS = c++/codet.cpp T3DK_CODETS = sip_codets.cpp CPPFLAGS = -I. -I/opt/boost-mingw/include Loading codec/c++/init.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ namespace t3devlib { void SAInit() { Port::RegisterType ("TestSystem", "SipPort", &createPort<EchoPort>); Port::RegisterType ("TestSystem", "SipTestPort", &createPort<EchoPort>); } void CDInit() Loading codec/c++/sip_codets.cpp 0 → 100644 +62 −0 Original line number Diff line number Diff line #include "gen_classes.h" #include <regex.h> namespace t3devlib { namespace gen { class Regex { public: Regex(const char* regex) { if (regcomp (&mRegex, regex, 0)) { std::cerr << "bad regex: " << regex << endl; abort(); } } bool Match (Buffer& buffer) { const char* start = buffer.GetValue().c_str() + (buffer.GetPosition() / 8); return !regexec (&mRegex, start, 16, mMatches, 0); } int GetMatchedLength() { return (mMatches[0].rm_eo - mMatches[0].rm_so)*8; } void Error (Variable* v, Buffer& buffer) throw (DecodeError) { const char* start = buffer.GetValue().c_str() + (buffer.GetPosition() / 8); std::string message ("cannot match regex in '"); message.append (start, 8); message += "...'"; throw DecodeError (v, message); } private: regex_t mRegex; regmatch_t mMatches[16]; }; void SipUrl::PreDecodeField (int id, Buffer& buffer) throw (DecodeError) { static Regex reg_scheme ("^sip:"); switch (id) { case id_scheme: if (reg_scheme.Match (buffer)) { SetHypFieldLength (id_scheme, reg_scheme.GetMatchedLength()); } else { reg_scheme.Error (this, buffer); } break; } } }} // namespaces codec/validation/Simple_Testcases.ttcn 0 → 100644 +40 −0 Original line number Diff line number Diff line module Simple_Testcases { import from TestSystem all; import from LibSip_SIPTypesAndValues all; // import from Simple_Templates all; template SipUrl m_simpleUrl (charstring user, charstring host) := { scheme := "sip:", userInfo := { userOrTelephoneSubscriber := user, password := omit }, hostPort := { host := host, portField := omit }, urlParameters := omit, headers := omit } testcase TC_SIMPLE_0001() runs on SipTest system SipTest { // Preamble connect (self:testPort, self:testPort); // Test Body testPort.send ("sip:user@host"); alt { [] testPort.receive (m_simpleUrl ("user", "host")) { setverdict (pass); } [] testPort.receive (SipUrl: ?) { setverdict (fail); } } } } codec/validation/TestExecution.ttcn +3 −0 Original line number Diff line number Diff line Loading @@ -6,11 +6,14 @@ */ module TestExecution { import from Simple_Testcases { testcase all } ; import from Sanity_Testcases { testcase all } ; import from LibSip_SIPTypesAndValues all; control { execute(TC_SIMPLE_0001()); execute(TC_SANITY_0001()); execute(TC_SANITY_0002()); Loading Loading
codec/c++/Makefile +1 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ T3DK_CXX_SOURCES = $(wildcard *.cpp) T3DK_CDGEN_HEADER = codec.h #T3DK_CODETS = c++/codet.cpp T3DK_CODETS = sip_codets.cpp CPPFLAGS = -I. -I/opt/boost-mingw/include Loading
codec/c++/init.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ namespace t3devlib { void SAInit() { Port::RegisterType ("TestSystem", "SipPort", &createPort<EchoPort>); Port::RegisterType ("TestSystem", "SipTestPort", &createPort<EchoPort>); } void CDInit() Loading
codec/c++/sip_codets.cpp 0 → 100644 +62 −0 Original line number Diff line number Diff line #include "gen_classes.h" #include <regex.h> namespace t3devlib { namespace gen { class Regex { public: Regex(const char* regex) { if (regcomp (&mRegex, regex, 0)) { std::cerr << "bad regex: " << regex << endl; abort(); } } bool Match (Buffer& buffer) { const char* start = buffer.GetValue().c_str() + (buffer.GetPosition() / 8); return !regexec (&mRegex, start, 16, mMatches, 0); } int GetMatchedLength() { return (mMatches[0].rm_eo - mMatches[0].rm_so)*8; } void Error (Variable* v, Buffer& buffer) throw (DecodeError) { const char* start = buffer.GetValue().c_str() + (buffer.GetPosition() / 8); std::string message ("cannot match regex in '"); message.append (start, 8); message += "...'"; throw DecodeError (v, message); } private: regex_t mRegex; regmatch_t mMatches[16]; }; void SipUrl::PreDecodeField (int id, Buffer& buffer) throw (DecodeError) { static Regex reg_scheme ("^sip:"); switch (id) { case id_scheme: if (reg_scheme.Match (buffer)) { SetHypFieldLength (id_scheme, reg_scheme.GetMatchedLength()); } else { reg_scheme.Error (this, buffer); } break; } } }} // namespaces
codec/validation/Simple_Testcases.ttcn 0 → 100644 +40 −0 Original line number Diff line number Diff line module Simple_Testcases { import from TestSystem all; import from LibSip_SIPTypesAndValues all; // import from Simple_Templates all; template SipUrl m_simpleUrl (charstring user, charstring host) := { scheme := "sip:", userInfo := { userOrTelephoneSubscriber := user, password := omit }, hostPort := { host := host, portField := omit }, urlParameters := omit, headers := omit } testcase TC_SIMPLE_0001() runs on SipTest system SipTest { // Preamble connect (self:testPort, self:testPort); // Test Body testPort.send ("sip:user@host"); alt { [] testPort.receive (m_simpleUrl ("user", "host")) { setverdict (pass); } [] testPort.receive (SipUrl: ?) { setverdict (fail); } } } }
codec/validation/TestExecution.ttcn +3 −0 Original line number Diff line number Diff line Loading @@ -6,11 +6,14 @@ */ module TestExecution { import from Simple_Testcases { testcase all } ; import from Sanity_Testcases { testcase all } ; import from LibSip_SIPTypesAndValues all; control { execute(TC_SIMPLE_0001()); execute(TC_SANITY_0001()); execute(TC_SANITY_0002()); Loading