reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TransactionController.hxx
Go to the documentation of this file.
1#if !defined(RESIP_TRANSACTION_CONTROLLER_HXX)
2#define RESIP_TRANSACTION_CONTROLLER_HXX
3
9
11
12namespace resip
13{
14
15class TransactionMessage;
16class TimerMessage;
17class ApplicationMessage;
18class StatisticsManager;
19class SipStack;
20class Compression;
21class FdPollGrp;
22
24{
25 public:
26 // set after starting at your peril
27 static unsigned int MaxTUFifoSize;
28 static unsigned int MaxTUFifoTimeDepthSecs;
29
30 TransactionController(SipStack& stack, AsyncProcessHandler* handler, bool useDnsVip);
32
33 void process(int timeout=0);
34 unsigned int getTimeTillNextProcessMS();
35
36 // graceful shutdown (eventually)
37 void shutdown();
38
39 TransportSelector& transportSelector() { return mTransportSelector; }
40 const TransportSelector& transportSelector() const { return mTransportSelector; }
41
42 bool isTUOverloaded() const;
43
44 void send(SipMessage* msg);
45
46 unsigned int getTuFifoSize() const;
47 unsigned int sumTransportFifoSizes() const;
48 unsigned int getTransactionFifoSize() const;
49 unsigned int getNumClientTransactions() const;
50 unsigned int getNumServerTransactions() const;
51 unsigned int getTimerQueueSize() const;
52 void zeroOutStatistics();
53 void pollStatistics();
54
56 {
57 mTransportSelector.setCongestionManager(manager);
58 if(mCongestionManager)
59 {
60 mCongestionManager->unregisterFifo(&mStateMacFifo);
61 }
62 mCongestionManager=manager;
63 if(mCongestionManager)
64 {
65 mCongestionManager->registerFifo(&mStateMacFifo);
66 }
67 }
68
70 {
71 if(mCongestionManager)
72 {
73 return mCongestionManager->getRejectionBehavior(&mStateMacFifo);
74 }
76 }
77
78 void registerMarkListener(MarkListener* listener);
80
81 inline bool getFixBadDialogIdentifiers() const
82 {
83 return mFixBadDialogIdentifiers;
84 }
85
86 inline void setFixBadDialogIdentifiers(bool pFixBadDialogIdentifiers)
87 {
88 mFixBadDialogIdentifiers = pFixBadDialogIdentifiers;
89 }
90
91 inline bool getFixBadCSeqNumbers() const { return mFixBadCSeqNumbers;}
92 inline void setFixBadCSeqNumbers(bool pFixBadCSeqNumbers)
93 {
94 mFixBadCSeqNumbers = pFixBadCSeqNumbers;
95 }
96
97 void abandonServerTransaction(const Data& tid);
98 void cancelClientInviteTransaction(const Data& tid, const resip::Tokens* reasons);
99 void addTransport(std::unique_ptr<Transport> transport);
100 void removeTransport(unsigned int transportKey);
101 void terminateFlow(const resip::Tuple& flow);
102 void enableFlowTimer(const resip::Tuple& flow);
103
104 void setInterruptor(AsyncProcessHandler* handler);
105
107
108 private:
110 TransactionController& operator=(const TransactionController& rhs);
111 SipStack& mStack;
112
113 // If true, indicate to the Transaction to ignore responses for which
114 // there is no transaction.
115 // !jf! Probably should transmit stray responses statelessly. see RFC3261
116 bool mDiscardStrayResponses;
117
118 bool mFixBadDialogIdentifiers;
119
120 bool mFixBadCSeqNumbers;
121 // fifo used to communicate to the transaction state machine within the
122 // stack. Not for external use by the application. May contain, sip
123 // messages (requests and responses), timers (used by state machines),
124 // asynchronous dns responses, transport errors from the underlying
125 // transports, etc.
126 Fifo<TransactionMessage> mStateMacFifo;
127 ConsumerFifoBuffer<TransactionMessage> mStateMacFifoOutBuffer;
128 CongestionManager* mCongestionManager;
129
130 //This needs to be separate from mStateMacFifo, because timer messages
131 //need to be processed before other work. (If timers start getting behind
132 //all kinds of nastiness occurs. We can tolerate some SipMessage traffic
133 //getting behind, but processing timers late can cripple the entire
134 //system with state-bloat.)
135 // !bwc! This thing does not need to be threadsafe; it is both populated
136 // and consumed from the same thread.
137 Fifo<TimerMessage> mTimerFifo;
138
139 // from the sipstack (for convenience)
140 TuSelector& mTuSelector;
141
142 // Used to decide which transport to send a sip message on.
143 TransportSelector mTransportSelector;
144
145 // stores all of the transactions that are currently active in this stack
146 TransactionMap mClientTransactionMap;
147 TransactionMap mServerTransactionMap;
148
149 // timers associated with the transactions. When a timer fires, it is
150 // placed in the mStateMacFifo
151 TransactionTimerQueue mTimers;
152
153 bool mShuttingDown;
154
155 StatisticsManager& mStatsManager;
156
157 Data mHostname;
158
159 friend class SipStack; // for debug only
160 friend class StatelessHandler;
161 friend class TransactionState;
162 friend class TransportSelector;
163
164 friend class TestDnsResolver;
165 friend class TestFSM;
166};
167
168
169}
170
171
172#endif
173/* ====================================================================
174 * The Vovida Software License, Version 1.0
175 *
176 * Copyright (c) 2004 Vovida Networks, Inc. All rights reserved.
177 *
178 * Redistribution and use in source and binary forms, with or without
179 * modification, are permitted provided that the following conditions
180 * are met:
181 *
182 * 1. Redistributions of source code must retain the above copyright
183 * notice, this list of conditions and the following disclaimer.
184 *
185 * 2. Redistributions in binary form must reproduce the above copyright
186 * notice, this list of conditions and the following disclaimer in
187 * the documentation and/or other materials provided with the
188 * distribution.
189 *
190 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
191 * and "Vovida Open Communication Application Library (VOCAL)" must
192 * not be used to endorse or promote products derived from this
193 * software without prior written permission. For written
194 * permission, please contact vocal@vovida.org.
195 *
196 * 4. Products derived from this software may not be called "VOCAL", nor
197 * may "VOCAL" appear in their name, without prior written
198 * permission of Vovida Networks, Inc.
199 *
200 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
201 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
202 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
203 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
204 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
205 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
206 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
207 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
208 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
209 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
210 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
211 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
212 * DAMAGE.
213 *
214 * ====================================================================
215 *
216 * This software consists of voluntary contributions made by Vovida
217 * Networks, Inc. and many individuals on behalf of Vovida Networks,
218 * Inc. For more information on Vovida Networks, Inc., please see
219 * <http://www.vovida.org/>.
220 *
221 * vi: set shiftwidth=3 expandtab:
222 */
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 RejectionBehavior getRejectionBehavior(const FifoStatsInterface *fifo) const =0
Return the current rejection behavior for this fifo.
virtual void registerFifo(resip::FifoStatsInterface *fifo)=0
Registers a fifo with the congestion manager.
@ NORMAL
Not rejecting any work.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
A templated, threadsafe message-queue class.
Definition Fifo.hxx:16
Represents a SIP message.
This is the primary point of interaction between the app-layer and the stack.
Definition SipStack.hxx:160
Keeps track of various statistics on the stack's operation, and periodically issues a StatisticsMessa...
const TransportSelector & transportSelector() const
void invokeAfterSocketCreationFunc(TransportType type)
void addTransport(std::unique_ptr< Transport > transport)
void cancelClientInviteTransaction(const Data &tid, const resip::Tokens *reasons)
unsigned int getTransactionFifoSize() const
TransportSelector & transportSelector()
CongestionManager::RejectionBehavior getRejectionBehavior() const
void setFixBadDialogIdentifiers(bool pFixBadDialogIdentifiers)
void setCongestionManager(CongestionManager *manager)
unsigned int getNumClientTransactions() const
void abandonServerTransaction(const Data &tid)
void enableFlowTimer(const resip::Tuple &flow)
void setFixBadCSeqNumbers(bool pFixBadCSeqNumbers)
unsigned int getNumServerTransactions() const
void removeTransport(unsigned int transportKey)
void registerMarkListener(MarkListener *listener)
void unregisterMarkListener(MarkListener *listener)
void terminateFlow(const resip::Tuple &flow)
void setInterruptor(AsyncProcessHandler *handler)
void setCongestionManager(CongestionManager *manager)
Represents a network address.
Definition Tuple.hxx:59
dcm! – add UnusedChecking(_enum) below;
TransportType
An enumeration of transport protocols.