Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00031
00032 #pragma once
00033
00034 #include "../api_network.h"
00035 #include "../../Core/System/sharedptr.h"
00036 #include "../../Core/Text/string_types.h"
00037
00038 class CL_DataBuffer;
00039 class CL_DNSResourceRecord;
00040 class CL_DNSPacket_Impl;
00041
00045 class CL_API_NETWORK CL_DNSPacket
00046 {
00049
00050 public:
00051 CL_DNSPacket();
00052
00056 CL_DNSPacket(const CL_DataBuffer &data);
00057
00058 CL_DNSPacket(
00059 int query_id,
00060 int opcode,
00061 bool recursion_desired,
00062 const CL_String &question_name,
00063 int question_type,
00064 int question_class);
00065
00066 ~CL_DNSPacket();
00067
00071
00072 public:
00073 const CL_DataBuffer &get_data() const;
00074
00075 unsigned short get_query_id() const;
00076
00080 bool is_query() const;
00081
00085 bool is_response() const;
00086
00087 enum Opcode
00088 {
00089 opcode_query = 0,
00090 opcode_inverse_query = 1,
00091 opcode_status = 2
00092 };
00093
00097 int get_opcode() const;
00098
00102 bool is_authoriative_answer() const;
00103
00107 bool is_truncated() const;
00108
00112 bool is_recursion_desired() const;
00113
00117 bool is_recursion_available() const;
00118
00119 enum ResponseCode
00120 {
00121 response_ok = 0,
00122 response_format_error = 1,
00123 response_server_failure = 2,
00124 response_name_error = 3,
00125 response_not_implemented = 4,
00126 response_refused = 5
00127 };
00128
00132 int get_response_code() const;
00133
00137 int get_question_count() const;
00138
00142 int get_answer_count() const;
00143
00147 int get_nameserver_count() const;
00148
00152 int get_additional_count() const;
00153
00159 CL_String get_question_name(int index) const;
00160
00166 int get_question_type(int index) const;
00167
00173 int get_question_class(int index) const;
00174
00180 CL_DNSResourceRecord get_answer(int index) const;
00181
00187 CL_DNSResourceRecord get_nameserver(int index) const;
00188
00194 CL_DNSResourceRecord get_additional(int index) const;
00195
00199
00200 public:
00201
00205 void set_data(const CL_DataBuffer &data);
00206
00210 void set_query_id(unsigned short query_id);
00211
00215
00216 private:
00217 CL_SharedPtr<CL_DNSPacket_Impl> impl;
00219 };
00220