Loading...
Searching...
No Matches
Address.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// Address.h
//------------------------------------------------------------------------------
// Copyright (C) 1997 Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef ADDRESS_H
#define ADDRESS_H
#if !defined (WIN32)
# include <netinet/in.h>
# include <netdb.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h> // addresses handling
# include <sys/un.h>
#endif
#include <string.h>
#include <errno.h>
#include "assa/Logger.h"
#include "assa/Assure.h"
namespace ASSA {
typedef struct sockaddr SA; // stolen from R.Stevens
typedef struct sockaddr_in SA_IN;
#if defined (WIN32)
struct sockaddr_un
{
short sun_family; /* AF_UNIX */
char sun_path [108]; /* Path name */
};
#endif
typedef struct sockaddr_un SA_UN;
class Address {
public:
enum addr_state_t {
goodbit=0,
badbit=1
};
typedef int addrstate;
private:
unsigned char m_state;
public:
Address () : m_state (Address::goodbit) { trace("Address::Address"); }
virtual ~Address() {}
bool good() const { return m_state == 0; }
bool bad() const { return m_state & Address::badbit; }
operator void* () const { return (void*) good (); }
bool operator! () const { return bad (); }
virtual const int getLength() const = 0;
virtual SA* getAddress() const = 0;
virtual void dump ()
{
trace("Address");
DL((TRACE,"state - %s\n", good () ? "good" : "bad"));
}
protected:
void setstate (addrstate flag_) { m_state |= flag_; }
};
} // end namespace ASSA
#endif /* ADDRESS_H */
Assure.h
A collection of assert function wrappers.
Logger.h
An abstraction to message logging facility.
trace
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition Logger.h:429
DL
#define DL(X)
A macro for writing debug message to the Logger.
Definition Logger.h:273
ASSA::Address::getAddress
virtual SA * getAddress() const =0
Retrieve pointer to the address structure.
ASSA::Address::bad
bool bad() const
Indicates whether there was error during address construction process i.e.
Definition Address.h:80
ASSA::Address::m_state
unsigned char m_state
Definition Address.h:61
ASSA::Address::~Address
virtual ~Address()
Destructor.
Definition Address.h:68
ASSA::Address::dump
virtual void dump()
Dump object state to the log file.
Definition Address.h:101
ASSA::Address::addrstate
int addrstate
Definition Address.h:58
ASSA::Address::good
bool good() const
Valid address is constructed.
Definition Address.h:73
ASSA::Address::getLength
virtual const int getLength() const =0
Return length of the underlying address structure.
ASSA::Address::operator!
bool operator!() const
Alias to bad ().
Definition Address.h:91
ASSA::Address::setstate
void setstate(addrstate flag_)
Set state of the Address object.
Definition Address.h:111
ASSA::Address::Address
Address()
Constructor.
Definition Address.h:65
ASSA::Address::addr_state_t
addr_state_t
State bits.
Definition Address.h:54
ASSA::Address::goodbit
@ goodbit
good state
Definition Address.h:55
ASSA::Address::badbit
@ badbit
bad state
Definition Address.h:56
ASSA
Definition Acceptor.h:40
ASSA::SA_IN
struct sockaddr_in SA_IN
Definition Address.h:34
ASSA::SA_UN
struct sockaddr_un SA_UN
Definition Address.h:44
ASSA::TRACE
@ TRACE
Function call trace.
Definition LogMask.h:26
ASSA::SA
struct sockaddr SA
Definition Address.h:33