Branch data Line data Source code
1 : : // Copyright (C) 2010 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 __DATA_SOURCE_SQLITE3_H
16 : : #define __DATA_SOURCE_SQLITE3_H
17 : :
18 : : #include <string>
19 : :
20 : : #include <exceptions/exceptions.h>
21 : :
22 : : #include <datasrc/data_source.h>
23 : :
24 : : namespace isc {
25 : :
26 : : namespace dns {
27 : : class Name;
28 : : class RRClass;
29 : : class RRType;
30 : : class RRsetList;
31 : : }
32 : :
33 : : namespace datasrc {
34 : :
35 : : class Query;
36 : : struct Sqlite3Parameters;
37 : :
38 : 3 : class Sqlite3Error : public Exception {
39 : : public:
40 : 3 : Sqlite3Error(const char* file, size_t line, const char* what) :
41 : 3 : isc::Exception(file, line, what) {}
42 : : };
43 : :
44 : 0 : class IncompatibleDbVersion : public Exception {
45 : : public:
46 : : IncompatibleDbVersion(const char* file, size_t line, const char* what) :
47 [ + - ]: 2 : isc::Exception(file, line, what) {}
48 : : };
49 : :
50 : : class Sqlite3DataSrc : public DataSrc {
51 : : ///
52 : : /// \name Constructors, Assignment Operator and Destructor.
53 : : ///
54 : : /// Note: The copy constructor and the assignment operator are intentionally
55 : : /// defined as private.
56 : : //@{
57 : : private:
58 : : Sqlite3DataSrc(const Sqlite3DataSrc& source);
59 : : Sqlite3DataSrc& operator=(const Sqlite3DataSrc& source);
60 : : public:
61 : : Sqlite3DataSrc();
62 : : ~Sqlite3DataSrc();
63 : : //@}
64 : :
65 : : void findClosestEnclosure(DataSrcMatch& match) const;
66 : :
67 : : Result findRRset(const isc::dns::Name& qname,
68 : : const isc::dns::RRClass& qclass,
69 : : const isc::dns::RRType& qtype,
70 : : isc::dns::RRsetList& target,
71 : : uint32_t& flags,
72 : : const isc::dns::Name* zonename) const;
73 : :
74 : : Result findExactRRset(const isc::dns::Name& qname,
75 : : const isc::dns::RRClass& qclass,
76 : : const isc::dns::RRType& qtype,
77 : : isc::dns::RRsetList& target,
78 : : uint32_t& flags,
79 : : const isc::dns::Name* zonename) const;
80 : :
81 : : Result findAddrs(const isc::dns::Name& qname,
82 : : const isc::dns::RRClass& qclass,
83 : : isc::dns::RRsetList& target,
84 : : uint32_t& flags,
85 : : const isc::dns::Name* zonename) const;
86 : :
87 : : Result findReferral(const isc::dns::Name& qname,
88 : : const isc::dns::RRClass& qclass,
89 : : isc::dns::RRsetList& target,
90 : : uint32_t& flags,
91 : : const isc::dns::Name* zonename) const;
92 : :
93 : : DataSrc::Result findPreviousName(const isc::dns::Name& qname,
94 : : isc::dns::Name& target,
95 : : const isc::dns::Name* zonename) const;
96 : :
97 : : Result findCoveringNSEC3(const isc::dns::Name& zonename,
98 : : std::string& hash,
99 : : isc::dns::RRsetList& target) const;
100 : :
101 [ # # ]: 0 : Result init() { return (init(isc::data::ElementPtr())); }
102 : : Result init(const isc::data::ConstElementPtr config);
103 : : Result close();
104 : :
105 : : private:
106 : : enum Mode {
107 : : NORMAL,
108 : : ADDRESS,
109 : : DELEGATION
110 : : };
111 : :
112 : : void open(const std::string& name);
113 : : int hasExactZone(const char *name) const;
114 : : int findRecords(const isc::dns::Name& name, const isc::dns::RRType& rdtype,
115 : : isc::dns::RRsetList& target, const isc::dns::Name* zonename,
116 : : const Mode mode, uint32_t& flags) const;
117 : : int findClosest(const isc::dns::Name& name, unsigned int* position) const;
118 : :
119 : : private:
120 : : Sqlite3Parameters* dbparameters;
121 : : };
122 : :
123 : : }
124 : : }
125 : :
126 : : #endif // __DATA_SOURCE_SQLITE3_H
127 : :
128 : : // Local Variables:
129 : : // mode: c++
130 : : // End:
|