reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
SimpleStaticRoute.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
5#include "repro/Proxy.hxx"
12#include "rutil/Inserter.hxx"
13#include "rutil/Logger.hxx"
14
15#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
16
17using namespace resip;
18using namespace repro;
19using namespace std;
20
21
23 Processor("SimpleStaticRoute")
24{
25 std::vector<Data> routeSet;
26 config.getConfigValue("Routes", routeSet);
27
28 resip::NameAddrs routes;
29 for (std::vector<Data>::iterator i=routeSet.begin();
30 i != routeSet.end(); ++i)
31 {
32 try
33 {
35 }
36 catch(BaseException& ex)
37 {
38 WarningLog(<< "SimpleStaticRoute: Skipping invalid route (" << *i << "): " << ex);
39 }
40 }
41}
42
45
46
49{
50 DebugLog(<< "Monkey handling request: " << *this
51 << "; reqcontext = " << context);
52
53 resip::SipMessage& request = context.getOriginalRequest();
54 const Uri& uri = request.header(h_RequestLine).uri();
55 if (context.getProxy().isMyUri(uri))
56 {
57 const resip::NameAddrs& current = request.header(h_Routes);
59 for (resip::NameAddrs::const_iterator i=current.begin(); i != current.end(); ++i)
60 {
61 replace.push_back(*i);
62 }
63 request.header(h_Routes) = replace;
65
66 InfoLog (<< "New route set is " << Inserter(request.header(h_Routes)));
67 }
68
70}
71
72
73/* ====================================================================
74 * The Vovida Software License, Version 1.0
75 *
76 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
77 *
78 * Redistribution and use in source and binary forms, with or without
79 * modification, are permitted provided that the following conditions
80 * are met:
81 *
82 * 1. Redistributions of source code must retain the above copyright
83 * notice, this list of conditions and the following disclaimer.
84 *
85 * 2. Redistributions in binary form must reproduce the above copyright
86 * notice, this list of conditions and the following disclaimer in
87 * the documentation and/or other materials provided with the
88 * distribution.
89 *
90 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
91 * and "Vovida Open Communication Application Library (VOCAL)" must
92 * not be used to endorse or promote products derived from this
93 * software without prior written permission. For written
94 * permission, please contact vocal@vovida.org.
95 *
96 * 4. Products derived from this software may not be called "VOCAL", nor
97 * may "VOCAL" appear in their name, without prior written
98 * permission of Vovida Networks, Inc.
99 *
100 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
101 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
102 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
103 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
104 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
105 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
106 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
107 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
108 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
109 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
110 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
111 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
112 * DAMAGE.
113 *
114 * ====================================================================
115 */
#define DebugLog(args_)
Definition Logger.hxx:128
#define InfoLog(args_)
Definition Logger.hxx:131
#define WarningLog(args_)
Definition Logger.hxx:134
virtual bool isMyUri(const resip::Uri &uri) const
Definition Proxy.cxx:600
resip::SipMessage & getOriginalRequest()
Returns the SipMessage associated with the server transaction.
ResponseContext & getResponseContext()
resip::Data addTarget(const resip::NameAddr &target, bool beginImmediately=false)
Adds this Target as a SimpleTarget to the collection of Targets.
SimpleStaticRoute(ProxyConfig &config)
virtual processor_action_t process(RequestContext &)
The abstract base-class for all exceptions thrown by resip code.
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Definition NameAddr.hxx:19
iterator end()
Returns an iterator pointing to the last header field value.
iterator begin()
Returns an iterator pointing to the first header field value.
void push_back(const T &t)
Inserts a header field value at the back of this container.
const Uri & uri() const
bool getConfigValue(const resip::Data &name, resip::Uri &value)
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
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
InserterClass< T > Inserter(const T &t)
Templatized function to construct an instance of InserterClass for a container to be inserted.
Definition Inserter.hxx:312
RequestLineType h_RequestLine
Definition Headers.cxx:347