2018-12-03 22:22:59 +00:00
|
|
|
#include <llarp/dns/question.hpp>
|
2018-12-04 16:16:43 +00:00
|
|
|
#include <llarp/logger.hpp>
|
2018-12-03 22:22:59 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dns
|
|
|
|
{
|
2018-12-04 16:16:43 +00:00
|
|
|
Question::Question(Question&& other)
|
|
|
|
: qname(std::move(other.qname))
|
|
|
|
, qtype(std::move(other.qtype))
|
|
|
|
, qclass(std::move(other.qclass))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
Question::Question(const Question& other)
|
|
|
|
: qname(other.qname), qtype(other.qtype), qclass(other.qclass)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-12-03 22:22:59 +00:00
|
|
|
bool
|
|
|
|
Question::Encode(llarp_buffer_t* buf) const
|
|
|
|
{
|
|
|
|
if(!EncodeName(buf, qname))
|
|
|
|
return false;
|
2018-12-04 16:16:43 +00:00
|
|
|
if(!llarp_buffer_put_uint16(buf, qtype))
|
2018-12-03 22:22:59 +00:00
|
|
|
return false;
|
2018-12-04 16:16:43 +00:00
|
|
|
return llarp_buffer_put_uint16(buf, qclass);
|
2018-12-03 22:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Question::Decode(llarp_buffer_t* buf)
|
|
|
|
{
|
|
|
|
if(!DecodeName(buf, qname))
|
2018-12-04 16:16:43 +00:00
|
|
|
{
|
|
|
|
llarp::LogError("failed to decode name");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(!llarp_buffer_read_uint16(buf, &qtype))
|
|
|
|
{
|
|
|
|
llarp::LogError("failed to decode type");
|
2018-12-03 22:22:59 +00:00
|
|
|
return false;
|
2018-12-04 16:16:43 +00:00
|
|
|
}
|
|
|
|
if(!llarp_buffer_read_uint16(buf, &qclass))
|
|
|
|
{
|
|
|
|
llarp::LogError("failed to decode class");
|
2018-12-03 22:22:59 +00:00
|
|
|
return false;
|
2018-12-04 16:16:43 +00:00
|
|
|
}
|
|
|
|
return true;
|
2018-12-03 22:22:59 +00:00
|
|
|
}
|
|
|
|
} // namespace dns
|
|
|
|
} // namespace llarp
|