]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/sortlist.hh
Better (actual) fix for leak reported by Coverity.
[thirdparty/pdns.git] / pdns / sortlist.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 #include "iputils.hh"
24 #include "dnsrecords.hh"
25
26 struct SortListOrder
27 {
28 NetmaskTree<int> d_orders;
29 };
30
31
32 struct SortListOrderCmp
33 {
34 SortListOrderCmp(const SortListOrder& slo) : d_slo(slo) {}
35 bool operator()(const DNSRecord& a, const DNSRecord& b) const;
36 const SortListOrder d_slo;
37 };
38
39 class SortList {
40 public:
41 void clear();
42 void addEntry(const Netmask& covers, const Netmask& answermask, int order=-1);
43 int getMaxOrder(const Netmask& formask) const;
44 std::unique_ptr<SortListOrderCmp> getOrderCmp(const ComboAddress& who) const;
45 private:
46
47 NetmaskTree<SortListOrder> d_sortlist;
48 };