reSIProcate/stack  9694
Public Member Functions | Private Attributes
Loadgen::Transceiver Class Reference

#include <Transceiver.hxx>

Collaboration diagram for Loadgen::Transceiver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Transceiver (int port)
void send (const resip::Resolver &target, resip::SipMessage &msg)
void send (resip::SipMessage &message)
resip::SipMessagereceive (int waitMs)
const resip::UricontactUri ()

Private Attributes

resip::Fifo< resip::MessagemReceived
resip::UdpTransport mUdp
resip::Uri mContactUri
resip::FdSet mFdset

Detailed Description

Definition at line 11 of file Transceiver.hxx.


Constructor & Destructor Documentation

Transceiver::Transceiver ( int  port)

Definition at line 23 of file Transceiver.cxx.

References resip::Uri::host(), mContactUri, mUdp, resip::ParserCategory::param(), resip::Uri::port(), resip::Transport::port(), and resip::UdpTransport::transport().

   : mUdp(mReceived, port)
{
   mContactUri.host() = DnsUtil::getLocalHostName();
   mContactUri.port() = mUdp.port();
   mContactUri.param(p_transport) = Transport::toData(mUdp.transport());
}

Here is the call graph for this function:


Member Function Documentation

const resip::Uri& Loadgen::Transceiver::contactUri ( ) [inline]

Definition at line 26 of file Transceiver.hxx.

References mContactUri.

Referenced by Loadgen::InviteServer::go(), Loadgen::Register::go(), and Loadgen::InviteClient::go().

{ return mContactUri; }
SipMessage * Transceiver::receive ( int  waitMs)

Definition at line 102 of file Transceiver.cxx.

References resip::UdpTransport::buildFdSet(), DebugLog, errno, resip::Fifo< Msg >::getNext(), InfoLog, resip::AbstractFifo< T >::messageAvailable(), mFdset, mReceived, mUdp, resip::UdpTransport::process(), resip::FdSet::selectMilliSeconds(), and strerror().

Referenced by Loadgen::Registrar::go(), Loadgen::Register::go(), Loadgen::InviteServer::waitForRequest(), Loadgen::InviteServer::waitForResponse(), and Loadgen::InviteClient::waitForResponse().

{
   UInt64 startTime = Timer::getTimeMs();

   UInt64 currentTime = Timer::getTimeMs();
   
   while( UInt64(waitMs) > currentTime - startTime)
   {
      int timeLeft = waitMs - (currentTime - startTime);
      if (!mReceived.messageAvailable())
      {
         mUdp.buildFdSet(mFdset);
         
         int  err = mFdset.selectMilliSeconds(timeLeft);
         int e = errno;
         if ( err == -1 )
         {
            InfoLog(<< "Error " << e << " " << strerror(e) << " in select");
         }
         
         DebugLog(<<"Calling process in Transceiver::receive");
         mUdp.process(mFdset);
      }

      if (mReceived.messageAvailable())
      {
         Message* msg = mReceived.getNext();
         DebugLog(<<"Received a message in the transceiver, " << msg);
         
         SipMessage* next = dynamic_cast<SipMessage*>(msg);
         DebugLog(<<"Dynamic cast resulted in: " << next);
         if (next)
         {
            DebugLog(<<"Received a sip message in the transceiver.");
            return next;
         }
         else
         {
            DebugLog(<<"Which was apparently not a sip message.");
            delete msg;
         }
      }
      currentTime = Timer::getTimeMs();
   }
   return 0;
}

Here is the call graph for this function:

void Transceiver::send ( const resip::Resolver target,
resip::SipMessage msg 
)

Definition at line 80 of file Transceiver.cxx.

References DebugLog, resip::SipMessage::encode(), resip::SipMessage::header(), resip::SipMessage::isRequest(), mFdset, resip::Resolver::mNextHops, mUdp, resip::Transport::port(), resip::UdpTransport::process(), resip::InternalTransport::send(), and resip::UdpTransport::transport().

Referenced by Loadgen::Registrar::go(), Loadgen::InviteServer::go(), Loadgen::InviteClient::go(), Loadgen::Register::go(), and send().

{
   DebugLog(<< message.header(h_Vias).size() );
 
   if (message.isRequest())
   {
      assert(!message.header(h_Vias).empty());
      message.header(h_Vias).front().transport() = Transport::toData(mUdp.transport()); 
      message.header(h_Vias).front().sentHost() =  DnsUtil::getLocalHostName();
      message.header(h_Vias).front().sentPort() = mUdp.port();
   }
   
   Data& encoded = message.getEncoded();
   DataStream strm(encoded);
   message.encode(strm);
   strm.flush();
   mUdp.send(target.mNextHops.front(), encoded, "bogus"); 
   mUdp.process(mFdset);
}

Here is the call graph for this function:

void Transceiver::send ( resip::SipMessage message)

Definition at line 32 of file Transceiver.cxx.

References DebugLog, resip::SipMessage::header(), resip::Uri::host(), resip::SipMessage::isRequest(), resip::SipMessage::isResponse(), resip::ParserCategory::param(), resip::Uri::port(), send(), and resip::RequestLine::uri().

{
   Uri target;
   if (message.isRequest())
   {
      if (message.header(h_Routes).size() && !message.header(h_Routes).front().exists(p_lr))
      {
         target = message.header(h_Routes).front().uri();
      }
      else
      {
         target = message.header(h_RequestLine).uri();         
      }
   }
   else if (message.isResponse())
   {
      assert (!message.header(h_Vias).empty());
      const Via& via = message.header(h_Vias).front();
      
      // should look at via.transport()
      target.param(p_transport) = Symbols::UDP; // !jf!
      target.host() = via.sentHost();
      target.port() = via.sentPort();
      
      if (via.exists(p_received))
      {
         target.host() = via.param(p_received);
      }
      if (via.exists(p_rport))
      {
         target.port() = via.param(p_rport).port();
      }
   }
   else
   {
      assert(0);
   }
   
   // do a dns lookup !jf!
   // should only do this once and store in the SipMessage (or somewhere)
   DebugLog(<<"Trying to resolve target: " << target);
   Resolver resolver(target);

   send(target, message);
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 31 of file Transceiver.hxx.

Referenced by contactUri(), and Transceiver().

Definition at line 32 of file Transceiver.hxx.

Referenced by receive(), and send().

Definition at line 29 of file Transceiver.hxx.

Referenced by receive().

Definition at line 30 of file Transceiver.hxx.

Referenced by receive(), send(), and Transceiver().


The documentation for this class was generated from the following files: