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


CTCPOptions Class Reference

#include <TCPSocket.h>

Inheritance diagram for CTCPOptions:
Collaboration diagram for CTCPOptions:

List of all members.


Public Member Functions

void AddOption_SegmentSize (unsigned short usMax)
void Reset ()
void SetAutoPad (BOOL bAutoPAD)
virtual void AddOption_ENDLIST ()
int GetBufferLength () const
const char * GetBuffer () const
virtual void AddOption_Nothing ()
 CTCPOptions ()
 CTCPOptions (const CTCPOptions &rOptions)
virtual ~CTCPOptions ()

Protected Types

typedef unsigned char OptionType
typedef struct
CIPOptions::_IPOption 
IPOption
typedef struct CIPOptions::_Routing Routing
enum  _LogPriority { lpDebug, lpMessage, lpCritical, lpError }
typedef enum
CErrorHandler::_LogPriority 
LogPriority

Protected Member Functions

void AddOption_Route (OptionType aRouteType, Routing aRoute)
void AddToBuffer (const char *pBuffer, int iBufLength)
OptionType GetOption (unsigned char ucCopyFlag, unsigned char ucClassFlag, unsigned char ucTypeFlag)
void AddOption_Timestamp (OptionType tFlags, int iMaxStamps)
void AddOption_LooseRoute (Routing tRoute)
void AddOption_RecordRoute (int iMaxRoutes)
void AddOption_StrictRoute (Routing tRoute)
void AddOption_Stream (unsigned short usStreamID)
virtual void AddOption_Security (unsigned short usType)
int GetSystemLastError () const
int GetLastError () const
virtual void NotifyShutdown ()
void RegisterShutdown (CSpoofBase *pBase)
void SetLastError (const std::string &rMethod) const
void SetLastError (const std::string &, int iErrorCode) const
void SetLocalLog (CErrorLog *pLog)
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 int GetErrorCode ()
static BOOL IsInitialized ()
static unsigned long StringToLong (const std::string &rAddress)
static char FAR * LongToString (unsigned long ulAddr)
static std::string LongToStdString (unsigned long ulAddr)
static BOOL InitializeSockets (BOOL bMultiThreaded=TRUE, unsigned long ulNumberOfThreads=10)
static BOOL InitializeSocketsNoMap (BOOL bMultiThreaded=TRUE, unsigned long ulNumberOfThreads=10)
static BOOL ShutdownSockets ()
static unsigned long GetNumberOfThreads ()
static BOOL IsMultiThreaded ()
static CGenericCriticalSectionGetGlobalCriticalSection ()
static std::string GetCurrentDateTime ()
static std::string ErrorCodeToString (DWORD dwErrorCode)
static void SetLog (CErrorLog *pLog)
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)

Static Protected Attributes

static CGenericCriticalSectionm_pCSection = NULL

Detailed Description

Definition at line 88 of file TCPSocket.h.


Member Typedef Documentation

typedef struct CIPOptions::_IPOption CIPOptions::IPOption [inherited]

typedef unsigned char CIPOptions::OptionType [inherited]

Definition at line 359 of file SpoofSocket.h.

typedef struct CIPOptions::_Routing CIPOptions::Routing [inherited]


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

CTCPOptions::CTCPOptions (  ) 

Definition at line 124 of file TCPSocket.cpp.

00124                          : CIPOptions()
00125 {
00126     try
00127     {
00128         SetName(CTCPOptions_LOGNAME);
00129     }
00130     ERROR_HANDLER("CTCPOptions")
00131 }

CTCPOptions::CTCPOptions ( const CTCPOptions rOptions  ) 

Definition at line 133 of file TCPSocket.cpp.

00133                                                     : CIPOptions(rOptions)
00134 {
00135     try
00136     {
00137         SetName(CTCPOptions_LOGNAME);
00138     }
00139     ERROR_HANDLER("CTCPOptions")
00140 }

CTCPOptions::~CTCPOptions (  )  [virtual]

