Retail products


Traffic interception SDK

Control every TCP/IP network connection

  • Route connections via proxy
  • Redirect connections and modify the data
  • Block connections and applications
SSL interception SDK

View SSL in plaintext and modify it

  • View the SSL stream decrypted in plaintext
  • Redirect SSL connection and modify decrypted data
  • Browser shows "SSL lock" without warnings

Documentation


KomodiaDNS::CDNSManager Class Reference

#include <DNSManager.h>

Inheritance diagram for KomodiaDNS::CDNSManager:
Collaboration diagram for KomodiaDNS::CDNSManager:

List of all members.


Classes

struct  _DNSData

Public Types

enum  _LogPriority { lpDebug, lpMessage, lpCritical, lpError }
typedef enum
CErrorHandler::_LogPriority 
LogPriority

Public Member Functions

CThreadPoolGetThreadManager () const
void SetDNSTimeout (DWORD dwMS)
BOOL SetConnectionTimeout (DWORD dwMS)
void Uninitialize ()
CDNSAnswersReceive ()
BOOL Initialize ()
BOOL IsInitialized () const
unsigned short GetDNSEntry (const std::string &rAddress, unsigned short usID=0, LPVOID lpLocalIDData=NULL)
unsigned short GetDNSEntry (unsigned long ulAddress, unsigned short usID=0, LPVOID lpLocalIDData=NULL)
void ParseMultithreaded (int iThreadNumber)
void ParseMultithreaded (CThreadPool *pThreadManager)
unsigned short QueryDNS (const CDNSQuery &rQuery, unsigned short usID=0, LPVOID lpLocalIDData=NULL)
 CDNSManager (const std::string strDNSServer, BOOL bTCP, BOOL bAsync, BOOL bAsyncConnect=FALSE)
virtual ~CDNSManager ()
void SetLocalLog (CErrorLog *pLog)

Static Public Member Functions

static std::string ParseAddress (const std::string &rAddress)
static std::string GetCurrentDateTime ()
static std::string ErrorCodeToString (DWORD dwErrorCode)
static void SetLog (CErrorLog *pLog)

Protected Member Functions

virtual LPDnsHeaderHeader GetDNSHeaderHeader (unsigned short usID, unsigned short usFlags, unsigned short usQuestions, unsigned short usAnswers=0) const
virtual void OnDNSError (int iErrorCode, LPVOID lpLocalIDData)
virtual void OnDNSTimeout (const CDNSQuery &rQuery, LPVOID lpLocalIDData)
virtual void OnDNSReceive (CDNSAnswers *pAnswers, LPVOID lpLocalIDData)
const std::string & GetClassName () const
void WriteMessage (const std::string &rMethod, const std::string &rMessage, LogPriority aPriority=lpMessage)
void WriteMessage (const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData, LogPriority aPriority=lpMessage)
virtual void ReportError (const std::string &rMethod) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData) const
virtual void ReportError (const std::string &rMethod, int iErrorCode) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage, int iErrorCode) const
virtual void ReportErrorOS (const std::string &rMethod, const std::string &rMessage) const
void SetName (const std::string &rName) const

Static Protected Member Functions

static void WriteStaticMessage (const std::string &rClass, const std::string &rMethod, const std::string &rMessage, LogPriority aPriority=lpMessage)
static void WriteStaticMessage (const std::string &rClass, const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData, LogPriority aPriority=lpMessage)
static void ReportStaticError (const std::string &rClass, const std::string &rMethod)
static void ReportStaticError (const std::string &rClass, const std::string &rMethod, const std::string &rMessage)
static void ReportStaticError (const std::string &rClass, const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData)

Friends

class CDNSSocket

Detailed Description

Definition at line 78 of file DNSManager.h.


Member Typedef Documentation


Member Enumeration Documentation

enum CErrorHandler::_LogPriority [inherited]

Enumerator:
lpDebug 
lpMessage 
lpCritical 
lpError 

Definition at line 53 of file ErrorHandler.h.

