|
reSIProcate/stack
9694
|
00001 #if defined(HAVE_CONFIG_H) 00002 #include "config.h" 00003 #endif 00004 00005 #include "resip/stack/RAckCategory.hxx" 00006 #include "resip/stack/UnknownParameter.hxx" 00007 #include "rutil/Data.hxx" 00008 #include "rutil/DnsUtil.hxx" 00009 #include "rutil/Logger.hxx" 00010 #include "rutil/ParseBuffer.hxx" 00011 //#include "rutil/WinLeakCheck.hxx" // not compatible with placement new used below 00012 00013 using namespace resip; 00014 using namespace std; 00015 00016 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP 00017 00018 //==================== 00019 // RAckCategory: 00020 //==================== 00021 RAckCategory::RAckCategory(const HeaderFieldValue& hfv, 00022 Headers::Type type, 00023 PoolBase* pool) 00024 : ParserCategory(hfv, type, pool), 00025 mMethod(UNKNOWN), 00026 mRSequence(0), 00027 mCSequence(0) 00028 {} 00029 00030 RAckCategory::RAckCategory() 00031 : ParserCategory(), 00032 mMethod(UNKNOWN), 00033 mUnknownMethodName(getMethodName(UNKNOWN)), 00034 mRSequence(0), 00035 mCSequence(0) 00036 {} 00037 00038 RAckCategory::RAckCategory(const RAckCategory& rhs, 00039 PoolBase* pool) 00040 : ParserCategory(rhs, pool), 00041 mMethod(rhs.mMethod), 00042 mUnknownMethodName(rhs.mUnknownMethodName), 00043 mRSequence(rhs.mRSequence), 00044 mCSequence(rhs.mCSequence) 00045 {} 00046 00047 RAckCategory& 00048 RAckCategory::operator=(const RAckCategory& rhs) 00049 { 00050 if (this != &rhs) 00051 { 00052 ParserCategory::operator=(rhs); 00053 mMethod = rhs.mMethod; 00054 mUnknownMethodName = rhs.mUnknownMethodName; 00055 mRSequence = rhs.mRSequence; 00056 mCSequence = rhs.mCSequence; 00057 } 00058 return *this; 00059 } 00060 00061 bool 00062 RAckCategory::operator==(const RAckCategory& rhs) const 00063 { 00064 return (mMethod == rhs.mMethod && 00065 (mMethod != UNKNOWN || mUnknownMethodName == rhs.mUnknownMethodName) && 00066 mRSequence == rhs.mRSequence && 00067 mCSequence == rhs.mCSequence); 00068 } 00069 00070 ParserCategory* 00071 RAckCategory::clone() const 00072 { 00073 return new RAckCategory(*this); 00074 } 00075 00076 ParserCategory* 00077 RAckCategory::clone(void* location) const 00078 { 00079 return new (location) RAckCategory(*this); 00080 } 00081 00082 ParserCategory* 00083 RAckCategory::clone(PoolBase* pool) const 00084 { 00085 return new (pool) RAckCategory(*this, pool); 00086 } 00087 00088 MethodTypes& 00089 RAckCategory::method() 00090 { 00091 checkParsed(); 00092 return mMethod; 00093 } 00094 00095 MethodTypes 00096 RAckCategory::method() const 00097 { 00098 checkParsed(); return mMethod; 00099 } 00100 00101 Data& 00102 RAckCategory::unknownMethodName() 00103 { 00104 checkParsed(); 00105 return mUnknownMethodName; 00106 } 00107 00108 const Data& 00109 RAckCategory::unknownMethodName() const 00110 { 00111 checkParsed(); 00112 return mUnknownMethodName; 00113 } 00114 00115 unsigned int& 00116 RAckCategory::rSequence() 00117 { 00118 checkParsed(); 00119 return mRSequence; 00120 } 00121 00122 unsigned int 00123 RAckCategory::rSequence() const 00124 { 00125 checkParsed(); 00126 return mRSequence; 00127 } 00128 00129 unsigned int& 00130 RAckCategory::cSequence() 00131 { 00132 checkParsed(); 00133 return mCSequence; 00134 } 00135 00136 unsigned int 00137 RAckCategory::cSequence() const 00138 { 00139 checkParsed(); 00140 return mCSequence; 00141 } 00142 00143 void 00144 RAckCategory::parse(ParseBuffer& pb) 00145 { 00146 const char* anchorPtr; 00147 pb.skipWhitespace(); 00148 mRSequence = pb.uInt32(); 00149 00150 pb.skipWhitespace(); 00151 mCSequence = pb.uInt32(); 00152 00153 anchorPtr = pb.skipWhitespace(); 00154 pb.skipNonWhitespace(); 00155 00156 mMethod = getMethodType(anchorPtr, int(pb.position() - anchorPtr)); 00157 // for backward compatibility, set the method name even if the method is known 00158 pb.data(mUnknownMethodName, anchorPtr); 00159 } 00160 00161 EncodeStream& 00162 RAckCategory::encodeParsed(EncodeStream& str) const 00163 { 00164 str << mRSequence << Symbols::SPACE 00165 << mCSequence << Symbols::SPACE 00166 << (mMethod != UNKNOWN ? getMethodName(mMethod) : mUnknownMethodName); 00167 return str; 00168 } 00169 00170 /* ==================================================================== 00171 * The Vovida Software License, Version 1.0 00172 * 00173 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00174 * 00175 * Redistribution and use in source and binary forms, with or without 00176 * modification, are permitted provided that the following conditions 00177 * are met: 00178 * 00179 * 1. Redistributions of source code must retain the above copyright 00180 * notice, this list of conditions and the following disclaimer. 00181 * 00182 * 2. Redistributions in binary form must reproduce the above copyright 00183 * notice, this list of conditions and the following disclaimer in 00184 * the documentation and/or other materials provided with the 00185 * distribution. 00186 * 00187 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00188 * and "Vovida Open Communication Application Library (VOCAL)" must 00189 * not be used to endorse or promote products derived from this 00190 * software without prior written permission. For written 00191 * permission, please contact vocal@vovida.org. 00192 * 00193 * 4. Products derived from this software may not be called "VOCAL", nor 00194 * may "VOCAL" appear in their name, without prior written 00195 * permission of Vovida Networks, Inc. 00196 * 00197 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00198 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00199 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00200 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00201 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00202 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00203 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00204 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00205 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00206 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00207 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00208 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00209 * DAMAGE. 00210 * 00211 * ==================================================================== 00212 * 00213 * This software consists of voluntary contributions made by Vovida 00214 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00215 * Inc. For more information on Vovida Networks, Inc., please see 00216 * <http://www.vovida.org/>. 00217 * 00218 */
1.7.5.1