dns_resource_record.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_network.h"
00035 #include "../../Core/System/sharedptr.h"
00036 
00037 class CL_DataBuffer;
00038 class CL_DNSPacket;
00039 class CL_DNSResourceRecord_Impl;
00040 
00044 class CL_API_NETWORK CL_DNSResourceRecord
00045 {
00048 
00049 public:
00050         CL_DNSResourceRecord();
00051 
00052         ~CL_DNSResourceRecord();
00053 
00057 
00058 public:
00059 
00063         CL_String get_name() const;
00064 
00068         CL_String get_type() const;
00069 
00073         CL_String get_class() const;
00074 
00078         int get_ttl() const;
00079 
00080         const CL_DNSPacket &get_packet() const;
00081 
00085         int get_record_offset() const;
00086 
00090         int get_rdata_offset() const;
00091 
00095         int get_rdata_length() const;
00096 
00100         CL_String get_cname_cname() const;
00101 
00105         int get_mx_preference() const;
00106 
00110         CL_String get_mx_exchange() const;
00111 
00115         CL_String get_ns_nsdname() const;
00116 
00120         CL_String get_ptr_ptrdname() const;
00121 
00125         CL_String get_soa_mname() const;
00126 
00130         CL_String get_soa_rname() const;
00131 
00132         unsigned int get_soa_serial() const;
00133 
00137         int get_soa_refresh() const;
00138 
00142         int get_soa_retry() const;
00143 
00147         int get_soa_expire() const;
00148 
00149         unsigned int get_soa_minimum() const;
00150 
00151         unsigned int get_a_address() const;
00152 
00156         CL_String get_a_address_str() const;
00157 
00158         unsigned int get_wks_address() const;
00159 
00163         CL_String get_wks_address_str() const;
00164 
00165         unsigned char get_wks_protocol() const;
00166 
00170         CL_DataBuffer get_wks_bit_map() const;
00171 
00175 
00176 public:
00177 
00182         void set_record(CL_DNSPacket packet, int record_offset);
00183 
00189         static int type_to_int(const CL_String &qtype);
00190 
00196         static CL_String type_from_int(int qtype);
00197 
00203         static CL_String type_description(const CL_String &qtype);
00204 
00210         static CL_String type_description(int qtype);
00211 
00217         static int class_to_int(const CL_String &qclass);
00218 
00224         static CL_String class_from_int(int qclass);
00225 
00231         static CL_String class_description(const CL_String &qclass);
00232 
00238         static CL_String class_description(int qclass);
00239 
00246         static int find_domain_name_end(const CL_DataBuffer &packet, int offset);
00247 
00254         static CL_String read_domain_name(const CL_DataBuffer &packet, int offset);
00255 
00259 
00260 private:
00261         CL_SharedPtr<CL_DNSResourceRecord_Impl> impl;
00263 };
00264