00054     {
00055         lpDebug,
00056         lpMessage,
00057         lpCritical,
00058         lpError
00059     } LogPriority;


Constructor & Destructor Documentation

KomodiaDNS::CDNSManager::CDNSManager ( const std::string  strDNSServer,
BOOL  bTCP,
BOOL  bAsync,
BOOL  bAsyncConnect = FALSE 
)

Definition at line 64 of file DNSManager.cpp.

00067                                              : CErrorHandler(),
00068                                                m_pSocket(NULL),
00069                                                m_strDNSServer(strDNSServer),
00070                                                m_iParseThreads(0),
00071                                                m_pCSection(NULL),
00072                                                m_bInitialized(FALSE),
00073                                                m_pThread(NULL),
00074                                                m_dwTimeout(0)
00075 {
00076     try
00077     {
00078         //Set our name
00079         SetName(CDNSManager_Class);
00080 
00081         //Set the values
00082         m_bAsync=bAsync;
00083         m_bTCP=bTCP;
00084 
00085         //Create the CS
00086         m_pCSection=COSManager::CreateCriticalSection();
00087 
00088         //Allocate our manager
00089         m_pSocket=new CDNSSocket(this,
00090                                 m_strDNSServer,
00091                                 m_bTCP,
00092                                 m_bAsync,
00093                                 bAsyncConnect);
00094 
00095         //Are we async ?
00096         if (m_bAsync)
00097         {
00098             //Create the timeout thread
00099             m_pThread=new CPeriodicThread(ThreadProc);
00100             
00101             //Set it's priority
00102             m_pThread->SetPriority(CGenericThread::tpAboveNormal);
00103 
00104             //Start it
00105             if (!m_pThread->Start(500,
00106                                   (LPVOID)this))
00107                 //Report it
00108                 ReportError("CDNSManager","Failed to start periodic thread!");
00109         }
00110     }
00111     ERROR_HANDLER("CDNSManager")
00112 }

KomodiaDNS::CDNSManager::~CDNSManager (  )  [virtual]

Definition at line 114 of file DNSManager.cpp.

00115 {
00116     try
00117     {
00118         //Delete the socket
00119         delete m_pSocket;
00120 
00121         //Delete the thread
00122         delete m_pThread;
00123 
00124         //And the CS
00125         delete m_pCSection;
00126     }
00127     ERROR_HANDLER("~CDNSManager")
00128 }


Member Function Documentation

std::string CErrorHandler::ErrorCodeToString ( DWORD  dwErrorCode  )  [static, inherited]

Definition at line 122 of file ErrorHandler.cpp.

00123 {
00124     try
00125     {
00126         //Get the error string
00127         LPVOID lpMsgBuf;
00128         FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 
00129                       FORMAT_MESSAGE_FROM_SYSTEM | 
00130                       FORMAT_MESSAGE_IGNORE_INSERTS,
00131                       NULL,
00132                       dwErrorCode,
00133                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
00134                       (LPTSTR) &lpMsgBuf,
00135                       0,
00136                       NULL);
00137 
00138         //Save it
00139         std::string sMessage;
00140         sMessage+=(char*)lpMsgBuf;
00141         
00142         //Release the buffer
00143         LocalFree(lpMsgBuf);
00144 
00145         //Done
00146         return sMessage;
00147     }
00148     catch (...)
00149     {
00150         return "Unknown";
00151     }
00152 }

const std::string & CErrorHandler::GetClassName (  )  const [protected, inherited]

Reimplemented in CSocketThreadManager.

Definition at line 516 of file ErrorHandler.cpp.

00517 {
00518     return m_sClassName;
00519 }

std::string CErrorHandler::GetCurrentDateTime (  )  [static, inherited]

Definition at line 521 of file ErrorHandler.cpp.

