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
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _DNSAnswer_H_
00037 #define _DNSAnswer_H_
00038
00039 #include "ErrorHandler.h"
00040
00041 #include "DNSQuery.h"
00042
00043 namespace KomodiaDNS
00044 {
00045
00046
00047 typedef struct _DnsRRHeader
00048 {
00049 std::string sName;
00050 unsigned short usType;
00051 unsigned short usClass;
00052 unsigned long ulTTL;
00053 unsigned short usRdlLength;
00054 std::string sData;
00055
00056
00057 _DnsRRHeader() : usType(0),
00058 usClass(0),
00059 ulTTL(0),
00060 usRdlLength(0)
00061 {
00062 }
00063 } DnsRRHeader;
00064
00065 typedef DnsRRHeader FAR * LPDnsRRHeader;
00066
00067
00068 typedef struct _DNSSOARecord
00069 {
00070 std::string sPrimaryNameServer;
00071 std::string sAuthorativeMailbox;
00072 unsigned long ulVersionNumber;
00073 unsigned long ulRefreshInterval;
00074 unsigned long ulRetryInterval;
00075 unsigned long ulExpirationLimit;
00076 unsigned long ulMinimumTTL;
00077
00078
00079 _DNSSOARecord() : ulVersionNumber(0),
00080 ulRefreshInterval(0),
00081 ulRetryInterval(0),
00082 ulExpirationLimit(0),
00083 ulMinimumTTL(0)
00084 {
00085 }
00086 } DNSSOARecord;
00087
00088 #define DNSSOARecordCopySize (sizeof(unsigned long)*5)
00089
00090 class CDNSAnswer : public CErrorHandler
00091 {
00092 public:
00093
00094 typedef enum _DnsHeaderType
00095 {
00096 dhQuestion,
00097 dhAnswer,
00098 dhAuthoritive,
00099 dhAdditional,
00100 dhNone
00101 } DnsHeaderType;
00102 public:
00103
00104 std::string GetAnswerParsed(BOOL bWindowsLines=TRUE,
00105 BOOL bBrief=TRUE)const;
00106
00107
00108 unsigned short GetMXPriority()const;
00109
00110
00111 const DNSSOARecord* GetSOARecord()const;
00112
00113
00114 const DnsRRHeader& GetAnswerStruct()const;
00115
00116
00117 DnsHeaderType GetAnswerType()const;
00118
00119
00120 CDNSQuery::DNSQueryTypes GetResourceType()const;
00121
00122
00123 const std::string& GetData()const;
00124
00125
00126 const std::string& GetName()const;
00127
00128
00129 void SetAnswerType(DnsHeaderType aType);
00130
00131
00132 int ParseBuffer(const char* pBuffer,
00133 const char* pOriginalBuffer);
00134
00135
00136 CDNSAnswer& operator=(const CDNSAnswer& rAnswer);
00137
00138
00139 CDNSAnswer();
00140 CDNSAnswer(const CDNSAnswer& rAnswer);
00141 virtual ~CDNSAnswer();
00142 private:
00143
00144 DNSSOARecord* ParseSOA(unsigned short usSOASize,
00145 const char* pBuffer,
00146 const char* pOriginalBuffer);
00147
00148
00149 void DeleteBuffer();
00150
00151
00152 std::string GetSOARecord(const std::string& rShift,
00153 const std::string& rTerminator)const;
00154
00155
00156 static std::string ConvertUL(unsigned long ulNumber);
00157
00158
00159 static std::string ConvertMS(unsigned long ulNumber);
00160
00161
00162 DnsHeaderType m_aAnswerType;
00163
00164
00165 DnsRRHeader m_aAnswer;
00166
00167
00168 unsigned short m_usMXPriority;
00169
00170
00171 DNSSOARecord* m_pSOA;
00172 };
00173
00174
00175 }
00176
00177 #endif