not used
[ghsmtp.git] / DNS-message.hpp
blob1d4f7514a081428aa519af12e3e84313cf9209b3
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;
23 using container_t = iobuffer<octet>;
25 message() = default;
27 explicit message(container_t::size_type sz)
28 : bfr_(sz)
30 CHECK_LE(sz, std::numeric_limits<uint16_t>::max());
33 explicit message(container_t&& bfr)
34 : bfr_{bfr}
36 CHECK_LE(size(), std::numeric_limits<uint16_t>::max());
39 uint16_t size() const { return bfr_.size(); }
41 // clang-format off
42 auto begin() const { return bfr_.data(); }
43 auto end() const { return bfr_.data() + bfr_.size(); }
44 // clang-format on
46 uint16_t id() const;
48 private:
49 container_t bfr_;
52 // clang-format off
53 inline auto begin(message const& pkt) { return pkt.begin(); }
54 inline auto end (message const& pkt) { return pkt.end(); }
55 inline auto size (message const& pkt) { return pkt.size(); }
56 // clang-format on
58 size_t min_message_sz();
60 DNS::message
61 create_question(char const* name, DNS::RR_type type, uint16_t cls, uint16_t id);
63 void check_answer(bool& nx_domain,
64 bool& bogus_or_indeterminate,
65 uint16_t& rcode,
66 uint16_t& extended_rcode,
67 bool& truncation,
68 bool& authentic_data,
69 bool& has_record,
70 message const& question,
71 message const& answer,
72 RR_type type,
73 char const* name);
75 RR_collection get_records(message const& pkt, bool& bogus_or_indeterminate);
77 } // namespace DNS
79 #endif // DNS_MESSAGE_DOT_HPP