00522 {
00523     try
00524     {
00525         //Our string
00526         std::string sDate;
00527 
00528         //Our tmp buf
00529         char cTmp[128];
00530 
00531         //Get date
00532         _strdate(cTmp);
00533         sDate=cTmp;
00534         sDate+=' ';
00535 
00536         //Get time
00537         _strtime(cTmp);
00538         sDate+=cTmp;
00539 
00540         //Done
00541         return sDate;
00542     }
00543     ERROR_HANDLER_STATIC_RETURN(CErrorHandler_Class,"GetCurrentDateTime","")
00544 }

unsigned short KomodiaDNS::CDNSManager::GetDNSEntry ( unsigned long  ulAddress,
unsigned short  usID = 0,
LPVOID  lpLocalIDData = NULL 
)

Definition at line 335 of file DNSManager.cpp.

00338 {
00339     try
00340     {
00341         //Reverse the address
00342         long ulNewAddress;
00343         ulNewAddress=htonl(ulAddress);
00344 
00345         //Convert it to string
00346         std::string sAddr;
00347         sAddr=CSpoofBase::LongToStdString(ulNewAddress);
00348 
00349         //Add the arpa stuff
00350         sAddr+=".in-addr.arpa.";
00351 
00352         //Create the query
00353         CDNSQuery aQuery;
00354         aQuery.AddQuery(sAddr.c_str(),
00355                         CDNSQuery::PTR);
00356 
00357         //and query it
00358         return QueryDNS(aQuery,
00359                         usID,
00360                         lpLocalIDData);
00361     }
00362     ERROR_HANDLER_RETURN("GetDNSEntry",0)
00363 }

unsigned short KomodiaDNS::CDNSManager::GetDNSEntry ( const std::string &  rAddress,
unsigned short  usID = 0,
LPVOID  lpLocalIDData = NULL 
)

Definition at line 317 of file DNSManager.cpp.

00320 {
00321     try
00322     {
00323         //Convert it to long
00324         unsigned long ulAddress;
00325         ulAddress=CSpoofBase::StringToLong(rAddress);
00326 
00327         //And run the query
00328         return GetDNSEntry(ulAddress,
00329                            usID,
00330                            lpLocalIDData);
00331     }
00332     ERROR_HANDLER_RETURN("GetDNSEntry",0)
00333 }

LPDnsHeaderHeader KomodiaDNS::CDNSManager::GetDNSHeaderHeader ( unsigned short  usID,
unsigned short  usFlags,
unsigned short  usQuestions,
unsigned short  usAnswers = 0 
) const [protected, virtual]

Definition at line 181 of file DNSManager.cpp.

00185 {
00186     try
00187     {
00188         //Build the header
00189         LPDnsHeaderHeader lpHead;
00190         lpHead=new DnsHeaderHeader;
00191 
00192         lpHead->usID=htons(usID);
00193         lpHead->usOptions=usFlags;
00194         lpHead->usQDCount=htons(usQuestions);
00195         lpHead->usANCount=htons(usAnswers);
00196 
00197         //Done
00198         return lpHead;
00199     }
00200     ERROR_HANDLER_RETURN("GetDNSHeaderHeader",NULL)
00201 }

CThreadPool * KomodiaDNS::CDNSManager::GetThreadManager (  )  const

Definition at line 130 of file DNSManager.cpp.

00131 {
00132     return m_pSocket->GetThreadManager();
00133 }

BOOL KomodiaDNS::CDNSManager::Initialize (  ) 

Definition at line 399 of file DNSManager.cpp.

00400 {
00401     try
00402     {
00403         if (m_bInitialized)
00404             return TRUE;
00405         else
00406         {
00407             //Initialize the sockets
00408             m_bInitialized=m_pSocket->Initialize();
00409 
00410             //Exit
00411             return m_bInitialized;
00412         }
00413     }
00414     ERROR_HANDLER_RETURN("Initialize",FALSE)
00415 }

BOOL KomodiaDNS::CDNSManager::IsInitialized (  )  const

Definition at line 417 of file DNSManager.cpp.

00418 {
00419     return m_bInitialized;
00420 }