Definition at line 142 of file TCPSocket.cpp.

00143 {
00144 }


Member Function Documentation

void CTCPOptions::AddOption_ENDLIST (  )  [virtual]

Reimplemented from CIPOptions.

Definition at line 74 of file TCPSocket.cpp.

00075 {
00076     try
00077     {
00078         //Add option end list
00079         OptionType aOptionType;
00080 
00081         //Get the option
00082         aOptionType=TCPOptions_END;
00083 
00084         //Add it to buffer
00085         AddToBuffer((char*)&aOptionType,sizeof(aOptionType));
00086     }
00087     ERROR_HANDLER("AddOption_ENDLIST")
00088 }

void CIPOptions::AddOption_LooseRoute ( Routing  tRoute  )  [inherited]

Definition at line 377 of file SpoofSocket.cpp.

00378 {
00379     try
00380     {
00381         AddOption_Route(IPOption_LOOSE_ROUTING,tRoute);
00382     }
00383     ERROR_HANDLER("AddOption_LooseRoute")
00384 }

void CTCPOptions::AddOption_Nothing (  )  [virtual]

Reimplemented from CIPOptions.

Definition at line 108 of file TCPSocket.cpp.

00109 {
00110     try
00111     {
00112         //Add option do nothing
00113         OptionType aOptionType;
00114 
00115         //Get the option
00116         aOptionType=TCPOptions_NO_OPERATION;
00117 
00118         //Add it to buffer
00119         AddToBuffer((char*)&aOptionType,sizeof(aOptionType));
00120     }
00121     ERROR_HANDLER("AddOption_Nothing")
00122 }

void CIPOptions::AddOption_RecordRoute ( int  iMaxRoutes  )  [inherited]

Definition at line 308 of file SpoofSocket.cpp.

00309 {
00310     try
00311     {
00312         //Option for strict routine
00313         //Add option strict route
00314         OptionType aOptionType;
00315 
00316         //Get the option
00317         aOptionType=GetOption(IPOption_DONT_COPY,
00318                               IPOption_CONTROL,
00319                               IPOption_RECORD_ROUTE);
00320 
00321         //Add it to buffer
00322         AddToBuffer((char*)&aOptionType,
00323                     sizeof(aOptionType));
00324 
00325         //Add the length
00326         aOptionType=iMaxRoutes*4+IPOption_STRICT_ROUTING_LENGTH;
00327         AddToBuffer((char*)&aOptionType,
00328                     sizeof(aOptionType));
00329         
00330         //Add the pointer
00331         aOptionType=IPOption_STRICT_ROUTING_POINTER;
00332         AddToBuffer((char*)&aOptionType,
00333                     sizeof(aOptionType));
00334         
00335         char cNothing[IPOption_SIZE]="";
00336         AddToBuffer(cNothing,
00337                     iMaxRoutes*4);
00338     }
00339     ERROR_HANDLER("AddOption_RecordRoute")
00340 }

void CIPOptions::AddOption_Route ( OptionType  aRouteType,
Routing  aRoute 
) [protected, inherited]

Definition at line 342 of file SpoofSocket.cpp.

00344 {
00345     try
00346     {
00347         //Option for strict routine
00348         //Add option strict route
00349         OptionType aOptionType;
00350 
00351         //Get the option
00352         aOptionType=GetOption(IPOption_COPY,
00353                               IPOption_CONTROL,
00354                               aRouteType);
00355 
00356         //Add it to buffer
00357         AddToBuffer((char*)&aOptionType,
00358                     sizeof(aOptionType));
00359 
00360         //Add the length
00361         aOptionType=aRoute.iRoutes*4+IPOption_STRICT_ROUTING_LENGTH;
00362         AddToBuffer((char*)&aOptionType,
00363                     sizeof(aOptionType));
00364         
00365         //Add the pointer
00366         aOptionType=IPOption_STRICT_ROUTING_POINTER;
00367         AddToBuffer((char*)&aOptionType,
00368                     sizeof(aOptionType));
00369         
00370         //Add the routing table
00371         AddToBuffer((char*)aRoute.ulRoutes,
00372                     aRoute.iRoutes*4);
00373     }
00374     ERROR_HANDLER("AddOption_Route")
00375 }

