#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 (u_short port_number, const wchar_t primary_host_name[], int encode=1, int address_family=AF_UNSPEC, const wchar_t *(secondary_host_names[])=0, size_t size=0) | |
int | set (u_short port_number, const wchar_t primary_host_name[], int encode=1, int address_family=AF_UNSPEC, const wchar_t *(secondary_host_names[])=0, size_t size=0) |
~ACE_Multihomed_INET_Addr (void) | |
Use compiler-generated copy constructor. Use compiler-generated assignment operator. 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, 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 |
void | get_addresses (sockaddr_in6 *addrs, size_t size) const |
IPV6 version of the above. | |
Private Attributes | |
ACE_Array< ACE_INET_Addr > | secondaries_ |
Definition at line 35 of file Multihomed_INET_Addr.h.
|
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 } |
|
Initializes an from the , 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 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 } |
|
Constructs an from a , a , and an array of . size is taken to be the length of the array. If is non-zero, then is converted into network byte order; otherwise it is assumed to be in network byte order already and is passed straight through. 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_Array_Base< ACE_INET_Addr >::set(), ACE_INET_Addr::set(), and ACE_Array_Base< ACE_INET_Addr >::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 } |
|
Constructs an 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_Array_Base< ACE_INET_Addr >::set(), ACE_INET_Addr::set(), and ACE_Array_Base< ACE_INET_Addr >::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 } |
|
WCHAR versions of the methods that take char's as arguments. Definition at line 70 of file Multihomed_INET_Addr.cpp. References ACE_DEBUG, ACE_TEXT, ACE_TEXT_WCHAR_TO_TCHAR, LM_DEBUG, secondaries_, ACE_Array_Base< ACE_INET_Addr >::set(), ACE_INET_Addr::set(), and ACE_Array_Base< ACE_INET_Addr >::size().
00075 { 00076 00077 // Initialize the primary INET addr 00078 ACE_INET_Addr::set(port_number, host_name, encode, address_family); 00079 00080 // check for secondary INET addrs 00081 if (secondary_host_names && size){ 00082 // we have a non-zero pointer and size 00083 this->secondaries_.size(size); // size the array 00084 00085 size_t next_empty_slot = 0; 00086 for (size_t i = 0; i < size; ++i) { 00087 int ret = this->secondaries_[next_empty_slot].set(port_number, 00088 secondary_host_names[i], 00089 encode, 00090 address_family); 00091 if (ret) { 00092 ACE_DEBUG ((LM_DEBUG, 00093 ACE_TEXT ("Invalid INET addr (%s:%u) will be ignored\n"), 00094 ACE_TEXT_WCHAR_TO_TCHAR (secondary_host_names[i]), port_number)); 00095 this->secondaries_.size(this->secondaries_.size() - 1); 00096 } 00097 else 00098 ++next_empty_slot; 00099 } 00100 } 00101 00102 return; 00103 } |
|
Use compiler-generated copy constructor. Use compiler-generated assignment operator. Default dtor.
Definition at line 295 of file Multihomed_INET_Addr.cpp.
00296 { 00297 00298 } |
|
IPV6 version of the above.
Definition at line 271 of file Multihomed_INET_Addr.cpp. References ACE_INET_Addr::get_addr(), secondaries_, and ACE_Array_Base< ACE_INET_Addr >::size().
00273 { 00274 // Copy primary address to the first slot of the user-supplied array 00275 if (size > 0) 00276 { 00277 addrs[0] = *reinterpret_cast<sockaddr_in6*> (this->get_addr ()); 00278 } 00279 00280 // Copy secondary addresses to remaining slots of the user-supplied 00281 // array. Secondary address [i] is copied to slot [i+1] 00282 size_t top = 00283 size - 1 < this->secondaries_.size() ? 00284 size - 1 : this->secondaries_.size(); 00285 00286 for (size_t i = 0; i < top; ++i) 00287 { 00288 addrs[i+1] = 00289 *reinterpret_cast<sockaddr_in6*> (this->secondaries_[i].get_addr()); 00290 } 00291 } |
|
Initialize user-supplied array 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< ACE_INET_Addr >::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 } |
|
Returns the number of secondary addresses. Definition at line 10 of file Multihomed_INET_Addr.inl. References secondaries_, and ACE_Array_Base< ACE_INET_Addr >::size(). Referenced by ACE_SOCK_SEQPACK_Connector::shared_connect_start(), and ACE_SOCK_SEQPACK_Acceptor::shared_open().
00011 { 00012 return this->secondaries_.size(); 00013 } |
|
Initialize user-supplied array 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_, ACE_INET_Addr::set(), and ACE_Array_Base< ACE_INET_Addr >::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 } |
|
Initializes an 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(), ACE_Array_Base< ACE_INET_Addr >::set(), and ACE_Array_Base< ACE_INET_Addr >::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 } |
|
Initializes an from a , a , and an array of . size is taken to be the length of the array. If is non-zero, then is converted into network byte order; otherwise it is assumed to be in network byte order already and is passed straight through. 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(), ACE_Array_Base< ACE_INET_Addr >::set(), and ACE_Array_Base< ACE_INET_Addr >::size().
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 } |
|
Definition at line 170 of file Multihomed_INET_Addr.cpp. References secondaries_, ACE_INET_Addr::set(), ACE_Array_Base< ACE_INET_Addr >::set(), and ACE_Array_Base< ACE_INET_Addr >::size().
00176 { 00177 this->secondaries_.size(size); 00178 00179 for (size_t i = 0; i < size; ++i) { 00180 00181 int ret = this->secondaries_[i].set(port_number, 00182 secondary_host_names[i], 00183 encode, 00184 address_family); 00185 if (ret) { 00186 return ret; 00187 } 00188 } 00189 00190 return ACE_INET_Addr::set(port_number, host_name, encode, address_family); 00191 } |
|
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 is enabled, then 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< ACE_INET_Addr >::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(). |