]>
Commit | Line | Data |
---|---|---|
12c86877 | 1 | /* |
12471842 PL |
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 | */ | |
e8c59f2d | 22 | #pragma once |
12c86877 BH |
23 | #include <string> |
24 | #include <vector> | |
092f210a | 25 | #include <sys/types.h> |
809fe23f | 26 | #include "iputils.hh" |
76473b92 KM |
27 | #include <netdb.h> |
28 | #include <unistd.h> | |
29 | #include <sys/time.h> | |
30 | #include <sys/uio.h> | |
31 | #include <fcntl.h> | |
32 | #include <sys/socket.h> | |
33 | #include <netinet/in.h> | |
34 | #include <arpa/inet.h> | |
35 | #undef res_mkquery | |
12c86877 | 36 | |
5c409fa2 | 37 | #include "pdnsexception.hh" |
12c86877 | 38 | #include "dns.hh" |
10f4eea8 | 39 | #include "namespaces.hh" |
ef03cc09 | 40 | #include "dnsrecords.hh" |
41 | #include "dnssecinfra.hh" | |
60a1c204 | 42 | #include "tsigverifier.hh" |
12c86877 | 43 | |
3f81d239 | 44 | class ResolverException : public PDNSException |
12c86877 BH |
45 | { |
46 | public: | |
dd079764 | 47 | ResolverException(const string &reason_) : PDNSException(reason_){} |
12c86877 BH |
48 | }; |
49 | ||
0c01dd7c | 50 | // make an IPv4 or IPv6 query socket |
f688119e | 51 | int makeQuerySocket(const ComboAddress& local, bool udpOrTCP, bool nonLocalBind=false); |
0c01dd7c BH |
52 | //! Resolver class. Can be used synchronously and asynchronously, over IPv4 and over IPv6 (simultaneously) |
53 | class Resolver : public boost::noncopyable | |
12c86877 BH |
54 | { |
55 | public: | |
56 | Resolver(); | |
57 | ~Resolver(); | |
12c86877 BH |
58 | |
59 | typedef vector<DNSResourceRecord> res_t; | |
0c01dd7c | 60 | //! synchronously resolve domain|type at IP, store result in result, rcode in ret |
d622042f | 61 | int resolve(const ComboAddress &ip, const DNSName &domain, int type, res_t* result, const ComboAddress& local); |
95302209 | 62 | |
d622042f | 63 | int resolve(const ComboAddress &ip, const DNSName &domain, int type, res_t* result); |
95302209 | 64 | |
0c01dd7c | 65 | //! only send out a resolution request |
7f24b6c6 | 66 | uint16_t sendResolve(const ComboAddress& remote, const ComboAddress& local, const DNSName &domain, int type, int *localsock, bool dnssecOk=false, |
561434a6 | 67 | const DNSName& tsigkeyname=DNSName(), const DNSName& tsigalgorithm=DNSName(), const string& tsigsecret=""); |
95302209 | 68 | |
0c01dd7c | 69 | //! see if we got a SOA response from our sendResolve |
40c9a111 | 70 | bool tryGetSOASerial(DNSName *theirDomain, ComboAddress* remote, uint32_t* theirSerial, uint32_t* theirInception, uint32_t* theirExpire, uint16_t* id); |
3696224d | 71 | |
0c01dd7c | 72 | //! convenience function that calls resolve above |
d622042f | 73 | void getSoaSerial(const ComboAddress&, const DNSName &, uint32_t *); |
12c86877 BH |
74 | |
75 | private: | |
95302209 | 76 | std::map<std::string, int> locals; |
0c01dd7c BH |
77 | }; |
78 | ||
0dd42dbb PL |
79 | namespace pdns { |
80 | namespace resolver { | |
81 | int parseResult(MOADNSParser& mdp, const DNSName& origQname, uint16_t origQtype, uint16_t id, Resolver::res_t* result); | |
82 | } // namespace resolver | |
83 | } // namespace pdns |