void KomodiaDNS::CDNSManager::OnDNSError ( int  iErrorCode,
LPVOID  lpLocalIDData 
) [protected, virtual]

Definition at line 381 of file DNSManager.cpp.

00383 {
00384 }

void KomodiaDNS::CDNSManager::OnDNSReceive ( CDNSAnswers pAnswers,
LPVOID  lpLocalIDData 
) [protected, virtual]

Definition at line 365 of file DNSManager.cpp.

00367 {
00368     try
00369     {
00370         //Here we received an answer, since a client should inherit this, I will delete it, to avoid leaks
00371         delete pAnswers;
00372     }
00373     ERROR_HANDLER("OnDNSReceive")
00374 }

void KomodiaDNS::CDNSManager::OnDNSTimeout ( const CDNSQuery rQuery,
LPVOID  lpLocalIDData 
) [protected, virtual]

Definition at line 376 of file DNSManager.cpp.

00378 {
00379 }

std::string KomodiaDNS::CDNSManager::ParseAddress ( const std::string &  rAddress  )  [static]

Definition at line 135 of file DNSManager.cpp.

00136 {
00137     try
00138     {
00139         //Our address
00140         std::string sAddress;
00141 
00142         //Index count
00143         int iIndex=0;
00144 
00145         //Our last found position
00146         std::string::size_type iLastPosition;
00147         iLastPosition=0;
00148 
00149         //Our current position
00150         std::string::size_type iFoundPos;
00151 
00152         //Start parsing
00153         while ((iFoundPos=rAddress.find_first_of('.',iLastPosition))!=std::string::npos)
00154         {
00155             //Put the position in the new string
00156             sAddress+=(char)(iFoundPos-iLastPosition);
00157 
00158             //Add the partial string
00159             sAddress+=rAddress.substr(iLastPosition,
00160                                       iFoundPos-iLastPosition);
00161 
00162             //Set the last position to be the current
00163             iLastPosition=iFoundPos+1;
00164         }
00165 
00166         //Only if not null
00167         if (rAddress.length()!=iLastPosition)
00168         {
00169             //Insert the last part of the string
00170             sAddress+=(char)(rAddress.length()-iLastPosition);
00171             sAddress+=rAddress.substr(iLastPosition,
00172                                       rAddress.length()-iLastPosition);
00173         }
00174 
00175         //Done
00176         return sAddress;
00177     }
00178     ERROR_HANDLER_STATIC_RETURN(CDNSManager_Class,"ParseAddress",NULL)
00179 }

void KomodiaDNS::CDNSManager::ParseMultithreaded ( CThreadPool pThreadManager  ) 

Definition at line 706 of file DNSManager.cpp.

00707 {
00708     try
00709     {
00710         //Pass it to the socket
00711         m_pSocket->SetMultithreaded(pThreadManager);
00712     }
00713     ERROR_HANDLER("ParseMultithreaded")
00714 }

void KomodiaDNS::CDNSManager::ParseMultithreaded ( int  iThreadNumber  ) 

Definition at line 386 of file DNSManager.cpp.

00387 {
00388     try
00389     {
00390         //Set the data
00391         m_iParseThreads=iThreadNumber;
00392 
00393         //And the socket
00394         m_pSocket->SetMultithreaded(m_iParseThreads);
00395     }
00396     ERROR_HANDLER("ParseMultithreaded")
00397 }

unsigned short KomodiaDNS::CDNSManager::QueryDNS ( const CDNSQuery rQuery,
unsigned short  usID = 0,
LPVOID  lpLocalIDData = NULL 
)

Definition at line 203 of file DNSManager.cpp.

