reSIProcate/stack  9694
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | Friends
resip::Transport Class Reference

The base class for Transport classes. More...

#include <Transport.hxx>

Inheritance diagram for resip::Transport:
Inheritance graph
[legend]
Collaboration diagram for resip::Transport:
Collaboration graph
[legend]

List of all members.

Classes

class  Exception
 General exception class for Transport. More...

Public Member Functions

 Transport (Fifo< TransactionMessage > &rxFifo, const GenericIPAddress &address, const Data &tlsDomain=Data::Empty, AfterSocketCreationFuncPtr socketFunc=0, Compression &compression=Compression::Disabled)
 Transport (Fifo< TransactionMessage > &rxFifo, int portNum, IpVersion version, const Data &interfaceObj, const Data &tlsDomain=Data::Empty, AfterSocketCreationFuncPtr socketFunc=0, Compression &compression=Compression::Disabled, unsigned transportFlags=0)
virtual ~Transport ()
virtual bool isFinished () const =0
std::auto_ptr< SendDatamakeSendData (const Tuple &tuple, const Data &data, const Data &tid, const Data &sigcompId=Data::Empty)
virtual void send (std::auto_ptr< SendData > data)=0
virtual void poke ()
 Called when a writer is done adding messages to the TxFifo; this is used to interrupt the select call if the Transport is running in its own thread.
virtual void process (FdSet &fdset)=0
 If there is work to do, this is the method that does it.
virtual void buildFdSet (FdSet &fdset)=0
 Adds the Transport's socket FD to the appropriate read or write sets as applicable.
virtual unsigned int getTimeTillNextProcessMS ()
virtual void process ()=0
 Version of process to be invoked periodically when using callback-based IO (via FdPollGrp).
virtual void setPollGrp (FdPollGrp *grp)=0
void flowTerminated (const Tuple &flow)
 Posts a ConnectionTerminated message to TransactionMessage Fifo.
void keepAlivePong (const Tuple &flow)
void fail (const Data &tid, TransportFailure::FailureReason reason=TransportFailure::Failure, int subCode=0)
 Posts a TransportFailure to the TransactionMessage Fifo.
const DatainterfaceName () const
int port () const
bool isV4 () const
IpVersion ipVersion () const
const DatatlsDomain () const
const sockaddr & boundInterface () const
const TuplegetTuple () const
virtual TransportType transport () const =0
virtual bool isReliable () const =0
virtual bool isDatagram () const =0
virtual bool hasSpecificContact () const
bool basicCheck (const SipMessage &msg)
 Perform basic sanity checks on message.
void makeFailedResponse (const SipMessage &msg, int responseCode=400, const char *warning=0)
std::auto_ptr< SendDatamake503 (SipMessage &msg, UInt16 retryAfter)
std::auto_ptr< SendDatamake100 (SipMessage &msg)
void setRemoteSigcompId (SipMessage &msg, Data &id)
virtual bool shareStackProcessAndSelect () const =0
 Returns true if this Transport should be included in the FdSet processing loop, false if the Transport will provide its own cycles.
virtual void startOwnProcessing ()=0
 transports that returned false to shareStackProcessAndSelect() shouldn't put messages into the fifo until this is called
virtual bool hasDataToSend () const =0
 only applies to transports that shareStackProcessAndSelect
virtual void shutdown ()
 This starts shutting-down procedures for this Transport.
bool operator== (const Transport &rhs) const
virtual unsigned int getFifoSize () const =0
void callSocketFunc (Socket sock)
virtual void setCongestionManager (CongestionManager *manager)
CongestionManager::RejectionBehavior getRejectionBehaviorForIncoming () const
UInt32 getExpectedWaitForIncoming () const
virtual void pushRxMsgUp (TransactionMessage *msg)
virtual void setRcvBufLen (int buflen)
virtual void setRecordRoute (const NameAddr &recordRoute)
virtual bool hasRecordRoute () const
virtual const NameAddrgetRecordRoute () const
unsigned int getKey () const

Static Public Member Functions

static void error (int e)
 Generates a generic log for the platform specific socket error number.
static void stampReceived (SipMessage *request)

Protected Member Functions

void setKey (unsigned int pKey)
void setTlsDomain (const Data &domain)

Protected Attributes

