]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/dnsdist-ecs.hh
dnsdist: Add SetNegativeAndSOAAction() and its Lua binding
[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
2aa2c0aa
RG
24// root label (1), type (2), class (2), ttl (4) + rdlen (2)
25static const size_t optRecordMinimumSize = 11;
26
e7c732b8
RG
27extern size_t g_EdnsUDPPayloadSize;
28extern uint16_t g_PayloadSizeSelfGenAnswers;
29
11d5d247
RG
30int rewriteResponseWithoutEDNS(const std::string& initialPacket, vector<uint8_t>& newContent);
31int locateEDNSOptRR(const std::string& packet, uint16_t * optStart, size_t * optLen, bool * last);
a9613dfe 32void generateOptRR(const std::string& optRData, string& res, uint16_t udpPayloadSize, uint8_t ednsrcode, bool dnssecOK);
cbf4e13a 33void generateECSOption(const ComboAddress& source, string& res, uint16_t ECSPrefixLength);
ff73f02b 34int removeEDNSOptionFromOPT(char* optStart, size_t* optLen, const uint16_t optionCodeToRemove);
11d5d247 35int rewriteResponseWithoutEDNSOption(const std::string& initialPacket, const uint16_t optionCodeToSkip, vector<uint8_t>& newContent);
cbf4e13a 36int getEDNSOptionsStart(const char* packet, const size_t offset, const size_t len, uint16_t* optRDPosition, size_t * remaining);
49c33a6c 37bool isEDNSOptionInOpt(const std::string& packet, const size_t optStart, const size_t optLen, const uint16_t optionCodeToFind, size_t* optContentStart = nullptr, uint16_t* optContentLen = nullptr);
a9613dfe 38bool addEDNS(dnsheader* dh, uint16_t& len, const size_t size, bool dnssecOK, uint16_t payloadSize, uint8_t ednsrcode);
e7c732b8 39bool addEDNSToQueryTurnedResponse(DNSQuestion& dq);
af9f750c 40bool 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);
e7c732b8 41
be90d6bd
RG
42bool handleEDNSClientSubnet(DNSQuestion& dq, bool& ednsAdded, bool& ecsAdded, bool preserveTrailingData);
43bool handleEDNSClientSubnet(char* packet, size_t packetSize, unsigned int consumed, uint16_t* len, bool& ednsAdded, bool& ecsAdded, bool overrideExisting, const string& newECSOption, bool preserveTrailingData);
cbf4e13a
RG
44
45bool parseEDNSOptions(DNSQuestion& dq);
46
e7c732b8
RG
47int getEDNSZ(const DNSQuestion& dq);
48bool queryHasEDNS(const DNSQuestion& dq);
2aa2c0aa 49bool getEDNS0Record(const DNSQuestion& dq, EDNS0Record& edns0);