00206 {
00207     try
00208     {
00209         //Are we initialized
00210         if (!m_bInitialized)
00211         {
00212             //Report it
00213             ReportError("QueryDNS","Not initialized!");
00214             
00215             //Exit
00216             return 0;
00217         }
00218 
00219         //Get the query size
00220         unsigned short usTotalSize;
00221         usTotalSize=rQuery.GetSerializationSize();
00222 
00223         //Is it bad?
00224         if (!usTotalSize)
00225         {
00226             //Report it
00227             ReportError("QueryDNS","Bad query size!");
00228             
00229             //Exit
00230             return 0;
00231         }
00232 
00233         //Add the dns header
00234         usTotalSize+=DnsHeaderHeaderLength;
00235 
00236         //Is it TCP
00237         if (m_bTCP)
00238             usTotalSize+=2;
00239 
00240         //Allocate the buffer
00241         char* pBuffer;
00242         pBuffer=new char[usTotalSize];
00243 
00244         //Protect it
00245         CArray_ptr<char> pProtection(pBuffer);
00246 
00247         //Keep track of position
00248         char* pBackupBuffer=pBuffer;
00249 
00250         if (m_bTCP)
00251             //Advance pointer
00252             pBuffer+=2;
00253 
00254         //Get the ID
00255         if (!usID)
00256         {
00257             //Get a running static ID
00258             static long lID=0;
00259             InterlockedIncrement(&lID);
00260             usID=lID;
00261         }
00262 
00263         //Get the DNS header 
00264         LPDnsHeaderHeader lpHead;
00265         lpHead=GetDNSHeaderHeader(usID,
00266                                   DNS_RECURSION,
00267                                   rQuery.GetQuestionCount());
00268 
00269         //Copy it
00270         memcpy(pBuffer,
00271                lpHead,
00272                DnsHeaderHeaderLength);
00273         pBuffer+=DnsHeaderHeaderLength;
00274 
00275         //Done with it
00276         delete lpHead;
00277 
00278         //Serialize the query
00279         if (!rQuery.SerializeQuery(pBuffer))
00280         {
00281             //Report it
00282             ReportError("QueryDNS","Failed to serialize query!");
00283             
00284             //Exit
00285             return 0;
00286         }
00287 
00288         //Fix the tcp header
00289         if (m_bTCP)
00290             *((unsigned short*)pBackupBuffer)=htons(usTotalSize-2);
00291 
00292         //Add the record
00293         AddRecord(usID,
00294                   lpLocalIDData,
00295                   m_dwTimeout,
00296                   rQuery);
00297 
00298         //Send the data
00299         BOOL bResult;
00300         bResult=m_pSocket->Send(pBackupBuffer,
00301                                 usTotalSize,
00302                                 lpLocalIDData);
00303 
00304         //If error remove the data
00305         if (!bResult)
00306             RemoveRecord(usID);
00307 
00308         //Check if all is OK
00309         if (bResult)
00310             return usID;
00311         else
00312             return 0;
00313     }
00314     ERROR_HANDLER_RETURN("QueryDNS",0)
00315 }

CDNSAnswers * KomodiaDNS::CDNSManager::Receive (  ) 

Definition at line 472 of file DNSManager.cpp.

00473 {
00474     try
00475     {
00476         //Are we initialized
00477         if (!m_bInitialized)
00478         {
00479             //Report it
00480             ReportError("Receive","Not initialized!");
00481             
00482             //Exit
00483             return NULL;
00484         }
00485 
00486         //Call socket
00487         return m_pSocket->Receive();
00488     }
00489     ERROR_HANDLER_RETURN("Receive",NULL)
00490 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage,
int  iErrorCode 
) const [protected, virtual, inherited]

Definition at line 154 of file ErrorHandler.cpp.

00157 {
00158     if (!GetLog())
00159         return;
00160 
00161     try
00162     {
00163         //Get the log
00164         CErrorLog* pLog;
00165         pLog=GetLog();
00166 
00167         //Convert the error code
00168         char aTmp[11];
00169         sprintf(aTmp,"%d",iErrorCode);
00170 
00171         //Get the string for it
00172         std::string sError;
00173         sError=rMessage;
00174         sError+=", and Socket error: ";
00175         sError+=aTmp;
00176         sError+=", ";
00177         sError+=ErrorCodeToString(iErrorCode);
00178 
00179         //Report to the log
00180         pLog->ReportError(m_sClassName,
00181                           rMethod,
00182                           sError);
00183     }
00184     ERROR_UNKNOWN("ReportError")
00185 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
int  iErrorCode 
) const [protected, virtual, inherited]

