2018-12-03 22:22:59 +00:00
|
|
|
#ifndef LLARP_DNS_RR_HPP
|
|
|
|
#define LLARP_DNS_RR_HPP
|
2018-12-12 02:52:51 +00:00
|
|
|
|
2018-12-12 00:58:08 +00:00
|
|
|
#include <dns/name.hpp>
|
|
|
|
#include <dns/serialize.hpp>
|
2019-01-11 01:42:02 +00:00
|
|
|
#include <net/net_int.hpp>
|
2018-12-12 00:58:08 +00:00
|
|
|
|
2018-12-03 22:22:59 +00:00
|
|
|
#include <memory>
|
2018-12-12 00:58:08 +00:00
|
|
|
#include <vector>
|
2018-12-03 22:22:59 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dns
|
|
|
|
{
|
2018-12-04 16:16:43 +00:00
|
|
|
using RRClass_t = uint16_t;
|
|
|
|
using RRType_t = uint16_t;
|
2018-12-03 22:22:59 +00:00
|
|
|
using RR_RData_t = std::vector< byte_t >;
|
2018-12-04 16:16:43 +00:00
|
|
|
using RR_TTL_t = uint32_t;
|
2018-12-03 22:22:59 +00:00
|
|
|
|
|
|
|
struct ResourceRecord : public Serialize
|
|
|
|
{
|
2018-12-04 16:16:43 +00:00
|
|
|
ResourceRecord() = default;
|
|
|
|
ResourceRecord(const ResourceRecord& other);
|
|
|
|
ResourceRecord(ResourceRecord&& other);
|
|
|
|
|
2018-12-03 22:22:59 +00:00
|
|
|
bool
|
|
|
|
Encode(llarp_buffer_t* buf) const override;
|
|
|
|
|
|
|
|
bool
|
|
|
|
Decode(llarp_buffer_t* buf) override;
|
|
|
|
|
2018-12-04 16:16:43 +00:00
|
|
|
friend std::ostream&
|
|
|
|
operator<<(std::ostream& out, const ResourceRecord& rr)
|
|
|
|
{
|
|
|
|
return out << "[RR name=" << rr.rr_name << " type=" << rr.rr_type
|
|
|
|
<< " class=" << rr.rr_class << " ttl=" << rr.ttl
|
|
|
|
<< " rdata=[" << rr.rData.size() << " bytes]";
|
|
|
|
}
|
|
|
|
|
2018-12-03 22:22:59 +00:00
|
|
|
Name_t rr_name;
|
|
|
|
RRType_t rr_type;
|
|
|
|
RRClass_t rr_class;
|
|
|
|
RR_TTL_t ttl;
|
|
|
|
RR_RData_t rData;
|
|
|
|
};
|
|
|
|
} // namespace dns
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|