/src/resiprocate/resip/stack/RAckCategory.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/RAckCategory.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 | | #define RESIPROCATE_SUBSYSTEM Subsystem::SIP |
17 | | |
18 | | //==================== |
19 | | // RAckCategory: |
20 | | //==================== |
21 | | RAckCategory::RAckCategory(const HeaderFieldValue& hfv, |
22 | | Headers::Type type, |
23 | | PoolBase* pool) |
24 | | : ParserCategory(hfv, type, pool), |
25 | | mMethod(UNKNOWN), |
26 | | mRSequence(0), |
27 | | mCSequence(0) |
28 | 6.23k | {} |
29 | | |
30 | | RAckCategory::RAckCategory() |
31 | | : ParserCategory(), |
32 | | mMethod(UNKNOWN), |
33 | | mUnknownMethodName(getMethodName(UNKNOWN)), |
34 | | mRSequence(0), |
35 | | mCSequence(0) |
36 | 0 | {} |
37 | | |
38 | | RAckCategory::RAckCategory(const RAckCategory& rhs, |
39 | | PoolBase* pool) |
40 | | : ParserCategory(rhs, pool), |
41 | | mMethod(rhs.mMethod), |
42 | | mUnknownMethodName(rhs.mUnknownMethodName), |
43 | | mRSequence(rhs.mRSequence), |
44 | | mCSequence(rhs.mCSequence) |
45 | 0 | {} |
46 | | |
47 | | RAckCategory& |
48 | | RAckCategory::operator=(const RAckCategory& rhs) |
49 | 0 | { |
50 | 0 | if (this != &rhs) |
51 | 0 | { |
52 | 0 | ParserCategory::operator=(rhs); |
53 | 0 | mMethod = rhs.mMethod; |
54 | 0 | mUnknownMethodName = rhs.mUnknownMethodName; |
55 | 0 | mRSequence = rhs.mRSequence; |
56 | 0 | mCSequence = rhs.mCSequence; |
57 | 0 | } |
58 | 0 | return *this; |
59 | 0 | } |
60 | | |
61 | | bool |
62 | | RAckCategory::operator==(const RAckCategory& rhs) const |
63 | 0 | { |
64 | 0 | return (mMethod == rhs.mMethod && |
65 | 0 | (mMethod != UNKNOWN || mUnknownMethodName == rhs.mUnknownMethodName) && |
66 | 0 | mRSequence == rhs.mRSequence && |
67 | 0 | mCSequence == rhs.mCSequence); |
68 | 0 | } |
69 | | |
70 | | ParserCategory* |
71 | | RAckCategory::clone() const |
72 | 0 | { |
73 | 0 | return new RAckCategory(*this); |
74 | 0 | } |
75 | | |
76 | | ParserCategory* |
77 | | RAckCategory::clone(void* location) const |
78 | 0 | { |
79 | 0 | return new (location) RAckCategory(*this); |
80 | 0 | } |
81 | | |
82 | | ParserCategory* |
83 | | RAckCategory::clone(PoolBase* pool) const |
84 | 0 | { |
85 | 0 | return new (pool) RAckCategory(*this, pool); |
86 | 0 | } |
87 | | |
88 | | MethodTypes& |
89 | | RAckCategory::method() |
90 | 0 | { |
91 | 0 | checkParsed(); |
92 | 0 | return mMethod; |
93 | 0 | } |
94 | | |
95 | | MethodTypes |
96 | | RAckCategory::method() const |
97 | 0 | { |
98 | 0 | checkParsed(); return mMethod; |
99 | 0 | } |
100 | | |
101 | | Data& |
102 | | RAckCategory::unknownMethodName() |
103 | 0 | { |
104 | 0 | checkParsed(); |
105 | 0 | return mUnknownMethodName; |
106 | 0 | } |
107 | | |
108 | | const Data& |
109 | | RAckCategory::unknownMethodName() const |
110 | 0 | { |
111 | 0 | checkParsed(); |
112 | 0 | return mUnknownMethodName; |
113 | 0 | } |
114 | | |
115 | | unsigned int& |
116 | | RAckCategory::rSequence() |
117 | 0 | { |
118 | 0 | checkParsed(); |
119 | 0 | return mRSequence; |
120 | 0 | } |
121 | | |
122 | | unsigned int |
123 | | RAckCategory::rSequence() const |
124 | 0 | { |
125 | 0 | checkParsed(); |
126 | 0 | return mRSequence; |
127 | 0 | } |
128 | | |
129 | | unsigned int& |
130 | | RAckCategory::cSequence() |
131 | 0 | { |
132 | 0 | checkParsed(); |
133 | 0 | return mCSequence; |
134 | 0 | } |
135 | | |
136 | | unsigned int |
137 | | RAckCategory::cSequence() const |
138 | 0 | { |
139 | 0 | checkParsed(); |
140 | 0 | return mCSequence; |
141 | 0 | } |
142 | | |
143 | | void |
144 | | RAckCategory::parse(ParseBuffer& pb) |
145 | 6.23k | { |
146 | 6.23k | const char* anchorPtr; |
147 | 6.23k | pb.skipWhitespace(); |
148 | 6.23k | mRSequence = pb.uInt32(); |
149 | | |
150 | 6.23k | pb.skipWhitespace(); |
151 | 6.23k | mCSequence = pb.uInt32(); |
152 | | |
153 | 6.23k | anchorPtr = pb.skipWhitespace(); |
154 | 6.23k | pb.skipNonWhitespace(); |
155 | | |
156 | 6.23k | mMethod = getMethodType(anchorPtr, int(pb.position() - anchorPtr)); |
157 | | // for backward compatibility, set the method name even if the method is known |
158 | 6.23k | pb.data(mUnknownMethodName, anchorPtr); |
159 | 6.23k | } |
160 | | |
161 | | EncodeStream& |
162 | | RAckCategory::encodeParsed(EncodeStream& str) const |
163 | 0 | { |
164 | 0 | str << mRSequence << Symbols::SPACE |
165 | 0 | << mCSequence << Symbols::SPACE |
166 | 0 | << (mMethod != UNKNOWN ? getMethodName(mMethod) : mUnknownMethodName); |
167 | 0 | return str; |
168 | 0 | } |
169 | | |
170 | | /* ==================================================================== |
171 | | * The Vovida Software License, Version 1.0 |
172 | | * |
173 | | * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. |
174 | | * |
175 | | * Redistribution and use in source and binary forms, with or without |
176 | | * modification, are permitted provided that the following conditions |
177 | | * are met: |
178 | | * |
179 | | * 1. Redistributions of source code must retain the above copyright |
180 | | * notice, this list of conditions and the following disclaimer. |
181 | | * |
182 | | * 2. Redistributions in binary form must reproduce the above copyright |
183 | | * notice, this list of conditions and the following disclaimer in |
184 | | * the documentation and/or other materials provided with the |
185 | | * distribution. |
186 | | * |
187 | | * 3. The names "VOCAL", "Vovida Open Communication Application Library", |
188 | | * and "Vovida Open Communication Application Library (VOCAL)" must |
189 | | * not be used to endorse or promote products derived from this |
190 | | * software without prior written permission. For written |
191 | | * permission, please contact vocal@vovida.org. |
192 | | * |
193 | | * 4. Products derived from this software may not be called "VOCAL", nor |
194 | | * may "VOCAL" appear in their name, without prior written |
195 | | * permission of Vovida Networks, Inc. |
196 | | * |
197 | | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
198 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
199 | | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
200 | | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA |
201 | | * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES |
202 | | * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, |
203 | | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
204 | | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
205 | | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
206 | | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
207 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
208 | | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
209 | | * DAMAGE. |
210 | | * |
211 | | * ==================================================================== |
212 | | * |
213 | | * This software consists of voluntary contributions made by Vovida |
214 | | * Networks, Inc. and many individuals on behalf of Vovida Networks, |
215 | | * Inc. For more information on Vovida Networks, Inc., please see |
216 | | * <http://www.vovida.org/>. |
217 | | * |
218 | | */ |