acl  3.5.3.0
rfc1035.hpp
浏览该文件的文档.
1 //
2 // Created by shuxin   zheng on 2020/11/14.
3 //
4 
5 #pragma once
6 #include "../acl_cpp_define.hpp"
7 #include "../stdlib/string.hpp"
8 #include <vector>
9 
10 struct ACL_RFC1035_MESSAGE;
11 
12 namespace acl {
13 
14 typedef enum {
22 
24 public:
25  rfc1035_request(void);
26  ~rfc1035_request(void);
27 
28  rfc1035_request& set_name(const char* name);
29  rfc1035_request& set_qid(unsigned short id);
30  rfc1035_request& set_type(rfc1035_type_t type);
31 
32  const char* get_name(void) const {
33  return name_;
34  }
35 
36  unsigned short get_qid(void) const {
37  return qid_;
38  }
39 
40  rfc1035_type_t get_type(void) const {
41  return type_;
42  }
43 
44 public:
45  size_t build_query(char* buf, size_t size);
46  size_t build_query4ptr(const struct in_addr addr, char* buf, size_t size);
47  bool parse_request(const void* buf, size_t len);
48 
49 private:
50  char name_[256];
51  unsigned short qid_;
52  rfc1035_type_t type_;
53 };
54 
56 public:
57  rfc1035_response(void);
58  ~rfc1035_response(void);
59 
60  rfc1035_response& set_name(const char* name);
61  rfc1035_response& set_qid(unsigned short id);
62  rfc1035_response& set_type(rfc1035_type_t type);
63  rfc1035_response& set_ttl(int ttl);
64 
65  const char* get_name(void) const {
66  return name_;
67  }
68 
69  unsigned short get_qid(void) const {
70  return qid_;
71  }
72 
73  rfc1035_type_t get_type(void) const {
74  return type_;
75  }
76 
77  int get_ttl(void) const {
78  return ttl_;
79  }
80 
81 public:
82  size_t build_reply(const std::vector<string>& addrs,
83  char* buf, size_t size);
84  bool parse_reply(const void* buf, size_t len);
85 
86 private:
87  char name_[256];
88  unsigned short qid_;
89  rfc1035_type_t type_;
90  int ttl_;
91  std::vector<string> addrs4a_;
92  std::vector<string> addrs4aaaa_;
93  std::vector<string> cnames_;
94 };
95 
96 } // namespace acl
HTTP_API void const char * name
Definition: lib_http.h:620
int get_ttl(void) const
Definition: rfc1035.hpp:77
rfc1035_type_t get_type(void) const
Definition: rfc1035.hpp:40
rfc1035_type_t
Definition: rfc1035.hpp:14
unsigned short get_qid(void) const
Definition: rfc1035.hpp:36
rfc1035_type_t get_type(void) const
Definition: rfc1035.hpp:73
unsigned short get_qid(void) const
Definition: rfc1035.hpp:69
const char * get_name(void) const
Definition: rfc1035.hpp:32
const char * get_name(void) const
Definition: rfc1035.hpp:65
#define ACL_CPP_API