1#if !defined(RESIP_SIPSTACK_HXX)
2#define RESIP_SIPSTACK_HXX
33#define RESIP_SIPSTACK_HAVE_FDPOLL 1
38class ApplicationMessage;
44class StatisticsManager;
47class TransactionControllerThread;
48class TransportSelectorThread;
50class AsyncProcessHandler;
223 bool stateless=
false,
227 bool useDnsVip =
false);
303 const char*
name() const noexcept
override {
return "SipStack::Exception"; }
406 unsigned transportFlags = 0,
407 const Data& certificateFilename =
"",
408 const Data& privateKeyFilename =
"",
410 bool useEmailAsSIP =
false,
411 std::shared_ptr<WsConnectionValidator> =
nullptr,
412 std::shared_ptr<WsCookieContextFactory> =
nullptr,
423 void addTransport(std::unique_ptr<Transport> transport);
590 void post(std::unique_ptr<ApplicationMessage> message,
591 unsigned int secondsLater,
606 void postMS(std::unique_ptr<ApplicationMessage> message,
622 void post(std::unique_ptr<ApplicationMessage> message,
623 std::chrono::duration<double> interval,
633 void post(std::unique_ptr<ApplicationMessage> message);
696 std::chrono::duration<double> interval,
852 bool process(
unsigned int timeoutMs);
1024 return mTransactionController->mFixBadDialogIdentifiers;
1042 mTransactionController->mFixBadDialogIdentifiers = pFixBadDialogIdentifiers;
1131 if(mCongestionManager)
1135 mCongestionManager=manager;
1136 if(mCongestionManager)
1179 void checkAsyncProcessHandler();
1182 bool mPollGrpIsMine;
1203 bool mInterruptorIsMine;
1221 mutable Mutex mAppTimerMutex;
1236 bool mInternalThreadsRunning;
1237 bool mProcessingHasStarted;
1242 typedef std::unordered_map<Data, unsigned int> DomainsMap;
1243 DomainsMap mDomains;
1245 mutable Mutex mDomainsMutex;
1249 std::map<int, unsigned int> mPorts;
1250 mutable Mutex mPortsMutex;
1256 typedef std::map<Tuple, Transport*> NonSecureTransportMap;
1257 NonSecureTransportMap mNonSecureTransports;
1258 typedef std::map<TransportSelector::TlsTransportKey, Transport*> SecureTransportMap;
1259 SecureTransportMap mSecureTransports;
1262 mutable Mutex mShutdownMutex;
1263 volatile bool mStatisticsManagerEnabled;
1267 unsigned int mNextTransportKey;
1289 tup.onlyUseExistingConnection =
true;
#define resip_assert(x)
This file needs to work for both C and C++ code.
A base-class for messages used by applications.
The abstract base-class for all exceptions thrown by resip code.
Abstract base class that provides a basic congestion management interface.
virtual void unregisterFifo(resip::FifoStatsInterface *fifo)=0
Unregisters a fifo with the congestion manager.
virtual void registerFifo(resip::FifoStatsInterface *fifo)=0
Registers a fifo with the congestion manager.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
static NameserverList EmptyNameserverList
std::vector< GenericIPAddress > NameserverList
Interface functor for external stats handling.
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.
The base-class used for message-passing.
Represents a SIP message.
static bool checkContentLength
This class holds constructor-time initialization arguments for SipStack.
Compression * mCompression
AfterSocketCreationFuncPtr mSocketFunc
const DnsStub::NameserverList * mExtraNameserverList
AsyncProcessHandler * mAsyncProcessHandler
thrown when the stack is unable to function.
const char * name() const noexcept override
what gets called instead of the pure virtual in the base
Exception(const Data &msg, const Data &file, const int line)
constructor
This is the primary point of interaction between the app-layer and the stack.
Fifo< TransactionMessage > & stateMacFifo()
Returns the fifo that subclasses of Transport should use for the rxFifo cons.
void shutdownAndJoinThreads()
Shutdown and join any threads that the SipStack is running.
static Data getHostname()
Get one of the names for this host (calls through to gethostbyname) and is not threadsafe.
Security * getSecurity() const
Returns a pointer to the embedded Security object, 0 if not set.
DnsStub & getDnsStub() const
EncodeStream & dump(EncodeStream &strm) const
output current state of the stack - for debug
void clearDnsCache()
Clear the DNS Cache.
void invokeAfterSocketCreationFunc(TransportType type=UNKNOWN_TRANSPORT)
void getDnsCacheDump(std::pair< unsigned long, unsigned long > key, GetDnsCacheDumpHandler *handler)
Get a string representation of the DNS Cache.
bool isMyPort(int port) const
Returns true if port is handled by this stack.
void setExternalStatsHandler(ExternalStatsHandler *handler)
Installs a handler for the stacks internal StatisticsManager.
void send(const SipMessage &msg, TransactionUser *tu=0)
allows a TU to send a message
Transport * addTransport(TransportType protocol, int port, IpVersion version=V4, StunSetting stun=StunDisabled, const Data &ipInterface=Data::Empty, const Data &sipDomainname=Data::Empty, const Data &privateKeyPassPhrase=Data::Empty, SecurityTypes::SSLType sslType=SecurityTypes::DynamicTLS, unsigned transportFlags=0, const Data &certificateFilename="", const Data &privateKeyFilename="", SecurityTypes::TlsClientVerificationMode cvm=SecurityTypes::None, bool useEmailAsSIP=false, std::shared_ptr< WsConnectionValidator >=nullptr, std::shared_ptr< WsCookieContextFactory >=nullptr, const Data &netNs=Data::Empty)
Used by the application to add in a new built-in transport.
friend class TestDnsResolver
void cancelClientInviteTransaction(const Data &tid, const Tokens *reasons)
Tells the stack that the TU wishes to CANCEL an INVITE request.
void setFixBadCSeqNumbers(bool pFixBadCSeqNumbers)
void reloadCertificates()
reload the TLS X.509 certificates
void setFallbackPostNotify(AsyncProcessHandler *handler)
virtual void process(FdSet &fdset)
This allows the executive to give processing time to stack components.
bool isMyDomain(const Data &domain, int port) const
Returns true if domain is handled by this stack.
SipMessage * receive()
retrieve a SipMessage off the old TuFifo
void addTransportSipMessageLoggingHandler(std::shared_ptr< Transport::SipMessageLoggingHandler > handler)
Used by the application to provide a handler that will get called for all inbound and outbound SIP me...
void registerTransactionUser(TransactionUser &, const bool front=false)
add a TU to the TU selection chain
void removeTransport(unsigned int transportKey)
Used to remove a previously added transport.
static Data getHostAddress()
Get one of the IP address for this host (calls through to gethostbyname) and is not threadsafe.
void shutdown()
perform orderly shutdown
void abandonServerTransaction(const Data &tid)
Tells the stack that the TU has abandoned a server transaction.
void onReload()
reload configuration
bool setUdpOnlyOnNumeric(bool value)
virtual unsigned int getTimeTillNextProcessMS()
Returns time in milliseconds when process next needs to be called.
void terminateFlow(const resip::Tuple &flow)
void logDnsCache()
Log the DNS Cache to WarningLog for Debugging.
void post(std::unique_ptr< ApplicationMessage > message, unsigned int secondsLater, TransactionUser *tu=0)
Makes the message available to the TU at some later time, specified in seconds.
void sendTo(std::unique_ptr< SipMessage > msg, const Uri &uri, TransactionUser *tu=0)
this is only if you want to send to a destination not in the route.
void unregisterTransactionUser(TransactionUser &)
Removes a TU from the TU selection chain.
const StatisticsManager * getStatisticsManager()
get statistics manager
virtual void buildFdSet(FdSet &fdset)
Build the FD set to use in a select to find out when process(FdSet&) must be called again.
void requestTransactionUserShutdown(TransactionUser &)
Queue a shutdown request to the specified TU.
void setTransportSipMessageLoggingHandler(std::shared_ptr< Transport::SipMessageLoggingHandler > handler)
Used by the application to provide a handler that will get called for all inbound and outbound SIP me...
bool getFixBadCSeqNumbers() const
void zeroOutStatistics()
Resets all of the cumulative statistics counters.
const Uri & getUri() const
Get one of the domains/ports that are handled by this stack in Uri form.
void enableFlowTimer(const resip::Tuple &flow)
void run()
Causes this SipStack object to create and run threads for carrying out processing.
bool pollStatistics()
Immediately polls for statistics to be logged and sent to external handlers, instead of waiting for n...
bool hasMessage() const
does the stack have new messages for the TU?
void reloadDnsServers()
Check if DnsServers list has changed, and if so reinitializes the DNS resolver (ares).
bool getUdpOnlyOnNumeric() const
void postMS(std::unique_ptr< ApplicationMessage > message, unsigned int ms, TransactionUser *tu=0)
Makes the message available to the TU at some later time, specified in milli-seconds.
void sendOverExistingConnection(const SipMessage &msg, const Tuple &tuple, TransactionUser *tu=0)
force the a message out over an existing connection
virtual void processTimers()
Check all timers.
Message * receiveAny()
retrieve a message off the old TuFifo
Keeps track of various statistics on the stack's operation, and periodically issues a StatisticsMessa...
TransportSelector & transportSelector()
void setCongestionManager(CongestionManager *manager)
void setFixBadCSeqNumbers(bool pFixBadCSeqNumbers)
bool getFixBadCSeqNumbers() const
The base-class for an RFC 3261 Transaction User.
bool setUdpOnlyOnNumeric(bool value)
bool getUdpOnlyOnNumeric() const
The base class for Transport classes.
std::vector< std::shared_ptr< SipMessageLoggingHandler > > SipMessageLoggingHandlerList
void setCongestionManager(CongestionManager *manager)
Represents a network address.
FlowKey mFlowKey
This is a (largely) opaque key that subclasses of Transport will use to help record/find flows.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
#define RESIP_DEPRECATED(x)
void unregisterMarkListener(MarkListener *listener)
Removed a registered BlacklistListener handler from the DNS Interface for a particualr Resource Recor...
CongestionManager * getCongestionManager()
Accessor for the CongestionManager object the stack is using.
volatile bool & statisticsManagerEnabled()
Enable Statistics Manager.
void addAlias(const Data &domain, int port)
add an alias for this sip element
void registerMarkListener(MarkListener *listener)
Register a handler with the DNS Interface for notifications of when a Dns Resource Record has been bl...
void setEnumSuffixes(const std::vector< Data > &suffixes)
Specify which enum domains will be searched when sending.
void setFixBadDialogIdentifiers(bool pFixBadDialogIdentifiers)
Specify whether the stack should fix corrupted/changed dialog identifiers (ie, Call-Id and tags) in r...
bool getFixBadDialogIdentifiers() const
Returns whether the stack is fixing corrupted/changed dialog identifiers (ie, Call-Id and tags) in re...
void setEnumDomains(const std::map< Data, Data > &domains)
Specify which domains in the To: Uri will be subject to ENUM.
void setCongestionManager(CongestionManager *manager)
Sets the CongestionManager used by the stack.
void setContentLengthChecking(bool check)
Used to enable/disable content-length checking on datagram-based transports.
void removeAlias(const Data &domain, int port)
removes an alias from this sip element
void setExternalStatsHandler(ExternalStatsHandler *handler)
Allows the application to set the ExternalStatsHandler for this StatisticsManager.
void setStatisticsInterval(unsigned long seconds)
Sets the interval that determines the time between Statistics messages.
Compression & getCompression()
Accessor for the Compression object the stack is using.
TlsClientVerificationMode
SSLType
Note: Before adding to the SSLType enum, please see the comments about mTlsCtx in resip/stack/ssl/Sec...
dcm! – add UnusedChecking(_enum) below;
void(* AfterSocketCreationFuncPtr)(Socket s, int transportType, const char *file, int line)
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
TransportType
An enumeration of transport protocols.
IpVersion
An enumeration of IP versions.
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)