reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Proxy.hxx
Go to the documentation of this file.
1#if !defined(RESIP_PROXY_HXX)
2#define RESIP_PROXY_HXX
3
4#include <memory>
5#include <map>
6
9#include "rutil/HashMap.hxx"
10#include "rutil/Mutex.hxx"
11#include "rutil/ThreadIf.hxx"
16#include "repro/ProxyConfig.hxx"
17
18namespace resip
19{
20class SipStack;
21class Transport;
22}
23
24namespace repro
25{
26
27class UserStore;
28class ProcessorChain;
29
31{
32public:
34 virtual ~OptionsHandler() {}
35
36 // return true if handled and response should be sent, false to route normally through proxy
38};
39
41{
42 public:
44 ProcessorChain& requestP, // monkeys
45 ProcessorChain& responseP, // lemurs
46 ProcessorChain& targetP); // baboons
48};
49
51{
52 public:
58 virtual ~Proxy();
59
60 // Crypto Random Key for Salting Flow Token HMACs
65 static resip::KeyValueStore::Key allocateGlobalKeyValueStoreKey(); // should only be called at static initialization time
66 static resip::KeyValueStore::Key allocateRequestKeyValueStoreKey(); // should only be called at static initialization time
67 static resip::KeyValueStore::Key allocateTargetKeyValueStoreKey(); // should only be called at static initialization time
68
69 // Note: These are not thread safe and should be called before run() only
70 void setOptionsHandler(OptionsHandler* handler) noexcept;
71 void setRequestContextFactory(std::unique_ptr<RequestContextFactory> requestContextFactory) noexcept;
72
73 virtual bool isShutDown() const;
74 virtual void thread();
75
76 virtual bool isMyUri(const resip::Uri& uri) const;
79 const resip::NameAddr& getRecordRoute(unsigned int transportKey, bool* transportSpecific = 0) const;
80 bool isUriTransportRecordRoute(const resip::Uri& uri) const;
83
86
88 resip::SipStack& getStack() noexcept { return mStack; }
90 void send(const resip::SipMessage& msg);
91 void addClientTransaction(const resip::Data& transactionId, RequestContext* rc);
92
93 void postTimerC(std::unique_ptr<TimerCMessage> tc);
94
95 void postMS(std::unique_ptr<resip::ApplicationMessage> msg, int msec);
96
97 bool compressionEnabled() const;
98
101
102 void setServerText(const resip::Data& text) { mServerText = text; }
103 const resip::Data& getServerText() const { return mServerText; }
104
105 // Accessor for global extensible state storage for monkeys
107
108 void doSessionAccounting(const resip::SipMessage& sip, bool received, RequestContext& context);
110
111 virtual void processUnknownMessage(resip::Message* msg);
112
113 protected:
114 virtual const resip::Data& name() const;
115
119 typedef std::map<unsigned int, resip::NameAddr> TransportRecordRouteMap;
122
129
130 // needs to be a reference since parent owns it
134
147
149 std::set<resip::Data> mSupportedOptions;
151 std::unique_ptr<RequestContextFactory> mRequestContextFactory;
152
156
157 // disabled
159};
160}
161#endif
162
163/* ====================================================================
164 * The Vovida Software License, Version 1.0
165 *
166 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
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 */
Wraps your platform's implementation of hash_map, hash_multimap, and hash_set.
virtual ~OptionsHandler()
Definition Proxy.hxx:34
virtual bool onOptionsRequest(const resip::SipMessage &request, resip::SipMessage &response)=0
virtual bool isMyUri(const resip::Uri &uri) const
Definition Proxy.cxx:600
const resip::NameAddr & getRecordRoute(unsigned int transportKey, bool *transportSpecific=0) const
Definition Proxy.cxx:664
ProxyConfig & getConfig() noexcept
Definition Proxy.hxx:89
void setRecordRouteForced(bool forced)
Definition Proxy.hxx:82
virtual bool isShutDown() const
Definition Proxy.cxx:143
bool mRegistrationAccountingEnabled
Definition Proxy.hxx:154
virtual ~Proxy()
Definition Proxy.cxx:122
void doSessionAccounting(const resip::SipMessage &sip, bool received, RequestContext &context)
Definition Proxy.cxx:703
void addSupportedOption(const resip::Data &option)
Definition Proxy.cxx:691
void removeSupportedOption(const resip::Data &option)
Definition Proxy.cxx:697
virtual const resip::Data & name() const
Return the name of this TransactionUser.
Definition Proxy.cxx:593
resip::KeyValueStore & getKeyValueStore()
Definition Proxy.hxx:106
std::map< unsigned int, resip::NameAddr > TransportRecordRouteMap
Definition Proxy.hxx:119
static resip::KeyValueStore::KeyValueStoreKeyAllocator * getRequestKeyValueStoreKeyAllocator()
Definition Proxy.cxx:41
ProcessorChain & mResponseProcessorChain
Definition Proxy.hxx:132
HashMap< resip::Data, RequestContext *, resip::KeyedDataHash > RequestContextMap
a map from transaction id to RequestContext.
Definition Proxy.hxx:144
void removeTransportRecordRoute(unsigned int transportKey)
Definition Proxy.cxx:636
static resip::KeyValueStore::KeyValueStoreKeyAllocator * getGlobalKeyValueStoreKeyAllocator()
Definition Proxy.cxx:35
bool isPAssertedIdentityProcessingEnabled()
Definition Proxy.hxx:84
UserStore & getUserStore() noexcept
Definition Proxy.cxx:149
TransportRecordRouteMap mTransportRecordRoutes
Definition Proxy.hxx:120
std::unique_ptr< RequestContextFactory > mRequestContextFactory
Definition Proxy.hxx:151
static resip::Data FlowTokenSalt
Definition Proxy.hxx:61
resip::Data mServerText
Definition Proxy.hxx:126
OptionsHandler * mOptionsHandler
Definition Proxy.hxx:150
void setServerText(const resip::Data &text)
Definition Proxy.hxx:102
resip::NameAddr mRecordRoute
Definition Proxy.hxx:118
void doRegistrationAccounting(repro::AccountingCollector::RegistrationEvent regEvent, const resip::SipMessage &sip)
Definition Proxy.cxx:713
static resip::KeyValueStore::Key allocateRequestKeyValueStoreKey()
Definition Proxy.cxx:58
void addTransportRecordRoute(unsigned int transportKey, const resip::NameAddr &recordRoute)
Definition Proxy.cxx:630
ProcessorChain & mRequestProcessorChain
Definition Proxy.hxx:131
bool mPAssertedIdentityProcessing
Definition Proxy.hxx:124
bool compressionEnabled() const
Definition Proxy.cxx:685
static resip::KeyValueStore::Key allocateGlobalKeyValueStoreKey()
Definition Proxy.cxx:53
ProcessorChain & mTargetProcessorChain
Definition Proxy.hxx:133
bool isUriTransportRecordRoute(const resip::Uri &uri) const
Definition Proxy.cxx:643
resip::SipStack & getStack() noexcept
Definition Proxy.hxx:88
bool mSessionAccountingEnabled
Definition Proxy.hxx:153
void setOptionsHandler(OptionsHandler *handler) noexcept
Definition Proxy.cxx:131
void setRequestContextFactory(std::unique_ptr< RequestContextFactory > requestContextFactory) noexcept
Definition Proxy.cxx:137
void postTimerC(std::unique_ptr< TimerCMessage > tc)
Definition Proxy.cxx:577
std::set< resip::Data > mSupportedOptions
Definition Proxy.hxx:149
resip::Mutex mTransportRecordRouteMutex
Definition Proxy.hxx:121
void postMS(std::unique_ptr< resip::ApplicationMessage > msg, int msec)
Definition Proxy.cxx:587
void send(const resip::SipMessage &msg)
Definition Proxy.cxx:557
resip::KeyValueStore mKeyValueStore
Definition Proxy.hxx:128
const resip::Data & getServerText() const
Definition Proxy.hxx:103
AccountingCollector * mAccountingCollector
Definition Proxy.hxx:155
virtual void thread()
Definition Proxy.cxx:155
ProxyConfig & mConfig
Definition Proxy.hxx:117
bool mRecordRouteForced
Definition Proxy.hxx:123
bool isNeverStripProxyAuthorizationHeadersEnabled()
Definition Proxy.hxx:85
bool getRecordRouteForced() const
Definition Proxy.hxx:81
UserStore & mUserStore
Definition Proxy.hxx:148
RequestContextMap mServerRequestContexts
Definition Proxy.hxx:146
static resip::KeyValueStore::KeyValueStoreKeyAllocator * getTargetKeyValueStoreKeyAllocator()
Definition Proxy.cxx:47
resip::SipStack & mStack
Definition Proxy.hxx:116
RequestContextMap mClientRequestContexts
Definition Proxy.hxx:145
bool mNeverStripProxyAuthorizationHeaders
Definition Proxy.hxx:125
static resip::KeyValueStore::Key allocateTargetKeyValueStoreKey()
Definition Proxy.cxx:63
void addClientTransaction(const resip::Data &transactionId, RequestContext *rc)
Definition Proxy.cxx:563
virtual void processUnknownMessage(resip::Message *msg)
Definition Proxy.cxx:550
virtual ~RequestContextFactory()
Definition Proxy.hxx:47
virtual RequestContext * createRequestContext(Proxy &proxy, ProcessorChain &requestP, ProcessorChain &responseP, ProcessorChain &targetP)
Definition Proxy.cxx:69
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
The base-class used for message-passing.
Definition Message.hxx:21
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Definition NameAddr.hxx:19
Represents a SIP message.
This is the primary point of interaction between the app-layer and the stack.
Definition SipStack.hxx:160
A wrapper class to create and spawn a thread.
Definition ThreadIf.hxx:54
The base-class for an RFC 3261 Transaction User.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
Definition Uri.hxx:22
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
Definition Mutex.hxx:37
void list()
Definition userAdmin.cxx:66