]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/protobuf.hh
rec: Don't account chained queries more than once
[thirdparty/pdns.git] / pdns / protobuf.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 */
d9d3f9c1
RG
22#pragma once
23
24#include <cstddef>
25#include <string>
26
27#include "config.h"
28
d9d3f9c1
RG
29#ifdef HAVE_PROTOBUF
30#include <boost/uuid/uuid.hpp>
31#include <boost/uuid/uuid_generators.hpp>
32#include "dnsmessage.pb.h"
33#endif /* HAVE_PROTOBUF */
34
dad05827
PD
35#include "dnsname.hh"
36#include "iputils.hh"
37
d9d3f9c1
RG
38class DNSProtoBufMessage
39{
40public:
41 enum DNSProtoBufMessageType {
42 Query,
4898a348
RG
43 Response,
44 OutgoingQuery,
45 IncomingResponse
d9d3f9c1
RG
46 };
47
48 DNSProtoBufMessage()
49 {
50 }
51
52 DNSProtoBufMessage(DNSProtoBufMessage::DNSProtoBufMessageType type);
53
54 ~DNSProtoBufMessage()
55 {
56 }
57
4898a348 58 void setType(DNSProtoBufMessage::DNSProtoBufMessageType type);
d9d3f9c1 59 void setQuestion(const DNSName& qname, uint16_t qtype, uint16_t qclass);
a94bc5d7 60 void setEDNSSubnet(const Netmask& subnet, uint8_t mask=128);
d9d3f9c1
RG
61 void setBytes(size_t bytes);
62 void setTime(time_t sec, uint32_t usec);
58307a85 63 void setQueryTime(time_t sec, uint32_t usec);
d9d3f9c1 64 void setResponseCode(uint8_t rcode);
165c9030 65 void addRRsFromPacket(const char* packet, const size_t len, bool includeCNAME=false);
d9d3f9c1 66 void serialize(std::string& data) const;
a94673ea
RG
67 void setRequestor(const std::string& requestor);
68 void setRequestor(const ComboAddress& requestor);
69 void setResponder(const std::string& responder);
70 void setResponder(const ComboAddress& responder);
67e31ebe 71 void setRequestorId(const std::string& requestorId);
590388d2 72 void setDeviceId(const std::string& deviceId);
d9d3f9c1 73 std::string toDebugString() const;
e6956c91 74 void addTag(const std::string& strValue);
ff09c374 75 void addRR(const DNSName& qame, uint16_t utype, uint16_t uClass, uint32_t uTTl, const std::string& strBlob);
26a6373d 76
d9d3f9c1
RG
77#ifdef HAVE_PROTOBUF
78 DNSProtoBufMessage(DNSProtoBufMessage::DNSProtoBufMessageType type, const boost::uuids::uuid& uuid, const ComboAddress* requestor, const ComboAddress* responder, const DNSName& domain, int qtype, uint16_t qclass, uint16_t qid, bool isTCP, size_t bytes);
79 void update(const boost::uuids::uuid& uuid, const ComboAddress* requestor, const ComboAddress* responder, bool isTCP, uint16_t id);
80 void setUUID(const boost::uuids::uuid& uuid);
4898a348 81 void setInitialRequestID(const boost::uuids::uuid& uuid);
d9d3f9c1
RG
82
83protected:
84 PBDNSMessage d_message;
85#endif /* HAVE_PROTOBUF */
86};