void CIPOptions::AddOption_Security ( unsigned short  usType  )  [virtual, inherited]

Definition at line 216 of file SpoofSocket.cpp.

00217 {
00218     try
00219     {
00220         //Add option security
00221         OptionType aOptionType;
00222 
00223         //Get the option
00224         aOptionType=GetOption(IPOption_COPY,
00225                               IPOption_CONTROL,
00226                               IPOption_SECURITY);
00227 
00228         //Add it to buffer
00229         AddToBuffer((char*)&aOptionType,
00230                     sizeof(aOptionType));
00231 
00232         //Add length
00233         aOptionType=IPOption_SECURITY_LENGTH;
00234         AddToBuffer((char*)&aOptionType,
00235                     sizeof(aOptionType));
00236 
00237         //Add options
00238         AddToBuffer((char*)&usType,
00239                     sizeof(usType));
00240 
00241         //Add zeros
00242         unsigned short usZeros;
00243         usZeros=0;
00244         unsigned char ucZeros;
00245         ucZeros=0;
00246 
00247         //A hacker would enumarate these values, according to the RFC
00248         //Compartments
00249         AddToBuffer((char*)&usZeros,
00250                     sizeof(usZeros));
00251 
00252         //Handling restrictions
00253         AddToBuffer((char*)&usZeros,
00254                     sizeof(usZeros));
00255 
00256         //Transmition control code (TCC)
00257         AddToBuffer((char*)&usZeros,
00258                     sizeof(usZeros));
00259         AddToBuffer((char*)&ucZeros,
00260                     sizeof(ucZeros));
00261 
00262         //Done
00263     }
00264     ERROR_HANDLER("AddOption_Security")
00265 }

void CTCPOptions::AddOption_SegmentSize ( unsigned short  usMax  ) 

Definition at line 146 of file TCPSocket.cpp.

00147 {
00148     try
00149     {
00150         //Add option Max segment
00151         OptionType aOptionType;
00152 
00153         //Get the option
00154         aOptionType=TCPOptions_MAX_Segment;
00155 
00156         //Add it to buffer
00157         AddToBuffer((char*)&aOptionType,
00158                     sizeof(aOptionType));
00159 
00160         //Add length
00161         aOptionType=TCPOptions_MAX_Segment_Length;
00162         AddToBuffer((char*)&aOptionType,
00163                     sizeof(aOptionType));
00164 
00165         //Add segment size
00166         unsigned short usOT;
00167         usOT=htons(usMax);
00168 
00169         //Add it
00170         AddToBuffer((char*)&usOT,
00171                     sizeof(usOT));
00172     }
00173     ERROR_HANDLER("AddOption_SegmentSize")
00174 }

void CIPOptions::AddOption_Stream ( unsigned short  usStreamID  )  [inherited]

Definition at line 267 of file SpoofSocket.cpp.

00268 {
00269     try
00270     {
00271         //Add option security
00272         OptionType aOptionType;
00273 
00274         //Get the option
00275         aOptionType=GetOption(IPOption_COPY,
00276                               IPOption_CONTROL,
00277                               IPOption_STREAM);
00278 
00279         //Add it to buffer
00280         AddToBuffer((char*)&aOptionType,
00281                     sizeof(aOptionType));
00282 
00283         //Add length
00284         aOptionType=IPOption_STREAM_LENGTH;
00285         AddToBuffer((char*)&aOptionType,
00286                     sizeof(aOptionType));
00287         
00288         //Convert endian format
00289         unsigned short usnStreamID;
00290         usnStreamID=htons(usStreamID);
00291         
00292         //Add options
00293         AddToBuffer((char*)&usnStreamID,
00294                     sizeof(usnStreamID));
00295     }
00296     ERROR_HANDLER("AddOption_Stream")
00297 }

