RTP Audio System  2.0.0
InternetAddress Class Reference

Socket Address. More...

#include <internetaddress.h>

Inheritance diagram for InternetAddress:
SocketAddress InternetFlow

List of all members.

Public Member Functions

 InternetAddress ()
 InternetAddress (const InternetAddress &address)
 InternetAddress (const String &address)
 InternetAddress (const String &hostName, const card16 port)
 InternetAddress (const card16 port)
 InternetAddress (const sockaddr *address, const socklen_t length)
 ~InternetAddress ()
void reset ()
SocketAddressduplicate () const
void init (const InternetAddress &address)
void init (const String &hostName, const card16 port)
void init (const card16 port)
void init (const sockaddr *address, const socklen_t length)
InternetAddressoperator= (const InternetAddress &source)
card16 getPort () const
void setPort (const card16 port)
bool isValid () const
integer getFamily () const
String getAddressString (const cardinal format=PF_Default) const
bool isIPv4 () const
bool isIPv4compatible () const
bool isIPv6 () const
bool isNull () const
bool isUnspecified () const
bool isLoopback () const
bool isLinkLocal () const
bool isSiteLocal () const
bool isGlobal () const
bool isMulticast () const
bool isBroadcast () const
bool isUnicast () const
bool isReserved () const
bool isNodeLocalMulticast () const
bool isLinkLocalMulticast () const
bool isSiteLocalMulticast () const
bool isOrgLocalMulticast () const
bool isGlobalMulticast () const
cardinal getSystemAddress (sockaddr *buffer, const socklen_t length, const cardinal type) const
bool setSystemAddress (const 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 cardinal getHostByName (const String &name, card16 *myadr, card16 *myscope=NULL)
static card16 getServiceByName (const char *name)
static bool getFullHostName (char *str, const size_t size)
static bool hasIPv6 ()
static InternetAddress getLocalAddress (const InternetAddress &peer)
static bool setIPv4Address (const InternetAddress &address, in_addr *ipv4Address)
static InternetAddress getIPv4Address (const in_addr &ipv4Address)
static card32 calculateChecksum (card8 *buffer, const cardinal bytes, card32 sum)
static card32 wrapChecksum (card32 sum)

Static Public Attributes

static bool UseIPv6 = checkIPv6()

Static Private Member Functions

static bool checkIPv6 ()

Private Attributes

union {
   card16   Host16 [8]
   card32   Host32 [4]
   in6_addr   Address
AddrSpec
card16 Port
card16 ScopeID
bool Valid

Detailed Description

Socket Address.

This class manages an internet address.

Author:
Thomas Dreibholz
Version:
1.0

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.
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.
InternetAddress::InternetAddress ( const sockaddr *  address,
const 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

card32 InternetAddress::calculateChecksum ( card8 buffer,
const cardinal  bytes,
card32  sum 
) [static]

Calculate internet checksum.

Parameters:
bufferBuffer to calculate checksum from.
bytesNumber of bytes.
sumChecksum value to add.
Returns:
Checksum.
bool InternetAddress::checkIPv6 ( ) [static, private]

duplicate() implementation of SocketAddress.

See also:
SocketAddress::duplicate

Implements SocketAddress.

Reimplemented in InternetFlow.

String InternetAddress::getAddressString ( const cardinal  format = PF_Default) const [virtual]

getAddressString() implementation of SocketAddress.

See also:
SocketAddress::getAddressString

Implements SocketAddress.

Reimplemented in InternetFlow.

integer InternetAddress::getFamily ( ) const [virtual]

getFamily() implementation of SocketAddress.

See also:
SocketAddress::getFamily

Implements SocketAddress.

bool InternetAddress::getFullHostName ( char *  str,
const size_t  size 
) [static]

Get the computer's full locat name (format: name.domain).

Parameters:
strBuffer to store name to.
sizeSize of buffer.
Returns:
true for success; false otherwise.
cardinal InternetAddress::getHostByName ( const String name,
card16 myadr,
card16 myscope = NULL 
) [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).
myscopeStorage space to save IPv6 link local scope ID to (or NULL).
lengthLength of the address saved in myaddr or 0 in case of failure.
InternetAddress InternetAddress::getIPv4Address ( const in_addr &  ipv4Address) [static]

Get IPv4 InternetAddress from in_addr structure.

Parameters:
ipv4Addressin_addr to get address from.
Returns:
InternetAddress.

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

Parameters:
peerAddress of peer.
Returns:
Local internet address.

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

card16 InternetAddress::getPort ( ) const [virtual]

getPort() implementation of SocketAddress.

See also:
SocketAddress::getPort

Implements SocketAddress.

card16 InternetAddress::getServiceByName ( const char *  name) [static]

Get port number for given service (e.g. http).

Parameters:
nameService name (e.g. "http" or "telnet").
Returns:
Port number of 0 if unknown.
cardinal InternetAddress::getSystemAddress ( sockaddr *  buffer,
const socklen_t  length,
const cardinal  type 
) const [virtual]

getSystemAddress() implementation of SocketAddress

See also:
SocketAddress::getSystemAddress

Implements SocketAddress.

Reimplemented in InternetFlow.

static bool InternetAddress::hasIPv6 ( ) [inline, static]

Check, if IPv6 support is available.

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

Initialize internet address from internet address.

void InternetAddress::init ( const String hostName,
const card16  port 
)

Initialize internet address with given host name and port.

Parameters:
hostNameHost name.
portPort number.
void InternetAddress::init ( const card16  port)

Initialize internet address with INADDR_ANY and given port.

Parameters:
portPort number.
void InternetAddress::init ( const sockaddr *  address,
const socklen_t  length 
)

Initialize 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)).
void InternetAddress::init ( const PortableAddress address)

Initialize InternetAddress from PortableAddress.

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

Check, if internet address broadcast address.

Returns:
true or false.
bool InternetAddress::isGlobal ( ) const [inline]

Check, if internet address is global, that is !(isLinkLocal() || isSiteLocal()).

Returns:
true or false.
bool InternetAddress::isGlobalMulticast ( ) const [inline]

Check, if internet address is a global IPv6 multicast address.

Returns:
true or false.
bool InternetAddress::isIPv4 ( ) const [inline]

Check, if internet address is an IPv4 or IPv4-mapped address (a.b.c.d or ::ffff:a.b.c.d).

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

Check, if internet address is an IPv4-compatible IPv6 address (::a.b.c.d and NOT ::ffff:a.b.c.d).

Returns:
true, if address is an IPv4-compatible IPv6 address; false otherwise.
bool 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 InternetAddress::isLinkLocal ( ) const [inline]

Check, if internet address is link local (IPv6) or 127.x.y.z (IPv4).

Returns:
true or false.
bool InternetAddress::isLinkLocalMulticast ( ) const [inline]

Check, if internet address is a link local IPv6 multicast address.

Returns:
true or false.
bool InternetAddress::isLoopback ( ) const [inline]

Check, if the address is loopback address (127.x.y.z for IPv4 or ::1 for IPv6).

Returns:
true, if the address is loopback address; false otherwise.
bool InternetAddress::isMulticast ( ) const [inline]

Check, if internet address is a multicast address.

Returns:
true or false.
bool InternetAddress::isNodeLocalMulticast ( ) const [inline]

Check, if internet address is a node local IPv6 multicast address.

Returns:
true or false.
bool InternetAddress::isNull ( ) const [inline]

Check, if the address is null address (0.0.0.0 for IPv4 or :: for IPv6) and port number 0. To skip port number check, use isUnspecified().

Returns:
true, if the address is null; false otherwise.
See also:
isUnspecified
bool InternetAddress::isOrgLocalMulticast ( ) const [inline]

Check, if internet address is a organization local IPv6 multicast address.

Returns:
true or false.
bool InternetAddress::isReserved ( ) const [inline]

Check, if internet address is an reserved address.

Returns:
true or false.
bool InternetAddress::isSiteLocal ( ) const [inline]

Check, if internet address is site local (IPv6) or 127.x.y.z, 192.168.x.y or 10.x.y.z or within {172.16.0.0 to 127.31.255.255} (IPv4).

Returns:
true or false.
bool InternetAddress::isSiteLocalMulticast ( ) const [inline]

Check, if internet address is a site local IPv6 multicast address.

Returns:
true or false.
bool InternetAddress::isUnicast ( ) const [inline]

Check, if internet address is an unicast address (not broadcast or multicast).

Returns:
true or false.
bool InternetAddress::isUnspecified ( ) const [inline]

Check, if the address is null address (0.0.0.0 for IPv4 or :: for IPv6). This function does not check the port number. To also check the port number, use isNull().

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

isValid() implementation of SocketAddress.

See also:
SocketAddress::isValid

Implements SocketAddress.

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

Implementation of != operator.

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

Implementation of < operator.

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

Implementation of <= operator.

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

Implementation of = operator.

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

Implementation of == operator.

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

Implementation of > operator.

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

Implementation of >= operator.

void InternetAddress::reset ( ) [virtual]

Reset internet address.

Implements SocketAddress.

Reimplemented in InternetFlow.

bool InternetAddress::setIPv4Address ( const InternetAddress address,
in_addr *  ipv4Address 
) [static]

Set in_addr structure from InternetAddress (IPv4 only!).

Parameters:
addressInternetAddress.
ipv4AddressPointer to in_addr to write address to.
Returns:
true for success; false otherwise (IPv6 address).
void InternetAddress::setPort ( const card16  port) [virtual]

setPort() implementation of SocketAddress.

See also:
SocketAddress::setPort

Implements SocketAddress.

bool InternetAddress::setSystemAddress ( const sockaddr *  address,
const socklen_t  length 
) [virtual]

Prepare checksum for writing into header: Wrap sum and convert byte order.

Parameters:
sumChecksum.
Returns:
Checksum.

Member Data Documentation

union { ... } InternetAddress::AddrSpec [private]

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

Port number.

Scope ID.

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!!!

bool InternetAddress::Valid [private]

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