Data mInterface
Tuple mTuple
NameAddr mRecordRoute
bool mHasRecordRoute
unsigned int mKey
CongestionManagermCongestionManager
ProducerFifoBuffer
< TransactionMessage
mStateMachineFifo
bool mShuttingDown
AfterSocketCreationFuncPtr mSocketFunc
CompressionmCompression
unsigned mTransportFlags

Private Attributes

Data mTlsDomain

Static Private Attributes

static const Data transportNames [MAX_TRANSPORT]

Friends

class TransportSelector
EncodeStreamoperator<< (EncodeStream &strm, const Transport &rhs)

Detailed Description

The base class for Transport classes.

A Transport presents layer 4 of the OSI model, the transport layer. For IP-based protocols, this means that a Transport object has an IP address (v4 or v6), a transport layer protocol (UDP or TCP/TLS), and a port number. These are managed through the Transport's Tuple member.

Definition at line 72 of file Transport.hxx.


Constructor & Destructor Documentation

Transport::Transport ( Fifo< TransactionMessage > &  rxFifo,
const GenericIPAddress address,
const Data tlsDomain = Data::Empty,
AfterSocketCreationFuncPtr  socketFunc = 0,
Compression compression = Compression::Disabled 
)
Parameters:
rxFifothe TransactionMessage Fifo that will receive any ConnectionTerminated or TransportFailure messages.
tlsDomainthe domain name of the Transport
socketFuncsubclassers can call this function after the socket is created. This is not currently used by Transport.

Definition at line 35 of file Transport.cxx.

References resip::Tuple::inet_ntop(), mInterface, and mTuple.

                                               :
   mTuple(address),
   mHasRecordRoute(false),
   mKey(0),
   mCongestionManager(0),
   mStateMachineFifo(rxFifo, 8),
   mShuttingDown(false),
   mTlsDomain(tlsDomain),
   mSocketFunc(socketFunc),
   mCompression(compression),
   mTransportFlags(0)
{
   mInterface = Tuple::inet_ntop(mTuple);
}

Here is the call graph for this function:

Transport::Transport ( Fifo< TransactionMessage > &  rxFifo,
int  portNum,
IpVersion  version,
const Data interfaceObj,
const Data tlsDomain = Data::Empty,
AfterSocketCreationFuncPtr  socketFunc = 0,
Compression compression = Compression::Disabled,
unsigned  transportFlags = 0 
)
Parameters:
rxFifothe TransactionMessage Fifo that will receive any ConnectionTerminated or TransportFailure messages.
interfaceObja "presentation format" representation of the IP address of this transport
See also:
Tuple::inet_ntop() for information about "presentation format"
Parameters:
portNumis the port to receive and/or send on
tlsDomainthe domain name of the Transport
Todo:
Note that because of InternalTransport's constructor, tlsDomain is always set to Data::Empty at construction time, in practice.
Parameters:
socketFuncsubclassers can call this function after the socket is created. This is not currently used by Transport.

Definition at line 54 of file Transport.cxx.

                                              :
   mInterface(intfc),
   mTuple(intfc, portNum, version),
   mHasRecordRoute(false),
   mKey(0),
   mCongestionManager(0),
   mStateMachineFifo(rxFifo,8),
   mShuttingDown(false),
   mTlsDomain(tlsDomain),
   mSocketFunc(socketFunc),
   mCompression(compression),
   mTransportFlags(transportFlags)
{
}
Transport::~Transport ( ) [virtual]

Definition at line 76 of file Transport.cxx.

{
}

Member Function Documentation

bool Transport::basicCheck ( const SipMessage msg)

Perform basic sanity checks on message.

Return false if there is a problem eg) no Vias.

Note:
--SIDE EFFECT-- This will queue a response if it CAN for a via-less request. Response will go straight into the TxFifo

Definition at line 388 of file Transport.cxx.

References resip::Message::brief(), resip::Data::c_str(), InfoLog, resip::SipMessage::isExternal(), resip::SipMessage::isRequest(), makeFailedResponse(), resip::SipMessage::method(), mShuttingDown, and resip::Helper::validateMessage().

Referenced by resip::UdpTransport::processRxParse().

