-
Notifications
You must be signed in to change notification settings - Fork 3
/
DNS-rrs.cpp
41 lines (32 loc) · 1.05 KB
/
DNS-rrs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "DNS-rrs.hpp"
#include "DNS-iostream.hpp"
#include <cstring>
#include <arpa/inet.h>
#include <glog/logging.h>
namespace DNS {
RR_A::RR_A(uint8_t const* rd, size_t sz)
{
static_assert(sizeof(addr_.sin_addr) == 4);
CHECK_EQ(sz, sizeof(addr_.sin_addr));
std::memcpy(&addr_.sin_addr, rd, sizeof(addr_.sin_addr));
PCHECK(inet_ntop(AF_INET, &addr_.sin_addr, str_, sizeof str_));
}
RR_AAAA::RR_AAAA(uint8_t const* rd, size_t sz)
{
static_assert(sizeof(addr_.sin6_addr) == 16);
CHECK_EQ(sz, sizeof(addr_.sin6_addr));
std::memcpy(&addr_.sin6_addr, rd, sizeof(addr_.sin6_addr));
PCHECK(inet_ntop(AF_INET6, &addr_.sin6_addr, str_, sizeof str_));
}
RR_TLSA::RR_TLSA(uint8_t cert_usage,
uint8_t selector,
uint8_t matching_type,
std::span<octet const> data)
: cert_usage_(cert_usage)
, selector_(selector)
, matching_type_(matching_type)
{
assoc_data_.resize(data.size());
std::memcpy(assoc_data_.data(), data.data(), data.size());
}
} // namespace DNS