MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
dns_message.hpp
1#ifndef MSTL_NETWORK_DNS_MESSAGE_HPP
2#define MSTL_NETWORK_DNS_MESSAGE_HPP
3#include "MSTL/core/container/vector.hpp"
5#include "MSTL/core/string/string.hpp"
6#include "dns_constants.hpp"
8
9struct dns_record {
10 string name;
11 string data;
12 uint32_t ttl;
13 DNS_RECORD type;
14 DNS_QUERY class_type;
15
16 dns_record() = default;
17 dns_record(string n,
18 const DNS_RECORD t, const DNS_QUERY c,
19 const uint32_t ttl_val, string d)
20 : name(_MSTL move(n)), data(_MSTL move(d)),
21 ttl(ttl_val), type(t), class_type(c) {}
22};
23
24struct dns_query_result {
25 vector<dns_record> answers;
26 vector<dns_record> authorities;
27 vector<dns_record> additional;
28 DNS_RESPONSE response_code;
29 bool truncated;
30 bool recursive_available;
31 milliseconds query_time;
32
33 bool is_success() const noexcept {
34 return response_code == DNS_RESPONSE::NON_ERROR;
35 }
36};
37
38struct dns_header {
39 uint16_t id = 0;
40 uint16_t flags = 0;
41 uint16_t qdcount = 0;
42 uint16_t ancount = 0;
43 uint16_t nscount = 0;
44 uint16_t arcount = 0;
45
46 dns_header() = default;
47};
48
50#endif // MSTL_NETWORK_DNS_MESSAGE_HPP
MSTL持续时间类型
unsigned int uint32_t
32位无符号整数类型
unsigned short uint16_t
16位无符号整数类型
duration< int64_t, milli > milliseconds
毫秒持续时间
#define _MSTL
全局命名空间MSTL前缀
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result)
移动范围元素