|
reSIProcate/repro
9694
|
00001 #include "repro/monkeys/OutboundTargetHandler.hxx" 00002 00003 #include "rutil/Logger.hxx" 00004 #include "resip/stack/InteropHelper.hxx" 00005 #include "resip/stack/SipMessage.hxx" 00006 #include "repro/OutboundTarget.hxx" 00007 #include "repro/ResponseContext.hxx" 00008 #include "repro/RequestContext.hxx" 00009 00010 #define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO 00011 00012 namespace repro 00013 { 00014 00015 OutboundTargetHandler::OutboundTargetHandler(resip::RegistrationPersistenceManager& store) : 00016 Processor("OutboundTargetHandler"), 00017 mRegStore(store) 00018 { 00019 } 00020 00021 OutboundTargetHandler::~OutboundTargetHandler() 00022 { 00023 } 00024 00025 Processor::processor_action_t 00026 OutboundTargetHandler::process(RequestContext & rc) 00027 { 00028 resip::Message* msg = rc.getCurrentEvent(); 00029 ResponseContext& rsp = rc.getResponseContext(); 00030 if(!msg) 00031 { 00032 return Processor::Continue; 00033 } 00034 00035 // !bwc! Check to see whether we need to move on to another reg-id 00036 resip::SipMessage* sip = dynamic_cast<resip::SipMessage*>(msg); 00037 if(sip && sip->isResponse() && sip->header(resip::h_StatusLine).responseCode() > 299) 00038 { 00039 const resip::Data& tid=sip->getTransactionId(); 00040 DebugLog(<<"Looking for tid " << tid); 00041 Target* target = rsp.getTarget(tid); 00042 assert(target); 00043 OutboundTarget* ot = dynamic_cast<OutboundTarget*>(target); 00044 if(ot) 00045 { 00046 int flowDeadCode; 00047 if(resip::InteropHelper::getOutboundVersion() >= 5) 00048 { 00049 flowDeadCode=430; 00050 } 00051 else 00052 { 00053 flowDeadCode=410; 00054 } 00055 if(sip->header(resip::h_StatusLine).responseCode()==flowDeadCode || // Remote or locally(stack) generate 430 00056 (sip->getReceivedTransport() == 0 && 00057 (sip->header(resip::h_StatusLine).responseCode()==408 || // Locally (stack) generated 408 or 503 00058 sip->header(resip::h_StatusLine).responseCode()==503))) 00059 { 00060 // Flow is dead remove contact from Location Database 00061 resip::Uri inputUri(ot->getAor()); 00062 00063 //!RjS! This doesn't look exception safe - need guards 00064 mRegStore.lockRecord(inputUri); 00065 mRegStore.removeContact(inputUri,ot->rec()); 00066 mRegStore.unlockRecord(inputUri); 00067 00068 std::auto_ptr<Target> newTarget(ot->nextInstance()); 00069 if(newTarget.get()) 00070 { 00071 // Try next reg-id 00072 rsp.addTarget(newTarget); 00073 return Processor::SkipAllChains; 00074 } 00075 } 00076 } 00077 } 00078 00079 return Processor::Continue; 00080 } 00081 00082 } 00083 00084 /* ==================================================================== 00085 * The Vovida Software License, Version 1.0 00086 * 00087 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00088 * 00089 * Redistribution and use in source and binary forms, with or without 00090 * modification, are permitted provided that the following conditions 00091 * are met: 00092 * 00093 * 1. Redistributions of source code must retain the above copyright 00094 * notice, this list of conditions and the following disclaimer. 00095 * 00096 * 2. Redistributions in binary form must reproduce the above copyright 00097 * notice, this list of conditions and the following disclaimer in 00098 * the documentation and/or other materials provided with the 00099 * distribution. 00100 * 00101 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00102 * and "Vovida Open Communication Application Library (VOCAL)" must 00103 * not be used to endorse or promote products derived from this 00104 * software without prior written permission. For written 00105 * permission, please contact vocal@vovida.org. 00106 * 00107 * 4. Products derived from this software may not be called "VOCAL", nor 00108 * may "VOCAL" appear in their name, without prior written 00109 * permission of Vovida Networks, Inc. 00110 * 00111 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00112 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00113 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00114 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00115 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00116 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00117 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00118 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00119 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00120 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00121 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00122 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00123 * DAMAGE. 00124 * 00125 * ==================================================================== 00126 */
1.7.5.1