{
   resip::Data reason;
   if (msg.isExternal())
   {
      try
      {
         if (!Helper::validateMessage(msg,&reason))
         {
            InfoLog(<<"Message Failed basicCheck :" << msg.brief());
            if (msg.isRequest() && msg.method()!=ACK )
            {
               // this is VERY low-level b/c we don't have a transaction...
               // here we make a response to warn the offending party.
               makeFailedResponse(msg,400,reason.c_str());
            }
            return false;
         }
         else if (mShuttingDown && msg.isRequest() && msg.method() != ACK)
         {
            InfoLog (<< "Server has been shutdown, reject message with 503");
            // this is VERY low-level b/c we don't have a transaction...
            // here we make a response to warn the offending party.
            makeFailedResponse(msg, 503, "Server has been shutdown");
            return false;
         }
      }
      catch (BaseException& e)
      {
         InfoLog (<< "Cannot make failure response to badly constructed message: " << e);
         return false;
      }
   }
   return true;
}

Here is the call graph for this function:

const sockaddr& resip::Transport::boundInterface ( ) const [inline]

Definition at line 239 of file Transport.hxx.

References resip::Tuple::getSockaddr(), and mTuple.

Referenced by operator==(), and resip::UdpTransport::processRxParse().

{ return mTuple.getSockaddr(); }

Here is the call graph for this function:

virtual void resip::Transport::buildFdSet ( FdSet fdset) [pure virtual]

Adds the Transport's socket FD to the appropriate read or write sets as applicable.

Implements resip::FdSetIOObserver.

Implemented in resip::UdpTransport, FakeTransport, and resip::TcpBaseTransport.

void Transport::callSocketFunc ( Socket  sock)

Definition at line 425 of file Transport.cxx.

References mSocketFunc, and transport().

Referenced by resip::Connection::performWrite().

{
   if (mSocketFunc)
   {
      mSocketFunc(sock, transport(), __FILE__, __LINE__);
   }
}

Here is the call graph for this function:

void Transport::error ( int  e) [static]

Generates a generic log for the platform specific socket error number.

Parameters:
ethe socket error number

Definition at line 81 of file Transport.cxx.

References DebugLog, InfoLog, strerror(), and WSANOTINITIALISED.

Referenced by resip::InternalTransport::bind(), resip::TlsConnection::checkState(), resip::DateCategory::DateCategory(), resip::TransportSelector::determineSourceInterface(), resip::TransportSelector::getFirstInterface(), resip::TcpBaseTransport::init(), resip::TcpBaseTransport::makeOutgoingConnection(), resip::TcpBaseTransport::processListen(), resip::UdpTransport::processRxRecv(), resip::UdpTransport::processTxOne(), and resip::DateCategory::setDatetime().

