reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
IdentityCategory.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
6#include "rutil/Data.hxx"
7#include "rutil/DnsUtil.hxx"
8#include "rutil/Logger.hxx"
10//#include "rutil/WinLeakCheck.hxx" // not compatible with placement new used below
11
12using namespace resip;
13using namespace std;
14
15#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
16
17
18//====================
19// IdentityCategory
20//===================
25
28 mValue(d)
29{}
30
32 : ParserCategory(hfv, type, pool),
33 mValue()
34{}
35
37 : ParserCategory(rhs, pool),
38 mValue(rhs.mValue)
39{}
40
43{
44 if (this != &rhs)
45 {
47 mValue = rhs.mValue;
48 }
49 return *this;
50}
51
52const Data&
54{
55 checkParsed();
56 return mValue;
57}
58
59Data&
61{
62 checkParsed();
63 return mValue;
64}
65
66void
68{
69 const char* startMark = pb.skipWhitespace();
71 pb.data(mValue, startMark);
74}
75
78{
79 return new IdentityCategory(*this);
80}
81
83IdentityCategory::clone(void* location) const
84{
85 return new (location) IdentityCategory(*this);
86}
87
90{
91 return new (pool) IdentityCategory(*this, pool);
92}
93
95IdentityCategory::encodeParsed(EncodeStream& str) const
96{
97 str << mValue;
99 return str;
100}
101
102ParameterTypes::Factory IdentityCategory::ParameterFactories[ParameterTypes::MAX_PARAMETER]={0};
103
104Parameter*
105IdentityCategory::createParam(ParameterTypes::Type type, ParseBuffer& pb, const std::bitset<256>& terminators, PoolBase* pool)
106{
107 if(type > ParameterTypes::UNKNOWN && type < ParameterTypes::MAX_PARAMETER && ParameterFactories[type])
108 {
109 return ParameterFactories[type](type, pb, terminators, pool);
110 }
111 return 0;
112}
113
114bool
116{
117 checkParsed();
118 bool ret = getParameterByEnum(paramType.getTypeNum()) != NULL;
119 return ret;
120}
121
122void
128
129#define defineParam(_enum, _name, _type, _RFC_ref_ignored) \
130_enum##_Param::DType& \
131IdentityCategory::param(const _enum##_Param& paramType) \
132{ \
133 checkParsed(); \
134 _enum##_Param::Type* p = \
135 static_cast<_enum##_Param::Type*>(getParameterByEnum(paramType.getTypeNum())); \
136 if (!p) \
137 { \
138 p = new _enum##_Param::Type(paramType.getTypeNum()); \
139 mParameters.push_back(p); \
140 } \
141 return p->value(); \
142} \
143 \
144const _enum##_Param::DType& \
145IdentityCategory::param(const _enum##_Param& paramType) const \
146{ \
147 checkParsed(); \
148 _enum##_Param::Type* p = \
149 static_cast<_enum##_Param::Type*>(getParameterByEnum(paramType.getTypeNum())); \
150 if (!p) \
151 { \
152 InfoLog(<< "Missing parameter " _name " " << ParameterTypes::ParameterNames[paramType.getTypeNum()]); \
153 DebugLog(<< *this); \
154 throw Exception("Missing parameter " _name, __FILE__, __LINE__); \
155 } \
156 return p->value(); \
157}
158
159defineParam(info, "info", UriParameter, "RFC 8224");
160
161#undef defineParam
162
163/* ====================================================================
164 * The Vovida Software License, Version 1.0
165 *
166 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
167 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
168 *
169 * Redistribution and use in source and binary forms, with or without
170 * modification, are permitted provided that the following conditions
171 * are met:
172 *
173 * 1. Redistributions of source code must retain the above copyright
174 * notice, this list of conditions and the following disclaimer.
175 *
176 * 2. Redistributions in binary form must reproduce the above copyright
177 * notice, this list of conditions and the following disclaimer in
178 * the documentation and/or other materials provided with the
179 * distribution.
180 *
181 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
182 * and "Vovida Open Communication Application Library (VOCAL)" must
183 * not be used to endorse or promote products derived from this
184 * software without prior written permission. For written
185 * permission, please contact vocal@vovida.org.
186 *
187 * 4. Products derived from this software may not be called "VOCAL", nor
188 * may "VOCAL" appear in their name, without prior written
189 * permission of Vovida Networks, Inc.
190 *
191 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
192 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
193 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
194 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
195 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
196 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
197 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
198 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
199 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
200 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
201 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
202 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
203 * DAMAGE.
204 *
205 * ====================================================================
206 *
207 * This software consists of voluntary contributions made by Vovida
208 * Networks, Inc. and many individuals on behalf of Vovida Networks,
209 * Inc. For more information on Vovida Networks, Inc., please see
210 * <http://www.vovida.org/>.
211 *
212 */
#define defineParam(_enum, _name, _type, _RFC_ref_ignored)
Definition Auth.cxx:239
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Represents an Identity header from RFC8824.
IdentityCategory & operator=(const IdentityCategory &)
const Data & value() const
Gets the value (ie; no parameters) of this IdentityCategory as a Data&.
bool exists(const Param< IdentityCategory > &paramType) const
virtual Parameter * createParam(ParameterTypes::Type type, ParseBuffer &pb, const std::bitset< 256 > &terminators, PoolBase *pool)
virtual void parse(ParseBuffer &pb)
virtual EncodeStream & encodeParsed(EncodeStream &str) const
void remove(const Param< IdentityCategory > &paramType)
virtual ParserCategory * clone() const
void checkParsed() const
virtual ParameterTypes::Type getTypeNum() const =0
Parameter *(* Factory)(ParameterTypes::Type, ParseBuffer &, const std::bitset< 256 > &terminators, PoolBase *pool)
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipWhitespace()
CurrentPosition skipToChar(char c)
CurrentPosition skipToOneOf(const char *cs)
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
static const char * Whitespace
Base class for all SIP grammar elements that can have parameters.
Parameter * getParameterByEnum(ParameterTypes::Type type) const
ParserCategory & operator=(const ParserCategory &rhs)
void removeParameterByEnum(ParameterTypes::Type type)
void parseParameters(ParseBuffer &pb)
EncodeStream & encodeParameters(EncodeStream &str) const
Encodes parameters as they should appear on the wire.
static const char * SEMI_COLON
Definition Symbols.hxx:30
Represents a URI enclosed in angle brackets, used in Identity headers for RFC8224.
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream