reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
BaseCreator.cxx
Go to the documentation of this file.
2#include "rutil/Logger.hxx"
8
9#include <utility>
10
11#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
12
13using namespace resip;
14
15BaseCreator::BaseCreator(DialogUsageManager& dum, std::shared_ptr<UserProfile> userProfile)
16 : mLastRequest(std::make_shared<SipMessage>()),
17 mDum(dum),
18 mUserProfile(userProfile)
19{
20}
21
22std::shared_ptr<SipMessage>
24{
25 return mLastRequest;
26}
27
28/*
29const SipMessage&
30BaseCreator::getLastRequest() const
31{
32 return mLastRequest;
33}
34*/
35
36std::shared_ptr<UserProfile>
38{
39 return mUserProfile;
40}
41
42void
44{
46 makeInitialRequest(target, mUserProfile->getDefaultFrom(), method);
47}
48
49
50void
52{
53 RequestLine rLine(method);
54 rLine.uri() = target.uri();
55 mLastRequest->header(h_RequestLine) = rLine;
56
57 mLastRequest->header(h_To) = target;
58 mLastRequest->header(h_MaxForwards).value() = 70;
59 mLastRequest->header(h_CSeq).method() = method;
60 mLastRequest->header(h_CSeq).sequence() = 1;
61 mLastRequest->header(h_From) = from;
62 mLastRequest->header(h_From).param(p_tag) = Helper::computeTag(Helper::tagSize);
63 mLastRequest->header(h_CallId).value() = Helper::computeCallId();
64
66 if (!mUserProfile->getImsAuthUserName().empty())
67 {
68 Auth auth;
69 auth.scheme() = Symbols::Digest;
70 auth.param(p_username) = mUserProfile->getImsAuthUserName();
71 auth.param(p_realm) = mUserProfile->getImsAuthHost();
72 auth.param(p_uri) = "sip:" + mUserProfile->getImsAuthHost();
73 auth.param(p_nonce) = Data::Empty;
74 auth.param(p_response) = Data::Empty;
75 mLastRequest->header(h_Authorizations).push_back(auth);
76 DebugLog ( << "Adding auth header to inital reg for IMS: " << auth);
77 }
78
79 NameAddr contact; // if no GRUU, let the stack fill in the contact
80
81 if(mUserProfile->hasUserAgentCapabilities())
82 {
83 contact = mUserProfile->getUserAgentCapabilities();
84 }
85
86 //.dcm. If we want to use userprofiles oacross multiple registration we will
87 //need the lookup-rtype hasGruu methods
88 //if (mUserProfile->hasGruu(target.uri().getAor()))
89 //?dcm? handle selction of anon vs pub gruu in profile?
90 //if (mUserProfile->hasGruu(target.uri().getAor()))
92 if (!mUserProfile->isAnonymous() && mUserProfile->hasPublicGruu() && method != REGISTER) //why not use GRUU for publish/etc?
93 {
94 contact.uri() = mUserProfile->getPublicGruu();
95 mLastRequest->header(h_Contacts).push_front(contact);
96 }
97 else if(mUserProfile->isAnonymous() && mUserProfile->hasTempGruu() && method != REGISTER)
98 {
99 contact.uri() = mUserProfile->getTempGruu();
100 mLastRequest->header(h_Contacts).push_front(contact);
101 }
102 else
103 {
104 if (mUserProfile->hasOverrideHostAndPort())
105 {
106 contact.uri() = mUserProfile->getOverrideHostAndPort();
107 }
108 // Contact header will always have a sip: scheme so it's safe to copy
109 // the user part from sip:, sips: and tel: but not from others like urn:
110 // (RFC 8141's NID:NSS has nothing to do with a sip: user's ABNF).
111 // When skipped, contact.uri().user() keeps whatever it already had:
112 // empty by default, or whatever getOverrideHostAndPort() set above --
113 // i.e. for a urn: "from" (e.g. an emergency-services From), an
114 // override profile's own user is now preserved instead of being
115 // clobbered by the (incompatible) urn: user. Legal either way; see
116 // the analogous comment in Dialog.cxx for the To/Request-URI case.
117 if (from.uri().isUserRelevant())
118 {
119 contact.uri().user() = from.uri().user();
120 }
121
122 // .jjg. there isn't anything in the outbound [11] draft that says we
123 // aren't allowed to include p_Instance in this case...
124 // odds are it will be useful (or necessary) for some implementations
125 const Data& instanceId = mUserProfile->getInstanceId();
126 if (!contact.uri().exists(p_gr) && !instanceId.empty())
127 {
128 contact.param(p_Instance) = instanceId;
129 }
130 mLastRequest->header(h_Contacts).push_front(contact);
131
132 if (method != REGISTER)
133 {
134 const NameAddrs& sRoute = mUserProfile->getServiceRoute();
135 if (!sRoute.empty())
136 {
137 mLastRequest->header(h_Routes) = sRoute;
138 }
139 }
140 }
141
142 if(mUserProfile->clientOutboundEnabled() && method != REGISTER)
143 {
144 // Add ;ob parm to non-register requests - RFC5626 pg17
145 mLastRequest->header(h_Contacts).front().uri().param(p_ob);
146 }
147
148 Via via;
149 mLastRequest->header(h_Vias).push_front(via);
150
151 // Add Advertised Capabilities to initial request
153
154 // Merge Embedded parameters
155 mLastRequest->mergeUri(target.uri());
156
157 //DumHelper::setOutgoingEncryptionLevel(mLastRequest, mEncryptionLevel);
158
159 DebugLog ( << "BaseCreator::makeInitialRequest: " << std::endl << std::endl << *mLastRequest);
160}
161
162
163/* ====================================================================
164 * The Vovida Software License, Version 1.0
165 *
166 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
167 *
168 * Redistribution and use in source and binary forms, with or without
169 * modification, are permitted provided that the following conditions
170 * are met:
171 *
172 * 1. Redistributions of source code must retain the above copyright
173 * notice, this list of conditions and the following disclaimer.
174 *
175 * 2. Redistributions in binary form must reproduce the above copyright
176 * notice, this list of conditions and the following disclaimer in
177 * the documentation and/or other materials provided with the
178 * distribution.
179 *
180 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
181 * and "Vovida Open Communication Application Library (VOCAL)" must
182 * not be used to endorse or promote products derived from this
183 * software without prior written permission. For written
184 * permission, please contact vocal@vovida.org.
185 *
186 * 4. Products derived from this software may not be called "VOCAL", nor
187 * may "VOCAL" appear in their name, without prior written
188 * permission of Vovida Networks, Inc.
189 *
190 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
191 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
192 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
193 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
194 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
195 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
196 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
197 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
198 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
199 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
200 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
201 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
202 * DAMAGE.
203 *
204 * ====================================================================
205 *
206 * This software consists of voluntary contributions made by Vovida
207 * Networks, Inc. and many individuals on behalf of Vovida Networks,
208 * Inc. For more information on Vovida Networks, Inc., please see
209 * <http://www.vovida.org/>.
210 *
211 */
212
#define DebugLog(args_)
Definition Logger.hxx:128
#define resip_assert(x)
This file needs to work for both C and C++ code.
Represents the "credentials" and "challenge" elements in the SIP grammar.
Definition Auth.hxx:18
Data & scheme()
Definition Auth.cxx:46
const Data & param(const ExtensionParameter &param) const
Const accessor for non-natively-supported parameter types.
void makeInitialRequest(const NameAddr &target, MethodTypes method)
DialogUsageManager & mDum
std::shared_ptr< UserProfile > getUserProfile() const noexcept
std::shared_ptr< SipMessage > mLastRequest
BaseCreator(DialogUsageManager &dum, std::shared_ptr< UserProfile > userProfile)
std::shared_ptr< UserProfile > mUserProfile
std::shared_ptr< SipMessage > getLastRequest() const noexcept
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
bool empty() const noexcept
Checks whether the Data is empty.
Definition Data.hxx:591
void setAdvertisedCapabilities(SipMessage &msg, const std::shared_ptr< UserProfile > &userProfile)
static const int tagSize
bytes in to-tag& from-tag, should prob. live somewhere else
Definition Helper.hxx:42
static Data computeTag(int numBytes)
Definition Helper.cxx:713
static Data computeCallId()
Definition Helper.cxx:690
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Definition NameAddr.hxx:19
const Data & param(const ExtensionParameter &param) const
Const accessor for non-natively-supported parameter types.
bool empty() const
return true or false indicating whether the mParsers vector is empty or not
T & front()
Returns the first header field value in this container.
Represents the "Request-Line" element in the RFC 3261 grammar.
const Uri & uri() const
Represents a SIP message.
static const char * Digest
Definition Symbols.hxx:74
bool isUserRelevant() const
Checks if this URI's scheme has sip:/sips:/tel: user-part semantics, i.e.
Definition Uri.cxx:528
bool exists(const Param< Uri > &paramType) const
Definition Uri.cxx:1701
Data & user()
Definition Uri.hxx:42
const Data & param(const ExtensionParameter &param) const
Const accessor for non-natively-supported parameter types.
Represents the "via-parm" element in the RFC 3261 grammar.
Definition Via.hxx:18
dcm! – add UnusedChecking(_enum) below;
RequestLineType h_RequestLine
Definition Headers.cxx:347
H_CallId h_CallId
Definition Headers.cxx:266