void CIPOptions::AddOption_StrictRoute ( Routing  tRoute  )  [inherited]

Definition at line 299 of file SpoofSocket.cpp.

00300 {
00301     try
00302     {
00303         AddOption_Route(IPOption_STRICT_ROUTING,tRoute);
00304     }
00305     ERROR_HANDLER("AddOption_StrictRoute")
00306 }

void CIPOptions::AddOption_Timestamp ( OptionType  tFlags,
int  iMaxStamps 
) [inherited]

Definition at line 386 of file SpoofSocket.cpp.

00387 {
00388     try
00389     {
00390         //Add option for timestamp
00391         OptionType aOptionType;
00392 
00393         //Get the option
00394         aOptionType=GetOption(IPOption_DONT_COPY,
00395                               IPOption_DEBUGGING,
00396                               IPOption_TIMESTAMP);
00397 
00398         //Add it to buffer
00399         AddToBuffer((char*)&aOptionType,
00400                     sizeof(aOptionType));
00401 
00402         //Add the length
00403         aOptionType=iMaxStamps*IPOption_TIMESTAMP_SIZE+IPOption_TIMESTAMP_LENGTH-1;
00404         AddToBuffer((char*)&aOptionType,
00405                     sizeof(aOptionType));
00406         
00407         //Add the pointer
00408         aOptionType=IPOption_TIMESTAMP_LENGTH;
00409         AddToBuffer((char*)&aOptionType,
00410                     sizeof(aOptionType));
00411 
00412         //Add the flags
00413         AddToBuffer((char*)&tFlags,
00414                     sizeof(tFlags));
00415 
00416         //Add the empty buffer
00417         char cNothing[IPOption_SIZE]="";
00418         AddToBuffer(cNothing,
00419                     iMaxStamps*IPOption_TIMESTAMP_SIZE);
00420     }
00421     ERROR_HANDLER("AddOption_Timestamp")
00422 }

void CIPOptions::AddToBuffer ( const char *  pBuffer,
int  iBufLength 
) [protected, inherited]

Definition at line 137 of file SpoofSocket.cpp.

00139 {
00140     if (m_iBufferLength<IPOption_SIZE)
00141     {
00142         //Add our option to the buffer
00143         memcpy(m_pBuffer+m_iBufferLength,
00144                pBuffer,
00145                iBufLength);
00146 
00147         //Adjust the size
00148         m_iBufferLength+=iBufLength;
00149     }
00150 }

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 char * CTCPOptions::GetBuffer (  )  const

Reimplemented from CIPOptions.

Definition at line 99 of file TCPSocket.cpp.

00100 {
00101     try
00102     {
00103         return CIPOptions::GetBuffer();
00104     }
00105     ERROR_HANDLER_RETURN("GetBuffer",NULL)
00106 }

int CTCPOptions::GetBufferLength (  )  const

Reimplemented from CIPOptions.

Definition at line 90 of file TCPSocket.cpp.

00091 {
00092     try
00093     {
00094         return CIPOptions::GetBufferLength();
00095     }
00096     ERROR_HANDLER_RETURN("GetBufferLength",0)
00097 }

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 }

int CSpoofBase::GetErrorCode (  )  [static, inherited]

Definition at line 488 of file SpoofBase.cpp.

00489 {
00490     return SOCKET_ERROR;
00491 }

CGenericCriticalSection * CSpoofBase::GetGlobalCriticalSection (  )  [static, inherited]

Definition at line 483 of file SpoofBase.cpp.

00484 {
00485     return m_pCSection;
00486 }

int CSpoofBase::GetLastError (  )  const [inherited]

Definition at line 138 of file SpoofBase.cpp.

00139 {
00140     return m_iLastError;
00141 }

unsigned long CSpoofBase::GetNumberOfThreads (  )  [static, inherited]

Definition at line 463 of file SpoofBase.cpp.

00464 {
00465     return m_ulNumberOfThreads;
00466 }

