]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/ixfrutils.hh
Merge pull request #12908 from wwijkander/master
[thirdparty/pdns.git] / pdns / ixfrutils.hh
1 /*
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 *
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.
8 *
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.
12 *
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.
17 *
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.
21 */
22 #pragma once
23
24 #include <sys/types.h>
25
26 #include <boost/multi_index_container.hpp>
27 #include <boost/multi_index/key_extractors.hpp>
28 #include <boost/multi_index/ordered_index.hpp>
29 #include <boost/multi_index/mem_fun.hpp>
30
31 #include "dnsparser.hh"
32 #include "dnsrecords.hh"
33
34 using namespace boost::multi_index;
35
36 struct CIContentCompareStruct
37 {
38 bool operator()(const shared_ptr<const DNSRecordContent>&a, const shared_ptr<const DNSRecordContent>& b) const
39 {
40 return toLower(a->getZoneRepresentation()) < toLower(b->getZoneRepresentation());
41 }
42 };
43
44
45 typedef multi_index_container <
46 DNSRecord,
47 indexed_by<
48 ordered_non_unique<
49 composite_key<DNSRecord,
50 member<DNSRecord, DNSName, &DNSRecord::d_name>,
51 member<DNSRecord, uint16_t, &DNSRecord::d_type>,
52 member<DNSRecord, uint16_t, &DNSRecord::d_class>,
53 BOOST_MULTI_INDEX_CONST_MEM_FUN(DNSRecord, const shared_ptr<const DNSRecordContent>&, getContent) >,
54 composite_key_compare<CanonDNSNameCompare, std::less<uint16_t>, std::less<uint16_t>, CIContentCompareStruct >
55 > /* ordered_non_uniquw */
56 > /* indexed_by */
57 > /* multi_index_container */ records_t;
58
59 uint32_t getSerialFromPrimary(const ComboAddress& primary, const DNSName& zone, shared_ptr<const SOARecordContent>& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2);
60 uint32_t getSerialFromDir(const std::string& dir);
61 uint32_t getSerialFromRecords(const records_t& records, DNSRecord& soaret);
62 void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::string& directory);
63 void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zone);
64 void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr<const SOARecordContent>& soa, uint32_t& soaTTL);