Mixe for Privacy and Anonymity in the Internet
Public Member Functions
CASocketAddrUnix Class Reference

This is a class for Unix Domain Protocol Sockat Addresses. More...

#include <CASocketAddrUnix.hpp>

Inheritance diagram for CASocketAddrUnix:
[legend]
Collaboration diagram for CASocketAddrUnix:
[legend]

List of all members.

Public Member Functions

 CASocketAddrUnix ()
 Constructs an address with an empty path.
 CASocketAddrUnix (const CASocketAddrUnix &addr)
 Constructs an Unix Adress from an other Unix-Address.
SINT32 getType () const
 Returns the type (family) of the socket this address is for (always AF_LOCAL)
CASocketAddrclone () const
 Creates a new copy of this address.
SINT32 getSize () const
 Resturns the size of the SOCKADDR struct used.
const SOCKADDRLPSOCKADDR () const
 Makes a cast to SOCKADDR* .
SINT32 setPath (const char *path)
 Sets the path of this unix address.
UINT8getPath () const
 Retruns the path of this address.
virtual SINT32 toString (UINT8 *buff, UINT32 bufflen) const
 Returns a human readable string describing this address.

Detailed Description

This is a class for Unix Domain Protocol Sockat Addresses.

Definition at line 33 of file CASocketAddrUnix.hpp.


Constructor & Destructor Documentation

Constructs an address with an empty path.

Definition at line 34 of file CASocketAddrUnix.cpp.

Referenced by clone().

  {
    sun_family=AF_LOCAL;
    memset(sun_path,0,sizeof(sun_path));
  }

Constructs an Unix Adress from an other Unix-Address.

Definition at line 41 of file CASocketAddrUnix.cpp.

  {
    sun_family=AF_LOCAL;
    memcpy(sun_path,addr.sun_path,sizeof(sun_path));
  }

Member Function Documentation

CASocketAddr* CASocketAddrUnix::clone ( ) const [inline, virtual]

Creates a new copy of this address.

Returns:
a copy of this address

Implements CASocketAddr.

Definition at line 52 of file CASocketAddrUnix.hpp.

References CASocketAddrUnix().

          {
            return new CASocketAddrUnix(*this);
          }

Here is the call graph for this function:

Retruns the path of this address.

Gets the path for the unix domain protocol address.

Returns:
the path of this address or NULL if not set

The returned char array has to be freed by the caller using delete[].

Return values:
NULLif path was no specified yet
copyof the path value

Definition at line 69 of file CASocketAddrUnix.cpp.

References len.

Referenced by toString().

  {
    UINT32 len=strlen(sun_path);
    if(len==0)
      return NULL;
    UINT8* p=new UINT8[len+1];
    strcpy((char*)p,sun_path);
    return p;
  }
SINT32 CASocketAddrUnix::getSize ( ) const [inline, virtual]

Resturns the size of the SOCKADDR struct used.

return sizeof(sockaddr_un)

Implements CASocketAddr.

Definition at line 61 of file CASocketAddrUnix.hpp.

          {
            return sizeof(sockaddr_un);
          }
SINT32 CASocketAddrUnix::getType ( ) const [inline, virtual]

Returns the type (family) of the socket this address is for (always AF_LOCAL)

Return values:
AF_LOCAL

Implements CASocketAddr.

Definition at line 42 of file CASocketAddrUnix.hpp.

          {
            return AF_LOCAL;
          }
const SOCKADDR* CASocketAddrUnix::LPSOCKADDR ( ) const [inline, virtual]

Makes a cast to SOCKADDR* .

Implements CASocketAddr.

Definition at line 67 of file CASocketAddrUnix.hpp.

          {
            return (const ::LPSOCKADDR)(static_cast<const sockaddr_un*>(this));
          }     
SINT32 CASocketAddrUnix::setPath ( const char *  path)

Sets the path of this unix address.

Sets the path for the unix domain protocol address.

Parameters:
paththe new path of this address
Return values:
E_SUCCESSif succesful
E_UNKNOWNotherwise
Parameters:
paththe new path value (zero terminated)
Return values:
E_SUCCESSif no error occured
E_UNSPECIFIEDif path was NULL
E_SPACEif path was to long

Definition at line 53 of file CASocketAddrUnix.cpp.

References E_SPACE, E_SUCCESS, and E_UNSPECIFIED.

  {
    if(path==NULL)
      return E_UNSPECIFIED;
//    ((sockaddr_un*)m_pAddr)->sun_len=strlen(path);
    if(strlen(path)>=sizeof(sun_path))
      return E_SPACE;
    strcpy(sun_path,path);
    return E_SUCCESS;
  }
virtual SINT32 CASocketAddrUnix::toString ( UINT8 buff,
UINT32  bufflen 
) const [inline, virtual]

Returns a human readable string describing this address.

Parameters:
buffbuffer which holds the string
bufflensize of the buffer
Return values:
E_SPACEif the bufvfer is to small for the string
E_UNKNOWNif an error occured
E_SUCCESSif successfull

Implements CASocketAddr.

Definition at line 92 of file CASocketAddrUnix.hpp.

References E_SPACE, E_SUCCESS, E_UNKNOWN, and getPath().

          {
            UINT8* tmppath=getPath();
            if(tmppath==NULL)
              return E_UNKNOWN;
            SINT32 ret=snprintf((char*)buff,bufflen,"Unix address: %s",tmppath);
            delete[]tmppath;
            tmppath = NULL;
            if(ret<0)
              {
                return E_SPACE;
              }
            return E_SUCCESS;
          }

Here is the call graph for this function:


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