Definition at line 187 of file ErrorHandler.cpp.

00189 {
00190     if (!GetLog())
00191         return;
00192 
00193     try
00194     {
00195         //Get the log
00196         CErrorLog* pLog;
00197         pLog=GetLog();
00198 
00199         //Convert the error code
00200         char aTmp[11];
00201         sprintf(aTmp,"%d",iErrorCode);
00202 
00203         //Get the string for it
00204         std::string sError;
00205         sError="Socket error: ";
00206         sError+=aTmp;
00207         sError+=", ";
00208         sError+=ErrorCodeToString(iErrorCode);
00209 
00210         //Report to the log
00211         pLog->ReportError(m_sClassName,
00212                           rMethod,
00213                           sError);
00214     }
00215     ERROR_UNKNOWN("ReportError")
00216 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage,
DWORD  dwAdditionalData 
) const [protected, virtual, inherited]

Definition at line 275 of file ErrorHandler.cpp.

00278 {
00279     if (!GetLog())
00280         return;
00281 
00282     try
00283     {
00284         //Get the log
00285         CErrorLog* pLog;
00286         pLog=GetLog();
00287 
00288         //Convert the number
00289         char aTmp[11];
00290         ltoa(dwAdditionalData,aTmp,10);
00291 
00292         //Create the new message
00293         std::string sNewMessage(rMessage);
00294         sNewMessage+="Additional data: ";
00295         sNewMessage+=aTmp;
00296 
00297         //Report to the log
00298         pLog->ReportError(m_sClassName,
00299                           rMethod,
00300                           sNewMessage);
00301     }
00302     ERROR_UNKNOWN("ReportError")
00303 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage 
) const [protected, virtual, inherited]

Definition at line 218 of file ErrorHandler.cpp.

00220 {
00221     if (!GetLog())
00222         return;
00223 
00224     try
00225     {
00226         CErrorLog* pLog;
00227         pLog=GetLog();
00228 
00229         //Report to the log
00230         pLog->ReportError(m_sClassName,
00231                           rMethod,
00232                           rMessage);
00233     }
00234     ERROR_UNKNOWN("ReportError")
00235 }

void CErrorHandler::ReportError ( const std::string &  rMethod  )  const [protected, virtual, inherited]

Definition at line 311 of file ErrorHandler.cpp.

00312 {
00313     if (!GetLog())
00314         return;
00315 
00316     try
00317     {
00318 #ifdef WIN32
00319         //Get the last error
00320         DWORD dwLastError;
00321         dwLastError=GetLastError();
00322 
00323         //Report the error
00324         GetLog()->ReportError(m_sClassName,
00325                               rMethod,
00326                               ErrorCodeToString(dwLastError));
00327 
00328 #else
00329         GetLog()->ReportCatchError(m_sClassName,
00330                                    rMethod,
00331                                    "Unknown error!");
00332 #endif
00333     }
00334     ERROR_UNKNOWN("ReportError")
00335 }

void CErrorHandler::ReportErrorOS ( const std::string &  rMethod,
const std::string &  rMessage 
) const [protected, virtual, inherited]

Definition at line 237 of file ErrorHandler.cpp.

00239 {
00240     if (!GetLog())
00241         return;
00242 
00243     try
00244     {
00245         //Get the last error
00246         DWORD dwLastError;
00247         dwLastError=GetLastError();
00248 
00249         //Format the message
00250         std::string sMessage;
00251         sMessage=rMessage;
00252         sMessage+=", with error code: ";
00253 
00254         //Convert the error code
00255         char aTmp[11];
00256         itoa(dwLastError,aTmp,10);
00257 
00258         //Add it again
00259         sMessage+=aTmp;
00260         sMessage+=" ";
00261         sMessage+=ErrorCodeToString(dwLastError);
00262         
00263         //Get the log
00264         CErrorLog* pLog;
00265         pLog=GetLog();
00266 
00267         //Report to the log
00268         pLog->ReportError(m_sClassName,
00269                           rMethod,
00270                           sMessage);
00271     }
00272     ERROR_UNKNOWN("ReportErrorOS")
00273 }

void CErrorHandler::ReportStaticError ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage,
DWORD  dwAdditionalData 
) [static, protected, inherited]

Definition at line 489 of file ErrorHandler.cpp.

00493 {
00494     if (!m_pLog)
00495         return;
00496 
00497     try
00498     {
00499         //Convert the number
00500         char aTmp[11];
00501         ltoa(dwAdditionalData,aTmp,10);
00502 
00503         //Create the new message
00504         std::string sNewMessage(rMessage);
00505         sNewMessage+="Additional data: ";
00506         sNewMessage+=aTmp;
00507 
00508         //Report to the log
00509         m_pLog->ReportError(rClass,
00510                             rMethod,
00511                             sNewMessage);
00512     }
00513     ERROR_UNKNOWN("ReportStaticError")
00514 }

void CErrorHandler::ReportStaticError ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage 
) [static, protected, inherited]

Definition at line 472 of file ErrorHandler.cpp.

00475 {
00476     if (!m_pLog)
00477         return;
00478 
00479     try
00480     {
00481         //Report to the log
00482         m_pLog->ReportError(rClass,
00483                             rMethod,
00484                             rMessage);
00485     }
00486     ERROR_UNKNOWN("ReportStaticError")
00487 }

void CErrorHandler::ReportStaticError ( const std::string &  rClass,
const std::string &  rMethod 
) [static, protected, inherited]

Definition at line 446 of file ErrorHandler.cpp.

00448 {
00449     if (!m_pLog)
00450         return;
00451 
00452     try
00453     {
00454 #ifdef WIN32
00455         //Get the last error
00456         DWORD dwLastError;
00457         dwLastError=GetLastError();
00458 
00459         //Report the error
00460         m_pLog->ReportError(rClass,
00461                             rMethod,
00462                             ErrorCodeToString(dwLastError));
00463 #else
00464         m_pLog->ReportError(rClass,
00465                             rMethod,
00466                             "Unknown error!");
00467 #endif
00468     }
00469     ERROR_UNKNOWN("ReportStaticError")
00470 }

BOOL KomodiaDNS::CDNSManager::SetConnectionTimeout ( DWORD  dwMS  ) 

Definition at line 603 of file DNSManager.cpp.

00604 {
00605     try
00606     {
00607         //Are we initialized
00608         if (!m_bInitialized)
00609         {
00610             //Report it
00611             ReportError("SetTimeout","Not initialized!");
00612             
00613             //Exit
00614             return NULL;
00615         }
00616 
00617         //Set it
00618         return m_pSocket->SetConnectionTimeout(dwMS);
00619     }
00620     ERROR_HANDLER_RETURN("SetTimeout",FALSE)
00621 }

void KomodiaDNS::CDNSManager::SetDNSTimeout ( DWORD  dwMS  ) 

Definition at line 583 of file DNSManager.cpp.

00584 {
00585     try
00586     {
00587         //Are we initialized
00588         if (!m_bInitialized)
00589         {
00590             //Report it
00591             ReportError("SetTimeout","Not initialized!");
00592             
00593             //Exit
00594             return;
00595         }
00596 
00597         //Save the new timeout
00598         m_dwTimeout=dwMS;
00599     }
00600     ERROR_HANDLER("SetDNSTimeout")
00601 }

void CErrorHandler::SetLocalLog ( CErrorLog pLog  )  [inherited]

Definition at line 441 of file ErrorHandler.cpp.

00442 {
00443     m_pLocalLog=pLog;
00444 }

void CErrorHandler::SetLog ( CErrorLog pLog  )  [static, inherited]

