#include <Multihomed_INET_Addr.h>
Inheritance diagram for ACE_Multihomed_INET_Addr:
Public Member Functions | |
ACE_Multihomed_INET_Addr (void) | |
Default constructor. | |
ACE_Multihomed_INET_Addr (const char address[]) | |
ACE_Multihomed_INET_Addr (u_short port_number, const char primary_host_name[], int encode=1, int address_family=AF_UNSPEC, const char *(secondary_host_names[])=0, size_t size=0) | |
ACE_Multihomed_INET_Addr (u_short port_number, ACE_UINT32 primary_ip_addr=INADDR_ANY, int encode=1, const ACE_UINT32 *secondary_ip_addrs=0, size_t size=0) | |
~ACE_Multihomed_INET_Addr (void) | |
Default dtor. | |
int | set (u_short port_number, const char primary_host_name[], int encode=1, int address_family=AF_UNSPEC, const char *(secondary_host_names[])=0, size_t size=0) |
int | set (u_short port_number, ACE_UINT32 primary_ip_addr=INADDR_ANY, int encode=1, const ACE_UINT32 *secondary_ip_addrs=0, size_t size=0) |
void | set_port_number (u_short port_number, int encode=1) |
size_t | get_num_secondary_addresses () const |
int | get_secondary_addresses (ACE_INET_Addr *secondary_addrs, size_t size) const |
void | get_addresses (sockaddr_in *addrs, size_t size) const |
Private Attributes | |
ACE_Array< ACE_INET_Addr > | secondaries_ |
Definition at line 35 of file Multihomed_INET_Addr.h.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr | ( | void | ) |
Default constructor.
Definition at line 22 of file Multihomed_INET_Addr.cpp.
References ACE_TRACE.
00023 : secondaries_ (0) 00024 { 00025 ACE_TRACE ("ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr"); 00026 }
ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr | ( | const char | address[] | ) | [explicit] |
Initializes an ACE_Multihomed_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.
Definition at line 28 of file Multihomed_INET_Addr.cpp.
00029 : ACE_INET_Addr (address), 00030 secondaries_ (0) 00031 { 00032 }
ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr | ( | u_short | port_number, | |
const char | primary_host_name[], | |||
int | encode = 1 , |
|||
int | address_family = AF_UNSPEC , |
|||
const char * | (secondary_host_names[]) = 0 , |
|||
size_t | size = 0 | |||
) |
Constructs an ACE_Multihomed_INET_Addr from a port_number, a primary_host_name, and an array of <secondary_host_names>. size is taken to be the length of the array. 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 is 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.
Definition at line 34 of file Multihomed_INET_Addr.cpp.
References ACE_DEBUG, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, LM_DEBUG, secondaries_, ACE_INET_Addr::set(), and ACE_Array_Base< T >::size().
00039 { 00040 00041 // Initialize the primary INET addr 00042 ACE_INET_Addr::set(port_number, host_name, encode, address_family); 00043 00044 // check for secondary INET addrs 00045 if (secondary_host_names && size){ 00046 // we have a non-zero pointer and size 00047 this->secondaries_.size(size); // size the array 00048 00049 size_t next_empty_slot = 0; 00050 for (size_t i = 0; i < size; ++i) { 00051 int ret = this->secondaries_[next_empty_slot].set(port_number, 00052 secondary_host_names[i], 00053 encode, 00054 address_family); 00055 if (ret) { 00056 ACE_DEBUG ((LM_DEBUG, 00057 ACE_TEXT ("Invalid INET addr (%s:%u) will be ignored\n"), 00058 ACE_TEXT_CHAR_TO_TCHAR (secondary_host_names[i]), port_number)); 00059 this->secondaries_.size(this->secondaries_.size() - 1); 00060 } 00061 else 00062 ++next_empty_slot; 00063 } 00064 } 00065 00066 return; 00067 }
ACE_Multihomed_INET_Addr::ACE_Multihomed_INET_Addr | ( | u_short | port_number, | |
ACE_UINT32 | primary_ip_addr = INADDR_ANY , |
|||
int | encode = 1 , |
|||
const ACE_UINT32 * | secondary_ip_addrs = 0 , |
|||
size_t | size = 0 | |||
) |
Constructs an ACE_Multihomed_INET_Addr from a port_number, a primary_ip_addr, and an array of secondary_ip_addrs. size is taken to be the length of the array. If encode is non-zero, then the port number and the IP addresses are converted into network byte order; otherwise they are assumed to be in network byte order already and are passed straight through.
Definition at line 106 of file Multihomed_INET_Addr.cpp.
References ACE_DEBUG, LM_DEBUG, secondaries_, ACE_INET_Addr::set(), and ACE_Array_Base< T >::size().
00110 { 00111 00112 // Initialize the primary INET addr 00113 ACE_INET_Addr::set(port_number, primary_ip_addr, encode); 00114 00115 // check for secondary INET addrs 00116 if (secondary_ip_addrs && size){ 00117 // we have a non-zero pointer and size 00118 this->secondaries_.size(size); // size the array 00119 00120 size_t next_empty_slot = 0; 00121 for (size_t i = 0; i < size; ++i) { 00122 int const ret = this->secondaries_[next_empty_slot].set(port_number, 00123 secondary_ip_addrs[i], 00124 encode); 00125 00126 if (ret) { 00127 ACE_DEBUG ((LM_DEBUG, 00128 "Invalid INET addr (%u:%u) will be ignored\n", 00129 secondary_ip_addrs[i], port_number)); 00130 this->secondaries_.size(this->secondaries_.size() - 1); 00131 } 00132 else 00133 ++next_empty_slot; 00134 } 00135 } 00136 00137 return; 00138 }
ACE_Multihomed_INET_Addr::~ACE_Multihomed_INET_Addr | ( | void | ) |
void ACE_Multihomed_INET_Addr::get_addresses | ( | sockaddr_in * | addrs, | |
size_t | size | |||
) | const |
Initialize user-supplied array addrs with the the current primary and secondary addresses. size is taken as the size of this array.
Definition at line 249 of file Multihomed_INET_Addr.cpp.
References ACE_INET_Addr::get_addr(), secondaries_, and ACE_Array_Base< T >::size().
Referenced by ACE_SOCK_SEQPACK_Connector::shared_connect_start(), and ACE_SOCK_SEQPACK_Acceptor::shared_open().
00251 { 00252 // Copy primary address to the first slot of the user-supplied array 00253 if (size > 0) { 00254 addrs[0] = *reinterpret_cast<sockaddr_in*> (this->get_addr ()); 00255 } 00256 00257 // Copy secondary addresses to remaining slots of the user-supplied 00258 // array. Secondary address [i] is copied to slot [i+1] 00259 00260 size_t top = size - 1 < this->secondaries_.size() ? 00261 size - 1 : this->secondaries_.size(); 00262 00263 for (size_t i = 0; i < top; ++i) { 00264 addrs[i+1] = 00265 *reinterpret_cast<sockaddr_in*> (this->secondaries_[i].get_addr()); 00266 } 00267 }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE size_t ACE_Multihomed_INET_Addr::get_num_secondary_addresses | ( | ) | const |
Returns the number of secondary addresses.
Definition at line 10 of file Multihomed_INET_Addr.inl.
References secondaries_, and ACE_Array_Base< T >::size().
Referenced by ACE_SOCK_SEQPACK_Connector::shared_connect_start(), and ACE_SOCK_SEQPACK_Acceptor::shared_open().
00011 { 00012 return this->secondaries_.size(); 00013 }
int ACE_Multihomed_INET_Addr::get_secondary_addresses | ( | ACE_INET_Addr * | secondary_addrs, | |
size_t | size | |||
) | const |
Initialize user-supplied array secondary_addrs with the current secondary addresses. size is taken as the size of this array.
Definition at line 228 of file Multihomed_INET_Addr.cpp.
References secondaries_, set(), and ACE_Array_Base< T >::size().
00230 { 00231 size_t top = 00232 size < this->secondaries_.size() ? 00233 size : this->secondaries_.size(); 00234 00235 for (size_t i = 0; i < top; ++i) 00236 { 00237 00238 int ret = 00239 secondary_addrs[i].set (this->secondaries_[i]); 00240 00241 if (ret) 00242 return ret; 00243 } 00244 00245 return 0; 00246 }
int ACE_Multihomed_INET_Addr::set | ( | u_short | port_number, | |
ACE_UINT32 | primary_ip_addr = INADDR_ANY , |
|||
int | encode = 1 , |
|||
const ACE_UINT32 * | secondary_ip_addrs = 0 , |
|||
size_t | size = 0 | |||
) |
Initializes an ACE_Multihomed_INET_Addr from a port_number, a primary_ip_addr, and an array of secondary_ip_addrs. size is taken to be the length of the array. If encode is non-zero, then the port number and the IP addresses are converted into network byte order; otherwise they are assumed to be in network byte order already and are passed straight through.
Definition at line 195 of file Multihomed_INET_Addr.cpp.
References secondaries_, ACE_INET_Addr::set(), and ACE_Array_Base< T >::size().
00200 { 00201 this->secondaries_.size(size); 00202 00203 for (size_t i = 0; i < size; ++i) { 00204 00205 int ret = this->secondaries_[i].set(port_number, 00206 secondary_ip_addrs[i], 00207 encode); 00208 00209 if (ret) { 00210 return ret; 00211 } 00212 } 00213 00214 return ACE_INET_Addr::set(port_number, primary_ip_addr, encode); 00215 }
int ACE_Multihomed_INET_Addr::set | ( | u_short | port_number, | |
const char | primary_host_name[], | |||
int | encode = 1 , |
|||
int | address_family = AF_UNSPEC , |
|||
const char * | (secondary_host_names[]) = 0 , |
|||
size_t | size = 0 | |||
) |
Initializes an ACE_Multihomed_INET_Addr from a port_number, a primary_host_name, and an array of <secondary_host_names>. size is taken to be the length of the array. 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 is 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.
Definition at line 142 of file Multihomed_INET_Addr.cpp.
References secondaries_, ACE_INET_Addr::set(), and ACE_Array_Base< T >::size().
Referenced by get_secondary_addresses().
00148 { 00149 this->secondaries_.size(size); 00150 00151 for (size_t i = 0; i < size; ++i) { 00152 00153 int const ret = this->secondaries_[i].set(port_number, 00154 secondary_host_names[i], 00155 encode, 00156 address_family); 00157 if (ret) { 00158 return ret; 00159 } 00160 } 00161 00162 return ACE_INET_Addr::set(port_number, host_name, encode, address_family); 00163 }
void ACE_Multihomed_INET_Addr::set_port_number | ( | u_short | port_number, | |
int | encode = 1 | |||
) |
Sets the port number without affecting the host name. The port numbers of the primary address, and of any and all secondary addresses, are affected. 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 is passed straight through.
Reimplemented from ACE_INET_Addr.
Definition at line 218 of file Multihomed_INET_Addr.cpp.
References secondaries_, ACE_INET_Addr::set_port_number(), and ACE_Array_Base< T >::size().
00219 { 00220 size_t i = 0; 00221 while (i < secondaries_.size()) 00222 secondaries_[i++].set_port_number(port_number, encode); 00223 00224 this->ACE_INET_Addr::set_port_number(port_number, encode); 00225 }
Definition at line 187 of file Multihomed_INET_Addr.h.
Referenced by ACE_Multihomed_INET_Addr(), get_addresses(), get_num_secondary_addresses(), get_secondary_addresses(), set(), and set_port_number().