1#if !defined(RESIP_TRANSPORT_HXX)
2#define RESIP_TRANSPORT_HXX
24class TransactionMessage;
65#define RESIP_TRANSPORT_FLAG_NOBIND (1<<0)
66#define RESIP_TRANSPORT_FLAG_RXALL (1<<1)
67#define RESIP_TRANSPORT_FLAG_TXALL (1<<2)
68#define RESIP_TRANSPORT_FLAG_TXNOW (1<<4)
69#define RESIP_TRANSPORT_FLAG_OWNTHREAD (1<<5)
70#define RESIP_TRANSPORT_FLAG_SYMMETRIC_CONNECTIONS (1<<6)
123 const char*
name() const noexcept
override {
return "TransportException"; }
167 const Data& interfaceObj,
171 unsigned transportFlags = 0,
195 virtual void send(std::unique_ptr<SendData> data)=0;
246 const Data& failureString,
247 const std::list<Data> additionalFailureStrings);
268 static void error(
int e);
315 int responseCode = 400,
316 const char * warning =
nullptr);
452 void reportDscp(
int wanted)
const;
The abstract base-class for all exceptions thrown by resip code.
static Compression Disabled
Represents a compression configuration object with compression disabled.
Abstract base class that provides a basic congestion management interface.
virtual RejectionBehavior getRejectionBehavior(const FifoStatsInterface *fifo) const =0
Return the current rejection behavior for this fifo.
@ NORMAL
Not rejecting any work.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
An interface class for elements that use an FdSet to watch for IO.
Object-oriented wrapper for your platform's file-descriptor set.
A templated, threadsafe message-queue class.
Class for buffering messages placed in a Fifo, to be used by a single producer.
Represents a SIP message.
General exception class for Transport.
const char * name() const noexcept override
SipMessageLoggingHandler & operator=(const SipMessageLoggingHandler &)=delete
virtual void outboundMessage(const Tuple &source, const Tuple &destination, const SipMessage &msg)=0
SipMessageLoggingHandler(SipMessageLoggingHandler &&)=delete
SipMessageLoggingHandler()=default
virtual ~SipMessageLoggingHandler()=default
SipMessageLoggingHandler & operator=(SipMessageLoggingHandler &&)=delete
virtual void inboundMessage(const Tuple &source, const Tuple &destination, const SipMessage &msg)=0
virtual void outboundRetransmit(const Tuple &source, const Tuple &destination, const SendData &data)
SipMessageLoggingHandler(const SipMessageLoggingHandler &)=delete
The base class for Transport classes.
virtual bool hasDataToSend() const =0
only applies to transports that shareStackProcessAndSelect
void drainDscpRefresh()
Serves a pending refresh and a pending report.
const Tuple & getTuple() const
virtual bool hasSpecificContact() const
std::unique_ptr< SendData > make503(SipMessage &msg, uint16_t retryAfter)
void setSipMessageLoggingHandlers(const SipMessageLoggingHandlerList &handlers)
void makeFailedResponse(const SipMessage &msg, int responseCode=400, const char *warning=nullptr)
void unsetSipMessageLoggingHandler() noexcept
virtual unsigned int getTimeTillNextProcessMS()
Returns the maximum timeout this object is willing to tolerate on the select call that is to be made,...
IpVersion ipVersion() const
std::atomic< bool > mWasMarkRequested
Whether this transport has asked a socket to carry a class that a clear would have to undo.
AfterSocketCreationFuncPtr mSocketFunc
int effectiveDscp() const
The class to write to a socket right now, or -1 to leave it alone.
const TransportType transport() const
virtual void poke()
Called when a writer is done adding messages to the TxFifo; this is used to interrupt the select call...
virtual void shutdown()
This starts shutting-down procedures for this Transport.
CongestionManager * mCongestionManager
virtual void pushRxMsgUp(SipMessage *msg)
unsigned int getKey() const
std::unique_ptr< SendData > make100(SipMessage &msg)
std::atomic< bool > mDscpReportPending
Set by every setDscp() call, cleared by the owning thread's report, so a reload that changed nothing ...
static void stampReceived(SipMessage *request)
void setTlsDomain(const Data &domain)
static Data errorToString(int e)
SipMessageLoggingHandlerList getSipMessageLoggingHandlers() const noexcept
virtual bool isFinished() const =0
virtual void setCongestionManager(CongestionManager *manager)
const Data & interfaceName() const
const Data & netNs() const
uint32_t getExpectedWaitForIncoming() const
void fail(const Data &tid, TransportFailure::FailureReason reason=TransportFailure::Failure, int subCode=0)
Posts a TransportFailure to the TransactionMessage Fifo.
Compression & mCompression
virtual unsigned int getFifoSize() const =0
std::atomic< int > mDscp
the class to write, -1 for "do not mark"
bool operator==(const Transport &rhs) const
void setKey(unsigned int pKey)
virtual void process(FdSet &fdset)=0
If there is work to do, this is the method that does it.
void callSocketFunc(Socket sock) const
bool basicCheck(const SipMessage &msg)
Perform basic sanity checks on message.
const sockaddr & boundInterface() const
virtual void invokeAfterSocketCreationFunc() const =0
void setSipMessageLoggingHandler(std::shared_ptr< SipMessageLoggingHandler > handler)
virtual void setPollGrp(FdPollGrp *grp)=0
const Data & tlsDomain() const
friend EncodeStream & operator<<(EncodeStream &strm, const Transport &rhs)
bool setDscp(int dscp)
Sets the DSCP class this transport puts on its sockets, and returns whether it was accepted.
virtual bool isReliable() const =0
void applyDscpToOwnSockets()
Re-runs the per-socket set-up on every socket this transport holds – the listener,...
virtual void process()=0
Version of process to be invoked periodically when using callback-based IO (via FdPollGrp).
std::atomic< bool > mDscpRefreshPending
Set by setDscp() when the value changes, cleared by the owning thread's refresh.
void setRemoteSigcompId(SipMessage &msg, Data &id)
virtual void setRcvBufLen(int buflen)
void applySocketOptions(Socket sock) const
The one place a socket of this transport is configured.
virtual bool shareStackProcessAndSelect() const =0
Returns true if this Transport should be included in the FdSet processing loop, false if the Transpor...
CongestionManager::RejectionBehavior getRejectionBehaviorForIncoming() const
static void error(int e)
Generates a generic log for the platform specific socket error number.
ProducerFifoBuffer< TransactionMessage > mStateMachineFifo
void keepAlivePong(const Tuple &flow)
virtual void startOwnProcessing()=0
transports that returned false to shareStackProcessAndSelect() shouldn't put messages into the fifo u...
std::vector< std::shared_ptr< SipMessageLoggingHandler > > SipMessageLoggingHandlerList
virtual bool isShuttingDown()
std::unique_ptr< SendData > makeSendData(const Tuple &tuple, const Data &data, const Data &tid, const Data &sigcompId=Data::Empty)
virtual void buildFdSet(FdSet &fdset)=0
Adds the Transport's socket FD to the appropriate read or write sets as applicable.
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 addSipMessageLoggingHandler(std::shared_ptr< SipMessageLoggingHandler > handler)
virtual void send(std::unique_ptr< SendData > data)=0
virtual Socket getListenerSocket() const
The transport's own listening or bound socket, or INVALID_SOCKET for a transport that holds none.
virtual bool isDatagram() const =0
void setTcpConnectState(const Data &tid, TcpConnectState::State state)
Posts a TcpConnectState to the TransactionMessage Fifo.
Represents a network address.
IpVersion ipVersion() const
Returns V4 or V6 as appropriate.
const Data & getNetNs() const
Get the netns for this Tuple.
TransportType getType() const
const sockaddr & getSockaddr() const
Retrieve a const binary representation of the socket address for this tuple.
TransportKey mTransportKey
dcm! – add UnusedChecking(_enum) below;
void(* AfterSocketCreationFuncPtr)(Socket s, int transportType, const char *file, int line)
TransportType
An enumeration of transport protocols.
IpVersion
An enumeration of IP versions.
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
Represents an IP-address and port (V4 or V6).