]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/dnsdist-ecs.hh
pkcs11signers: Use emplace_back for attributes
[thirdparty/pdns.git] / pdns / dnsdist-ecs.hh
CommitLineData
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 29struct DNSQuestion;
3165970b 30
2aa2c0aa
RG
31// root label (1), type (2), class (2), ttl (4) + rdlen (2)
32static const size_t optRecordMinimumSize = 11;
33
e7c732b8
RG
34extern size_t g_EdnsUDPPayloadSize;
35extern uint16_t g_PayloadSizeSelfGenAnswers;
36
32fbb2ab 37int rewriteResponseWithoutEDNS(const PacketBuffer& initialPacket, PacketBuffer& newContent);
670e6761 38bool slowRewriteEDNSOptionInQueryWithRecords(const PacketBuffer& initialPacket, PacketBuffer& newContent, bool& ednsAdded, uint16_t optionToReplace, bool& optionAdded, bool overrideExisting, const string& newOptionContent);
32fbb2ab
RG
39int locateEDNSOptRR(const PacketBuffer & packet, uint16_t * optStart, size_t * optLen, bool * last);
40bool generateOptRR(const std::string& optRData, PacketBuffer& res, size_t maximumSize, uint16_t udpPayloadSize, uint8_t ednsrcode, bool dnssecOK);
cbf4e13a 41void generateECSOption(const ComboAddress& source, string& res, uint16_t ECSPrefixLength);
ff73f02b 42int removeEDNSOptionFromOPT(char* optStart, size_t* optLen, const uint16_t optionCodeToRemove);
32fbb2ab
RG
43int rewriteResponseWithoutEDNSOption(const PacketBuffer& initialPacket, const uint16_t optionCodeToSkip, PacketBuffer& newContent);
44int getEDNSOptionsStart(const PacketBuffer& packet, const size_t offset, uint16_t* optRDPosition, size_t * remaining);
45bool isEDNSOptionInOpt(const PacketBuffer& packet, const size_t optStart, const size_t optLen, const uint16_t optionCodeToFind, size_t* optContentStart = nullptr, uint16_t* optContentLen = nullptr);
46bool addEDNS(PacketBuffer& packet, size_t maximumSize, bool dnssecOK, uint16_t payloadSize, uint8_t ednsrcode);
e7c732b8 47bool addEDNSToQueryTurnedResponse(DNSQuestion& dq);
61643ae0 48bool 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 50bool handleEDNSClientSubnet(DNSQuestion& dq, bool& ednsAdded, bool& ecsAdded);
32fbb2ab 51bool handleEDNSClientSubnet(PacketBuffer& packet, size_t maximumSize, size_t qnameWireLength, bool& ednsAdded, bool& ecsAdded, bool overrideExisting, const string& newECSOption);
cbf4e13a 52
acf16adc 53bool parseEDNSOptions(const DNSQuestion& dq);
cbf4e13a 54
e7c732b8
RG
55int getEDNSZ(const DNSQuestion& dq);
56bool queryHasEDNS(const DNSQuestion& dq);
582d5b58 57bool getEDNS0Record(const PacketBuffer& packet, EDNS0Record& edns0);
721569c1
RG
58
59bool setEDNSOption(DNSQuestion& dq, uint16_t ednsCode, const std::string& data);
27f38b46
RG
60
61namespace dnsdist {
62bool setInternalQueryRCode(InternalQueryState& state, PacketBuffer& buffer, uint8_t rcode, bool clearAnswers);
63}