|
reSIProcate
SIP stack, Dialog Usage Manager and related libraries
|
The base class for Transport classes. More...
#include <Transport.hxx>
Classes | |
| class | Exception |
| General exception class for Transport. More... | |
| class | SipMessageLoggingHandler |
Public Types | |
| using | SipMessageLoggingHandlerList = std::vector< std::shared_ptr< SipMessageLoggingHandler > > |
Public Member Functions | |
| 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 () |
| virtual bool | isFinished () const =0 |
| std::unique_ptr< SendData > | makeSendData (const Tuple &tuple, const Data &data, const Data &tid, const Data &sigcompId=Data::Empty) |
| virtual void | send (std::unique_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 () |
| 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). | |
| virtual void | setPollGrp (FdPollGrp *grp)=0 |
| 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 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. | |
| virtual bool | isShuttingDown () |
| bool | operator== (const Transport &rhs) const |
| virtual unsigned int | getFifoSize () const =0 |
| void | callSocketFunc (Socket sock) const |
| virtual void | invokeAfterSocketCreationFunc () const =0 |
| 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. | |
| virtual void | setCongestionManager (CongestionManager *manager) |
| 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 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 | |
| void | drainDscpRefresh () |
| Serves a pending refresh and a pending report. | |
| virtual Socket | getListenerSocket () const |
| The transport's own listening or bound socket, or INVALID_SOCKET for a transport that holds none. | |
| void | setTlsDomain (const Data &domain) |
Protected Attributes | |
| 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 | |
| EncodeStream & | operator<< (EncodeStream &strm, const Transport &rhs) |
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 82 of file Transport.hxx.
| using resip::Transport::SipMessageLoggingHandlerList = std::vector<std::shared_ptr<SipMessageLoggingHandler> > |
Definition at line 105 of file Transport.hxx.
| Transport::Transport | ( | Fifo< TransactionMessage > & | rxFifo, |
| const GenericIPAddress & | address, | ||
| const Data & | tlsDomain = Data::Empty, |
||
| AfterSocketCreationFuncPtr | socketFunc = nullptr, |
||
| Compression & | compression = Compression::Disabled |
||
| ) |
| rxFifo | the TransactionMessage Fifo that will receive any ConnectionTerminated or TransportFailure messages. |
| tlsDomain | the domain name of the Transport |
| socketFunc | subclassers can call this function after the socket is created. This is not currently used by Transport. |
Definition at line 73 of file Transport.cxx.
| Transport::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 |
||
| ) |
| rxFifo | the TransactionMessage Fifo that will receive any ConnectionTerminated or TransportFailure messages. |
| interfaceObj | a "presentation format" representation of the IP address of this transport |
| portNum | is the port to receive and/or send on |
| tlsDomain | the domain name of the Transport |
| socketFunc | subclassers can call this function after the socket is created. This is not currently used by Transport. |
Definition at line 94 of file Transport.cxx.
|
virtual |
Definition at line 115 of file Transport.cxx.
| void Transport::addSipMessageLoggingHandler | ( | std::shared_ptr< SipMessageLoggingHandler > | handler | ) |
Definition at line 42 of file Transport.cxx.
| void Transport::applyDscpToOwnSockets | ( | ) |
Re-runs the per-socket set-up on every socket this transport holds – the listener, and each established connection.
Call this directly only while the transport is still single-threaded, before its processing thread starts. Once it is running, ask through setDscp() instead: the traversal walks the list of connections that thread owns.
Definition at line 144 of file Transport.cxx.
| void Transport::applySocketOptions | ( | Socket | sock | ) | const |
The one place a socket of this transport is configured.
Puts the effective DSCP class on {sock}, then hands it to the user's AfterSocketCreationFunc. Every site that configures a socket – the listener, an accepted connection, an outgoing connection – routes through here, so a socket cannot be created without passing it.
Definition at line 607 of file Transport.cxx.
| bool Transport::basicCheck | ( | const SipMessage & | msg | ) |
Perform basic sanity checks on message.
Return false if there is a problem eg) no Vias.
Definition at line 531 of file Transport.cxx.
|
inline |
Definition at line 287 of file Transport.hxx.
|
pure virtual |
Adds the Transport's socket FD to the appropriate read or write sets as applicable.
Implements resip::FdSetIOObserver.
Implemented in resip::DtlsTransport, resip::TcpBaseTransport, and resip::UdpTransport.
| void Transport::callSocketFunc | ( | Socket | sock | ) | const |
Definition at line 622 of file Transport.cxx.
|
protected |
Serves a pending refresh and a pending report.
Called by the owning thread at the top of its processing cycle.
Definition at line 125 of file Transport.cxx.
| int Transport::effectiveDscp | ( | ) | const |
The class to write to a socket right now, or -1 to leave it alone.
| mDscp | mWasMarkRequested | result |
|---|---|---|
| >= 0 | any | mDscp |
| -1 | true | 0, undo the mark we made |
| -1 | false | -1, never marked, leave the socket alone |
The last two rows are why a mark is tracked at all: undoing one and never having made one are different actions.
Definition at line 590 of file Transport.cxx.
| int Transport::effectiveDscp | ( | int | wanted | ) | const |
effectiveDscp() for a value the caller has already read.
A traversal has to read mDscp exactly once – a value that changes while it runs raises its own request, and reading again would mix the two passes.
Definition at line 596 of file Transport.cxx.
|
static |
Generates a generic log for the platform specific socket error number.
| e | the socket error number |
Definition at line 203 of file Transport.cxx.
|
static |
Definition at line 212 of file Transport.cxx.
| void Transport::fail | ( | const Data & | tid, |
| TransportFailure::FailureReason | reason = TransportFailure::Failure, |
||
| int | subCode = 0 |
||
| ) |
Posts a TransportFailure to the TransactionMessage Fifo.
Definition at line 352 of file Transport.cxx.
| void Transport::flowTerminated | ( | const Tuple & | flow, |
| TransportFailure::FailureReason | failureReason, | ||
| int | failureSubCode, | ||
| const Data & | failureString, | ||
| const std::list< Data > | additionalFailureStrings | ||
| ) |
Posts a ConnectionTerminated message to TransactionMessage Fifo.
Definition at line 340 of file Transport.cxx.
|
inline |
Definition at line 470 of file Transport.hxx.
|
inline |
Definition at line 475 of file Transport.hxx.
|
pure virtual |
Implemented in resip::InternalTransport.
|
inline |
Definition at line 486 of file Transport.hxx.
|
inlineprotectedvirtual |
The transport's own listening or bound socket, or INVALID_SOCKET for a transport that holds none.
Reimplemented in resip::InternalTransport.
Definition at line 495 of file Transport.hxx.
|
inline |
Definition at line 461 of file Transport.hxx.
|
noexcept |
Definition at line 63 of file Transport.cxx.
|
inlinevirtual |
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.
Implements resip::FdSetIOObserver.
Definition at line 229 of file Transport.hxx.
|
inline |
Definition at line 288 of file Transport.hxx.
|
pure virtual |
only applies to transports that shareStackProcessAndSelect
Implemented in resip::InternalTransport, and resip::UdpTransport.
|
inlinevirtual |
Definition at line 302 of file Transport.hxx.
|
inline |
Definition at line 272 of file Transport.hxx.
|
pure virtual |
Implemented in resip::InternalTransport, and resip::TcpBaseTransport.
|
inline |
Definition at line 279 of file Transport.hxx.
|
pure virtual |
Implemented in resip::DtlsTransport, resip::TcpBaseTransport, and resip::UdpTransport.
|
pure virtual |
Implemented in resip::InternalTransport.
|
pure virtual |
Implemented in resip::DtlsTransport, resip::TcpBaseTransport, and resip::UdpTransport.
|
inlinevirtual |
Definition at line 366 of file Transport.hxx.
|
inline |
Definition at line 277 of file Transport.hxx.
| void Transport::keepAlivePong | ( | const Tuple & | flow | ) |
Definition at line 346 of file Transport.cxx.
| std::unique_ptr< SendData > Transport::make100 | ( | SipMessage & | msg | ) |
Definition at line 442 of file Transport.cxx.
| std::unique_ptr< SendData > Transport::make503 | ( | SipMessage & | msg, |
| uint16_t | retryAfter | ||
| ) |
Definition at line 408 of file Transport.cxx.
| void Transport::makeFailedResponse | ( | const SipMessage & | msg, |
| int | responseCode = 400, |
||
| const char * | warning = nullptr |
||
| ) |
Definition at line 378 of file Transport.cxx.
| std::unique_ptr< SendData > Transport::makeSendData | ( | const Tuple & | tuple, |
| const Data & | data, | ||
| const Data & | tid, | ||
| const Data & | sigcompId = Data::Empty |
||
| ) |
Definition at line 370 of file Transport.cxx.
|
inline |
Definition at line 296 of file Transport.hxx.
|
virtual |
Reimplemented in resip::TlsBaseTransport.
Definition at line 120 of file Transport.cxx.
| bool Transport::operator== | ( | const Transport & | rhs | ) | const |
Definition at line 642 of file Transport.cxx.
|
inlinevirtual |
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 204 of file Transport.hxx.
|
inline |
Definition at line 274 of file Transport.hxx.
|
pure virtual |
Version of process to be invoked periodically when using callback-based IO (via FdPollGrp).
Implemented in resip::TcpBaseTransport, and resip::UdpTransport.
|
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.
| fdset | is the FdSet after select() has been called. |
Implements resip::FdSetIOObserver.
Implemented in resip::DtlsTransport, resip::TcpBaseTransport, and resip::UdpTransport.
|
virtual |
Definition at line 631 of file Transport.cxx.
|
pure virtual |
Implemented in resip::InternalTransport.
|
inlinevirtual |
Reimplemented in resip::InternalTransport.
Definition at line 456 of file Transport.hxx.
| bool Transport::setDscp | ( | int | dscp | ) |
Sets the DSCP class this transport puts on its sockets, and returns whether it was accepted.
The range is 0 to 63; -1 asks for no marking, and is the state of a transport this was never called on. Callable from any thread.
A value outside -1..63 is refused and the transport keeps the one it had. A value that differs schedules a refresh of the sockets this transport already holds, which it serves from its own processing cycle – and with it, the AfterSocketCreationFunc a user installed. Setting the same value again schedules no refresh, so a service may call this on every configuration reload.
Definition at line 568 of file Transport.cxx.
|
inline |
Definition at line 487 of file Transport.hxx.
|
pure virtual |
Implemented in resip::InternalTransport, resip::TcpBaseTransport, and resip::UdpTransport.
|
inlinevirtual |
Reimplemented in resip::TcpBaseTransport, and resip::UdpTransport.
Definition at line 484 of file Transport.hxx.
| void Transport::setRemoteSigcompId | ( | SipMessage & | msg, |
| Data & | id | ||
| ) |
Definition at line 474 of file Transport.cxx.
| void Transport::setSipMessageLoggingHandler | ( | std::shared_ptr< SipMessageLoggingHandler > | handler | ) |
Definition at line 31 of file Transport.cxx.
| void Transport::setSipMessageLoggingHandlers | ( | const SipMessageLoggingHandlerList & | handlers | ) |
Definition at line 51 of file Transport.cxx.
| void Transport::setTcpConnectState | ( | const Data & | tid, |
| TcpConnectState::State | state | ||
| ) |
Posts a TcpConnectState to the TransactionMessage Fifo.
Definition at line 361 of file Transport.cxx.
|
inlineprotected |
Definition at line 504 of file Transport.hxx.
|
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.
| true | will run in the SipStack's processing context |
| false | provides own cycles, just puts messages in rxFifo |
Implemented in resip::InternalTransport.
|
inlinevirtual |
This starts shutting-down procedures for this Transport.
New requests may be denied while "mShuttingDown" is true.
Overriding implementations should chain through to this.
Definition at line 361 of file Transport.hxx.
|
static |
Definition at line 509 of file Transport.cxx.
|
pure virtual |
transports that returned false to shareStackProcessAndSelect() shouldn't put messages into the fifo until this is called
Implemented in resip::InternalTransport.
|
inline |
Definition at line 286 of file Transport.hxx.
|
inline |
Definition at line 291 of file Transport.hxx.
|
noexcept |
Definition at line 57 of file Transport.cxx.
|
friend |
|
protected |
Definition at line 514 of file Transport.hxx.
|
protected |
Definition at line 500 of file Transport.hxx.
|
protected |
the class to write, -1 for "do not mark"
Definition at line 518 of file Transport.hxx.
|
protected |
Set by setDscp() when the value changes, cleared by the owning thread's refresh.
Sequentially consistent on purpose: under a relaxed order that refresh could see the request and still read the previous mDscp.
Definition at line 522 of file Transport.hxx.
|
protected |
Set by every setDscp() call, cleared by the owning thread's report, so a reload that changed nothing still says what the listener carries.
Definition at line 525 of file Transport.hxx.
|
protected |
Definition at line 497 of file Transport.hxx.
|
protected |
Definition at line 502 of file Transport.hxx.
|
protected |
Definition at line 513 of file Transport.hxx.
|
protected |
Definition at line 501 of file Transport.hxx.
|
protected |
Definition at line 515 of file Transport.hxx.
|
protected |
Definition at line 498 of file Transport.hxx.
|
mutableprotected |
Whether this transport has asked a socket to carry a class that a clear would have to undo.
Definition at line 528 of file Transport.hxx.