{
   switch (e)
   {
      case EAGAIN:
         //InfoLog (<< "No data ready to read" << strerror(e));
         break;
      case EINTR:
         InfoLog (<< "The call was interrupted by a signal before any data was read : " << strerror(e));
         break;
      case EIO:
         InfoLog (<< "I/O error : " << strerror(e));
         break;
      case EBADF:
         InfoLog (<< "fd is not a valid file descriptor or is not open for reading : " << strerror(e));
         break;
      case EINVAL:
         InfoLog (<< "fd is attached to an object which is unsuitable for reading : " << strerror(e));
         break;
      case EFAULT:
         InfoLog (<< "buf is outside your accessible address space : " << strerror(e));
         break;

#if defined(WIN32)
      case WSAENETDOWN:
         InfoLog (<<" The network subsystem has failed.  ");
         break;
      case WSAEFAULT:
         InfoLog (<<" The buf or from parameters are not part of the user address space, "
                   "or the fromlen parameter is too small to accommodate the peer address.  ");
         break;
      case WSAEINTR:
         InfoLog (<<" The (blocking) call was canceled through WSACancelBlockingCall.  ");
         break;
      case WSAEINPROGRESS:
         InfoLog (<<" A blocking Windows Sockets 1.1 call is in progress, or the "
                   "service provider is still processing a callback function.  ");
         break;
      case WSAEINVAL:
         InfoLog (<<" The socket has not been bound with bind, or an unknown flag was specified, "
                   "or MSG_OOB was specified for a socket with SO_OOBINLINE enabled, "
                   "or (for byte stream-style sockets only) len was zero or negative.  ");
         break;
      case WSAEISCONN :
         InfoLog (<<"The socket is connected. This function is not permitted with a connected socket, "
                  "whether the socket is connection-oriented or connectionless.  ");
         break;
      case WSAENETRESET:
         InfoLog (<<" The connection has been broken due to the keep-alive activity "
                  "detecting a failure while the operation was in progress.  ");
         break;
      case WSAENOTSOCK :
         InfoLog (<<"The descriptor is not a socket.  ");
         break;
      case WSAEOPNOTSUPP:
         InfoLog (<<" MSG_OOB was specified, but the socket is not stream-style such as type "
                   "SOCK_STREAM, OOB data is not supported in the communication domain associated with this socket, "
                   "or the socket is unidirectional and supports only send operations.  ");
         break;
      case WSAESHUTDOWN:
         InfoLog (<<"The socket has been shut down; it is not possible to recvfrom on a socket after "
                  "shutdown has been invoked with how set to SD_RECEIVE or SD_BOTH.  ");
         break;
      case WSAEMSGSIZE:
         InfoLog (<<" The message was too large to fit into the specified buffer and was truncated.  ");
         break;
      case WSAETIMEDOUT:
         InfoLog (<<" The connection has been dropped, because of a network failure or because the "
                  "system on the other end went down without notice.  ");
         break;
      case WSAECONNRESET :
         InfoLog (<<"Connection reset ");
         break;

      case WSAEWOULDBLOCK:
         DebugLog (<<"Would Block ");
         break;

      case WSAEHOSTUNREACH:
         InfoLog (<<"A socket operation was attempted to an unreachable host ");
         break;
      case WSANOTINITIALISED:
         InfoLog (<<"Either the application has not called WSAStartup or WSAStartup failed. "
                  "The application may be accessing a socket that the current active task does not own (that is, trying to share a socket between tasks),"
                  "or WSACleanup has been called too many times.  ");
         break;
      case WSAEACCES:
         InfoLog (<<"An attempt was made to access a socket in a way forbidden by its access permissions ");
         break;
      case WSAENOBUFS:
         InfoLog (<<"An operation on a socket could not be performed because the system lacked sufficient "
                  "buffer space or because a queue was full");
         break;
      case WSAENOTCONN:
         InfoLog (<<"A request to send or receive data was disallowed because the socket is not connected "
                  "and (when sending on a datagram socket using sendto) no address was supplied");
         break;
      case WSAECONNABORTED:
         InfoLog (<<"An established connection was aborted by the software in your host computer, possibly "
                  "due to a data transmission time-out or protocol error");
         break;
      case WSAEADDRNOTAVAIL:
         InfoLog (<<"The requested address is not valid in its context. This normally results from an attempt to "
                  "bind to an address that is not valid for the local computer");
         break;
      case WSAEAFNOSUPPORT:
         InfoLog (<<"An address incompatible with the requested protocol was used");
         break;
      case WSAEDESTADDRREQ:
         InfoLog (<<"A required address was omitted from an operation on a socket");
         break;
      case WSAENETUNREACH:
         InfoLog (<<"A socket operation was attempted to an unreachable network");
         break;

#endif

      default:
         InfoLog (<< "Some other error (" << e << "): " << strerror(e));
         break;
   }
}

Here is the call graph for this function:

void Transport::fail ( const Data tid,
TransportFailure::FailureReason  reason = TransportFailure::Failure,
int  subCode = 0 
)
void Transport::flowTerminated ( const Tuple flow)

Posts a ConnectionTerminated message to TransactionMessage Fifo.

Definition at line 205 of file Transport.cxx.

References resip::ProducerFifoBuffer< class >::add(), and mStateMachineFifo.

Referenced by resip::ConnectionBase::~ConnectionBase().

Here is the call graph for this function:

UInt32 resip::Transport::getExpectedWaitForIncoming ( ) const [inline]

Definition at line 339 of file Transport.hxx.

References resip::AbstractFifo< T >::expectedWaitTimeMilliSec(), resip::ProducerFifoBuffer< class >::getFifo(), and mStateMachineFifo.

Referenced by resip::ConnectionBase::preparseNewBytes(), and resip::UdpTransport::processRxParse().

      {
         return (UInt32)mStateMachineFifo.getFifo().expectedWaitTimeMilliSec()/1000;
      }

