/src/resiprocate/resip/stack/RequestLine.cxx
Line | Count | Source |
1 | | #if defined(HAVE_CONFIG_H) |
2 | | #include "config.h" |
3 | | #endif |
4 | | |
5 | | #include "resip/stack/RequestLine.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 | | // RequestLine: |
20 | | //==================== |
21 | | RequestLine::RequestLine() |
22 | 0 | : StartLine(), |
23 | 0 | mMethod(UNKNOWN), |
24 | 0 | mUnknownMethodName(Data::Share,getMethodName(UNKNOWN)), |
25 | 0 | mSipVersion(Data::Share,Symbols::DefaultSipVersion) |
26 | 0 | {} |
27 | | |
28 | | RequestLine::RequestLine(MethodTypes method, |
29 | | const Data& sipVersion) |
30 | 0 | : mMethod(method), |
31 | 0 | mUnknownMethodName(), |
32 | 0 | mSipVersion(sipVersion) |
33 | 0 | {} |
34 | | |
35 | | RequestLine::RequestLine(const HeaderFieldValue& hfv) |
36 | 5.87k | : StartLine(hfv), |
37 | 5.87k | mMethod(UNKNOWN), |
38 | 5.87k | mUnknownMethodName(Data::Share,getMethodName(UNKNOWN)), |
39 | 5.87k | mSipVersion(Data::Share,Symbols::DefaultSipVersion) |
40 | 5.87k | {} |
41 | | |
42 | | RequestLine::RequestLine(const char* buf, int len) : |
43 | 551 | StartLine(buf, len), |
44 | 551 | mMethod(UNKNOWN), |
45 | 551 | mUnknownMethodName(Data::Share,getMethodName(UNKNOWN)), |
46 | 551 | mSipVersion(Data::Share,Symbols::DefaultSipVersion) |
47 | 551 | {} |
48 | | |
49 | | RequestLine::RequestLine(const RequestLine& rhs) |
50 | 0 | : StartLine(rhs), |
51 | 0 | mUri(rhs.mUri), |
52 | 0 | mMethod(rhs.mMethod), |
53 | 0 | mUnknownMethodName(rhs.mUnknownMethodName), |
54 | 0 | mSipVersion(rhs.mSipVersion) |
55 | 0 | {} |
56 | | |
57 | | RequestLine& |
58 | | RequestLine::operator=(const RequestLine& rhs) |
59 | 0 | { |
60 | 0 | if (this != &rhs) |
61 | 0 | { |
62 | 0 | StartLine::operator=(rhs); |
63 | 0 | mUri = rhs.mUri; |
64 | 0 | mMethod = rhs.mMethod; |
65 | 0 | mUnknownMethodName = rhs.mUnknownMethodName; |
66 | 0 | mSipVersion = rhs.mSipVersion; |
67 | 0 | } |
68 | 0 | return *this; |
69 | 0 | } |
70 | | |
71 | | RequestLine::~RequestLine() |
72 | 6.42k | {} |
73 | | |
74 | | StartLine * |
75 | | RequestLine::clone() const |
76 | 0 | { |
77 | 0 | return new RequestLine(*this); |
78 | 0 | } |
79 | | |
80 | | StartLine * |
81 | | RequestLine::clone(void* location) const |
82 | 0 | { |
83 | 0 | return new (location) RequestLine(*this); |
84 | 0 | } |
85 | | |
86 | | const Uri& |
87 | | RequestLine::uri() const |
88 | 0 | { |
89 | 0 | checkParsed(); |
90 | 0 | return mUri; |
91 | 0 | } |
92 | | |
93 | | Uri& |
94 | | RequestLine::uri() |
95 | 0 | { |
96 | 0 | checkParsed(); |
97 | 0 | return mUri; |
98 | 0 | } |
99 | | |
100 | | MethodTypes |
101 | | RequestLine::getMethod() const |
102 | 0 | { |
103 | 0 | checkParsed(); |
104 | 0 | return mMethod; |
105 | 0 | } |
106 | | |
107 | | MethodTypes& |
108 | | RequestLine::method() |
109 | 0 | { |
110 | 0 | checkParsed(); |
111 | 0 | return mMethod; |
112 | 0 | } |
113 | | |
114 | | MethodTypes |
115 | | RequestLine::method() const |
116 | 0 | { |
117 | 0 | checkParsed(); |
118 | 0 | return mMethod; |
119 | 0 | } |
120 | | |
121 | | Data& |
122 | | RequestLine::unknownMethodName() |
123 | 0 | { |
124 | 0 | checkParsed(); |
125 | 0 | return mUnknownMethodName; |
126 | 0 | } |
127 | | |
128 | | const Data& |
129 | | RequestLine::unknownMethodName() const |
130 | 0 | { |
131 | 0 | checkParsed(); |
132 | 0 | return mUnknownMethodName; |
133 | 0 | } |
134 | | |
135 | | const Data& |
136 | | RequestLine::getSipVersion() const |
137 | 0 | { |
138 | 0 | checkParsed(); |
139 | 0 | return mSipVersion; |
140 | 0 | } |
141 | | |
142 | | void |
143 | | RequestLine::parse(ParseBuffer& pb) |
144 | 5.87k | { |
145 | 5.87k | const char* start; |
146 | 5.87k | start = pb.skipWhitespace(); |
147 | 5.87k | pb.skipNonWhitespace(); |
148 | 5.87k | mMethod = getMethodType(start, int(pb.position() - start)); |
149 | | // for backward compatibility, set the method name even if the method is known |
150 | 5.87k | pb.data(mUnknownMethodName, start); |
151 | 5.87k | pb.skipWhitespace(); |
152 | 5.87k | mUri.parse(pb); |
153 | 5.87k | start = pb.skipWhitespace(); |
154 | 5.87k | pb.skipNonWhitespace(); |
155 | 5.87k | pb.data(mSipVersion, start); |
156 | 5.87k | } |
157 | | |
158 | | EncodeStream& |
159 | | RequestLine::encodeParsed(EncodeStream& str) const |
160 | 0 | { |
161 | 0 | str << (mMethod != UNKNOWN ? getMethodName(mMethod) : mUnknownMethodName) << Symbols::SPACE; |
162 | 0 | mUri.encodeParsed(str); |
163 | 0 | str << Symbols::SPACE << mSipVersion; |
164 | 0 | return str; |
165 | 0 | } |
166 | | |
167 | | const Data& |
168 | | RequestLine::errorContext() const |
169 | 5.87k | { |
170 | 5.87k | static const Data reqLine("Request Line"); |
171 | 5.87k | return reqLine; |
172 | 5.87k | } |
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 | | */ |