reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
MasterProfile.cxx
Go to the documentation of this file.
1
5#include "rutil/Logger.hxx"
6
7using namespace resip;
8#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
9
10
11// Be sure to look at the documentation of the accessors for
12// the members being set by this constructor in the .hxx file
13// for the implications of these default values.
14
16 mValidateContentEnabled(true),
17 mValidateContentLanguageEnabled(false),
18 mValidateAcceptEnabled(false),
19 mAllowBadRegistrationEnabled(false),
20 mCheckReqUriInMergeDetectionEnabled(false),
21 mUacReliableProvisionalMode(Never),
22 mUasReliableProvisionalMode(Never),
23 mServerRegistrationMinExpires(0),
24 mServerRegistrationMaxExpires(UINT_MAX),
25 mServerRegistrationDefaultExpires(3600),
26 mAdditionalTransactionTerminatingResponsesEnabled(false)
27{
28 // Default settings
29 addSupportedMimeType(INVITE, Mime("application", "sdp"));
30 addSupportedMimeType(OPTIONS, Mime("application", "sdp"));
31 addSupportedMimeType(PRACK, Mime("application", "sdp"));
32 addSupportedMimeType(UPDATE, Mime("application", "sdp"));
34 addSupportedMethod(INVITE);
36 addSupportedMethod(CANCEL);
37 addSupportedMethod(OPTIONS);
39 addSupportedMethod(UPDATE);
41 // urn: (e.g. RFC 5031 emergency service URNs) is intentionally not
42 // added to the default supported schemes. An application that wants
43 // it should call addSupportedScheme(Symbols::Urn) itself.
44}
45
46void
48{
49 mSupportedSchemes.insert(scheme);
50}
51
52bool
54{
55 return mSupportedSchemes.find(scheme) != mSupportedSchemes.end();
56}
57
58void
60{
61 mSupportedSchemes.clear();
62}
63
64void
66{
67 mSupportedMethodTypes.insert(method);
68 mSupportedMethods.push_back(Token(getMethodName(method)));
69}
70
71void
73{
74 mSupportedMethodTypes.erase(method);
75 for (Tokens::iterator i = mSupportedMethods.begin();
76 i != mSupportedMethods.end(); ++i)
77 {
78 if (getMethodType(i->value()) == method)
79 {
80 mSupportedMethods.erase(i);
81 break;
82 }
83 }
84
85 // Should we clear the mimetypes as well?
86 // clearSupportedMimeTypes(method);
87}
88
89bool
91{
92 return mSupportedMethodTypes.find(method) != mSupportedMethodTypes.end();
93}
94
95Tokens
97{
98 return mSupportedMethods;
99}
100
101Data
103{
104 Data result;
105
106 for (Tokens::const_iterator i = mSupportedMethods.begin();
107 i != mSupportedMethods.end(); ++i)
108 {
109 if (i != mSupportedMethods.begin())
110 {
111 result += Symbols::COMMA[0];
112 }
113 result += i->value();
114 }
115
116 return result;
117}
118
119void
121{
122 mSupportedMethodTypes.clear();
123 mSupportedMethods.clear();
124}
125
126void
128{
129 if (tag == Token(Symbols::C100rel))
130 {
131 //use setUasReliableProvisionalMode and setUacReliableProvisionalMode
132 resip_assert(0);
133 }
134 mSupportedOptionTags.push_back(tag);
135}
136
137Tokens
139{
140 Tokens tokens;
141 for (Tokens::const_iterator i=requiresOptionTags.begin(); i != requiresOptionTags.end(); ++i)
142 {
143 if (!i->isWellFormed())
144 {
145 tokens.push_back(Token("malformedTag"));
146 }
147 else if (*i == Token(Symbols::C100rel) )
148 {
149 if (mUasReliableProvisionalMode == Never)
150 {
151 tokens.push_back(*i);
152 }
153 }
154 // if this option is not supported
155 else if (!mSupportedOptionTags.find(*i))
156 {
157 tokens.push_back(*i);
158 }
159 }
160
161 return tokens;
162}
163
164Tokens
166{
167 return mSupportedOptionTags;
168}
169
170void
172{
173 mSupportedOptionTags.clear();
174}
175
176void
178{
179 mUacReliableProvisionalMode = mode;
180}
181
182void
184{
185 mUasReliableProvisionalMode = mode;
186}
187
190{
191 return mUacReliableProvisionalMode;
192}
193
196{
197 return mUasReliableProvisionalMode;
198}
199
200void
202{
203 mSupportedMimeTypes[method].push_back(mimeType);
204}
205
206bool
208{
209 std::map<MethodTypes, Mimes>::iterator foundMethod = mSupportedMimeTypes.find(method);
210 if (foundMethod != mSupportedMimeTypes.end())
211 {
212 for (Mimes::iterator i = foundMethod->second.begin();
213 i != foundMethod->second.end(); ++i)
214 {
215 if (mimeType.isEqual(*i))
216 {
217 foundMethod->second.erase(i);
218 return true;
219 }
220 }
221 }
222 return false;
223}
224
225bool
227{
228 if(!mimeType.isWellFormed())
229 {
230 return false;
231 }
232
233 std::map<MethodTypes, Mimes>::iterator found = mSupportedMimeTypes.find(method);
234 if (found != mSupportedMimeTypes.end())
235 {
236 return found->second.find(mimeType);
237 }
238 return false;
239}
240
241Mimes
243{
244 std::map<MethodTypes, Mimes>::iterator found = mSupportedMimeTypes.find(method);
245 if (found != mSupportedMimeTypes.end())
246 {
247 return found->second;
248 }
249 return Mimes();
250}
251
252void
254{
255 std::map<MethodTypes, Mimes>::iterator found = mSupportedMimeTypes.find(method);
256 if (found != mSupportedMimeTypes.end())
257 {
258 found->second.clear();
259 }
260}
261
262void
264{
265 mSupportedMimeTypes.clear();
266}
267
268void
270{
271 mSupportedEncodings.push_back(encoding);
272}
273
274bool
276{
277 return encoding.isWellFormed() && mSupportedEncodings.find(encoding);
278}
279
280Tokens
282{
283 return mSupportedEncodings;
284}
285
286void
288{
289 mSupportedEncodings.clear();
290}
291
292void
294{
295 mSupportedLanguages.push_back(lang);
296}
297
298bool
300{
301 for (Tokens::const_iterator i=langs.begin(); i != langs.end(); ++i)
302 {
303 if (!i->isWellFormed() || mSupportedLanguages.find(*i) == false)
304 {
305 return false;
306 }
307 }
308 return true;
309}
310
311Tokens
313{
314 return mSupportedLanguages;
315}
316
317void
319{
320 mSupportedLanguages.clear();
321}
322
323void
325{
326 mAllowedEvents.push_back(event);
327}
328
329bool
331{
332 for (Tokens::const_iterator i=events.begin(); i != events.end(); ++i)
333 {
334 if (!i->isWellFormed() || mAllowedEvents.find(*i) == false)
335 {
336 return false;
337 }
338 }
339 return true;
340}
341
342Tokens
344{
345 return mAllowedEvents;
346}
347
348void
350{
351 mAllowedEvents.clear();
352}
353
354bool&
356{
357 return mValidateContentEnabled;
358}
359
360bool
362{
363 return mValidateContentEnabled;
364}
365
366bool&
368{
369 return mValidateContentLanguageEnabled;
370}
371
372bool
374{
375 return mValidateContentLanguageEnabled;
376}
377
378bool&
380{
381 return mValidateAcceptEnabled;
382}
383
384bool
386{
387 return mValidateAcceptEnabled;
388}
389
390bool
392{
393 return mAllowBadRegistrationEnabled;
394}
395
396bool&
398{
399 return mAllowBadRegistrationEnabled;
400}
401
402
403uint32_t &
405{
406 return mServerRegistrationMinExpires;
407}
408
411{
412 return mServerRegistrationMinExpires;
413}
414
415uint32_t &
417{
418 return mServerRegistrationMaxExpires;
419}
420
423{
424 return mServerRegistrationMaxExpires;
425}
426
427uint32_t &
429{
430 return mServerRegistrationDefaultExpires;
431}
432
435{
436 return mServerRegistrationDefaultExpires;
437}
438
439bool
441{
442 return mCheckReqUriInMergeDetectionEnabled;
443}
444
445bool&
447{
448 return mCheckReqUriInMergeDetectionEnabled;
449}
450
452MasterProfile::clone() const
453{
454 return new MasterProfile(*this);
455}
456
458{
459 return mAdditionalTransactionTerminatingResponsesEnabled;
460}
461
463{
464 return mAdditionalTransactionTerminatingResponsesEnabled;
465}
466
468{
469 DebugLog(<< "MasterProfile::addAdditionalTransactionTerminatingResponses" << "added code: " << code);
470 mAdditionalTransactionTerminatingResponsess.insert(code);
471}
472
474{
475 bool isAllowed = (mAdditionalTransactionTerminatingResponsess.end() != mAdditionalTransactionTerminatingResponsess.find(code));
476
477 DebugLog(<< "MasterProfile::isAdditionalTransactionTerminatingResponse" << "is code " << code << " allowed: " << isAllowed);
478 return isAllowed;
479}
480
482{
483 return mAdditionalTransactionTerminatingResponsess;
484}
485
487{
488 mAdditionalTransactionTerminatingResponsess.clear();
489}
490
491/* ====================================================================
492 * The Vovida Software License, Version 1.0
493 *
494 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
495 *
496 * Redistribution and use in source and binary forms, with or without
497 * modification, are permitted provided that the following conditions
498 * are met:
499 *
500 * 1. Redistributions of source code must retain the above copyright
501 * notice, this list of conditions and the following disclaimer.
502 *
503 * 2. Redistributions in binary form must reproduce the above copyright
504 * notice, this list of conditions and the following disclaimer in
505 * the documentation and/or other materials provided with the
506 * distribution.
507 *
508 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
509 * and "Vovida Open Communication Application Library (VOCAL)" must
510 * not be used to endorse or promote products derived from this
511 * software without prior written permission. For written
512 * permission, please contact vocal@vovida.org.
513 *
514 * 4. Products derived from this software may not be called "VOCAL", nor
515 * may "VOCAL" appear in their name, without prior written
516 * permission of Vovida Networks, Inc.
517 *
518 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
519 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
520 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
521 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
522 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
523 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
524 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
525 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
526 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
527 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
528 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
529 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
530 * DAMAGE.
531 *
532 * ====================================================================
533 *
534 * This software consists of voluntary contributions made by Vovida
535 * Networks, Inc. and many individuals on behalf of Vovida Networks,
536 * Inc. For more information on Vovida Networks, Inc., please see
537 * <http://www.vovida.org/>.
538 *
539 */
540
#define DebugLog(args_)
Definition Logger.hxx:128
#define resip_assert(x)
This file needs to work for both C and C++ code.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
bool isWellFormed() const
Returns true iff this element was parsed successfully, according to the implementation of parse().
virtual bool isSchemeSupported(const Data &scheme) const
virtual void setUasReliableProvisionalMode(ReliableProvisionalMode mode) noexcept
virtual void clearSupportedEncodings() noexcept
virtual void clearSupportedSchemes() noexcept
virtual bool isMimeTypeSupported(const MethodTypes &method, const Mime &mimeType)
virtual uint32_t & serverRegistrationDefaultExpiresTime() noexcept
If no Expires header or individual contact bindings specify an expiration value, use this value.
virtual bool isLanguageSupported(const Tokens &lang) const
virtual void clearAllowedEvents() noexcept
virtual const std::set< int > & getAdditionalTransactionTerminatingResponses() const
virtual bool & validateAcceptEnabled() noexcept
enable/disable Accept header validation
virtual bool isMethodSupported(MethodTypes method) const
virtual void clearSupportedOptionTags() noexcept
virtual void removeSupportedMethod(const MethodTypes &method)
virtual Tokens getSupportedLanguages() const
virtual void clearSupportedMimeTypes() noexcept
virtual bool & validateContentLanguageEnabled() noexcept
enable/disable content language validation
virtual Tokens getSupportedEncodings() const
virtual Tokens getAllowedMethods() const
virtual void addSupportedScheme(const Data &scheme)
Default is "sip".
virtual void addAllowedEvent(const Token &event)
Default is to not send an Allow-Events header.
virtual Tokens getSupportedOptionTags() const
virtual ReliableProvisionalMode getUacReliableProvisionalMode() const noexcept
MasterProfile()
Creates an Identity/Profile with no BaseProfile - this is the root of all profiles.
virtual Tokens getAllowedEvents() const
virtual void addSupportedMimeType(const MethodTypes &method, const Mime &mimeType)
Default is application/sdp for INVITE, OPTIONS, PRACK and UPDATE Methods.
virtual uint32_t & serverRegistrationMaxExpiresTime() noexcept
If an inbound REGISTER has an Expires header or any individual contact bindings with expires greater ...
virtual void addSupportedEncoding(const Token &encoding)
Default is no encoding.
virtual bool isEventAllowed(const Tokens &event) const
virtual bool isContentEncodingSupported(const Token &contentEncoding) const
virtual ReliableProvisionalMode getUasReliableProvisionalMode() const noexcept
virtual Data getAllowedMethodsData() const
virtual bool & validateContentEnabled() noexcept
enable/disable content validation
virtual void addSupportedOptionTag(const Token &tag)
Default is none. Do not use to enable PRACK(100rel) support.
virtual void addSupportedMethod(const MethodTypes &method)
Defaults are: INVITE, ACK, CANCEL, OPTIONS, BYE, UPDATE.
virtual void setUacReliableProvisionalMode(ReliableProvisionalMode mode) noexcept
virtual void addAdditionalTransactionTerminatingResponses(int code)
virtual bool removeSupportedMimeType(const MethodTypes &method, const Mime &mimeType)
virtual bool & additionalTransactionTerminatingResponsesEnabled() noexcept
Enabling this setting will allow the application layer to provide additional SIP responses,...
virtual Tokens getUnsupportedOptionsTags(const Tokens &requiresOptionTags)
virtual void clearSupportedMethods() noexcept
virtual bool & checkReqUriInMergeDetectionEnabled() noexcept
Set this to include the RequestURI in merge request detection.
virtual uint32_t & serverRegistrationMinExpiresTime() noexcept
Used when receiving a REGISTER request, if the expires value in the request is less than this time,...
virtual bool isAdditionalTransactionTerminatingResponse(int code) const
virtual void clearSupportedLanguages() noexcept
virtual void clearAdditionalTransactionTerminatingResponses() noexcept
virtual bool & allowBadRegistrationEnabled() noexcept
Set this to allow the Registration Server to accept registration requests that contain a To Tag.
virtual void addSupportedLanguage(const Token &lang)
Default is all - if nothing is set, then all are allowed.
virtual Mimes getSupportedMimeTypes(const MethodTypes &method)
Represents the "media-type" element in the RFC 3261 grammar.
Definition Mime.hxx:20
bool isEqual(const Mime &rhs) const
Definition Mime.cxx:74
void clear()
clear the mParsers vector
iterator end()
Returns an iterator pointing to the last header field value.
iterator erase(iterator i)
Erases the header field value pointed to by i.
iterator begin()
Returns an iterator pointing to the first header field value.
void push_back(const T &t)
Inserts a header field value at the back of this container.
bool find(const T &rhs) const
Finds the first header field value that matches rhs.
static const char * C100rel
Definition Symbols.hxx:107
static const char * COMMA
Definition Symbols.hxx:35
static const char * Sip
Definition Symbols.hxx:62
Represents the "token" element in the RFC 3261 grammar.
Definition Token.hxx:18
dcm! – add UnusedChecking(_enum) below;
ParserContainer< Mime > Mimes
Definition Headers.hxx:164
unsigned int uint32_t
Definition Stun.hxx:34
const Data & getMethodName(MethodTypes t)
MethodTypes getMethodType(const Data &name)