Coverage Report

Created: 2024-07-23 06:39

/src/resiprocate/resip/stack/CallId.cxx
Line
Count
Source (jump to first uncovered line)
1
#if defined(HAVE_CONFIG_H)
2
#include "config.h"
3
#endif
4
5
#include "resip/stack/CallId.hxx"
6
#include "resip/stack/UnknownParameter.hxx"
7
#include "rutil/Data.hxx"
8
#include "rutil/DnsUtil.hxx"
9
#include "rutil/Logger.hxx"
10
#include "rutil/ParseBuffer.hxx"
11
//#include "rutil/WinLeakCheck.hxx"  // not compatible with placement new used below
12
13
using namespace resip;
14
using namespace std;
15
16
17
#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
18
19
//====================
20
// CallID:
21
//====================
22
CallID::CallID()
23
   : ParserCategory(), 
24
     mValue() 
25
0
{}
26
27
CallID::CallID(const HeaderFieldValue& hfv, 
28
               Headers::Type type,
29
               PoolBase* pool) 
30
   : ParserCategory(hfv, type, pool), mValue()
31
6.46k
{}
32
33
CallID::CallID(const CallID& rhs,
34
               PoolBase* pool)
35
   : ParserCategory(rhs, pool),
36
     mValue(rhs.mValue)
