00001 /* 00002 * sipep.h 00003 * 00004 * Session Initiation Protocol endpoint. 00005 * 00006 * Open Phone Abstraction Library (OPAL) 00007 * Formally known as the Open H323 project. 00008 * 00009 * Copyright (c) 2001 Equivalence Pty. Ltd. 00010 * 00011 * The contents of this file are subject to the Mozilla Public License 00012 * Version 1.0 (the "License"); you may not use this file except in 00013 * compliance with the License. You may obtain a copy of the License at 00014 * http://www.mozilla.org/MPL/ 00015 * 00016 * Software distributed under the License is distributed on an "AS IS" 00017 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00018 * the License for the specific language governing rights and limitations 00019 * under the License. 00020 * 00021 * The Original Code is Open Phone Abstraction Library. 00022 * 00023 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00024 * 00025 * Contributor(s): ______________________________________. 00026 * 00027 * $Log: sipep.h,v $ 00028 * Revision 2.89 2007/10/12 08:07:16 csoutheren 00029 * Add virtual for REGISTER and SUBSCRIBE pdu reception 00030 * 00031 * Revision 2.88.2.1 2007/10/12 07:22:24 csoutheren 00032 * Add overrides for REGISTER and SUBSCRIBE commands 00033 * 00034 * Revision 2.88 2007/09/21 01:34:09 rjongbloed 00035 * Rewrite of SIP transaction handling to: 00036 * a) use PSafeObject and safe collections 00037 * b) only one database of transactions, remove connection copy 00038 * c) fix timers not always firing due to bogus deadlock avoidance 00039 * d) cleaning up only occurs in the existing garbage collection thread 00040 * e) use of read/write mutex on endpoint list to avoid possible deadlock 00041 * 00042 * Revision 2.87 2007/09/04 05:40:15 rjongbloed 00043 * Added OnRegistrationStatus() call back function so can distinguish 00044 * between initial registration and refreshes. 00045 * 00046 * Revision 2.86 2007/07/22 13:02:11 rjongbloed 00047 * Cleaned up selection of registered name usage of URL versus host name. 00048 * 00049 * Revision 2.85 2007/06/29 06:59:56 rjongbloed 00050 * Major improvement to the "product info", normalising H.221 and User-Agent mechanisms. 00051 * 00052 * Revision 2.84 2007/06/25 05:16:19 rjongbloed 00053 * Changed GetDefaultTransport() so can return multiple transport names eg udp$ AND tcp$. 00054 * Changed listener start up so if no transport is mentioned in the "interface" to listen on 00055 * then will listen on all transports supplied by GetDefaultTransport() 00056 * 00057 * Revision 2.83 2007/06/10 08:55:11 rjongbloed 00058 * Major rework of how SIP utilises sockets, using new "socket bundling" subsystem. 00059 * 00060 * Revision 2.82 2007/05/21 04:30:30 dereksmithies 00061 * put #ifndef _PTLIB_H protection around the include of ptlib.h 00062 * 00063 * Revision 2.81 2007/05/18 00:35:11 csoutheren 00064 * Normalise Register functions 00065 * Add symbol so applications know about presence of presence :) 00066 * 00067 * Revision 2.80 2007/05/16 01:16:20 csoutheren 00068 * Added new files to Windows build 00069 * Removed compiler warnings on Windows 00070 * Added backwards compatible SIP Register function 00071 * 00072 * Revision 2.79 2007/05/15 20:46:00 dsandras 00073 * Added various handlers to manage subscriptions for presence, message 00074 * waiting indications, registrations, state publishing, 00075 * message conversations, ... 00076 * Adds/fixes support for RFC3856, RFC3903, RFC3863, RFC3265, ... 00077 * Many improvements over the original SIPInfo code. 00078 * Code contributed by NOVACOM (http://www.novacom.be) thanks to 00079 * EuroWeb (http://www.euroweb.hu). 00080 * 00081 * Revision 2.78 2007/04/18 03:23:50 rjongbloed 00082 * Moved large chunk of code from header to source file. 00083 * 00084 * Revision 2.77 2007/04/17 21:49:41 dsandras 00085 * Fixed Via field in previous commit. 00086 * Make sure the correct port is being used. 00087 * Improved FindSIPInfoByDomain. 00088 * 00089 * Revision 2.76 2007/04/15 10:09:14 dsandras 00090 * Some systems like CISCO Call Manager do not like having a Contact field in INVITE 00091 * PDUs which is different to the one being used in the original REGISTER request. 00092 * Added code to use the same Contact field in both cases if we can determine that 00093 * we are registered to that specific account and if there is a transport running. 00094 * Fixed problem where the SIP connection was not released with a BYE PDU when 00095 * the ACK is received while we are already in EstablishedPhase. 00096 * 00097 * Revision 2.75 2007/03/30 14:45:32 hfriederich 00098 * Reorganization of hte way transactions are handled. Delete transactions 00099 * in garbage collector when they're terminated. Update destructor code 00100 * to improve safe destruction of SIPEndPoint instances. 00101 * 00102 * Revision 2.74 2007/03/27 21:00:29 dsandras 00103 * Removed cout. 00104 * 00105 * Revision 2.73 2007/03/27 20:16:23 dsandras 00106 * Temporarily removed use of shared transports as it could have unexpected 00107 * side effects on the routing of PDUs. 00108 * Various fixes on the way SIPInfo objects are being handled. Wait 00109 * for transports to be closed before being deleted. Added missing mutexes. 00110 * Added garbage collector. 00111 * 00112 * Revision 2.71 2007/03/10 17:56:58 dsandras 00113 * Improved locking. 00114 * 00115 * Revision 2.70 2007/03/01 05:51:04 rjongbloed 00116 * Fixed backward compatibility of OnIncomingConnection() virtual 00117 * functions on various classes. If an old override returned FALSE 00118 * then it will now abort the call as it used to. 00119 * 00120 * Revision 2.69 2007/02/27 21:22:42 dsandras 00121 * Added missing locking. Fixes Ekiga report #411438. 00122 * 00123 * Revision 2.68 2007/01/24 04:00:56 csoutheren 00124 * Arrrghh. Changing OnIncomingConnection turned out to have a lot of side-effects 00125 * Added some pure viritual functions to prevent old code from breaking silently 00126 * New OpalEndpoint and OpalConnection descendants will need to re-implement 00127 * OnIncomingConnection. Sorry :) 00128 * 00129 * Revision 2.67 2007/01/18 04:45:16 csoutheren 00130 * Messy, but simple change to add additional options argument to OpalConnection constructor 00131 * This allows the provision of non-trivial arguments for connections 00132 * 00133 * Revision 2.66 2007/01/02 15:26:13 dsandras 00134 * Added DNS Fallback for realm authentication if the classical comparison 00135 * doesn't work. Fixes problems with broken SIP proxies. (Ekiga report #377346) 00136 * 00137 * Revision 2.65 2006/12/18 03:18:41 csoutheren 00138 * Messy but simple fixes 00139 * - Add access to SIP REGISTER timeout 00140 * - Ensure OpalConnection options are correctly progagated 00141 * 00142 * Revision 2.64 2006/11/09 18:24:55 hfriederich 00143 * Ensures that responses to received INVITE get sent out on the same network interface as where the INVITE was received. Remove cout statement 00144 * 00145 * Revision 2.63 2006/08/12 04:20:39 csoutheren 00146 * Removed Windows warning and fixed timeout in SIP PING code 00147 * 00148 * Revision 2.62 2006/08/12 04:09:24 csoutheren 00149 * Applied 1538497 - Add the PING method 00150 * Thanks to Paul Rolland 00151 * 00152 * Revision 2.61 2006/07/29 08:49:25 hfriederich 00153 * Abort the authentication process after a given number of unsuccessful authentication attempts to prevent infinite authentication attempts. Use not UINT_MAX as GetExpires() default to fix incorrect detection of registration/unregistration 00154 * 00155 * Revision 2.60 2006/07/24 14:03:39 csoutheren 00156 * Merged in audio and video plugins from CVS branch PluginBranch 00157 * 00158 * Revision 2.59 2006/07/14 04:22:43 csoutheren 00159 * Applied 1517397 - More Phobos stability fix 00160 * Thanks to Dinis Rosario 00161 * 00162 * Revision 2.58 2006/04/30 17:24:39 dsandras 00163 * Various clean ups. 00164 * 00165 * Revision 2.57 2006/04/11 21:58:25 dsandras 00166 * Various cleanups and fixes. Fixes Ekiga report #336444. 00167 * 00168 * Revision 2.56 2006/03/27 20:28:18 dsandras 00169 * Added mutex to fix concurrency issues between OnReceivedPDU which checks 00170 * if a connection is in the list, and OnReceivedINVITE, which adds it to the 00171 * list. Fixes Ekiga report #334847. Thanks Robert for your input on this! 00172 * 00173 * Revision 2.55 2006/03/19 18:57:06 dsandras 00174 * More work on Ekiga report #334999. 00175 * 00176 * Revision 2.54 2006/03/19 17:26:15 dsandras 00177 * Fixed FindSIPInfoByDomain so that it doesn't return unregistered accounts. 00178 * Fixes Ekiga report #335006. 00179 * 00180 * Revision 2.53 2006/03/19 12:32:05 dsandras 00181 * RFC3261 says that "CANCEL messages "SHOULD NOT" be sent for anything but INVITE 00182 * requests". Fixes Ekiga report #334985. 00183 * 00184 * Revision 2.52 2006/03/19 11:45:47 dsandras 00185 * The remote address of the registrar transport might have changed due 00186 * to the Via field. This affected unregistering which was reusing 00187 * the exact same transport to unregister. Fixed Ekiga report #334999. 00188 * 00189 * Revision 2.51 2006/03/06 22:52:59 csoutheren 00190 * Reverted experimental SRV patch due to unintended side effects 00191 * 00192 * Revision 2.50 2006/03/06 19:01:30 dsandras 00193 * Allow registering several accounts with the same realm but different 00194 * user names to the same provider. Fixed possible crash due to transport 00195 * deletion before the transaction is over. 00196 * 00197 * Revision 2.49 2006/03/06 12:56:02 csoutheren 00198 * Added experimental support for SIP SRV lookups 00199 * 00200 * Revision 2.48.2.2 2006/04/06 05:33:07 csoutheren 00201 * Backports from CVS head up to Plugin_Merge2 00202 * 00203 * Revision 2.48.2.1 2006/03/20 02:25:26 csoutheren 00204 * Backports from CVS head 00205 * 00206 * Revision 2.56 2006/03/27 20:28:18 dsandras 00207 * Added mutex to fix concurrency issues between OnReceivedPDU which checks 00208 * if a connection is in the list, and OnReceivedINVITE, which adds it to the 00209 * list. Fixes Ekiga report #334847. Thanks Robert for your input on this! 00210 * 00211 * Revision 2.55 2006/03/19 18:57:06 dsandras 00212 * More work on Ekiga report #334999. 00213 * 00214 * Revision 2.54 2006/03/19 17:26:15 dsandras 00215 * Fixed FindSIPInfoByDomain so that it doesn't return unregistered accounts. 00216 * Fixes Ekiga report #335006. 00217 * 00218 * Revision 2.53 2006/03/19 12:32:05 dsandras 00219 * RFC3261 says that "CANCEL messages "SHOULD NOT" be sent for anything but INVITE 00220 * requests". Fixes Ekiga report #334985. 00221 * 00222 * Revision 2.52 2006/03/19 11:45:47 dsandras 00223 * The remote address of the registrar transport might have changed due 00224 * to the Via field. This affected unregistering which was reusing 00225 * the exact same transport to unregister. Fixed Ekiga report #334999. 00226 * 00227 * Revision 2.51 2006/03/06 22:52:59 csoutheren 00228 * Reverted experimental SRV patch due to unintended side effects 00229 * 00230 * Revision 2.50 2006/03/06 19:01:30 dsandras 00231 * Allow registering several accounts with the same realm but different 00232 * user names to the same provider. Fixed possible crash due to transport 00233 * deletion before the transaction is over. 00234 * 00235 * Revision 2.49 2006/03/06 12:56:02 csoutheren 00236 * Added experimental support for SIP SRV lookups 00237 * 00238 * Revision 2.48 2006/02/19 11:51:46 dsandras 00239 * Fixed FindSIPInfoByDomain. 00240 * 00241 * Revision 2.47 2006/01/29 20:55:32 dsandras 00242 * Allow using a simple username or a fill url when registering. 00243 * 00244 * Revision 2.46 2006/01/08 21:53:40 dsandras 00245 * Changed IsRegistered so that it takes the registration url as argument, 00246 * allowing it to work when there are several accounts on the same server. 00247 * 00248 * Revision 2.45 2006/01/08 14:43:46 dsandras 00249 * Improved the NAT binding refresh methods so that it works with all endpoint 00250 * created transports that require it and so that it can work by sending 00251 * SIP Options, or empty SIP requests. More methods can be added later. 00252 * 00253 * Revision 2.44 2006/01/02 11:28:07 dsandras 00254 * Some documentation. Various code cleanups to prevent duplicate code. 00255 * 00256 * Revision 2.43 2005/12/18 21:06:56 dsandras 00257 * Added function to clean up the registrations object. 00258 * Moved DeleteObjectsToBeRemoved call outside of the loop. 00259 * 00260 * Revision 2.42 2005/12/14 17:59:50 dsandras 00261 * Added ForwardConnection executed when the remote asks for a call forwarding. 00262 * Similar to what is done in the H.323 part with the method of the same name. 00263 * 00264 * Revision 2.41 2005/12/11 19:14:20 dsandras 00265 * Added support for setting a different user name and authentication user name 00266 * as required by some providers like digisip. 00267 * 00268 * Revision 2.40 2005/12/08 21:14:54 dsandras 00269 * Added function allowing to change the nat binding refresh timeout. 00270 * 00271 * Revision 2.39 2005/12/05 22:20:57 dsandras 00272 * Update the transport when the computer is behind NAT, using STUN, the IP 00273 * address has changed compared to the original transport and a registration 00274 * refresh must occur. 00275 * 00276 * Revision 2.38 2005/12/04 22:08:58 dsandras 00277 * Added possibility to provide an expire time when registering, if not 00278 * the default expire time for the endpoint will be used. 00279 * 00280 * Revision 2.37 2005/11/30 13:35:26 csoutheren 00281 * Changed tags for Doxygen 00282 * 00283 * Revision 2.36 2005/11/28 19:07:56 dsandras 00284 * Moved OnNATTimeout to SIPInfo and use it for active conversations too. 00285 * Added E.164 support. 00286 * 00287 * Revision 2.35 2005/10/30 23:01:29 dsandras 00288 * Added possibility to have a body for SIPInfo. Moved MESSAGE sending 00289 * to SIPInfo for more efficiency during conversations. 00290 * 00291 * Revision 2.34 2005/10/22 17:14:45 dsandras 00292 * Send an OPTIONS request periodically when STUN is being used to maintain the registrations binding alive. 00293 * 00294 * Revision 2.33 2005/10/20 20:26:58 dsandras 00295 * Made the transactions handling thread-safe. 00296 * 00297 * Revision 2.32 2005/10/02 21:46:20 dsandras 00298 * Added more doc. 00299 * 00300 * Revision 2.31 2005/10/02 17:47:37 dsandras 00301 * Added function to return the translated contact address of the endpoint. 00302 * Added some doc. 00303 * 00304 * Revision 2.30 2005/05/23 20:14:05 dsandras 00305 * Added preliminary support for basic instant messenging. 00306 * 00307 * Revision 2.29 2005/05/06 07:37:06 csoutheren 00308 * Various changed while working with SIP carrier 00309 * - remove assumption that authentication realm is a domain name. 00310 * - stopped rewrite of "To" field when proxy being used 00311 * - fix Contact field in REGISTER to match actual port used 00312 * when Symmetric NATin use 00313 * - lots of formatting changes and cleanups 00314 * 00315 * Revision 2.28 2005/05/03 20:41:51 dsandras 00316 * Do not count SUBSCRIBEs when returning the number of registered accounts. 00317 * 00318 * Revision 2.27 2005/04/28 20:22:53 dsandras 00319 * Applied big sanity patch for SIP thanks to 00320 * Ted Szoczei <tszoczei@microtronix.ca>. 00321 * Thanks a lot! 00322 * 00323 * Revision 2.25 2005/04/26 19:50:54 dsandras 00324 * Added function to return the number of registered accounts. 00325 * 00326 * Revision 2.24 2005/04/10 21:01:09 dsandras 00327 * Added Blind Transfer support. 00328 * 00329 * Revision 2.23 2005/03/11 18:12:08 dsandras 00330 * Added support to specify the realm when registering. That way softphones 00331 * already know what authentication information to use when required. 00332 * The realm/domain can also be used in the From field. 00333 * 00334 * Revision 2.22 2005/02/19 22:48:48 dsandras 00335 * Added the possibility to register to several registrars and be able to do 00336 * authenticated calls to each of them. Added SUBSCRIBE/NOTIFY support for 00337 * Message Waiting Indications. 00338 * 00339 * Revision 2.21 2004/12/17 12:06:52 dsandras 00340 * Added error code to OnRegistrationFailed. Made Register/Unregister wait 00341 * until the transaction is over. Fixed Unregister so that the SIPRegister 00342 * is used as a pointer or the object is deleted at the end of the function 00343 * and make Opal crash when transactions are cleaned. Reverted part of the 00344 * patch that was sending authentication again when it had already been done 00345 * on a Register. 00346 * 00347 * Revision 2.20 2004/12/12 12:30:09 dsandras 00348 * Added virtual function called when registration to a registrar fails. 00349 * 00350 * Revision 2.19 2004/11/29 08:18:31 csoutheren 00351 * Added support for setting the SIP authentication domain/realm as needed 00352 * for many service providers. 00353 * 00354 * Revision 2.18 2004/10/02 04:30:10 rjongbloed 00355 * Added unregister function for SIP registrar 00356 * 00357 * Revision 2.17 2004/08/22 12:27:44 rjongbloed 00358 * More work on SIP registration, time to live refresh and deregistration 00359 * on exit. 00360 * 00361 * Revision 2.16 2004/08/14 07:56:30 rjongbloed 00362 * Major revision to utilise the PSafeCollection classes for the connections 00363 * and calls. 00364 * 00365 * Revision 2.15 2004/07/11 12:42:10 rjongbloed 00366 * Added function on endpoints to get the list of all media formats any 00367 * connection the endpoint may create can support. 00368 * 00369 * Revision 2.14 2004/06/05 14:36:32 rjongbloed 00370 * Added functions to get registration URL. 00371 * Added ability to set proxy bu host/user/password strings. 00372 * 00373 * Revision 2.13 2004/04/26 06:30:33 rjongbloed 00374 * Added ability to specify more than one defualt listener for an endpoint, 00375 * required by SIP which listens on both UDP and TCP. 00376 * 00377 * Revision 2.12 2004/04/26 05:40:38 rjongbloed 00378 * Added RTP statistics callback to SIP 00379 * 00380 * Revision 2.11 2004/03/14 11:32:19 rjongbloed 00381 * Changes to better support SIP proxies. 00382 * 00383 * Revision 2.10 2004/03/14 10:13:03 rjongbloed 00384 * Moved transport on SIP top be constructed by endpoint as any transport 00385 * created on an endpoint can receive data for any connection. 00386 * Changes to REGISTER to support authentication 00387 * 00388 * Revision 2.9 2004/03/14 08:34:09 csoutheren 00389 * Added ability to set User-Agent string 00390 * 00391 * Revision 2.8 2004/03/13 06:51:31 rjongbloed 00392 * Alllowed for empty "username" in registration 00393 * 00394 * Revision 2.7 2004/03/13 06:32:17 rjongbloed 00395 * Fixes for removal of SIP and H.323 subsystems. 00396 * More registration work. 00397 * 00398 * Revision 2.6 2003/03/06 03:57:47 robertj 00399 * IVR support (work in progress) requiring large changes everywhere. 00400 * 00401 * Revision 2.5 2002/09/16 02:52:35 robertj 00402 * Added #define so can select if #pragma interface/implementation is used on 00403 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00404 * 00405 * Revision 2.4 2002/07/04 07:41:47 robertj 00406 * Fixed memory/thread leak of transports. 00407 * 00408 * Revision 2.3 2002/04/16 08:06:35 robertj 00409 * Fixed GNU warnings. 00410 * 00411 * Revision 2.2 2002/04/05 10:42:04 robertj 00412 * Major changes to support transactions (UDP timeouts and retries). 00413 * 00414 * Revision 2.1 2002/02/01 04:53:01 robertj 00415 * Added (very primitive!) SIP support. 00416 * 00417 */ 00418 00419 #ifndef __OPAL_SIPEP_H 00420 #define __OPAL_SIPEP_H 00421 00422 #ifdef P_USE_PRAGMA 00423 #pragma interface 00424 #endif 00425 00426 #ifndef _PTLIB_H 00427 #include <ptlib.h> 00428 #endif 00429 00430 #include <opal/endpoint.h> 00431 #include <sip/sipcon.h> 00432 #include <sip/sippdu.h> 00433 #include <sip/handlers.h> 00434 00435 // 00436 // provide flag so applications know if presence is available 00437 // 00438 #define OPAL_HAS_SIP_PRESENCE 1 00439 00440 00442 00446 class SIPAuthInfo : public PObject 00447 { 00448 public: 00449 SIPAuthInfo() 00450 { } 00451 00452 SIPAuthInfo(const PString & u, const PString & p) 00453 { username = u; password = p; } 00454 PString username; 00455 PString password; 00456 }; 00457 00459 00462 class SIPEndPoint : public OpalEndPoint 00463 { 00464 PCLASSINFO(SIPEndPoint, OpalEndPoint); 00465 00466 public: 00471 SIPEndPoint( 00472 OpalManager & manager 00473 ); 00474 00477 ~SIPEndPoint(); 00479 00485 virtual PString GetDefaultTransport() const { return "udp$,tcp$"; } 00486 00491 virtual BOOL NewIncomingConnection( 00492 OpalTransport * transport 00493 ); 00494 00524 virtual BOOL MakeConnection( 00525 OpalCall & call, 00526 const PString & party, 00527 void * userData, 00528 unsigned int options, 00529 OpalConnection::StringOptions * stringOptions 00530 ); 00531 00541 virtual OpalMediaFormatList GetMediaFormats() const; 00542 00547 virtual BOOL GarbageCollection(); 00549 00555 virtual SIPConnection * CreateConnection( 00556 OpalCall & call, 00557 const PString & token, 00558 void * userData, 00559 const SIPURL & destination, 00560 OpalTransport * transport, 00561 SIP_PDU * invite, 00562 unsigned int options = 0, 00563 OpalConnection::StringOptions * stringOptions = NULL 00564 00565 ); 00566 00569 virtual BOOL SetupTransfer( 00570 const PString & token, 00571 const PString & callIdentity, 00572 const PString & remoteParty, 00573 void * userData = NULL 00574 ); 00575 00579 virtual BOOL ForwardConnection( 00580 SIPConnection & connection, 00581 const PString & forwardParty 00582 ); 00583 00585 00588 00592 OpalTransport * CreateTransport( 00593 const OpalTransportAddress & remoteAddress, 00594 const OpalTransportAddress & localAddress = OpalTransportAddress() 00595 ); 00596 00597 virtual void HandlePDU( 00598 OpalTransport & transport 00599 ); 00600 00603 virtual BOOL OnReceivedPDU( 00604 OpalTransport & transport, 00605 SIP_PDU * pdu 00606 ); 00607 00610 virtual void OnReceivedResponse( 00611 SIPTransaction & transaction, 00612 SIP_PDU & response 00613 ); 00614 00617 virtual BOOL OnReceivedINVITE( 00618 OpalTransport & transport, 00619 SIP_PDU * pdu 00620 ); 00621 00624 virtual void OnReceivedAuthenticationRequired( 00625 SIPTransaction & transaction, 00626 SIP_PDU & response 00627 ); 00628 00632 virtual void OnReceivedOK( 00633 SIPTransaction & transaction, 00634 SIP_PDU & response 00635 ); 00636 00639 virtual BOOL OnReceivedNOTIFY( 00640 OpalTransport & transport, 00641 SIP_PDU & response 00642 ); 00643 00646 virtual BOOL OnReceivedREGISTER( 00647 OpalTransport & transport, 00648 SIP_PDU & pdu 00649 ); 00650 00653 virtual BOOL OnReceivedSUBSCRIBE( 00654 OpalTransport & transport, 00655 SIP_PDU & pdu 00656 ); 00657 00660 virtual void OnReceivedMESSAGE( 00661 OpalTransport & transport, 00662 SIP_PDU & response 00663 ); 00664 00667 virtual void OnTransactionTimeout( 00668 SIPTransaction & transaction 00669 ); 00670 00678 virtual void OnRTPStatistics( 00679 const SIPConnection & connection, 00680 const RTP_Session & session 00681 ) const; 00683 00684 00689 PSafePtr<SIPConnection> GetSIPConnectionWithLock( 00690 const PString & token, 00691 PSafetyMode mode = PSafeReadWrite 00692 ) { return PSafePtrCast<OpalConnection, SIPConnection>(GetConnectionWithLock(token, mode)); } 00693 00694 virtual BOOL IsAcceptedAddress(const SIPURL & toAddr); 00695 00696 00699 virtual void OnMessageReceived (const SIPURL & from, 00700 const PString & body); 00701 00702 00715 BOOL Register( 00716 unsigned expire, 00717 const PString & aor = PString::Empty(), 00718 const PString & authName = PString::Empty(), 00719 const PString & password = PString::Empty(), 00720 const PString & authRealm = PString::Empty(), 00721 const PTimeInterval & minRetryTime = PMaxTimeInterval, 00722 const PTimeInterval & maxRetryTime = PMaxTimeInterval 00723 ); 00724 BOOL Register( 00725 const PString & host, 00726 const PString & user = PString::Empty(), 00727 const PString & autName = PString::Empty(), 00728 const PString & password = PString::Empty(), 00729 const PString & authRealm = PString::Empty(), 00730 unsigned expire = 0, 00731 const PTimeInterval & minRetryTime = PMaxTimeInterval, 00732 const PTimeInterval & maxRetryTime = PMaxTimeInterval 00733 ); 00734 00735 00738 BOOL Unregister(const PString & aor); 00739 00740 00744 BOOL Subscribe( 00745 SIPSubscribe::SubscribeType & type, 00746 unsigned expire, 00747 const PString & to 00748 ); 00749 00750 00751 BOOL Unsubscribe( 00752 SIPSubscribe::SubscribeType & type, 00753 const PString & to 00754 ); 00755 00756 00759 BOOL Message ( 00760 const PString & to, 00761 const PString & body 00762 ); 00763 00764 00768 BOOL Publish( 00769 const PString & to, 00770 const PString & body, 00771 unsigned expire = 0 00772 ); 00773 00774 00777 BOOL Ping( 00778 const PString & to 00779 ); 00780 00783 virtual void OnMWIReceived ( 00784 const PString & to, 00785 SIPSubscribe::MWIType type, 00786 const PString & msgs); 00787 00788 00791 virtual void OnPresenceInfoReceived ( 00792 const PString & user, 00793 const PString & basic, 00794 const PString & note); 00795 00796 00801 virtual void OnRegistrationStatus( 00802 const PString & aor, 00803 BOOL wasRegistering, 00804 BOOL reRegistering, 00805 SIP_PDU::StatusCodes reason 00806 ); 00807 00812 virtual void OnRegistrationFailed( 00813 const PString & aor, 00814 SIP_PDU::StatusCodes reason, 00815 BOOL wasRegistering 00816 ); 00817 00822 virtual void OnRegistered( 00823 const PString & aor, 00824 BOOL wasRegistering 00825 ); 00826 00827 00831 BOOL IsRegistered(const PString & aor); 00832 00836 BOOL IsSubscribed( 00837 SIPSubscribe::SubscribeType type, 00838 const PString & to); 00839 00840 00843 unsigned GetRegistrationsCount () { return activeSIPHandlers.GetRegistrationsCount (); } 00844 00845 00850 virtual void OnMessageFailed( 00851 const SIPURL & messageUrl, 00852 SIP_PDU::StatusCodes reason); 00853 00854 00855 void SetMIMEForm(BOOL v) { mimeForm = v; } 00856 BOOL GetMIMEForm() const { return mimeForm; } 00857 00858 void SetMaxRetries(unsigned r) { maxRetries = r; } 00859 unsigned GetMaxRetries() const { return maxRetries; } 00860 00861 void SetRetryTimeouts( 00862 const PTimeInterval & t1, 00863 const PTimeInterval & t2 00864 ) { retryTimeoutMin = t1; retryTimeoutMax = t2; } 00865 const PTimeInterval & GetRetryTimeoutMin() const { return retryTimeoutMin; } 00866 const PTimeInterval & GetRetryTimeoutMax() const { return retryTimeoutMax; } 00867 00868 void SetNonInviteTimeout( 00869 const PTimeInterval & t 00870 ) { nonInviteTimeout = t; } 00871 const PTimeInterval & GetNonInviteTimeout() const { return nonInviteTimeout; } 00872 00873 void SetPduCleanUpTimeout( 00874 const PTimeInterval & t 00875 ) { pduCleanUpTimeout = t; } 00876 const PTimeInterval & GetPduCleanUpTimeout() const { return pduCleanUpTimeout; } 00877 00878 void SetInviteTimeout( 00879 const PTimeInterval & t 00880 ) { inviteTimeout = t; } 00881 const PTimeInterval & GetInviteTimeout() const { return inviteTimeout; } 00882 00883 void SetAckTimeout( 00884 const PTimeInterval & t 00885 ) { ackTimeout = t; } 00886 const PTimeInterval & GetAckTimeout() const { return ackTimeout; } 00887 00888 void SetRegistrarTimeToLive( 00889 const PTimeInterval & t 00890 ) { registrarTimeToLive = t; } 00891 const PTimeInterval & GetRegistrarTimeToLive() const { return registrarTimeToLive; } 00892 00893 void SetNotifierTimeToLive( 00894 const PTimeInterval & t 00895 ) { notifierTimeToLive = t; } 00896 const PTimeInterval & GetNotifierTimeToLive() const { return notifierTimeToLive; } 00897 00898 void SetNATBindingTimeout( 00899 const PTimeInterval & t 00900 ) { natBindingTimeout = t; natBindingTimer.RunContinuous (natBindingTimeout); } 00901 const PTimeInterval & GetNATBindingTimeout() const { return natBindingTimeout; } 00902 00903 void AddTransaction( 00904 SIPTransaction * transaction 00905 ) { transactions.SetAt(transaction->GetTransactionID(), transaction); } 00906 00907 PSafePtr<SIPTransaction> GetTransaction(const PString & transactionID, PSafetyMode mode = PSafeReadWrite) 00908 { return transactions.FindWithLock(transactionID, mode); } 00909 00912 unsigned GetNextCSeq() { return ++lastSentCSeq; } 00913 00914 00917 BOOL GetAuthentication(const PString & authRealm, SIPAuthentication &); 00918 00919 00925 virtual SIPURL GetRegisteredPartyName(const SIPURL &); 00926 00927 00930 virtual SIPURL GetDefaultRegisteredPartyName(); 00931 00932 00944 SIPURL GetContactURL(const OpalTransport &transport, const PString & userName, const PString & host); 00945 00946 00956 SIPURL GetLocalURL( 00957 const OpalTransport & transport, 00958 const PString & userName = PString::Empty() 00959 ); 00960 00961 00964 const SIPURL & GetProxy() const { return proxy; } 00965 00966 00969 void SetProxy(const SIPURL & url); 00970 00971 00974 void SetProxy( 00975 const PString & hostname, 00976 const PString & username, 00977 const PString & password 00978 ); 00979 00980 00987 virtual PString GetUserAgent() const; 00988 00991 void SetUserAgent(const PString & str) { userAgentString = str; } 00992 00993 00994 BOOL SendResponse( 00995 SIP_PDU::StatusCodes code, 00996 OpalTransport & transport, 00997 SIP_PDU & pdu 00998 ); 00999 01002 enum NATBindingRefreshMethod{ 01003 None, 01004 Options, 01005 EmptyRequest, 01006 NumMethods 01007 }; 01008 01009 01012 void SetNATBindingRefreshMethod(const NATBindingRefreshMethod m) { natMethod = m; } 01013 01014 virtual SIPRegisterHandler * CreateRegisterHandler(const PString & to, 01015 const PString & authName, 01016 const PString & password, 01017 const PString & realm, 01018 int expire, 01019 const PTimeInterval & minRetryTime, 01020 const PTimeInterval & maxRetryTime); 01021 01022 protected: 01023 PDECLARE_NOTIFIER(PThread, SIPEndPoint, TransportThreadMain); 01024 PDECLARE_NOTIFIER(PTimer, SIPEndPoint, NATBindingRefresh); 01025 01026 01027 void ParsePartyName( 01028 const PString & remoteParty, 01029 PString & party 01030 ); 01031 01032 01033 SIPURL proxy; 01034 PString userAgentString; 01035 01036 BOOL mimeForm; 01037 unsigned maxRetries; 01038 PTimeInterval retryTimeoutMin; // T1 01039 PTimeInterval retryTimeoutMax; // T2 01040 PTimeInterval nonInviteTimeout; // T3 01041 PTimeInterval pduCleanUpTimeout; // T4 01042 PTimeInterval inviteTimeout; 01043 PTimeInterval ackTimeout; 01044 PTimeInterval registrarTimeToLive; 01045 PTimeInterval notifierTimeToLive; 01046 PTimeInterval natBindingTimeout; 01047 01048 SIPHandlersList activeSIPHandlers; 01049 01050 PSafeDictionary<PString, SIPTransaction> transactions; 01051 01052 PTimer natBindingTimer; 01053 NATBindingRefreshMethod natMethod; 01054 01055 PAtomicInteger lastSentCSeq; 01056 }; 01057 01058 #endif // __OPAL_SIPEP_H 01059 01060 01061 // End of File ///////////////////////////////////////////////////////////////