Mixes for Privacy and Anonymity in the Internet
Public Member Functions | Static Public Member Functions | Static Private Attributes | List of all members
CASocketAddrINet Class Reference

This class represents a socket address for Internet (IP) connections. More...

Inheritance diagram for CASocketAddrINet:
sockaddr_in CASocketAddr

Public Member Functions

SINT32 getType () const
 The type (family) of socket for which this address is useful. More...
 
 CASocketAddrINet ()
 Must be called once before using one of the CAsocketAddrINet functions. More...
 
 CASocketAddrINet (UINT16 port)
 Constructs an IP-Address for port and ANY local host ip. More...
 
 CASocketAddrINet (const CASocketAddrINet &addr)
 Constructs an IP-Address from an other IP Adress. More...
 
CASocketAddrclone () const
 Creates a copy of the Address. More...
 
const SOCKADDRLPSOCKADDR () const
 Makes a cast to struct SOCKADDR*. More...
 
SINT32 getSize () const
 Returns the Size of the SOCKADDR struct used. More...
 
SINT32 setAddr (const UINT8 *szIP, UINT16 port)
 Sets the address to szIP and port. More...
 
SINT32 setIP (UINT8 ip[4])
 Sets the IP-Numbers for this address. More...
 
SINT32 setPort (UINT16 port)
 Changes only(!) the port value of the address. More...
 
UINT16 getPort () const
 Returns the port value of the address. More...
 
SINT32 getHostName (UINT8 *buff, UINT32 len) const
 Returns the hostname for this address. More...
 
SINT32 getIP (UINT8 buff[4]) const
 Returns the IP-Numbers for this address. More...
 
SINT32 getIPAsStr (UINT8 *buff, UINT32 len) const
 Returns the IP-Number as an address string (doted-format). More...
 
bool isAnyIP ()
 
bool equalsIP (UINT8 ip[4]) const
 
virtual SINT32 toString (UINT8 *buff, UINT32 bufflen) const
 Returns a human readable representation of this address. More...
 
- Public Member Functions inherited from CASocketAddr
virtual ~CASocketAddr ()
 

Static Public Member Functions

static SINT32 init ()
 
static SINT32 cleanup ()
 
static SINT32 getLocalHostName (UINT8 *buff, UINT32 len)
 Returns the name of the local host. More...
 
static SINT32 getLocalHostIP (UINT8 ip[4])
 Returns the local IP-Address as four bytes. More...
 
static SINT32 getIPForString (UINT8 *strIP, UINT8 ip[4])
 

Static Private Attributes

static CAMutexm_pcsGet =NULL
 

Detailed Description

This class represents a socket address for Internet (IP) connections.

Constructor & Destructor Documentation

◆ CASocketAddrINet() [1/3]

CASocketAddrINet::CASocketAddrINet ( )

Must be called once before using one of the CAsocketAddrINet functions.

Should be called if CASocketAddrINEt functions are not longer needed. If needed again init() must be called Constructs a IP-Address for port 0 and ANY local host ip

References getSize(), and LPSOCKADDR().

Referenced by clone().

◆ CASocketAddrINet() [2/3]

CASocketAddrINet::CASocketAddrINet ( UINT16  port)

Constructs an IP-Address for port and ANY local host ip.

References getSize(), and LPSOCKADDR().

◆ CASocketAddrINet() [3/3]

CASocketAddrINet::CASocketAddrINet ( const CASocketAddrINet addr)

Constructs an IP-Address from an other IP Adress.

References getSize(), and LPSOCKADDR().

Member Function Documentation

◆ cleanup()

static SINT32 CASocketAddrINet::cleanup ( )
static

References E_SUCCESS, and m_pcsGet.

Referenced by CALibProxytest::cleanup().

◆ clone()

CASocketAddr* CASocketAddrINet::clone ( ) const
virtual

Creates a copy of the Address.

Implements CASocketAddr.

References CASocketAddrINet().

◆ equalsIP()

bool CASocketAddrINet::equalsIP ( UINT8  ip[4]) const

◆ getHostName()

SINT32 CASocketAddrINet::getHostName ( UINT8 buff,
UINT32  len 
) const

Returns the hostname for this address.

Parameters
buffbuffer for the returned zero terminated hostname
lenthe size of the buffer
Return values
E_SUCCESSif no error occured
E_UNKNOWN_HOSTif the name of the host could not be resolved
E_UNSPECIFIEDif buff was NULL
E_SPACEif size of the buffer is to small

References E_SPACE, E_SUCCESS, E_UNKNOWN_HOST, E_UNSPECIFIED, len, CAMutex::lock(), m_pcsGet, and CAMutex::unlock().

Referenced by CAAccountingBIInterface::initBIConnection().

◆ getIP()

SINT32 CASocketAddrINet::getIP ( UINT8  buff[4]) const

Returns the IP-Numbers for this address.

Parameters
buffbuffer for the returned IP-Address (4 Bytes)
Return values
E_SUCCESSif no error occured

References E_SUCCESS.

