/[resiprocate]/main/sip/resiprocate/SipStack.hxx
ViewVC logotype

Contents of /main/sip/resiprocate/SipStack.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4740 - (show annotations) (download)
Tue May 24 21:30:57 2005 UTC (14 years, 6 months ago) by daniel
File size: 10854 byte(s)
AresDns.hxx/cxx: Redefined lookup and ares callback methonds.
DnsInterface.hxx/cxx: Added dns caching support and  methods to (un)register blacklist listener.
DnsResult.hxx/cxx: Modified to use dns caching, blacklisting, and vip; removed dead code.
Makefile: Added dns cache related files.
Security.hxx/cxx: correctly handle default paths in the constructor
SipStack.hxx/cxx: Added blacklist listener registration and unregistration.
StatelessHandler.cxx: Got it to compile with USE_IPV6 defined.
TlsConnection.cxx: Make logging less verbose.
TransactionController.hxx/cxx: Added blacklist listener registration and unregistration.
TransactionState.cxx: Added whitelisting(vip) rules.
TransportSelector.hxx/cxx: Added blacklist listener registration and unregistration; refactor and clarify for IPv6
WinSecurity.hxx/cxx: since certificates are preloaded, don't query the filesystem cert store.
dum/ClientAuthManager.cxx: changed DebugLog to InfoLog in handle method.
dum/DialogUsageManager.cxx: changed DebugLog to InfoLog in internalProcess method.
dum/test/BasicCall.cxx: added keep-alive test case.
dum/test/basicRegister.cxx: updated commandline options and simplified for TLS/IPv6.
dum/test/testIdentity.cxx: added test for identity over TLS/IPv6.
external/ExternalDns.hxx: redefined ExternalDnsHandler and lookup methods in ExternalDns class.
os/Tuple.cxx: fix constructor to copy complete IPv6 address.
os/WinCompat.hxx/cxx: add support to determine local IPv6 address; now only used on Windows platform.
os/compat.hxx: added define for T_A.
1 #if !defined(RESIP_SIPSTACK_HXX)
2 #define RESIP_SIPSTACK_HXX
3
4 #include <set>
5 #include <iosfwd>
6
7 #include "resiprocate/os/TimeLimitFifo.hxx"
8 #include "resiprocate/os/Mutex.hxx"
9 #include "resiprocate/os/TransportType.hxx"
10 #include "resiprocate/os/BaseException.hxx"
11 #include "resiprocate/TransactionController.hxx"
12 #include "resiprocate/SecurityTypes.hxx"
13 #include "resiprocate/StatisticsManager.hxx"
14 #include "resiprocate/TuSelector.hxx"
15
16 namespace resip
17 {
18
19 class ApplicationMessage;
20 class Data;
21 class Message;
22 class Security;
23 class SipMessage;
24 class StatisticsManager;
25 class Tuple;
26 class Uri;
27 class TransactionUser;
28 class AsyncProcessHandler;
29
30 class SipStack
31 {
32 public:
33 // Set stateless=true, if you want to use the stack for a stateless proxy
34 // (no transactions)
35 SipStack(Security* security=0, AsyncProcessHandler* handler = 0,
36 bool stateless=false);
37
38 virtual ~SipStack();
39
40 // inform the transaction state machine processor that it should not
41 // create any new transactions and to perform an orderly shutdown. When
42 // the transactions are all terminated, return a ShutdownMessage to the TU
43 void shutdown();
44
45 class Exception : public BaseException
46 {
47 public:
48 Exception(const Data& msg, const Data& file, const int line)
49 : BaseException(msg, file, line) {}
50
51 const char* name() const { return "SipStack::Exception"; }
52 };
53
54 // Used by the application to add in a new transport
55 // ipInterface parameter is used to specify which ethernet interface to
56 // bind to. If set to Data::Empty, bind to all interfaces
57 // If port = 0, use DNS to lookup the port number for the specified
58 // domain. Only allow messages to be sent as the specified domain.
59 // For default case, you can pass in domainname =
60 // DnsUtil::getLocalDomainName().
61
62 enum TransportProcessApproach
63 {
64 SharesStackProcessAndSelect,
65 RunsInOwnThread
66 };
67
68 //factory method to construct built-in transports. A Transport::Exception
69 //will be thrown if the transport couldn't be added, usually because the
70 //port was already bound.
71 void addTransport( TransportType protocol,
72 int port=0,
73 IpVersion version=V4,
74 const Data& ipInterface = Data::Empty,
75 const Data& sipDomainname = Data::Empty, // only used
76 // for TLS
77 // based stuff
78 const Data& privateKeyPassPhrase = Data::Empty,
79 SecurityTypes::SSLType sslType = SecurityTypes::TLSv1,
80 TransportProcessApproach threadApproach = SharesStackProcessAndSelect);
81
82 void addTransport( std::auto_ptr<Transport> transport);
83
84 //this is the fifo subclasses of Transport should use for the rxFifo
85 //cons. param
86 Fifo<TransactionMessage>& stateMacFifo();
87
88 // used to add an alias for this sip element. e.g. foobar.com and boo.com
89 // are both handled by this proxy.
90 // not threadsafe
91 void addAlias(const Data& domain, int port);
92
93 // return true if domain is handled by this stack. convenience for
94 // Transaction Users.
95 bool isMyDomain(const Data& domain, int port) const;
96
97 // get one of the names for this host (calls through to gethostbyname) and
98 // is not threadsafe
99 static Data getHostname();
100
101 // get one of the IP address for this host (calls through to gethostbyname) and
102 // is not threadsafe
103 static Data getHostAddress();
104
105 // get one of the Uris for this host
106 // not threadsafe
107 const Uri& getUri() const;
108
109 // interface for the TU to send a message. makes a copy of the
110 // SipMessage. Caller is responsible for deleting the memory and may do
111 // so as soon as it returns. Loose Routing processing as per RFC3261 must
112 // be done before calling send by the TU. See Helper::processStrictRoute
113 void send(const SipMessage& msg, TransactionUser* tu=0);
114
115 // this is only if you want to send to a destination not in the route. You
116 // probably don't want to use it.
117 void sendTo(const SipMessage& msg, const Uri& uri, TransactionUser* tu=0);
118
119 void sendTo(const SipMessage& msg, const Tuple& tuple,
120 TransactionUser* tu=0);
121
122 // makes the message available to the TU later, TranasctionUser subclasses
123 // can just post to themselves
124 void post(const ApplicationMessage& message);
125
126 void post(const ApplicationMessage& message, unsigned int secondsLater,
127 TransactionUser* tu=0);
128
129 void postMS(const ApplicationMessage& message, unsigned int ms,
130 TransactionUser* tu=0);
131
132 // Return true if the stack has new messages for the TU
133 bool hasMessage() const;
134
135 // applications posting non-sip messages must use receive any.
136 // caller now owns the memory. returns 0 if nothing there
137 SipMessage* receive();
138
139 // May return TransactionTerminated* or SipMessage* or derived ApplicationMessage*
140 Message* receiveAny();
141
142 // build the FD set to use in a select to find out when process bust be
143 // called again. This must be called prior to calling process.
144 virtual void buildFdSet(FdSet& fdset);
145
146 // should call buildFdSet before calling process. This allows the
147 // executive to give processing time to stack components.
148 virtual void process(FdSet& fdset);
149
150 /// returns time in milliseconds when process next needs to be called
151 virtual unsigned int getTimeTillNextProcessMS();
152
153 // Inform the TU that whenever a transaction has been terminated.
154 void registerForTransactionTermination();
155
156 // Allow the application to specify strict routing behavior, by default
157 // loose routing policy is used.
158 void enableStrictRouting(bool strict=true) { mStrictRouting = strict; }
159 bool isStrictRouting() const { return mStrictRouting; }
160
161 void setStatisticsInterval(unsigned long seconds);
162
163 // output current state of the stack - for debug
164 std::ostream& dump(std::ostream& strm) const;
165
166 Security* getSecurity() const;
167
168 //adds a Tu to the tu selection chain. Tu do not call receive or
169 //receiveAny, the SipStack will call postToTu on the appropriate
170 //Tu. Messages no associated with a registered TU go into SipStack::mTuFifo
171 void registerTransactionUser(TransactionUser&);
172 void requestTransactionUserShutdown(TransactionUser&);
173 void unregisterTransactionUser(TransactionUser&);
174
175 void registerBlacklistListener(int rrType, DnsStub::BlacklistListener*);
176 void unregisterBlacklistListener(int rrType, DnsStub::BlacklistListener*);
177
178 private:
179 void checkAsyncProcessHandler();
180
181 /// if this object exists, it manages advanced security featues
182 Security* mSecurity;
183 AsyncProcessHandler* mAsyncProcessHandler;
184
185 SipStack(const SipStack& copy);
186 SipStack& operator=(const SipStack& rhs);
187
188 // fifo used to communicate between the TU (Transaction User) and stack
189 TimeLimitFifo<Message> mTUFifo;
190
191 // timers associated with the application. When a timer fires, it is
192 // placed in the mTUFifo
193 mutable Mutex mAppTimerMutex;
194 TuSelectorTimerQueue mAppTimers;
195
196 // Track stack statistics
197 StatisticsManager mStatsManager;
198
199 // All aspects of the Transaction State Machine / DNS resolver
200 TransactionController mTransactionController;
201
202 // store all domains that this stack is responsible for. Controlled by
203 // addAlias and addTransport interfaces and checks can be made with isMyDomain()
204 std::set<Data> mDomains;
205
206 bool mStrictRouting;
207 bool mShuttingDown;
208
209 TuSelector mTuSelector;
210
211 friend class Executive;
212 friend class StatelessHandler;
213 friend class StatisticsManager;
214 friend class TestDnsResolver;
215 friend class TestFSM;
216 friend class TransactionState;
217 friend class TransactionController;
218 friend class TuSelector;
219 };
220
221 std::ostream& operator<<(std::ostream& strm, const SipStack& stack);
222
223 }
224
225 #endif
226
227 /* ====================================================================
228 * The Vovida Software License, Version 1.0
229 *
230 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
231 *
232 * Redistribution and use in source and binary forms, with or without
233 * modification, are permitted provided that the following conditions
234 * are met:
235 *
236 * 1. Redistributions of source code must retain the above copyright
237 * notice, this list of conditions and the following disclaimer.
238 *
239 * 2. Redistributions in binary form must reproduce the above copyright
240 * notice, this list of conditions and the following disclaimer in
241 * the documentation and/or other materials provided with the
242 * distribution.
243 *
244 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
245 * and "Vovida Open Communication Application Library (VOCAL)" must
246 * not be used to endorse or promote products derived from this
247 * software without prior written permission. For written
248 * permission, please contact vocal@vovida.org.
249 *
250 * 4. Products derived from this software may not be called "VOCAL", nor
251 * may "VOCAL" appear in their name, without prior written
252 * permission of Vovida Networks, Inc.
253 *
254 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
255 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
256 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
257 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
258 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
259 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
260 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
261 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
262 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
263 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
265 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
266 * DAMAGE.
267 *
268 * ====================================================================
269 *
270 * This software consists of voluntary contributions made by Vovida
271 * Networks, Inc. and many individuals on behalf of Vovida Networks,
272 * Inc. For more information on Vovida Networks, Inc., please see
273 * <http://www.vovida.org/>.
274 *
275 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27