Here is the call graph for this function:

virtual unsigned int resip::Transport::getFifoSize ( ) const [pure virtual]
unsigned int resip::Transport::getKey ( ) const [inline]
virtual const NameAddr& resip::Transport::getRecordRoute ( ) const [inline, virtual]

Definition at line 353 of file Transport.hxx.

References mHasRecordRoute, and mRecordRoute.

{ assert(mHasRecordRoute); return mRecordRoute; }
CongestionManager::RejectionBehavior resip::Transport::getRejectionBehaviorForIncoming ( ) const [inline]
virtual unsigned int resip::Transport::getTimeTillNextProcessMS ( ) [inline, virtual]

Implements resip::FdSetIOObserver.

Definition at line 191 of file Transport.hxx.

{return UINT_MAX;}
const Tuple& resip::Transport::getTuple ( ) const [inline]

Definition at line 240 of file Transport.hxx.

References mTuple.

Referenced by resip::TransportSelector::addTransportInternal(), main(), and resip::TransportSelector::transmit().

{ return mTuple; }
virtual bool resip::Transport::hasDataToSend ( ) const [pure virtual]

only applies to transports that shareStackProcessAndSelect

Implemented in resip::UdpTransport, FakeTransport, and resip::InternalTransport.

virtual bool resip::Transport::hasRecordRoute ( ) const [inline, virtual]

Definition at line 352 of file Transport.hxx.

References mHasRecordRoute.

{ return mHasRecordRoute; }
virtual bool resip::Transport::hasSpecificContact ( ) const [inline, virtual]
Returns:
true here if the subclass has a specific contact value that it wishes the TransportSelector to use.

Definition at line 251 of file Transport.hxx.

Referenced by resip::TransportSelector::addTransportInternal(), and resip::TransportSelector::transmit().

{ return false; }
const Data& resip::Transport::interfaceName ( ) const [inline]
IpVersion resip::Transport::ipVersion ( ) const [inline]

Definition at line 231 of file Transport.hxx.

References resip::Tuple::ipVersion(), and mTuple.

Referenced by resip::TransportSelector::addTransportInternal(), resip::TcpBaseTransport::makeOutgoingConnection(), and resip::UdpTransport::processRxParse().

{ return mTuple.ipVersion(); }

Here is the call graph for this function:

virtual bool resip::Transport::isDatagram ( ) const [pure virtual]
virtual bool resip::Transport::isFinished ( ) const [pure virtual]
Note:
Subclasses override this method by checking whether there are unprocessed messages on the TransactionMessage Fifo (that was passed in to the constructor).

Implemented in resip::InternalTransport, and FakeTransport.

virtual bool resip::Transport::isReliable ( ) const [pure virtual]
bool resip::Transport::isV4 ( ) const [inline]
Deprecated:
use ipVersion()

Definition at line 229 of file Transport.hxx.

References resip::Tuple::isV4(), and mTuple.

Referenced by operator==().

{ return mTuple.isV4(); } // !dcm! -- deprecate ASAP

Here is the call graph for this function:

void Transport::keepAlivePong ( const Tuple flow)

Definition at line 211 of file Transport.cxx.

References resip::ProducerFifoBuffer< class >::add(), and mStateMachineFifo.

Referenced by resip::Connection::onSingleCRLF().

Here is the call graph for this function:

std::auto_ptr< SendData > Transport::make100 ( SipMessage msg)

Definition at line 298 of file Transport.cxx.

References dest, resip::Data::Empty, resip::SipMessage::getSource(), resip::SipMessage::isResponse(), resip::Helper::makeRawResponse(), makeSendData(), resip::SipMessage::method(), and setRemoteSigcompId().

{
  std::auto_ptr<SendData> result;
  if (msg.isResponse()) return result;

   try
   {
      if(msg.method()==ACK)
      {
         return result;
      }
   }
   catch(BaseException&)
   {
      // .bwc. Parse failed on the start-line. Stop.
      return result;
   }
   
  const Tuple& dest = msg.getSource();

   // Calculate compartment ID for outbound message
   Data remoteSigcompId;
   setRemoteSigcompId(msg,remoteSigcompId);

   // .bwc. msg is completely unverified. Handle with caution.
   result=makeSendData(dest, Data::Empty, Data::Empty, remoteSigcompId);
   Helper::makeRawResponse(result->data, msg, 100);

   return result;
}