Referenced by getIPAsStr(), isAllowedToPassRestrictions(), and CALastMix::setTargets().

◆ getIPAsStr()

SINT32 CASocketAddrINet::getIPAsStr ( UINT8 buff,
UINT32  len 
) const

Returns the IP-Number as an address string (doted-format).

Parameters
buffbuffer for the returned IP-Address
lenbuffer-space
Return values
E_SUCCESSif no error occured

References E_SUCCESS, E_UNKNOWN, getIP(), and len.

Referenced by CAInfoService::getPaymentInstance(), CAInfoService::sendCascadeHelo(), CAInfoService::sendMixHelo(), CAInfoService::sendStatus(), and toString().

◆ getIPForString()

static SINT32 CASocketAddrINet::getIPForString ( UINT8 strIP,
UINT8  ip[4] 
)
static

References E_SUCCESS, and E_UNKNOWN.

◆ getLocalHostIP()

SINT32 CASocketAddrINet::getLocalHostIP ( UINT8  ip[4])
static

Returns the local IP-Address as four bytes.

Parameters
ipbuffer for the returned IP-Address
Return values
E_SUCCESSif no error occurs
E_UNKNOWNin case of an error

References E_SUCCESS, E_UNKNOWN, CAMutex::lock(), m_pcsGet, and CAMutex::unlock().

◆ getLocalHostName()

SINT32 CASocketAddrINet::getLocalHostName ( UINT8 buff,
UINT32  len 
)
static

Returns the name of the local host.

Parameters
buffbuffer for the returned zero terminated hostname
lenthe size of the buffer
Return values
E_SUCCESSif no error occured
E_UNKNOWN_HOSTif the name of the host could not be resolved
E_UNSPECIFIEDif buff was NULL
E_SPACEif size of the buffer is to small

References E_SPACE, E_SUCCESS, E_UNKNOWN_HOST, E_UNSPECIFIED, len, CAMutex::lock(), m_pcsGet, and CAMutex::unlock().

◆ getPort()

UINT16 CASocketAddrINet::getPort ( ) const

◆ getSize()

SINT32 CASocketAddrINet::getSize ( ) const
virtual

Returns the Size of the SOCKADDR struct used.

Returns
sizeof(sockaddr_in)

Implements CASocketAddr.

Referenced by CASocketAddrINet().

◆ getType()

SINT32 CASocketAddrINet::getType ( ) const
virtual

The type (family) of socket for which this address is useful.

Must be overwritten in subclasses.

Implements CASocketAddr.

◆ init()

static SINT32 CASocketAddrINet::init ( )
static

References E_SUCCESS, and m_pcsGet.

Referenced by CALibProxytest::init().

◆ isAnyIP()

bool CASocketAddrINet::isAnyIP ( )

Referenced by CALocalProxy::init().

◆ LPSOCKADDR()

const SOCKADDR* CASocketAddrINet::LPSOCKADDR ( ) const
virtual

Makes a cast to struct SOCKADDR*.

Implements CASocketAddr.

Referenced by CASocketAddrINet().

◆ setAddr()

SINT32 CASocketAddrINet::setAddr ( const UINT8 szIP,
UINT16  port 
)

Sets the address to szIP and port.

szIP could be either a hostname or an IP-Address of the form a.b.c.d . If szIP==NULL, the the IP-Adredress ist set to ANY local IP Address

Parameters
szIPnew value for IP-Address or hostname (zero terminated string)
portnew value for port
Return values
E_SUCCESSif no error occurs
E_UNKNOWN_HOSTif the hostname couldt not be resolved (or the ip is wrong). In this case the old values are NOT changed.

References E_SUCCESS, E_UNKNOWN_HOST, INADDR_NONE, CAMutex::lock(), m_pcsGet, and CAMutex::unlock().

Referenced by CAInfoService::getPaymentInstance(), CALocalProxy::init(), and CAAccountingBIInterface::setPIServerConfiguration().

◆ setIP()

SINT32 CASocketAddrINet::setIP ( UINT8  ip[4])

Sets the IP-Numbers for this address.

Parameters
ipbuffer with the IP-Address (4 Bytes)
Return values
E_SUCCESSif no error occured

References E_SUCCESS.

◆ setPort()

SINT32 CASocketAddrINet::setPort ( UINT16  port)

Changes only(!) the port value of the address.

Parameters
portnew value for port
Returns
always E_SUCCESS

References E_SUCCESS.

◆ toString()

virtual SINT32 CASocketAddrINet::toString ( UINT8 buff,
UINT32  bufflen 
) const
virtual

Returns a human readable representation of this address.

Parameters
buffbuffer which stores the address string
bufflensize of the buffer
Return values
E_SPACEif the buffer is to small
E_UNKNOWNif an error occured
E_SUCCESSif successfull

Implements CASocketAddr.

References E_SPACE, E_SUCCESS, E_UNKNOWN, getIPAsStr(), and getPort().

Member Data Documentation

◆ m_pcsGet

CAMutex * CASocketAddrINet::m_pcsGet =NULL
staticprivate