]>
Commit | Line | Data |
---|---|---|
12471842 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 | */ | |
ca404e94 RG |
22 | #pragma once |
23 | ||
3165970b RG |
24 | #include <string> |
25 | ||
26 | #include "iputils.hh" | |
27 | #include "noinitvector.hh" | |
28 | ||
3baa93c2 | 29 | struct DNSQuestion; |
3165970b | 30 | |
2aa2c0aa RG |
31 | // root label (1), type (2), class (2), ttl (4) + rdlen (2) |
32 | static const size_t optRecordMinimumSize = 11; | |
33 | ||
e7c732b8 RG |
34 | extern size_t g_EdnsUDPPayloadSize; |
35 | extern uint16_t g_PayloadSizeSelfGenAnswers; | |
36 | ||
32fbb2ab | 37 | int rewriteResponseWithoutEDNS(const PacketBuffer& initialPacket, PacketBuffer& newContent); |
670e6761 | 38 | bool slowRewriteEDNSOptionInQueryWithRecords(const PacketBuffer& initialPacket, PacketBuffer& newContent, bool& ednsAdded, uint16_t optionToReplace, bool& optionAdded, bool overrideExisting, const string& newOptionContent); |
32fbb2ab RG |
39 | int locateEDNSOptRR(const PacketBuffer & packet, uint16_t * optStart, size_t * optLen, bool * last); |
40 | bool generateOptRR(const std::string& optRData, PacketBuffer& res, size_t maximumSize, uint16_t udpPayloadSize, uint8_t ednsrcode, bool dnssecOK); | |
cbf4e13a | 41 | void generateECSOption(const ComboAddress& source, string& res, uint16_t ECSPrefixLength); |
ff73f02b | 42 | int removeEDNSOptionFromOPT(char* optStart, size_t* optLen, const uint16_t optionCodeToRemove); |
32fbb2ab RG |
43 | int rewriteResponseWithoutEDNSOption(const PacketBuffer& initialPacket, const uint16_t optionCodeToSkip, PacketBuffer& newContent); |
44 | int getEDNSOptionsStart(const PacketBuffer& packet, const size_t offset, uint16_t* optRDPosition, size_t * remaining); | |
45 | bool isEDNSOptionInOpt(const PacketBuffer& packet, const size_t optStart, const size_t optLen, const uint16_t optionCodeToFind, size_t* optContentStart = nullptr, uint16_t* optContentLen = nullptr); | |
46 | bool addEDNS(PacketBuffer& packet, size_t maximumSize, bool dnssecOK, uint16_t payloadSize, uint8_t ednsrcode); | |
e7c732b8 | 47 | bool addEDNSToQueryTurnedResponse(DNSQuestion& dq); |
61643ae0 | 48 | bool setNegativeAndAdditionalSOA(DNSQuestion& dq, bool nxd, const DNSName& zone, uint32_t ttl, const DNSName& mname, const DNSName& rname, uint32_t serial, uint32_t refresh, uint32_t retry, uint32_t expire, uint32_t minimum, bool soaInAuthoritySection); |
e7c732b8 | 49 | |
341d2553 | 50 | bool handleEDNSClientSubnet(DNSQuestion& dq, bool& ednsAdded, bool& ecsAdded); |
32fbb2ab | 51 | bool handleEDNSClientSubnet(PacketBuffer& packet, size_t maximumSize, size_t qnameWireLength, bool& ednsAdded, bool& ecsAdded, bool overrideExisting, const string& newECSOption); |
cbf4e13a | 52 | |
acf16adc | 53 | bool parseEDNSOptions(const DNSQuestion& dq); |
cbf4e13a | 54 | |
e7c732b8 RG |
55 | int getEDNSZ(const DNSQuestion& dq); |
56 | bool queryHasEDNS(const DNSQuestion& dq); | |
582d5b58 | 57 | bool getEDNS0Record(const PacketBuffer& packet, EDNS0Record& edns0); |
721569c1 RG |
58 | |
59 | bool setEDNSOption(DNSQuestion& dq, uint16_t ednsCode, const std::string& data); | |
27f38b46 RG |
60 | |
61 | namespace dnsdist { | |
62 | bool setInternalQueryRCode(InternalQueryState& state, PacketBuffer& buffer, uint8_t rcode, bool clearAnswers); | |
63 | } |