reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ExtendedDomainMatcher.cxx
Go to the documentation of this file.
1#include "rutil/Data.hxx"
3
4#define RESIPROCATE_SUBSYSTEM resip::Subsystem::SIP
5
6using namespace resip;
7
9 mDomainSuffixList()
10{
11}
12
16
17bool
19{
21 {
22 return true;
23 }
24
25 if (mDomainSuffixList.empty())
26 {
27 return false;
28 }
29
30 // Domain search should be case insensitive - search in lowercase only
31 Data _domain(domain);
32 _domain.lowercase();
33
34 static const Data dot(".");
35 Data::size_type i = 0;
36 for(i = _domain.find(dot, i); i < _domain.size() && i != Data::npos; i++)
37 {
38 Data _search = _domain.substr(i);
39 if (mDomainSuffixList.find(_search) != mDomainSuffixList.end())
40 {
41 return true;
42 }
43 }
44 return false;
45}
46
47void
49{
50 // Domain search should be case insensitive - store in lowercase only
51 mDomainSuffixList.emplace(Data(domainSuffix).lowercase());
52}
53
54void
56{
57 DomainSuffixList::iterator it = mDomainSuffixList.find(Data(domainSuffix).lowercase());
58 if (it != mDomainSuffixList.end())
59 {
60 mDomainSuffixList.erase(it);
61 }
62}
63
64/* ====================================================================
65 *
66 * Copyright 2017 Daniel Pocock http://danielpocock.com All rights reserved.
67 *
68 * Redistribution and use in source and binary forms, with or without
69 * modification, are permitted provided that the following conditions
70 * are met:
71 *
72 * 1. Redistributions of source code must retain the above copyright
73 * notice, this list of conditions and the following disclaimer.
74 *
75 * 2. Redistributions in binary form must reproduce the above copyright
76 * notice, this list of conditions and the following disclaimer in
77 * the documentation and/or other materials provided with the
78 * distribution.
79 *
80 * 3. Neither the name of the author(s) nor the names of any contributors
81 * may be used to endorse or promote products derived from this software
82 * without specific prior written permission.
83 *
84 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
85 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
87 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
88 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 * SUCH DAMAGE.
95 *
96 * ====================================================================
97 *
98 *
99 */
100
virtual bool isMyDomain(const Data &domain) const
Returns true iff domain matches one of the domains that this TransactionUser is responsible for.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Data substr(size_type first, size_type count=Data::npos) const
Copies a portion of this Data into a new Data.
Definition Data.cxx:1932
Data & lowercase()
Converts this Data to lowercase.
Definition Data.cxx:1635
size_t size_type
Definition Data.hxx:94
size_type size() const noexcept
Returns the number of bytes in this Data.
Definition Data.hxx:599
size_type find(const Data &match, size_type start=0) const
Finds a specified sequence of bytes in this Data.
Definition Data.cxx:1947
static const size_type npos
Represents an impossible position; returned to indicate failure to find.
Definition Data.hxx:887
virtual bool isMyDomain(const Data &domain) const
Returns true iff domain matches one of the domains that this TransactionUser is responsible for.
virtual void addDomainSuffix(const Data &domainSuffix)
virtual void removeDomainSuffix(const Data &domainSuffix)
dcm! – add UnusedChecking(_enum) below;