Commit b19160b3 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Undo broken Win32 ifdefs (breaks IPv6 case on decent OSes)

parent 061b69e7
...@@ -648,47 +648,23 @@ static const char *MakeRandMulticast (int family, char *buf, size_t buflen) ...@@ -648,47 +648,23 @@ static const char *MakeRandMulticast (int family, char *buf, size_t buflen)
#ifdef AF_INET6 #ifdef AF_INET6
case AF_INET6: case AF_INET6:
{ {
struct sockaddr_in6 addr; struct in6_addr addr;
memset(&addr, 0, sizeof(addr));
memcpy (&addr, "\xff\x38\x00\x00" "\x00\x00\x00\x00" memcpy (&addr, "\xff\x38\x00\x00" "\x00\x00\x00\x00"
"\x00\x00\x00\x00", 12); "\x00\x00\x00\x00", 12);
rand |= 0x80000000; rand |= 0x80000000;
memcpy (addr.sin6_addr.s6_addr + 12, &(uint32_t){ htonl (rand) }, 4); memcpy (addr.s6_addr + 12, &(uint32_t){ htonl (rand) }, 4);
#if defined(WIN32) || defined(UNDER_CE) return inet_ntop (family, &addr, buf, buflen);
addr.sin6_family = AF_INET6;
if( 0 == WSAAddressToStringA((LPSOCKADDR)&addr, sizeof(struct sockaddr_in6), NULL, buf, &buflen) )
{
buf[buflen] = '\0';
return buf;
}
return NULL;
#else
return inet_ntop (family, &(addr.sin6_addr), buf, buflen);
#endif
} }
#endif #endif
case AF_INET: case AF_INET:
{ {
struct sockaddr_in addr; struct in_addr addr;
memset(&addr, 0, sizeof(addr)); addr.s_addr = htonl ((rand & 0xffffff) | 0xe8000000);
addr.sin_addr.s_addr = htonl ((rand & 0xffffff) | 0xe8000000); return inet_ntop (family, &addr, buf, buflen);
#if defined(WIN32) || defined(UNDER_CE)
addr.sin_family = AF_INET;
if( 0 == WSAAddressToStringA((LPSOCKADDR)&addr, sizeof(struct sockaddr_in), NULL, buf, &buflen) )
{
buf[buflen] = '\0';
return buf;
}
return NULL;
#else
return inet_ntop (family, &(addr.sin_addr), buf, buflen);
#endif
} }
} }
#if defined(WIN32) || defined(UNDER_CE) #ifdef EAFNOSUPPORT
WSASetLastError(WSAEAFNOSUPPORT);
#else
errno = EAFNOSUPPORT; errno = EAFNOSUPPORT;
#endif #endif
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment