dns_resource_record.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
29 
30 #pragma once
31 
32 #include "../api_network.h"
33 #include <memory>
34 
35 namespace clan
36 {
39 
40 class DataBuffer;
41 class DNSPacket;
42 class DNSResourceRecord_Impl;
43 
45 class CL_API_NETWORK DNSResourceRecord
46 {
49 
50 public:
52 
54 
58 
59 public:
60 
64  std::string get_name() const;
65 
69  std::string get_type() const;
70 
74  std::string get_class() const;
75 
79  int get_ttl() const;
80 
81  const DNSPacket &get_packet() const;
82 
86  int get_record_offset() const;
87 
91  int get_rdata_offset() const;
92 
96  int get_rdata_length() const;
97 
101  std::string get_cname_cname() const;
102 
106  int get_mx_preference() const;
107 
111  std::string get_mx_exchange() const;
112 
116  std::string get_ns_nsdname() const;
117 
121  std::string get_ptr_ptrdname() const;
122 
126  std::string get_soa_mname() const;
127 
131  std::string get_soa_rname() const;
132 
133  unsigned int get_soa_serial() const;
134 
138  int get_soa_refresh() const;
139 
143  int get_soa_retry() const;
144 
148  int get_soa_expire() const;
149 
150  unsigned int get_soa_minimum() const;
151 
152  unsigned int get_a_address() const;
153 
157  std::string get_a_address_str() const;
158 
159  unsigned int get_wks_address() const;
160 
164  std::string get_wks_address_str() const;
165 
166  unsigned char get_wks_protocol() const;
167 
171  DataBuffer get_wks_bit_map() const;
172 
176 
177 public:
178 
183  void set_record(DNSPacket packet, int record_offset);
184 
190  static int type_to_int(const std::string &qtype);
191 
197  static std::string type_from_int(int qtype);
198 
204  static std::string type_description(const std::string &qtype);
205 
211  static std::string type_description(int qtype);
212 
218  static int class_to_int(const std::string &qclass);
219 
225  static std::string class_from_int(int qclass);
226 
232  static std::string class_description(const std::string &qclass);
233 
239  static std::string class_description(int qclass);
240 
247  static int find_domain_name_end(const DataBuffer &packet, int offset);
248 
255  static std::string read_domain_name(const DataBuffer &packet, int offset);
256 
260 
261 private:
262  std::shared_ptr<DNSResourceRecord_Impl> impl;
264 };
265 
266 }
267 
DNS packet.
Definition: dns_packet.h:45
General purpose data buffer.
Definition: databuffer.h:43
DNS resource record.
Definition: dns_resource_record.h:45