]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/lwres.hh
Merge pull request #8223 from PowerDNS/omoerbeek-patch-1
[thirdparty/pdns.git] / pdns / lwres.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 #ifndef PDNS_LWRES_HH
23 #define PDNS_LWRES_HH
24 #include <string>
25 #include <vector>
26 #include <sys/types.h>
27 #include "misc.hh"
28 #include "iputils.hh"
29 #include <netdb.h>
30 #include <unistd.h>
31 #include <sys/time.h>
32 #include <sys/uio.h>
33 #include <fcntl.h>
34 #include <sys/socket.h>
35 #include <netinet/in.h>
36 #include "dnsparser.hh"
37 #include <arpa/inet.h>
38 #undef res_mkquery
39
40 #include "pdnsexception.hh"
41 #include "dns.hh"
42 #include "namespaces.hh"
43 #include "remote_logger.hh"
44 #include "fstrm_logger.hh"
45 #include "resolve-context.hh"
46
47
48 int asendto(const char *data, size_t len, int flags, const ComboAddress& ip, uint16_t id,
49 const DNSName& domain, uint16_t qtype, int* fd);
50 int arecvfrom(std::string& packet, int flags, const ComboAddress& ip, size_t *d_len, uint16_t id,
51 const DNSName& domain, uint16_t qtype, int fd, struct timeval* now);
52
53 class LWResException : public PDNSException
54 {
55 public:
56 LWResException(const string &reason_) : PDNSException(reason_){}
57 };
58
59 //! LWRes class
60 class LWResult
61 {
62 public:
63 LWResult() : d_usec(0) {}
64
65 vector<DNSRecord> d_records;
66 int d_rcode{0};
67 bool d_validpacket{false};
68 bool d_aabit{false}, d_tcbit{false};
69 uint32_t d_usec{0};
70 bool d_haveEDNS{false};
71 };
72
73 int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional<Netmask>& srcmask, boost::optional<const ResolveContext&> context, const std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>>& outgoingLoggers, const std::shared_ptr<std::vector<std::unique_ptr<FrameStreamLogger>>>& fstrmLoggers, const std::set<uint16_t>& exportTypes, LWResult* res, bool* chained);
74 #endif // PDNS_LWRES_HH