CIPOptions::OptionType CIPOptions::GetOption ( unsigned char  ucCopyFlag,
unsigned char  ucClassFlag,
unsigned char  ucTypeFlag 
) [protected, inherited]

Definition at line 127 of file SpoofSocket.cpp.

00130 {
00131     //Return a single option type
00132     return ucCopyFlag | 
00133            ucClassFlag | 
00134            ucTypeFlag;
00135 }

int CSpoofBase::GetSystemLastError (  )  const [inherited]

Definition at line 478 of file SpoofBase.cpp.

00479 {
00480     return WSAGetLastError();
00481 }

BOOL CSpoofBase::InitializeSockets ( BOOL  bMultiThreaded = TRUE,
unsigned long  ulNumberOfThreads = 10 
) [static, inherited]

Definition at line 279 of file SpoofBase.cpp.

00281 {
00282     //To avoid double initialize
00283     if (m_bInitialized)
00284     {
00285         //Report it
00286         ReportStaticError(CSpoofBase_Class,"InitializeSockets","Already initialized!");
00287 
00288         //Exit
00289         return TRUE;
00290     }
00291 
00292     //Check that the number of threads are OK?
00293     if (ulNumberOfThreads>CLibConfig::GetInstance().GetMaxThreads())
00294     {
00295         //Report it
00296         ReportStaticError(CSpoofBase_Class,"InitializeSockets","Too many threads!");
00297 
00298         //Exit
00299         return FALSE;
00300     }
00301 
00302     //Do we have threads at all
00303     if (bMultiThreaded &&
00304         !ulNumberOfThreads)
00305     {
00306         //Report it
00307         ReportStaticError(CSpoofBase_Class,"InitializeSockets","Didn't receive any threads!");
00308 
00309         //Exit
00310         return FALSE;
00311     }
00312 
00313     try
00314     {
00315         //Initialize the sockets
00316         WORD wVersionRequested;
00317         wVersionRequested=MAKEWORD(2,2);
00318  
00319         //Try to initialize
00320         WSADATA wsaData;
00321         int iErr;
00322         iErr=WSAStartup(wVersionRequested, 
00323                         &wsaData);
00324 
00325         //Did we succeed?
00326         if (iErr!=0)
00327             /* Tell the user that we could not find a usable */
00328             /* WinSock DLL.                                  */
00329             return FALSE;
00330  
00331         /* Confirm that the WinSock DLL supports 2.2.*/
00332         /* Note that if the DLL supports versions greater    */
00333         /* than 2.2 in addition to 2.2, it will still return */
00334         /* 2.2 in wVersion since that is the version we      */
00335         /* requested.                                        */
00336  
00337         if (LOBYTE(wsaData.wVersion)!=2 || 
00338             HIBYTE(wsaData.wVersion)!=2)
00339         {
00340             /* Tell the user that we could not find a usable */
00341             /* WinSock DLL.                                  */
00342             WSACleanup();
00343 
00344             //Exit
00345             return FALSE;
00346         }
00347 
00348         //Save the threading information
00349         m_bMultiThreaded=bMultiThreaded;
00350         m_ulNumberOfThreads=ulNumberOfThreads;
00351 
00352         //Create the critical section
00353         m_pCSection=COSManager::CreateCriticalSection();
00354 
00355         //And we are initialized
00356         m_bInitialized=TRUE;
00357 
00358         return TRUE;
00359     }
00360     ERROR_HANDLER_STATIC_RETURN(CSpoofBase_Class,"InitializeSockets",FALSE)
00361 }

BOOL CSpoofBase::InitializeSocketsNoMap ( BOOL  bMultiThreaded = TRUE,
unsigned long  ulNumberOfThreads = 10 
) [static, inherited]

Definition at line 202 of file SpoofBase.cpp.

