build the sockaddr_un without copy
[ghsmtp.git] / DNS-rrs.cpp
blob19799e7f17ef9cc54c8182d23e291c4bf8e08f64
1 #include "DNS-rrs.hpp"
3 #include "DNS-iostream.hpp"
5 #include <cstring>
7 #include <arpa/inet.h>
9 #include <glog/logging.h>
11 namespace DNS {
13 RR_A::RR_A(uint8_t const* rd, size_t sz)
15 CHECK_EQ(sz, sizeof(addr_.sin_addr));
16 std::memcpy(&addr_.sin_addr, rd, sizeof(addr_.sin_addr));
17 static_assert(sizeof(addr_.sin_addr) == 4);
18 PCHECK(inet_ntop(AF_INET, &addr_.sin_addr, str_, sizeof str_));
21 RR_AAAA::RR_AAAA(uint8_t const* rd, size_t sz)
23 CHECK_EQ(sz, sizeof(addr_.sin6_addr));
24 std::memcpy(&addr_.sin6_addr, rd, sizeof(addr_.sin6_addr));
25 static_assert(sizeof(addr_.sin6_addr) == 16);
26 PCHECK(inet_ntop(AF_INET6, &addr_.sin6_addr, str_, sizeof str_));
29 RR_TLSA::RR_TLSA(uint8_t cert_usage,
30 uint8_t selector,
31 uint8_t matching_type,
32 uint8_t const* assoc_data,
33 size_t assoc_data_sz)
34 : cert_usage_(cert_usage)
35 , selector_(selector)
36 , matching_type_(matching_type)
38 assoc_data_.resize(assoc_data_sz);
39 std::memcpy(assoc_data_.data(), assoc_data, assoc_data_sz);
42 } // namespace DNS