reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
resip::InternalTransport Class Reference

#include <InternalTransport.hxx>

Inheritance diagram for resip::InternalTransport:
[legend]

Public Member Functions

 InternalTransport (Fifo< TransactionMessage > &rxFifo, int portNum, IpVersion version, const Data &interfaceObj, AfterSocketCreationFuncPtr socketFunc=0, Compression &compression=Compression::Disabled, unsigned transportFlags=0, const Data &netNs=Data::Empty)
 
virtual ~InternalTransport ()
 
virtual bool isFinished () const
 
virtual bool hasDataToSend () const
 only applies to transports that shareStackProcessAndSelect
 
virtual bool shareStackProcessAndSelect () const
 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 ()
 transports that returned false to shareStackProcessAndSelect() shouldn't put messages into the fifo until this is called
 
void bind ()
 
virtual void setPollGrp (FdPollGrp *grp)
 
virtual unsigned int getFifoSize () const
 
virtual void send (std::unique_ptr< SendData > data)
 
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 setCongestionManager (CongestionManager *manager)
 
virtual void invokeAfterSocketCreationFunc () const
 
- Public Member Functions inherited from resip::Transport
void setSipMessageLoggingHandler (std::shared_ptr< SipMessageLoggingHandler > handler)
 
void addSipMessageLoggingHandler (std::shared_ptr< SipMessageLoggingHandler > handler)
 
void setSipMessageLoggingHandlers (const SipMessageLoggingHandlerList &handlers)
 
void unsetSipMessageLoggingHandler () noexcept
 
SipMessageLoggingHandlerList getSipMessageLoggingHandlers () const noexcept
 
 Transport (Fifo< TransactionMessage > &rxFifo, const GenericIPAddress &address, const Data &tlsDomain=Data::Empty, AfterSocketCreationFuncPtr socketFunc=nullptr, Compression &compression=Compression::Disabled)
 
 Transport (Fifo< TransactionMessage > &rxFifo, int portNum, IpVersion version, const Data &interfaceObj, const Data &tlsDomain=Data::Empty, AfterSocketCreationFuncPtr socketFunc=nullptr, Compression &compression=Compression::Disabled, unsigned transportFlags=0, const Data &netNs=Data::Empty)
 
virtual ~Transport ()
 
virtual void onReload ()
 
std::unique_ptr< SendData > makeSendData (const Tuple &tuple, const Data &data, const Data &tid, const Data &sigcompId=Data::Empty)
 
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 ()
 Returns the maximum timeout this object is willing to tolerate on the select call that is to be made, to prevent starvation of work that is not IO-based.
 
virtual void process ()=0
 Version of process to be invoked periodically when using callback-based IO (via FdPollGrp).
 
void flowTerminated (const Tuple &flow, TransportFailure::FailureReason failureReason, int failureSubCode, const Data &failureString, const std::list< Data > additionalFailureStrings)
 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.
 
void setTcpConnectState (const Data &tid, TcpConnectState::State state)
 Posts a TcpConnectState to the TransactionMessage Fifo.
 
const Data & interfaceName () const
 
int port () const
 
bool isV4 () const
 
IpVersion ipVersion () const
 
const Data & tlsDomain () const
 
const sockaddr & boundInterface () const
 
const Tuple & getTuple () const
 
const TransportType transport () const
 
virtual bool isReliable () const =0
 
virtual bool isDatagram () const =0
 
const Data & netNs () const
 
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=nullptr)
 
std::unique_ptr< SendData > make503 (SipMessage &msg, uint16_t retryAfter)
 
std::unique_ptr< SendData > make100 (SipMessage &msg)
 
void setRemoteSigcompId (SipMessage &msg, Data &id)
 
virtual void shutdown ()
 This starts shutting-down procedures for this Transport.
 
virtual bool isShuttingDown ()
 
bool operator== (const Transport &rhs) const
 
void callSocketFunc (Socket sock) const
 
