reSIProcate/stack  9694
Classes | Defines | Functions
testConnectionBase.cxx File Reference
#include <iostream>
#include <memory>
#include "rutil/DataStream.hxx"
#include "resip/stack/SipMessage.hxx"
#include "resip/stack/ConnectionBase.hxx"
#include "resip/stack/Helper.hxx"
#include "resip/stack/Uri.hxx"
#include "resip/stack/Transport.hxx"
#include "resip/stack/SdpContents.hxx"
#include "resip/stack/test/TestSupport.hxx"
#include "resip/stack/PlainContents.hxx"
#include "resip/stack/UnknownHeaderType.hxx"
#include "resip/stack/UnknownParameterType.hxx"
#include "rutil/Logger.hxx"
#include "rutil/ParseBuffer.hxx"
#include "rutil/Random.hxx"
Include dependency graph for testConnectionBase.cxx:

Go to the source code of this file.

Classes

class  FakeTransport
class  TestConnection

Defines

#define RESIPROCATE_SUBSYSTEM   Subsystem::TEST
#define CRLF   "\r\n"

Functions

int main (int argc, char **argv)

Define Documentation

#define CRLF   "\r\n"
#define RESIPROCATE_SUBSYSTEM   Subsystem::TEST

Definition at line 25 of file testConnectionBase.cxx.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 91 of file testConnectionBase.cxx.

References resip::Log::Cout, resip::Data::Empty, FakeTransport::flush(), resip::Random::getRandom(), resip::Transport::getTuple(), resip::Log::Info, resip::Log::initialize(), TestConnection::read(), resip::AbstractFifo< T >::size(), resip::swap(), and resip::V4.

{
   Log::initialize(Log::Cout, Log::Info, argv[0]);

   Data bytes("INVITE sip:192.168.2.92:5100;q=1 SIP/2.0\r\n"
              "To: <sip:yiwen_AT_meet2talk.com@whistler.gloo.net>\r\n"
              "From: Jason Fischl<sip:jason_AT_meet2talk.com@whistler.gloo.net>;tag=ba1aee2d\r\n"
              "Via: SIP/2.0/UDP 192.168.2.220:5060;branch=z9hG4bK-c87542-da4d3e6a.0-1--c87542-;rport=5060;received=192.168.2.220;stid=579667358\r\n"
              "Via: SIP/2.0/UDP 192.168.2.15:5100;branch=z9hG4bK-c87542-579667358-1--c87542-;rport=5100;received=192.168.2.15\r\n"
              "Call-ID: 6c64b42fce01b007\r\n"
              "CSeq: 2 INVITE\r\n"
              "Route: <sip:proxy@192.168.2.220:5060;lr>\r\n"
              "Contact: <sip:192.168.2.15:5100>\r\n"
              "Content-Length: 0\r\n"
              "\r\n"
              "\r\n\r\n" //keepalive
              "INVITE sip:192.168.2.92:5100;q=1 SIP/2.0\r\n"
              "To: <sip:yiwen_AT_meet2talk.com@whistler.gloo.net>\r\n"
              "From: Jason Fischl<sip:jason_AT_meet2talk.com@whistler.gloo.net>;tag=ba1aee2d\r\n"
              "Via: SIP/2.0/UDP 192.168.2.220:5060;branch=z9hG4bK-c87542-da4d3e6a.0-1--c87542-;rport=5060;received=192.168.2.220;stid=579667358\r\n"
              "Via: SIP/2.0/UDP 192.168.2.15:5100;branch=z9hG4bK-c87542-579667358-1--c87542-;rport=5100;received=192.168.2.15\r\n"
              "Call-ID: 6c64b42fce01b007\r\n"
              "CSeq: 2 INVITE\r\n"
              "Record-Route: <sip:proxy@192.168.2.220:5060;lr>\r\n"
              "Contact: <sip:192.168.2.15:5100>\r\n"
              "Max-Forwards: 69\r\n"
              "Content-Type: application/sdp\r\n"
              "Content-Length: 307\r\n"
              "\r\n"
              "v=0\r\n"
              "o=M2TUA 1589993278 1032390928 IN IP4 192.168.2.15\r\n"
              "s=-\r\n"
              "c=IN IP4 192.168.2.15\r\n"
              "t=0 0\r\n"
              "m=audio 9000 RTP/AVP 103 97 100 101 0 8 102\r\n"
              "a=rtpmap:103 ISAC/16000\r\n"
              "a=rtpmap:97 IPCMWB/16000\r\n"
              "a=rtpmap:100 EG711U/8000\r\n"
              "a=rtpmap:101 EG711A/8000\r\n"
              "a=rtpmap:0 PCMU/8000\r\n"
              "a=rtpmap:8 PCMA/8000\r\n"
              "a=rtpmap:102 iLBC/8000\r\n");
   
   Fifo<TransactionMessage> testRxFifo;
   FakeTransport fake(testRxFifo, 5060, V4, Data::Empty);
   Tuple who(fake.getTuple());
  
   int chunkRange = 700;
   unsigned int runs = 100;

   for (unsigned int i=0; i < runs; i++)
   {
      TestConnection cBase(&fake,who, bytes);
      int minChunk = (Random::getRandom() % chunkRange)+1;
      int maxChunk = (Random::getRandom() % chunkRange)+1;
      if (maxChunk < minChunk) swap(maxChunk, minChunk);
      while(cBase.read(minChunk, maxChunk));      
   }
   fake.flush();
   assert(testRxFifo.size() == runs * 3);

   cerr << "\nTEST OK" << endl;
   return 0;
}

Here is the call graph for this function: