]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/ixfrutils.hh
Merge pull request #8223 from PowerDNS/omoerbeek-patch-1
[thirdparty/pdns.git] / pdns / ixfrutils.hh
CommitLineData
4db8fd44
PL
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#include <sys/types.h>
23#include <boost/multi_index_container.hpp>
24#include "dnsparser.hh"
25#include "dnsrecords.hh"
26
27using namespace boost::multi_index;
28
29struct CIContentCompareStruct
30{
31 bool operator()(const shared_ptr<DNSRecordContent>&a, const shared_ptr<DNSRecordContent>& b) const
32 {
33 return toLower(a->getZoneRepresentation()) < toLower(b->getZoneRepresentation());
34 }
35};
36
37
38typedef multi_index_container <
39 DNSRecord,
40 indexed_by<
41 ordered_non_unique<
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 */
49 > /* indexed_by */
50> /* multi_index_container */ records_t;
51
2dfb13fe 52uint32_t getSerialFromMaster(const ComboAddress& master, const DNSName& zone, shared_ptr<SOARecordContent>& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2);
4db8fd44
PL
53uint32_t getSerialsFromDir(const std::string& dir);
54uint32_t getSerialFromRecords(const records_t& records, DNSRecord& soaret);
55void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::string& directory);
56void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zone);
d56c1443 57void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr<SOARecordContent>& soa, uint32_t& soaTTL);