37
0
{}
38
39
CallID&
40
CallID::operator=(const CallID& rhs)
41
0
{
42
0
   if (this != &rhs)
43
0
   {
44
0
      ParserCategory::operator=(rhs);
45
0
      mValue = rhs.mValue;
46
0
   }
47
0
   return *this;
48
0
}
49
50
bool
51
CallID::operator==(const CallID& rhs) const
52
0
{
53
0
   return value() == rhs.value();
54
0
}
55
56
ParserCategory *
57
CallID::clone() const
58
0
{
59
0
   return new CallID(*this);
60
0
}
61
62
ParserCategory *
63
CallID::clone(void* location) const
64
0
{
65
0
   return new (location) CallID(*this);
66
0
}
67
68
ParserCategory* 
69
CallID::clone(PoolBase* pool) const
70
0
{
71
0
   return new (pool) CallID(*this, pool);
72
0
}
73
74
Data& 
75
CallID::value() 
76
0
{
77
0
   checkParsed(); 
78
0
   return mValue;
79
0
}
80
81
const Data& 
82
CallID::value() const 
83
0
{
84
0
   checkParsed(); 
85
0
   return mValue;
86
0
}
87
88
void
89
CallID::parse(ParseBuffer& pb)
90
6.46k
{
91
6.46k
   const char* start = pb.skipWhitespace();
92
6.46k
   pb.assertNotEof();
93
6.46k
   static const std::bitset<256> wsOrSemi(Data::toBitset(ParseBuffer::Whitespace).set(Symbols::SEMI_COLON[0]));
94
6.46k
   pb.skipToOneOf(wsOrSemi);
95
6.46k
   pb.data(mValue, start);
96
97
6.46k
   parseParameters(pb);
98
6.46k
}
99
100
EncodeStream&
101
CallID::encodeParsed(EncodeStream& str) const
102
0
{
103
0
   str << mValue;
104
0
   encodeParameters(str);
105
0
   return str;
106
0
}
107
108
ParameterTypes::Factory CallID::ParameterFactories[ParameterTypes::MAX_PARAMETER]={0};
109
110
Parameter* 
111
CallID::createParam(ParameterTypes::Type type, ParseBuffer& pb, const std::bitset<256>& terminators, PoolBase* pool)
112
256k
{
113
256k
   if(type > ParameterTypes::UNKNOWN && type < ParameterTypes::MAX_PARAMETER && ParameterFactories[type])
114
0
   {
115
0
      return ParameterFactories[type](type, pb, terminators, pool);
116
0
   }
117
256k
   return 0;
118
256k
}
119
120
bool 
121
CallID::exists(const Param<CallID>& paramType) const
122
0
{
123
0
    checkParsed();
124
0
    bool ret = getParameterByEnum(paramType.getTypeNum()) != NULL;
125
0
    return ret;
126
0
}
127
128
void 
129
CallID::remove(const Param<CallID>& paramType)
130
0
{
131
0
    checkParsed();
132
0
    removeParameterByEnum(paramType.getTypeNum());
133
0
}
134
135
#define defineParam(_enum, _name, _type, _RFC_ref_ignored)                                                      \
136
_enum##_Param::DType&                                                                                           \
137
0
CallID::param(const _enum##_Param& paramType)                                                           \
138
0
{                                                                                                               \
139
0
   checkParsed();                                                                                               \
140
0
   _enum##_Param::Type* p =                                                                                     \
141
0
      static_cast<_enum##_Param::Type*>(getParameterByEnum(paramType.getTypeNum()));                            \
142
0
   if (!p)                                                                                                      \
143
0
   {                                                                                                            \
144
0
      p = new _enum##_Param::Type(paramType.getTypeNum());                                                      \
145
0
      mParameters.push_back(p);                                                                                 \
146
0
   }                                                                                                            \
147
0
   return p->value();                                                                                           \
148
0
}                                                                                                               \
Unexecuted instantiation: resip::CallID::param(resip::fromTag_Param const&)
Unexecuted instantiation: resip::CallID::param(resip::toTag_Param const&)
Unexecuted instantiation: resip::CallID::param(resip::earlyOnly_Param const&)
149
                                                                                                                \
150
const _enum##_Param::DType&                                                                                     \
151
0
CallID::param(const _enum##_Param& paramType) const                                                     \
152
0
{                                                                                                               \
153
0
   checkParsed();                                                                                               \
154
0
   _enum##_Param::Type* p =                                                                                     \
155
0
      static_cast<_enum##_Param::Type*>(getParameterByEnum(paramType.getTypeNum()));                            \
156
0
   if (!p)                                                                                                      \
157
0
   {                                                                                                            \
158
0
      InfoLog(<< "Missing parameter " _name " " << ParameterTypes::ParameterNames[paramType.getTypeNum()]);     \
159
0
      DebugLog(<< *this);                                                                                       \
160
0
      throw Exception("Missing parameter " _name, __FILE__, __LINE__);                                          \
161
0
   }                                                                                                            \
162
0
   return p->value();                                                                                           \
163
0
}
Unexecuted instantiation: resip::CallID::param(resip::fromTag_Param const&) const
Unexecuted instantiation: resip::CallID::param(resip::toTag_Param const&) const
Unexecuted instantiation: resip::CallID::param(resip::earlyOnly_Param const&) const
164
165
defineParam(fromTag, "from-tag", DataParameter, "RFC 3891 (not in IANA, apparently)");
166
defineParam(toTag, "to-tag", DataParameter, "RFC 3891 (not in IANA, apparently)");
167
defineParam(earlyOnly, "early-only", ExistsParameter, "RFC 3891 (not in IANA, apparently)");
168
169
#undef defineParam
170
171
172
/* ====================================================================
173
 * The Vovida Software License, Version 1.0 
174
 * 
175
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
176
 * 
177
 * Redistribution and use in source and binary forms, with or without
178
 * modification, are permitted provided that the following conditions
179
 * are met:
180
 * 
181
 * 1. Redistributions of source code must retain the above copyright
182
 *    notice, this list of conditions and the following disclaimer.
183
 * 
184
 * 2. Redistributions in binary form must reproduce the above copyright
185
 *    notice, this list of conditions and the following disclaimer in
186
 *    the documentation and/or other materials provided with the
187
 *    distribution.
188
 * 
189
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
190
 *    and "Vovida Open Communication Application Library (VOCAL)" must
191
 *    not be used to endorse or promote products derived from this
192
 *    software without prior written permission. For written
193
 *    permission, please contact vocal@vovida.org.
194
 *
195
 * 4. Products derived from this software may not be called "VOCAL", nor
196
 *    may "VOCAL" appear in their name, without prior written
197
 *    permission of Vovida Networks, Inc.
198
 * 
199
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
200
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
201
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
202
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
203
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
204
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
205
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
206
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
207
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
208
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
209
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
210
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
211
 * DAMAGE.
212
 * 
213
 * ====================================================================
214
 * 
215
 * This software consists of voluntary contributions made by Vovida
216
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
217
 * Inc.  For more information on Vovida Networks, Inc., please see
218
 * <http://www.vovida.org/>.
219
 *
220
 */