00204 {
00205     //To avoid double initialize
00206     if (m_bInitialized)
00207     {
00208         //Report it
00209         ReportStaticError(CSpoofBase_Class,"InitializeSocketsNoMap","Already initialized!");
00210 
00211         //Exit
00212         return TRUE;
00213     }
00214 
00215     //Check that the number of threads are OK?
00216     if (ulNumberOfThreads>CLibConfig::GetInstance().GetMaxThreads())
00217     {
00218         //Report it
00219         ReportStaticError(CSpoofBase_Class,"InitializeSocketsNoMap","Too many threads!");
00220 
00221         //Exit
00222         return FALSE;
00223     }
00224 
00225     //Do we have threads at all
00226     if (bMultiThreaded &&
00227         !ulNumberOfThreads)
00228     {
00229         //Report it
00230         ReportStaticError(CSpoofBase_Class,"InitializeSocketsNoMap","Didn't receive any threads!");
00231 
00232         //Exit
00233         return FALSE;
00234     }
00235 
00236     try
00237     {
00238         //Create the thread data
00239         ThreadData* pThreadData;
00240         pThreadData=new ThreadData;
00241 
00242         //Populate the data
00243         pThreadData->pEvent=COSManager::CreateEvent();
00244         pThreadData->bMultiThreaded=bMultiThreaded;
00245         pThreadData->ulNumberOfThreads=ulNumberOfThreads;
00246 
00247         //Create the thread
00248         m_pThread=new CManagedThread(InitProc);
00249         m_pThread->Start((LPVOID)pThreadData);
00250 
00251         //Wait on the event
00252         if (pThreadData->pEvent->Wait(THREAD_TIMEOUT))
00253         {
00254             //Report it
00255             ReportStaticError(CSpoofBase_Class,"InitializeSocketsNoMap","Timeout waiting for thread");
00256 
00257             //Delete the thread
00258             delete m_pThread;
00259             m_pThread=NULL;
00260 
00261             //Exit
00262             return FALSE;
00263         }
00264 
00265         //Are we initialized
00266         if (!IsInitialized())
00267         {
00268             //Delete the thread
00269             delete m_pThread;
00270             m_pThread=NULL;
00271         }
00272 
00273         //Done
00274         return IsInitialized();
00275     }
00276     ERROR_HANDLER_STATIC_RETURN(CSpoofBase_Class,"InitializeSocketsNoMap",FALSE)
00277 }

BOOL CSpoofBase::IsInitialized (  )  [static, inherited]

Definition at line 468 of file SpoofBase.cpp.

00469 {
00470     return m_bInitialized;
00471 }

BOOL CSpoofBase::IsMultiThreaded (  )  [static, inherited]

Definition at line 458 of file SpoofBase.cpp.

00459 {
00460     return m_bMultiThreaded;
00461 }

std::string CSpoofBase::LongToStdString ( unsigned long  ulAddr  )  [static, inherited]

Definition at line 420 of file SpoofBase.cpp.

00421 {
00422     try
00423     {
00424         //First create the address
00425         in_addr addr;
00426 
00427         //Assign it
00428         addr.S_un.S_addr=ulAddr;
00429 
00430         //Enter the critical section
00431         CCriticalAutoRelease aRelease(m_pCSection);
00432 
00433         //Return the value
00434         return inet_ntoa(addr);
00435     }
00436     ERROR_HANDLER_STATIC_RETURN(CSpoofBase_Class,"LongToStdString","0.0.0.0")
00437 }

char FAR * CSpoofBase::LongToString ( unsigned long  ulAddr  )  [static, inherited]

Definition at line 439 of file SpoofBase.cpp.

00440 {
00441     try
00442     {
00443         //First create the address
00444         in_addr addr;
00445 
00446         //Assign it
00447         addr.S_un.S_addr=ulAddr;
00448 
00449         //Enter the critical section
00450         CCriticalAutoRelease aRelease(m_pCSection);
00451 
00452         //Return the value
00453         return inet_ntoa(addr);
00454     }
00455     ERROR_HANDLER_STATIC_RETURN(CSpoofBase_Class,"LongToString",NULL)
00456 }

