2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <sys/types.h>
23 #include <boost/multi_index_container.hpp>
24 #include "dnsparser.hh"
25 #include "dnsrecords.hh"
27 using namespace boost::multi_index;
29 struct CIContentCompareStruct
31 bool operator()(const shared_ptr<DNSRecordContent>&a, const shared_ptr<DNSRecordContent>& b) const
33 return toLower(a->getZoneRepresentation()) < toLower(b->getZoneRepresentation());
38 typedef multi_index_container <
42 composite_key<DNSRecord,
43 member<DNSRecord, DNSName, &DNSRecord::d_name>,
44 member<DNSRecord, uint16_t, &DNSRecord::d_type>,
45 member<DNSRecord, uint16_t, &DNSRecord::d_class>,
46 member<DNSRecord, shared_ptr<DNSRecordContent>, &DNSRecord::d_content> >,
47 composite_key_compare<CanonDNSNameCompare, std::less<uint16_t>, std::less<uint16_t>, CIContentCompareStruct >
48 > /* ordered_non_uniquw */
50 > /* multi_index_container */ records_t;
52 uint32_t getSerialFromMaster(const ComboAddress& master, const DNSName& zone, shared_ptr<SOARecordContent>& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2);
53 uint32_t getSerialsFromDir(const std::string& dir);
54 uint32_t getSerialFromRecords(const records_t& records, DNSRecord& soaret);
55 void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::string& directory);
56 void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zone);
57 void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr<SOARecordContent>& soa, uint32_t& soaTTL);