Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACE6] Fixes for IPv6 multicast and inet_ntop/inet_pton on Windows #1352

Merged
merged 4 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions ACE/ace/SOCK_Dgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,21 +786,34 @@ ACE_SOCK_Dgram::make_multicast_ifaddr6 (ipv6_mreq *ret_mreq,
ACE_OS::ace_isdigit (net_if[0]) &&
(if_ix = ACE_OS::atoi (net_if)) > 0;

IP_ADAPTER_ADDRESSES tmp_addrs;
// Initial call to determine actual memory size needed
ULONG bufLen = 0;
ULONG bufLen = 15000; // Initial size as per Microsoft
jwillemsen marked this conversation as resolved.
Show resolved Hide resolved
char *buf = 0;
if (::GetAdaptersAddresses (AF_INET6, 0, 0, &tmp_addrs, &bufLen)
== ERROR_BUFFER_OVERFLOW)
ACE_NEW_RETURN (buf, char[bufLen], -1);
DWORD dwRetVal = 0;
ULONG iterations = 0;
const ULONG maxTries = 3;
kuznetsovmoci marked this conversation as resolved.
Show resolved Hide resolved
PIP_ADAPTER_ADDRESSES pAddrs;
do
{
ACE_NEW_RETURN (buf, char[bufLen], -1);
}
pAddrs = reinterpret_cast<PIP_ADAPTER_ADDRESSES> (buf);
dwRetVal = ::GetAdaptersAddresses (AF_INET6, 0, 0, pAddrs, &bufLen);
if (dwRetVal == ERROR_BUFFER_OVERFLOW)
{
delete[] buf;
ACE_NEW_RETURN (buf, char[bufLen], -1);
++iterations;
}
else
{
break;
}
} while (dwRetVal == ERROR_BUFFER_OVERFLOW && iterations < maxTries);

// Get required output buffer and retrieve info for real.
PIP_ADAPTER_ADDRESSES pAddrs = reinterpret_cast<PIP_ADAPTER_ADDRESSES> (buf);
if (::GetAdaptersAddresses (AF_INET6, 0, 0, pAddrs, &bufLen) != NO_ERROR)
if (dwRetVal != NO_ERROR)
{
pAddrs = 0;
delete[] buf;
errno = EINVAL;
return -1;
}

while (pAddrs)
Expand All @@ -819,14 +832,11 @@ ACE_SOCK_Dgram::make_multicast_ifaddr6 (ipv6_mreq *ret_mreq,

delete[] buf; // clean up

#endif /* ACE_WIN32 */
#else /* ACE_WIN32 */
#ifndef ACE_LACKS_IF_NAMETOINDEX
if (lmreq.ipv6mr_interface == 0)
{
lmreq.ipv6mr_interface = ACE_OS::if_nametoindex (ACE_TEXT_ALWAYS_CHAR (net_if));
}

lmreq.ipv6mr_interface = ACE_OS::if_nametoindex (ACE_TEXT_ALWAYS_CHAR (net_if));
#endif /* ACE_LACKS_IF_NAMETOINDEX */
#endif /* ACE_WIN32 */
if (lmreq.ipv6mr_interface == 0)
{
errno = EINVAL;
Expand Down
6 changes: 2 additions & 4 deletions ACE/ace/config-win32-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,6 @@
#define ACE_LACKS_GETIPNODEBYNAME_IPV6
#define ACE_LACKS_KILL
#define ACE_LACKS_INET_ATON
#if _WIN32_WINNT < 0x0600
# define ACE_LACKS_INET_NTOP
# define ACE_LACKS_INET_PTON
#endif
#define ACE_LACKS_MADVISE
#define ACE_LACKS_MKFIFO
#define ACE_LACKS_MODE_MASKS
Expand Down Expand Up @@ -566,6 +562,8 @@
# define ACE_HAS_WIN32_TRYLOCK
#endif
#if _WIN32_WINNT < 0x600
# define ACE_LACKS_INET_NTOP
# define ACE_LACKS_INET_PTON
# define ACE_LACKS_IF_NAMETOINDEX
#endif
#define ACE_LACKS_IF_NAMEINDEX
Expand Down