removed
[ghsmtp.git] / DNS-message.hpp
blobf50bce2779b8e8c53b51a13b6107f14127794b5f
1 #ifndef DNS_MESSAGE_DOT_HPP
2 #define DNS_MESSAGE_DOT_HPP
4 #include <limits>
5 #include <memory>
7 #include "DNS-rrs.hpp"
9 #include "iobuffer.hpp"
11 #include <glog/logging.h>
13 namespace Config {
14 auto constexpr max_udp_sz{uint16_t(4 * 1024)};
15 } // namespace Config
17 namespace DNS {
19 class message {
20 public:
21 using octet = unsigned char;
22 using container_t = iobuffer<octet>;
24 message() = default;
26 explicit message(container_t::size_type sz)
27 : buf_(sz)
29 CHECK_LE(sz, std::numeric_limits<uint16_t>::max());
32 explicit message(container_t&& buf)
33 : buf_{buf}
35 CHECK_LE(buf.size(), std::numeric_limits<uint16_t>::max());
38 operator std::span<octet>() { return {buf_.data(), buf_.size()}; }
39 operator std::span<octet const>() const { return {buf_.data(), buf_.size()}; }
41 uint16_t id() const;
43 static size_t min_sz();
45 private:
46 container_t buf_;
49 DNS::message
50 create_question(char const* name, DNS::RR_type type, uint16_t cls, uint16_t id);
52 void check_answer(bool& nx_domain,
53 bool& bogus_or_indeterminate,
54 uint16_t& rcode,
55 uint16_t& extended_rcode,
56 bool& truncation,
57 bool& authentic_data,
58 bool& has_record,
59 message const& question,
60 message const& answer,
61 RR_type type,
62 char const* name);
64 RR_collection get_records(message const& pkt, bool& bogus_or_indeterminate);
66 } // namespace DNS
68 #endif // DNS_MESSAGE_DOT_HPP