reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
DialogSetId.cxx
Go to the documentation of this file.
1#include "DialogSetId.hxx"
4#include "rutil/Logger.hxx"
5
6#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
7
8using namespace resip;
9
11
12DialogSetId::DialogSetId(const SipMessage& msg) :
13 mCallId(msg.header(h_CallID).value())
14{
15 //find local tag, generate one as necessary
16 if (msg.isExternal())
17 {
18 if(msg.isResponse())
19 {
20 if(msg.header(h_From).exists(p_tag))
21 {
22 // .bwc. If no tag, leave mTag empty.
23 mTag = msg.header(h_From).param(p_tag);
24 }
25 }
26 else //external request; generate to tag if not present
27 {
28 if (msg.header(h_To).exists(p_tag))
29 {
30 mTag = msg.header(h_To).param(p_tag);
31 }
32 else
33 {
34 //DebugLog ( << "********** Generated Local Tag *********** " );
36 }
37 }
38 }
39 else
40 {
41 if(msg.isRequest())
42 {
43 resip_assert(msg.header(h_From).exists(p_tag));
44 mTag = msg.header(h_From).param(p_tag);
45 }
46 else
47 {
48 resip_assert(msg.header(h_To).exists(p_tag));
49 mTag = msg.header(h_To).param(p_tag);
50 }
51 }
52}
53
54DialogSetId::DialogSetId(const Data& callId, const Data& tag)
55 : mCallId(callId),
56 mTag(tag)
57{
58}
59
60DialogSetId::DialogSetId()
61 : mCallId(),
62 mTag()
63{
64}
65
66bool
68{
69 return mCallId == rhs.mCallId && mTag == rhs.mTag;
70}
71
72bool
74{
75 return mCallId != rhs.mCallId || mTag != rhs.mTag;
76}
77
78bool
79DialogSetId::operator<(const DialogSetId& rhs) const
80{
81 if (mCallId < rhs.mCallId)
82 {
83 return true;
84 }
85 if (mCallId > rhs.mCallId)
86 {
87 return false;
88 }
89 return mTag < rhs.mTag;
90}
91
92bool
94{
95 if (mCallId > rhs.mCallId)
96 {
97 return true;
98 }
99 if (mCallId < rhs.mCallId)
100 {
101 return false;
102 }
103 return mTag > rhs.mTag;
104}
105
106size_t DialogSetId::hash() const
107{
108 // Call-IDs and tags are chosen by remote peers. With fixed hashes a sender
109 // could make every dialog set collide in DUM's DialogSetMap, so that each
110 // new request scans all of them; keyed hashes prevent that (see
111 // KeyedDataHash). hashCombine rather than XOR, which would cancel out
112 // when Call-ID == tag.
113 return hashCombine(mCallId.keyedHash(), mTag.keyedHash());
114}
115
116
118resip::operator<<(EncodeStream& os, const DialogSetId& id)
119{
120 return os << id.mCallId << '-' << id.mTag ;
121}
122
124
125/* ====================================================================
126 * The Vovida Software License, Version 1.0
127 *
128 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
129 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
130 *
131 * Redistribution and use in source and binary forms, with or without
132 * modification, are permitted provided that the following conditions
133 * are met:
134 *
135 * 1. Redistributions of source code must retain the above copyright
136 * notice, this list of conditions and the following disclaimer.
137 *
138 * 2. Redistributions in binary form must reproduce the above copyright
139 * notice, this list of conditions and the following disclaimer in
140 * the documentation and/or other materials provided with the
141 * distribution.
142 *
143 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
144 * and "Vovida Open Communication Application Library (VOCAL)" must
145 * not be used to endorse or promote products derived from this
146 * software without prior written permission. For written
147 * permission, please contact vocal@vovida.org.
148 *
149 * 4. Products derived from this software may not be called "VOCAL", nor
150 * may "VOCAL" appear in their name, without prior written
151 * permission of Vovida Networks, Inc.
152 *
153 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
154 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
155 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
156 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
157 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
158 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
159 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
160 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
161 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
162 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
163 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
164 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
165 * DAMAGE.
166 *
167 * ====================================================================
168 *
169 * This software consists of voluntary contributions made by Vovida
170 * Networks, Inc. and many individuals on behalf of Vovida Networks,
171 * Inc. For more information on Vovida Networks, Inc., please see
172 * <http://www.vovida.org/>.
173 *
174 */
#define HashValueImp(type, ret)
Definition HashMap.hxx:24
#define resip_assert(x)
This file needs to work for both C and C++ code.
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 DialogSetId &rhs) const
bool operator!=(const DialogSetId &rhs) const
size_t hash() const
bool operator<(const DialogSetId &rhs) const
bool operator>(const DialogSetId &rhs) const
static const DialogSetId Empty
static const int tagSize
bytes in to-tag& from-tag, should prob. live somewhere else
Definition Helper.hxx:42
static Data computeTag(int numBytes)
Definition Helper.cxx:713
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