reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ServerOutOfDialogReq.cxx
Go to the documentation of this file.
8#include "rutil/Logger.hxx"
10
11#include <utility>
12
13using namespace resip;
14
15#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
16
22
23
25 DialogSet& dialogSet,
26 const SipMessage& req)
27 : NonDialogUsage(dum, dialogSet),
28 mResponse(std::make_shared<SipMessage>())
29{
30
31}
32
34{
35 mDialogSet.mServerOutOfDialogRequest = nullptr;
36}
37
38void
40{
41 delete this;
42}
43
44void
46{
48
49 OutOfDialogHandler *pHandler = mDum.getOutOfDialogHandler(msg.header(h_CSeq).method());
50 if(pHandler != NULL)
51 {
52 // Let handler deal with message
53 mRequest = msg;
54 DebugLog ( << "ServerOutOfDialogReq::dispatch - handler found for " << getMethodName(msg.header(h_CSeq).method()) << " method.");
55 pHandler->onReceivedRequest(getHandle(), msg); // Wait for application to send response
56 }
57 else
58 {
59 if(msg.header(h_CSeq).method() == OPTIONS)
60 {
61 DebugLog ( << "ServerOutOfDialogReq::dispatch - handler not found for OPTIONS - sending autoresponse.");
62 // If no handler exists for OPTIONS then handle internally
63 mRequest = msg;
65 delete this;
66 }
67 else
68 {
69 DebugLog ( << "ServerOutOfDialogReq::dispatch - handler not found for " << getMethodName(msg.header(h_CSeq).method()) << " method - sending 405.");
70 // No handler found for out of dialog request - return a 405
71 mDum.makeResponse(*mResponse, msg, 405);
72 mDum.send(mResponse);
73 delete this;
74 }
75 }
76}
77
78void
82
83std::shared_ptr<SipMessage>
85{
86 mDum.makeResponse(*mResponse, mRequest, 200);
87 applyLocalContact(*mResponse, mRequest);
88
89 // Add in Allow, Accept, Accept-Encoding, Accept-Language, and Supported Headers from Profile
90 mResponse->header(h_Allows) = mDum.getMasterProfile()->getAllowedMethods();
91 mResponse->header(h_Accepts) = mDum.getMasterProfile()->getSupportedMimeTypes(INVITE);
92 mResponse->header(h_AcceptEncodings) = mDum.getMasterProfile()->getSupportedEncodings();
93 mResponse->header(h_AcceptLanguages) = mDum.getMasterProfile()->getSupportedLanguages();
94 mResponse->header(h_AllowEvents) = mDum.getMasterProfile()->getAllowedEvents();
95 mResponse->header(h_Supporteds) = mDum.getMasterProfile()->getSupportedOptionTags();
96
97 return mResponse;
98}
99
100void
101ServerOutOfDialogReq::send(std::shared_ptr<SipMessage> response)
102{
103 resip_assert(response->isResponse());
104 mDum.send(response);
105 delete this;
106}
107
108std::shared_ptr<SipMessage>
110{
112 mDum.makeResponse(*mResponse, mRequest, statusCode);
113 applyLocalContact(*mResponse, mRequest);
114 return mResponse;
115}
116
117std::shared_ptr<SipMessage>
119{
121 mDum.makeResponse(*mResponse, mRequest, statusCode);
122 return mResponse;
123}
124
126ServerOutOfDialogReq::dump(EncodeStream& strm) const
127{
128 if(mRequest.exists(h_CSeq))
129 {
130 strm << "ServerOutOfDialogReq " << getMethodName(mRequest.header(h_RequestLine).method())
131 << " cseq=" << mRequest.header(h_CSeq).sequence();
132 }
133 else
134 {
135 strm << "ServerOutOfDialogReq, dispatch has not occured yet.";
136 }
137 return strm;
138}
139
140/* ====================================================================
141 * The Vovida Software License, Version 1.0
142 *
143 * Copyright (c) 2026 SIP Spectrum, Inc. http://www.sipspectrum.com
144 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
145 *
146 * Redistribution and use in source and binary forms, with or without
147 * modification, are permitted provided that the following conditions
148 * are met:
149 *
150 * 1. Redistributions of source code must retain the above copyright
151 * notice, this list of conditions and the following disclaimer.
152 *
153 * 2. Redistributions in binary form must reproduce the above copyright
154 * notice, this list of conditions and the following disclaimer in
155 * the documentation and/or other materials provided with the
156
157 * distribution.
158 *
159 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
160 * and "Vovida Open Communication Application Library (VOCAL)" must
161 * not be used to endorse or promote products derived from this
162 * software without prior written permission. For written
163 * permission, please contact vocal@vovida.org.
164 *
165 * 4. Products derived from this software may not be called "VOCAL", nor
166 * may "VOCAL" appear in their name, without prior written
167 * permission of Vovida Networks, Inc.
168 *
169 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
170 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
171 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
172 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
173 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
174 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
175 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
176 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
177 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
178 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
179 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
180 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
181 * DAMAGE.
182 *
183 * ====================================================================
184 *
185 * This software consists of voluntary contributions made by Vovida
186 * Networks, Inc. and many individuals on behalf of Vovida Networks,
187 * Inc. For more information on Vovida Networks, Inc., please see
188 * <http://www.vovida.org/>.
189 *
190 */
191
#define DebugLog(args_)
Definition Logger.hxx:128
#define resip_assert(x)
This file needs to work for both C and C++ code.
BaseUsageHandle getBaseHandle() const
Definition BaseUsage.cxx:36
DialogUsageManager & mDum
Definition BaseUsage.hxx:43
void send(std::shared_ptr< SipMessage > request)
std::shared_ptr< MasterProfile > & getMasterProfile()
void applyLocalContact(SipMessage &response, const SipMessage &request) const
virtual void onReceivedRequest(ServerOutOfDialogReqHandle, const SipMessage &request)=0
MethodTypes & method()
ServerOutOfDialogReqHandle getHandle()
virtual std::shared_ptr< SipMessage > answerOptions()
void dispatch(const SipMessage &msg) override
void send(std::shared_ptr< SipMessage > msg) override
std::shared_ptr< SipMessage > accept(int statusCode=200)
EncodeStream & dump(EncodeStream &strm) const override
ServerOutOfDialogReq(const ServerOutOfDialogReq &)=delete
Handle< ServerOutOfDialogReq > ServerOutOfDialogReqHandle
std::shared_ptr< SipMessage > reject(int statusCode)
Represents a SIP message.
bool isRequest() const
Returns true if message is a request, false otherwise.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
bool exists(const HeaderBase &headerType) const
Returns true if the given header field is present, false otherwise.
dcm! – add UnusedChecking(_enum) below;
const Data & getMethodName(MethodTypes t)
RequestLineType h_RequestLine
Definition Headers.cxx:347
H_AllowEventss h_AllowEvents
Definition Headers.cxx:143
#define EncodeStream