reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
DialogId.cxx
Go to the documentation of this file.
1#include "DialogId.hxx"
3#include "rutil/Logger.hxx"
4
5#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
6
7using namespace resip;
8
10 mDialogSetId(msg),
11 mRemoteTag(Data::Empty)
12{
13 //find remote tag, which may not exist
14 if (msg.isExternal())
15 {
16 if(msg.isResponse())
17 {
18 if (msg.header(h_To).exists(p_tag))
19 {
20 mRemoteTag = msg.header(h_To).param(p_tag);
21 }
22 }
23 else
24 {
25 if (msg.header(h_From).exists(p_tag))
26 {
27 mRemoteTag = msg.header(h_From).param(p_tag);
28 }
29 }
30 }
31 else
32 {
33 if(msg.isRequest())
34 {
35 //?dcm? -- is this just for 2543? At this point, we will have to have
36 //established a dialog(or else we would just have a dialogset)
37 if (msg.header(h_To).exists(p_tag))
38 {
39 mRemoteTag = msg.header(h_To).param(p_tag);
40 }
41 }
42 else
43 {
44 if (msg.header(h_From).exists(p_tag))
45 {
46 mRemoteTag = msg.header(h_From).param(p_tag);
47 }
48 }
49 }
50 DebugLog ( << "DialogId::DialogId: " << *this);
51}
52
53DialogId::DialogId(const Data& callId, const Data& localTag, const Data& remoteTag) :
54 mDialogSetId(callId, localTag),
55 mRemoteTag(remoteTag)
56{
57}
58
59DialogId::DialogId(const DialogSetId& id, const Data& remoteTag) :
60 mDialogSetId(id),
61 mRemoteTag(remoteTag)
62{
63 DebugLog ( << "DialogId::DialogId: " << *this);
64}
65
66bool
68{
69 return mDialogSetId == rhs.mDialogSetId && mRemoteTag == rhs.mRemoteTag;
70}
71
72bool
74{
75 return mDialogSetId != rhs.mDialogSetId || mRemoteTag != rhs.mRemoteTag;
76}
77
78bool
79DialogId::operator<(const DialogId& rhs) const
80{
81 if (mDialogSetId < rhs.mDialogSetId)
82 {
83 return true;
84 }
85 if (mDialogSetId > rhs.mDialogSetId)
86 {
87 return false;
88 }
89 return mRemoteTag < rhs.mRemoteTag;
90}
91
92const DialogSetId&
94{
95 return mDialogSetId;
96}
97
98const Data&
100{
101 return getDialogSetId().getCallId();
102}
103
104const Data&
106{
107 return getDialogSetId().getLocalTag();
108}
109
110const Data&
112{
113 return mRemoteTag;
114}
115
116
118resip::operator<<(EncodeStream& os, const DialogId& id)
119{
120 return os << id.mDialogSetId << "-" << id.mRemoteTag;
121}
122
123
124size_t DialogId::hash() const
125{
126 // Keyed and combined like DialogSetId::hash(), for the same reason: tags are
127 // chosen by remote peers (see KeyedDataHash)
128 return hashCombine(mDialogSetId.hash(), mRemoteTag.keyedHash());
129}
130
132
133/* ====================================================================
134 * The Vovida Software License, Version 1.0
135 *
136 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
137 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
138 *
139 * Redistribution and use in source and binary forms, with or without
140 * modification, are permitted provided that the following conditions
141 * are met:
142 *
143 * 1. Redistributions of source code must retain the above copyright
144 * notice, this list of conditions and the following disclaimer.
145 *
146 * 2. Redistributions in binary form must reproduce the above copyright
147 * notice, this list of conditions and the following disclaimer in
148 * the documentation and/or other materials provided with the
149 * distribution.
150 *
151 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
152 * and "Vovida Open Communication Application Library (VOCAL)" must
153 * not be used to endorse or promote products derived from this
154 * software without prior written permission. For written
155 * permission, please contact vocal@vovida.org.
156 *
157 * 4. Products derived from this software may not be called "VOCAL", nor
158 * may "VOCAL" appear in their name, without prior written
159 * permission of Vovida Networks, Inc.
160 *
161 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
162 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
163 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
164 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
165 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
166 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
167 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
168 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
169 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
170 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
171 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
172 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
173 * DAMAGE.
174 *
175 * ====================================================================
176 *
177 * This software consists of voluntary contributions made by Vovida
178 * Networks, Inc. and many individuals on behalf of Vovida Networks,
179 * Inc. For more information on Vovida Networks, Inc., please see
180 * <http://www.vovida.org/>.
181 *
182 */
#define HashValueImp(type, ret)
Definition HashMap.hxx:24
#define DebugLog(args_)
Definition Logger.hxx:128
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
size_t keyedHash() const
Creates a keyed hash based on the contents of this Data.
Definition Data.cxx:2373
bool operator<(const DialogId &rhs) const
Definition DialogId.cxx:79
const Data & getLocalTag() const
Definition DialogId.cxx:105
bool operator!=(const DialogId &rhs) const
Definition DialogId.cxx:73
DialogId(const SipMessage &msg)
Definition DialogId.cxx:9
bool operator==(const DialogId &rhs) const
Definition DialogId.cxx:67
const Data & getRemoteTag() const
Definition DialogId.cxx:111
const DialogSetId & getDialogSetId() const
Definition DialogId.cxx:93
size_t hash() const
Definition DialogId.cxx:124
const Data & getCallId() const
Definition DialogId.cxx:99
const Data & getCallId() const
const Data & getLocalTag() const
size_t hash() const
Represents a SIP message.
bool isRequest() const
Returns true if message is a request, false otherwise.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
bool isResponse() const
Returns true if message is a response, false otherwise.
bool isExternal() const
Check if SipMessage is to be treated as it came off the wire.
dcm! – add UnusedChecking(_enum) below;
size_t hashCombine(size_t seed, size_t hash)
Combines the hashes of the parts of a composite key, eg.
Definition Data.hxx:1296
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
#define EncodeStream