void CSpoofBase::NotifyShutdown (  )  [protected, virtual, inherited]

Definition at line 402 of file SpoofBase.cpp.

00403 {
00404 }

void CSpoofBase::RegisterShutdown ( CSpoofBase pBase  )  [protected, inherited]

Definition at line 406 of file SpoofBase.cpp.

00407 {
00408     try
00409     {
00410         //Check if we already have a class
00411         if (m_pShutdownClass)
00412             delete m_pShutdownClass;
00413 
00414         //Take it
00415         m_pShutdownClass=pBase;
00416     }
00417     ERROR_HANDLER("RegisterShutdown")
00418 }

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 }

void CTCPOptions::Reset (  ) 

Reimplemented from CIPOptions.

Definition at line 56 of file TCPSocket.cpp.

00057 {
00058     try
00059     {
00060         CIPOptions::Reset();
00061     }
00062     ERROR_HANDLER("Reset")
00063 }

void CTCPOptions::SetAutoPad ( BOOL  bAutoPAD  ) 

Reimplemented from CIPOptions.

Definition at line 65 of file TCPSocket.cpp.

00066 {
00067     try
00068     {
00069         CIPOptions::SetAutoPad(bAutoPAD);
00070     }
00071     ERROR_HANDLER("SetAutoPad")
00072 }

void CSpoofBase::SetLastError ( const std::string &  rMethod,
int  iErrorCode 
) const [protected, inherited]

Definition at line 122 of file SpoofBase.cpp.

00124 {
00125     try
00126     {
00127         //First set the error
00128         m_iLastError=iErrorCode;
00129 
00130         //Check if there is an error
00131         if (m_iLastError)
00132             ReportError(rMethod,
00133                         m_iLastError);
00134     }
00135     ERROR_HANDLER("SetLastError")
00136 }

void CSpoofBase::SetLastError ( const std::string &  rMethod  )  const [protected, inherited]

Definition at line 103 of file SpoofBase.cpp.

00104 {
00105     try
00106     {
00107 #ifdef WIN32
00108         //First set the error
00109         m_iLastError=WSAGetLastError();
00110 #else
00111         m_iLastError=errno();
00112 #endif
00113 
00114         //Check if there is an error
00115         if (m_iLastError)
00116             ReportError(rMethod,
00117                         m_iLastError);
00118     }
00119     ERROR_HANDLER("SetLastError")
00120 }

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 }

BOOL CSpoofBase::ShutdownSockets (  )  [static, inherited]

Definition at line 363 of file SpoofBase.cpp.

00364 {
00365     //Only if initialized
00366     if (!m_bInitialized)
00367         return TRUE;
00368 
00369     try
00370     {
00371         //Do we have a thread?
00372         if (m_pThread)
00373         {
00374             //Delete it
00375             delete m_pThread;
00376             m_pThread=NULL;
00377         }
00378 
00379         //Delete the CS
00380         delete m_pCSection;
00381         m_pCSection=NULL;
00382 
00383         //Notify shutdown class
00384         if (m_pShutdownClass)
00385         {
00386             m_pShutdownClass->NotifyShutdown();
00387             delete m_pShutdownClass;
00388         }
00389 
00390         if (WSACleanup()==GetErrorCode())
00391             return FALSE;
00392 
00393         //Not initialized anymore
00394         m_bInitialized=FALSE;
00395 
00396         //Done
00397         return TRUE;
00398     }
00399     ERROR_HANDLER_STATIC_RETURN(CSpoofBase_Class,"ShutdownSockets",FALSE)
00400 }

unsigned long CSpoofBase::StringToLong ( const std::string &  rAddress  )  [static, inherited]

Definition at line 473 of file SpoofBase.cpp.

00474 {
00475     return inet_addr(rAddress.c_str());
00476 }

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 }


Member Data Documentation

CGenericCriticalSection * CSpoofBase::m_pCSection = NULL [static, protected, inherited]

Definition at line 124 of file SpoofBase.h.


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