reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
RecursiveRedirect.cxx
Go to the documentation of this file.
1
#if defined(HAVE_CONFIG_H)
2
#include "config.h"
3
#endif
4
5
#include <algorithm>
6
7
#include "
resip/stack/SipMessage.hxx
"
8
#include "
resip/stack/NameAddr.hxx
"
9
#include "
repro/monkeys/RecursiveRedirect.hxx
"
10
#include "
repro/RequestContext.hxx
"
11
#include "
repro/QValueTarget.hxx
"
12
#include "
rutil/Logger.hxx
"
13
14
#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
15
16
using namespace
resip
;
17
using namespace
repro
;
18
using namespace
std;
19
20
RecursiveRedirect::RecursiveRedirect
() :
21
Processor
(
"RecursiveRedirectHandler"
)
22
{}
23
24
25
RecursiveRedirect::~RecursiveRedirect
()
26
{}
27
28
29
Processor::processor_action_t
30
RecursiveRedirect::process
(
RequestContext
& context)
31
{
32
DebugLog
(<<
"Lemur handling request: "
<< *
this
33
<<
"; reqcontext = "
<< context);
34
35
const
SipMessage
* response =
dynamic_cast<
const
SipMessage
*
>
(context.
getCurrentEvent
());
36
if
(response &&
37
response->
isResponse
() &&
38
response->
header
(
h_StatusLine
).statusCode() / 100 == 3)
39
{
40
TargetPtrList
batch;
41
for
(NameAddrs::const_iterator i=response->
header
(h_Contacts).begin();
42
i != response->
header
(h_Contacts).end(); ++i)
43
{
44
if
(i->isWellFormed() && !i->isAllContacts())
45
{
46
QValueTarget
* target =
new
QValueTarget
(*i);
47
batch.push_back(target);
48
}
49
}
50
if
(!batch.empty())
51
{
52
#ifdef __SUNPRO_CC
53
sort(batch.begin(), batch.end(),
Target::priorityMetricCompare
);
54
#else
55
batch.sort(
Target::priorityMetricCompare
);
56
#endif
57
context.
getResponseContext
().
addTargetBatch
(batch);
58
//ResponseContext should be consuming the vector
59
resip_assert
(batch.empty());
60
}
61
return
Processor::SkipAllChains
;
62
}
63
return
Processor::Continue
;
64
}
65
66
67
/* ====================================================================
68
* The Vovida Software License, Version 1.0
69
*
70
* Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
71
*
72
* Redistribution and use in source and binary forms, with or without
73
* modification, are permitted provided that the following conditions
74
* are met:
75
*
76
* 1. Redistributions of source code must retain the above copyright
77
* notice, this list of conditions and the following disclaimer.
78
*
79
* 2. Redistributions in binary form must reproduce the above copyright
80
* notice, this list of conditions and the following disclaimer in
81
* the documentation and/or other materials provided with the
82
* distribution.
83
*
84
* 3. The names "VOCAL", "Vovida Open Communication Application Library",
85
* and "Vovida Open Communication Application Library (VOCAL)" must
86
* not be used to endorse or promote products derived from this
87
* software without prior written permission. For written
88
* permission, please contact vocal@vovida.org.
89
*
90
* 4. Products derived from this software may not be called "VOCAL", nor
91
* may "VOCAL" appear in their name, without prior written
92
* permission of Vovida Networks, Inc.
93
*
94
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
95
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
96
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
97
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
98
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
99
* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
100
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
101
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
102
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
103
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
104
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
105
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
106
* DAMAGE.
107
*
108
* ====================================================================
109
*/
Logger.hxx
DebugLog
#define DebugLog(args_)
Definition
Logger.hxx:128
NameAddr.hxx
QValueTarget.hxx
RecursiveRedirect.hxx
RequestContext.hxx
resip_assert
#define resip_assert(x)
This file needs to work for both C and C++ code.
Definition
ResipAssert.h:107
SipMessage.hxx
repro::Processor
Definition
Processor.hxx:15
repro::Processor::processor_action_t
processor_action_t
Definition
Processor.hxx:29
repro::Processor::Continue
@ Continue
Definition
Processor.hxx:30
repro::Processor::SkipAllChains
@ SkipAllChains
Definition
Processor.hxx:33
repro::QValueTarget
Definition
QValueTarget.hxx:13
repro::RecursiveRedirect::~RecursiveRedirect
virtual ~RecursiveRedirect()
Definition
RecursiveRedirect.cxx:25
repro::RecursiveRedirect::process
virtual processor_action_t process(RequestContext &)
Definition
RecursiveRedirect.cxx:30
repro::RecursiveRedirect::RecursiveRedirect
RecursiveRedirect()
Definition
RecursiveRedirect.cxx:20
repro::RequestContext
Definition
RequestContext.hxx:29
repro::RequestContext::getCurrentEvent
resip::Message * getCurrentEvent()
Returns the event that we are currently working on.
Definition
RequestContext.cxx:863
repro::RequestContext::getResponseContext
ResponseContext & getResponseContext()
Definition
RequestContext.cxx:1059
repro::ResponseContext::addTargetBatch
bool addTargetBatch(TargetPtrList &targets, bool highPriority=false)
Adds a batch of Targets.
Definition
ResponseContext.cxx:123
repro::Target::priorityMetricCompare
static bool priorityMetricCompare(const Target *lhs, const Target *rhs)
Definition
Target.hxx:60
resip::SipMessage
Represents a SIP message.
Definition
SipMessage.hxx:175
resip::SipMessage::header
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
Definition
SipMessage.cxx:1382
resip::SipMessage::isResponse
bool isResponse() const
Returns true if message is a response, false otherwise.
Definition
SipMessage.hxx:734
repro
This Class is used to implement a primitive form of RPC using loose XML formatting.
Definition
AbstractDb.hxx:16
repro::TargetPtrList
std::list< Target * > TargetPtrList
Definition
Target.hxx:81
resip
dcm! – add UnusedChecking(_enum) below;
Definition
AbstractFifo.hxx:16
resip::h_StatusLine
StatusLineType h_StatusLine
Definition
Headers.cxx:348
repro
monkeys
RecursiveRedirect.cxx
Generated by
1.9.8