RTP Trace System  1.0
Coral::InternetAddress Class Reference

Socket Address. More...

#include <internetaddress.h>

Inheritance diagram for Coral::InternetAddress:
Coral::SocketAddress Coral::InternetFlow

List of all members.

Public Types

enum  PrintFormat { PF_Address = (1 << 0), PF_Hostname = (1 << 1), PF_Full = PF_Address | PF_Hostname }

Public Member Functions

 InternetAddress ()
 InternetAddress (const InternetAddress &address)
 InternetAddress (const String &address)
 InternetAddress (const String &hostName, const card16 port)
 InternetAddress (const card16 port)
 InternetAddress (sockaddr *address, socklen_t length)
 ~InternetAddress ()
void reset ()
void init (const InternetAddress &address)
void init (const card16 port)
void init (const String &hostName, const card16 port)
InternetAddressoperator= (const InternetAddress &source)
card16 getPort () const
void setPort (const card16 port)
PrintFormat getPrintFormat () const
void setPrintFormat (const PrintFormat format)
bool isValid () const
bool isNull () const
String getAddressString () const
bool isIPv4 () const
bool isIPv6 () const
cardinal getSystemAddress (sockaddr *buffer, const socklen_t length, const cardinal type) const
bool setSystemAddress (sockaddr *address, const socklen_t length)
int operator== (const InternetAddress &address) const
int operator!= (const InternetAddress &address) const
int operator< (const InternetAddress &address) const
int operator<= (const InternetAddress &address) const
int operator> (const InternetAddress &address) const
int operator>= (const InternetAddress &address) const
PortableAddress getPortableAddress () const
 InternetAddress (const PortableAddress &address)
void init (const PortableAddress &address)

Static Public Member Functions

static InternetAddress getLocalAddress (const InternetAddress &peer)
static cardinal getHostByName (const String &name, card16 *myadr)
static bool hasIPv6 ()

Static Public Attributes

static bool UseIPv6 = checkIPv6()

Static Private Member Functions

static bool checkIPv6 ()

Private Attributes

card16 Host [8]
card16 Port
PrintFormat Format
bool Valid

Detailed Description

Socket Address.

This class manages an internet address.

Author:
Thomas Dreibholz
Version:
1.0

Member Enumeration Documentation

setPrintFormat() printing formats.

Enumerator:
PF_Address 
PF_Hostname 
PF_Full 

Constructor & Destructor Documentation

Constructor for an empty internet address.

Constructor for an internet address from an internet address.

Parameters:
addressInternet address.

Constructor for a internet address given by a string. Examples: "gaffel:7500", "12.34.56.78:7500", "3ffe:4711::0!7500", "odin:7500", "ipv6-odin:7500".

Parameters:
addressAddress string.
Coral::InternetAddress::InternetAddress ( const String hostName,
const card16  port 
)

Constructor for a internet address given by host name and port.

Parameters:
hostNameHost name.
portPort number.

Constructor for INADDR_ANY address with given port.

Parameters:
portPort number.
Coral::InternetAddress::InternetAddress ( sockaddr *  address,
socklen_t  length 
)

Constructor for a internet address from the system's sockaddr structure. The sockaddr structure may be sockaddr_in (IPv4) or sockaddr_in6 (IPv6).

Parameters:
addresssockaddr.
lengthLength of sockaddr (sizeof(sockaddr_in) or sizeof(sockaddr_in6)).

Constructor for InternetAddress from PortableAddress.

Parameters:
addressPortableAddress.

Member Function Documentation

bool Coral::InternetAddress::checkIPv6 ( ) [static, private]

Get address string.

Returns:
Address string.

Implements Coral::SocketAddress.

Reimplemented in Coral::InternetFlow.

cardinal Coral::InternetAddress::getHostByName ( const String name,
card16 myadr 
) [static]

Wrapper for system's gethostbyname() function. This version does support IPv6 addresses even if the system itself does not support IPv6. IPv6 addresses are then converted to IPv4 if possible (IPv4-mapped IPv6).

