1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/llarp/dns/rr.hpp

51 lines
1 KiB
C++
Raw Normal View History

2018-12-03 23:22:59 +01:00
#ifndef LLARP_DNS_RR_HPP
#define LLARP_DNS_RR_HPP
2018-12-12 01:58:08 +01:00
#include <dns/name.hpp>
#include <dns/serialize.hpp>
#include <net/net_int.hpp>
2018-12-12 01:58:08 +01:00
2018-12-03 23:22:59 +01:00
#include <memory>
2018-12-12 01:58:08 +01:00
#include <vector>
2018-12-03 23:22:59 +01:00
namespace llarp
{
namespace dns
{
2018-12-04 17:16:43 +01:00
using RRClass_t = uint16_t;
using RRType_t = uint16_t;
2018-12-03 23:22:59 +01:00
using RR_RData_t = std::vector< byte_t >;
2018-12-04 17:16:43 +01:00
using RR_TTL_t = uint32_t;
2018-12-03 23:22:59 +01:00
struct ResourceRecord : public Serialize
{
2018-12-04 17:16:43 +01:00
ResourceRecord() = default;
ResourceRecord(const ResourceRecord& other);
ResourceRecord(ResourceRecord&& other);
2018-12-03 23:22:59 +01:00
bool
Encode(llarp_buffer_t* buf) const override;
bool
Decode(llarp_buffer_t* buf) override;
2019-02-25 00:46:37 +01:00
std::ostream&
print(std::ostream& stream, int level, int spaces) const;
2018-12-04 17:16:43 +01:00
2018-12-03 23:22:59 +01:00
Name_t rr_name;
RRType_t rr_type;
RRClass_t rr_class;
RR_TTL_t ttl;
RR_RData_t rData;
};
2019-02-25 00:46:37 +01:00
inline std::ostream&
operator<<(std::ostream& out, const ResourceRecord& rr)
{
return rr.print(out, -1, -1);
}
2018-12-03 23:22:59 +01:00
} // namespace dns
} // namespace llarp
#endif