1
#ifndef TINYDNSBACKEND_HH
2
#define TINYDNSBACKEND_HH
4
#include <pdns/dnsbackend.hh>
5
#include <pdns/logger.hh>
6
#include <pdns/iputils.hh>
7
#include <pdns/dnspacket.hh>
13
#include <pdns/lock.hh>
14
#include <boost/multi_index_container.hpp>
15
#include <boost/multi_index/hashed_index.hpp>
16
#include <boost/multi_index/member.hpp>
18
using namespace ::boost;
19
using namespace ::boost::multi_index;
21
struct TinyDomainInfo {
23
uint32_t notified_serial;
26
bool operator<(const TinyDomainInfo& tdi) const
28
return zone < tdi.zone;
32
struct TDI_SerialModifier {
33
TDI_SerialModifier (const int newSerial) : d_newSerial(newSerial) {}
35
void operator()(TinyDomainInfo& tdi)
37
tdi.notified_serial = d_newSerial;
45
class TinyDNSBackend : public DNSBackend
48
// Methods for simple operation
49
TinyDNSBackend(const string &suffix);
50
void lookup(const QType &qtype, const string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1);
51
bool list(const string &target, int domain_id);
52
bool get(DNSResourceRecord &rr);
53
void getAllDomains(vector<DomainInfo> *domains);
55
//Master mode operation
56
void getUpdatedMasters(vector<DomainInfo>* domains);
57
void setNotified(uint32_t id, uint32_t serial);
59
vector<string> getLocations();
63
struct tag_domainid{};
64
typedef multi_index_container<
67
hashed_unique<tag<tag_zone>, member<TinyDomainInfo, string, &TinyDomainInfo::zone> >,
68
hashed_unique<tag<tag_domainid>, member<TinyDomainInfo, uint32_t, &TinyDomainInfo::id> >
71
typedef map<string, TDI_t> TDI_suffix_t;
72
typedef TDI_t::index<tag_zone>::type TDIByZone_t;
73
typedef TDI_t::index<tag_domainid>::type TDIById_t;
75
//data member variables
79
DNSPacket *d_dnspacket; // used for location and edns-client support.
80
bool d_isWildcardQuery; // Indicate if the query received was a wildcard query.
81
bool d_isAxfr; // Indicate if we received a list() and not a lookup().
88
static pthread_mutex_t s_domainInfoLock;
89
static TDI_suffix_t s_domainInfo;
90
static uint32_t s_lastId; // used to give a domain an id.
93
#endif // TINYDNSBACKEND_HH