]>
Commit | Line | Data |
---|---|---|
12c86877 BH |
1 | /* |
2 | PowerDNS Versatile Database Driven Nameserver | |
e0d84497 | 3 | Copyright (C) 2002 - 2011 PowerDNS.COM BV |
12c86877 BH |
4 | |
5 | This program is free software; you can redistribute it and/or modify | |
22dc646a BH |
6 | it under the terms of the GNU General Public License version 2 |
7 | as published by the Free Software Foundation | |
f782fe38 MH |
8 | |
9 | Additionally, the license of this program contains a special | |
10 | exception which allows to distribute the program in binary form when | |
11 | it is linked against OpenSSL. | |
12c86877 BH |
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 | |
06bd9ccf | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
12c86877 BH |
21 | */ |
22 | #ifndef PACKETHANDLER_HH | |
23 | #define PACKETHANDLER_HH | |
cc3afe25 | 24 | |
76473b92 KM |
25 | #include <sys/socket.h> |
26 | #include <netinet/in.h> | |
27 | #include <arpa/inet.h> | |
12c86877 BH |
28 | #include "ueberbackend.hh" |
29 | #include "dnspacket.hh" | |
30 | #include "packetcache.hh" | |
e0d84497 | 31 | #include "dnsseckeeper.hh" |
5704e107 | 32 | #include "lua-auth.hh" |
7f9ac49b | 33 | #include "gss_context.hh" |
12c86877 | 34 | |
10f4eea8 | 35 | #include "namespaces.hh" |
12c86877 | 36 | |
88def049 BH |
37 | // silly Solaris people define PC |
38 | #undef PC | |
39 | ||
12c86877 BH |
40 | /** Central DNS logic according to RFC1034. Ask this class a question in the form of a DNSPacket |
41 | and it will return, synchronously, a DNSPacket answer, suitable for | |
42 | sending out over the network. | |
43 | ||
44 | The PacketHandler gives your question to the PacketCache for possible inclusion | |
45 | in the cache. | |
46 | ||
47 | In order to do so, the PacketHandler contains a reference to the global extern PacketCache PC | |
48 | ||
49 | It also contains an UeberBackend instance for answering the subqueries needed to generate | |
50 | a complete reply. | |
51 | ||
52 | */ | |
5c3bf2db | 53 | class NSEC3PARAMRecordContent; |
12c86877 BH |
54 | |
55 | class PacketHandler | |
56 | { | |
57 | public: | |
ff76e8b4 | 58 | DNSPacket *questionOrRecurse(DNSPacket *, bool* shouldRecurse); //!< hand us a DNS packet with a question, we'll tell you answer, or that you should recurse |
12c86877 BH |
59 | DNSPacket *question(DNSPacket *); //!< hand us a DNS packet with a question, we give you an answer |
60 | PacketHandler(); | |
61 | ~PacketHandler(); // defined in packethandler.cc, and does --count | |
bdc9f8d2 | 62 | static int numRunning(){return s_count;}; //!< Returns the number of running PacketHandlers. Called by Distributor |
12c86877 | 63 | |
3971cf53 | 64 | UeberBackend *getBackend(); |
cc3afe25 | 65 | |
7108e055 | 66 | int trySuperMasterSynchronous(DNSPacket *p); |
d207ad63 | 67 | static NetmaskGroup s_allowNotifyFrom; |
12c86877 BH |
68 | |
69 | private: | |
7108e055 | 70 | int trySuperMaster(DNSPacket *p); |
3777f434 | 71 | int processNotify(DNSPacket *); |
8a63d3ce | 72 | void addRootReferral(DNSPacket *r); |
675fa24c | 73 | int doChaosRequest(DNSPacket *p, DNSPacket *r, DNSName &target); |
088370cd | 74 | bool addDNSKEY(DNSPacket *p, DNSPacket *r, const SOAData& sd, bool doCDNSKEY); |
794c2f92 | 75 | bool addNSEC3PARAM(DNSPacket *p, DNSPacket *r, const SOAData& sd); |
d2323cd0 | 76 | int doAdditionalProcessingAndDropAA(DNSPacket *p, DNSPacket *r, const SOAData& sd, bool retargeted); |
675fa24c PD |
77 | void addNSECX(DNSPacket *p, DNSPacket* r, const DNSName &target, const DNSName &wildcard, const DNSName &auth, int mode); |
78 | void addNSEC(DNSPacket *p, DNSPacket* r, const DNSName &target, const DNSName &wildcard, const DNSName& auth, int mode); | |
79 | void addNSEC3(DNSPacket *p, DNSPacket* r, const DNSName &target, const DNSName &wildcard, const DNSName& auth, const NSEC3PARAMRecordContent& nsec3param, bool narrow, int mode); | |
ca617317 | 80 | void emitNSEC(DNSPacket *r, const SOAData& sd, const DNSName& name, const DNSName& next, int mode); |
576e7e0f | 81 | void emitNSEC3(DNSPacket *r, const SOAData& sd, const NSEC3PARAMRecordContent &ns3rc, const DNSName& unhashed, const string& begin, const string& end, int mode); |
f7a69a4c | 82 | int processUpdate(DNSPacket *p); |
b3148887 | 83 | int forwardPacket(const string &msgPrefix, DNSPacket *p, DomainInfo *di); |
d0d273cf | 84 | uint performUpdate(const string &msgPrefix, const DNSRecord *rr, DomainInfo *di, bool isPresigned, bool* narrow, bool* haveNSEC3, NSEC3PARAMRecordContent *ns3pr, bool *updatedSerial); |
f7a69a4c RA |
85 | int checkUpdatePrescan(const DNSRecord *rr); |
86 | int checkUpdatePrerequisites(const DNSRecord *rr, DomainInfo *di); | |
166ac305 | 87 | void increaseSerial(const string &msgPrefix, const DomainInfo *di, bool haveNSEC3, bool narrow, const NSEC3PARAMRecordContent *ns3pr); |
5c3bf2db | 88 | |
675fa24c PD |
89 | void makeNXDomain(DNSPacket* p, DNSPacket* r, const DNSName& target, const DNSName& wildcard, SOAData& sd); |
90 | void makeNOError(DNSPacket* p, DNSPacket* r, const DNSName& target, const DNSName& wildcard, SOAData& sd, int mode); | |
91 | vector<DNSResourceRecord> getBestReferralNS(DNSPacket *p, SOAData& sd, const DNSName &target); | |
92 | vector<DNSResourceRecord> getBestDNAMESynth(DNSPacket *p, SOAData& sd, DNSName &target); | |
93 | bool tryDNAME(DNSPacket *p, DNSPacket*r, SOAData& sd, DNSName &target); | |
94 | bool tryReferral(DNSPacket *p, DNSPacket*r, SOAData& sd, const DNSName &target, bool retargeted); | |
95 | ||
96 | bool getBestWildcard(DNSPacket *p, SOAData& sd, const DNSName &target, DNSName &wildcard, vector<DNSResourceRecord>* ret); | |
97 | bool tryWildcard(DNSPacket *p, DNSPacket*r, SOAData& sd, DNSName &target, DNSName &wildcard, bool& retargeted, bool& nodata); | |
98 | bool addDSforNS(DNSPacket* p, DNSPacket* r, SOAData& sd, const DNSName& dsname); | |
99 | void completeANYRecords(DNSPacket *p, DNSPacket*r, SOAData& sd, const DNSName &target); | |
c00d7891 | 100 | |
6d45df05 | 101 | void tkeyHandler(DNSPacket *p, DNSPacket *r); //<! process TKEY record, and adds TKEY record to (r)eply, or error code. |
c00d7891 | 102 | |
16f7d28d | 103 | static AtomicCounter s_count; |
ee9ef8f2 | 104 | static pthread_mutex_t s_rfc2136lock; |
12c86877 | 105 | bool d_doRecursion; |
12c86877 | 106 | bool d_logDNSDetails; |
fd8bc993 | 107 | bool d_doIPv6AdditionalProcessing; |
8dee0750 | 108 | bool d_doDNAME; |
3194f0df | 109 | int d_sendRootReferral; |
5704e107 | 110 | AuthLua* d_pdl; |
12c86877 BH |
111 | |
112 | UeberBackend B; // every thread an own instance | |
e59b5787 | 113 | DNSSECKeeper d_dk; // B is shared with DNSSECKeeper |
12c86877 | 114 | }; |
561434a6 | 115 | bool getNSEC3Hashes(bool narrow, DNSBackend* db, int id, const std::string& hashed, bool decrement, DNSName& unhashed, string& before, string& after, int mode=0); |
12c86877 | 116 | #endif /* PACKETHANDLER */ |