|
reSIProcate/repro
9694
|
00001 #if defined(HAVE_CONFIG_H) 00002 #include "config.h" 00003 #endif 00004 00005 #include <algorithm> 00006 00007 #include "resip/stack/SipMessage.hxx" 00008 #include "resip/stack/NameAddr.hxx" 00009 #include "repro/monkeys/RecursiveRedirect.hxx" 00010 #include "repro/RequestContext.hxx" 00011 #include "repro/QValueTarget.hxx" 00012 #include "rutil/Logger.hxx" 00013 00014 #define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO 00015 00016 using namespace resip; 00017 using namespace repro; 00018 using namespace std; 00019 00020 RecursiveRedirect::RecursiveRedirect() : 00021 Processor("RecursiveRedirectHandler") 00022 {} 00023 00024 00025 RecursiveRedirect::~RecursiveRedirect() 00026 {} 00027 00028 00029 Processor::processor_action_t 00030 RecursiveRedirect::process(RequestContext& context) 00031 { 00032 DebugLog(<< "Lemur handling request: " << *this 00033 << "; reqcontext = " << context); 00034 00035 const SipMessage* response = dynamic_cast<const SipMessage*>(context.getCurrentEvent()); 00036 if (response && 00037 response->isResponse() && 00038 response->header(h_StatusLine).statusCode() / 100 == 3) 00039 { 00040 TargetPtrList batch; 00041 for (NameAddrs::const_iterator i=response->header(h_Contacts).begin(); 00042 i != response->header(h_Contacts).end(); ++i) 00043 { 00044 if(i->isWellFormed() && !i->isAllContacts()) 00045 { 00046 QValueTarget* target = new QValueTarget(*i); 00047 batch.push_back(target); 00048 } 00049 } 00050 if(!batch.empty()) 00051 { 00052 #ifdef __SUNPRO_CC 00053 sort(batch.begin(), batch.end(), Target::priorityMetricCompare); 00054 #else 00055 batch.sort(Target::priorityMetricCompare); 00056 #endif 00057 context.getResponseContext().addTargetBatch(batch); 00058 //ResponseContext should be consuming the vector 00059 assert(batch.empty()); 00060 } 00061 return Processor::SkipAllChains; 00062 } 00063 return Processor::Continue; 00064 } 00065 00066 00067 /* ==================================================================== 00068 * The Vovida Software License, Version 1.0 00069 * 00070 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00071 * 00072 * Redistribution and use in source and binary forms, with or without 00073 * modification, are permitted provided that the following conditions 00074 * are met: 00075 * 00076 * 1. Redistributions of source code must retain the above copyright 00077 * notice, this list of conditions and the following disclaimer. 00078 * 00079 * 2. Redistributions in binary form must reproduce the above copyright 00080 * notice, this list of conditions and the following disclaimer in 00081 * the documentation and/or other materials provided with the 00082 * distribution. 00083 * 00084 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00085 * and "Vovida Open Communication Application Library (VOCAL)" must 00086 * not be used to endorse or promote products derived from this 00087 * software without prior written permission. For written 00088 * permission, please contact vocal@vovida.org. 00089 * 00090 * 4. Products derived from this software may not be called "VOCAL", nor 00091 * may "VOCAL" appear in their name, without prior written 00092 * permission of Vovida Networks, Inc. 00093 * 00094 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00095 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00096 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00097 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00098 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00099 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00100 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00101 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00102 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00103 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00104 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00105 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00106 * DAMAGE. 00107 * 00108 * ==================================================================== 00109 */
1.7.5.1