OPAL  Version 3.18.8
sippdu.h
Go to the documentation of this file.
1 /*
2  * sippdu.h
3  *
4  * Session Initiation Protocol PDU support.
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (c) 2002 Equivalence Pty. Ltd.
10  *
11  * The contents of this file are subject to the Mozilla Public License
12  * Version 1.0 (the "License"); you may not use this file except in
13  * compliance with the License. You may obtain a copy of the License at
14  * http://www.mozilla.org/MPL/
15  *
16  * Software distributed under the License is distributed on an "AS IS"
17  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18  * the License for the specific language governing rights and limitations
19  * under the License.
20  *
21  * The Original Code is Open Phone Abstraction Library.
22  *
23  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24  *
25  * Contributor(s): ______________________________________.
26  */
27 
28 #ifndef OPAL_SIP_SIPPDU_H
29 #define OPAL_SIP_SIPPDU_H
30 
31 #ifdef P_USE_PRAGMA
32 #pragma interface
33 #endif
34 
35 #include <opal_config.h>
36 
37 #if OPAL_SIP
38 
39 #include <ptclib/mime.h>
40 #include <ptclib/url.h>
41 #include <ptclib/http.h>
42 #include <ptclib/pxml.h>
43 #include <ptclib/threadpool.h>
44 #include <opal/transports.h>
45 #include <im/im.h>
46 #include <rtp/rtpconn.h>
47 
48 
50 class OpalProductInfo;
51 
52 class SIPEndPoint;
53 class SIPConnection;
54 class SIPHandler;
55 class SIP_PDU;
57 class SIPDialogContext;
58 class SIPMIMEInfo;
59 class SIPTransaction;
60 class SDPSessionDescription;
61 
62 
64 // SIPURL
65 
71 class SIPURL : public PURL
72 {
73  PCLASSINFO_WITH_CLONE(SIPURL, PURL);
74  public:
75  static const WORD DefaultPort;
76  static const WORD DefaultSecurePort;
77 
78  SIPURL();
79 
81  const PURL & url
82  ) : PURL(url) { }
84  const PURL & url
85  ) { PURL::operator=(url); return *this; }
86 
89  SIPURL(
90  const char * cstr,
91  const char * defaultScheme = NULL
92  );
94  const char * cstr
95  ) { Parse(cstr); return *this; }
96 
99  SIPURL(
100  const PString & str,
101  const char * defaultScheme = NULL
102  );
104  const PString & str
105  ) { Parse(str); return *this; }
106 
116  SIPURL(
117  const PString & name,
118  const OpalTransportAddress & address,
119  WORD listenerPort = 0,
120  const char * scheme = NULL
121  );
122 
123  SIPURL(
124  const OpalTransportAddress & address,
125  WORD listenerPort = 0,
126  const char * scheme = NULL
127  );
128  SIPURL & operator=(
129  const OpalTransportAddress & address
130  );
131 
132  SIPURL(
133  const SIPMIMEInfo & mime,
134  const char * name
135  );
136 
145  virtual Comparison Compare(
146  const PObject & obj
147  ) const;
148 
152  PString AsQuotedString() const;
153 
156  PString GetDisplayName(PBoolean useDefault = true) const;
157 
158  void SetDisplayName(const PString & str)
159  {
160  m_displayName = str;
161  }
162 
164  const PStringOptions & GetFieldParameters() const { return m_fieldParameters; }
165  PStringOptions & GetFieldParameters() { return m_fieldParameters; }
166 
168  PCaselessString GetTransportProto() const;
169 
176  PINDEX dnsEntry = P_MAX_INDEX
177  ) const;
178 
180  bool CanLookupSRV() const;
181 
184  void SetHostAddress(const OpalTransportAddress & addr);
185 
196  };
197 
203  void Sanitise(
204  UsageContext context
205  );
206 
208  static PString GenerateTag();
209 
211  PString SetTag(
212  const PString & tag = GenerateTag(),
213  bool force = false
214  );
215 
217  PString GetTag() const;
218 
219  protected:
220  void ParseAsAddress(
221  const PString & name,
222  const OpalTransportAddress & address,
223  WORD listenerPort,
224  const char * scheme);
225 
226  // Override from PURL()
227  virtual PBoolean InternalParse(
228  const char * cstr,
229  const char * defaultScheme
230  ) { return ReallyInternalParse(false, cstr, defaultScheme); }
231 
232  bool ReallyInternalParse(
233  bool fromField,
234  const char * cstr,
235  const char * defaultScheme
236  );
237  WORD GetDefaultPort() const;
238 
239  PString m_displayName;
240  PStringOptions m_fieldParameters;
241 };
242 
243 
244 class SIPURLList : public std::list<SIPURL>
245 {
246  public:
247  bool FromString(
248  const PString & str,
250  bool reversed = false
251  );
252  PString ToString() const;
253  SIPURL FindCompatible(const OpalTransportAddress & addr PTRACE_PARAM(, const char * listType)) const;
254 
255  friend ostream & operator<<(ostream & strm, const SIPURLList & urls);
256 
257  protected:
258  void InternalFromString(const PString & str, SIPURL::UsageContext context, bool reversed);
259 };
260 
261 
262 
264 // SIPMIMEInfo
265 
296 class SIPMIMEInfo : public PMIMEInfo
297 {
298  PCLASSINFO(SIPMIMEInfo, PMIMEInfo);
299  public:
300  SIPMIMEInfo(bool compactForm = false);
301 
302  virtual void PrintOn(ostream & strm) const;
303  virtual bool InternalAddMIME(const PString & fieldName, const PString & fieldValue);
304 
305  void SetCompactForm(bool form) { compactForm = form; }
306 
307  PCaselessString GetContentType(bool includeParameters = false) const;
308  void SetContentType(const PString & v);
309 
310  bool GetSDP(const PString & entityBody, PString & sdp, PMultiPartList & parts) const;
311 
312  PCaselessString GetContentEncoding() const;
313  void SetContentEncoding(const PString & v);
314 
315  SIPURL GetFrom() const;
316  PString GetFromTag() const;
317  void SetFrom(const SIPURL & v);
318 
320  void SetPAssertedIdentity(const PString & v);
321 
323  void SetPPreferredIdentity(const PString & v);
324 
325  PString GetAccept() const;
326  void SetAccept(const PString & v);
327 
328  PString GetAcceptEncoding() const;
329  void SetAcceptEncoding(const PString & v);
330 
331  PString GetAcceptLanguage() const;
332  void SetAcceptLanguage(const PString & v);
333 
334  PString GetAllow() const;
335  unsigned GetAllowBitMask() const;
336  void SetAllow(const PString & v);
337 
338  PString GetCallID() const;
339  void SetCallID(const PString & v);
340 
341  SIPURL GetContact() const;
342  bool GetContacts(SIPURLList & contacts, unsigned defaultExpires) const;
343  void SetContact(const PString & v);
344 
345  PString GetSubject() const;
346  void SetSubject(const PString & v);
347 
348  SIPURL GetTo() const;
349  PString GetToTag() const;
350  void SetTo(const SIPURL & v);
351 
352  PString GetVia() const;
353  void SetVia(const PString & v);
354 
355  bool GetViaList(PStringList & v) const;
356  void SetViaList(const PStringList & v);
357 
358  PString GetFirstVia() const;
360 
361  SIPURL GetReferTo() const;
362  void SetReferTo(const PString & r);
363 
364  SIPURL GetReferredBy() const;
365  void SetReferredBy(const PString & r);
366 
367  PINDEX GetContentLength() const;
368  void SetContentLength(PINDEX v);
369  PBoolean IsContentLengthPresent() const;
370 
371  PString GetCSeq() const;
372  void SetCSeq(const PString & v);
373 
374  PString GetDate() const;
375  void SetDate(const PString & v);
376  void SetDate(const PTime & t);
377  void SetDate(void); // set to current date
378 
379  unsigned GetExpires(unsigned dflt = UINT_MAX) const;// returns default value if not found
380  void SetExpires(unsigned v);
381 
382  unsigned GetMaxForwards() const;
383  void SetMaxForwards(PINDEX v);
384 
385  unsigned GetMinExpires() const;
386  void SetMinExpires(PINDEX v);
387 
388  PString GetProxyAuthenticate() const;
389  void SetProxyAuthenticate(const PString & v);
390 
391  PString GetRoute() const;
392  bool GetRoute(SIPURLList & proxies) const;
393  void SetRoute(const PString & v);
394  void SetRoute(const SIPURLList & proxies);
395 
396  PString GetRecordRoute() const;
397  bool GetRecordRoute(SIPURLList & proxies, bool reversed) const;
398  void SetRecordRoute(const PString & v);
399  void SetRecordRoute(const SIPURLList & proxies);
400 
401  unsigned GetCSeqIndex() const { return GetCSeq().AsUnsigned(); }
402 
403  PStringSet GetRequire() const;
404  void SetRequire(const PStringSet & v);
405  void AddRequire(const PString & v);
406 
407  PStringSet GetSupported() const;
408  void SetSupported(const PStringSet & v);
409  void AddSupported(const PString & v);
410 
411  PStringSet GetUnsupported() const;
412  void SetUnsupported(const PStringSet & v);
413  void AddUnsupported(const PString & v);
414 
415  PString GetEvent() const;
416  void SetEvent(const PString & v);
417 
418  PCaselessString GetSubscriptionState(PStringToString & info) const;
419  void SetSubscriptionState(const PString & v);
420 
421  PString GetUserAgent() const;
422  void SetUserAgent(const PString & v);
423 
424  PString GetOrganization() const;
425  void SetOrganization(const PString & v);
426 
427  void GetProductInfo(OpalProductInfo & info) const;
428  void SetProductInfo(const PString & ua, const OpalProductInfo & info);
429 
430  PString GetWWWAuthenticate() const;
431  void SetWWWAuthenticate(const PString & v);
432 
433  PString GetSIPIfMatch() const;
434  void SetSIPIfMatch(const PString & v);
435 
436  PString GetSIPETag() const;
437  void SetSIPETag(const PString & v);
438 
439  void GetAlertInfo(PString & info, int & appearance) const;
440  void SetAlertInfo(const PString & info, int appearance);
441 
442  PString GetCallInfo() const;
443 
444  PString GetAllowEvents() const;
445  void SetAllowEvents(const PString & v);
446  void SetAllowEvents(const PStringSet & list);
447 
451  const PString & fieldName,
452  const PString & paramName,
453  const PString & defaultValue = PString::Empty()
454  ) const { return ExtractFieldParameter((*this)(fieldName), paramName, defaultValue); }
455 
461  const PString & fieldName,
462  const PString & paramName,
463  const PString & newValue
464  ) { SetAt(fieldName, InsertFieldParameter((*this)(fieldName), paramName, newValue)); }
465 
468  static PString ExtractFieldParameter(
469  const PString & fieldValue,
470  const PString & paramName,
471  const PString & defaultValue = PString::Empty()
472  );
473 
478  static PString InsertFieldParameter(
479  const PString & fieldValue,
480  const PString & paramName,
481  const PString & newValue
482  );
483 
484  protected:
485  PStringSet GetTokenSet(const char * field) const;
486  void AddTokenSet(const char * field, const PString & token);
487  void SetTokenSet(const char * field, const PStringSet & tokens);
488 
491 };
492 
493 
495 // SIPAuthentication
496 
497 typedef PHTTPClientAuthentication SIPAuthentication;
498 
499 class SIPAuthenticator : public PHTTPClientAuthentication::AuthObject
500 {
501  public:
502  SIPAuthenticator(SIP_PDU & pdu);
503  virtual PMIMEInfo & GetMIME();
504  virtual PString GetURI();
505  virtual PString GetEntityBody();
506  virtual PString GetMethod();
507 
508  protected:
510 };
511 
512 
513 
515 // SIP_PDU
516 
522 class SIP_PDU : public PSafeObject
523 {
524  PCLASSINFO(SIP_PDU, PSafeObject);
525  public:
526  enum Methods {
542  };
543 
544  enum StatusCodes {
555 
561 
564 
570 
603 
611 
616 
618  };
619 
620  static PString GetStatusCodeDescription(int code);
621  friend ostream & operator<<(ostream & strm, StatusCodes status);
622 
623  SIP_PDU(
624  Methods method = SIP_PDU::NumMethods,
625  const OpalTransportPtr & transport = NULL,
626  const PString & transactionID = PString::Empty()
627  );
628 
632  SIP_PDU(
633  const SIP_PDU & request,
634  StatusCodes code,
635  const SDPSessionDescription * sdp = NULL
636  );
637 
638  SIP_PDU(const SIP_PDU &);
639  SIP_PDU & operator=(const SIP_PDU &);
640  ~SIP_PDU();
641 
642  void PrintOn(
643  ostream & strm
644  ) const;
645 
646  void InitialiseHeaders(
647  const SIPURL & dest,
648  const SIPURL & to,
649  const SIPURL & from,
650  const PString & callID,
651  unsigned cseq
652  );
653  void InitialiseHeaders(
654  SIPDialogContext & dialog,
655  unsigned cseq = 0
656  );
657  void InitialiseHeaders(
658  SIPConnection & connection,
659  unsigned cseq = 0
660  );
661  void InitialiseHeaders(
662  const SIP_PDU & request
663  );
664 
669  bool SetRoute(const SIPURLList & routeSet);
670  bool SetRoute(const SIPURL & proxy);
671 
674  void SetAllow(unsigned bitmask);
675 
678  StatusCodes Read();
680  istream & strm,
681  bool truncated
682  );
683 
686  virtual bool Send();
687 
690  bool SendResponse(
691  StatusCodes code
692  );
693 
697  void Build(PString & pduStr, PINDEX & pduLen);
698 
699  const PString & GetTransactionID() const { return m_transactionID; }
700 
701  Methods GetMethod() const { return m_method; }
704  const SIPURL & GetURI() const { return m_uri; }
705  void SetURI(const SIPURL & newuri) { m_uri = newuri; }
706  unsigned GetVersionMajor() const { return m_versionMajor; }
707  unsigned GetVersionMinor() const { return m_versionMinor; }
708  void SetCSeq(unsigned cseq);
709  const PString & GetEntityBody() const { return m_entityBody; }
710  void SetEntityBody(const PString & body) { m_entityBody = body; }
711  void SetEntityBody();
712  const PString & GetInfo() const { return m_info; }
713  void SetInfo(const PString & info) { m_info = info; }
714  const SIPMIMEInfo & GetMIME() const { return m_mime; }
715  SIPMIMEInfo & GetMIME() { return m_mime; }
716  SDPSessionDescription * GetSDP() { return m_SDP; }
717  void SetSDP(SDPSessionDescription * sdp);
718  bool DecodeSDP(SIPConnection & connection, PMultiPartList & parts);
719  bool DecodeSDP(SIPConnection & connection, PString & sdpText, PMultiPartList & parts);
720  bool IsContentSDP(bool emptyOK = false) const;
721 
724  void SetTransport(const OpalTransportPtr & transport PTRACE_PARAM(, const char * location));
725 
726  protected:
727  void CalculateVia();
728  StatusCodes InternalSend(bool canDoTCP);
729 
730  Methods m_method; // Request type, ==NumMethods for Response
732  SIPURL m_uri; // display name & URI, no tag
733  unsigned m_versionMajor;
734  unsigned m_versionMinor;
735  PString m_info;
737  PString m_entityBody;
739 
740  SDPSessionDescription * m_SDP;
741 
745 };
746 
747 
748 PQUEUE(SIP_PDU_Queue, SIP_PDU);
749 
750 
751 #if PTRACING
752 ostream & operator<<(ostream & strm, SIP_PDU::Methods method);
753 #endif
754 
755 
757 // SIPDialogContext
758 
761 class SIPDialogContext : public PObject
762 {
763  public:
765  SIPDialogContext(const SIPMIMEInfo & mime);
766 
767  PString AsString() const;
768  bool FromString(
769  const PString & str
770  );
771 
772  const PString & GetCallID() const { return m_callId; }
773  void SetCallID(const PString & id) { m_callId = id; }
774 
775  const SIPURL & GetRequestURI() const { return m_requestURI; }
776  void SetRequestURI(const SIPURL & url);
777 
778  const PString & GetLocalTag() const { return m_localTag; }
779  void SetLocalTag(const PString & tag) { m_localTag = tag; }
780 
781  const SIPURL & GetLocalURI() const { return m_localURI; }
782  void SetLocalURI(const SIPURL & url);
783 
784  const PString & GetRemoteTag() const { return m_remoteTag; }
785  void SetRemoteTag(const PString & tag) { m_remoteTag = tag; }
786 
787  const SIPURL & GetRemoteURI() const { return m_remoteURI; }
788  void SetRemoteURI(const SIPURL & url);
789 
790  const SIPURLList & GetRouteSet() const { return m_routeSet; }
791  void SetRouteSet(const PString & str) { m_routeSet.FromString(str); }
792 
793  const SIPURL & GetProxy() const { return m_proxy; }
794  void SetProxy(const SIPURL & proxy, bool addToRouteSet);
795 
796  void Update(const SIP_PDU & response);
797 
798  unsigned GetNextCSeq();
799  void IncrementCSeq(unsigned inc) { m_lastSentCSeq += inc; }
800 
801  bool IsDuplicateCSeq(unsigned sequenceNumber);
802 
803  bool IsEstablished() const
804  {
805  return !m_callId.IsEmpty() &&
806  !m_requestURI.IsEmpty() &&
807  !m_localURI.IsEmpty() &&
808  !m_localTag.IsEmpty() &&
809  !m_remoteURI.IsEmpty() &&
810  !m_remoteTag.IsEmpty();
811  }
812 
813  OpalTransportAddress GetRemoteTransportAddress(PINDEX dnsEntry) const;
814  const PString & GetInterface() const { return m_interface; }
815  void SetInterface(const PString & newInterface) { m_interface = newInterface; }
816 
817  void SetForking(bool f) { m_forking = f; }
818 
819  protected:
820  PString m_callId;
823  PString m_localTag;
825  PString m_remoteTag;
827  unsigned m_lastSentCSeq;
830  bool m_forking;
832  PString m_interface;
833 };
834 
835 
837 
839 {
841  const PString & aor = PString::Empty(),
842  const PString & remote = PString::Empty()
843  );
844 
845  bool Normalise(
846  const PString & defaultUser,
847  const PTimeInterval & defaultExpire
848  );
849 
850  PCaselessString m_remoteAddress;
851  PCaselessString m_localAddress;
852  PCaselessString m_proxyAddress;
853  PCaselessString m_addressOfRecord;
854  PCaselessString m_contactAddress;
855  PCaselessString m_interface;
857  PMultiPartList m_body;
858  PString m_authID;
859  PString m_password;
860  PString m_realm;
861  unsigned m_expire;
862  unsigned m_restoreTime;
863  PTimeInterval m_minRetryTime;
864  PTimeInterval m_maxRetryTime;
866  void * m_userData;
867 };
868 
869 
870 #if PTRACING
871 ostream & operator<<(ostream & strm, const SIPParameters & params);
872 #endif
873 
874 
876 // Thread pooling stuff
877 //
878 // Timer call back mechanism using PNOTIFIER is too prone to deadlocks, we
879 // want to use the existing thread pool for handling incoming PDUs.
880 
881 class SIPWorkItem : public PObject
882 {
883  PCLASSINFO(SIPWorkItem, PObject);
884  public:
885  SIPWorkItem(SIPEndPoint & ep, const PString & token);
886 
887  virtual void Work() = 0;
888 
889  bool GetTarget(PSafePtr<SIPTransaction> & transaction);
890  bool GetTarget(PSafePtr<SIPConnection> & connection);
891  bool GetTarget(PSafePtr<SIPHandler> & handler);
892 
893  protected:
895  PString m_token;
896 };
897 
898 
899 class SIPThreadPool : public PQueuedThreadPool<SIPWorkItem>
900 {
901  typedef PQueuedThreadPool<SIPWorkItem> BaseClass;
902  PCLASSINFO(SIPThreadPool, BaseClass);
903  public:
904  SIPThreadPool(unsigned maxWorkers, const char * threadName)
905  : BaseClass(maxWorkers, 0, threadName, PThread::HighPriority)
906  {
907  }
908 };
909 
910 
911 template <class Target_T>
913 {
914  PCLASSINFO(SIPTimeoutWorkItem, SIPWorkItem);
915  public:
916  typedef void (Target_T::* Callback)();
917 
918  SIPTimeoutWorkItem(SIPEndPoint & ep, const PString & token, Callback callback)
919  : SIPWorkItem(ep, token)
920  , m_callback(callback)
921  {
922  }
923 
924  virtual void Work()
925  {
926  PSafePtr<Target_T> target;
927  if (GetTarget(target)) {
928  PTRACE_CONTEXT_ID_PUSH_THREAD(target);
929  (target->*m_callback)();
930  PTRACE(4, "SIP\tHandled timeout");
931  }
932  }
933 
934  protected:
936 };
937 
938 
939 template <class Target_T>
940 class SIPPoolTimer : public PPoolTimerArg3<SIPTimeoutWorkItem<Target_T>,
941  SIPEndPoint &,
942  PString,
943  void (Target_T::*)(),
944  SIPWorkItem>
945 {
947  typedef PPoolTimerArg3<Work_T, SIPEndPoint &, PString, void (Target_T::*)(), SIPWorkItem> BaseClass;
948  PCLASSINFO(SIPPoolTimer, BaseClass);
949  private:
950  PString m_token;
951  public:
952  SIPPoolTimer(SIPThreadPool & pool, SIPEndPoint & ep, const PString & token, void (Target_T::* callback)())
953  : BaseClass(pool, ep, token, callback)
954  , m_token(token)
955  {
956  }
957 
959  {
960  this->m_stopped = true;
961  }
962 
963  virtual const char * GetGroup(const Work_T &) const { return m_token; }
964 
966 };
967 
968 
970 // SIPTransaction
971 
973 {
974  public:
976  PSafeObject & object,
977  SIPEndPoint & endpoint
978  );
979  virtual ~SIPTransactionOwner();
980 
981  virtual PString GetAuthID() const = 0;
982  virtual PString GetPassword() const { return PString::Empty(); }
983  virtual unsigned GetAllowedMethods() const;
984 
985  virtual void OnStartTransaction(SIPTransaction & /*transaction*/) { }
986  virtual void OnReceivedResponse(SIPTransaction & transaction, SIP_PDU & response);
987  virtual void OnTransactionFailed(SIPTransaction & transaction);
988 
989  void FinaliseForking(SIPTransaction & transaction, SIP_PDU & response);
991  void AbortPendingTransactions(bool all = true);
992 
994  const OpalTransport::WriteConnectCallback & function
995  );
996 
997  SIP_PDU::StatusCodes SwitchTransportProto(const char * proto, SIP_PDU * pdu);
998 
1000 
1001  SIPEndPoint & GetEndPoint() const { return m_sipEndpoint; }
1003  const SIPURL & GetRequestURI() const { return m_dialog.GetRequestURI(); }
1004  const SIPURL & GetRemoteURI() const { return m_dialog.GetRemoteURI(); }
1005  const SIPURL & GetProxy() const { return m_dialog.GetProxy(); }
1006  const PString & GetInterface() const { return m_dialog.GetInterface(); }
1007  PINDEX GetDNSEntry() const { return m_dnsEntry; }
1008  SIPAuthentication * GetAuthenticator() const { return m_authentication; }
1010  const SIPDialogContext & GetDialog() const { return m_dialog; }
1011 
1012  protected:
1013  PSafeObject & m_object;
1015  SIPDialogContext m_dialog; // Not all derived classes use this as a dialog, but many fields useful
1016  PINDEX m_dnsEntry;
1017  SIPAuthentication * m_authentication;
1019 
1020  PSafeArray<SIPTransaction> m_transactions;
1021  PDECLARE_MUTEX(m_forkMutex);
1022 
1023  friend class SIPTransaction;
1024 };
1025 
1026 
1028 {
1029  PCLASSINFO(SIPTransactionBase, SIP_PDU);
1030  protected:
1032  Methods method,
1033  const OpalTransportPtr & transport,
1034  const PString & transactionID
1035  ) : SIP_PDU(method, transport, transactionID) { }
1036 
1037  public:
1039  const PString & transactionID
1040  ) { m_transactionID = transactionID; }
1041 
1042  virtual bool IsTerminated() const { return true; }
1043 };
1044 
1045 
1057 {
1058  PCLASSINFO(SIPTransaction, SIPTransactionBase);
1059  protected:
1061  Methods method,
1062  SIPTransactionOwner * owner,
1063  OpalTransport * transport,
1064  bool deleteOwner = false,
1065  const PString & transactionID = PString::Empty()
1066  );
1067  public:
1068  ~SIPTransaction();
1069 
1070  /* Under some circumstances a new transaction with all the same parameters
1071  but different ID needs to be created, e.g. when get authentication error. */
1072  virtual SIPTransaction * CreateDuplicate() const = 0;
1073 
1074  bool Start();
1075  bool IsTrying() const { return GetState() == Trying; }
1076  bool IsProceeding() const { return GetState() == Proceeding; }
1077  bool IsInProgress() const { const States state = GetState(); return state == Trying || state == Proceeding; }
1078  bool IsFailed() const { return GetState() > Terminated_Success; }
1079  bool IsCompleted() const { return GetState() >= Completed; }
1080  bool IsCanceled() const { const States state = GetState(); return state == Cancelling || state == Terminated_Cancelled || state == Terminated_Aborted; }
1081  bool IsTerminated() const { return GetState() >= Terminated_Success; }
1082 
1083  void WaitForCompletion();
1084  PBoolean Cancel();
1085  void Abort();
1086 
1087  virtual PBoolean OnReceivedResponse(SIP_PDU & response);
1088  virtual PBoolean OnCompleted(SIP_PDU & response);
1089  virtual bool ReSend(const SIP_PDU & /*cmd*/) { return false; }
1090 
1091  SIPEndPoint & GetEndPoint() const { return m_owner->GetEndPoint(); }
1092  SIPConnection * GetConnection() const;
1093  PString GetInterface() const;
1094 
1095  static PString GenerateCallID();
1096 
1097  protected:
1098  bool ResendCANCEL();
1099  void SetParameters(const SIPParameters & params);
1100 
1102 
1103  void OnRetry();
1104  void OnTimeout();
1105 
1106  P_DECLARE_TRACED_ENUM(States,
1107  NotStarted,
1108  Trying,
1109  Proceeding,
1110  Cancelling,
1111  Completed,
1112  Terminated_Success,
1113  Terminated_Timeout,
1114  Terminated_RetriesExceeded,
1115  Terminated_TransportError,
1116  Terminated_Cancelled,
1117  Terminated_Aborted
1118  );
1119  States GetState() const;
1120  virtual void SetTerminated(States newState);
1121 
1123  const bool m_deleteOwner;
1124 
1125  PTimeInterval m_retryTimeoutMin;
1126  PTimeInterval m_retryTimeoutMax;
1127 
1128  States m_state;
1129  unsigned m_retry;
1132  PSyncPoint m_completed;
1135 
1136  friend class SIPConnection;
1137 };
1138 
1139 
1140 #define OPAL_PROXY_PARAM "OPAL-proxy"
1141 #define OPAL_LOCAL_ID_PARAM "OPAL-local-id"
1142 #define OPAL_INTERFACE_PARAM "OPAL-interface"
1143 
1144 
1146 // SIPResponse
1147 
1151 {
1152  PCLASSINFO(SIPResponse, SIPTransaction);
1153  public:
1154  SIPResponse(
1155  SIPEndPoint & endpoint,
1156  const SIP_PDU & command,
1157  StatusCodes code
1158  );
1159 
1160  virtual SIPTransaction * CreateDuplicate() const;
1161 
1162  virtual bool Send();
1163  virtual bool ReSend(const SIP_PDU & cmd);
1164 };
1165 
1166 
1168 // SIPInvite
1169 
1176 {
1177  PCLASSINFO(SIPInvite, SIPTransaction);
1178  public:
1179  SIPInvite(
1180  SIPConnection & connection,
1181  OpalTransport * transport = NULL
1182  );
1183  ~SIPInvite();
1184 
1185  virtual SIPTransaction * CreateDuplicate() const;
1186 
1187  virtual PBoolean OnReceivedResponse(SIP_PDU & response);
1188 
1190 };
1191 
1192 
1194 
1195 /* This is the ACK request sent when receiving a response to an outgoing
1196  * INVITE.
1197  */
1198 class SIPAck : public SIP_PDU
1199 {
1200  PCLASSINFO(SIPAck, SIP_PDU);
1201  public:
1202  SIPAck(
1203  const SIPTransaction & invite,
1204  const SIP_PDU & response
1205  );
1206 
1207  virtual SIPTransaction * CreateDuplicate() const;
1208 };
1209 
1210 
1212 
1213 /* This is a BYE request
1214  */
1215 class SIPBye : public SIPTransaction
1216 {
1217  PCLASSINFO(SIPBye, SIPTransaction);
1218  public:
1219  SIPBye(
1220  SIPEndPoint & endpoint,
1221  SIPDialogContext & dialog
1222  );
1223  SIPBye(
1224  SIPConnection & conn
1225  );
1226 
1227  virtual SIPTransaction * CreateDuplicate() const;
1228 };
1229 
1230 
1232 
1234 {
1235  PCLASSINFO(SIPRegister, SIPTransaction);
1236  public:
1237  P_DECLARE_TRACED_ENUM(CompatibilityModes,
1238  e_FullyCompliant,
1241  e_CannotRegisterMultipleContacts,
1245  e_CannotRegisterPrivateContacts,
1249  e_HasApplicationLayerGateway,
1253  e_RFC5626,
1256  e_Cisco
1257  );
1258 
1260  struct Params : public SIPParameters {
1263  , m_compatibility(SIPRegister::e_FullyCompliant)
1264  , m_instanceId(NULL)
1265  { }
1266 
1267  Params(const Params & param)
1268  : SIPParameters(param)
1271  , m_instanceId(param.m_instanceId)
1274  { }
1275 
1276  PCaselessString & m_registrarAddress; // For backward compatibility
1277  CompatibilityModes m_compatibility;
1278  PGloballyUniqueID m_instanceId;
1281  };
1282 
1283  SIPRegister(
1284  SIPTransactionOwner & owner,
1285  OpalTransport & transport,
1286  const PString & callId,
1287  unsigned cseq,
1288  const Params & params
1289  );
1290 
1291  virtual SIPTransaction * CreateDuplicate() const;
1292 };
1293 
1294 
1295 #if PTRACING
1296 ostream & operator<<(ostream & strm, SIPRegister::CompatibilityModes mode);
1297 ostream & operator<<(ostream & strm, const SIPRegister::Params & params);
1298 #endif
1299 
1300 
1302 
1304 {
1305  PCLASSINFO(SIPSubscribe, SIPTransaction);
1306  public:
1315 
1317 
1318  Watcher = 0x8000,
1319 
1323 
1325  };
1327 
1328  class EventPackage : public PCaselessString
1329  {
1330  PCLASSINFO(EventPackage, PCaselessString);
1331  public:
1333  explicit EventPackage(const PString & str) : PCaselessString(str) { }
1334  explicit EventPackage(const char * str) : PCaselessString(str) { }
1335 
1337  EventPackage & operator=(const PString & str) { PCaselessString::operator=(str); return *this; }
1338  EventPackage & operator=(const char * str) { PCaselessString::operator=(str); return *this; }
1339 
1340  bool operator==(PredefinedPackages pkg) const { return Compare(EventPackage(pkg)) == EqualTo; }
1341  bool operator==(const PString & str) const { return Compare(str) == EqualTo; }
1342  bool operator==(const char * cstr) const { return InternalCompare(0, P_MAX_INDEX, cstr) == EqualTo; }
1343  virtual Comparison InternalCompare(PINDEX offset, PINDEX length, const char * cstr) const;
1344 
1345  bool IsWatcher() const;
1346  };
1347 
1356  void * m_userData;
1357  friend ostream & operator<<(ostream & strm, const SubscriptionStatus & status);
1358  };
1359 
1362  SIPSubscribeHandler & handler,
1363  SIPEndPoint & ep,
1364  SIP_PDU & request,
1365  SIP_PDU & response
1366  );
1367 
1368 #if P_EXPAT
1369  bool LoadAndValidate(
1370  PXML & xml,
1371  const PXML::ValidationInfo * validator,
1372  PXML::Options options = PXML::WithNS
1373  );
1374 #endif
1375 
1376  bool SendResponse(
1378  const char * extra = NULL
1379  );
1380 
1386  };
1387 
1388  struct Params : public SIPParameters
1389  {
1392  , m_eventPackage(pkg)
1393  , m_eventList(false)
1394  { }
1395 
1396  Params(const Params & param)
1397  : SIPParameters(param)
1400  , m_eventList(param.m_eventList)
1401  , m_contentType(param.m_contentType)
1403  , m_onNotify(param.m_onNotify)
1404  { }
1405 
1406  PCaselessString & m_agentAddress; // For backward compatibility
1408  bool m_eventList; // Enable RFC4662
1409  PCaselessString m_contentType; // May be \n separated list of types
1410 
1411  PNotifierTemplate<const SubscriptionStatus &> m_onSubcribeStatus;
1412  PNotifierTemplate<NotifyCallbackInfo &> m_onNotify;
1413  };
1414 
1415  SIPSubscribe(
1416  SIPTransactionOwner & owner,
1417  OpalTransport & transport,
1418  SIPDialogContext & dialog,
1419  const Params & params
1420  );
1421 
1422  virtual SIPTransaction * CreateDuplicate() const;
1423 };
1424 
1425 
1426 #if PTRACING
1427 ostream & operator<<(ostream & strm, const SIPSubscribe::Params & params);
1428 #endif
1429 
1430 
1432 
1433 
1435 
1436 class SIPHandler;
1437 
1438 class SIPEventPackageHandler : public PObject
1439 {
1440  unsigned m_expectedSequenceNumber;
1441 
1442 public:
1443  SIPEventPackageHandler() : m_expectedSequenceNumber(UINT_MAX) { }
1444 
1446  virtual PCaselessString GetContentType() const = 0;
1447  virtual bool ValidateContentType(const PString & type, const SIPMIMEInfo & mime);
1448  virtual bool ValidateNotificationSequence(SIPSubscribeHandler & handler, unsigned newSequenceNumber, bool fullUpdate);
1449  virtual void OnReceivedNOTIFY(SIPSubscribe::NotifyCallbackInfo & notifyInfo) = 0;
1450  virtual PString OnSendNOTIFY(SIPHandler & /*handler*/, const PObject * /*body*/) { return PString::Empty(); }
1451 
1453 };
1454 
1455 
1456 typedef PFactory<SIPEventPackageHandler, SIPEventPackage> SIPEventPackageFactory;
1457 
1458 
1460 
1462 {
1463  PCLASSINFO(SIPNotify, SIPTransaction);
1464  public:
1465  SIPNotify(
1466  SIPTransactionOwner & owner,
1467  OpalTransport & transport,
1468  SIPDialogContext & dialog,
1469  const SIPEventPackage & eventPackage,
1470  const PString & state,
1471  const PString & body
1472  );
1473 
1474  virtual SIPTransaction * CreateDuplicate() const;
1475 };
1476 
1477 
1479 
1481 {
1482  PCLASSINFO(SIPPublish, SIPTransaction);
1483  public:
1484  SIPPublish(
1485  SIPTransactionOwner & owner,
1486  OpalTransport & transport,
1487  const PString & id,
1488  const PString & sipIfMatch,
1489  const SIPSubscribe::Params & params,
1490  const PString & body
1491  );
1492 
1493  virtual SIPTransaction * CreateDuplicate() const;
1494 };
1495 
1496 
1498 
1499 class SIPRefer : public SIPTransaction
1500 {
1501  PCLASSINFO(SIPRefer, SIPTransaction);
1502  public:
1504  {
1508  };
1509  static ReferSubMode SubModeFromBooleans(bool avoid, bool sub) { return avoid ? e_NoSubMode : (sub ? e_EnableSubMode : e_DisableSubMode); }
1510 
1511  SIPRefer(
1512  SIPConnection & connection,
1513  const SIPURL & referTo,
1514  const SIPURL & referred_by,
1515  ReferSubMode referSubMode
1516  );
1517 
1518  virtual SIPTransaction * CreateDuplicate() const;
1519 };
1520 
1521 
1523 
1524 /* This is not a generic NOTIFY PDU, but the minimal one
1525  * that gets sent when receiving a REFER
1526  */
1528 {
1529  PCLASSINFO(SIPReferNotify, SIPTransaction);
1530  public:
1532  SIPConnection & connection,
1533  StatusCodes code
1534  );
1535 
1536  virtual SIPTransaction * CreateDuplicate() const;
1537 };
1538 
1539 
1541 
1542 /* This is a MESSAGE PDU, with a body
1543  */
1545 {
1546  PCLASSINFO(SIPMessage, SIPTransaction);
1547  public:
1548  struct Params : public SIPParameters
1549  {
1551  : m_contentType("text/plain;charset=UTF-8")
1552  {
1553  m_expire = 3600; // Try to get mesage through for an hour
1554  }
1555 
1556  PCaselessString m_contentType;
1557  PString m_id;
1558 #if OPAL_HAS_IM
1560 #endif
1561  };
1562 
1563  SIPMessage(
1564  SIPTransactionOwner & owner,
1565  OpalTransport & transport,
1566  const Params & params
1567  );
1568  SIPMessage(
1569  SIPConnection & connection,
1570  const Params & params
1571  );
1572 
1573  virtual SIPTransaction * CreateDuplicate() const;
1574 
1575  const Params & GetParameters() const { return m_parameters; }
1576  const SIPURL & GetLocalAddress() const { return m_localAddress; }
1577 
1578  private:
1579  Params m_parameters;
1580  SIPURL m_localAddress;
1581 };
1582 
1583 
1585 
1586 /* This is an OPTIONS request
1587  */
1589 {
1590  PCLASSINFO(SIPOptions, SIPTransaction);
1591 
1592  public:
1593  struct Params : public SIPParameters
1594  {
1596  : m_acceptContent("application/sdp, application/media_control+xml, application/dtmf, application/dtmf-relay")
1597  {
1598  }
1599 
1600  PCaselessString m_acceptContent;
1601  PCaselessString m_contentType;
1602  };
1603 
1604  SIPOptions(
1605  SIPEndPoint & endpoint,
1606  const Params & params
1607  );
1608  SIPOptions(
1609  SIPConnection & conn,
1610  const Params & params
1611  );
1612 
1613  virtual SIPTransaction * CreateDuplicate() const;
1614 
1615  protected:
1616  void Construct(const Params & params);
1617 };
1618 
1619 
1621 
1622 /* This is an INFO request
1623  */
1624 class SIPInfo : public SIPTransaction
1625 {
1626  PCLASSINFO(SIPInfo, SIPTransaction);
1627 
1628  public:
1629  struct Params : public SIPParameters
1630  {
1631  Params(const PString & contentType = PString::Empty(),
1632  const PString & body = PString::Empty())
1633  {
1634  if (!contentType.IsEmpty() || !body.IsEmpty())
1635  m_body.AddPart(body, contentType);
1636  }
1637  };
1638 
1639  SIPInfo(
1640  SIPConnection & conn,
1641  const Params & params
1642  );
1643 
1644  virtual SIPTransaction * CreateDuplicate() const;
1645 };
1646 
1647 
1649 
1650 /* This is a PING PDU, with a body
1651  */
1652 class SIPPing : public SIPTransaction
1653 {
1654  PCLASSINFO(SIPPing, SIPTransaction);
1655 
1656  public:
1657  SIPPing(
1658  SIPTransactionOwner & owner,
1659  OpalTransport & transport,
1660  const SIPURL & address
1661  );
1662 
1663  virtual SIPTransaction * CreateDuplicate() const;
1664 };
1665 
1666 
1668 
1669 /* This is a PRACK PDU
1670  */
1671 class SIPPrack : public SIPTransaction
1672 {
1673  PCLASSINFO(SIPPrack, SIPTransaction);
1674 
1675  public:
1676  SIPPrack(
1677  SIPConnection & conn,
1678  OpalTransport & transport,
1679  const PString & rack
1680  );
1681 
1682  virtual SIPTransaction * CreateDuplicate() const;
1683 };
1684 
1685 
1686 #endif // OPAL_SIP
1687 
1688 #endif // OPAL_SIP_SIPPDU_H
1689 
1690 
1691 // End of File ///////////////////////////////////////////////////////////////
Definition: sippdu.h:1318
static const WORD DefaultPort
Definition: sippdu.h:75
PNotifierTemplate< const SubscriptionStatus & > m_onSubcribeStatus
Definition: sippdu.h:1411
static PString ExtractFieldParameter(const PString &fieldValue, const PString &paramName, const PString &defaultValue=PString::Empty())
virtual bool ReSend(const SIP_PDU &)
Definition: sippdu.h:1089
OpalTransportAddressArray m_responseAddresses
Definition: sippdu.h:744
SIPReferNotify(SIPConnection &connection, StatusCodes code)
void SetUserAgent(const PString &v)
const PString & GetTransactionID() const
Definition: sippdu.h:699
Definition: sippdu.h:1328
friend ostream & operator<<(ostream &strm, const SubscriptionStatus &status)
bool ReallyInternalParse(bool fromField, const char *cstr, const char *defaultScheme)
Definition: sippdu.h:552
const SIPURL & GetRequestURI() const
Definition: sippdu.h:1003
PCaselessString m_contactAddress
Definition: sippdu.h:854
SIP_PDU & m_pdu
Definition: sippdu.h:509
PString GetRecordRoute() const
Definition: sippdu.h:71
PString GetFieldParameter(const PString &fieldName, const PString &paramName, const PString &defaultValue=PString::Empty()) const
Definition: sippdu.h:450
virtual PString GetMethod()
Definition: sippdu.h:599
PString GetOrganization() const
SIPRefer(SIPConnection &connection, const SIPURL &referTo, const SIPURL &referred_by, ReferSubMode referSubMode)
PTimeInterval m_retryTimeoutMin
Definition: sippdu.h:1125
const SIPURL & GetProxy() const
Definition: sippdu.h:793
Definition: sippdu.h:1324
Definition: sippdu.h:596
SIP_PDU & operator=(const SIP_PDU &)
Definition: sippdu.h:531
Definition: sippdu.h:537
bool SendResponse(SIP_PDU::StatusCodes status=SIP_PDU::Successful_OK, const char *extra=NULL)
Definition: sippdu.h:615
Methods m_method
Definition: sippdu.h:730
PCaselessString m_interface
Definition: sippdu.h:855
virtual PBoolean OnReceivedResponse(SIP_PDU &response)
PString GetAcceptLanguage() const
bool IsInProgress() const
Definition: sippdu.h:1077
States GetState() const
friend ostream & operator<<(ostream &strm, const SIPURLList &urls)
virtual SIPTransaction * CreateDuplicate() const
Definition: sippdu.h:527
uint32_t MessageID
Definition: im.h:91
Definition: sippdu.h:1303
void SetMaxForwards(PINDEX v)
unsigned m_restoreTime
Definition: sippdu.h:862
Definition: sippdu.h:1150
PString m_ciscoDeviceType
Definition: sippdu.h:1279
void SetWWWAuthenticate(const PString &v)
OpalTransportAddress m_viaAddress
Definition: sippdu.h:743
~SIPPoolTimer()
Definition: sippdu.h:958
void AddRequire(const PString &v)
unsigned GetVersionMinor() const
Definition: sippdu.h:707
SIPURL GetReferTo() const
PString GetAllowEvents() const
PStringSet GetUnsupported() const
PredefinedPackages
Definition: sippdu.h:1309
void SetEntityBody(const PString &body)
Definition: sippdu.h:710
PQUEUE(SIP_PDU_Queue, SIP_PDU)
Definition: sippdu.h:1056
OpalProductInfo m_productInfo
Server product info from registrar if available.
Definition: sippdu.h:1355
Definition: sippdu.h:1544
static const WORD DefaultSecurePort
Definition: sippdu.h:76
SIPMIMEInfo & GetMIME()
Definition: sippdu.h:715
void SetContentEncoding(const PString &v)
PCaselessString & m_registrarAddress
Definition: sippdu.h:1276
SIPPoolTimer< SIPTransaction > PoolTimer
Definition: sippdu.h:1101
PString GetVia() const
virtual bool ReSend(const SIP_PDU &cmd)
void SetSIPIfMatch(const PString &v)
void SetProductInfo(const PString &ua, const OpalProductInfo &info)
Definition: sippdu.h:548
SIPThreadPool(unsigned maxWorkers, const char *threadName)
Definition: sippdu.h:904
SIPEndPoint & m_sipEndpoint
Definition: sippdu.h:1014
Definition: sippdu.h:1314
void SetProxyAuthenticate(const PString &v)
SIPPoolTimer(SIPThreadPool &pool, SIPEndPoint &ep, const PString &token, void(Target_T::*callback)())
Definition: sippdu.h:952
SIP_PDU::StatusCodes m_reason
Reason for status change.
Definition: sippdu.h:1354
Definition: sippdu.h:296
static ReferSubMode SubModeFromBooleans(bool avoid, bool sub)
Definition: sippdu.h:1509
bool m_forking
Definition: sippdu.h:830
Definition: sippdu.h:1548
virtual SIPTransaction * CreateDuplicate() const
virtual SIPTransaction * CreateDuplicate() const
void SetAllow(const PString &v)
NotifyCallbackInfo(SIPSubscribeHandler &handler, SIPEndPoint &ep, SIP_PDU &request, SIP_PDU &response)
bool m_retryForbidden
Definition: sippdu.h:865
void SetProxy(const SIPURL &proxy, bool addToRouteSet)
void SetContentLength(PINDEX v)
Definition: sippdu.h:1215
PString AsQuotedString() const
virtual SIPTransaction * CreateDuplicate() const
SIPDialogContext m_dialog
Definition: sippdu.h:1015
SIPDialogContext & GetDialog()
Definition: sippdu.h:1009
const SIPURL & GetProxy() const
Definition: sippdu.h:1005
virtual SIPTransaction * CreateDuplicate() const =0
const PString & GetEntityBody() const
Definition: sippdu.h:709
virtual PBoolean InternalParse(const char *cstr, const char *defaultScheme)
Definition: sippdu.h:227
bool SendResponse(StatusCodes code)
const OpalTransportAddressArray & GetResponseAddresses() const
Definition: sippdu.h:722
void SetContentType(const PString &v)
virtual Comparison Compare(const PObject &obj) const
virtual void PrintOn(ostream &strm) const
virtual bool ValidateContentType(const PString &type, const SIPMIMEInfo &mime)
Definition: sippdu.h:562
void SetAcceptEncoding(const PString &v)
PString GetAccept() const
SIPInvite(SIPConnection &connection, OpalTransport *transport=NULL)
PString m_interface
Definition: sippdu.h:832
P_REMOVE_VIRTUAL(bool, OnReceivedNOTIFY(SIPHandler &, SIP_PDU &), false)
PString GetWWWAuthenticate() const
SIP_PDU & m_request
Definition: sippdu.h:1383
Definition: sipcon.h:131
SIPTransactionOwner *const m_owner
Definition: sippdu.h:1122
static PString InsertFieldParameter(const PString &fieldValue, const PString &paramName, const PString &newValue)
SIPAuthenticator(SIP_PDU &pdu)
void SetRequire(const PStringSet &v)
void * m_userData
User data corresponding to this registration.
Definition: sippdu.h:1356
virtual SIPTransaction * CreateDuplicate() const
bool ResendCANCEL()
PMultiPartList m_body
Definition: sippdu.h:857
virtual const char * GetGroup(const Work_T &) const
Definition: sippdu.h:963
Callback m_callback
Definition: sippdu.h:935
PString m_remoteTag
Definition: sippdu.h:825
bool IsTrying() const
Definition: sippdu.h:1075
virtual void OnStartTransaction(SIPTransaction &)
Definition: sippdu.h:985
Definition: sippdu.h:1027
Definition: sippdu.h:573
StatusCodes m_statusCode
Definition: sippdu.h:731
Definition: transports.h:788
Definition: sippdu.h:533
PTimeInterval m_maxRetryTime
Definition: sippdu.h:864
Definition: sippdu.h:1671
Definition: sippdu.h:1312
Definition: sippdu.h:1388
SIPURL m_uri
Definition: sippdu.h:732
EventPackage(PredefinedPackages=NumPredefinedPackages)
bool GetTarget(PSafePtr< SIPTransaction > &transaction)
Definition: sipep.h:52
virtual void OnTransactionFailed(SIPTransaction &transaction)
const PString & GetInfo() const
Definition: sippdu.h:712
PString GetProxyAuthenticate() const
virtual SIPTransaction * CreateDuplicate() const
Definition: sippdu.h:593
PString GetAcceptEncoding() const
PStringOptions & GetFieldParameters()
Definition: sippdu.h:165
Definition: sippdu.h:1311
PString m_realm
Definition: sippdu.h:860
SIPEndPoint & GetEndPoint() const
Definition: sippdu.h:1001
virtual bool ValidateNotificationSequence(SIPSubscribeHandler &handler, unsigned newSequenceNumber, bool fullUpdate)
Definition: sippdu.h:1505
Definition: sippdu.h:613
SIPNotify(SIPTransactionOwner &owner, OpalTransport &transport, SIPDialogContext &dialog, const SIPEventPackage &eventPackage, const PString &state, const PString &body)
Definition: sippdu.h:605
PString m_displayName
Definition: sippdu.h:239
OpalTransportAddressArray m_responseAddresses
Definition: sippdu.h:829
Definition: sippdu.h:604
void SetLocalTag(const PString &tag)
Definition: sippdu.h:779
bool operator==(PredefinedPackages pkg) const
Definition: sippdu.h:1340
PCaselessString m_contentType
Definition: sippdu.h:1601
Definition: sippdu.h:563
StatusCodes
Definition: sippdu.h:544
Definition: sippdu.h:522
void SetExpires(unsigned v)
PCaselessString m_remoteAddress
Definition: sippdu.h:850
Definition: sippdu.h:1320
void InitialiseHeaders(const SIPURL &dest, const SIPURL &to, const SIPURL &from, const PString &callID, unsigned cseq)
Definition: sippdu.h:579
SDPSessionDescription * m_SDP
Definition: sippdu.h:740
void AddSupported(const PString &v)
PCaselessString & m_agentAddress
Definition: sippdu.h:1406
void SetDate(void)
Definition: sippdu.h:1527
SIPURL & operator=(const PURL &url)
Definition: sippdu.h:83
SIPURLList m_routeSet
Definition: sippdu.h:826
PSafeObject & m_object
Definition: sippdu.h:1013
bool GetViaList(PStringList &v) const
PString GetCallID() const
SIPURL m_localURI
Definition: sippdu.h:822
const PString & GetLocalTag() const
Definition: sippdu.h:778
void SetCompactForm(bool form)
Definition: sippdu.h:305
SIPURL GetPPreferredIdentity() const
const PString & GetInterface() const
Definition: sippdu.h:814
EventPackage & operator=(const PString &str)
Definition: sippdu.h:1337
virtual PString GetEntityBody()
Definition: sippdu.h:1198
Definition: sippdu.h:535
Registration Contact header field.
Definition: sippdu.h:194
virtual bool Send()
SIPRegister(SIPTransactionOwner &owner, OpalTransport &transport, const PString &callId, unsigned cseq, const Params &params)
SIPURL m_proxy
Definition: sippdu.h:831
OpalTransportAddress GetRemoteTransportAddress(PINDEX dnsEntry) const
SIPEndPoint & m_endpoint
Definition: sippdu.h:894
PString m_addressofRecord
Address of record for registration.
Definition: sippdu.h:1351
PString GetSIPETag() const
Definition: sippdu.h:536
PCaselessString GetContentEncoding() const
unsigned GetMinExpires() const
SIPMessage(SIPTransactionOwner &owner, OpalTransport &transport, const Params &params)
virtual SIPTransaction * CreateDuplicate() const
Definition: sippdu.h:575
void SetTransport(const OpalTransportPtr &transport PTRACE_PARAM(, const char *location))
Definition: sippdu.h:601
Definition: sippdu.h:589
SIP_PDU & m_response
Definition: sippdu.h:1384
SIPEndPoint & m_endpoint
Definition: sippdu.h:1382
Definition: sippdu.h:547
void SetRouteSet(const PString &str)
Definition: sippdu.h:791
unsigned m_lastSentCSeq
Definition: sippdu.h:827
SIPAuthentication * GetAuthenticator() const
Definition: sippdu.h:1008
void SetReferredBy(const PString &r)
PSafeDictionary< PKey< unsigned >, OpalMediaSession > SessionMap
Definition: rtpconn.h:320
Definition: sippdu.h:553
Definition: sippdu.h:1480
SIPSubscribe::EventPackage SIPEventPackage
Definition: sippdu.h:1431
SIPWorkItem(SIPEndPoint &ep, const PString &token)
virtual SIPTransaction * CreateDuplicate() const
Definition: sippdu.h:972
PoolTimer m_completionTimer
Definition: sippdu.h:1131
void SetInterface(const PString &newInterface)
Definition: sippdu.h:815
void SetAlertInfo(const PString &info, int appearance)
void SetVia(const PString &v)
PString GetUserAgent() const
const SIPMIMEInfo & GetMIME() const
Definition: sippdu.h:714
virtual SIPTransaction * CreateDuplicate() const
PTimeInterval m_minRetryTime
Definition: sippdu.h:863
void SetSIPETag(const PString &v)
const PString & GetInterface() const
Definition: sippdu.h:1006
States m_state
Definition: sippdu.h:1128
PNotifierTemplate< bool & > WriteConnectCallback
Definition: transports.h:965
PString GetSubject() const
Definition: sippdu.h:538
virtual PString GetURI()
SIPURL & operator=(const PString &str)
Definition: sippdu.h:103
bool operator==(const char *cstr) const
Definition: sippdu.h:1342
virtual SIP_PDU::StatusCodes StartTransaction(const OpalTransport::WriteConnectCallback &function)
Definition: sippdu.h:594
SIPSubscribe(SIPTransactionOwner &owner, OpalTransport &transport, SIPDialogContext &dialog, const Params &params)
virtual void OnReceivedResponse(SIPTransaction &transaction, SIP_PDU &response)
void SetCSeq(const PString &v)
PCaselessString m_contentType
Definition: sippdu.h:1556
virtual PBoolean OnCompleted(SIP_PDU &response)
Params()
Definition: sippdu.h:1595
unsigned m_lastReceivedCSeq
Definition: sippdu.h:828
bool SetRoute(const SIPURLList &routeSet)
Definition: sippdu.h:541
PCaselessString GetTransportProto() const
Return the correct &quot;transport&quot; parameter, using correct default based on scheme.
void SetAcceptLanguage(const PString &v)
WORD GetDefaultPort() const
void SetOrganization(const PString &v)
virtual bool IsTerminated() const
Definition: sippdu.h:1042
void SetURI(const SIPURL &newuri)
Definition: sippdu.h:705
Definition: sippdu.h:1506
virtual bool InternalAddMIME(const PString &fieldName, const PString &fieldValue)
PString GetFirstVia() const
Definition: sippdu.h:580
CompatibilityModes m_compatibility
Definition: sippdu.h:1277
PCaselessString m_localAddress
Definition: sippdu.h:851
Definition: mediafmt.h:112
Definition: sippdu.h:1175
SIPMIMEInfo(bool compactForm=false)
bool IsFailed() const
Definition: sippdu.h:1078
virtual PMIMEInfo & GetMIME()
PString m_ciscoDevicePattern
Definition: sippdu.h:1280
Definition: sippdu.h:584
Definition: sippdu.h:565
virtual void Work()
Definition: sippdu.h:924
PString GetFromTag() const
General Contact header field.
Definition: sippdu.h:193
void SetPPreferredIdentity(const PString &v)
bool IsProceeding() const
Definition: sippdu.h:1076
ReferSubMode
Definition: sippdu.h:1503
SIPPrack(SIPConnection &conn, OpalTransport &transport, const PString &rack)
void SetSubject(const PString &v)
const SIPURL & GetLocalAddress() const
Definition: sippdu.h:1576
PString ToString() const
SIP_PDU(Methods method=SIP_PDU::NumMethods, const OpalTransportPtr &transport=NULL, const PString &transactionID=PString::Empty())
void SetContact(const PString &v)
void SetSubscriptionState(const PString &v)
bool GetContacts(SIPURLList &contacts, unsigned defaultExpires) const
Definition: sippdu.h:499
Definition: sippdu.h:1321
Definition: sippdu.h:597
SIPSubscribeHandler & m_handler
Definition: sippdu.h:1381
bool CleanPendingTransactions()
Definition: sippdu.h:1588
Redirect Contact header field.
Definition: sippdu.h:192
void SetViaList(const PStringList &v)
Definition: sippdu.h:1593
void AddUnsupported(const PString &v)
virtual PBoolean OnReceivedResponse(SIP_PDU &response)
PString m_authID
Definition: sippdu.h:858
Definition: sippdu.h:572
virtual bool Send()
static PString GenerateCallID()
const bool m_deleteOwner
Definition: sippdu.h:1123
Definition: sippdu.h:540
void Build(PString &pduStr, PINDEX &pduLen)
SIPURL FindCompatible(const OpalTransportAddress &addr PTRACE_PARAM(, const char *listType)) const
unsigned m_versionMinor
Definition: sippdu.h:734
const PString & GetRemoteTag() const
Definition: sippdu.h:784
bool CanLookupSRV() const
Indicate we can do an SRV lookup for host names.
Params()
Definition: sippdu.h:1550
unsigned m_retry
Definition: sippdu.h:1129
SIPEndPoint & GetEndPoint() const
Definition: sippdu.h:1091
SIPAck(const SIPTransaction &invite, const SIP_PDU &response)
SIPBye(SIPEndPoint &endpoint, SIPDialogContext &dialog)
PCaselessString m_acceptContent
Definition: sippdu.h:1600
virtual unsigned GetAllowedMethods() const
void SetReferTo(const PString &r)
Definition: sippdu.h:539
Definition: sippdu.h:587
bool DecodeSDP(SIPConnection &connection, PMultiPartList &parts)
Definition: handlers.h:49
Definition: sippdu.h:1316
SIPURL m_remoteURI
Definition: sippdu.h:824
PCaselessString GetSubscriptionState(PStringToString &info) const
bool GetSDP(const PString &entityBody, PString &sdp, PMultiPartList &parts) const
#define PTRACE(level, section, args)
Definition: opalplugin.hpp:84
Definition: sippdu.h:602
Definition: sippdu.h:1652
virtual SIPTransaction * CreateDuplicate() const
Definition: sippdu.h:571
static PString GenerateTag()
Generate a unique string suitable as a dialog tag.
SIPPublish(SIPTransactionOwner &owner, OpalTransport &transport, const PString &id, const PString &sipIfMatch, const SIPSubscribe::Params &params, const PString &body)
PCaselessString m_contentType
Definition: sippdu.h:1409
Definition: sippdu.h:838
virtual SIPTransaction * CreateDuplicate() const
PTimeInterval m_retryTimeoutMax
Definition: sippdu.h:1126
void IncrementCSeq(unsigned inc)
Definition: sippdu.h:799
Definition: sippdu.h:610
bool m_reSubscribing
Was a registration refresh.
Definition: sippdu.h:1353
bool operator==(const PString &str) const
Definition: sippdu.h:1341
Definition: sippdu.h:550
OpalTransportAddress GetRemoteTransportAddress() const
Definition: sippdu.h:1002
void SetParameters(const SIPParameters &params)
PString m_localTag
Definition: sippdu.h:823
StatusCodes InternalSend(bool canDoTCP)
SIPPing(SIPTransactionOwner &owner, OpalTransport &transport, const SIPURL &address)
Definition: sippdu.h:581
PString GetCSeq() const
void SetRemoteURI(const SIPURL &url)
void SetMinExpires(PINDEX v)
Methods GetMethod() const
Definition: sippdu.h:701
virtual PCaselessString GetContentType() const =0
EventPackage(const char *str)
Definition: sippdu.h:1334
EventPackage & operator=(const char *str)
Definition: sippdu.h:1338
Definition: sippdu.h:574
SIPInfo(SIPConnection &conn, const Params &params)
Definition: sippdu.h:534
PString GetAllow() const
Definition: sippdu.h:588
const SIPURL & GetRemoteURI() const
Definition: sippdu.h:787
void PrintOn(ostream &strm) const
void AbortPendingTransactions(bool all=true)
PString GetRoute() const
Definition: sippdu.h:598
Definition: sippdu.h:1349
Definition: sippdu.h:881
unsigned GetAllowBitMask() const
Definition: sippdu.h:1313
Definition: sippdu.h:1310
Definition: sippdu.h:1233
Definition: sippdu.h:761
PHTTPClientAuthentication SIPAuthentication
Definition: sippdu.h:497
friend PredefinedPackages operator|(PredefinedPackages p1, PredefinedPackages p2)
Definition: sippdu.h:1326
Definition: sippdu.h:558
Params(const Params &param)
Definition: sippdu.h:1396
SIPTimeoutWorkItem(SIPEndPoint &ep, const PString &token, Callback callback)
Definition: sippdu.h:918
Definition: sippdu.h:1438
void * m_userData
Definition: sippdu.h:866
To header field.
Definition: sippdu.h:189
UsageContext
Definition: sippdu.h:186
URI on REGISTER request line.
Definition: sippdu.h:195
Request-URI (after the INVITE)
Definition: sippdu.h:188
virtual ~SIPEventPackageHandler()
Definition: sippdu.h:1445
PINDEX m_dnsEntry
Definition: sippdu.h:1016
P_DECLARE_TRACED_ENUM(CompatibilityModes, e_FullyCompliant, e_CannotRegisterMultipleContacts, e_CannotRegisterPrivateContacts, e_HasApplicationLayerGateway, e_RFC5626, e_Cisco)
SIPURL GetFrom() const
PString m_callId
Definition: sippdu.h:820
unsigned GetCSeqIndex() const
Definition: sippdu.h:401
void SetTo(const SIPURL &v)
PCaselessString m_addressOfRecord
Definition: sippdu.h:853
const SIPURL & GetRemoteURI() const
Definition: sippdu.h:1004
PString AsString() const
bool IsContentSDP(bool emptyOK=false) const
virtual void SetTerminated(States newState)
void SetRecordRoute(const PString &v)
void SetDisplayName(const PString &str)
Definition: sippdu.h:158
void SetUnsupported(const PStringSet &v)
P_DECLARE_TRACED_ENUM(States, NotStarted, Trying, Proceeding, Cancelling, Completed, Terminated_Success, Terminated_Timeout, Terminated_RetriesExceeded, Terminated_TransportError, Terminated_Cancelled, Terminated_Aborted)
ostream & operator<<(ostream &strm, OpalSilenceDetector::Mode mode)
PGloballyUniqueID m_instanceId
Definition: sippdu.h:1278
void SetLocalURI(const SIPURL &url)
Definition: sippdu.h:1461
Definition: sippdu.h:546
Definition: sippdu.h:940
virtual PString OnSendNOTIFY(SIPHandler &, const PObject *)
Definition: sippdu.h:1450
StatusCodes GetStatusCode() const
Definition: sippdu.h:702
OpalTransportPtr GetTransport() const
Definition: sippdu.h:723
void SetCallID(const PString &v)
static PString GetStatusCodeDescription(int code)
virtual SIPTransaction * CreateDuplicate() const
Definition: sippdu.h:595
SIPURL(const PURL &url)
Definition: sippdu.h:80
PString m_id
Definition: sippdu.h:1557
PINDEX GetContentLength() const
SIPOptions(SIPEndPoint &endpoint, const Params &params)
SIP_PDU::StatusCodes HandleAuthentication(const SIP_PDU &response)
Definition: sippdu.h:582
bool IsEstablished() const
Definition: sippdu.h:803
PString m_localInterface
Definition: sippdu.h:1134
Definition: sippdu.h:912
SIPURL GetContact() const
virtual Comparison InternalCompare(PINDEX offset, PINDEX length, const char *cstr) const
PNotifierTemplate< NotifyCallbackInfo & > m_onNotify
Definition: sippdu.h:1412
const SIPURL & GetRequestURI() const
Definition: sippdu.h:775
SIPURL m_requestURI
Definition: sippdu.h:821
Definition: sippdu.h:576
bool IsCanceled() const
Definition: sippdu.h:1080
Definition: sippdu.h:568
Definition: sippdu.h:600
void Sanitise(UsageContext context)
PSafePtr< OpalTransport > OpalTransportPtr
Definition: transports.h:50
void SetAllowEvents(const PString &v)
Params(const PString &contentType=PString::Empty(), const PString &body=PString::Empty())
Definition: sippdu.h:1631
OpalRTPConnection::SessionMap m_sessions
Definition: sippdu.h:1189
Definition: sippdu.h:556
virtual PString GetPassword() const
Definition: sippdu.h:982
void SetPAssertedIdentity(const PString &v)
unsigned GetVersionMajor() const
Definition: sippdu.h:706
void InternalFromString(const PString &str, SIPURL::UsageContext context, bool reversed)
PoolTimer m_retryTimer
Definition: sippdu.h:1130
const SIPURL & GetURI() const
Definition: sippdu.h:704
void GetProductInfo(OpalProductInfo &info) const
URI used anywhere outside of protocol.
Definition: sippdu.h:187
virtual SIPTransaction * CreateDuplicate() const
Definition: handlers.h:205
OpalTransportAddress GetViaReceivedAddress() const
SIPMIMEInfo m_mime
Definition: sippdu.h:856
Registrar parameters.
Definition: sippdu.h:1260
SIPURL GetPAssertedIdentity() const
PCaselessString m_proxyAddress
Definition: sippdu.h:852
const Params & GetParameters() const
Definition: sippdu.h:1575
void SetEntityBody()
Definition: sippdu.h:549
void SetInfo(const PString &info)
Definition: sippdu.h:713
void SetCallID(const PString &id)
Definition: sippdu.h:773
Params(const Params &param)
Definition: sippdu.h:1267
Params()
Definition: sippdu.h:1261
void SetSupported(const PStringSet &v)
virtual SIPTransaction * CreateDuplicate() const
bool m_sendResponse
Definition: sippdu.h:1385
void SetRoute(const PString &v)
bool m_eventList
Definition: sippdu.h:1408
unsigned m_authenticateErrors
Definition: sippdu.h:1018
SIPURL GetReferredBy() const
Definition: sippdu.h:1624
Definition: sippdu.h:244
Definition: sippdu.h:1322
void Construct(const Params &params)
PStringSet GetSupported() const
Definition: sippdu.h:617
SIPAuthentication * m_authentication
Definition: sippdu.h:1017
Definition: sippdu.h:551
PString GetSIPIfMatch() const
bool IsCompleted() const
Definition: sippdu.h:1079
SIPURL GetTo() const
unsigned GetMaxForwards() const
Definition: sippdu.h:577
void SetAllow(unsigned bitmask)
void SetForking(bool f)
Definition: sippdu.h:817
const SIPURL & GetLocalURI() const
Definition: sippdu.h:781
PStringSet GetRequire() const
void SetAccept(const PString &v)
Definition: sippdu.h:559
Methods
Definition: sippdu.h:526
SIPEventPackageHandler()
Definition: sippdu.h:1443
void SetCSeq(unsigned cseq)
unsigned m_versionMajor
Definition: sippdu.h:733
PString GetTag() const
Get a tag.
const SIPURLList & GetRouteSet() const
Definition: sippdu.h:790
void SetFieldParameter(const PString &fieldName, const PString &paramName, const PString &newValue)
Definition: sippdu.h:460
Definition: sippdu.h:899
friend ostream & operator<<(ostream &strm, StatusCodes status)
StatusCodes Read()
Definition: sippdu.h:1499
const PStringOptions & GetFieldParameters() const
Return string options in field parameters.
Definition: sippdu.h:164
virtual void OnReceivedNOTIFY(SIPSubscribe::NotifyCallbackInfo &notifyInfo)=0
void SetTokenSet(const char *field, const PStringSet &tokens)
PTIMER_OPERATORS(SIPPoolTimer)
PString m_transactionID
Definition: sippdu.h:738
void SetHostAddress(const OpalTransportAddress &addr)
PBoolean Cancel()
StatusCodes Parse(istream &strm, bool truncated)
bool FromString(const PString &str)
bool IsTerminated() const
Definition: sippdu.h:1081
Params(PredefinedPackages pkg=NumPredefinedPackages)
Definition: sippdu.h:1390
void SetStatusCode(StatusCodes c)
Definition: sippdu.h:703
SIPURL & operator=(const char *cstr)
Definition: sippdu.h:93
PFactory< SIPEventPackageHandler, SIPEventPackage > SIPEventPackageFactory
Definition: sippdu.h:1456
PString m_token
Definition: sippdu.h:895
SIPMIMEInfo m_mime
Definition: sippdu.h:736
Definition: sippdu.h:606
void SetEvent(const PString &v)
PSyncPoint m_completed
Definition: sippdu.h:1132
EventPackage & operator=(PredefinedPackages pkg)
void SetFrom(const SIPURL &v)
void ParseAsAddress(const PString &name, const OpalTransportAddress &address, WORD listenerPort, const char *scheme)
bool Normalise(const PString &defaultUser, const PTimeInterval &defaultExpire)
Definition: sippdu.h:529
SIPSubscribeHandler * m_handler
Handler for subscription.
Definition: sippdu.h:1350
SIPTransactionBase(Methods method, const OpalTransportPtr &transport, const PString &transactionID)
Definition: sippdu.h:1031
OpalTransportPtr m_transport
Definition: sippdu.h:742
PString GetInterface() const
const PString & GetCallID() const
Definition: sippdu.h:772
PString GetDisplayName(PBoolean useDefault=true) const
Definition: sippdu.h:1360
Definition: transports.h:151
PString m_info
Definition: sippdu.h:735
Definition: transports.h:326
EventPackage m_eventPackage
Definition: sippdu.h:1407
void SetRequestURI(const SIPURL &url)
bool compactForm
Encode using compact form.
Definition: sippdu.h:490
bool IsDuplicateCSeq(unsigned sequenceNumber)
Definition: sippdu.h:557
void GetAlertInfo(PString &info, int &appearance) const
PINDEX GetDNSEntry() const
Definition: sippdu.h:1007
SIPTransactionBase(const PString &transactionID)
Definition: sippdu.h:1038
unsigned GetExpires(unsigned dflt=UINT_MAX) const
void(Target_T::* Callback)()
Definition: sippdu.h:916
SIPParameters(const PString &aor=PString::Empty(), const PString &remote=PString::Empty())
virtual SIPTransaction * CreateDuplicate() const
Definition: sippdu.h:554
PCaselessString GetContentType(bool includeParameters=false) const
Definition: sippdu.h:545
Definition: sippdu.h:1507
void SetRemoteTag(const PString &tag)
Definition: sippdu.h:785
void AddTokenSet(const char *field, const PString &token)
void WaitForCompletion()
const SIPDialogContext & GetDialog() const
Definition: sippdu.h:1010
virtual void Work()=0
SIPTransaction(Methods method, SIPTransactionOwner *owner, OpalTransport *transport, bool deleteOwner=false, const PString &transactionID=PString::Empty())
bool FromString(const PString &str, SIPURL::UsageContext context=SIPURL::RouteURI, bool reversed=false)
OpalIM::MessageID m_messageId
Definition: sippdu.h:1559
void FinaliseForking(SIPTransaction &transaction, SIP_PDU &response)
unsigned m_expire
Definition: sippdu.h:861
From header field.
Definition: sippdu.h:190
PString m_entityBody
Definition: sippdu.h:737
SIPResponse(SIPEndPoint &endpoint, const SIP_PDU &command, StatusCodes code)
Definition: sippdu.h:1629
PString SetTag(const PString &tag=GenerateTag(), bool force=false)
Set a tag with a new unique ID.
PDECLARE_MUTEX(m_forkMutex)
PStringSet GetTokenSet(const char *field) const
PString GetEvent() const
Definition: sippdu.h:608
SIPConnection * GetConnection() const
virtual PString GetAuthID() const =0
PStringOptions m_fieldParameters
Definition: sippdu.h:240
PString m_password
Definition: sippdu.h:859
Definition: sippdu.h:532
bool m_pduSizeOK
Definition: sippdu.h:1133
OpalTransportAddress GetTransportAddress(PINDEX dnsEntry=P_MAX_INDEX) const
Record-Route header field.
Definition: sippdu.h:191
SDPSessionDescription * GetSDP()
Definition: sippdu.h:716
void CalculateVia()
PBoolean IsContentLengthPresent() const
SIP_PDU::StatusCodes SwitchTransportProto(const char *proto, SIP_PDU *pdu)
EventPackage(const PString &str)
Definition: sippdu.h:1333
Definition: connection.h:358
SIPTransactionOwner(PSafeObject &object, SIPEndPoint &endpoint)
PString GetCallInfo() const
void Update(const SIP_PDU &response)
Definition: sippdu.h:528
Definition: sippdu.h:607
void SetSDP(SDPSessionDescription *sdp)
PString GetToTag() const
virtual ~SIPTransactionOwner()
unsigned GetNextCSeq()
PSafeArray< SIPTransaction > m_transactions
Definition: sippdu.h:1020
bool m_wasSubscribing
Was registering or unregistering.
Definition: sippdu.h:1352
Definition: sippdu.h:530
PString GetDate() const