|
reSIProcate/DialogUsageManager
9694
|
00001 #if !defined(RESIP_REDIRECTMANAGER_HXX) 00002 #define RESIP_REDIRECTMANAGER_HXX 00003 00004 00005 #include <set> 00006 #include <queue> 00007 #include <functional> 00008 #include <vector> 00009 00010 #include "resip/dum/Handles.hxx" 00011 #include "resip/stack/NameAddr.hxx" 00012 #include "resip/stack/SipMessage.hxx" 00013 #include "resip/dum/DialogSetId.hxx" 00014 #include "rutil/HashMap.hxx" 00015 00016 //8.1.3.4 00017 //19.1.5 00018 00019 namespace resip 00020 { 00021 00022 class DialogSet; 00023 00024 class RedirectManager 00025 { 00026 public: 00027 class Ordering : public std::binary_function<const NameAddr&, const NameAddr&, bool> 00028 { 00029 public: 00030 virtual ~Ordering() {} 00031 virtual bool operator()(const NameAddr& lhs, const NameAddr& rhs) const; 00032 }; 00033 virtual ~RedirectManager() {} 00034 virtual bool handle(DialogSet& dSet, SipMessage& origRequest, const SipMessage& response); 00035 00036 //deafult is by q-value, no q-value treated as 1.0 00037 void setOrdering(const Ordering& order); 00038 00039 void removeDialogSet(DialogSetId id); 00040 00041 //based on follows 8.1.3.4 of 3261. Overload to interject user decisions 00042 //or to process 301, 305 or 380 reponses. 00043 // virtual void onRedirect(AppDialogSetHandle, const SipMessage& response); 00044 //use a priority queue by q-value, and a list(linear, set too heavy?) of 00045 //values that have been tried. Do q-values really have any meaning across 00046 //different 3xx values? Or should the first 3xx always win. 00047 protected: 00048 class TargetSet 00049 { 00050 public: 00051 TargetSet(const SipMessage& request, const Ordering& order) : 00052 mTargetQueue(order), 00053 mRequest(request) 00054 {} 00055 00056 void addTargets(const SipMessage& msg); 00057 //pass in the message stored in the creator 00058 bool makeNextRequest(SipMessage& request); 00059 protected: 00060 typedef std::set<NameAddr> EncounteredTargetSet; 00061 typedef std::priority_queue<NameAddr, std::vector<NameAddr>, Ordering> TargetQueue; 00062 00063 EncounteredTargetSet mTargetSet; 00064 TargetQueue mTargetQueue; 00065 //mLastRequest in creator is kept in sync with this, this is needed 00066 //so that embedded information in a target uri does not migrate to 00067 //the wrong attempt 00068 SipMessage mRequest; 00069 }; 00070 00071 typedef HashMap<DialogSetId, TargetSet*> RedirectedRequestMap; 00072 RedirectedRequestMap mRedirectedRequestMap; 00073 Ordering mOrdering; 00074 }; 00075 00076 00077 } 00078 00079 #endif 00080 00081 /* ==================================================================== 00082 * The Vovida Software License, Version 1.0 00083 * 00084 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00085 * 00086 * Redistribution and use in source and binary forms, with or without 00087 * modification, are permitted provided that the following conditions 00088 * are met: 00089 * 00090 * 1. Redistributions of source code must retain the above copyright 00091 * notice, this list of conditions and the following disclaimer. 00092 * 00093 * 2. Redistributions in binary form must reproduce the above copyright 00094 * notice, this list of conditions and the following disclaimer in 00095 * the documentation and/or other materials provided with the 00096 * distribution. 00097 * 00098 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00099 * and "Vovida Open Communication Application Library (VOCAL)" must 00100 * not be used to endorse or promote products derived from this 00101 * software without prior written permission. For written 00102 * permission, please contact vocal@vovida.org. 00103 * 00104 * 4. Products derived from this software may not be called "VOCAL", nor 00105 * may "VOCAL" appear in their name, without prior written 00106 * permission of Vovida Networks, Inc. 00107 * 00108 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00109 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00110 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00111 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00112 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00113 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00114 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00115 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00116 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00117 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00118 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00119 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00120 * DAMAGE. 00121 * 00122 * ==================================================================== 00123 * 00124 * This software consists of voluntary contributions made by Vovida 00125 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00126 * Inc. For more information on Vovida Networks, Inc., please see 00127 * <http://www.vovida.org/>. 00128 * 00129 */
1.7.5.1