Here is the call graph for this function:

std::auto_ptr< SendData > Transport::make503 ( SipMessage msg,
UInt16  retryAfter 
)

Definition at line 264 of file Transport.cxx.

References dest, resip::Data::Empty, resip::SipMessage::getSource(), resip::SipMessage::isResponse(), resip::Helper::makeRawResponse(), makeSendData(), resip::SipMessage::method(), setRemoteSigcompId(), and value.

Referenced by resip::ConnectionBase::preparseNewBytes(), and resip::UdpTransport::processRxParse().

{
  std::auto_ptr<SendData> result;
  if (msg.isResponse()) return result;

   try
   {
      if(msg.method()==ACK)
      {
         return result;
      }
   }
   catch(BaseException&)
   {
      // .bwc. Parse failed on the start-line. Stop.
      return result;
   }
   
  const Tuple& dest = msg.getSource();

   // Calculate compartment ID for outbound message
   Data remoteSigcompId;
   setRemoteSigcompId(msg,remoteSigcompId);

   // .bwc. msg is completely unverified. Handle with caution.
   result=makeSendData(dest, Data::Empty, Data::Empty, remoteSigcompId);
   static const Data retryAfterHeader("Retry-After: ");
   Data value(retryAfter);
   Helper::makeRawResponse(result->data, msg, 503, retryAfterHeader+value+"\r\n");

  return result;
}

Here is the call graph for this function:

void Transport::makeFailedResponse ( const SipMessage msg,
int  responseCode = 400,
const char *  warning = 0 
)

Definition at line 234 of file Transport.cxx.

References resip::Data::clear(), dest, resip::Data::Empty, resip::Data::empty(), resip::SipMessage::getSource(), InfoLog, resip::SipMessage::isResponse(), resip::Helper::makeResponse(), makeSendData(), send(), and setRemoteSigcompId().

Referenced by basicCheck().

{
  if (msg.isResponse()) return;

  const Tuple& dest = msg.getSource();

  std::auto_ptr<SipMessage> errMsg(Helper::makeResponse(msg,
                                                        responseCode,
                                                        warning ? warning : "Original request had no Vias"));

  // make send data here w/ blank tid and blast it out.
  // encode message
  Data encoded;
  encoded.clear();
  DataStream encodeStream(encoded);
  errMsg->encode(encodeStream);
  encodeStream.flush();
  assert(!encoded.empty());

  InfoLog(<<"Sending response directly to " << dest << " : " << errMsg->brief() );

  // Calculate compartment ID for outbound message
  Data remoteSigcompId;
   setRemoteSigcompId(*errMsg,remoteSigcompId);
  send(std::auto_ptr<SendData>(makeSendData(dest, encoded, Data::Empty, remoteSigcompId)));
}

Here is the call graph for this function:

std::auto_ptr< SendData > Transport::makeSendData ( const Tuple tuple,
const Data data,
const Data tid,
const Data sigcompId = Data::Empty 
)

Definition at line 226 of file Transport.cxx.

References resip::Tuple::getPort().

Referenced by main(), make100(), make503(), and makeFailedResponse().

{
   assert(dest.getPort() != -1);
   std::auto_ptr<SendData> data(new SendData(dest, d, tid, sigcompId));
   return data;
}

Here is the call graph for this function:

bool Transport::operator== ( const Transport rhs) const

Definition at line 441 of file Transport.cxx.

References boundInterface(), resip::Tuple::isV4(), isV4(), resip::Tuple::length(), mTuple, and port().

{
   return ( ( mTuple.isV4() == rhs.isV4()) &&
            ( port() == rhs.port()) &&
            ( memcmp(&boundInterface(),&rhs.boundInterface(),mTuple.length()) == 0) );
}

Here is the call graph for this function:

virtual void resip::Transport::poke ( ) [inline, virtual]

Called when a writer is done adding messages to the TxFifo; this is used to interrupt the select call if the Transport is running in its own thread.

This does nothing if select is not currently blocking, so don't bother calling this from the same thread that selects on this Transport's fds. Default impl is a no-op.

Reimplemented in resip::InternalTransport.

Definition at line 166 of file Transport.hxx.

{};
int resip::Transport::port ( ) const [inline]
virtual void resip::Transport::process ( FdSet fdset) [pure virtual]

If there is work to do, this is the method that does it.

If the socket is readable, it is read. If the socket is writable and there are outgoing messages to be sent, they are sent.

Incoming messages are parsed and dispatched to the relevant entity. SIP messages will be posted to the TransactionMessage Fifo.

See also:
sendData()
Parameters:
fdsetis the FdSet after select() has been called.
See also:
FdSet::select()

Implements resip::FdSetIOObserver.

Implemented in resip::UdpTransport, FakeTransport, and resip::TcpBaseTransport.

Referenced by resip::TransportThread::thread().

virtual void resip::Transport::process ( ) [pure virtual]

Version of process to be invoked periodically when using callback-based IO (via FdPollGrp).

Implemented in resip::UdpTransport, FakeTransport, and resip::TcpBaseTransport.

void Transport::pushRxMsgUp ( TransactionMessage msg) [virtual]

Definition at line 434 of file Transport.cxx.

References resip::ProducerFifoBuffer< class >::add(), and mStateMachineFifo.

Referenced by resip::ConnectionBase::preparseNewBytes().

Here is the call graph for this function:

virtual void resip::Transport::send ( std::auto_ptr< SendData data) [pure virtual]
Todo:
!bwc! What we do with a SendData is flexible.

It might make a copy, or send synchronously, or convert to another type, etc.

Todo:
!bch! Should this be protected and not public? !bwc! TransportSelector uses this directly for retransmissions.

Implemented in resip::InternalTransport, and FakeTransport.

Referenced by resip::TransportSelector::closeConnection(), resip::TransportSelector::enableFlowTimer(), makeFailedResponse(), resip::ConnectionBase::preparseNewBytes(), resip::TransportSelector::retransmit(), and resip::TransportSelector::transmit().

virtual void resip::Transport::setCongestionManager ( CongestionManager manager) [inline, virtual]

Reimplemented in resip::InternalTransport.

Definition at line 325 of file Transport.hxx.

References mCongestionManager.

      {
         mCongestionManager=manager;
      }
void resip::Transport::setKey ( unsigned int  pKey) [inline, protected]

Definition at line 359 of file Transport.hxx.

References mKey.

Referenced by resip::TransportSelector::addTransportInternal().

{ mKey = pKey;}
virtual void resip::Transport::setPollGrp ( FdPollGrp grp) [pure virtual]
virtual void resip::Transport::setRcvBufLen ( int  buflen) [inline, virtual]

Reimplemented in resip::UdpTransport, and resip::TcpBaseTransport.

Definition at line 348 of file Transport.hxx.

{ };    // make pure?
virtual void resip::Transport::setRecordRoute ( const NameAddr recordRoute) [inline, virtual]

Definition at line 351 of file Transport.hxx.

References mHasRecordRoute, and mRecordRoute.

{ mRecordRoute = recordRoute; mHasRecordRoute = true; }
void Transport::setRemoteSigcompId ( SipMessage msg,
Data id 
)

Definition at line 330 of file Transport.cxx.

References resip::SipMessage::const_header(), resip::Compression::isEnabled(), and mCompression.

Referenced by make100(), make503(), and makeFailedResponse().

{
   if (mCompression.isEnabled())
   {
      try
      {
         const Via &topVia(msg.const_header(h_Vias).front());
         
         if(topVia.exists(p_comp) && topVia.param(p_comp) == "sigcomp")
         {
            if (topVia.exists(p_sigcompId))
            {
               remoteSigcompId = topVia.param(p_sigcompId);
            }
            else
            {
               // XXX rohc-sigcomp-sip-03 says "sent-by",
               // but this should probably be "received" if present,
               // and "sent-by" otherwise.
               // XXX Also, the spec is ambiguous about whether
               // to include the port in this identifier.
               remoteSigcompId = topVia.sentHost();
            }
         }
      }
      catch(BaseException&)
      {
         // ?bwc? Couldn't grab sigcomp compartment id. We don't even know if
         // the initial request was using sigcomp or not. 
         // What should we do here?
      }
   }
}

Here is the call graph for this function:

void resip::Transport::setTlsDomain ( const Data domain) [inline, protected]

Definition at line 371 of file Transport.hxx.

