/[resiprocate]/branches/b-identity-0505/DnsInterface.hxx
ViewVC logotype

Contents of /branches/b-identity-0505/DnsInterface.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4598 - (show annotations) (download)
Wed May 11 22:53:07 2005 UTC (14 years, 6 months ago) by derek
File size: 6713 byte(s)
set svn:eol-style to LF
1 #if !defined(RESIP_DNSINTERFACE_HXX)
2 #define RESIP_DNSINTERFACE_HXX
3
4 #include <set>
5 #include <vector>
6
7 #include "resiprocate/os/TransportType.hxx"
8 #include "resiprocate/os/Data.hxx"
9 #include "resiprocate/os/Socket.hxx"
10 #include "resiprocate/os/BaseException.hxx"
11 #include "resiprocate/external/ExternalDns.hxx"
12
13 namespace resip
14 {
15 class DnsHandler;
16 class DnsResult;
17 class TransactionState;
18 class Uri;
19 class Via;
20 class ExternalDns;
21 //
22 class DnsInterface : public ExternalDnsHandler
23 {
24 public:
25 class Exception : public BaseException
26 {
27 public:
28 Exception(const Data& msg, const Data& file, const int line) : BaseException(msg,file,line){}
29 const char* name() const { return "DnsInterface::Exception"; }
30 };
31
32 // Used to create an asynchronous Dns Interface. Any lookup requests will
33 // be queued for later processing. It is critical that the consumer of the
34 // DnsResult be in the same thread that is processing the async results
35 // since there is no locking on the DnsResult
36 // Will throw DnsInterface::Exception if the Dns provider fails to initialize
37 DnsInterface();
38
39 virtual ~DnsInterface();
40
41 void lookupARecords(const Data& target, DnsResult* dres);
42 void lookupAAAARecords(const Data& target, DnsResult* dres);
43 void lookupNAPTR(const Data& target, DnsResult* dres);
44 void lookupSRV(const Data& target, DnsResult* dres);
45
46 Data errorMessage(int status);
47
48 // set the supported set of types that a UAC wishes to use
49 void addTransportType(TransportType type, IpVersion version);
50
51 // return if the client supports the specified service (e.g. SIP+D2T)
52 bool isSupported(const Data& service);
53 bool isSupported(TransportType t, IpVersion version);
54
55 // this is used if NAPTR doesn't return anything to decide which SRV
56 // records to query
57 bool isSupportedProtocol(TransportType t);
58
59
60 //only call buildFdSet and process if requiresProcess is true.
61 bool requiresProcess();
62
63 // adds the appropriate file descriptors to the fdset to allow a
64 // select/poll call to be made
65 void buildFdSet(FdSet& fdset);
66
67 // process any dns results back from the async dns library (e.g. ares). If
68 // there are results to report, post an event to the fifo
69 void process(FdSet& fdset);
70
71 // For each of the following calls, immediately return a DnsResult to the
72 // caller. If synchronous, the DnsResult is complete and may block for an
73 // arbitrary amount of time. In the synchronous case, the transactionId is
74 // not useful. If asynchronous, the DnsResult will be returned immediately
75 // and is owned by the caller. If queries are outstanding, it is not valid
76 // for the caller to delete the DnsResult.
77 //
78 // First determine a transport. Second, determine a set of ports and ip
79 // addresses. These can be returned to the client by asking the DnsResult
80 // for the next result in the form of a Transport:Tuple. The client can
81 // continue to ask the DnsResult to return more tuples. If the tuples for
82 // the current transport are exhausted, move on to the next preferred
83 // transport (if there is one)
84
85 DnsResult* createDnsResult(DnsHandler* handler=0);
86 void lookup(DnsResult* res, const Uri& uri);
87
88 // DnsResult* lookup(const Uri& url, DnsHandler* handler=0);
89 // DnsResult* lookup(const Via& via, DnsHandler* handler=0);
90
91 //callbacks for mDnsProvider
92 virtual void handle_NAPTR(ExternalDnsRawResult res);
93 virtual void handle_SRV(ExternalDnsRawResult res);
94 virtual void handle_AAAA(ExternalDnsRawResult res);
95 virtual void handle_host(ExternalDnsHostResult res);
96
97 protected:
98 // When complete or partial results are ready, call DnsHandler::process()
99 // For synchronous DnsInterface, set to 0
100 friend class DnsResult;
101 DnsHandler* mHandler;
102 std::set<Data> mSupportedNaptrs;
103 typedef std::vector<std::pair<TransportType, IpVersion> > TransportMap;
104 TransportMap mSupportedTransports;
105 //std::set<TransportType> mSupportedTransportTypes;
106
107 ExternalDns* mDnsProvider;
108 int mActiveQueryCount;
109 };
110
111 }
112
113 #endif
114 // Copyright (c) 2003, Jason Fischl
115 /* ====================================================================
116 * The Vovida Software License, Version 1.0
117 *
118 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
119 *
120 * Redistribution and use in source and binary forms, with or without
121 * modification, are permitted provided that the following conditions
122 * are met:
123 *
124 * 1. Redistributions of source code must retain the above copyright
125 * notice, this list of conditions and the following disclaimer.
126 *
127 * 2. Redistributions in binary form must reproduce the above copyright
128 * notice, this list of conditions and the following disclaimer in
129 * the documentation and/or other materials provided with the
130 * distribution.
131 *
132 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
133 * and "Vovida Open Communication Application Library (VOCAL)" must
134 * not be used to endorse or promote products derived from this
135 * software without prior written permission. For written
136 * permission, please contact vocal@vovida.org.
137 *
138 * 4. Products derived from this software may not be called "VOCAL", nor
139 * may "VOCAL" appear in their name, without prior written
140 * permission of Vovida Networks, Inc.
141 *
142 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
143 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
144 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
145 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
146 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
147 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
148 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
149 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
150 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
151 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
152 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
153 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
154 * DAMAGE.
155 *
156 * ====================================================================
157 *
158 * This software consists of voluntary contributions made by Vovida
159 * Networks, Inc. and many individuals on behalf of Vovida Networks,
160 * Inc. For more information on Vovida Networks, Inc., please see
161 * <http://www.vovida.org/>.
162 *
163 */
164
165

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27