CBS_Mole Class Reference

The base class of all mole classes. More...

Inheritance diagram for CBS_Mole:

Inheritance graph
[legend]
Collaboration diagram for CBS_Mole:

Collaboration graph
[legend]
List of all members.

Public Member Functions

BOOL IsListening ()
FP_EXIT_PROC SetExitProc (FP_EXIT_PROC pProc, LPVOID pParam)
FP_RESTART_PROC SetRestartProc (FP_RESTART_PROC pProc, LPVOID pParam)
BOOL StartListen (DWORD dwIP, WORD wPort)
BOOL StopListen ()
virtual ~CBS_Mole ()

Protected Member Functions

 CBS_Mole (CBS_Trace *pTrace)
SOCKET GetConnectionSocket ()
LPVOID GetExitParam ()
FP_EXIT_PROC GetExitProc ()
DWORD GetIP ()
WORD GetPortNbr ()
LPVOID GetRestartParam ()
FP_RESTART_PROC GetRestartProc ()
virtual DWORD Read (LPTSTR pBuf, DWORD dwSize)
virtual DWORD Send (LPCSTR pBuf, DWORD dwSize=0)
virtual DWORD SendFile (LPCSTR lpFileName, LPCSTR lpEmptyNotification="The requested file contains no data.")
virtual DWORD SendTraceFile ()
DWORD SetSendBlockSize (DWORD dwNewSize)

Detailed Description

The base class of all mole classes.

Author:
Dror Otmi
Date:
12.07.2003
Version:
V 1.0 Initial version
An abstract class. The application must use one of it’s derived class (or to derive a class from this class and implement the pure virtual methods) in order to create a mole instance. At the moment telnet and HTTP respective HTTPS connection are implemented.
Note:
Caution: Imprudently usage of this class might lead to serious security leaks!!!


Constructor & Destructor Documentation

CBS_Mole::CBS_Mole CBS_Trace pTrace  )  [protected]
 

Constructor

Parameters:
pTrace The trace object for manipulating.

CBS_Mole::~CBS_Mole  )  [virtual]
 

Destructor.


Member Function Documentation

SOCKET CBS_Mole::GetConnectionSocket  )  [protected]
 

See return.

Returns:
The socket handle of the mole.

LPVOID CBS_Mole::GetExitParam  )  [protected]
 

See return.

Returns:
A pointer to the application defined exit parameter.

CBS_Mole::FP_EXIT_PROC CBS_Mole::GetExitProc  )  [protected]
 

See return.

Returns:
A pointer to the application defined exit procedure.

DWORD CBS_Mole::GetIP  )  [protected]
 

See return.

Returns:
The IP of the mole.

WORD CBS_Mole::GetPortNbr  )  [protected]
 

See return.

Returns:
The Port number of the Mole .

LPVOID CBS_Mole::GetRestartParam  )  [protected]
 

See return.

Returns:
A pointer to the application defined restart parameter.

CBS_Mole::FP_RESTART_PROC CBS_Mole::GetRestartProc  )  [protected]
 

See return.

Returns:
A pointer to the application defined restart procedure.

BOOL CBS_Mole::IsListening  ) 
 

See return.

Returns:
TRUE if the thread is in listening mode.

DWORD CBS_Mole::Read LPTSTR  pBuf,
DWORD  dwSize
[protected, virtual]
 

Reads from a socket.

Parameters:
pBuf The buffer to put the data.
dwSize The size of pBuf in bytes.
Returns:
The number of bytes received from the socket.
Exceptions:
CBS_SocketException will be thrown if the socket could not be selected for reading withing a timeout of 20 seconds or if a reading return with errors.

Reimplemented in CBS_HTTPSMole.

DWORD CBS_Mole::Send LPCSTR  pBuf,
DWORD  dwSize = 0
[protected, virtual]
 

Sends data to the client. The data are sent in blocks (default = 2048).

Parameters:
pBuf The buffer with the data.
dwSize The size in bytes of pBuf.
Returns:
The number of bytes sent or SOCKET_ERROR if a failure occurred.
Exceptions:
CBS_SocketException will be thrown if the socket could not be selected for sending withing a timeout of 5 second.

Reimplemented in CBS_HTTPSMole.

DWORD CBS_Mole::SendFile LPCSTR  lpFileName,
LPCSTR  lpEmptyNotification = "The requested file contains no data."
[protected, virtual]
 

Sends a content of a file to the client.

Parameters:
lpFileName The file name.
lpEmptyNotification A notification to send to the client if the file is empty. By default this paramter is initialized as "The requested file contains no data.". If this parameter is NULL, the function return 0 and nothing will be sent to the client.
Returns:
The number of bytes sent or SOCKET_ERROR if a failure occurred.
Note:
If the mole could not open the file, an error message will be sent to the client (and will be written to the trace) and the number of bytes sent will be returned.

DWORD CBS_Mole::SendTraceFile  )  [protected, virtual]
 

Send the content of the trace file to current connected client.

Returns:
The number of bytes sent or SOCKET_ERROR if something went wrong. If the file could not be opened, the function will send an error message to the client (and will be written to the trace) and will return the number of bytes sent (not an error code!!!).

Reimplemented in CBS_TelnetMole.

CBS_Mole::FP_EXIT_PROC CBS_Mole::SetExitProc CBS_Mole::FP_EXIT_PROC  pProc,
LPVOID  pParam
 

Sets the pointer to the callback function that will be invoked when the client sends exit request.

Parameters:
pProc A pointer to an application defined exit callback function.
pParam an application defined parameter that will be pass as an argument to the exit callback function.
Returns:
The pointer to the previous exit callback function associated with the object.

CBS_Mole::FP_RESTART_PROC CBS_Mole::SetRestartProc CBS_Mole::FP_RESTART_PROC  pProc,
LPVOID  pParam
 

Sets the pointer to the callback function that will be invoked when the client sends restart request.

Parameters:
pProc A pointer to an application defined restart callback function.
pParam an application defined parameter that will be pass as an argument to the restart callback function.
Returns:
The function return a pointer to the previous restart callback function associated with the object.

DWORD CBS_Mole::SetSendBlockSize DWORD  dwNewSize  )  [protected]
 

Sets the default block size for sending the data.

Parameters:
dwNewSize The new block size. Might not be zero.
Returns:
The old block size or zero if dwNewSize is zero.

BOOL CBS_Mole::StartListen DWORD  dwIP,
WORD  wPort
 

Starts listening for incoming connections.

Parameters:
dwIP The IP Address to use.
wPort The listening port.
Returns:
TRUE if the Mole could start listening.

BOOL CBS_Mole::StopListen  ) 
 

Stop listening.

Returns:
FALSE if the mole is not listening.
Bitspot AG


Bitspot AG
Rietlistrasse 1
CH-6345 Neuheim

Bitspot AG Logo

Phone:

+41 41 755 11 22

Fax:

+41 41 755 11 31

e-mail:

mail@bitspot.com

Web:

www.bitspot.com