# sippdu.h

Go to the documentation of this file.

    00001 /*
    00002  * sippdu.h
    00003  *
    00004  * Session Initiation Protocol PDU support.
    00005  *
    00006  * Open Phone Abstraction Library (OPAL)
    00007  * Formally known as the Open H323 project.
    00008  *
    00009  * Copyright (c) 2002 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  * $Revision: 21004 $
    00028  * $Author: rjongbloed $
    00029  * $Date: 2008-09-16 07:08:56 +0000 (Tue, 16 Sep 2008) $
    00030  */
    00031
    00032 #ifndef __OPAL_SIPPDU_H
    00033 #define __OPAL_SIPPDU_H
    00034
    00035 #ifdef P_USE_PRAGMA
    00036 #pragma interface
    00037 #endif
    00038
    00039 #include <opal/buildopts.h>
    00040
    00041 #include <ptclib/mime.h>
    00042 #include <ptclib/url.h>
    00043 #include <sip/sdp.h>
    00044 #include <opal/rtpconn.h>
    00045
    00046
    00047 class OpalTransport;
    00048 class OpalTransportAddress;
    00049 class OpalProductInfo;
    00050
    00051 class SIPEndPoint;
    00052 class SIPConnection;
    00053 class SIP_PDU;
    00054
    00055
    00057 // SIPURL
    00058
    00064 class SIPURL : public PURL
    00065 {
    00066   PCLASSINFO(SIPURL, PURL);
    00067   public:
    00068     SIPURL();
    00069
    00072     SIPURL(
    00073       const char * cstr,
    00074       const char * defaultScheme = NULL
    00075     );
    00076
    00079     SIPURL(
    00080       const PString & str,
    00081       const char * defaultScheme = NULL
    00082     );
    00083
    00091     SIPURL(
    00092       const PString & name,
    00093       const OpalTransportAddress & address,
    00094       WORD listenerPort = 0
    00095     );
    00096
    00105     virtual Comparison Compare(
    00106       const PObject & obj
    00107     ) const;
    00108
    00112     PString AsQuotedString() const;
    00113
    00116     PString GetDisplayName(PBoolean useDefault = PTrue) const;
    00117
    00118     void SetDisplayName(const PString & str)
    00119       { displayName = str; }
    00120
    00123     PString GetFieldParameters() const { return fieldParameters; }
    00124
    00127     OpalTransportAddress GetHostAddress() const;
    00128
    00129     enum UsageContext {
    00130       ExternalURI,
    00131       RequestURI,
    00132       ToURI,
    00133       FromURI,
    00134       ContactURI,
    00135       RouteURI
    00136     };
    00137
    00143     void Sanitise(
    00144       UsageContext context
    00145     );
    00146
    00152     PBoolean AdjustToDNS(
    00153       PINDEX entry = 0
    00154     );
    00155
    00156   protected:
    00175     virtual PBoolean InternalParse(
    00176       const char * cstr,
    00177       const char * defaultScheme
    00178     );
    00179
    00180     PString displayName;
    00181     PString fieldParameters;
    00182 };
    00183
    00184
    00186 // SIPMIMEInfo
    00187
    00218 class SIPMIMEInfo : public PMIMEInfo
    00219 {
    00220   PCLASSINFO(SIPMIMEInfo, PMIMEInfo);
    00221   public:
    00222     SIPMIMEInfo(bool compactForm = false);
    00223
    00224     virtual void PrintOn(ostream & strm) const;
    00225     virtual void ReadFrom(istream & strm);
    00226
    00227     void SetCompactForm(bool form) { compactForm = form; }
    00228
    00229     PString GetContentType() const;
    00230     void SetContentType(const PString & v);
    00231
    00232     PString GetContentEncoding() const;
    00233     void SetContentEncoding(const PString & v);
    00234
    00235     PString GetFrom() const;
    00236     void SetFrom(const PString & v);
    00237
    00238     PString GetPAssertedIdentity() const;
    00239     void SetPAssertedIdentity(const PString & v);
    00240
    00241     PString GetPPreferredIdentity() const;
    00242     void SetPPreferredIdentity(const PString & v);
    00243
    00244     PString GetAccept() const;
    00245     void SetAccept(const PString & v);
    00246
    00247     PString GetAcceptEncoding() const;
    00248     void SetAcceptEncoding(const PString & v);
    00249
    00250     PString GetAcceptLanguage() const;
    00251     void SetAcceptLanguage(const PString & v);
    00252
    00253     PString GetAllow() const;
    00254     void SetAllow(const PString & v);
    00255
    00256     PString GetCallID() const;
    00257     void SetCallID(const PString & v);
    00258
    00259     PString GetContact() const;
    00260     bool GetContacts(std::vector<SIPURL> & contacts) const;
    00261     void SetContact(const PString & v);
    00262     void SetContact(const SIPURL & url);
    00263
    00264     PString GetSubject() const;
    00265     void SetSubject(const PString & v);
    00266
    00267     PString GetTo() const;
    00268     void SetTo(const PString & v);
    00269
    00270     PString GetVia() const;
    00271     void SetVia(const PString & v);
    00272
    00273     PStringList GetViaList() const;
    00274     void SetViaList(const PStringList & v);
    00275
    00276     PString GetReferTo() const;
    00277     void SetReferTo(const PString & r);
    00278
    00279     PString GetReferredBy() const;
    00280     void SetReferredBy(const PString & r);
    00281
    00282     PINDEX  GetContentLength() const;
    00283     void SetContentLength(PINDEX v);
    00284     PBoolean IsContentLengthPresent() const;
    00285
    00286     PString GetCSeq() const;
    00287     void SetCSeq(const PString & v);
    00288
    00289     PString GetDate() const;
    00290     void SetDate(const PString & v);
    00291     void SetDate(const PTime & t);
    00292     void SetDate(void); // set to current date
    00293
    00294     unsigned GetExpires(unsigned dflt = UINT_MAX) const;// returns default value if not found
    00295     void SetExpires(unsigned v);
    00296
    00297     PINDEX GetMaxForwards() const;
    00298     void SetMaxForwards(PINDEX v);
    00299
    00300     PINDEX GetMinExpires() const;
    00301     void SetMinExpires(PINDEX v);
    00302
    00303     PString GetProxyAuthenticate() const;
    00304     void SetProxyAuthenticate(const PString & v);
    00305
    00306     PStringList GetRoute() const;
    00307     void SetRoute(const PStringList & v);
    00308
    00309     PStringList GetRecordRoute() const;
    00310     void SetRecordRoute(const PStringList & v);
    00311
    00312     unsigned GetCSeqIndex() const { return GetCSeq().AsUnsigned(); }
    00313
    00314     PString GetSupported() const;
    00315     void SetSupported(const PString & v);
    00316
    00317     PString GetUnsupported() const;
    00318     void SetUnsupported(const PString & v);
    00319
    00320     PString GetEvent() const;
    00321     void SetEvent(const PString & v);
    00322
    00323     PString GetSubscriptionState() const;
    00324     void SetSubscriptionState(const PString & v);
    00325
    00326     PString GetUserAgent() const;
    00327     void SetUserAgent(const PString & v);
    00328
    00329     PString GetOrganization() const;
    00330     void SetOrganization(const PString & v);
    00331
    00332     void GetProductInfo(OpalProductInfo & info);
    00333     void SetProductInfo(const PString & ua, const OpalProductInfo & info);
    00334
    00335     PString GetWWWAuthenticate() const;
    00336     void SetWWWAuthenticate(const PString & v);
    00337
    00338     PString GetSIPIfMatch() const;
    00339     void SetSIPIfMatch(const PString & v);
    00340
    00341     PString GetSIPETag() const;
    00342     void SetSIPETag(const PString & v);
    00343
    00346     PString GetFieldParameter(
    00347       const PString & fieldName,
    00348       const PString & paramName,
    00349       const PString & defaultValue = PString::Empty()
    00350     ) const { return ExtractFieldParameter((*this)(fieldName), paramName, defaultValue); }
    00351
    00356     void SetFieldParameter(
    00357       const PString & fieldName,
    00358       const PString & paramName,
    00359       const PString & newValue
    00360     ) { SetAt(fieldName, InsertFieldParameter((*this)(fieldName), paramName, newValue)); }
    00361
    00364     static PString ExtractFieldParameter(
    00365       const PString & fieldValue,
    00366       const PString & paramName,
    00367       const PString & defaultValue = PString::Empty()
    00368     );
    00369
    00374     static PString InsertFieldParameter(
    00375       const PString & fieldValue,
    00376       const PString & paramName,
    00377       const PString & newValue
    00378     );
    00379
    00380   protected:
    00383     PStringList GetRouteList(const char * name) const;
    00384
    00388     void SetRouteList(const char * name, const PStringList & v);
    00389
    00391     bool compactForm;
    00392 };
    00393
    00394
    00396 // SIPAuthentication
    00397
    00398 class SIPAuthentication : public PObject
    00399 {
    00400   PCLASSINFO(SIPAuthentication, PObject);
    00401   public:
    00402     SIPAuthentication();
    00403
    00404     virtual bool EquivalentTo(
    00405       const SIPAuthentication & _oldAuth
    00406     ) = 0;
    00407
    00408     virtual PBoolean Parse(
    00409       const PString & auth,
    00410       PBoolean proxy
    00411     ) = 0;
    00412
    00413     virtual PBoolean Authorise(
    00414       SIP_PDU & pdu
    00415     ) const =  0;
    00416
    00417     virtual PBoolean IsProxy() const               { return isProxy; }
    00418
    00419     virtual PString GetUsername() const   { return username; }
    00420     virtual PString GetPassword() const   { return password; }
    00421     virtual PString GetAuthRealm() const  { return authRealm; }
    00422
    00423     virtual void SetUsername(const PString & user) { username = user; }
    00424     virtual void SetPassword(const PString & pass) { password = pass; }
    00425     virtual void SetAuthRealm(const PString & r)   { authRealm = r; }
    00426
    00427     PString GetAuthParam(const PString & auth, const char * name) const;
    00428     PString AsHex(PMessageDigest5::Code & digest) const;
    00429     PString AsHex(const PBYTEArray & data) const;
    00430
    00431     static SIPAuthentication * ParseAuthenticationRequired(bool isProxy,
    00432                                                 const PString & line,
    00433                                                       PString & errorMsg);
    00434
    00435   protected:
    00436     PBoolean  isProxy;
    00437
    00438     PString   username;
    00439     PString   password;
    00440     PString   authRealm;
    00441 };
    00442
    00443 typedef PFactory<SIPAuthentication> SIPAuthenticationFactory;
    00444
    00446
    00447 class SIPDigestAuthentication : public SIPAuthentication
    00448 {
    00449   PCLASSINFO(SIPDigestAuthentication, SIPAuthentication);
    00450   public:
    00451     SIPDigestAuthentication();
    00452
    00453     SIPDigestAuthentication & operator =(
    00454       const SIPDigestAuthentication & auth
    00455     );
    00456
    00457     bool EquivalentTo(
    00458       const SIPAuthentication & _oldAuth
    00459     );
    00460
    00461     PBoolean Parse(
    00462       const PString & auth,
    00463       PBoolean proxy
    00464     );
    00465
    00466     PBoolean Authorise(
    00467       SIP_PDU & pdu
    00468     ) const;
    00469
    00470     enum Algorithm {
    00471       Algorithm_MD5,
    00472       NumAlgorithms
    00473     };
    00474     const PString & GetNonce() const       { return nonce; }
    00475     Algorithm GetAlgorithm() const         { return algorithm; }
    00476     const PString & GetOpaque() const      { return opaque; }
    00477
    00478   protected:
    00479     PString   nonce;
    00480     Algorithm algorithm;
    00481     PString   opaque;
    00482
    00483     PBoolean qopAuth;
    00484     PBoolean qopAuthInt;
    00485     PString cnonce;
    00486     mutable PAtomicInteger nonceCount;
    00487 };
    00488
    00490 // SIP_PDU
    00491
    00497 class SIP_PDU : public PSafeObject
    00498 {
    00499   PCLASSINFO(SIP_PDU, PSafeObject);
    00500   public:
    00501     enum Methods {
    00502       Method_INVITE,
    00503       Method_ACK,
    00504       Method_OPTIONS,
    00505       Method_BYE,
    00506       Method_CANCEL,
    00507       Method_REGISTER,
    00508       Method_SUBSCRIBE,
    00509       Method_NOTIFY,
    00510       Method_REFER,
    00511       Method_MESSAGE,
    00512       Method_INFO,
    00513       Method_PING,
    00514       Method_PUBLISH,
    00515       NumMethods
    00516     };
    00517
    00518     enum StatusCodes {
    00519       IllegalStatusCode,
    00520       Local_TransportError,
    00521       Local_BadTransportAddress,
    00522
    00523       Information_Trying                  = 100,
    00524       Information_Ringing                 = 180,
    00525       Information_CallForwarded           = 181,
    00526       Information_Queued                  = 182,
    00527       Information_Session_Progress        = 183,
    00528
    00529       Successful_OK                       = 200,
    00530       Successful_Accepted                         = 202,
    00531
    00532       Redirection_MultipleChoices         = 300,
    00533       Redirection_MovedPermanently        = 301,
    00534       Redirection_MovedTemporarily        = 302,
    00535       Redirection_UseProxy                = 305,
    00536       Redirection_AlternativeService      = 380,
    00537
    00538       Failure_BadRequest                  = 400,
    00539       Failure_UnAuthorised                = 401,
    00540       Failure_PaymentRequired             = 402,
    00541       Failure_Forbidden                   = 403,
    00542       Failure_NotFound                    = 404,
    00543       Failure_MethodNotAllowed            = 405,
    00544       Failure_NotAcceptable               = 406,
    00545       Failure_ProxyAuthenticationRequired = 407,
    00546       Failure_RequestTimeout              = 408,
    00547       Failure_Conflict                    = 409,
    00548       Failure_Gone                        = 410,
    00549       Failure_LengthRequired              = 411,
    00550       Failure_RequestEntityTooLarge       = 413,
    00551       Failure_RequestURITooLong           = 414,
    00552       Failure_UnsupportedMediaType        = 415,
    00553       Failure_UnsupportedURIScheme        = 416,
    00554       Failure_BadExtension                = 420,
    00555       Failure_ExtensionRequired           = 421,
    00556       Failure_IntervalTooBrief            = 423,
    00557       Failure_TemporarilyUnavailable      = 480,
    00558       Failure_TransactionDoesNotExist     = 481,
    00559       Failure_LoopDetected                = 482,
    00560       Failure_TooManyHops                 = 483,
    00561       Failure_AddressIncomplete           = 484,
    00562       Failure_Ambiguous                   = 485,
    00563       Failure_BusyHere                    = 486,
    00564       Failure_RequestTerminated           = 487,
    00565       Failure_NotAcceptableHere           = 488,
    00566       Failure_BadEvent                    = 489,
    00567       Failure_RequestPending              = 491,
    00568       Failure_Undecipherable              = 493,
    00569
    00570       Failure_InternalServerError         = 500,
    00571       Failure_NotImplemented              = 501,
    00572       Failure_BadGateway                  = 502,
    00573       Failure_ServiceUnavailable          = 503,
    00574       Failure_ServerTimeout               = 504,
    00575       Failure_SIPVersionNotSupported      = 505,
    00576       Failure_MessageTooLarge             = 513,
    00577
    00578       GlobalFailure_BusyEverywhere        = 600,
    00579       GlobalFailure_Decline               = 603,
    00580       GlobalFailure_DoesNotExistAnywhere  = 604,
    00581       GlobalFailure_NotAcceptable         = 606,
    00582
    00583       MaxStatusCode                       = 699
    00584     };
    00585
    00586         static const char * GetStatusCodeDescription(int code);
    00587     friend ostream & operator<<(ostream & strm, StatusCodes status);
    00588
    00589     enum {
    00590       MaxSize = 65535
    00591     };
    00592
    00593     SIP_PDU();
    00594
    00597     SIP_PDU(
    00598       Methods method,
    00599       const SIPURL & dest,
    00600       const PString & to,
    00601       const PString & from,
    00602       const PString & callID,
    00603       unsigned cseq,
    00604       const OpalTransportAddress & via
    00605     );
    00608     SIP_PDU(
    00609       Methods method,
    00610       SIPConnection & connection,
    00611       const OpalTransport & transport
    00612     );
    00613
    00617     SIP_PDU(
    00618       const SIP_PDU & request,
    00619       StatusCodes code,
    00620       const char * contact = NULL,
    00621       const char * extra = NULL,
    00622       const SDPSessionDescription * sdp = NULL
    00623     );
    00624     SIP_PDU(const SIP_PDU &);
    00625     SIP_PDU & operator=(const SIP_PDU &);
    00626     ~SIP_PDU();
    00627
    00628     void PrintOn(
    00629       ostream & strm
    00630     ) const;
    00631
    00632     void Construct(
    00633       Methods method
    00634     );
    00635     void Construct(
    00636       Methods method,
    00637       const SIPURL & dest,
    00638       const PString & to,
    00639       const PString & from,
    00640       const PString & callID,
    00641       unsigned cseq,
    00642       const OpalTransportAddress & via
    00643     );
    00644     void Construct(
    00645       Methods method,
    00646       SIPConnection & connection,
    00647       const OpalTransport & transport
    00648     );
    00649
    00654     PBoolean SetRoute(const PStringList & routeSet);
    00655
    00658     void SetAllow(unsigned bitmask);
    00659
    00662     void AdjustVia(OpalTransport & transport);
    00663
    00666     PBoolean Read(
    00667       OpalTransport & transport
    00668     );
    00669
    00672     PBoolean Write(
    00673       OpalTransport & transport,
    00674       const OpalTransportAddress & remoteAddress = OpalTransportAddress()
    00675     );
    00676
    00679     bool SendResponse(
    00680       OpalTransport & transport,
    00681       StatusCodes code,
    00682       const char * contact = NULL,
    00683       const char * extra = NULL
    00684     );
    00685     bool SendResponse(
    00686       OpalTransport & transport,
    00687       SIP_PDU & response
    00688     );
    00689
    00693     PString Build();
    00694
    00695     PString GetTransactionID() const;
    00696
    00697     Methods GetMethod() const                { return method; }
    00698     StatusCodes GetStatusCode () const       { return statusCode; }
    00699     const SIPURL & GetURI() const            { return uri; }
    00700     unsigned GetVersionMajor() const         { return versionMajor; }
    00701     unsigned GetVersionMinor() const         { return versionMinor; }
    00702     const PString & GetEntityBody() const    { return entityBody; }
    00703           PString & GetEntityBody()          { return entityBody; }
    00704     const PString & GetInfo() const          { return info; }
    00705     const SIPMIMEInfo & GetMIME() const      { return mime; }
    00706           SIPMIMEInfo & GetMIME()            { return mime; }
    00707     void SetURI(const SIPURL & newuri)       { uri = newuri; }
    00708     SDPSessionDescription * GetSDP();
    00709
    00710   protected:
    00711     Methods     method;                 // Request type, ==NumMethods for Response
    00712     StatusCodes statusCode;
    00713     SIPURL      uri;                    // display name & URI, no tag
    00714     unsigned    versionMajor;
    00715     unsigned    versionMinor;
    00716     PString     info;
    00717     SIPMIMEInfo mime;
    00718     PString     entityBody;
    00719
    00720     SDPSessionDescription * m_SDP;
    00721
    00722     mutable PString transactionID;
    00723 };
    00724
    00725
    00726 PQUEUE(SIP_PDU_Queue, SIP_PDU);
    00727
    00728
    00729 #if PTRACING
    00730 ostream & operator<<(ostream & strm, SIP_PDU::Methods method);
    00731 #endif
    00732
    00733
    00735 // SIPTransaction
    00736
    00747 class SIPTransaction : public SIP_PDU
    00748 {
    00749     PCLASSINFO(SIPTransaction, SIP_PDU);
    00750   public:
    00751     SIPTransaction(
    00752       SIPEndPoint   & endpoint,
    00753       OpalTransport & transport,
    00754       const PTimeInterval & minRetryTime = PMaxTimeInterval,
    00755       const PTimeInterval & maxRetryTime = PMaxTimeInterval
    00756     );
    00760     SIPTransaction(
    00761       SIPConnection & connection,
    00762       OpalTransport & transport,
    00763       Methods method = NumMethods
    00764     );
    00765     ~SIPTransaction();
    00766
    00767     PBoolean Start();
    00768     PBoolean IsInProgress() const { return state == Trying || state == Proceeding; }
    00769     PBoolean IsFailed() const { return state > Terminated_Success; }
    00770     PBoolean IsCompleted() const { return state >= Completed; }
    00771     PBoolean IsCanceled() const { return state == Cancelling || state == Terminated_Cancelled || state == Terminated_Aborted; }
    00772     PBoolean IsTerminated() const { return state >= Terminated_Success; }
    00773
    00774     void WaitForCompletion();
    00775     PBoolean Cancel();
    00776     void Abort();
    00777
    00778     virtual PBoolean OnReceivedResponse(SIP_PDU & response);
    00779     virtual PBoolean OnCompleted(SIP_PDU & response);
    00780
    00781     OpalTransport & GetTransport() const  { return transport; }
    00782     SIPConnection * GetConnection() const { return connection; }
    00783     PString         GetInterface() const { return localInterface; }
    00784
    00785   protected:
    00786     void Construct(
    00787       const PTimeInterval & minRetryTime = PMaxTimeInterval,
    00788       const PTimeInterval & maxRetryTime = PMaxTimeInterval
    00789     );
    00790     bool SendPDU(SIP_PDU & pdu);
    00791     bool ResendCANCEL();
    00792
    00793     PDECLARE_NOTIFIER(PTimer, SIPTransaction, OnRetry);
    00794     PDECLARE_NOTIFIER(PTimer, SIPTransaction, OnTimeout);
    00795
    00796     enum States {
    00797       NotStarted,
    00798       Trying,
    00799       Aborting,
    00800       Proceeding,
    00801       Cancelling,
    00802       Completed,
    00803       Terminated_Success,
    00804       Terminated_Timeout,
    00805       Terminated_RetriesExceeded,
    00806       Terminated_TransportError,
    00807       Terminated_Cancelled,
    00808       Terminated_Aborted,
    00809       NumStates
    00810     };
    00811     virtual void SetTerminated(States newState);
    00812
    00813     SIPEndPoint           & endpoint;
    00814     OpalTransport         & transport;
    00815     PSafePtr<SIPConnection> connection;
    00816     PTimeInterval           retryTimeoutMin;
    00817     PTimeInterval           retryTimeoutMax;
    00818
    00819     States     state;
    00820     unsigned   retry;
    00821     PTimer     retryTimer;
    00822     PTimer     completionTimer;
    00823     PSyncPoint completed;
    00824     PString    localInterface;
    00825     OpalTransportAddress m_remoteAddress;
    00826 };
    00827
    00828
    00830 // SIPInvite
    00831
    00837 class SIPInvite : public SIPTransaction
    00838 {
    00839     PCLASSINFO(SIPInvite, SIPTransaction);
    00840   public:
    00841     SIPInvite(
    00842       SIPConnection & connection,
    00843       OpalTransport & transport,
    00844       OpalRTPSessionManager * sm
    00845     );
    00846
    00847     virtual PBoolean OnReceivedResponse(SIP_PDU & response);
    00848
    00849     OpalRTPSessionManager & GetSessionManager() { return rtpSessions; }
    00850
    00851   protected:
    00852     OpalRTPSessionManager rtpSessions;
    00853 };
    00854
    00855
    00857
    00858 class SIPRegister : public SIPTransaction
    00859 {
    00860     PCLASSINFO(SIPRegister, SIPTransaction);
    00861   public:
    00862     struct Params {
    00863       Params();
    00864
    00865       PString       m_addressOfRecord;
    00866       PString       m_registrarAddress;
    00867       PString       m_contactAddress;
    00868       PString       m_authID;
    00869       PString       m_password;
    00870       PString       m_realm;
    00871       unsigned      m_expire;
    00872       unsigned      m_restoreTime;
    00873       PTimeInterval m_minRetryTime;
    00874       PTimeInterval m_maxRetryTime;
    00875     };
    00876
    00877     SIPRegister(
    00878       SIPEndPoint   & endpoint,
    00879       OpalTransport & transport,
    00880       const PStringList & routeSet,
    00881       const PString & id,
    00882       const Params & params
    00883     );
    00884 };
    00885
    00886
    00888
    00889 class SIPSubscribe : public SIPTransaction
    00890 {
    00891     PCLASSINFO(SIPSubscribe, SIPTransaction);
    00892   public:
    00895     enum PredefinedPackages {
    00896       MessageSummary,
    00897       Presence,
    00898       NumPredefinedPackages
    00899     };
    00900     static PredefinedPackages GetEventPackage(const PString & name);
    00901     static PString GetEventPackageName(PredefinedPackages pkg);
    00902
    00903     struct Params {
    00904       Params(PredefinedPackages pkg = NumPredefinedPackages);
    00905
    00906       PString       m_eventPackage;
    00907       PString       m_mimeType;
    00908       PString       m_targetAddress;
    00909       PString       m_contactAddress;
    00910       PString       m_authID;
    00911       PString       m_password;
    00912       PString       m_realm;
    00913       unsigned      m_expire;
    00914       unsigned      m_restoreTime;
    00915       PTimeInterval m_minRetryTime;
    00916       PTimeInterval m_maxRetryTime;
    00917     };
    00918
    00921     SIPSubscribe(
    00922         SIPEndPoint & ep,
    00923         OpalTransport & trans,
    00924         const PStringList & routeSet,
    00925         const PString & to,
    00926         const PString & from,
    00927         const PString & id,
    00928         unsigned cseq,
    00929         const Params & params
    00930     );
    00931 };
    00932
    00933
    00935
    00936 class SIPPublish : public SIPTransaction
    00937 {
    00938     PCLASSINFO(SIPPublish, SIPTransaction);
    00939   public:
    00940     SIPPublish(
    00941       SIPEndPoint & ep,
    00942       OpalTransport & trans,
    00943       const PStringList & routeSet,
    00944       const SIPURL & targetAddress,
    00945       const PString & id,
    00946       const PString & sipIfMatch,
    00947       const PString & body,
    00948       unsigned expires
    00949     );
    00950 };
    00951
    00952
    00954
    00955 class SIPRefer : public SIPTransaction
    00956 {
    00957   PCLASSINFO(SIPRefer, SIPTransaction);
    00958   public:
    00959     SIPRefer(
    00960       SIPConnection & connection,
    00961       OpalTransport & transport,
    00962       const SIPURL & refer
    00963     );
    00964     SIPRefer(
    00965       SIPConnection & connection,
    00966       OpalTransport & transport,
    00967       const SIPURL & refer,
    00968       const SIPURL & referred_by
    00969     );
    00970   protected:
    00971     void Construct(
    00972       SIPConnection & connection,
    00973       OpalTransport & transport,
    00974       const SIPURL & refer,
    00975       const SIPURL & referred_by
    00976     );
    00977 };
    00978
    00979
    00981
    00982 /* This is not a generic NOTIFY PDU, but the minimal one
    00983  * that gets sent when receiving a REFER
    00984  */
    00985 class SIPReferNotify : public SIPTransaction
    00986 {
    00987     PCLASSINFO(SIPReferNotify, SIPTransaction);
    00988   public:
    00989     SIPReferNotify(
    00990       SIPConnection & connection,
    00991       OpalTransport & transport,
    00992       StatusCodes code
    00993     );
    00994 };
    00995
    00996
    00998
    00999 /* This is a MESSAGE PDU, with a body
    01000  */
    01001 class SIPMessage : public SIPTransaction
    01002 {
    01003     PCLASSINFO(SIPMessage, SIPTransaction);
    01004
    01005   public:
    01006     SIPMessage(
    01007                SIPEndPoint & ep,
    01008                OpalTransport & trans,
    01009                const SIPURL & to,
    01010                const PStringList & routeSet,
    01011                const PString & id,
    01012                const PString & body
    01013     );
    01014 };
    01015
    01016
    01018
    01019 /* This is the ACK request sent when receiving a response to an outgoing
    01020  * INVITE.
    01021  */
    01022 class SIPAck : public SIP_PDU
    01023 {
    01024     PCLASSINFO(SIPAck, SIP_PDU);
    01025   public:
    01026     SIPAck(
    01027       SIPTransaction & invite,
    01028       SIP_PDU & response
    01029     );
    01030 };
    01031
    01032
    01034
    01035 /* This is an OPTIONS request
    01036  */
    01037 class SIPOptions : public SIPTransaction
    01038 {
    01039     PCLASSINFO(SIPOptions, SIPTransaction);
    01040
    01041   public:
    01042     SIPOptions(
    01043         SIPEndPoint & ep,
    01044       OpalTransport & trans,
    01045        const SIPURL & address
    01046     );
    01047 };
    01048
    01049
    01051
    01052 /* This is a PING PDU, with a body
    01053  */
    01054 class SIPPing : public SIPTransaction
    01055 {
    01056   PCLASSINFO(SIPPing, SIPTransaction);
    01057
    01058   public:
    01059     SIPPing(
    01060                SIPEndPoint & ep,
    01061              OpalTransport & trans,
    01062               const SIPURL & address,
    01063               const PString & body = PString::Empty()
    01064    );
    01065 };
    01066
    01067
    01068 #endif // __OPAL_SIPPDU_H
    01069
    01070
    01071 // End of File ///////////////////////////////////////////////////////////////