reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
StatusLine.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
6#include "rutil/Data.hxx"
7#include "rutil/DnsUtil.hxx"
8#include "rutil/Logger.hxx"
10//#include "rutil/WinLeakCheck.hxx" // not compatible with placement new used below
11
12using namespace resip;
13using namespace std;
14
15#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
16
17//====================
18// StatusLine:
19//====================
21 : StartLine(),
22 mResponseCode(-1),
23 mSipVersion(Data::Share,Symbols::DefaultSipVersion),
24 mReason()
25{}
26
28 : StartLine(hfv),
29 mResponseCode(-1),
30 mSipVersion(Data::Share,Symbols::DefaultSipVersion),
31 mReason()
32{}
33
34StatusLine::StatusLine(const char* buf, int length) :
35 StartLine(buf, length),
36 mResponseCode(-1),
37 mSipVersion(Data::Share,Symbols::DefaultSipVersion),
38 mReason()
39{}
40
42 : StartLine(rhs),
43 mResponseCode(rhs.mResponseCode),
44 mSipVersion(rhs.mSipVersion),
45 mReason(rhs.mReason)
46{}
47
50{
51 if (this != &rhs)
52 {
54 mResponseCode = rhs.mResponseCode;
55 mSipVersion = rhs.mSipVersion;
56 mReason = rhs.mReason;
57 }
58 return *this;
59}
60
63{
64 return new StatusLine(*this);
65}
66
68StatusLine::clone(void* location) const
69{
70 return new (location) StatusLine(*this);
71}
72
73int&
75{
77 return mResponseCode;
78}
79
80int
82{
84 return mResponseCode;
85}
86
87int&
89{
91 return mResponseCode;
92}
93
94int
96{
98 return mResponseCode;
99}
100
101const Data&
103{
104 checkParsed();
105 return mSipVersion;
106}
107
108Data&
110{
111 checkParsed();
112 return mReason;
113}
114
115const Data&
117{
118 checkParsed();
119 return mReason;
120}
121
122void
124{
125 const char* start = pb.skipWhitespace();
127 pb.data(mSipVersion, start);
128
129 start = pb.skipWhitespace();
130 mResponseCode = pb.integer();
131 start = pb.skipWhitespace();
132 pb.skipToEnd();
133 pb.data(mReason, start);
134}
135
137StatusLine::encodeParsed(EncodeStream& str) const
138{
139 str << mSipVersion << Symbols::SPACE
140 << mResponseCode << Symbols::SPACE
141 << mReason;
142 return str;
143}
144
145const Data&
147{
148 static const Data statLine("Status Line");
149 return statLine;
150}
151
152/* ====================================================================
153 * The Vovida Software License, Version 1.0
154 *
155 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
156 *
157 * Redistribution and use in source and binary forms, with or without
158 * modification, are permitted provided that the following conditions
159 * are met:
160 *
161 * 1. Redistributions of source code must retain the above copyright
162 * notice, this list of conditions and the following disclaimer.
163 *
164 * 2. Redistributions in binary form must reproduce the above copyright
165 * notice, this list of conditions and the following disclaimer in
166 * the documentation and/or other materials provided with the
167 * distribution.
168 *
169 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
170 * and "Vovida Open Communication Application Library (VOCAL)" must
171 * not be used to endorse or promote products derived from this
172 * software without prior written permission. For written
173 * permission, please contact vocal@vovida.org.
174 *
175 * 4. Products derived from this software may not be called "VOCAL", nor
176 * may "VOCAL" appear in their name, without prior written
177 * permission of Vovida Networks, Inc.
178 *
179 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
180 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
181 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
182 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
183 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
184 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
185 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
186 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
187 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
188 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
189 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
190 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
191 * DAMAGE.
192 *
193 * ====================================================================
194 *
195 * This software consists of voluntary contributions made by Vovida
196 * Networks, Inc. and many individuals on behalf of Vovida Networks,
197 * Inc. For more information on Vovida Networks, Inc., please see
198 * <http://www.vovida.org/>.
199 *
200 */
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 skipToEnd()
CurrentPosition skipWhitespace()
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
Represents the "Status-Line" element in the RFC 3261 grammar.
virtual EncodeStream & encodeParsed(EncodeStream &str) const
virtual void parse(ParseBuffer &pb)
StatusLine & operator=(const StatusLine &)
const Data & getSipVersion() const
virtual StartLine * clone() const
virtual const Data & errorContext() const
static const char * SPACE
Definition Symbols.hxx:34
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream