/src/resiprocate/resip/stack/IdentityCategory.cxx
Line | Count | Source |
1 | | #if defined(HAVE_CONFIG_H) |
2 | | #include "config.h" |
3 | | #endif |
4 | | |
5 | | #include "resip/stack/IdentityCategory.hxx" |
6 | | #include "rutil/Data.hxx" |
7 | | #include "rutil/DnsUtil.hxx" |
8 | | #include "rutil/Logger.hxx" |
9 | | #include "rutil/ParseBuffer.hxx" |
10 | | //#include "rutil/WinLeakCheck.hxx" // not compatible with placement new used below |
11 | | |
12 | | using namespace resip; |
13 | | using namespace std; |
14 | | |
15 | | #define RESIPROCATE_SUBSYSTEM Subsystem::SIP |
16 | | |
17 | | |
18 | | //==================== |
19 | | // IdentityCategory |
20 | | //=================== |
21 | | IdentityCategory::IdentityCategory() |
22 | 0 | : ParserCategory(), |
23 | 0 | mValue() |
24 | 0 | {} |
25 | | |
26 | | IdentityCategory::IdentityCategory(const Data& d) |
27 | 0 | : ParserCategory(), |
28 | 0 | mValue(d) |
29 | 0 | {} |
30 | | |
31 | | IdentityCategory::IdentityCategory(const HeaderFieldValue& hfv, Headers::Type type, PoolBase* pool) |
32 | 0 | : ParserCategory(hfv, type, pool), |
33 | 0 | mValue() |
34 | 0 | {} |
35 | | |
36 | | IdentityCategory::IdentityCategory(const IdentityCategory& rhs, PoolBase* pool) |
37 | 0 | : ParserCategory(rhs, pool), |
38 | 0 | mValue(rhs.mValue) |
39 | 0 | {} |
40 | | |
41 | | IdentityCategory& |
42 | | IdentityCategory::operator=(const IdentityCategory& rhs) |
43 | 0 | { |
44 | 0 | if (this != &rhs) |
45 | 0 | { |
46 | 0 | ParserCategory::operator=(rhs); |
47 | 0 | mValue = rhs.mValue; |
48 | 0 | } |
49 | 0 | return *this; |
50 | 0 | } |
51 | | |
52 | | const Data& |
53 | | IdentityCategory::value() const |
54 | 0 | { |
55 | 0 | checkParsed(); |
56 | 0 | return mValue; |
57 | 0 | } |
58 | | |
59 | | Data& |
60 | | IdentityCategory::value() |
61 | 0 | { |
62 | 0 | checkParsed(); |
63 | 0 | return mValue; |
64 | 0 | } |
65 | | |
66 | | void |
67 | | IdentityCategory::parse(ParseBuffer& pb) |
68 | 0 | { |
69 | 0 | const char* startMark = pb.skipWhitespace(); |
70 | 0 | pb.skipToOneOf(ParseBuffer::Whitespace, Symbols::SEMI_COLON); |
71 | 0 | pb.data(mValue, startMark); |
72 | 0 | pb.skipToChar(Symbols::SEMI_COLON[0]); |
73 | 0 | parseParameters(pb); |
74 | 0 | } |
75 | | |
76 | | ParserCategory* |
77 | | IdentityCategory::clone() const |
78 | 0 | { |
79 | 0 | return new IdentityCategory(*this); |
80 | 0 | } |
81 | | |
82 | | ParserCategory* |
83 | | IdentityCategory::clone(void* location) const |
84 | 0 | { |
85 | 0 | return new (location) IdentityCategory(*this); |
86 | 0 | } |
87 | | |
88 | | ParserCategory* |
89 | | IdentityCategory::clone(PoolBase* pool) const |
90 | 0 | { |
91 | 0 | return new (pool) IdentityCategory(*this, pool); |
92 | 0 | } |
93 | | |
94 | | EncodeStream& |
95 | | IdentityCategory::encodeParsed(EncodeStream& str) const |
96 | 0 | { |
97 | 0 | str << mValue; |
98 | 0 | encodeParameters(str); |
99 | 0 | return str; |
100 | 0 | } |
101 | | |
102 | | ParameterTypes::Factory IdentityCategory::ParameterFactories[ParameterTypes::MAX_PARAMETER]={0}; |
103 | | |
104 | | Parameter* |
105 | | IdentityCategory::createParam(ParameterTypes::Type type, ParseBuffer& pb, const std::bitset<256>& terminators, PoolBase* pool) |
106 | 0 | { |
107 | 0 | if(type > ParameterTypes::UNKNOWN && type < ParameterTypes::MAX_PARAMETER && ParameterFactories[type]) |
108 | 0 | { |
109 | 0 | return ParameterFactories[type](type, pb, terminators, pool); |
110 | 0 | } |
111 | 0 | return 0; |
112 | 0 | } |
113 | | |
114 | | bool |
115 | | IdentityCategory::exists(const Param<IdentityCategory>& paramType) const |
116 | 0 | { |
117 | 0 | checkParsed(); |
118 | 0 | bool ret = getParameterByEnum(paramType.getTypeNum()) != NULL; |
119 | 0 | return ret; |
120 | 0 | } |
121 | | |
122 | | void |
123 | | IdentityCategory::remove(const Param<IdentityCategory>& paramType) |
124 | 0 | { |
125 | 0 | checkParsed(); |
126 | 0 | removeParameterByEnum(paramType.getTypeNum()); |
127 | 0 | } |
128 | | |
129 | | #define defineParam(_enum, _name, _type, _RFC_ref_ignored) \ |
130 | | _enum##_Param::DType& \ |
131 | 0 | IdentityCategory::param(const _enum##_Param& paramType) \ |
132 | 0 | { \ |
133 | 0 | checkParsed(); \ |
134 | 0 | _enum##_Param::Type* p = \ |
135 | 0 | static_cast<_enum##_Param::Type*>(getParameterByEnum(paramType.getTypeNum())); \ |
136 | 0 | if (!p) \ |
137 | 0 | { \ |
138 | 0 | p = new _enum##_Param::Type(paramType.getTypeNum()); \ |
139 | 0 | mParameters.push_back(p); \ |
140 | 0 | } \ |
141 | 0 | return p->value(); \ |
142 | 0 | } \ |
143 | | \ |
144 | | const _enum##_Param::DType& \ |
145 | 0 | IdentityCategory::param(const _enum##_Param& paramType) const \ |
146 | 0 | { \ |
147 | 0 | checkParsed(); \ |
148 | 0 | _enum##_Param::Type* p = \ |
149 | 0 | static_cast<_enum##_Param::Type*>(getParameterByEnum(paramType.getTypeNum())); \ |
150 | 0 | if (!p) \ |
151 | 0 | { \ |
152 | 0 | InfoLog(<< "Missing parameter " _name " " << ParameterTypes::ParameterNames[paramType.getTypeNum()]); \ |
153 | 0 | DebugLog(<< *this); \ |
154 | 0 | throw Exception("Missing parameter " _name, __FILE__, __LINE__); \ |
155 | 0 | } \ |
156 | 0 | return p->value(); \ |
157 | 0 | } |
158 | | |
159 | | defineParam(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 | | */ |