bool setDscp (int dscp)
 Sets the DSCP class this transport puts on its sockets, and returns whether it was accepted.
 
int effectiveDscp () const
 The class to write to a socket right now, or -1 to leave it alone.
 
int effectiveDscp (int wanted) const
 effectiveDscp() for a value the caller has already read.
 
void applySocketOptions (Socket sock) const
 The one place a socket of this transport is configured.
 
void applyDscpToOwnSockets ()
 Re-runs the per-socket set-up on every socket this transport holds – the listener, and each established connection.
 
CongestionManager::RejectionBehavior getRejectionBehaviorForIncoming () const
 
void flushStateMacFifo ()
 
uint32_t getExpectedWaitForIncoming () const
 
virtual void pushRxMsgUp (SipMessage *msg)
 
virtual void setRcvBufLen (int buflen)
 
unsigned int getKey () const
 
void setKey (unsigned int pKey)
 
- Public Member Functions inherited from resip::FdSetIOObserver
 FdSetIOObserver ()
 
virtual ~FdSetIOObserver ()
 

Static Public Member Functions

static Socket socket (TransportType type, IpVersion ipVer)
 
- Static Public Member Functions inherited from resip::Transport
static void error (int e)
 Generates a generic log for the platform specific socket error number.
 
static Data errorToString (int e)
 
static void stampReceived (SipMessage *request)
 

Protected Member Functions

virtual Socket getListenerSocket () const
 The transport's own listening or bound socket, or INVALID_SOCKET for a transport that holds none.
 
- Protected Member Functions inherited from resip::Transport
void drainDscpRefresh ()
 Serves a pending refresh and a pending report.
 
void setTlsDomain (const Data &domain)
 

Protected Attributes

Socket mFd
 
SelectInterruptor mSelectInterruptor
 
FdPollItemHandle mInterruptorHandle
 
Fifo< SendData > mTxFifo
 
ConsumerFifoBuffer< SendData > mTxFifoOutBuffer
 
FdPollGrp * mPollGrp
 
FdPollItemHandle mPollItemHandle
 
- Protected Attributes inherited from resip::Transport
Data mInterface
 
Tuple mTuple
 
CongestionManager * mCongestionManager
 
ProducerFifoBuffer< TransactionMessage > mStateMachineFifo
 
bool mShuttingDown
 
AfterSocketCreationFuncPtr mSocketFunc
 
Compression & mCompression
 
unsigned mTransportFlags
 
std::atomic< int > mDscp { -1 }
 the class to write, -1 for "do not mark"
 
std::atomic< bool > mDscpRefreshPending { false }
 Set by setDscp() when the value changes, cleared by the owning thread's refresh.
 
std::atomic< bool > mDscpReportPending { false }
 Set by every setDscp() call, cleared by the owning thread's report, so a reload that changed nothing still says what the listener carries.
 
std::atomic< bool > mWasMarkRequested { false }
 Whether this transport has asked a socket to carry a class that a clear would have to undo.
 

Friends

class SipStack
 

Additional Inherited Members

- Public Types inherited from resip::Transport
using SipMessageLoggingHandlerList = std::vector< std::shared_ptr< SipMessageLoggingHandler > >
 

Detailed Description

Definition at line 30 of file InternalTransport.hxx.

Constructor & Destructor Documentation

◆ InternalTransport()

InternalTransport::InternalTransport ( Fifo< TransactionMessage > &  rxFifo,
int  portNum,
IpVersion  version,
const Data &  interfaceObj,
AfterSocketCreationFuncPtr  socketFunc = 0,
Compression &  compression = Compression::Disabled,
unsigned  transportFlags = 0,
const Data &  netNs = Data::Empty 
)

Definition at line 30 of file InternalTransport.cxx.

◆ ~InternalTransport()

InternalTransport::~InternalTransport ( )
virtual

Definition at line 47 of file InternalTransport.cxx.

Member Function Documentation

