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