Some missing from merge.

Signed-off-by: Salja <salja2012@hotmail.de>
This commit is contained in:
Salja 2012-08-05 14:54:07 +02:00 committed by Antz
parent ec939a5bce
commit f4be15a7af
1895 changed files with 160408 additions and 53601 deletions

View file

@ -1,3 +1,5 @@
// $Id: Multihomed_INET_Addr.cpp 96985 2013-04-11 15:50:32Z huangh $
// Extends ACE_INET_Addr with support for multi-homed addresses.
#include "ace/Multihomed_INET_Addr.h"
@ -243,40 +245,21 @@ void
ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in *addrs,
size_t size) const
{
if (size == 0)
return;
// Copy primary address(es) to the first slot(s) of the user-supplied array
ACE_INET_Addr me (*this);
size_t i = 0;
for (i = 0; i < size; ++i)
{
sockaddr_in *in4 = reinterpret_cast<sockaddr_in*> (me.get_addr ());
if (in4->sin_family == AF_INET)
{
addrs[i] = *in4;
++i;
}
if (!me.next ())
break;
}
// Copy primary address to the first slot of the user-supplied array
if (size > 0) {
addrs[0] = *reinterpret_cast<sockaddr_in*> (this->get_addr ());
}
// Copy secondary addresses to remaining slots of the user-supplied
// array. Secondary address [i] is copied to slot [i+1]
for (size_t j = 0; j < this->secondaries_.size (); ++j)
{
ACE_INET_Addr copy (this->secondaries_[j]);
for (; i < size; ++i)
{
sockaddr_in *in4 = reinterpret_cast<sockaddr_in*> (copy.get_addr ());
if (in4->sin_family == AF_INET)
{
addrs[i] = *in4;
++i;
}
if (!copy.next ())
break;
}
}
size_t top = size - 1 < this->secondaries_.size() ?
size - 1 : this->secondaries_.size();
for (size_t i = 0; i < top; ++i) {
addrs[i+1] =
*reinterpret_cast<sockaddr_in*> (this->secondaries_[i].get_addr());
}
}
#if defined (ACE_HAS_IPV6)
@ -284,40 +267,22 @@ void
ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in6 *addrs,
size_t size) const
{
if (size == 0)
return;
// Copy primary address(es) to the first slot(s) of the user-supplied array
ACE_INET_Addr me (*this);
size_t i = 0;
for (i = 0; i < size; ++i)
// Copy primary address to the first slot of the user-supplied array
if (size > 0)
{
sockaddr_in6 *in6 = reinterpret_cast<sockaddr_in6*> (me.get_addr ());
if (in6->sin6_family == AF_INET6)
{
addrs[i] = *in6;
++i;
}
if (!me.next ())
break;
addrs[0] = *reinterpret_cast<sockaddr_in6*> (this->get_addr ());
}
// Copy secondary addresses to remaining slots of the user-supplied
// array. Secondary address [i] is copied to slot [i+1]
for (size_t j = 0; j < this->secondaries_.size (); ++j)
size_t top =
size - 1 < this->secondaries_.size() ?
size - 1 : this->secondaries_.size();
for (size_t i = 0; i < top; ++i)
{
ACE_INET_Addr copy (this->secondaries_[j]);
for (; i < size; ++i)
{
sockaddr_in6 *in6 =
reinterpret_cast<sockaddr_in6*> (copy.get_addr ());
if (in6->sin6_family == AF_INET6)
{
addrs[i] = *in6;
++i;
}
if (!copy.next ())
break;
}
addrs[i+1] =
*reinterpret_cast<sockaddr_in6*> (this->secondaries_[i].get_addr());
}
}
#endif /* ACE_HAS_IPV6 */