◆ bind()

void InternalTransport::bind ( )

Definition at line 161 of file InternalTransport.cxx.

◆ getFifoSize()

unsigned int InternalTransport::getFifoSize ( ) const
virtual

Implements resip::Transport.

Definition at line 210 of file InternalTransport.cxx.

◆ getListenerSocket()

virtual Socket resip::InternalTransport::getListenerSocket ( ) const
inlineprotectedvirtual

The transport's own listening or bound socket, or INVALID_SOCKET for a transport that holds none.

Reimplemented from resip::Transport.

Definition at line 89 of file InternalTransport.hxx.

◆ hasDataToSend()

bool InternalTransport::hasDataToSend ( ) const
virtual

only applies to transports that shareStackProcessAndSelect

Implements resip::Transport.

Reimplemented in resip::UdpTransport.

Definition at line 216 of file InternalTransport.cxx.

◆ invokeAfterSocketCreationFunc()

void InternalTransport::invokeAfterSocketCreationFunc ( ) const
virtual

Implements resip::Transport.

Reimplemented in resip::TcpBaseTransport.

Definition at line 270 of file InternalTransport.cxx.

◆ isFinished()

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

Implements resip::Transport.

Definition at line 72 of file InternalTransport.cxx.

◆ poke()

void InternalTransport::poke ( )
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 from resip::Transport.

Definition at line 251 of file InternalTransport.cxx.

◆ send()

void InternalTransport::send ( std::unique_ptr< SendData >  data)
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.

Implements resip::Transport.

Definition at line 222 of file InternalTransport.cxx.

◆ setCongestionManager()

virtual void resip::InternalTransport::setCongestionManager ( CongestionManager *  manager)
inlinevirtual

Reimplemented from resip::Transport.

Definition at line 71 of file InternalTransport.hxx.

◆ setPollGrp()

void InternalTransport::setPollGrp ( FdPollGrp *  grp)
virtual

Implements resip::Transport.

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

Definition at line 228 of file InternalTransport.cxx.

◆ shareStackProcessAndSelect()

virtual bool resip::InternalTransport::shareStackProcessAndSelect ( ) const
inlinevirtual

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

Implements resip::Transport.

Definition at line 49 of file InternalTransport.hxx.

◆ socket()

Socket InternalTransport::socket ( TransportType  type,
IpVersion  ipVer 
)
static

Definition at line 78 of file InternalTransport.cxx.

◆ startOwnProcessing()

virtual void resip::InternalTransport::startOwnProcessing ( )
inlinevirtual

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.

Implements resip::Transport.

Definition at line 55 of file InternalTransport.hxx.

Friends And Related Symbol Documentation

◆ SipStack

friend class SipStack
friend

Definition at line 87 of file InternalTransport.hxx.

Member Data Documentation

◆ mFd

Socket resip::InternalTransport::mFd
protected

Definition at line 91 of file InternalTransport.hxx.

◆ mInterruptorHandle

FdPollItemHandle resip::InternalTransport::mInterruptorHandle
protected

Definition at line 98 of file InternalTransport.hxx.

◆ mPollGrp

FdPollGrp* resip::InternalTransport::mPollGrp
protected

Definition at line 102 of file InternalTransport.hxx.

◆ mPollItemHandle

FdPollItemHandle resip::InternalTransport::mPollItemHandle
protected

Definition at line 104 of file InternalTransport.hxx.

◆ mSelectInterruptor

SelectInterruptor resip::InternalTransport::mSelectInterruptor
protected

Definition at line 97 of file InternalTransport.hxx.

◆ mTxFifo

Fifo<SendData> resip::InternalTransport::mTxFifo
protected

Definition at line 100 of file InternalTransport.hxx.

◆ mTxFifoOutBuffer

ConsumerFifoBuffer<SendData> resip::InternalTransport::mTxFifoOutBuffer
protected

Definition at line 101 of file InternalTransport.hxx.


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