reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TransactionUser.cxx
Go to the documentation of this file.
4#include "rutil/Logger.hxx"
6
7#include <utility>
8
9#define RESIPROCATE_SUBSYSTEM resip::Subsystem::TRANSACTION
10
11using namespace resip;
12
15 KeepAlivePongs k) :
16 mFifo(0, 0),
17 mCongestionManager(0),
18 mRuleList(),
19 mDomainMatcher(new BasicDomainMatcher()),
20 mRegisteredForTransactionTermination(t == RegisterForTransactionTermination),
21 mRegisteredForConnectionTermination(c == RegisterForConnectionTermination),
22 mRegisteredForKeepAlivePongs(k == RegisterForKeepAlivePongs)
23{
24 // This creates a default message filter rule, which
25 // handles all sip:, sips:, and tel: requests.
26 mRuleList.push_back(MessageFilterRule());
27
28 // Set a default Fifo description - should be modified by override class to be
29 // more desriptive
30 mFifo.setDescription("TransactionUser::mFifo");
31}
32
36 KeepAlivePongs k) :
37 mFifo(0, 0),
38 mCongestionManager(0),
39 mRuleList(mfrl),
40 mDomainMatcher(new BasicDomainMatcher()),
41 mRegisteredForTransactionTermination(t == RegisterForTransactionTermination),
42 mRegisteredForConnectionTermination(c == RegisterForConnectionTermination),
43 mRegisteredForKeepAlivePongs(k == RegisterForKeepAlivePongs)
44{
45 // Set a default Fifo description - should be modified by override class to be
46 // more desriptive
47 mFifo.setDescription("TransactionUser::mFifo");
48}
49
53
54void
59
60void
61TransactionUser::postToTransactionUser(Message* msg, TimeLimitFifo<Message>::DepthUsage usage)
62{
63 mFifo.add(msg, usage);
64 //DebugLog (<< "TransactionUser::postToTransactionUser " << msg->brief() << " &=" << &mFifo << " size=" << mFifo.size());
65}
66
67unsigned int
68TransactionUser::size() const
69{
70 return mFifo.size();
71}
72
73bool
74TransactionUser::wouldAccept(TimeLimitFifo<Message>::DepthUsage usage) const
75{
76 return mFifo.wouldAccept(usage);
77}
78
79bool
81{
82 // do this for each MessageFilterRule
83 for (MessageFilterRuleList::const_iterator i = mRuleList.begin() ;
84 i != mRuleList.end() ; ++i)
85 {
86 DebugLog(<< "TransactionUser::isForMe: TU=" << name() << ", Checking rule... : " << msg.brief());
87 if (i->matches(msg))
88 {
89 DebugLog(<< "TransactionUser::isForMe: TU=" << name() << ", Match! : " << msg.brief());
90 return true;
91 }
92 }
93 DebugLog(<< "TransactionUser::isForMe: TU=" << name() << ", No matching rule found : " << msg.brief());
94 return false;
95}
96
97bool
99{
100 return mDomainMatcher->isMyDomain(domain);
101}
102
103void
105{
106 mDomainMatcher->addDomain(domain);
107}
108
109void
111{
112 mDomainMatcher->removeDomain(domain);
113}
114
115void
116TransactionUser::setDomainMatcher(std::shared_ptr<DomainMatcher> domainMatcher) noexcept
117{
118 mDomainMatcher = domainMatcher;
119}
120
122TransactionUser::encode(EncodeStream& strm) const
123{
124 strm << "TU: " << name() << " size=" << mFifo.size();
125 return strm;
126}
127
128void
130{
131 mRuleList = rules;
132 MessageFilterRuleList::iterator it = mRuleList.begin();
133 for(;it!=mRuleList.end();it++)
134 {
135 it->setTransactionUser(this);
136 }
137}
138
139bool
141{
142 return mRegisteredForTransactionTermination;
143}
144
145bool
147{
148 return mRegisteredForConnectionTermination;
149}
150
151bool
153{
154 return mRegisteredForKeepAlivePongs;
155}
156
158resip::operator<<(EncodeStream& strm, const resip::TransactionUser& tu)
159{
160 tu.encode(strm);
161 return strm;
162}
163
164/* ====================================================================
165 * The Vovida Software License, Version 1.0
166 *
167 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
168 *
169 * Redistribution and use in source and binary forms, with or without
170 * modification, are permitted provided that the following conditions
171 * are met:
172 *
173 * 1. Redistributions of source code must retain the above copyright
174 * notice, this list of conditions and the following disclaimer.
175 *
176 * 2. Redistributions in binary form must reproduce the above copyright
177 * notice, this list of conditions and the following disclaimer in
178 * the documentation and/or other materials provided with the
179 * distribution.
180 *
181 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
182 * and "Vovida Open Communication Application Library (VOCAL)" must
183 * not be used to endorse or promote products derived from this
184 * software without prior written permission. For written
185 * permission, please contact vocal@vovida.org.
186 *
187 * 4. Products derived from this software may not be called "VOCAL", nor
188 * may "VOCAL" appear in their name, without prior written
189 * permission of Vovida Networks, Inc.
190 *
191 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
192 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
193 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
194 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
195 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
196 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
197 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
198 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
199 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
200 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
201 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
202 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
203 * DAMAGE.
204 *
205 * ====================================================================
206 *
207 * This software consists of voluntary contributions made by Vovida
208 * Networks, Inc. and many individuals on behalf of Vovida Networks,
209 * Inc. For more information on Vovida Networks, Inc., please see
210 * <http://www.vovida.org/>.
211 *
212 */
#define DebugLog(args_)
Definition Logger.hxx:128
static void usage(void)
Definition adig.c:755
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
size_type size() const noexcept
Returns the number of bytes in this Data.
Definition Data.hxx:599
The base-class used for message-passing.
Definition Message.hxx:21
virtual Brief brief() const
return a facet for brief encoding of message
Definition Message.cxx:16
Represents a SIP message.
The base-class for an RFC 3261 Transaction User.
TransactionUser(TransactionTermination t=DoNotRegisterForTransactionTermination, ConnectionTermination c=DoNotRegisterForConnectionTermination, KeepAlivePongs k=DoNotRegisterForKeepAlivePongs)
Constructor that specifies whether this TransactionUser needs to hear about the completion of transac...
TimeLimitFifo< Message > mFifo
This TransactionUser's fifo.
void setMessageFilterRuleList(MessageFilterRuleList &rules)
Sets this TransactionUser's MessageFilterRuleList.
bool isRegisteredForConnectionTermination() const
virtual bool isForMe(const SipMessage &msg) const
Returns true iff this TransactionUser should process msg.
void addDomain(const Data &domain)
Adds a domain to the set of domains that this TransactionUser is responsible for.
bool isMyDomain(const Data &domain) const
Returns true iff domain matches one of the domains that this TransactionUser is responsible for.
virtual const Data & name() const =0
Return the name of this TransactionUser.
void post(Message *msg)
Posts a Message to this TransactionUser's fifo.
virtual EncodeStream & encode(EncodeStream &strm) const
Encodes the name of this TransactionUser (as specified by name()), and the current depth of its fifo.
void removeDomain(const Data &domain)
Removes a domain from the set of domains that this TransactionUser is responsible for.
void setDomainMatcher(std::shared_ptr< DomainMatcher > domainMatcher) noexcept
Replaces the default DomainMatcher.
bool isRegisteredForTransactionTermination() const
bool isRegisteredForKeepAlivePongs() const
dcm! – add UnusedChecking(_enum) below;
std::vector< MessageFilterRule > MessageFilterRuleList
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
#define EncodeStream