diff --git a/sflphone-common/test/sippxml/test_4.xml b/sflphone-common/test/sippxml/test_4.xml new file mode 100644 index 0000000000000000000000000000000000000000..bc4e5636fee7ad1998c5cd59747eed2edd3208c6 --- /dev/null +++ b/sflphone-common/test/sippxml/test_4.xml @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE scenario SYSTEM "sipp.dtd"> + +<!-- This program is free software; you can redistribute it and/or --> +<!-- modify it under the terms of the GNU General Public License as --> +<!-- published by the Free Software Foundation; either version 2 of the --> +<!-- License, or (at your option) any later version. --> +<!-- --> +<!-- This program is distributed in the hope that it will be useful, --> +<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of --> +<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --> +<!-- GNU General Public License for more details. --> +<!-- --> +<!-- You should have received a copy of the GNU General Public License --> +<!-- along with this program; if not, write to the --> +<!-- Free Software Foundation, Inc., --> +<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> +<!-- --> +<!-- Sipp default 'uac' scenario. --> +<!-- --> + +<scenario name="Basic Sipstone UAC"> + <!-- In client mode (sipp placing calls), the Call-ID MUST be --> + <!-- generated by sipp. To do so, use [call_id] keyword. -- + <send retrans="500"> + <![CDATA[ + + INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0 + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] + From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number] + To: sut <sip:[service]@[remote_ip]:[remote_port]> + Call-ID: [call_id] + CSeq: 1 INVITE + Contact: sip:sipp@[local_ip]:[local_port] + Max-Forwards: 70 + Subject: Performance Test + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + </send> + + <recv response="100" + optional="true"> + </recv> + + <recv response="180" optional="true"> + </recv> + + <recv response="183" optional="true"> + </recv> + + <!-- By adding rrs="true" (Record Route Sets), the route sets --> + <!-- are saved and used for following messages sent. Useful to test --> + <!-- against stateful SIP proxies/B2BUAs. --> + <recv response="200" rtd="true"> + <action> + <ereg regexp="a=rtpmap:0 PCMU/8000" search_in="body" check_it="true" assign_to="1" /> + <log message="Custom header is [$1]"/> + </action> + </recv> + + <!-- Packet lost can be simulated in any send/recv message by --> + <!-- by adding the 'lost = "10"'. Value can be [1-100] percent. --> + <send> + <![CDATA[ + + ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0 + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] + From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number] + To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param] + Call-ID: [call_id] + CSeq: 1 ACK + Contact: sip:sipp@[local_ip]:[local_port] + Max-Forwards: 70 + Subject: Performance Test + Content-Length: 0 + + ]]> + </send> + + <!-- This delay can be customized by the -d command-line option --> + <!-- or by adding a 'milliseconds = "value"' option here. --> + <pause/> + + <!-- The 'crlf' option inserts a blank line in the statistics report. --> + <send retrans="500"> + <![CDATA[ + + BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0 + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] + From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number] + To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param] + Call-ID: [call_id] + CSeq: 2 BYE + Contact: sip:sipp@[local_ip]:[local_port] + Max-Forwards: 70 + Subject: Performance Test + Content-Length: 0 + + ]]> + </send> + + <recv response="200" crlf="true"> + </recv> + + <!-- definition of the response time repartition table (unit is ms) --> + <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/> + + <!-- definition of the call length repartition table (unit is ms) --> + <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/> + +</scenario> + diff --git a/sflphone-common/test/siptest.cpp b/sflphone-common/test/siptest.cpp index 27d15273578c70ffd35fc218af121be86e729c81..b764376c4283342fc06c158226974aebf1c1cdb7 100644 --- a/sflphone-common/test/siptest.cpp +++ b/sflphone-common/test/siptest.cpp @@ -408,3 +408,46 @@ void SIPTest::testHoldIpCall() Manager::instance().hangupCall(testCallID); } + +void SIPTest::testIncomingIpCallSdp () +{ + + pthread_t thethread; + void *status; + + // command to be executed by the thread, user agent client which initiate a call and hangup + std::string command("sipp -sf sippxml/test_4.xml 127.0.0.1 -i 127.0.0.1 -p 5062 -m 1"); + + int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command)); + if (rc) { + std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl; + } + + + // sleep a while to make sure that sipp insdtance is initialized and sflphoned received + // the incoming invite. + sleep(2); + + // gtrab call id from sipvoiplink + SIPVoIPLink *siplink = SIPVoIPLink::instance (""); + + CPPUNIT_ASSERT(siplink->_callMap.size() == 1); + CallMap::iterator iterCallId = siplink->_callMap.begin(); + std::string testcallid = iterCallId->first; + + // TODO: hmmm, should IP2IP call be stored in call list.... + CPPUNIT_ASSERT(Manager::instance().getCallList().size() == 0); + + // Answer this call + CPPUNIT_ASSERT(Manager::instance().answerCall(testcallid)); + + + sleep(1); + + rc = pthread_join(thethread, &status); + if (rc) { + std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl; + } + else + std::cout << "SIPTest: completed join with thread" << std::endl; +} diff --git a/sflphone-common/test/siptest.h b/sflphone-common/test/siptest.h index 8810273bca1717ff0fc4b3cb48508a28a8e95f1a..abf5558f1536460e082b1c2f62f7362b527963d2 100644 --- a/sflphone-common/test/siptest.h +++ b/sflphone-common/test/siptest.h @@ -58,6 +58,7 @@ class SIPTest : public CppUnit::TestCase { CPPUNIT_TEST ( testTwoOutgoingIpCall ); // CPPUNIT_TEST ( testTwoIncomingIpCall ); CPPUNIT_TEST ( testHoldIpCall); + CPPUNIT_TEST ( testIncomingIpCallSdp ); CPPUNIT_TEST_SUITE_END(); public: @@ -86,6 +87,7 @@ class SIPTest : public CppUnit::TestCase { void testHoldIpCall(void); + void testIncomingIpCallSdp(void); private: };