Branch data Line data Source code
1 : : // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
2 : : //
3 : : // Permission to use, copy, modify, and/or distribute this software for any
4 : : // purpose with or without fee is hereby granted, provided that the above
5 : : // copyright notice and this permission notice appear in all copies.
6 : : //
7 : : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
8 : : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9 : : // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
10 : : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11 : : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
12 : : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13 : : // PERFORMANCE OF THIS SOFTWARE.
14 : :
15 : : #ifndef __ASIOLINK_DNS_LOOKUP_H
16 : : #define __ASIOLINK_DNS_LOOKUP_H 1
17 : :
18 : : #include <asiolink/io_message.h>
19 : : #include <asiodns/dns_server.h>
20 : : #include <dns/message.h>
21 : : #include <util/buffer.h>
22 : :
23 : : namespace isc {
24 : : namespace asiodns {
25 : :
26 : : /// \brief The \c DNSLookup class is an abstract base class for a DNS
27 : : /// Lookup provider function.
28 : : ///
29 : : /// Specific derived class implementations are hidden within the
30 : : /// implementation. Instances of the derived classes can be called
31 : : /// as functions via the operator() interface. Pointers to these
32 : : /// instances can then be provided to the \c IOService class
33 : : /// via its constructor.
34 : : ///
35 : : /// A DNS Lookup provider function obtains the data needed to answer
36 : : /// a DNS query (e.g., from authoritative data source, cache, or upstream
37 : : /// query). After it has run, the OutputBuffer object passed to it
38 : : /// should contain the answer to the query, in an internal representation.
39 : : class DNSLookup {
40 : : ///
41 : : /// \name Constructors and Destructor
42 : : ///
43 : : /// Note: The copy constructor and the assignment operator are
44 : : /// intentionally defined as private, making this class non-copyable.
45 : : //@{
46 : : private:
47 : : DNSLookup(const DNSLookup& source);
48 : : DNSLookup& operator=(const DNSLookup& source);
49 : : protected:
50 : : /// \brief The default constructor.
51 : : ///
52 : : /// This is intentionally defined as \c protected as this base class
53 : : /// should never be instantiated (except as part of a derived class).
54 : 161 : DNSLookup() {
55 : 161 : self_ = this;
56 : : }
57 : : public:
58 : : /// \brief The destructor
59 : 161 : virtual ~DNSLookup() {}
60 : : //@}
61 : : /// \brief The function operator
62 : : ///
63 : : /// This makes its call indirectly via the "self" pointer, ensuring
64 : : /// that the function ultimately invoked will be the one in the derived
65 : : /// class.
66 : : ///
67 : : /// \param io_message The event message to handle
68 : : /// \param message The DNS MessagePtr that needs handling
69 : : /// \param answer_message The final answer will be constructed in
70 : : /// this MessagePtr
71 : : /// \param buffer The final answer is put here
72 : : /// \param server DNSServer object to use
73 : 0 : virtual void operator()(const asiolink::IOMessage& io_message,
74 : : isc::dns::MessagePtr message,
75 : : isc::dns::MessagePtr answer_message,
76 : : isc::util::OutputBufferPtr buffer,
77 : : DNSServer* server) const
78 : : {
79 [ # # ]: 0 : (*self_)(io_message, message, answer_message, buffer, server);
80 : 0 : }
81 : : private:
82 : : DNSLookup* self_;
83 : : };
84 : :
85 : : } // namespace asiodns
86 : : } // namespace isc
87 : : #endif // __ASIOLINK_DNS_LOOKUP_H
|