reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
RequestLine.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// RequestLine:
20//====================
22 : StartLine(),
23 mMethod(UNKNOWN),
24 mUnknownMethodName(Data::Share,getMethodName(UNKNOWN)),
25 mSipVersion(Data::Share,Symbols::DefaultSipVersion)
26{}
27
29 const Data& sipVersion)
30 : mMethod(method),
31 mUnknownMethodName(),
32 mSipVersion(sipVersion)
33{}
34
36 : StartLine(hfv),
37 mMethod(UNKNOWN),
38 mUnknownMethodName(Data::Share,getMethodName(UNKNOWN)),
39 mSipVersion(Data::Share,Symbols::DefaultSipVersion)
40{}
41
42RequestLine::RequestLine(const char* buf, int len) :
43 StartLine(buf, len),
44 mMethod(UNKNOWN),
45 mUnknownMethodName(Data::Share,getMethodName(UNKNOWN)),
46 mSipVersion(Data::Share,Symbols::DefaultSipVersion)
47{}
48
50 : StartLine(rhs),
51 mUri(rhs.mUri),
52 mMethod(rhs.mMethod),
53 mUnknownMethodName(rhs.mUnknownMethodName),
54 mSipVersion(rhs.mSipVersion)
55{}
56
59{
60 if (this != &rhs)
61 {
63 mUri = rhs.mUri;
64 mMethod = rhs.mMethod;
65 mUnknownMethodName = rhs.mUnknownMethodName;
66 mSipVersion = rhs.mSipVersion;
67 }
68 return *this;
69}
70
73
76{
77 return new RequestLine(*this);
78}
79
81RequestLine::clone(void* location) const
82{
83 return new (location) RequestLine(*this);
84}
85
86const Uri&
88{
89 checkParsed();
90 return mUri;
91}
92
93Uri&
95{
96 checkParsed();
97 return mUri;
98}
99
102{
103 checkParsed();
104 return mMethod;
105}
106
109{
110 checkParsed();
111 return mMethod;
112}
113
116{
117 checkParsed();
118 return mMethod;
119}
120
121Data&
123{
124 checkParsed();
125 return mUnknownMethodName;
126}
127
128const Data&
130{
131 checkParsed();
132 return mUnknownMethodName;
133}
134
135const Data&
137{
138 checkParsed();
139 return mSipVersion;
140}
141
142void
144{
145 const char* start;
146 start = pb.skipWhitespace();
148 mMethod = getMethodType(start, int(pb.position() - start));
149 // for backward compatibility, set the method name even if the method is known
150 pb.data(mUnknownMethodName, start);
151 pb.skipWhitespace();
152 mUri.parse(pb);
153 start = pb.skipWhitespace();
155 pb.data(mSipVersion, start);
156}
157
159RequestLine::encodeParsed(EncodeStream& str) const
160{
161 str << (mMethod != UNKNOWN ? getMethodName(mMethod) : mUnknownMethodName) << Symbols::SPACE;
162 mUri.encodeParsed(str);
163 str << Symbols::SPACE << mSipVersion;
164 return str;
165}
166
167const Data&
169{
170 static const Data reqLine("Request Line");
171 return reqLine;
172}
173
174/* ====================================================================
175 * The Vovida Software License, Version 1.0
176 *
177 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
178 *
179 * Redistribution and use in source and binary forms, with or without
180 * modification, are permitted provided that the following conditions
181 * are met:
182 *
183 * 1. Redistributions of source code must retain the above copyright
184 * notice, this list of conditions and the following disclaimer.
185 *
186 * 2. Redistributions in binary form must reproduce the above copyright
187 * notice, this list of conditions and the following disclaimer in
188 * the documentation and/or other materials provided with the
189 * distribution.
190 *
191 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
192 * and "Vovida Open Communication Application Library (VOCAL)" must
193 * not be used to endorse or promote products derived from this
194 * software without prior written permission. For written
195 * permission, please contact vocal@vovida.org.
196 *
197 * 4. Products derived from this software may not be called "VOCAL", nor
198 * may "VOCAL" appear in their name, without prior written
199 * permission of Vovida Networks, Inc.
200 *
201 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
202 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
203 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
204 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
205 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
206 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
207 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
208 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
209 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
210 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
211 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
212 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
213 * DAMAGE.
214 *
215 * ====================================================================
216 *
217 * This software consists of voluntary contributions made by Vovida
218 * Networks, Inc. and many individuals on behalf of Vovida Networks,
219 * Inc. For more information on Vovida Networks, Inc., please see
220 * <http://www.vovida.org/>.
221 *
222 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
void checkParsed() const
LazyParser & operator=(const LazyParser &rhs)
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipNonWhitespace()
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)
Represents the "Request-Line" element in the RFC 3261 grammar.
const Data & getSipVersion() const
virtual StartLine * clone() const
virtual void parse(ParseBuffer &pb)
RequestLine & operator=(const RequestLine &)
MethodTypes getMethod() const
virtual const Data & errorContext() const
const Uri & uri() const
virtual EncodeStream & encodeParsed(EncodeStream &str) const
MethodTypes & method()
static const char * SPACE
Definition Symbols.hxx:34
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
Definition Uri.hxx:22
virtual EncodeStream & encodeParsed(EncodeStream &str) const
Definition Uri.cxx:1496
virtual void parse(ParseBuffer &pb)
Definition Uri.cxx:1176
dcm! – add UnusedChecking(_enum) below;
const Data & getMethodName(MethodTypes t)
MethodTypes getMethodType(const Data &name)
#define EncodeStream