Mixe for Privacy and Anonymity in the Internet
Public Member Functions | List of all members
CASocketAddrUnix Class Reference

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

#include <CASocketAddrUnix.hpp>

Inheritance diagram for CASocketAddrUnix:
Collaboration diagram for CASocketAddrUnix:

Public Member Functions

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

Detailed Description

This is a class for Unix Domain Protocol Sockat Addresses.

Definition at line 33 of file CASocketAddrUnix.hpp.

Constructor & Destructor Documentation

◆ CASocketAddrUnix() [1/2]

CASocketAddrUnix::CASocketAddrUnix ( )

Constructs an address with an empty path.

Definition at line 34 of file CASocketAddrUnix.cpp.

35  {
36  sun_family=AF_LOCAL;
37  memset(sun_path,0,sizeof(sun_path));
38  }
#define AF_LOCAL
Definition: StdAfx.h:482

References AF_LOCAL.

Referenced by clone().

Here is the caller graph for this function:

◆ CASocketAddrUnix() [2/2]

CASocketAddrUnix::CASocketAddrUnix ( const CASocketAddrUnix addr)

Constructs an Unix Adress from an other Unix-Address.

Definition at line 41 of file CASocketAddrUnix.cpp.

42  {
43  sun_family=AF_LOCAL;
44  memcpy(sun_path,addr.sun_path,sizeof(sun_path));
45  }

References AF_LOCAL.

Member Function Documentation

◆ clone()

CASocketAddr* CASocketAddrUnix::clone ( ) const
inlinevirtual

Creates a new copy of this address.

Returns
a copy of this address

Implements CASocketAddr.

Definition at line 52 of file CASocketAddrUnix.hpp.

53  {
54  return new CASocketAddrUnix(*this);
55  }
CASocketAddrUnix()
Constructs an address with an empty path.

References CASocketAddrUnix().

Here is the call graph for this function:

◆ getPath()

UINT8 * CASocketAddrUnix::getPath ( ) const

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.

70  {
71  UINT32 len=strlen(sun_path);
72  if(len==0)
73  return NULL;
74  UINT8* p=new UINT8[len+1];
75  strcpy((char*)p,sun_path);
76  return p;
77  }
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
UINT16 len
Definition: typedefs.hpp:0

References len.

Referenced by toString().

Here is the caller graph for this function:

◆ getSize()

SINT32 CASocketAddrUnix::getSize ( ) const
inlinevirtual

Resturns the size of the SOCKADDR struct used.

return sizeof(sockaddr_un)

Implements CASocketAddr.

Definition at line 61 of file CASocketAddrUnix.hpp.

62  {
63  return sizeof(sockaddr_un);
64  }

◆ getType()

SINT32 CASocketAddrUnix::getType ( ) const
inlinevirtual

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.

43  {
44  return AF_LOCAL;
45  }

References AF_LOCAL.

◆ LPSOCKADDR()

const SOCKADDR* CASocketAddrUnix::LPSOCKADDR ( ) const
inlinevirtual

Makes a cast to SOCKADDR* .

Implements CASocketAddr.

Definition at line 67 of file CASocketAddrUnix.hpp.

68  {
69  return (const ::LPSOCKADDR)(static_cast<const sockaddr_un*>(this));
70  }
SOCKADDR * LPSOCKADDR
Definition: StdAfx.h:459

◆ setPath()

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.

54  {
55  if(path==NULL)
56  return E_UNSPECIFIED;
57 // ((sockaddr_un*)m_pAddr)->sun_len=strlen(path);
58  if(strlen(path)>=sizeof(sun_path))
59  return E_SPACE;
60  strcpy(sun_path,path);
61  return E_SUCCESS;
62  }
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_SPACE
Definition: errorcodes.hpp:7
#define E_UNSPECIFIED
Definition: errorcodes.hpp:6

References E_SPACE, E_SUCCESS, and E_UNSPECIFIED.

◆ toString()

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

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.

93  {
94  UINT8* tmppath=getPath();
95  if(tmppath==NULL)
96  return E_UNKNOWN;
97  SINT32 ret=snprintf((char*)buff,bufflen,"Unix address: %s",tmppath);
98  delete[]tmppath;
99  tmppath = NULL;
100  if(ret<0)
101  {
102  return E_SPACE;
103  }
104  return E_SUCCESS;
105  }
signed int SINT32
Definition: basetypedefs.h:132
UINT8 * getPath() const
Retruns the path of this address.
#define E_UNKNOWN
Definition: errorcodes.hpp:3

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

Here is the call graph for this function:

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