sipep.h

Go to the documentation of this file.
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.46.2.3  2006/03/06 19:04:39  dsandras
00029  * Backports from HEAD.
00030  *
00031  * Revision 2.50  2006/03/06 19:01:30  dsandras
00032  * Allow registering several accounts with the same realm but different
00033  * user names to the same provider. Fixed possible crash due to transport
00034  * deletion before the transaction is over.
00035  *
00036  * Revision 2.46.2.2  2006/02/19 11:53:22  dsandras
00037  * More backports from HEAD.
00038  *
00039  * Revision 2.48  2006/02/19 11:51:46  dsandras
00040  * Fixed FindSIPInfoByDomain.
00041  *
00042  * Revision 2.46.2.1  2006/01/29 21:01:40  dsandras
00043  * Backports from CVS HEAD.
00044  *
00045  * Revision 2.47  2006/01/29 20:55:32  dsandras
00046  * Allow using a simple username or a fill url when registering.
00047  *
00048  * Revision 2.46  2006/01/08 21:53:40  dsandras
00049  * Changed IsRegistered so that it takes the registration url as argument,
00050  * allowing it to work when there are several accounts on the same server.
00051  *
00052  * Revision 2.45  2006/01/08 14:43:46  dsandras
00053  * Improved the NAT binding refresh methods so that it works with all endpoint
00054  * created transports that require it and so that it can work by sending
00055  * SIP Options, or empty SIP requests. More methods can be added later.
00056  *
00057  * Revision 2.44  2006/01/02 11:28:07  dsandras
00058  * Some documentation. Various code cleanups to prevent duplicate code.
00059  *
00060  * Revision 2.43  2005/12/18 21:06:56  dsandras
00061  * Added function to clean up the registrations object. Moved DeleteObjectsToBeRemoved call outside of the loop.
00062  *
00063  * Revision 2.42  2005/12/14 17:59:50  dsandras
00064  * Added ForwardConnection executed when the remote asks for a call forwarding.
00065  * Similar to what is done in the H.323 part with the method of the same name.
00066  *
00067  * Revision 2.41  2005/12/11 19:14:20  dsandras
00068  * Added support for setting a different user name and authentication user name
00069  * as required by some providers like digisip.
00070  *
00071  * Revision 2.40  2005/12/08 21:14:54  dsandras
00072  * Added function allowing to change the nat binding refresh timeout.
00073  *
00074  * Revision 2.39  2005/12/05 22:20:57  dsandras
00075  * Update the transport when the computer is behind NAT, using STUN, the IP
00076  * address has changed compared to the original transport and a registration
00077  * refresh must occur.
00078  *
00079  * Revision 2.38  2005/12/04 22:08:58  dsandras
00080  * Added possibility to provide an expire time when registering, if not
00081  * the default expire time for the endpoint will be used.
00082  *
00083  * Revision 2.37  2005/11/30 13:35:26  csoutheren
00084  * Changed tags for Doxygen
00085  *
00086  * Revision 2.36  2005/11/28 19:07:56  dsandras
00087  * Moved OnNATTimeout to SIPInfo and use it for active conversations too.
00088  * Added E.164 support.
00089  *
00090  * Revision 2.35  2005/10/30 23:01:29  dsandras
00091  * Added possibility to have a body for SIPInfo. Moved MESSAGE sending to SIPInfo for more efficiency during conversations.
00092  *
00093  * Revision 2.34  2005/10/22 17:14:45  dsandras
00094  * Send an OPTIONS request periodically when STUN is being used to maintain the registrations binding alive.
00095  *
00096  * Revision 2.33  2005/10/20 20:26:58  dsandras
00097  * Made the transactions handling thread-safe.
00098  *
00099  * Revision 2.32  2005/10/02 21:46:20  dsandras
00100  * Added more doc.
00101  *
00102  * Revision 2.31  2005/10/02 17:47:37  dsandras
00103  * Added function to return the translated contact address of the endpoint.
00104  * Added some doc.
00105  *
00106  * Revision 2.30  2005/05/23 20:14:05  dsandras
00107  * Added preliminary support for basic instant messenging.
00108  *
00109  * Revision 2.29  2005/05/06 07:37:06  csoutheren
00110  * Various changed while working with SIP carrier
00111  *   - remove assumption that authentication realm is a domain name.
00112  *   - stopped rewrite of "To" field when proxy being used
00113  *   - fix Contact field in REGISTER to match actual port used when Symmetric NATin use
00114  *   - lots of formatting changes and cleanups
00115  *
00116  * Revision 2.28  2005/05/03 20:41:51  dsandras
00117  * Do not count SUBSCRIBEs when returning the number of registered accounts.
00118  *
00119  * Revision 2.27  2005/04/28 20:22:53  dsandras
00120  * Applied big sanity patch for SIP thanks to Ted Szoczei <tszoczei@microtronix.ca>.
00121  * Thanks a lot!
00122  *
00123  * Revision 2.25  2005/04/26 19:50:54  dsandras
00124  * Added function to return the number of registered accounts.
00125  *
00126  * Revision 2.24  2005/04/10 21:01:09  dsandras
00127  * Added Blind Transfer support.
00128  *
00129  * Revision 2.23  2005/03/11 18:12:08  dsandras
00130  * Added support to specify the realm when registering. That way softphones already know what authentication information to use when required. The realm/domain can also be used in the From field.
00131  *
00132  * Revision 2.22  2005/02/19 22:48:48  dsandras
00133  * Added the possibility to register to several registrars and be able to do authenticated calls to each of them. Added SUBSCRIBE/NOTIFY support for Message Waiting Indications.
00134  *
00135  * Revision 2.21  2004/12/17 12:06:52  dsandras
00136  * Added error code to OnRegistrationFailed. Made Register/Unregister wait until the transaction is over. Fixed Unregister so that the SIPRegister is used as a pointer or the object is deleted at the end of the function and make Opal crash when transactions are cleaned. Reverted part of the patch that was sending authentication again when it had already been done on a Register.
00137  *
00138  * Revision 2.20  2004/12/12 12:30:09  dsandras
00139  * Added virtual function called when registration to a registrar fails.
00140  *
00141  * Revision 2.19  2004/11/29 08:18:31  csoutheren
00142  * Added support for setting the SIP authentication domain/realm as needed for many service
00143  *  providers
00144  *
00145  * Revision 2.18  2004/10/02 04:30:10  rjongbloed
00146  * Added unregister function for SIP registrar
00147  *
00148  * Revision 2.17  2004/08/22 12:27:44  rjongbloed
00149  * More work on SIP registration, time to live refresh and deregistration on exit.
00150  *
00151  * Revision 2.16  2004/08/14 07:56:30  rjongbloed
00152  * Major revision to utilise the PSafeCollection classes for the connections and calls.
00153  *
00154  * Revision 2.15  2004/07/11 12:42:10  rjongbloed
00155  * Added function on endpoints to get the list of all media formats any
00156  *   connection the endpoint may create can support.
00157  *
00158  * Revision 2.14  2004/06/05 14:36:32  rjongbloed
00159  * Added functions to get registration URL.
00160  * Added ability to set proxy bu host/user/password strings.
00161  *
00162  * Revision 2.13  2004/04/26 06:30:33  rjongbloed
00163  * Added ability to specify more than one defualt listener for an endpoint,
00164  *   required by SIP which listens on both UDP and TCP.
00165  *
00166  * Revision 2.12  2004/04/26 05:40:38  rjongbloed
00167  * Added RTP statistics callback to SIP
00168  *
00169  * Revision 2.11  2004/03/14 11:32:19  rjongbloed
00170  * Changes to better support SIP proxies.
00171  *
00172  * Revision 2.10  2004/03/14 10:13:03  rjongbloed
00173  * Moved transport on SIP top be constructed by endpoint as any transport created on
00174  *   an endpoint can receive data for any connection.
00175  * Changes to REGISTER to support authentication
00176  *
00177  * Revision 2.9  2004/03/14 08:34:09  csoutheren
00178  * Added ability to set User-Agent string
00179  *
00180  * Revision 2.8  2004/03/13 06:51:31  rjongbloed
00181  * Alllowed for empty "username" in registration
00182  *
00183  * Revision 2.7  2004/03/13 06:32:17  rjongbloed
00184  * Fixes for removal of SIP and H.323 subsystems.
00185  * More registration work.
00186  *
00187  * Revision 2.6  2003/03/06 03:57:47  robertj
00188  * IVR support (work in progress) requiring large changes everywhere.
00189  *
00190  * Revision 2.5  2002/09/16 02:52:35  robertj
00191  * Added #define so can select if #pragma interface/implementation is used on
00192  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00193  *
00194  * Revision 2.4  2002/07/04 07:41:47  robertj
00195  * Fixed memory/thread leak of transports.
00196  *
00197  * Revision 2.3  2002/04/16 08:06:35  robertj
00198  * Fixed GNU warnings.
00199  *
00200  * Revision 2.2  2002/04/05 10:42:04  robertj
00201  * Major changes to support transactions (UDP timeouts and retries).
00202  *
00203  * Revision 2.1  2002/02/01 04:53:01  robertj
00204  * Added (very primitive!) SIP support.
00205  *
00206  */
00207 
00208 #ifndef __OPAL_SIPEP_H
00209 #define __OPAL_SIPEP_H
00210 
00211 #ifdef P_USE_PRAGMA
00212 #pragma interface
00213 #endif
00214 
00215 
00216 #include <opal/endpoint.h>
00217 #include <sip/sippdu.h>
00218  
00219 
00220 class SIPConnection;
00221 
00223 
00224 /* Class to contain parameters about SIP requests which maintain a
00225  * transport open such as REGISTER, SUBSCRIBE and MESSAGE.
00226  * Required to support several concurrent registrations or conversations.
00227  */
00228 class SIPInfo : public PSafeObject 
00229 {
00230   PCLASSINFO(SIPInfo, PSafeObject);
00231   public:
00232     SIPInfo(
00233       SIPEndPoint & ep, 
00234       const PString & name
00235     );
00236 
00237     ~SIPInfo();
00238   
00239     virtual BOOL CreateTransport(OpalTransportAddress & addr);
00240 
00241     virtual void Cancel(SIPTransaction & transaction);
00242 
00243     virtual OpalTransport *GetTransport()
00244     { PWaitAndSignal m(transportMutex); return registrarTransport; }
00245 
00246     virtual SIPAuthentication & GetAuthentication()
00247     { return authentication; }
00248 
00249     virtual const SIPURL & GetRegistrationAddress()
00250     { return registrationAddress; }
00251     
00252     virtual void AppendTransaction(SIPTransaction * transaction) 
00253     { registrations.Append (transaction); }
00254     
00255     virtual void RemoveTransactions() 
00256     { registrations.RemoveAll (); }
00257 
00258     virtual BOOL IsRegistered() 
00259     { return registered; }
00260 
00261     virtual void SetRegistered(BOOL r) 
00262     { registered = r; if (r) registrationTime = PTime ();}
00263 
00264     // An expire time of -1 corresponds to an invalid SIPInfo that 
00265     // should be deleted.
00266     virtual void SetExpire(int e)
00267     { expire = e; }
00268 
00269     virtual int GetExpire()
00270     { return expire; }
00271 
00272     virtual PString GetRegistrationID()
00273     { return registrationID; }
00274 
00275     virtual BOOL HasExpired()
00276     { return (registered && (PTime () - registrationTime) >= PTimeInterval (0, expire)); }
00277 
00278     virtual void SetAuthUser(const PString & u)
00279     { authUser = u;}
00280     
00281     virtual void SetPassword(const PString & p)
00282     { password = p;}
00283     
00284     virtual void SetAuthRealm(const PString & r)
00285     { authRealm = r;}
00286     
00287     virtual void SetBody(const PString & b)
00288     { body = b;}
00289    
00290     virtual SIPTransaction * CreateTransaction(
00291       OpalTransport & t, 
00292       BOOL unregister
00293     ) = 0;
00294 
00295     virtual SIP_PDU::Methods GetMethod() = 0;
00296 
00297     virtual void OnSuccess() = 0;
00298 
00299     virtual void OnFailed(
00300       SIP_PDU::StatusCodes
00301     ) = 0;
00302 
00303     protected:
00304       SIPEndPoint      & ep;
00305       SIPAuthentication  authentication;
00306       OpalTransport    * registrarTransport;
00307       SIPURL             registrationAddress;
00308       PString            registrationID;
00309       SIPTransactionList registrations;
00310       PTime              registrationTime;
00311       BOOL               registered;
00312       int                expire;
00313       PString            authRealm;
00314       PString            authUser;
00315       PString            password;
00316       PString            body;
00317       PMutex             transportMutex;
00318     
00319     private:
00320 };
00321 
00322 class SIPRegisterInfo : public SIPInfo
00323 {
00324   PCLASSINFO(SIPRegisterInfo, SIPInfo);
00325 
00326   public:
00327     SIPRegisterInfo(SIPEndPoint & ep, const PString & adjustedUsername, const PString & authName, const PString & password, int expire);
00328     ~SIPRegisterInfo();
00329     virtual SIPTransaction * CreateTransaction(OpalTransport &, BOOL);
00330     virtual SIP_PDU::Methods GetMethod()
00331     { return SIP_PDU::Method_REGISTER; }
00332 
00333     virtual void OnSuccess();
00334     virtual void OnFailed(SIP_PDU::StatusCodes r);
00335 };
00336 
00337 class SIPMWISubscribeInfo : public SIPInfo
00338 {
00339   PCLASSINFO(SIPMWISubscribeInfo, SIPInfo);
00340   public:
00341     SIPMWISubscribeInfo (SIPEndPoint & ep, const PString & adjustedUsername, int expire);
00342     virtual SIPTransaction * CreateTransaction (OpalTransport &, BOOL);
00343     virtual SIP_PDU::Methods GetMethod ()
00344     { return SIP_PDU::Method_SUBSCRIBE; }
00345     virtual void OnSuccess ();
00346     virtual void OnFailed (SIP_PDU::StatusCodes);
00347 };
00348 
00349 class SIPMessageInfo : public SIPInfo
00350 {
00351   PCLASSINFO(SIPMessageInfo, SIPInfo);
00352   public:
00353     SIPMessageInfo (SIPEndPoint & ep, const PString & adjustedUsername, const PString & body);
00354     virtual SIPTransaction * CreateTransaction (OpalTransport &, BOOL);
00355     virtual SIP_PDU::Methods GetMethod ()
00356     { return SIP_PDU::Method_MESSAGE; }
00357     virtual void OnSuccess ();
00358     virtual void OnFailed (SIP_PDU::StatusCodes);
00359 };
00360 
00361 
00363 
00367 class SIPAuthInfo : public PObject
00368 {
00369   public:
00370     SIPAuthInfo()
00371     { }
00372 
00373     SIPAuthInfo(const PString & u, const PString & p)
00374     { username = u; password = p; }
00375     PString username;
00376     PString password;
00377 };
00378 
00380 
00383 class SIPEndPoint : public OpalEndPoint
00384 {
00385   PCLASSINFO(SIPEndPoint, OpalEndPoint);
00386 
00387   public:
00392     SIPEndPoint(
00393       OpalManager & manager
00394     );
00395 
00398     ~SIPEndPoint();
00400 
00406     virtual PStringArray GetDefaultListeners() const;
00407 
00412     virtual BOOL NewIncomingConnection(
00413       OpalTransport * transport  
00414     );
00415 
00445     virtual BOOL MakeConnection(
00446       OpalCall & call,        
00447       const PString & party,  
00448       void * userData = NULL  
00449     );
00450 
00460     virtual OpalMediaFormatList GetMediaFormats() const;
00462 
00468     virtual SIPConnection * CreateConnection(
00469       OpalCall & call,            
00470       const PString & token,      
00471       void * userData,            
00472       const SIPURL & destination, 
00473       OpalTransport * transport,  
00474       SIP_PDU * invite            
00475     );
00476     
00479     virtual BOOL SetupTransfer(
00480       const PString & token,        
00481       const PString & callIdentity, 
00482       const PString & remoteParty,  
00483       void * userData = NULL        
00484     );
00485     
00489     virtual BOOL ForwardConnection(
00490       SIPConnection & connection,     
00491       const PString & forwardParty    
00492     );
00493 
00495   
00498     OpalTransport * CreateTransport(
00499       const OpalTransportAddress & address
00500     );
00501 
00502     virtual void HandlePDU(
00503       OpalTransport & transport
00504     );
00505 
00508     virtual BOOL OnReceivedPDU(
00509       OpalTransport & transport,
00510       SIP_PDU * pdu
00511     );
00512 
00515     virtual void OnReceivedResponse(
00516       SIPTransaction & transaction,
00517       SIP_PDU & response
00518     );
00519 
00522     virtual BOOL OnReceivedINVITE(
00523       OpalTransport & transport,
00524       SIP_PDU * pdu
00525     );
00526   
00529     virtual void OnReceivedAuthenticationRequired(
00530       SIPTransaction & transaction,
00531       SIP_PDU & response
00532     );
00533 
00537     virtual void OnReceivedOK(
00538       SIPTransaction & transaction,
00539       SIP_PDU & response
00540     );
00541     
00544     virtual BOOL OnReceivedNOTIFY(
00545       OpalTransport & transport,
00546       SIP_PDU & response
00547     );
00548 
00551     virtual void OnReceivedMESSAGE(
00552       OpalTransport & transport,
00553       SIP_PDU & response
00554     );
00555     
00563     virtual void OnRTPStatistics(
00564       const SIPConnection & connection,  
00565       const RTP_Session & session         
00566     ) const;
00568  
00569 
00574     PSafePtr<SIPConnection> GetSIPConnectionWithLock(
00575       const PString & token,     
00576       PSafetyMode mode = PSafeReadWrite
00577     ) { return PSafePtrCast<OpalConnection, SIPConnection>(GetConnectionWithLock(token, mode)); }
00578 
00579     virtual BOOL IsAcceptedAddress(const SIPURL & toAddr);
00580 
00581 
00584     virtual void OnMessageReceived (const SIPURL & from,
00585                                     const PString & body);
00586 
00587                                 
00600     BOOL Register(
00601       const PString & host,
00602       const PString & username = PString::Empty(),
00603       const PString & autName = PString::Empty(),
00604       const PString & password = PString::Empty(),
00605       const PString & authRealm = PString::Empty(),
00606       int timeout = 0
00607     );
00608 
00611     virtual void OnMWIReceived (
00612       const PString & host,
00613       const PString & user,
00614       SIPMWISubscribe::MWIType type,
00615       const PString & msgs);
00616 
00617     
00621     BOOL MWISubscribe(
00622       const PString & host,
00623       const PString & username,
00624       int timeout = 0
00625     );
00626    
00627     
00632     virtual void OnRegistrationFailed(
00633       const PString & host,
00634       const PString & userName,
00635       SIP_PDU::StatusCodes reason,
00636       BOOL wasRegistering);
00637     
00638       
00643     virtual void OnRegistered(
00644       const PString & host,
00645       const PString & userName,
00646       BOOL wasRegistering);
00647 
00648     
00652     BOOL IsRegistered(const PString & host);
00653 
00654 
00657     unsigned GetRegistrationsCount () { return activeSIPInfo.GetRegistrationsCount (); }
00658     
00659     
00662     BOOL IsSubscribed(
00663       const PString & host, 
00664       const PString & user);
00665  
00666     
00670     BOOL Unregister(const PString & host,
00671                     const PString & user);
00672 
00673     
00677     BOOL MWIUnsubscribe(
00678       const PString & host,
00679       const PString & user);
00680     
00681     
00686     virtual void OnMessageFailed(
00687       const SIPURL & messageUrl,
00688       SIP_PDU::StatusCodes reason);
00689     
00690 
00691     void SetMIMEForm(BOOL v) { mimeForm = v; }
00692     BOOL GetMIMEForm() const { return mimeForm; }
00693 
00694     void SetMaxRetries(unsigned r) { maxRetries = r; }
00695     unsigned GetMaxRetries() const { return maxRetries; }
00696 
00697     void SetRetryTimeouts(
00698       const PTimeInterval & t1,
00699       const PTimeInterval & t2
00700     ) { retryTimeoutMin = t1; retryTimeoutMax = t2; }
00701     const PTimeInterval & GetRetryTimeoutMin() const { return retryTimeoutMin; }
00702     const PTimeInterval & GetRetryTimeoutMax() const { return retryTimeoutMax; }
00703 
00704     void SetNonInviteTimeout(
00705       const PTimeInterval & t
00706     ) { nonInviteTimeout = t; }
00707     const PTimeInterval & GetNonInviteTimeout() const { return nonInviteTimeout; }
00708 
00709     void SetPduCleanUpTimeout(
00710       const PTimeInterval & t
00711     ) { pduCleanUpTimeout = t; }
00712     const PTimeInterval & GetPduCleanUpTimeout() const { return pduCleanUpTimeout; }
00713 
00714     void SetInviteTimeout(
00715       const PTimeInterval & t
00716     ) { inviteTimeout = t; }
00717     const PTimeInterval & GetInviteTimeout() const { return inviteTimeout; }
00718 
00719     void SetAckTimeout(
00720       const PTimeInterval & t
00721     ) { ackTimeout = t; }
00722     const PTimeInterval & GetAckTimeout() const { return ackTimeout; }
00723 
00724     void SetRegistrarTimeToLive(
00725       const PTimeInterval & t
00726     ) { registrarTimeToLive = t; }
00727     const PTimeInterval & GetRegistrarTimeToLive() const { return registrarTimeToLive; }
00728     
00729     void SetNotifierTimeToLive(
00730       const PTimeInterval & t
00731     ) { notifierTimeToLive = t; }
00732     const PTimeInterval & GetNotifierTimeToLive() const { return notifierTimeToLive; }
00733     
00734     void SetNATBindingTimeout(
00735       const PTimeInterval & t
00736     ) { natBindingTimeout = t; natBindingTimer.RunContinuous (natBindingTimeout); }
00737     const PTimeInterval & GetNATBindingTimeout() const { return natBindingTimeout; }
00738 
00739     void AddTransaction(
00740       SIPTransaction * transaction
00741     ) { PWaitAndSignal m(transactionsMutex); transactions.SetAt(transaction->GetTransactionID(), transaction); }
00742 
00743     void RemoveTransaction(
00744       SIPTransaction * transaction
00745     ) { PWaitAndSignal m(transactionsMutex); transactions.SetAt(transaction->GetTransactionID(), NULL); }
00746 
00747     
00750     unsigned GetNextCSeq() { return ++lastSentCSeq; }
00751 
00752     
00755     BOOL GetAuthentication(const PString & authRealm, SIPAuthentication &); 
00756     
00757 
00763     const SIPURL GetRegisteredPartyName(const PString &);
00764     
00765 
00775     const SIPURL GetLocalURL(
00776        const OpalTransport & transport,             
00777        const PString & userName = PString::Empty()  
00778     );
00779     
00780     
00783     const SIPURL & GetProxy() const { return proxy; }
00784 
00785     
00788     void SetProxy(const SIPURL & url);
00789     
00790     
00793     void SetProxy(
00794       const PString & hostname,
00795       const PString & username,
00796       const PString & password
00797     );
00798 
00799     
00802     virtual PString GetUserAgent() const;
00803 
00804     
00807     void SetUserAgent(const PString & str) { userAgentString = str; }
00808 
00809     
00812     BOOL SendMessage (const SIPURL & url, const PString & body);
00813     
00814 
00817     enum NATBindingRefreshMethod{
00818       None,
00819       Options,
00820       EmptyRequest,
00821       NumMethods
00822     };
00823 
00824 
00827     void SetNATBindingRefreshMethod(const NATBindingRefreshMethod m) { natMethod = m; }
00828 
00829 
00830   protected:
00831     PDECLARE_NOTIFIER(PThread, SIPEndPoint, TransportThreadMain);
00832     PDECLARE_NOTIFIER(PTimer, SIPEndPoint, NATBindingRefresh);
00833     PDECLARE_NOTIFIER(PTimer, SIPEndPoint, RegistrationRefresh);
00834 
00839     class RegistrationList : public PSafeList<SIPInfo>
00840     {
00841       public:
00842 
00846             unsigned GetRegistrationsCount ()
00847             {
00848               unsigned count = 0;
00849               for (PSafePtr<SIPInfo> info(*this, PSafeReference); info != NULL; ++info)
00850                 if (info->IsRegistered() && info->GetMethod() == SIP_PDU::Method_REGISTER) 
00851                   count++;
00852               return count;
00853             }
00854           
00858             SIPInfo *FindSIPInfoByCallID (const PString & callID, PSafetyMode m)
00859             {
00860               for (PSafePtr<SIPInfo> info(*this, m); info != NULL; ++info)
00861                       if (callID == info->GetRegistrationID())
00862                         return info;
00863               return NULL;
00864             }
00865 
00869             SIPInfo *FindSIPInfoByAuthRealm (const PString & authRealm, const PString & userName, PSafetyMode m)
00870             {
00871               for (PSafePtr<SIPInfo> info(*this, m); info != NULL; ++info)
00872                       if (authRealm == info->GetAuthentication().GetAuthRealm() && (userName.IsEmpty() || userName == info->GetAuthentication().GetUsername()))
00873                         return info;
00874               return NULL;
00875             }
00876 
00884             SIPInfo *FindSIPInfoByUrl (const PString & url, SIP_PDU::Methods meth, PSafetyMode m)
00885             {
00886               for (PSafePtr<SIPInfo> info(*this, m); info != NULL; ++info) {
00887                       if (SIPURL(url) == info->GetRegistrationAddress() && meth == info->GetMethod())
00888                         return info;
00889               }
00890               return NULL;
00891             }
00892 
00898             SIPInfo *FindSIPInfoByDomain (const PString & name, SIP_PDU::Methods meth, PSafetyMode m)
00899             {
00900               OpalTransportAddress addr = name;
00901               for (PSafePtr<SIPInfo> info(*this, m); info != NULL; ++info) {
00902                       if ((name == info->GetRegistrationAddress().GetHostName() || (info->GetTransport() && addr.GetHostName() == info->GetTransport()->GetRemoteAddress().GetHostName()) && meth == info->GetMethod()))
00903                         return info;
00904               }
00905               return NULL;
00906             }
00907     };
00908 
00909     static BOOL WriteSIPInfo(
00910       OpalTransport & transport, 
00911       void * info
00912     );
00913 
00914     BOOL TransmitSIPInfo (
00915       SIP_PDU::Methods method,
00916       const PString & host, 
00917       const PString & username, 
00918       const PString & authName = PString::Empty(),
00919       const PString & password = PString::Empty(), 
00920       const PString & authRealm = PString::Empty(),
00921       const PString & body = PString::Empty(),
00922       int timeout = 0
00923     );
00924 
00925     BOOL TransmitSIPUnregistrationInfo (
00926       const PString & host, 
00927       const PString & username, 
00928       SIP_PDU::Methods method
00929     );
00930     
00931     void ParsePartyName(
00932       const PString & remoteParty,     
00933       PString & party);                
00934 
00935     SIPURL            proxy;
00936     PString           userAgentString;
00937 
00938     BOOL          mimeForm;
00939     unsigned      maxRetries;
00940     PTimeInterval retryTimeoutMin;   // T1
00941     PTimeInterval retryTimeoutMax;   // T2
00942     PTimeInterval nonInviteTimeout;  // T3
00943     PTimeInterval pduCleanUpTimeout; // T4
00944     PTimeInterval inviteTimeout;
00945     PTimeInterval ackTimeout;
00946     PTimeInterval registrarTimeToLive;
00947     PTimeInterval notifierTimeToLive;
00948     PTimeInterval natBindingTimeout;
00949     
00950     RegistrationList   activeSIPInfo;
00951 
00952     PTimer registrationTimer; // Used to refresh the REGISTER and the SUBSCRIBE transactions.
00953     SIPTransactionList messages;
00954     SIPTransactionDict transactions;
00955 
00956     PMutex                  natTransportMutex;
00957     PTimer                  natBindingTimer;
00958     NATBindingRefreshMethod natMethod;
00959     PList<OpalTransport>    natTransports;
00960 
00961     PMutex             transactionsMutex;
00962 
00963     unsigned           lastSentCSeq;
00964 };
00965 
00966 #endif // __OPAL_SIPEP_H
00967 
00968 
00969 // End of File ///////////////////////////////////////////////////////////////

Generated on Mon Jan 7 22:31:19 2008 for OPAL by  doxygen 1.4.6