reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
RAckCategory.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
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
13using namespace resip;
14using namespace std;
15
16#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
17
18//====================
19// RAckCategory:
20//====================
22 Headers::Type type,
23 PoolBase* pool)
24 : ParserCategory(hfv, type, pool),
25 mMethod(UNKNOWN),
26 mRSequence(0),
27 mCSequence(0)
28{}
29
31 : ParserCategory(),
32 mMethod(UNKNOWN),
33 mUnknownMethodName(getMethodName(UNKNOWN)),
34 mRSequence(0),
35 mCSequence(0)
36{}
37
39 PoolBase* pool)
40 : ParserCategory(rhs, pool),
41 mMethod(rhs.mMethod),
42 mUnknownMethodName(rhs.mUnknownMethodName),
43 mRSequence(rhs.mRSequence),
44 mCSequence(rhs.mCSequence)
45{}
46
49{
50 if (this != &rhs)
51 {
53 mMethod = rhs.mMethod;
54 mUnknownMethodName = rhs.mUnknownMethodName;
55 mRSequence = rhs.mRSequence;
56 mCSequence = rhs.mCSequence;
57 }
58 return *this;
59}
60
61bool
63{
64 return (mMethod == rhs.mMethod &&
65 (mMethod != UNKNOWN || mUnknownMethodName == rhs.mUnknownMethodName) &&
66 mRSequence == rhs.mRSequence &&
67 mCSequence == rhs.mCSequence);
68}
69
72{
73 return new RAckCategory(*this);
74}
75
77RAckCategory::clone(void* location) const
78{
79 return new (location) RAckCategory(*this);
80}
81
84{
85 return new (pool) RAckCategory(*this, pool);
86}
87
90{
91 checkParsed();
92 return mMethod;
93}
94
97{
98 checkParsed(); return mMethod;
99}
100
101Data&
103{
104 checkParsed();
105 return mUnknownMethodName;
106}
107
108const Data&
110{
111 checkParsed();
112 return mUnknownMethodName;
113}
114
115unsigned int&
117{
118 checkParsed();
119 return mRSequence;
120}
121
122unsigned int
124{
125 checkParsed();
126 return mRSequence;
127}
128
129unsigned int&
131{
132 checkParsed();
133 return mCSequence;
134}
135
136unsigned int
138{
139 checkParsed();
140 return mCSequence;
141}
142
143void
145{
146 const char* anchorPtr;
147 pb.skipWhitespace();
148 mRSequence = pb.uInt32();
149
150 pb.skipWhitespace();
151 mCSequence = pb.uInt32();
152
153 anchorPtr = pb.skipWhitespace();
155
156 mMethod = getMethodType(anchorPtr, int(pb.position() - anchorPtr));
157 // for backward compatibility, set the method name even if the method is known
158 pb.data(mUnknownMethodName, anchorPtr);
159}
160
162RAckCategory::encodeParsed(EncodeStream& str) const
163{
164 str << mRSequence << Symbols::SPACE
165 << mCSequence << Symbols::SPACE
166 << (mMethod != UNKNOWN ? getMethodName(mMethod) : mUnknownMethodName);
167 return str;
168}
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 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
void checkParsed() const
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipNonWhitespace()
uint32_t uInt32()
dcm! – merge these, ask about length checks
CurrentPosition skipWhitespace()
CurrentPosition position() const
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
Base class for all SIP grammar elements that can have parameters.
ParserCategory & operator=(const ParserCategory &rhs)
Represents the RAck header field value defined in the RFC 3262 grammar.
unsigned int & rSequence()
virtual ParserCategory * clone() const
bool operator==(const RAckCategory &rhs) const
virtual void parse(ParseBuffer &pb)
unsigned int & cSequence()
RAckCategory & operator=(const RAckCategory &)
virtual EncodeStream & encodeParsed(EncodeStream &str) const
MethodTypes & method()
static const char * SPACE
Definition Symbols.hxx:34
dcm! – add UnusedChecking(_enum) below;
const Data & getMethodName(MethodTypes t)
MethodTypes getMethodType(const Data &name)
#define EncodeStream