ACE
6.3.3
|
Defines a C++ wrapper facade for the Internet domain address family format. More...
#include <INET_Addr.h>
Classes | |
union | ip46 |
Public Member Functions | |
ACE_INET_Addr (void) | |
Default constructor. More... | |
ACE_INET_Addr (const ACE_INET_Addr &) | |
Copy constructor. More... | |
ACE_INET_Addr (const sockaddr_in *addr, int len) | |
Creates an ACE_INET_Addr from a sockaddr_in structure. More... | |
ACE_INET_Addr (u_short port_number, const char host_name[], int address_family=AF_UNSPEC) | |
ACE_INET_Addr (const char address[], int address_family=AF_UNSPEC) | |
ACE_INET_Addr (u_short port_number, ACE_UINT32 ip_addr=INADDR_ANY) | |
ACE_INET_Addr (const char port_name[], const char host_name[], const char protocol[]="tcp") | |
ACE_INET_Addr (const char port_name[], ACE_UINT32 ip_addr, const char protocol[]="tcp") | |
ACE_INET_Addr (u_short port_number, const wchar_t host_name[], int address_family=AF_UNSPEC) | |
ACE_INET_Addr (const wchar_t address[], int address_family=AF_UNSPEC) | |
ACE_INET_Addr (const wchar_t port_name[], const wchar_t host_name[], const wchar_t protocol[]=ACE_TEXT_WIDE("tcp")) | |
ACE_INET_Addr (const wchar_t port_name[], ACE_UINT32 ip_addr, const wchar_t protocol[]=ACE_TEXT_WIDE("tcp")) | |
~ACE_INET_Addr (void) | |
Default dtor. More... | |
ACE_INET_Addr & | operator= (const ACE_INET_Addr &rhs) |
int | set (const ACE_INET_Addr &) |
Initializes from another ACE_INET_Addr. More... | |
int | set (u_short port_number, const char host_name[], int encode=1, int address_family=AF_UNSPEC) |
int | set (u_short port_number, ACE_UINT32 ip_addr=INADDR_ANY, int encode=1, int map=0) |
int | set (const char port_name[], const char host_name[], const char protocol[]="tcp") |
int | set (const char port_name[], ACE_UINT32 ip_addr, const char protocol[]="tcp") |
int | set (const char addr[], int address_family=AF_UNSPEC) |
int | set (const sockaddr_in *, int len) |
Creates an ACE_INET_Addr from a sockaddr_in structure. More... | |
int | set (u_short port_number, const wchar_t host_name[], int encode=1, int address_family=AF_UNSPEC) |
int | set (const wchar_t port_name[], const wchar_t host_name[], const wchar_t protocol[]=ACE_TEXT_WIDE("tcp")) |
int | set (const wchar_t port_name[], ACE_UINT32 ip_addr, const wchar_t protocol[]=ACE_TEXT_WIDE("tcp")) |
int | set (const wchar_t addr[], int address_family=AF_UNSPEC) |
virtual void * | get_addr (void) const |
Return a pointer to the underlying network address. More... | |
int | get_addr_size (void) const |
virtual void | set_addr (const void *, int len) |
Set a pointer to the address. More... | |
virtual void | set_addr (const void *, int len, int map) |
Set a pointer to the address. More... | |
virtual int | addr_to_string (ACE_TCHAR buffer[], size_t size, int ipaddr_format=1) const |
virtual int | string_to_addr (const char address[], int address_family=AF_UNSPEC) |
void | set_port_number (u_short, int encode=1) |
int | set_address (const char *ip_addr, int len, int encode=1, int map=0) |
int | set_interface (const char *intf_name) |
u_short | get_port_number (void) const |
Return the port number, converting it into host byte-order. More... | |
int | get_host_name (char hostname[], size_t hostnamelen) const |
int | get_host_name (wchar_t hostname[], size_t hostnamelen) const |
const char * | get_host_name (void) const |
const char * | get_host_addr (char *addr, int addr_size) const |
const char * | get_host_addr (void) const |
ACE_UINT32 | get_ip_address (void) const |
bool | is_any (void) const |
Return true if the IP address is INADDR_ANY or IN6ADDR_ANY. More... | |
bool | is_loopback (void) const |
Return true if the IP address is IPv4/IPv6 loopback address. More... | |
bool | is_multicast (void) const |
Return true if the IP address is IPv4/IPv6 multicast address. More... | |
bool | is_linklocal (void) const |
Return true if the IP address is IPv6 linklocal address. More... | |
bool | is_ipv4_mapped_ipv6 (void) const |
Return true if the IP address is IPv4-mapped IPv6 address. More... | |
bool | is_ipv4_compat_ipv6 (void) const |
Return true if the IP address is IPv4-compatible IPv6 address. More... | |
bool | operator< (const ACE_INET_Addr &rhs) const |
bool | operator== (const ACE_INET_Addr &SAP) const |
bool | operator!= (const ACE_INET_Addr &SAP) const |
Compare two addresses for inequality. More... | |
bool | is_ip_equal (const ACE_INET_Addr &SAP) const |
virtual u_long | hash (void) const |
Computes and returns hash value. More... | |
bool | next (void) |
void | reset (void) |
Reset the set of address so they can be scanned again using next(). More... | |
void | dump (void) const |
Dump the state of an object. More... | |
Public Member Functions inherited from ACE_Addr | |
ACE_Addr (int type=-1, int size=-1) | |
Initializes instance variables. More... | |
virtual | ~ACE_Addr (void) |
Destructor. More... | |
int | get_size (void) const |
Return the size of the address. More... | |
void | set_size (int size) |
Sets the size of the address. More... | |
int | get_type (void) const |
Get the type of the address. More... | |
void | set_type (int type) |
Set the type of the address. More... | |
bool | operator== (const ACE_Addr &sap) const |
Check for address equality. More... | |
bool | operator!= (const ACE_Addr &sap) const |
Check for address inequality. More... | |
void | base_set (int type, int size) |
Initializes instance variables. More... | |
void | dump (void) const |
Dump the state of an object. More... | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. More... | |
Public Attributes inherited from ACE_Addr | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. More... | |
Private Member Functions | |
int | get_host_name_i (char hostname[], size_t hostnamelen) const |
Insure that hostname is properly null-terminated. More... | |
void * | ip_addr_pointer (void) const |
int | ip_addr_size (void) const |
int | determine_type (void) const |
void | reset_i (void) |
Initialize underlying inet_addr_ to default values. More... | |
Private Attributes | |
union ACE_INET_Addr::ip46 | inet_addr_ |
std::vector< union ip46 > | inet_addrs_ |
std::vector< union ip46 >::iterator | inet_addrs_iter_ |
Additional Inherited Members | |
Static Public Attributes inherited from ACE_Addr | |
static const ACE_Addr | sap_any |
Wild-card address. More... | |
Protected Attributes inherited from ACE_Addr | |
int | addr_type_ |
e.g., AF_UNIX, AF_INET, AF_SPIPE, etc. More... | |
int | addr_size_ |
Number of bytes in the address. More... | |
Defines a C++ wrapper facade for the Internet domain address family format.
ACE_INET_Addr can hold all of the IP addresses assigned to a single name. By default it refers only to the first, if there is more than one. The next() method can make the others available in turn.
ACE_INET_Addr::ACE_INET_Addr | ( | void | ) |
Default constructor.
ACE_INET_Addr::ACE_INET_Addr | ( | const ACE_INET_Addr & | sa | ) |
Copy constructor.
ACE_INET_Addr::ACE_INET_Addr | ( | const sockaddr_in * | addr, |
int | len | ||
) |
Creates an ACE_INET_Addr from a sockaddr_in structure.
ACE_INET_Addr::ACE_INET_Addr | ( | u_short | port_number, |
const char | host_name[], | ||
int | address_family = AF_UNSPEC |
||
) |
Creates an ACE_INET_Addr from a port_number and the remote host_name. The port number is assumed to be in host byte order. To set a port already in network byte order, please
|
explicit |
Initializes an ACE_INET_Addr from the address, which can be "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or "128.252.166.57:1234"). If there is no ':' in the address it is assumed to be a port number, with the IP address being INADDR_ANY.
|
explicit |
Creates an ACE_INET_Addr from a port_number and an Internet ip_addr. This method assumes that port_number and ip_addr are in host byte order. If you have addressing information in network byte order,
ACE_INET_Addr::ACE_INET_Addr | ( | const char | port_name[], |
const char | host_name[], | ||
const char | protocol[] = "tcp" |
||
) |
Uses getservbyname() to create an ACE_INET_Addr from a port_name, the remote host_name, and the protocol.
ACE_INET_Addr::ACE_INET_Addr | ( | const char | port_name[], |
ACE_UINT32 | ip_addr, | ||
const char | protocol[] = "tcp" |
||
) |
Uses getservbyname() to create an ACE_INET_Addr from a port_name, an Internet ip_addr, and the protocol. This method assumes that ip_addr is in host byte order.
ACE_INET_Addr::ACE_INET_Addr | ( | u_short | port_number, |
const wchar_t | host_name[], | ||
int | address_family = AF_UNSPEC |
||
) |
|
explicit |
ACE_INET_Addr::ACE_INET_Addr | ( | const wchar_t | port_name[], |
const wchar_t | host_name[], | ||
const wchar_t | protocol[] = ACE_TEXT_WIDE ("tcp") |
||
) |
ACE_INET_Addr::ACE_INET_Addr | ( | const wchar_t | port_name[], |
ACE_UINT32 | ip_addr, | ||
const wchar_t | protocol[] = ACE_TEXT_WIDE ("tcp") |
||
) |
ACE_INET_Addr::~ACE_INET_Addr | ( | void | ) |
Default dtor.
|
virtual |
Transform the current ACE_INET_Addr address into string format. If ipaddr_format is true this produces "ip-number:port-number" (e.g., "128.252.166.57:1234"), whereas if ipaddr_format is false this produces "ip-name:port-number" (e.g., "tango.cs.wustl.edu:1234"). Returns -1 if the size of the buffer is too small, else 0.
|
inlineprivate |
void ACE_INET_Addr::dump | ( | void | ) | const |
Dump the state of an object.
|
virtual |
Return a pointer to the underlying network address.
Reimplemented from ACE_Addr.
|
inline |
const char * ACE_INET_Addr::get_host_addr | ( | char * | addr, |
int | addr_size | ||
) | const |
Return the "dotted decimal" Internet address representation of the hostname storing it in the addr (which is assumed to be addr_size bytes long). This version is reentrant.
const char * ACE_INET_Addr::get_host_addr | ( | void | ) | const |
Return the "dotted decimal" Internet address representation of the hostname. This version is non-reentrant since it returns a pointer to a static data area. You should therefore either (1) do a "deep copy" of the address returned by get_host_addr(), e.g., using strdup() or (2) use the "reentrant" version of get_host_addr() described above.
int ACE_INET_Addr::get_host_name | ( | char | hostname[], |
size_t | hostnamelen | ||
) | const |
Return the character representation of the name of the host, storing it in the hostname (which is assumed to be hostnamelen bytes long). This version is reentrant. If hostnamelen is greater than 0 then hostname will be NUL-terminated even if -1 is returned.
int ACE_INET_Addr::get_host_name | ( | wchar_t | hostname[], |
size_t | hostnamelen | ||
) | const |
const char * ACE_INET_Addr::get_host_name | ( | void | ) | const |
Return the character representation of the hostname. This version is non-reentrant since it returns a pointer to a static data area. You should therefore either (1) do a "deep copy" of the address returned by get_host_name(), e.g., using strdup() or (2) use the "reentrant" version of get_host_name() described above.
|
private |
Insure that hostname is properly null-terminated.
ACE_UINT32 ACE_INET_Addr::get_ip_address | ( | void | ) | const |
Return the 4-byte IP address, converting it into host byte order.
|
inline |
Return the port number, converting it into host byte-order.
|
virtual |
Computes and returns hash value.
Reimplemented from ACE_Addr.
|
inlineprivate |
|
inlineprivate |
|
inline |
Return true
if the IP address is INADDR_ANY or IN6ADDR_ANY.
bool ACE_INET_Addr::is_ip_equal | ( | const ACE_INET_Addr & | SAP | ) | const |
A variation of the equality operator, this method only compares the IP address and ignores the port number.
|
inline |
Return true
if the IP address is IPv4-compatible IPv6 address.
|
inline |
Return true
if the IP address is IPv4-mapped IPv6 address.
|
inline |
Return true
if the IP address is IPv6 linklocal address.
|
inline |
Return true
if the IP address is IPv4/IPv6 loopback address.
|
inline |
Return true
if the IP address is IPv4/IPv6 multicast address.
bool ACE_INET_Addr::next | ( | void | ) |
If there is another address to examine, move to it and return true; else return false.
bool ACE_INET_Addr::operator!= | ( | const ACE_INET_Addr & | SAP | ) | const |
Compare two addresses for inequality.
|
inline |
Returns true
if this
is less than rhs. In this context, "less than" is defined in terms of IP address and TCP port number. This operator makes it possible to use ACE_INET_Addrs
in STL maps.
ACE_INET_Addr & ACE_INET_Addr::operator= | ( | const ACE_INET_Addr & | rhs | ) |
Assignment. In a more well-ordered world, member-wise assignment would work fine. However, because of the class design feature that all of the acceptor/connector-type classes that can be used in the Acceptor-Connector framework take ACE_Addr objects instead of the addressing class matching the family in use. The mechanism used to enable this substitution to the more-appropriate class is ACE_sap_any_cast, which casts the ACE_Addr to the more-specific class. In this case, casting an ACE_Addr to ACE_INET_Addr then copying it. Since adding multiple address support to ACE_INET_Addr, that cast-copy operation ends up, in the member-wise case, copying a bogus vector and doing lots of random damage. Thus, this operator is used to make life ordered in this common scenario.
bool ACE_INET_Addr::operator== | ( | const ACE_INET_Addr & | SAP | ) | const |
Compare two addresses for equality. The addresses are considered equal if they contain the same IP address and port number.
void ACE_INET_Addr::reset | ( | void | ) |
Reset the set of address so they can be scanned again using next().
|
inlineprivate |
Initialize underlying inet_addr_ to default values.
int ACE_INET_Addr::set | ( | const ACE_INET_Addr & | sa | ) |
Initializes from another ACE_INET_Addr.
int ACE_INET_Addr::set | ( | u_short | port_number, |
const char | host_name[], | ||
int | encode = 1 , |
||
int | address_family = AF_UNSPEC |
||
) |
Initializes an ACE_INET_Addr from a port_number and the remote host_name. If encode is non-zero then port_number is converted into network byte order, otherwise it is assumed to be in network byte order already and are passed straight through. address_family can be used to select IPv4/IPv6 if the OS has IPv6 capability (ACE_HAS_IPV6 is defined). To specify IPv6, use the value AF_INET6. To specify IPv4, use AF_INET.
int ACE_INET_Addr::set | ( | u_short | port_number, |
ACE_UINT32 | ip_addr = INADDR_ANY , |
||
int | encode = 1 , |
||
int | map = 0 |
||
) |
Initializes an ACE_INET_Addr from a port_number and an Internet ip_addr. If encode is non-zero then the port number and IP address are converted into network byte order, otherwise they are assumed to be in network byte order already and are passed straight through.
If map is non-zero and IPv6 support has been compiled in, then this address will be set to the IPv4-mapped IPv6 address of it.
int ACE_INET_Addr::set | ( | const char | port_name[], |
const char | host_name[], | ||
const char | protocol[] = "tcp" |
||
) |
Uses getservbyname() to initialize an ACE_INET_Addr from a port_name, the remote host_name, and the protocol.
int ACE_INET_Addr::set | ( | const char | port_name[], |
ACE_UINT32 | ip_addr, | ||
const char | protocol[] = "tcp" |
||
) |
Uses getservbyname() to initialize an ACE_INET_Addr from a port_name, an ip_addr, and the protocol. This assumes that ip_addr is already in network byte order.
int ACE_INET_Addr::set | ( | const char | addr[], |
int | address_family = AF_UNSPEC |
||
) |
Initializes an ACE_INET_Addr from the addr, which can be "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or "128.252.166.57:1234"). If there is no ':' in the address it is assumed to be a port number, with the IP address being INADDR_ANY.
int ACE_INET_Addr::set | ( | const sockaddr_in * | addr, |
int | len | ||
) |
Creates an ACE_INET_Addr from a sockaddr_in structure.
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Set a pointer to the address.
Reimplemented from ACE_Addr.
|
virtual |
Set a pointer to the address.
int ACE_INET_Addr::set_address | ( | const char * | ip_addr, |
int | len, | ||
int | encode = 1 , |
||
int | map = 0 |
||
) |
Sets the address without affecting the port number. If encode is enabled then ip_addr is converted into network byte order, otherwise it is assumed to be in network byte order already and are passed straight through. The size of the address is specified in the len parameter. If map is non-zero, IPv6 support has been compiled in, and ip_addr is an IPv4 address, then this address is set to the IPv4-mapped IPv6 address of it.
int ACE_INET_Addr::set_interface | ( | const char * | intf_name | ) |
Sets the interface that should be used for this address. This only has an effect when the address is link local, otherwise it does nothing.
void ACE_INET_Addr::set_port_number | ( | u_short | port_number, |
int | encode = 1 |
||
) |
Sets the port number without affecting the host name. If encode is enabled then port_number is converted into network byte order, otherwise it is assumed to be in network byte order already and are passed straight through.
|
virtual |
Initializes an ACE_INET_Addr from the address, which can be "ip-addr:port-number" (e.g., "tango.cs.wustl.edu:1234"), "ip-addr:port-name" (e.g., "tango.cs.wustl.edu:telnet"), "ip-number:port-number" (e.g., "128.252.166.57:1234"), or "ip-number:port-name" (e.g., "128.252.166.57:telnet"). If there is no ':' in the address it is assumed to be a port number, with the IP address being INADDR_ANY.
ACE_INET_Addr::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
|
private |
|
private |
|
private |