|
|
This class manages an internet address.
InternetAddress ()
| InternetAddress |
Constructor for an empty internet address.
InternetAddress (const InternetAddress& address)
| InternetAddress |
Constructor for an internet address from an internet address.
Parameters:
address | Internet address. |
InternetAddress (const String& address)
| InternetAddress |
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:
address | Address string. |
InternetAddress (const String& hostName,
const card16 port)
| InternetAddress |
Constructor for a internet address given by host name and port.
Parameters:
hostName | Host name. |
port | Port number. |
InternetAddress (const card16 port)
| InternetAddress |
Constructor for INADDR_ANY address with given port.
Parameters:
port | Port number. |
InternetAddress (sockaddr* address, socklen_t length)
| InternetAddress |
Constructor for a internet address from the system's sockaddr structure. The sockaddr structure may be sockaddr_in (IPv4) or sockaddr_in6 (IPv6).
Parameters:
address | sockaddr. |
length | Length of sockaddr (sizeof(sockaddr_in) or sizeof(sockaddr_in6)). |
~InternetAddress ()
| ~InternetAddress |
Destructor.
void reset ()
| reset |
Reset internet address.
Reimplemented from SocketAddress.
void init (const InternetAddress& address)
| init |
Initialize internet address from internet address.
void init (const String& hostName, const card16 port)
| init |
Initialize internet address with given host name and port.
Parameters:
hostName | Host name. |
port | Port number. |
void init (const card16 port)
| init |
Initialize internet address with INADDR_ANY and given port.
Parameters:
port | Port number. |
void init (sockaddr* address, socklen_t length)
| init |
Initialize internet address from the system's sockaddr structure. The sockaddr structure may be sockaddr_in (IPv4) or sockaddr_in6 (IPv6).
Parameters:
address | sockaddr. |
length | Length of sockaddr (sizeof(sockaddr_in) or sizeof(sockaddr_in6)). |
inline InternetAddress& operator= (const InternetAddress& source)
| operator= |
Implementation of = operator.
card16 getPort ()
| getPort |
[const]
getPort() implementation of SocketAddress.
See also: SocketAddress#getPort
Reimplemented from SocketAddress.
void setPort (const card16 port)
| setPort |
setPort() implementation of SocketAddress.
See also: SocketAddress#setPort
Reimplemented from SocketAddress.
bool isValid ()
| isValid |
[const]
isValid() implementation of SocketAddress.
See also: SocketAddress#isValid
Reimplemented from SocketAddress.
integer getFamily ()
| getFamily |
[const]
getFamily() implementation of SocketAddress.
See also: SocketAddress#getFamily
Reimplemented from SocketAddress.
String getAddressString (const cardinal format = PF_Default)
| getAddressString |
[const]
getAddressString() implementation of SocketAddress.
See also: SocketAddress#getAddressString
Reimplemented from SocketAddress.
inline bool isIPv4 ()
| isIPv4 |
[const]
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.
inline bool isIPv4compatible ()
| isIPv4compatible |
[const]
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.
inline bool isIPv6 ()
| isIPv6 |
[const]
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.
inline bool isNull ()
| isNull |
[const]
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
inline bool isUnspecified ()
| isUnspecified |
[const]
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
inline bool isLoopback ()
| isLoopback |
[const]
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.
inline bool isClassA ()
| isClassA |
[const]
Check, if internet address is class A IPv4-compatible or IPv4-mapped.
Returns: true or false.
inline bool isClassB ()
| isClassB |
[const]
Check, if internet address is class B IPv4-compatible or IPv4-mapped.
Returns: true or false.
inline bool isClassC ()
| isClassC |
[const]
Check, if internet address is class C IPv4-compatible or IPv4-mapped.
Returns: true or false.
inline bool isLinkLocal ()
| isLinkLocal |
[const]
Check, if internet address is link local (IPv6) or 127.x.y.z (IPv4).
Returns: true or false.
inline bool isSiteLocal ()
| isSiteLocal |
[const]
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.
inline bool isGlobal ()
| isGlobal |
[const]
Check, if internet address is global, that is !(isLinkLocal() || isSiteLocal()).
Returns: true or false.
inline bool isMulticast ()
| isMulticast |
[const]
Check, if internet address is a multicast address.
Returns: true or false.
inline bool isBroadcast ()
| isBroadcast |
[const]
Check, if internet address broadcast address.
Returns: true or false.
inline bool isUnicast ()
| isUnicast |
[const]
Check, if internet address is an unicast address (not broadcast or multicast).
Returns: true or false.
inline bool isReserved ()
| isReserved |
[const]
Check, if internet address is an reserved address.
Returns: true or false.
inline bool isNodeLocalMulticast ()
| isNodeLocalMulticast |
[const]
Check, if internet address is a node local IPv6 multicast address.
Returns: true or false.
inline bool isLinkLocalMulticast ()
| isLinkLocalMulticast |
[const]
Check, if internet address is a link local IPv6 multicast address.
Returns: true or false.
inline bool isSiteLocalMulticast ()
| isSiteLocalMulticast |
[const]
Check, if internet address is a site local IPv6 multicast address.
Returns: true or false.
inline bool isOrgLocalMulticast ()
| isOrgLocalMulticast |
[const]
Check, if internet address is a organization local IPv6 multicast address.
Returns: true or false.
inline bool isGlobalMulticast ()
| isGlobalMulticast |
[const]
Check, if internet address is a global IPv6 multicast address.
Returns: true or false.
cardinal getSystemAddress (sockaddr* buffer,
const socklen_t length,
const cardinal type)
| getSystemAddress |
[const]
getSystemAddress() implementation of SocketAddress
See also: SocketAddress#getSystemAddress
Reimplemented from SocketAddress.
bool setSystemAddress (sockaddr* address, const socklen_t length)
| setSystemAddress |
setSystemAddress() implementation of SocketAddress.
See also: SocketAddress#setSystemAddress
Reimplemented from SocketAddress.
cardinal getHostByName (const String& name, card16* myadr)
| getHostByName |
[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:
name | Host name. |
myadr | Storage space to save a IPv6 address (16 bytes). |
length | Length of the address saved in myaddr or 0 in case of failure. |
card16 getServiceByName (const char* name)
| getServiceByName |
[static]
Get port number for given service (e.g. http).
Parameters:
name | Service name (e.g. "http" or "telnet"). |
Returns: Port number of 0 if unknown.
bool getFullHostName (char* str, const size_t size)
| getFullHostName |
[static]
Get the computer's full locat name (format: name.domain).
Parameters:
str | Buffer to store name to. |
size | Size of buffer. |
Returns: true for success; false otherwise.
inline bool hasIPv6 ()
| hasIPv6 |
[static]
Check, if IPv6 support is available.
Returns: true, if IPv6 support is available; false otherwise.
static bool UseIPv6 | UseIPv6 |
InternetAddress getLocalAddress (const InternetAddress& peer)
| getLocalAddress |
[static]
Get the local host address. The parameter peer gives the address of the other host.
Examples: localhost => localhost address (127.0.0.1 or ::1). ethernet-host => ethernet interface address. internet-address => dynamic-ip address set by pppd.
Parameters:
peer | Address of peer. |
Returns: Local internet address.
Reimplemented from SocketAddress.
int operator== (const InternetAddress& address)
| operator== |
[const]
Implementation of == operator.
inline int operator!= (const InternetAddress& address)
| operator!= |
[const]
Implementation of != operator.
int operator< (const InternetAddress& address)
| operator< |
[const]
Implementation of < operator.
inline int operator<= (const InternetAddress& address)
| operator<= |
[const]
Implementation of <= operator.
int operator> (const InternetAddress& address)
| operator> |
[const]
Implementation of > operator.
inline int operator>= (const InternetAddress& address)
| operator>= |
[const]
Implementation of >= operator.
inline PortableAddress getPortableAddress ()
| getPortableAddress |
[const]
Get PortableAddress from InternetAddress.
Returns: PortableAddress.
InternetAddress (const PortableAddress& address)
| InternetAddress |
Constructor for InternetAddress from PortableAddress.
Parameters:
address | PortableAddress. |
void init (const PortableAddress& address)
| init |
Initialize InternetAddress from PortableAddress.
Parameters:
address | PortableAddress. |
bool setIPv4Address (const InternetAddress& address,
in_addr* ipv4Address)
| setIPv4Address |
[static]
Set in_addr structure from InternetAddress (IPv4 only!).
Parameters:
address | InternetAddress. |
ipv4Address | Pointer to in_addr to write address to. |
Returns: true for success; false otherwise (IPv6 address).
InternetAddress getIPv4Address (const in_addr& ipv4Address)
| getIPv4Address |
[static]
Get IPv4 InternetAddress from in_addr structure.
Parameters:
ipv4Address | in_addr to get address from. |
Returns: InternetAddress.
card32 calculateChecksum (card8* buffer,
const cardinal bytes,
card32 sum)
| calculateChecksum |
[static]
Calculate internet checksum.
Parameters:
buffer | Buffer to calculate checksum from. |
bytes | Number of bytes. |
sum | Checksum value to add. |
Returns: Checksum.
card32 wrapChecksum (card32 sum)
| wrapChecksum |
[static]
Prepare checksum for writing into header: Wrap sum and convert byte order.
Parameters:
sum | Checksum. |
Returns: Checksum.