📄 sipstack.hxx
字号:
@param message ApplicationMessage to post
@param secondsLater Number of seconds before message is to be posted.
@param tu TransactionUser to post to.
*/
void post(const ApplicationMessage& message, unsigned int secondsLater,
TransactionUser* tu=0);
/**
Makes the message available to the TU at some later time - specified in
milli-seconds. Makes a copy of the ApplicationMessage. Caller is
responsible for deleting the memory and may do so as soon as it returns.
Note: TranasctionUser subclasses can just post to themselves.
@param message ApplicationMessage to post
@param ms Number of milli-seconds before message is to be posted.
@param tu TransactionUser to post to.
*/
void postMS(const ApplicationMessage& message, unsigned int ms,
TransactionUser* tu=0);
/**
Return true if the stack has new messages for the TU. Since the addition
of TransactionUsers, this method is deprecated. This only looks into the
old TuFifo that is not associated with any TransactionUser.
@deprecated
*/
bool hasMessage() const;
/**
Retrieve a SipMessage off the old TuFifo. Caller now owns the memory. Returns
0 if nothing there. Since the addition of TransactionUsers, this method
is deprecated. This only looks into the old TuFifo that is not associated
with any TransactionUser.
Note: Applications posting non-sip messages must use receive any. If non
SipMessages are on the Fifo, then they are just deleted.
@deprecated
@returns pointer to received SipMessage, 0 if nothing there.
*/
SipMessage* receive();
/**
Retrieve a Message off the old TuFifo. Caller now owns the memory. Returns
0 if nothing there. Since the addition of TransactionUsers, this method
is deprecated. This only looks into the old TuFifo that is not associated
with any TransactionUser.
Note: Applications posting non-sip messages must use receive any. If non
SipMessages are on the Fifo, then they are just deleted.
@deprecated
@returns pointer to received Message, 0 if nothing there. May return
TransactionTerminated*, TimerMessage*, SipMessage* or derived
ApplicationMessage*
*/
Message* receiveAny();
/**
Build the FD set to use in a select to find out when process must be
called again. This must be called prior to calling process.
Note: select must also be called on the fdset prior to process.
@param fdset an empty or partially populated fdset, fd's are added
to the fdset on return
*/
virtual void buildFdSet(FdSet& fdset);
/**
This allows the executive to give processing time to stack components.
Must call buildFdSet and select before calling this.
@param fdset a populated and 'select'ed fdset
*/
virtual void process(FdSet& fdset);
/// returns time in milliseconds when process next needs to be called
virtual unsigned int getTimeTillNextProcessMS();
/// Sets the interval that determines the time between Statistics messages
void setStatisticsInterval(unsigned long seconds);
/// output current state of the stack - for debug
std::ostream& dump(std::ostream& strm) const;
/// Returns a pointer to the embedded Security object, 0 if not set
Security* getSecurity() const;
/**
Adds a TU to the TU selection chain. Tu's do not call receive or
receiveAny, the SipStack will call postToTu on the appropriate
Tu. Messages not associated with a registered TU go into SipStack::mTuFifo.
*/
void registerTransactionUser(TransactionUser&);
/// Queue a shutdown request to the specified TU
void requestTransactionUserShutdown(TransactionUser&);
/// Removes a TU from the TU selection chain
void unregisterTransactionUser(TransactionUser&);
/**
Register a handler with the DNS Interface for notifications of when a Dns
Resource Record has been blacklisted.
@param rrType Resource Record type you are interested in receiving
notifications for
@param BlackListListener Class implementing the onBlacklisted callback
event sink defined in BlackListListener
*/
void registerBlacklistListener(int rrType, DnsStub::BlacklistListener*);
/**
Removed a registered BlacklistListener handler from the DNS Interface
for a particualr Resource Record type and handler pointer.
@param rrType Resource Record type
@param BlackListListener Pointer to the class implementing the
BlackListListener event sink
*/
void unregisterBlacklistListener(int rrType, DnsStub::BlacklistListener*);
DnsStub& getDnsStub() const;
/**
Specify which enum domains will be searched when sending to URIs that
return true to Uri::isEnumSearchable(). An enum query will be done for
each suffix in parallel.
*/
void setEnumSuffixes(const std::vector<Data>& suffixes);
/**
Clear the DNS Cache
*/
void clearDnsCache();
/**
Log the DNS Cache to WarningLog for Debugging
*/
void logDnsCache();
/**
Enable Statistics Manager. SIP Statistics will be collected and
dispatched periodically via a StatisticsMessage. Note: By default
the Statistics Manager is enabled.
*/
volatile bool& statisticsManagerEnabled();
const bool statisticsManagerEnabled() const;
void setContentLengthChecking(bool check)
{
SipMessage::checkContentLength=check;
}
Compression &getCompression() { return *mCompression; }
private:
/// Notify an async process handler - if one has been registered
void checkAsyncProcessHandler();
/// if this object exists, it manages advanced security featues
Security* mSecurity;
DnsStub* mDnsStub;
/// If this object exists, it manages compression parameters
Compression* mCompression;
/// if this object exists, it gets notified when ApplicationMessage's get posted
AsyncProcessHandler* mAsyncProcessHandler;
/// Disallow copy, by not implementing
SipStack(const SipStack& copy);
/// Disallow assignment, by not implementing
SipStack& operator=(const SipStack& rhs);
/** fifo used to communicate between the TU (Transaction User) and stack
Note: since the introduction of multiple TU's this Fifo should no
longer be used by most applications - each TU now owns it's own Fifo. */
TimeLimitFifo<Message> mTUFifo;
/// Protection for AppTimerQueue
mutable Mutex mAppTimerMutex;
/** timers associated with the application. When a timer fires, it is
placed in the mTUFifo (if there is not associated TU), or it is placed
on the fifo of the appropriate TU */
TuSelectorTimerQueue mAppTimers;
/// Used to Track stack statistics
StatisticsManager mStatsManager;
/// All aspects of the Transaction State Machine / DNS resolver
TransactionController mTransactionController;
/** store all domains that this stack is responsible for. Controlled by
addAlias and addTransport interfaces and checks can be made with isMyDomain() */
std::set<Data> mDomains;
bool mShuttingDown;
volatile bool mStatisticsManagerEnabled;
/// Responsible for routing messages to the correct TU based on installed rules
TuSelector mTuSelector;
AfterSocketCreationFuncPtr mSocketFunc;
friend class Executive;
friend class StatelessHandler;
friend class StatisticsManager;
friend class TestDnsResolver;
friend class TestFSM;
friend class TransactionState;
friend class TransactionController;
friend class TuSelector;
};
std::ostream& operator<<(std::ostream& strm, const SipStack& stack);
inline void
SipStack::sendOverExistingConnection(const SipMessage& msg, const Tuple& tuple,
TransactionUser* tu)
{
assert(tuple.transport);
assert(tuple.connectionId);
Tuple tup(tuple);
tup.onlyUseExistingConnection = true;
sendTo(msg, tuple, tu);
}
}
#endif
/* ====================================================================
* The Vovida Software License, Version 1.0
*
* Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The names "VOCAL", "Vovida Open Communication Application Library",
* and "Vovida Open Communication Application Library (VOCAL)" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact vocal@vovida.org.
*
* 4. Products derived from this software may not be called "VOCAL", nor
* may "VOCAL" appear in their name, without prior written
* permission of Vovida Networks, Inc.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* ====================================================================
*
* This software consists of voluntary contributions made by Vovida
* Networks, Inc. and many individuals on behalf of Vovida Networks,
* Inc. For more information on Vovida Networks, Inc., please see
* <http://www.vovida.org/>.
*
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -