reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
StrictRouteFixup.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
8#include "repro/Proxy.hxx"
9
11
12#include "rutil/Logger.hxx"
13#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
14
15using namespace resip;
16using namespace repro;
17using namespace std;
18
19
21 Processor("StrictRouteFixup")
22{}
23
26
37{
38 DebugLog(<< "Monkey handling request: " << *this << "; reqcontext = " << context);
39
40 resip::SipMessage& request = context.getOriginalRequest();
41
42 if (request.exists(h_Routes) && !request.header(h_Routes).empty())
43 {
44 if(!request.header(h_Routes).front().isWellFormed())
45 {
46 // Garbage topmost Route, reject
47 SipMessage resp;
48 resip::Helper::makeResponse(resp, request, 400, "Garbage Route Header.");
49 context.sendResponse(resp);
50 return SkipAllChains;
51 }
52
53 // Do any required session accounting
54 context.getProxy().doSessionAccounting(request, true /* received */, context);
55
56 // Will cancel any active transactions (ideally there should be none)
57 // and terminate any pending transactions.
59 std::unique_ptr<Target> target(new Target(request.header(h_RequestLine).uri()));
60 if (context.isTopRouteFlowTupleSet())
61 {
62 target->rec().mReceivedFrom = context.getTopRouteFlowTuple();
63 target->rec().mUseFlowRouting = true;
64 }
65 context.getResponseContext().addTarget(std::move(target));
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 *
116 * This software consists of voluntary contributions made by Vovida
117 * Networks, Inc. and many individuals on behalf of Vovida Networks,
118 * Inc. For more information on Vovida Networks, Inc., please see
119 * <http://www.vovida.org/>.
120 *
121 */
#define DebugLog(args_)
Definition Logger.hxx:128
void doSessionAccounting(const resip::SipMessage &sip, bool received, RequestContext &context)
Definition Proxy.cxx:703
resip::SipMessage & getOriginalRequest()
Returns the SipMessage associated with the server transaction.
ResponseContext & getResponseContext()
resip::Tuple & getTopRouteFlowTuple()
void sendResponse(resip::SipMessage &response)
bool cancelAllClientTransactions(const resip::Tokens *reasons=0)
Cancels all active client transactions.
resip::Data addTarget(const resip::NameAddr &target, bool beginImmediately=false)
Adds this Target as a SimpleTarget to the collection of Targets.
virtual processor_action_t process(RequestContext &)
This monkey looks to see if the request has a Route header (the RequestContext has already done prepr...
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
bool isWellFormed() const
Returns true iff this element was parsed successfully, according to the implementation of parse().
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.
bool exists(const HeaderBase &headerType) const
Returns true if the given header field is present, false otherwise.
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