/[resiprocate]/main/sip/resiprocate/TransactionUser.cxx
ViewVC logotype

Contents of /main/sip/resiprocate/TransactionUser.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4335 - (show annotations) (download)
Tue Apr 12 21:40:15 2005 UTC (14 years, 9 months ago) by jason
File size: 5177 byte(s)
merged changes from b-dev-repro from rev 4155:4334
used cmd: svn merge -r 4155:4334 https://scm.sipfoundry.org/rep/ resiprocate/branches/b-dev-repro-20050401

1 #include "resiprocate/TransactionUser.hxx"
2 #include "resiprocate/MessageFilterRule.hxx"
3 #include "resiprocate/os/Logger.hxx"
4
5 #define RESIPROCATE_SUBSYSTEM resip::Subsystem::TRANSACTION
6
7 using namespace resip;
8
9 TransactionUser::TransactionUser() : mFifo(0, 0)
10 {
11 // This creates a default message filter rule, which
12 // handles all sip: and sips: requests.
13 mRuleList.push_back(MessageFilterRule());
14 }
15
16 TransactionUser::TransactionUser(MessageFilterRuleList &mfrl)
17 : mFifo(0, 0), mRuleList(mfrl)
18 {
19 }
20
21
22 TransactionUser::~TransactionUser()
23 {
24 }
25
26 void
27 TransactionUser::post(Message* msg)
28 {
29 mFifo.add(msg, TimeLimitFifo<Message>::InternalElement);
30 }
31
32 void
33 TransactionUser::postToTransactionUser(Message* msg, TimeLimitFifo<Message>::DepthUsage usage)
34 {
35 mFifo.add(msg, usage);
36 //DebugLog (<< "TransactionUser::postToTransactionUser " << msg->brief() << " &=" << &mFifo << " size=" << mFifo.size());
37 }
38
39 unsigned int
40 TransactionUser::size() const
41 {
42 return mFifo.size();
43 }
44
45 bool
46 TransactionUser::wouldAccept(TimeLimitFifo<Message>::DepthUsage usage) const
47 {
48 return mFifo.wouldAccept(usage);
49 }
50
51 bool
52 TransactionUser::isForMe(const SipMessage& msg) const
53 {
54 DebugLog (<< "Checking if " << msg.brief() << " is for me");
55 // do this for each MessageFilterRule
56 for (MessageFilterRuleList::const_iterator i = mRuleList.begin() ;
57 i != mRuleList.end() ; ++i)
58 {
59 DebugLog (<< "Checking rule...");
60 if (i->matches(msg))
61 {
62 DebugLog (<< "Match!");
63 return true;
64 }
65 }
66 DebugLog (<< "No matching rule found");
67 return false;
68 }
69
70 bool
71 TransactionUser::isMyDomain(const Uri& uri) const
72 {
73 for (DomainList::const_iterator it = mDomainList.begin();
74 it != mDomainList.end(); it++)
75 {
76 if(uri.host() == it->host() && uri.port() == it->port())
77 {
78 return true;
79 }
80 }
81 return false;
82 }
83
84 bool
85 TransactionUser::isMyDomain(const Data& domain) const
86 {
87 for (DomainList::const_iterator it = mDomainList.begin();
88 it != mDomainList.end(); it++)
89 {
90 if(domain == it->host())
91 {
92 return true;
93 }
94 }
95 return false;
96 }
97
98 void TransactionUser::addDomain(const Data& domain)
99 {
100 Uri u;
101 u.host() = domain;
102 mDomainList.push_back(u);
103 }
104
105 void TransactionUser::addDomain(const Data& domain, int port)
106 {
107 Uri u;
108 u.host() = domain;
109 u.port() = port;
110 mDomainList.push_back(u);
111 }
112
113 std::ostream&
114 TransactionUser::encode(std::ostream& strm) const
115 {
116 strm << "TU: " << name() << " size=" << mFifo.size();
117 return strm;
118 }
119
120 void
121 TransactionUser::setMessageFilterRuleList(MessageFilterRuleList &rules)
122 {
123 mRuleList = rules;
124 }
125
126 std::ostream&
127 resip::operator<<(std::ostream& strm, const resip::TransactionUser& tu)
128 {
129 tu.encode(strm);
130 return strm;
131 }
132
133 /* ====================================================================
134 * The Vovida Software License, Version 1.0
135 *
136 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
137 *
138 * Redistribution and use in source and binary forms, with or without
139 * modification, are permitted provided that the following conditions
140 * are met:
141 *
142 * 1. Redistributions of source code must retain the above copyright
143 * notice, this list of conditions and the following disclaimer.
144 *
145 * 2. Redistributions in binary form must reproduce the above copyright
146 * notice, this list of conditions and the following disclaimer in
147 * the documentation and/or other materials provided with the
148 * distribution.
149 *
150 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
151 * and "Vovida Open Communication Application Library (VOCAL)" must
152 * not be used to endorse or promote products derived from this
153 * software without prior written permission. For written
154 * permission, please contact vocal@vovida.org.
155 *
156 * 4. Products derived from this software may not be called "VOCAL", nor
157 * may "VOCAL" appear in their name, without prior written
158 * permission of Vovida Networks, Inc.
159 *
160 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
161 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
162 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
163 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
164 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
165 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
166 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
167 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
168 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
169 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
170 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
171 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
172 * DAMAGE.
173 *
174 * ====================================================================
175 *
176 * This software consists of voluntary contributions made by Vovida
177 * Networks, Inc. and many individuals on behalf of Vovida Networks,
178 * Inc. For more information on Vovida Networks, Inc., please see
179 * <http://www.vovida.org/>.
180 *
181 */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27