Definition at line 305 of file ErrorHandler.cpp.

00306 {
00307     //Save the new log
00308     m_pLog=pLog;
00309 }

void CErrorHandler::SetName ( const std::string &  rName  )  const [protected, inherited]

Definition at line 116 of file ErrorHandler.cpp.

00117 {
00118     //Save the class name
00119     m_sClassName=rName;
00120 }

void KomodiaDNS::CDNSManager::Uninitialize (  ) 

Definition at line 422 of file DNSManager.cpp.

00423 {
00424     try
00425     {
00426         if (!m_bInitialized)
00427             return;
00428         else
00429         {
00430             //Not initialized
00431             m_bInitialized=FALSE;
00432             
00433             //Delete the socket
00434             delete m_pSocket;
00435             m_pSocket=NULL;
00436         }
00437     }
00438     ERROR_HANDLER("Uninitialize")
00439 }

void CErrorHandler::WriteMessage ( const std::string &  rMethod,
const std::string &  rMessage,
DWORD  dwAdditionalData,
LogPriority  aPriority = lpMessage 
) [protected, inherited]

Definition at line 355 of file ErrorHandler.cpp.

00359 {
00360     if (!GetLog())
00361         return;
00362 
00363     try
00364     {
00365         //Convert the number
00366         char aTmp[11];
00367         ltoa(dwAdditionalData,aTmp,10);
00368 
00369         //Create the new message
00370         std::string sNewMessage(rMessage);
00371         sNewMessage+="Additional data: ";
00372         sNewMessage+=aTmp;
00373 
00374         //Delegate the call
00375         GetLog()->WriteMessage(m_sClassName,
00376                                rMethod,
00377                                sNewMessage,
00378                                aPriority);
00379     }
00380     ERROR_UNKNOWN("WriteMessage")
00381 }

void CErrorHandler::WriteMessage ( const std::string &  rMethod,
const std::string &  rMessage,
LogPriority  aPriority = lpMessage 
) [protected, inherited]

Definition at line 337 of file ErrorHandler.cpp.

00340 {
00341     if (!GetLog())
00342         return;
00343 
00344     try
00345     {
00346         //Delegate the call
00347         GetLog()->WriteMessage(m_sClassName,
00348                                rMethod,
00349                                rMessage,
00350                                aPriority);
00351     }
00352     ERROR_UNKNOWN("WriteMessage")
00353 }

void CErrorHandler::WriteStaticMessage ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage,
DWORD  dwAdditionalData,
LogPriority  aPriority = lpMessage 
) [static, protected, inherited]

Definition at line 403 of file ErrorHandler.cpp.

00408 {
00409     if (!m_pLog)
00410         return;
00411 
00412     try
00413     {
00414         //Convert the number
00415         char aTmp[11];
00416         ltoa(dwAdditionalData,aTmp,10);
00417 
00418         //Create the new message
00419         std::string sNewMessage(rMessage);
00420         sNewMessage+="Additional data: ";
00421         sNewMessage+=aTmp;
00422 
00423         //Delegate the call
00424         m_pLog->WriteMessage(rClass,
00425                              rMethod,
00426                              sNewMessage,
00427                              aPriority);
00428     }
00429     ERROR_UNKNOWN("WriteStaticMessage")
00430 }

void CErrorHandler::WriteStaticMessage ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage,
LogPriority  aPriority = lpMessage 
) [static, protected, inherited]

Definition at line 383 of file ErrorHandler.cpp.

00388 {
00389     if (!m_pLog)
00390         return;
00391 
00392     try
00393     {
00394         //Delegate the call
00395         m_pLog->WriteMessage(rClass,
00396                              rMethod,
00397                              rMessage,
00398                              aPriority);
00399     }
00400     ERROR_UNKNOWN("WriteStaticMessage")
00401 }


Friends And Related Function Documentation

friend class CDNSSocket [friend]

Definition at line 81 of file DNSManager.h.


The documentation for this class was generated from the following files: