/[resiprocate]/branches/b-directory-reorg/sip/resiprocate/RAckCategory.cxx
ViewVC logotype

Contents of /branches/b-directory-reorg/sip/resiprocate/RAckCategory.cxx

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27