References mTlsDomain.

{ mTlsDomain = domain; }
virtual bool resip::Transport::shareStackProcessAndSelect ( ) const [pure virtual]

Returns true if this Transport should be included in the FdSet processing loop, false if the Transport will provide its own cycles.

If the Transport is going to provide its own cycles, the startOwnProcessing() and shutdown() will be called to tell the Transport when to process.

Return values:
truewill run in the SipStack's processing context
falseprovides own cycles, just puts messages in rxFifo

Implemented in resip::InternalTransport, and FakeTransport.

Referenced by resip::TransportSelector::addTransportInternal().

virtual void resip::Transport::shutdown ( ) [inline, virtual]

This starts shutting-down procedures for this Transport.

New requests may be denied while "mShuttingDown" is true.

Overriding implementations should chain through to this.

Todo:
?dcm? pure virtual protected method to enforce this?
See also:
basicCheck()
isFinished()

Definition at line 310 of file Transport.hxx.

References mShuttingDown.

      {
         // !jf! should use the fifo to pass this in
         mShuttingDown = true;
      }
void Transport::stampReceived ( SipMessage request) [static]

Definition at line 365 of file Transport.cxx.

References resip::SipMessage::const_header(), DebugLog, resip::SipMessage::exists(), resip::Tuple::getPort(), resip::SipMessage::getSource(), resip::SipMessage::header(), resip::Tuple::inet_ntop(), resip::SipMessage::isRequest(), received, and StackLog.

Referenced by resip::ConnectionBase::preparseNewBytes(), and resip::UdpTransport::processRxParse().

{
   // set the received= and rport= parameters in the message if necessary !jf!
   if (message->isRequest() && message->exists(h_Vias) && !message->const_header(h_Vias).empty())
   {
      const Tuple& tuple = message->getSource();
      Data received = Tuple::inet_ntop(tuple);
          if(message->const_header(h_Vias).front().sentHost() != received)  // only add if received address is different from sent-by in Via
      {
         message->header(h_Vias).front().param(p_received) = received;
      }
      //message->header(h_Vias).front().param(p_received) = Tuple::inet_ntop(tuple);
      if (message->const_header(h_Vias).front().exists(p_rport))
      {
         message->header(h_Vias).front().param(p_rport).port() = tuple.getPort();
      }
   }
   DebugLog (<< "incoming from: " << message->getSource());
   StackLog (<< endl << endl << *message);
}

Here is the call graph for this function:

virtual void resip::Transport::startOwnProcessing ( ) [pure virtual]

transports that returned false to shareStackProcessAndSelect() shouldn't put messages into the fifo until this is called

Todo:
?dcm? avoid the received a message but haven't added a transport to the TransportSelector race, but this might not be necessary.

Implemented in resip::InternalTransport, and FakeTransport.

const Data& resip::Transport::tlsDomain ( ) const [inline]
Returns:
the domain name that will be used for TLS, to, for example, find the certificate to present in the TLS handshake.

Definition at line 238 of file Transport.hxx.

References mTlsDomain.

Referenced by resip::TransportSelector::addTransportInternal(), and resip::ConnectionBase::preparseNewBytes().

{ return mTlsDomain; }
virtual TransportType resip::Transport::transport ( ) const [pure virtual]

Friends And Related Function Documentation

EncodeStream& operator<< ( EncodeStream strm,
const Transport rhs 
) [friend]
friend class TransportSelector [friend]

Definition at line 358 of file Transport.hxx.


Member Data Documentation

Definition at line 364 of file Transport.hxx.

Referenced by getRecordRoute(), hasRecordRoute(), and setRecordRoute().

Definition at line 361 of file Transport.hxx.

Referenced by interfaceName(), and Transport().

unsigned int resip::Transport::mKey [protected]

Definition at line 365 of file Transport.hxx.

Referenced by getKey(), and setKey().

Definition at line 363 of file Transport.hxx.

Referenced by getRecordRoute(), and setRecordRoute().

Definition at line 369 of file Transport.hxx.

Referenced by basicCheck(), and shutdown().

Definition at line 376 of file Transport.hxx.

Referenced by setTlsDomain(), and tlsDomain().

unsigned resip::Transport::mTransportFlags [protected]

Definition at line 373 of file Transport.hxx.


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