2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
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.
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.
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.
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.
33 #include <boost/uuid/uuid.hpp>
34 #include "dnsmessage.pb.h"
35 #endif /* HAVE_PROTOBUF */
37 class DNSProtoBufMessage
40 enum DNSProtoBufMessageType {
51 DNSProtoBufMessage(DNSProtoBufMessage::DNSProtoBufMessageType type);
57 void setType(DNSProtoBufMessage::DNSProtoBufMessageType type);
58 void setQuestion(const DNSName& qname, uint16_t qtype, uint16_t qclass);
59 void setEDNSSubnet(const Netmask& subnet, uint8_t mask=128);
60 void setBytes(size_t bytes);
61 void setTime(time_t sec, uint32_t usec);
62 void setQueryTime(time_t sec, uint32_t usec);
63 void setResponseCode(uint8_t rcode);
64 void addRRsFromPacket(const char* packet, const size_t len, bool includeCNAME=false);
65 void serialize(std::string& data) const;
66 void setRequestor(const std::string& requestor);
67 void setRequestor(const ComboAddress& requestor);
68 void setResponder(const std::string& responder);
69 void setResponder(const ComboAddress& responder);
70 void setRequestorId(const std::string& requestorId);
71 void setDeviceId(const std::string& deviceId);
72 void setServerIdentity(const std::string& serverId);
73 std::string toDebugString() const;
74 void addTag(const std::string& strValue);
75 void addRR(const DNSName& qame, uint16_t utype, uint16_t uClass, uint32_t uTTl, const std::string& strBlob);
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);
81 void setInitialRequestID(const boost::uuids::uuid& uuid);
82 void copyFrom(const DNSProtoBufMessage& msg);
85 PBDNSMessage d_message;
86 #endif /* HAVE_PROTOBUF */