]>
Commit | Line | Data |
---|---|---|
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 | */ | |
f2c11a8b OM |
22 | #pragma once |
23 | ||
4db8fd44 | 24 | #include <sys/types.h> |
905dae56 | 25 | |
4db8fd44 | 26 | #include <boost/multi_index_container.hpp> |
905dae56 RG |
27 | #include <boost/multi_index/key_extractors.hpp> |
28 | #include <boost/multi_index/ordered_index.hpp> | |
d06dcda4 | 29 | #include <boost/multi_index/mem_fun.hpp> |
905dae56 | 30 | |
4db8fd44 PL |
31 | #include "dnsparser.hh" |
32 | #include "dnsrecords.hh" | |
33 | ||
34 | using namespace boost::multi_index; | |
35 | ||
36 | struct CIContentCompareStruct | |
37 | { | |
d06dcda4 | 38 | bool operator()(const shared_ptr<const DNSRecordContent>&a, const shared_ptr<const DNSRecordContent>& b) const |
4db8fd44 PL |
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>, | |
d06dcda4 | 53 | BOOST_MULTI_INDEX_CONST_MEM_FUN(DNSRecord, const shared_ptr<const DNSRecordContent>&, getContent) >, |
4db8fd44 PL |
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 | ||
d525b58b | 59 | uint32_t getSerialFromPrimary(const ComboAddress& primary, const DNSName& zone, shared_ptr<const SOARecordContent>& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2); |
28942414 | 60 | uint32_t getSerialFromDir(const std::string& dir); |
4db8fd44 PL |
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); | |
d06dcda4 | 64 | void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr<const SOARecordContent>& soa, uint32_t& soaTTL); |