reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
GruuMonkey.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
9#include "repro/Proxy.hxx"
10#include "resip/dum/RegistrationPersistence
11#include <ostream>
12
13#include "rutil/Logger.hxx"
14#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
15
16using namespace resip;
17using namespace repro;
18using namespace std;
19
22
25
28{
29 DebugLog(<< "Monkey handling request: " << *this
30 << "; reqcontext = " << context);
31
32 resip::SipMessage& request = context.getOriginalRequest();
33
34 // sip:alice;uuid:urn:00000-000-8....@example.com;user=gruu
35 //
36 // Looking for a Request URI which contains ";user=gruu"
37
38
39 // This monkey looks for a Request URIs such as:
40 // sip:alice@example.com;opaque=uuid:urn:0000-000-89akkskhnasd
41 //
42 // Looking for a Request URI which contains an opaque parameter
43
44
45 Uri reqUri = request.header(h_RequestLine).uri();
46
47 if (reqUri.exists(p_opaque))
48 {
49 Uri aor = reqUri.getAor();
50 Data instance = reqUri.param(p_opaque);
51
52 // find the GRUU from the AOR and instance
53
54 if (!mStore.mUserStore.aorExists(aor))
55 {
56 // send 404 Not Found
57 resip::SipMessage response;
58 InfoLog (<< *this << ": no AOR matching this GRUU found. Gruu: <" << uri << ">, sending 404");
59 Helper::makeResponse(response, request, 404);
60 context.sendResponse(response);
62 }
63
64 if (mStore.isContactRegistered(reqUri.getAor(), reqUri.param(p_opaque)))
65 {
66 // grab the grid from the Request URI
67 Data grid;
68 if (reqUri.exists(p_grid))
69 {
70 grid = reqUri.params(p_grid);
71 }
72
73 // walk through the entries that match the instance and aor
74 RegistrationPersistenceManager::ContactList records = mStore.getRegistrationBinding(aor)->mContacts;
75 RegistrationPersistenceManager::ContactList::const_iterator i;
76
77 for (i = records.begin(); i != records.end(); ++i)
78 {
79 if (i->mInstance == reqUri.param(p_opaque))
80 {
81 NameAddr newTarget = i->mContact.uri();
82 // strip caller prefs
83 // strip instance and flowId
84 // preserve q-values
85 if (i->mContact.exists(p_q))
86 {
87 newTarget.param(p_q) = i->mContact.param(p_q);
88 }
89
90 // copy the grid over from the request URI
91 if (!grid.empty())
92 {
93 newTarget.uri().param(p_grid) = grid;
94 }
95
96 // populate the targetSet with appropriate tuple (or sessionId) and URI combo
97 // !rwm! TODO add a version of addTarget that take the server session id or the Path
98 // and only uses sendOverExistingConnection
99 if (i->mSipPath.empty())
100 {
101 resip_assert(i->mServerSessionId) // make sure there is either a Path or a sessionId
102 context.addTarget(newTarget, i->mServerSessionId);
103 }
104 else
105 {
106 context.addTarget(newTarget, i->mSipPath);
107 }
108 }
109
110
111 InfoLog (<< "Sending to requri: " << request.header(h_RequestLine).uri());
112 // skip the rest of the monkeys
114 }
115 else // nobody home with that GRUU
116 {
117 // send 480 Temporarily Unavailable
118 resip::SipMessage response;
119 InfoLog (<< *this << ": no contacts matching this GRUU found. Gruu: <" << uri << ">, sending 480");
120 Helper::makeResponse(response, request, 480);
121 context.sendResponse(response);
123 }
124 }
125 }
126 return Processor::Continue;
127}
128
129
130void
131GruuMonkey::dump(std::ostream &os) const
132{
133 os << "Gruu Monkey" << std::endl;
134}
135
136
137/* ====================================================================
138 * The Vovida Software License, Version 1.0
139 *
140 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
141 *
142 * Redistribution and use in source and binary forms, with or without
143 * modification, are permitted provided that the following conditions
144 * are met:
145 *
146 * 1. Redistributions of source code must retain the above copyright
147 * notice, this list of conditions and the following disclaimer.
148 *
149 * 2. Redistributions in binary form must reproduce the above copyright
150 * notice, this list of conditions and the following disclaimer in
151 * the documentation and/or other materials provided with the
152 * distribution.
153 *
154 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
155 * and "Vovida Open Communication Application Library (VOCAL)" must
156 * not be used to endorse or promote products derived from this
157 * software without prior written permission. For written
158 * permission, please contact vocal@vovida.org.
159 *
160 * 4. Products derived from this software may not be called "VOCAL", nor
161 * may "VOCAL" appear in their name, without prior written
162 * permission of Vovida Networks, Inc.
163 *
164 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
165 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
166 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
167 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
168 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
169 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
170 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
171 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
172 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
173 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
174 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
175 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
176 * DAMAGE.
177 *
178 * ====================================================================
179 *
180 * This software consists of voluntary contributions made by Vovida
181 * Networks, Inc. and many individuals on behalf of Vovida Networks,
182 * Inc. For more information on Vovida Networks, Inc., please see
183 * <http://www.vovida.org/>.
184 *
185 */
#define DebugLog(args_)
Definition Logger.hxx:128
#define InfoLog(args_)
Definition Logger.hxx:131
#define resip_assert(x)
This file needs to work for both C and C++ code.
virtual void dump(std::ostream &os) const
virtual processor_action_t process(RequestContext &)
virtual ~GruuMonkey()
resip::SipMessage & getOriginalRequest()
Returns the SipMessage associated with the server transaction.
void sendResponse(resip::SipMessage &response)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
bool empty() const noexcept
Checks whether the Data is empty.
Definition Data.hxx:591
static void makeResponse(SipMessage &response, const SipMessage &request, int responseCode, const Data &reason=Data::Empty, const Data &hostname=Data::Empty, const Data &warning=Data::Empty)
Make a response to a provided request.
Definition Helper.cxx:412
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.
const Uri & uri() const
Represents a SIP message.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
Definition Uri.hxx:22
Data getAor() const
Definition Uri.cxx:1095
bool exists(const Param< Uri > &paramType) const
Definition Uri.cxx:1701
const Data & param(const ExtensionParameter &param) const
Const accessor for non-natively-supported parameter types.
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
RequestLineType h_RequestLine
Definition Headers.cxx:347