sipxtacklib  Version 3.3
SipDialog.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2014 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2004-2006 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
8 // Licensed to SIPfoundry under a Contributor Agreement.
9 //
10 // $$
12 // Author: Dan Petrie (dpetrie AT SIPez DOT com)
13 
14 #ifndef _SipDialog_h_
15 #define _SipDialog_h_
16 
17 // SYSTEM INCLUDES
18 
19 // APPLICATION INCLUDES
20 
21 #include <os/OsDefs.h>
22 #include <utl/UtlHashMap.h>
23 #include <net/Url.h>
24 
25 // DEFINES
26 // MACROS
27 // EXTERNAL FUNCTIONS
28 // EXTERNAL VARIABLES
29 // CONSTANTS
30 #define DIALOG_HANDLE_SEPARATOR ','
31 
32 // STRUCTS
33 // TYPEDEFS
34 // FORWARD DECLARATIONS
35 class SipMessage;
36 
38 
61 class SipDialog : public UtlString
62 {
63 /* //////////////////////////// PUBLIC //////////////////////////////////// */
64 public:
65 
67  {
73  };
74 
75 /* ============================ CREATORS ================================== */
76 
78 
88  SipDialog(const SipMessage* initialMessage = NULL,
89  UtlBoolean isFromLocal = TRUE);
90 
92 
100  SipDialog(const char* callId, const char* localField, const char* remoteField);
101 
103  virtual
104  ~SipDialog();
105 
106 
107 /* ============================ MANIPULATORS ============================== */
108 
110 
115  void updateDialogData(const SipMessage& message);
116 
118 
125  void setRequestData(SipMessage& request, const char* method);
126 
127 /* ============================ ACCESSORS ================================= */
128 
129 
131  void getHandle(UtlString& dialogHandle) const;
132 
134  void getEarlyHandle(UtlString& earlyDialogHandle) const;
135 
137  static void parseHandle(const char* dialogHandle,
138  UtlString& callId,
139  UtlString& localTag,
140  UtlString& remoteTag);
141 
143  static void reverseTags(const char* dialogHandle,
144  UtlString& reversedHandle);
145 
147  void getCallId(UtlString& callId) const;
149  void setCallId(const char* callId);
150 
152  void getLocalField(Url& localUrl) const;
154  void getLocalTag(UtlString& localTag) const;
156  void setLocalField(const Url& localUrl);
157 
159  void getRemoteField(Url& remoteUrl) const;
161  void getRemoteTag(UtlString& remoteTag) const;
163  void setRemoteField(const Url& remoteUrl);
164 
166  void getRemoteContact(Url& remoteContact) const;
168  void setRemoteContact(const Url& remoteContact);
169 
171  void getLocalContact(Url& localContact) const;
173  void setLocalContact(const Url& localContact);
174 
176  void getInitialMethod(UtlString& method) const;
178  void setInitialMethod(const char* method);
179 
181  int getNextLocalCseq();
183  int getLastLocalCseq() const;
185  void setLastLocalCseq(int seqNum);
186 
188  int getLastRemoteCseq() const;
190  void setLastRemoteCseq(int seqNum);
191 
193 
197  void getLocalRequestUri(UtlString& requestUri) const;
199  void setLocalRequestUri(const UtlString& requestUri);
201 
208  void getRemoteRequestUri(UtlString& requestUri) const;
210  void setRemoteRequestUri(const UtlString& requestUri);
211 
212  //int getDialogState() const;
213 
215  void toString(UtlString& dialogDumpString);
216 
218  static void getStateString(DialogState state,
219  UtlString& stateString);
220 
221 /* ============================ INQUIRY =================================== */
222 
224 
229  UtlBoolean isSameDialog(const SipMessage& message) const;
230 
232 
234  UtlBoolean isSameDialog(const UtlString& callId,
235  const UtlString& localTag,
236  const UtlString& remoteTag) const;
237 
239 
241  UtlBoolean isSameDialog(const char* dialogHandle);
242 
244  UtlBoolean isEarlyDialog() const;
245 
247 
249  static UtlBoolean isEarlyDialog(const char* dialogHandle);
250 
252  UtlBoolean isEarlyDialogFor(const SipMessage& message) const;
253 
255  UtlBoolean isEarlyDialogFor(const UtlString& callId,
256  const UtlString& localTag,
257  const UtlString& remoteTag) const;
258 
260 
264  UtlBoolean wasEarlyDialogFor(const SipMessage& message) const;
265 
267 
271  UtlBoolean wasEarlyDialogFor(const UtlString& callId,
272  const UtlString& localTag,
273  const UtlString& remoteTag) const;
274 
276 
279  UtlBoolean isTransactionLocallyInitiated(const UtlString& callId,
280  const UtlString& fromTag,
281  const UtlString& toTag) const;
282 
284 
287  UtlBoolean isTransactionRemotelyInitiated(const UtlString& callId,
288  const UtlString& fromTag,
289  const UtlString& toTag) const;
290 
292  UtlBoolean isSameLocalCseq(const SipMessage& message) const;
293 
295  UtlBoolean isSameRemoteCseq(const SipMessage& message) const;
296 
298  UtlBoolean isNextLocalCseq(const SipMessage& message) const;
299 
301  UtlBoolean isNextRemoteCseq(const SipMessage& message) const;
302 
303 /* //////////////////////////// PROTECTED ///////////////////////////////// */
304 protected:
305 
306 /* //////////////////////////// PRIVATE /////////////////////////////////// */
307 private:
309  SipDialog(const SipDialog& rSipDialog);
310 
312  SipDialog& operator=(const SipDialog& rhs);
313 
314  // The callId is stored in the UtlString base class data element
315  Url mLocalField; // To or From depending on who initiated the transaction
316  Url mRemoteField; // To or From depending on who initiated the transaction
317  UtlString mLocalTag;
318  UtlString mRemoteTag;
319  Url mLocalContact;
320  Url mRemoteContact;
321  UtlString mRouteSet;
322  UtlString mInitialMethod;
323  UtlString msLocalRequestUri;
324  UtlString msRemoteRequestUri;
325  UtlBoolean mLocalInitatedDialog;
326  int mInitialLocalCseq;
327  int mInitialRemoteCseq;
328  int mLastLocalCseq;
329  int mLastRemoteCseq;
330  int mDialogState;
331 
332 };
333 
334 /* ============================ INLINE METHODS ============================ */
335 
336 #endif // _SipDialog_h_
void setRemoteField(const Url &remoteUrl)
Set the SIP To/From header value for the remote side of this dialog.
Definition: SipDialog.cpp:509
void getRemoteField(Url &remoteUrl) const
Get the SIP To/From header value for the remote side of this dialog.
Definition: SipDialog.cpp:499
virtual ~SipDialog()
Destructor.
Definition: SipDialog.cpp:151
static void reverseTags(const char *dialogHandle, UtlString &reversedHandle)
Reverse the order of the tags in the handle.
Definition: SipDialog.cpp:460
void getLocalField(Url &localUrl) const
Get the SIP To/From header value for the local side of this dialog.
Definition: SipDialog.cpp:484
UtlBoolean isSameDialog(const SipMessage &message) const
Compare the message to see if it matches this dialog.
Definition: SipDialog.cpp:600
UtlBoolean isEarlyDialog() const
Determine if this is an early dialog.
Definition: SipDialog.cpp:793
UtlBoolean isSameRemoteCseq(const SipMessage &message) const
Check if message and SIP remote Cseq match.
Definition: SipDialog.cpp:841
UtlBoolean isTransactionRemotelyInitiated(const UtlString &callId, const UtlString &fromTag, const UtlString &toTag) const
Query if the transaction request was sent from the remote side.
Definition: SipDialog.cpp:771
void getEarlyHandle(UtlString &earlyDialogHandle) const
Get the early dialog handle for this dialog.
Definition: SipDialog.cpp:409
UtlBoolean isEarlyDialogFor(const SipMessage &message) const
Checks if this is an early dialog for the given SIP message.
Definition: SipDialog.cpp:674
int getNextLocalCseq()
Get the next (incremented) SIP Cseq number for the local side.
Definition: SipDialog.cpp:586
DialogState
Definition: SipDialog.h:66
void setLastRemoteCseq(int seqNum)
Set the last used SIP Cseq number for the remote side.
Definition: SipDialog.cpp:581
void updateDialogData(const SipMessage &message)
update the dialog information based upon the given message
Definition: SipDialog.cpp:189
Specialization of HttpMessage to contain and manipulate SIP messages.
Definition: SipMessage.h:343
SipDialog(const SipMessage *initialMessage=NULL, UtlBoolean isFromLocal=TRUE)
Default Dialog constructor.
Definition: SipDialog.cpp:34
void getRemoteRequestUri(UtlString &requestUri) const
Get the request URI for the remote side.
Definition: SipDialog.cpp:545
void setRemoteRequestUri(const UtlString &requestUri)
Set the request URI for the remote side.
Definition: SipDialog.cpp:550
UtlBoolean wasEarlyDialogFor(const SipMessage &message) const
Checks if this was an early dialog for the given SIP message.
Definition: SipDialog.cpp:719
void setLocalRequestUri(const UtlString &requestUri)
Set the request URI for the local side.
Definition: SipDialog.cpp:540
void getRemoteContact(Url &remoteContact) const
Get the SIP Contact header value for the remote side of this dialog.
Definition: SipDialog.cpp:514
void getHandle(UtlString &dialogHandle) const
Gets a string handle that can be used to uniquely identify this dialog.
Definition: SipDialog.cpp:400
Definition: SipDialog.h:70
void getLocalContact(Url &localContact) const
Get the SIP Contact header value for the local side of this dialog.
Definition: SipDialog.cpp:525
static void parseHandle(const char *dialogHandle, UtlString &callId, UtlString &localTag, UtlString &remoteTag)
Gets the call-id, and tags from the dialogHandle.
Definition: SipDialog.cpp:425
void getRemoteTag(UtlString &remoteTag) const
Get the tag from the SIP To/From header value for the remote side of this dialog. ...
Definition: SipDialog.cpp:504
void setRequestData(SipMessage &request, const char *method)
Set fields in next SIP request for this dialog.
Definition: SipDialog.cpp:335
void setInitialMethod(const char *method)
Set the SIP method of the request that initiated this dialog.
Definition: SipDialog.cpp:561
Definition: SipDialog.h:69
static void getStateString(DialogState state, UtlString &stateString)
Get a string representation for the state value.
Definition: SipDialog.cpp:919
void setLocalContact(const Url &localContact)
Get the SIP Contact header value for the remote side of this dialog.
Definition: SipDialog.cpp:530
Definition: SipDialog.h:68
UtlBoolean isNextRemoteCseq(const SipMessage &message) const
Check if mesage cseq is after the last remote transaction.
Definition: SipDialog.cpp:857
UtlBoolean isTransactionLocallyInitiated(const UtlString &callId, const UtlString &fromTag, const UtlString &toTag) const
Query if the transaction request was sent from the local side.
Definition: SipDialog.cpp:753
UtlBoolean isNextLocalCseq(const SipMessage &message) const
Check if mesage cseq is after the last local transaction.
Definition: SipDialog.cpp:849
void getCallId(UtlString &callId) const
Get the SIP call-id header value for this dialog.
Definition: SipDialog.cpp:473
void setCallId(const char *callId)
Set the SIP call-id header value for this dialog.
Definition: SipDialog.cpp:478
void getInitialMethod(UtlString &method) const
Get the SIP method of the request that initiated this dialog.
Definition: SipDialog.cpp:556
void getLocalRequestUri(UtlString &requestUri) const
Get the request URI for the local side.
Definition: SipDialog.cpp:535
int getLastRemoteCseq() const
Get the last used SIP Cseq number for the remote side.
Definition: SipDialog.cpp:576
Class for containing SIP dialog state information.
Definition: SipDialog.h:61
Definition: SipDialog.h:72
URL parser and constructor.
Definition: Url.h:90
UtlBoolean isSameLocalCseq(const SipMessage &message) const
Check if message and SIP local Cseq match.
Definition: SipDialog.cpp:833
void setLastLocalCseq(int seqNum)
Set the last used SIP Cseq number for the local side.
Definition: SipDialog.cpp:571
void setLocalField(const Url &localUrl)
Set the SIP To/From header value for the local side of this dialog.
Definition: SipDialog.cpp:494
int getLastLocalCseq() const
Get the last used SIP Cseq number for the local side.
Definition: SipDialog.cpp:566
void getLocalTag(UtlString &localTag) const
Get the tag from the SIP To/From header value for the local side of this dialog.
Definition: SipDialog.cpp:489
void toString(UtlString &dialogDumpString)
Debug method to dump the contents of this SipDialog into a string.
Definition: SipDialog.cpp:865
void setRemoteContact(const Url &remoteContact)
Set the SIP Contact header value for the remote side of this dialog.
Definition: SipDialog.cpp:519
Definition: SipDialog.h:71

sipXtackLib home page