00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef OPAL_SIP_SIPPDU_H
00033 #define OPAL_SIP_SIPPDU_H
00034
00035 #ifdef P_USE_PRAGMA
00036 #pragma interface
00037 #endif
00038
00039 #include <opal/buildopts.h>
00040
00041 #if OPAL_SIP
00042
00043 #include <ptclib/mime.h>
00044 #include <ptclib/url.h>
00045 #include <sip/sdp.h>
00046 #include <opal/rtpconn.h>
00047
00048
00049 class OpalTransport;
00050 class OpalTransportAddress;
00051 class OpalProductInfo;
00052
00053 class SIPEndPoint;
00054 class SIPConnection;
00055 class SIP_PDU;
00056
00057
00059
00060
00066 class SIPURL : public PURL
00067 {
00068 PCLASSINFO(SIPURL, PURL);
00069 public:
00070 SIPURL();
00071
00074 SIPURL(
00075 const char * cstr,
00076 const char * defaultScheme = NULL
00077 );
00078
00081 SIPURL(
00082 const PString & str,
00083 const char * defaultScheme = NULL
00084 );
00085
00093 SIPURL(
00094 const PString & name,
00095 const OpalTransportAddress & address,
00096 WORD listenerPort = 0
00097 );
00098
00099 SIPURL(
00100 const OpalTransportAddress & _address,
00101 WORD listenerPort = 0
00102 );
00103
00112 virtual Comparison Compare(
00113 const PObject & obj
00114 ) const;
00115
00119 PString AsQuotedString() const;
00120
00123 PString GetDisplayName(PBoolean useDefault = PTrue) const;
00124
00125 void SetDisplayName(const PString & str)
00126 { displayName = str; }
00127
00130 PString GetFieldParameters() const { return fieldParameters; }
00131
00134 void SetFieldParameters(const PString & str ) { fieldParameters = str; }
00135
00138 OpalTransportAddress GetHostAddress() const;
00139
00140 enum UsageContext {
00141 ExternalURI,
00142 RequestURI,
00143 ToURI,
00144 FromURI,
00145 ContactURI,
00146 RouteURI,
00147 RegisterURI
00148 };
00149
00155 void Sanitise(
00156 UsageContext context
00157 );
00158
00164 PBoolean AdjustToDNS(
00165 PINDEX entry = 0
00166 );
00167
00169 static PString GenerateTag();
00170
00172 void SetTag(
00173 const PString & tag = GenerateTag()
00174 );
00175
00176 protected:
00177 void ParseAsAddress(const PString & name, const OpalTransportAddress & _address, WORD listenerPort = 0);
00178
00197 virtual PBoolean InternalParse(
00198 const char * cstr,
00199 const char * defaultScheme
00200 );
00201
00202 PString displayName;
00203 PString fieldParameters;
00204 };
00205
00206
00208
00209
00240 class SIPMIMEInfo : public PMIMEInfo
00241 {
00242 PCLASSINFO(SIPMIMEInfo, PMIMEInfo);
00243 public:
00244 SIPMIMEInfo(bool compactForm = false);
00245
00246 virtual void PrintOn(ostream & strm) const;
00247 virtual void ReadFrom(istream & strm);
00248
00249 void SetCompactForm(bool form) { compactForm = form; }
00250
00251 PCaselessString GetContentType() const;
00252 void SetContentType(const PString & v);
00253
00254 PCaselessString GetContentEncoding() const;
00255 void SetContentEncoding(const PString & v);
00256
00257 PString GetFrom() const;
00258 void SetFrom(const PString & v);
00259
00260 PString GetPAssertedIdentity() const;
00261 void SetPAssertedIdentity(const PString & v);
00262
00263 PString GetPPreferredIdentity() const;
00264 void SetPPreferredIdentity(const PString & v);
00265
00266 PString GetAccept() const;
00267 void SetAccept(const PString & v);
00268
00269 PString GetAcceptEncoding() const;
00270 void SetAcceptEncoding(const PString & v);
00271
00272 PString GetAcceptLanguage() const;
00273 void SetAcceptLanguage(const PString & v);
00274
00275 PString GetAllow() const;
00276 void SetAllow(const PString & v);
00277
00278 PString GetCallID() const;
00279 void SetCallID(const PString & v);
00280
00281 PString GetContact() const;
00282 bool GetContacts(std::list<SIPURL> & contacts) const;
00283 void SetContact(const PString & v);
00284 void SetContact(const SIPURL & url);
00285
00286 PString GetSubject() const;
00287 void SetSubject(const PString & v);
00288
00289 PString GetTo() const;
00290 void SetTo(const PString & v);
00291
00292 PString GetVia() const;
00293 void SetVia(const PString & v);
00294
00295 PStringList GetViaList() const;
00296 void SetViaList(const PStringList & v);
00297
00298 PString GetReferTo() const;
00299 void SetReferTo(const PString & r);
00300
00301 PString GetReferredBy() const;
00302 void SetReferredBy(const PString & r);
00303
00304 PINDEX GetContentLength() const;
00305 void SetContentLength(PINDEX v);
00306 PBoolean IsContentLengthPresent() const;
00307
00308 PString GetCSeq() const;
00309 void SetCSeq(const PString & v);
00310
00311 PString GetDate() const;
00312 void SetDate(const PString & v);
00313 void SetDate(const PTime & t);
00314 void SetDate(void);
00315
00316 unsigned GetExpires(unsigned dflt = UINT_MAX) const;
00317 void SetExpires(unsigned v);
00318
00319 PINDEX GetMaxForwards() const;
00320 void SetMaxForwards(PINDEX v);
00321
00322 PINDEX GetMinExpires() const;
00323 void SetMinExpires(PINDEX v);
00324
00325 PString GetProxyAuthenticate() const;
00326 void SetProxyAuthenticate(const PString & v);
00327
00328 PStringList GetRoute() const;
00329 void SetRoute(const PString & v);
00330 void SetRoute(const PStringList & v);
00331
00332 PStringList GetRecordRoute(bool reversed) const;
00333 void SetRecordRoute(const PStringList & v);
00334
00335 unsigned GetCSeqIndex() const { return GetCSeq().AsUnsigned(); }
00336
00337 PString GetSupported() const;
00338 void SetSupported(const PString & v);
00339
00340 PString GetUnsupported() const;
00341 void SetUnsupported(const PString & v);
00342
00343 PString GetEvent() const;
00344 void SetEvent(const PString & v);
00345
00346 PString GetSubscriptionState() const;
00347 void SetSubscriptionState(const PString & v);
00348
00349 PString GetUserAgent() const;
00350 void SetUserAgent(const PString & v);
00351
00352 PString GetOrganization() const;
00353 void SetOrganization(const PString & v);
00354
00355 void GetProductInfo(OpalProductInfo & info);
00356 void SetProductInfo(const PString & ua, const OpalProductInfo & info);
00357
00358 PString GetWWWAuthenticate() const;
00359 void SetWWWAuthenticate(const PString & v);
00360
00361 PString GetSIPIfMatch() const;
00362 void SetSIPIfMatch(const PString & v);
00363
00364 PString GetSIPETag() const;
00365 void SetSIPETag(const PString & v);
00366
00367 PString GetRequire() const;
00368 void SetRequire(const PString & v, bool overwrite);
00369
00370 void GetAlertInfo(PString & info, int & appearance);
00371 void SetAlertInfo(const PString & info, int appearance);
00372
00375 PString GetFieldParameter(
00376 const PString & fieldName,
00377 const PString & paramName,
00378 const PString & defaultValue = PString::Empty()
00379 ) const { return ExtractFieldParameter((*this)(fieldName), paramName, defaultValue); }
00380
00385 void SetFieldParameter(
00386 const PString & fieldName,
00387 const PString & paramName,
00388 const PString & newValue
00389 ) { SetAt(fieldName, InsertFieldParameter((*this)(fieldName), paramName, newValue)); }
00390
00393 static PString ExtractFieldParameter(
00394 const PString & fieldValue,
00395 const PString & paramName,
00396 const PString & defaultValue = PString::Empty()
00397 );
00398
00403 static PString InsertFieldParameter(
00404 const PString & fieldValue,
00405 const PString & paramName,
00406 const PString & newValue
00407 );
00408
00409 protected:
00412 PStringList GetRouteList(const char * name, bool reversed) const;
00413
00417 void SetRouteList(const char * name, const PStringList & v);
00418
00420 bool compactForm;
00421 };
00422
00423
00425
00426
00427 class SIPAuthentication : public PObject
00428 {
00429 PCLASSINFO(SIPAuthentication, PObject);
00430 public:
00431 SIPAuthentication();
00432
00433 virtual Comparison Compare(
00434 const PObject & other
00435 ) const;
00436
00437 virtual PBoolean Parse(
00438 const PString & auth,
00439 PBoolean proxy
00440 ) = 0;
00441
00442 virtual PBoolean Authorise(
00443 SIP_PDU & pdu
00444 ) const = 0;
00445
00446 virtual PBoolean IsProxy() const { return isProxy; }
00447
00448 virtual PString GetUsername() const { return username; }
00449 virtual PString GetPassword() const { return password; }
00450 virtual PString GetAuthRealm() const { return PString::Empty(); }
00451
00452 virtual void SetUsername(const PString & user) { username = user; }
00453 virtual void SetPassword(const PString & pass) { password = pass; }
00454 virtual void SetAuthRealm(const PString &) { }
00455
00456 PString GetAuthParam(const PString & auth, const char * name) const;
00457 PString AsHex(PMessageDigest5::Code & digest) const;
00458 PString AsHex(const PBYTEArray & data) const;
00459
00460 static SIPAuthentication * ParseAuthenticationRequired(bool isProxy,
00461 const PString & line,
00462 PString & errorMsg);
00463
00464 protected:
00465 PBoolean isProxy;
00466
00467 PString username;
00468 PString password;
00469 };
00470
00471 typedef PFactory<SIPAuthentication> SIPAuthenticationFactory;
00472
00474
00475 class SIPDigestAuthentication : public SIPAuthentication
00476 {
00477 PCLASSINFO(SIPDigestAuthentication, SIPAuthentication);
00478 public:
00479 SIPDigestAuthentication();
00480
00481 SIPDigestAuthentication & operator =(
00482 const SIPDigestAuthentication & auth
00483 );
00484
00485 virtual Comparison Compare(
00486 const PObject & other
00487 ) const;
00488
00489 virtual PBoolean Parse(
00490 const PString & auth,
00491 PBoolean proxy
00492 );
00493
00494 virtual PBoolean Authorise(
00495 SIP_PDU & pdu
00496 ) const;
00497
00498 virtual PString GetAuthRealm() const { return authRealm; }
00499 virtual void SetAuthRealm(const PString & r) { authRealm = r; }
00500
00501 enum Algorithm {
00502 Algorithm_MD5,
00503 NumAlgorithms
00504 };
00505 const PString & GetNonce() const { return nonce; }
00506 Algorithm GetAlgorithm() const { return algorithm; }
00507 const PString & GetOpaque() const { return opaque; }
00508
00509 protected:
00510 PString authRealm;
00511 PString nonce;
00512 Algorithm algorithm;
00513 PString opaque;
00514
00515 PBoolean qopAuth;
00516 PBoolean qopAuthInt;
00517 PString cnonce;
00518 mutable PAtomicInteger nonceCount;
00519 };
00520
00522
00523
00529 class SIP_PDU : public PSafeObject
00530 {
00531 PCLASSINFO(SIP_PDU, PSafeObject);
00532 public:
00533 enum Methods {
00534 Method_INVITE,
00535 Method_ACK,
00536 Method_OPTIONS,
00537 Method_BYE,
00538 Method_CANCEL,
00539 Method_REGISTER,
00540 Method_SUBSCRIBE,
00541 Method_NOTIFY,
00542 Method_REFER,
00543 Method_MESSAGE,
00544 Method_INFO,
00545 Method_PING,
00546 Method_PUBLISH,
00547 NumMethods
00548 };
00549
00550 enum StatusCodes {
00551 IllegalStatusCode,
00552 Local_TransportError,
00553 Local_BadTransportAddress,
00554
00555 Information_Trying = 100,
00556 Information_Ringing = 180,
00557 Information_CallForwarded = 181,
00558 Information_Queued = 182,
00559 Information_Session_Progress = 183,
00560
00561 Successful_OK = 200,
00562 Successful_Accepted = 202,
00563
00564 Redirection_MultipleChoices = 300,
00565 Redirection_MovedPermanently = 301,
00566 Redirection_MovedTemporarily = 302,
00567 Redirection_UseProxy = 305,
00568 Redirection_AlternativeService = 380,
00569
00570 Failure_BadRequest = 400,
00571 Failure_UnAuthorised = 401,
00572 Failure_PaymentRequired = 402,
00573 Failure_Forbidden = 403,
00574 Failure_NotFound = 404,
00575 Failure_MethodNotAllowed = 405,
00576 Failure_NotAcceptable = 406,
00577 Failure_ProxyAuthenticationRequired = 407,
00578 Failure_RequestTimeout = 408,
00579 Failure_Conflict = 409,
00580 Failure_Gone = 410,
00581 Failure_LengthRequired = 411,
00582 Failure_RequestEntityTooLarge = 413,
00583 Failure_RequestURITooLong = 414,
00584 Failure_UnsupportedMediaType = 415,
00585 Failure_UnsupportedURIScheme = 416,
00586 Failure_BadExtension = 420,
00587 Failure_ExtensionRequired = 421,
00588 Failure_IntervalTooBrief = 423,
00589 Failure_TemporarilyUnavailable = 480,
00590 Failure_TransactionDoesNotExist = 481,
00591 Failure_LoopDetected = 482,
00592 Failure_TooManyHops = 483,
00593 Failure_AddressIncomplete = 484,
00594 Failure_Ambiguous = 485,
00595 Failure_BusyHere = 486,
00596 Failure_RequestTerminated = 487,
00597 Failure_NotAcceptableHere = 488,
00598 Failure_BadEvent = 489,
00599 Failure_RequestPending = 491,
00600 Failure_Undecipherable = 493,
00601
00602 Failure_InternalServerError = 500,
00603 Failure_NotImplemented = 501,
00604 Failure_BadGateway = 502,
00605 Failure_ServiceUnavailable = 503,
00606 Failure_ServerTimeout = 504,
00607 Failure_SIPVersionNotSupported = 505,
00608 Failure_MessageTooLarge = 513,
00609
00610 GlobalFailure_BusyEverywhere = 600,
00611 GlobalFailure_Decline = 603,
00612 GlobalFailure_DoesNotExistAnywhere = 604,
00613 GlobalFailure_NotAcceptable = 606,
00614
00615 MaxStatusCode = 699
00616 };
00617
00618 static const char * GetStatusCodeDescription(int code);
00619 friend ostream & operator<<(ostream & strm, StatusCodes status);
00620
00621 enum {
00622 MaxSize = 65535
00623 };
00624
00625 SIP_PDU();
00626
00629 SIP_PDU(
00630 Methods method,
00631 const SIPURL & dest,
00632 const PString & to,
00633 const PString & from,
00634 const PString & callID,
00635 unsigned cseq,
00636 const OpalTransportAddress & via
00637 );
00640 SIP_PDU(
00641 Methods method,
00642 SIPConnection & connection,
00643 const OpalTransport & transport
00644 );
00645
00649 SIP_PDU(
00650 const SIP_PDU & request,
00651 StatusCodes code,
00652 const char * contact = NULL,
00653 const char * extra = NULL,
00654 const SDPSessionDescription * sdp = NULL
00655 );
00656 SIP_PDU(const SIP_PDU &);
00657 SIP_PDU & operator=(const SIP_PDU &);
00658 ~SIP_PDU();
00659
00660 void PrintOn(
00661 ostream & strm
00662 ) const;
00663
00664 void Construct(
00665 Methods method
00666 );
00667 void Construct(
00668 Methods method,
00669 const SIPURL & dest,
00670 const PString & to,
00671 const PString & from,
00672 const PString & callID,
00673 unsigned cseq,
00674 const OpalTransportAddress & via
00675 );
00676 void Construct(
00677 Methods method,
00678 SIPConnection & connection,
00679 const OpalTransport & transport
00680 );
00681
00686 bool SetRoute(const PStringList & routeSet);
00687 bool SetRoute(const SIPURL & proxy);
00688
00691 void SetAllow(unsigned bitmask);
00692
00695 void AdjustVia(OpalTransport & transport);
00696
00699 PBoolean Read(
00700 OpalTransport & transport
00701 );
00702
00705 PBoolean Write(
00706 OpalTransport & transport,
00707 const OpalTransportAddress & remoteAddress = OpalTransportAddress(),
00708 const PString & localInterface = PString::Empty()
00709 );
00710
00713 bool SendResponse(
00714 OpalTransport & transport,
00715 StatusCodes code,
00716 SIPEndPoint * endpoint = NULL,
00717 const char * contact = NULL,
00718 const char * extra = NULL
00719 );
00720 bool SendResponse(
00721 OpalTransport & transport,
00722 SIP_PDU & response,
00723 SIPEndPoint * endpoint = NULL
00724 );
00725
00729 PString Build();
00730
00731 PString GetTransactionID() const;
00732
00733 Methods GetMethod() const { return method; }
00734 StatusCodes GetStatusCode () const { return statusCode; }
00735 const SIPURL & GetURI() const { return uri; }
00736 unsigned GetVersionMajor() const { return versionMajor; }
00737 unsigned GetVersionMinor() const { return versionMinor; }
00738 const PString & GetEntityBody() const { return entityBody; }
00739 PString & GetEntityBody() { return entityBody; }
00740 const PString & GetInfo() const { return info; }
00741 const SIPMIMEInfo & GetMIME() const { return mime; }
00742 SIPMIMEInfo & GetMIME() { return mime; }
00743 void SetURI(const SIPURL & newuri) { uri = newuri; }
00744 SDPSessionDescription * GetSDP();
00745 void SetSDP(SDPSessionDescription * sdp);
00746
00747 protected:
00748 Methods method;
00749 StatusCodes statusCode;
00750 SIPURL uri;
00751 unsigned versionMajor;
00752 unsigned versionMinor;
00753 PString info;
00754 SIPMIMEInfo mime;
00755 PString entityBody;
00756
00757 SDPSessionDescription * m_SDP;
00758
00759 mutable PString transactionID;
00760 };
00761
00762
00763 PQUEUE(SIP_PDU_Queue, SIP_PDU);
00764
00765
00766 #if PTRACING
00767 ostream & operator<<(ostream & strm, SIP_PDU::Methods method);
00768 #endif
00769
00770
00772
00773
00776 class SIPDialogContext
00777 {
00778 public:
00779 SIPDialogContext();
00780
00781 const PString & GetCallID() const { return m_callId; }
00782 void SetCallID(const PString & id) { m_callId = id; }
00783
00784 const SIPURL & GetRequestURI() const { return m_requestURI; }
00785 void SetRequestURI(const SIPURL & url) { m_requestURI = url; }
00786 bool SetRequestURI(const PString & uri) { return m_requestURI.Parse(uri); }
00787
00788 const PString & GetLocalTag() const { return m_localTag; }
00789 void SetLocalTag(const PString & tag) { m_localTag = tag; }
00790
00791 const SIPURL & GetLocalURI() const { return m_localURI; }
00792 void SetLocalURI(const SIPURL & url);
00793 bool SetLocalURI(const PString & uri);
00794
00795 const PString & GetRemoteTag() const { return m_remoteTag; }
00796 void SetRemoteTag(const PString & tag) { m_remoteTag = tag; }
00797
00798 const SIPURL & GetRemoteURI() const { return m_remoteURI; }
00799 void SetRemoteURI(const SIPURL & url);
00800 bool SetRemoteURI(const PString & uri);
00801
00802 const PStringList & GetRouteSet() const { return m_routeSet; }
00803 void SetRouteSet(const PStringList & routes) { m_routeSet = routes; }
00804 void UpdateRouteSet(const SIPURL & proxy);
00805
00806 void Update(const SIP_PDU & response);
00807
00808 unsigned GetNextCSeq() { return ++m_lastSentCSeq; }
00809 bool IsDuplicateCSeq(unsigned sequenceNumber);
00810
00811 bool IsEstablished() const { return !m_remoteTag.IsEmpty(); }
00812
00813 protected:
00814 PString m_callId;
00815 SIPURL m_requestURI;
00816 SIPURL m_localURI;
00817 PString m_localTag;
00818 SIPURL m_remoteURI;
00819 PString m_remoteTag;
00820 PStringList m_routeSet;
00821 unsigned m_lastSentCSeq;
00822 unsigned m_lastReceivedCSeq;
00823 };
00824
00825
00827
00828
00839 class SIPTransaction : public SIP_PDU
00840 {
00841 PCLASSINFO(SIPTransaction, SIP_PDU);
00842 public:
00843 SIPTransaction(
00844 SIPEndPoint & endpoint,
00845 OpalTransport & transport,
00846 const PTimeInterval & minRetryTime = PMaxTimeInterval,
00847 const PTimeInterval & maxRetryTime = PMaxTimeInterval
00848 );
00852 SIPTransaction(
00853 SIPConnection & connection,
00854 OpalTransport & transport,
00855 Methods method = NumMethods
00856 );
00857 ~SIPTransaction();
00858
00859 PBoolean Start();
00860 bool IsTrying() const { return state == Trying; }
00861 bool IsProceeding() const { return state == Proceeding; }
00862 bool IsInProgress() const { return state == Trying || state == Proceeding; }
00863 bool IsFailed() const { return state > Terminated_Success; }
00864 bool IsCompleted() const { return state >= Completed; }
00865 bool IsCanceled() const { return state == Cancelling || state == Terminated_Cancelled || state == Terminated_Aborted; }
00866 bool IsTerminated() const { return state >= Terminated_Success; }
00867
00868 void WaitForCompletion();
00869 PBoolean Cancel();
00870 void Abort();
00871
00872 virtual PBoolean OnReceivedResponse(SIP_PDU & response);
00873 virtual PBoolean OnCompleted(SIP_PDU & response);
00874
00875 OpalTransport & GetTransport() const { return transport; }
00876 SIPConnection * GetConnection() const { return connection; }
00877 PString GetInterface() const { return m_localInterface; }
00878
00879 static PString GenerateCallID();
00880
00881 protected:
00882 void Construct(
00883 const PTimeInterval & minRetryTime = PMaxTimeInterval,
00884 const PTimeInterval & maxRetryTime = PMaxTimeInterval
00885 );
00886 void Construct(
00887 Methods method,
00888 SIPDialogContext & dialog
00889 );
00890 bool SendPDU(SIP_PDU & pdu);
00891 bool ResendCANCEL();
00892
00893 PDECLARE_NOTIFIER(PTimer, SIPTransaction, OnRetry);
00894 PDECLARE_NOTIFIER(PTimer, SIPTransaction, OnTimeout);
00895
00896 enum States {
00897 NotStarted,
00898 Trying,
00899 Proceeding,
00900 Cancelling,
00901 Completed,
00902 Terminated_Success,
00903 Terminated_Timeout,
00904 Terminated_RetriesExceeded,
00905 Terminated_TransportError,
00906 Terminated_Cancelled,
00907 Terminated_Aborted,
00908 NumStates
00909 };
00910 virtual void SetTerminated(States newState);
00911
00912 SIPEndPoint & endpoint;
00913 OpalTransport & transport;
00914 PSafePtr<SIPConnection> connection;
00915 PTimeInterval retryTimeoutMin;
00916 PTimeInterval retryTimeoutMax;
00917
00918 States state;
00919 unsigned retry;
00920 PTimer retryTimer;
00921 PTimer completionTimer;
00922 PSyncPoint completed;
00923 PString m_localInterface;
00924 OpalTransportAddress m_remoteAddress;
00925 };
00926
00927
00929
00930
00936 class SIPInvite : public SIPTransaction
00937 {
00938 PCLASSINFO(SIPInvite, SIPTransaction);
00939 public:
00940 SIPInvite(
00941 SIPConnection & connection,
00942 OpalTransport & transport,
00943 const OpalRTPSessionManager & sm
00944 );
00945
00946 virtual PBoolean OnReceivedResponse(SIP_PDU & response);
00947
00948 const OpalRTPSessionManager & GetSessionManager() const { return rtpSessions; }
00949 OpalRTPSessionManager & GetSessionManager() { return rtpSessions; }
00950
00951 protected:
00952 OpalRTPSessionManager rtpSessions;
00953 };
00954
00955
00957
00958 class SIPRegister : public SIPTransaction
00959 {
00960 PCLASSINFO(SIPRegister, SIPTransaction);
00961 public:
00962 struct Params {
00963 Params();
00964
00965 PString m_addressOfRecord;
00966 PString m_registrarAddress;
00967 PString m_contactAddress;
00968 PString m_authID;
00969 PString m_password;
00970 PString m_realm;
00971 unsigned m_expire;
00972 unsigned m_restoreTime;
00973 PTimeInterval m_minRetryTime;
00974 PTimeInterval m_maxRetryTime;
00975 void * m_userData;
00976 };
00977
00978 SIPRegister(
00979 SIPEndPoint & endpoint,
00980 OpalTransport & transport,
00981 const SIPURL & proxy,
00982 const PString & callId,
00983 unsigned cseq,
00984 const Params & params
00985 );
00986 };
00987
00988
00990
00991 class SIPSubscribe : public SIPTransaction
00992 {
00993 PCLASSINFO(SIPSubscribe, SIPTransaction);
00994 public:
00997 enum PredefinedPackages {
00998 MessageSummary,
00999 Presence,
01000 Dialog,
01001 NumPredefinedPackages
01002 };
01003
01004 class EventPackage : public PCaselessString
01005 {
01006 PCLASSINFO(EventPackage, PCaselessString);
01007 public:
01008 EventPackage(PredefinedPackages);
01009 EventPackage(const PString & str) : PCaselessString(str) { }
01010 EventPackage(const char * cstr) : PCaselessString(cstr) { }
01011 bool operator==(PredefinedPackages) const;
01012 bool operator==(const PString & str) const { return Compare(str) == EqualTo; }
01013 bool operator==(const char * cstr) const { return InternalCompare(0, P_MAX_INDEX, cstr) == EqualTo; }
01014 virtual Comparison InternalCompare(PINDEX offset, PINDEX length, const char * cstr) const;
01015 };
01016
01017 struct Params {
01018 Params(PredefinedPackages pkg = NumPredefinedPackages);
01019
01020 EventPackage m_eventPackage;
01021 PString m_agentAddress;
01022 PString m_addressOfRecord;
01023 PString m_contactAddress;
01024 PString m_authID;
01025 PString m_password;
01026 PString m_realm;
01027 unsigned m_expire;
01028 unsigned m_restoreTime;
01029 PTimeInterval m_minRetryTime;
01030 PTimeInterval m_maxRetryTime;
01031 void * m_userData;
01032 PString m_from;
01033 };
01034
01035 SIPSubscribe(
01036 SIPEndPoint & ep,
01037 OpalTransport & trans,
01038 SIPDialogContext & dialog,
01039 const Params & params
01040 );
01041 };
01042
01043
01044 typedef SIPSubscribe::EventPackage SIPEventPackage;
01045
01046
01048
01049 class SIPHandler;
01050
01051 class SIPEventPackageHandler
01052 {
01053 public:
01054 virtual ~SIPEventPackageHandler() { }
01055 virtual PCaselessString GetContentType() const = 0;
01056 virtual bool OnReceivedNOTIFY(SIPHandler & handler, SIP_PDU & request) = 0;
01057 virtual PString OnSendNOTIFY(SIPHandler & , const PObject * ) { return PString::Empty(); }
01058 };
01059
01060
01061 typedef PFactory<SIPEventPackageHandler, SIPEventPackage> SIPEventPackageFactory;
01062
01063
01065
01066 class SIPNotify : public SIPTransaction
01067 {
01068 PCLASSINFO(SIPNotify, SIPTransaction);
01069 public:
01070 SIPNotify(
01071 SIPEndPoint & ep,
01072 OpalTransport & trans,
01073 SIPDialogContext & dialog,
01074 const SIPEventPackage & eventPackage,
01075 const PString & state,
01076 const PString & body
01077 );
01078 };
01079
01080
01082
01083 class SIPPublish : public SIPTransaction
01084 {
01085 PCLASSINFO(SIPPublish, SIPTransaction);
01086 public:
01087 SIPPublish(
01088 SIPEndPoint & ep,
01089 OpalTransport & trans,
01090 const PString & id,
01091 const PString & sipIfMatch,
01092 SIPSubscribe::Params & params,
01093 const PString & body
01094 );
01095 };
01096
01097
01099
01100 class SIPRefer : public SIPTransaction
01101 {
01102 PCLASSINFO(SIPRefer, SIPTransaction);
01103 public:
01104 SIPRefer(
01105 SIPConnection & connection,
01106 OpalTransport & transport,
01107 const SIPURL & refer
01108 );
01109 SIPRefer(
01110 SIPConnection & connection,
01111 OpalTransport & transport,
01112 const SIPURL & refer,
01113 const SIPURL & referred_by
01114 );
01115 protected:
01116 void Construct(
01117 SIPConnection & connection,
01118 OpalTransport & transport,
01119 const SIPURL & refer,
01120 const SIPURL & referred_by
01121 );
01122 };
01123
01124
01126
01127
01128
01129
01130 class SIPReferNotify : public SIPTransaction
01131 {
01132 PCLASSINFO(SIPReferNotify, SIPTransaction);
01133 public:
01134 SIPReferNotify(
01135 SIPConnection & connection,
01136 OpalTransport & transport,
01137 StatusCodes code
01138 );
01139 };
01140
01141
01143
01144
01145
01146 class SIPMessage : public SIPTransaction
01147 {
01148 PCLASSINFO(SIPMessage, SIPTransaction);
01149
01150 public:
01151 SIPMessage(
01152 SIPEndPoint & ep,
01153 OpalTransport & trans,
01154 const SIPURL & proxy,
01155 const SIPURL & to,
01156 const PString & id,
01157 const PString & body
01158 );
01159 };
01160
01161
01163
01164
01165
01166
01167 class SIPAck : public SIP_PDU
01168 {
01169 PCLASSINFO(SIPAck, SIP_PDU);
01170 public:
01171 SIPAck(
01172 SIPTransaction & invite,
01173 SIP_PDU & response
01174 );
01175 };
01176
01177
01179
01180
01181
01182 class SIPOptions : public SIPTransaction
01183 {
01184 PCLASSINFO(SIPOptions, SIPTransaction);
01185
01186 public:
01187 SIPOptions(
01188 SIPEndPoint & ep,
01189 OpalTransport & trans,
01190 const SIPURL & address
01191 );
01192 };
01193
01194
01196
01197
01198
01199 class SIPPing : public SIPTransaction
01200 {
01201 PCLASSINFO(SIPPing, SIPTransaction);
01202
01203 public:
01204 SIPPing(
01205 SIPEndPoint & ep,
01206 OpalTransport & trans,
01207 const SIPURL & address,
01208 const PString & body = PString::Empty()
01209 );
01210 };
01211
01212
01213 #endif // OPAL_SIP
01214
01215 #endif // OPAL_SIP_SIPPDU_H
01216
01217
01218