Parameters:
nameHost name.
myadrStorage space to save a IPv6 address (16 bytes).
lengthLength of the address saved in myaddr or 0 in case of failure.

Get the local host address. The parameter peer gives the address of the other host.

Parameters:
addressReference to SocketAddress to write address to.
peerAddress of peer.
Returns:
true, if call was successful; false otherwise.

Examples: localhost => localhost address (127.0.0.1 or ::1). ethernet-host => ethernet interface address. internet-address => dynamic-ip address set by pppd.

Get port of address.

Get printing format.

Returns:
Print format.
cardinal Coral::InternetAddress::getSystemAddress ( sockaddr *  buffer,
const socklen_t  length,
const cardinal  type 
) const [virtual]
static bool Coral::InternetAddress::hasIPv6 ( ) [inline, static]

Check, if IPv6 support is available.

Returns:
true, if IPv6 support is available; false otherwise.
void Coral::InternetAddress::init ( const InternetAddress address)

Initialize internet address from internet address.

void Coral::InternetAddress::init ( const card16  port)

Initialize internet address with INADDR_ANY and given port.

Parameters:
portPort number.
void Coral::InternetAddress::init ( const String hostName,
const card16  port 
)

Initialize internet address with given host name and port.

Parameters:
hostNameHost name.
portPort number.
void Coral::InternetAddress::init ( const PortableAddress address)

Initialize InternetAddress from PortableAddress.

Parameters:
addressPortableAddress.
bool Coral::InternetAddress::isIPv4 ( ) const [inline]

Check, if internet address is an IPv4 or IPv4-mapped address.

Returns:
true, if address is an IPv4 or IPv4-mapped address; false otherwise.
bool Coral::InternetAddress::isIPv6 ( ) const [inline]

Check, if internet address is a real (not IPv4-mapped) IPv6 address. Addresses which return true here can be used with labeled flows by class Socket.

Returns:
true, if address is real IPv6; false otherwise.
bool Coral::InternetAddress::isNull ( ) const [inline]

Check, if the address is null.

Returns:
true, if the address is not null; false otherwise.
bool Coral::InternetAddress::isValid ( ) const [virtual]

isValid() implementation of SocketAddress.

See also:
SocketAddress::isValid

Implements Coral::SocketAddress.

int Coral::InternetAddress::operator!= ( const InternetAddress address) const [inline]

Implementation of != operator.

int Coral::InternetAddress::operator< ( const InternetAddress address) const

Implementation of < operator.

int Coral::InternetAddress::operator<= ( const InternetAddress address) const [inline]

Implementation of <= operator.

InternetAddress& Coral::InternetAddress::operator= ( const InternetAddress source) [inline]

Implementation of = operator.

int Coral::InternetAddress::operator== ( const InternetAddress address) const

Implementation of == operator.

int Coral::InternetAddress::operator> ( const InternetAddress address) const

Implementation of > operator.

int Coral::InternetAddress::operator>= ( const InternetAddress address) const [inline]

Implementation of >= operator.

void Coral::InternetAddress::reset ( ) [virtual]

Reset internet address.

Implements Coral::SocketAddress.

Reimplemented in Coral::InternetFlow.

void Coral::InternetAddress::setPort ( const card16  port) [inline]

Set port of address.

void Coral::InternetAddress::setPrintFormat ( const PrintFormat  format) [inline]

Set printing format.

Parameters:
formatPrint format.
bool Coral::InternetAddress::setSystemAddress ( sockaddr *  address,
const socklen_t  length 
) [virtual]

Member Data Documentation

Host address in network byte order. IPv4 addresses are converted to IPv4-mapped IPv6 addresses.

Port number.

Static variable which shows the availability of IPv6. Setting this variable to false on an IPv6 system simulates an IPv4-only system.

Do *not* change this variable if Socket or InternetAddress objects are already in use!!!

Is address valid?


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines