|
reSIProcate/stack
9694
|
00001 #if !defined(RESIP_DNSINTERFACE_HXX) 00002 #define RESIP_DNSINTERFACE_HXX 00003 00004 #include <set> 00005 #include <vector> 00006 00007 #include "rutil/TransportType.hxx" 00008 #include "rutil/Data.hxx" 00009 #include "rutil/Socket.hxx" 00010 #include "rutil/BaseException.hxx" 00011 #include "rutil/dns/DnsStub.hxx" 00012 #include "rutil/dns/RRVip.hxx" 00013 #include "resip/stack/TupleMarkManager.hxx" 00014 00015 namespace resip 00016 { 00017 class DnsHandler; 00018 class DnsResultSink; 00019 class DnsResult; 00020 class Uri; 00021 class Via; 00022 //class ExternalDns; 00023 class DnsRawSink; 00024 00025 class DnsInterface 00026 { 00027 public: 00028 class Exception : public BaseException 00029 { 00030 public: 00031 Exception(const Data& msg, const Data& file, const int line) : BaseException(msg,file,line){} 00032 const char* name() const { return "DnsInterface::Exception"; } 00033 }; 00034 00035 // Used to create an asynchronous Dns Interface. Any lookup requests will 00036 // be queued for later processing. It is critical that the consumer of the 00037 // DnsResult be in the same thread that is processing the async results 00038 // since there is no locking on the DnsResult 00039 // Will throw DnsInterface::Exception if the Dns provider fails to initialize 00040 DnsInterface(DnsStub& dnsStub); 00041 00042 virtual ~DnsInterface(); 00043 00044 //Data errorMessage(int status); 00045 00046 // set the supported set of types that a UAC wishes to use 00047 void addTransportType(TransportType type, IpVersion version); 00048 00049 // return if the client supports the specified service (e.g. SIP+D2T) 00050 bool isSupported(const Data& service); 00051 bool isSupported(TransportType t, IpVersion version); 00052 00053 // this is used if NAPTR doesn't return anything to decide which SRV 00054 // records to query 00055 bool isSupportedProtocol(TransportType t); 00056 int supportedProtocols(); 00057 00058 // For each of the following calls, immediately return a DnsResult to the 00059 // caller. If synchronous, the DnsResult is complete and may block for an 00060 // arbitrary amount of time. In the synchronous case, the transactionId is 00061 // not useful. If asynchronous, the DnsResult will be returned immediately 00062 // and is owned by the caller. If queries are outstanding, it is not valid 00063 // for the caller to delete the DnsResult. 00064 // 00065 // First determine a transport. Second, determine a set of ports and ip 00066 // addresses. These can be returned to the client by asking the DnsResult 00067 // for the next result in the form of a Transport:Tuple. The client can 00068 // continue to ask the DnsResult to return more tuples. If the tuples for 00069 // the current transport are exhausted, move on to the next preferred 00070 // transport (if there is one) 00071 00072 DnsResult* createDnsResult(DnsHandler* handler=0); 00073 void lookup(DnsResult* res, const Uri& uri); 00074 00075 //DnsResult* lookup(const Uri& url, DnsHandler* handler=0); 00076 //DnsResult* lookup(const Via& via, DnsHandler* handler=0); 00077 00078 //void lookupRecords(const Data& target, unsigned short type, DnsRawSink* sink); 00079 //virtual void handleDnsRaw(ExternalDnsRawResult); 00080 TupleMarkManager& getMarkManager(){return mMarkManager;} 00081 00082 protected: 00083 // When complete or partial results are ready, call DnsHandler::process() 00084 // For synchronous DnsInterface, set to 0 00085 friend class DnsResult; 00086 // DnsHandler* mHandler; // .kw. not used anymore? 00087 std::set<Data> mSupportedNaptrs; 00088 typedef std::vector<std::pair<TransportType, IpVersion> > TransportMap; 00089 TransportMap mSupportedTransports; 00090 //std::set<TransportType> mSupportedTransportTypes; 00091 00092 //ExternalDns* mDnsProvider; 00093 00094 DnsStub& mDnsStub; 00095 RRVip mVip; 00096 TupleMarkManager mMarkManager; 00097 }; 00098 00099 } 00100 00101 #endif 00102 // Copyright (c) 2003, Jason Fischl 00103 /* ==================================================================== 00104 * The Vovida Software License, Version 1.0 00105 * 00106 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00107 * 00108 * Redistribution and use in source and binary forms, with or without 00109 * modification, are permitted provided that the following conditions 00110 * are met: 00111 * 00112 * 1. Redistributions of source code must retain the above copyright 00113 * notice, this list of conditions and the following disclaimer. 00114 * 00115 * 2. Redistributions in binary form must reproduce the above copyright 00116 * notice, this list of conditions and the following disclaimer in 00117 * the documentation and/or other materials provided with the 00118 * distribution. 00119 * 00120 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00121 * and "Vovida Open Communication Application Library (VOCAL)" must 00122 * not be used to endorse or promote products derived from this 00123 * software without prior written permission. For written 00124 * permission, please contact vocal@vovida.org. 00125 * 00126 * 4. Products derived from this software may not be called "VOCAL", nor 00127 * may "VOCAL" appear in their name, without prior written 00128 * permission of Vovida Networks, Inc. 00129 * 00130 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00131 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00132 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00133 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00134 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00135 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00136 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00137 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00138 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00139 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00140 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00141 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00142 * DAMAGE. 00143 * 00144 * ==================================================================== 00145 * 00146 * This software consists of voluntary contributions made by Vovida 00147 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00148 * Inc. For more information on Vovida Networks, Inc., please see 00149 * <http://www.vovida.org/>. 00150 * 00151 */ 00152 00153
1.7.5.1