libassa 3.5.1
Public Member Functions | Private Attributes | List of all members
ASSA::UNIXAddress Class Reference

#include <UNIXAddress.h>

Inheritance diagram for ASSA::UNIXAddress:
ASSA::Address

Public Member Functions

 UNIXAddress (const char *socket_name_)
 Constructor. More...
 
 UNIXAddress (SA *socket_address_)
 Copy constructor. More...
 
virtual ~UNIXAddress ()
 Destructor. More...
 
const int getLength () const
 Retrieve address length. More...
 
SAgetAddress () const
 Retrieve underlying address structure. More...
 
- Public Member Functions inherited from ASSA::Address
 Address ()
 Constructor. More...
 
virtual ~Address ()
 Destructor. More...
 
bool good () const
 Valid address is constructed. More...
 
bool bad () const
 Indicates whether there was error during address construction process i.e. More...
 
 operator void * () const
 Conversion to void * (or bool) for testing where bool is required (in conditional statements). More...
 
bool operator! () const
 Alias to bad (). More...
 
virtual const int getLength () const =0
 Return length of the underlying address structure. More...
 
virtual SAgetAddress () const =0
 Retrieve pointer to the address structure. More...
 
virtual void dump ()
 Dump object state to the log file. More...
 

Private Attributes

SA_UN m_address
 UNIX socket address structure. More...
 

Additional Inherited Members

- Public Types inherited from ASSA::Address
enum  addr_state_t { goodbit =0 , badbit =1 }
 State bits. More...
 
typedef int addrstate
 
- Protected Member Functions inherited from ASSA::Address
void setstate (addrstate flag_)
 Set state of the Address object. More...
 

Detailed Description

Definition at line 28 of file UNIXAddress.h.

Constructor & Destructor Documentation

◆ UNIXAddress() [1/2]

UNIXAddress::UNIXAddress ( const char *  socket_name_)

Constructor.

Parameters
socket_name_UNIX path name

Definition at line 21 of file UNIXAddress.cpp.

23{
24 trace("UNIXAddress::UNIXAddress(char* name_)");
25
26 size_t len;
27 m_address.sun_family = AF_UNIX;
28
29 if ( (len = strlen(socket_name_)) > sizeof(m_address.sun_path) ) {
30 EL((ASSAERR,"Socket path name is too long (%d bytes)\n", len));
32 }
33 strcpy (m_address.sun_path, socket_name_);
34}
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition: Logger.h:429
#define EL(X)
A macro for writing error message to the Logger.
Definition: Logger.h:285
void setstate(addrstate flag_)
Set state of the Address object.
Definition: Address.h:111
@ badbit
bad state
Definition: Address.h:56
SA_UN m_address
UNIX socket address structure.
Definition: UNIXAddress.h:51
@ ASSAERR
ASSA and system errors
Definition: LogMask.h:34

References ASSA::ASSAERR, ASSA::Address::badbit, EL, m_address, ASSA::Address::setstate(), and trace.

◆ UNIXAddress() [2/2]

UNIXAddress::UNIXAddress ( SA socket_address_)

Copy constructor.

Parameters
socket_address_address to copy from

Definition at line 36 of file UNIXAddress.cpp.

38{
39 trace("UNIXAddress::UNIXAddress(SA_UN*)");
40
41 SA_UN* sa_un = (SA_UN*) saddr_;
42 m_address.sun_family = AF_UNIX;
43
44 size_t len = strlen(sa_un->sun_path);
45
46 if ( len > sizeof (m_address.sun_path) - 1 ) {
47 EL((ASSAERR,"Socket path name is too long (%d bytes)\n", len));
49 }
50 strcpy(m_address.sun_path, sa_un->sun_path);
51}
struct sockaddr_un SA_UN
Definition: Address.h:44

References ASSA::ASSAERR, ASSA::Address::badbit, EL, m_address, ASSA::Address::setstate(), and trace.

◆ ~UNIXAddress()

ASSA::UNIXAddress::~UNIXAddress ( )
inlinevirtual

Destructor.

Definition at line 55 of file UNIXAddress.h.

56{ trace("UNIXAddress::~UNIXAddress"); }

References trace.

Member Function Documentation

◆ getAddress()

SA * ASSA::UNIXAddress::getAddress ( ) const
inlinevirtual

Retrieve underlying address structure.

Implements ASSA::Address.

Definition at line 63 of file UNIXAddress.h.

64{ return (SA*) &m_address; }
struct sockaddr SA
Definition: Address.h:33

References m_address.

Referenced by ASSA::ConUDPSocket::unconnect().

◆ getLength()

const int ASSA::UNIXAddress::getLength ( ) const
inlinevirtual

Retrieve address length.

Implements ASSA::Address.

Definition at line 59 of file UNIXAddress.h.

60{ return sizeof (m_address); }

References m_address.

Member Data Documentation

◆ m_address

SA_UN ASSA::UNIXAddress::m_address
private

UNIX socket address structure.

Definition at line 51 of file UNIXAddress.h.

Referenced by getAddress(), getLength(), and UNIXAddress().


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