ws2_32: Make inet_ntop conform to msdn definition.

This commit is contained in:
Jeff Latimer 2009-04-25 00:30:22 +10:00 committed by Alexandre Julliard
parent 0cdd0d80ee
commit 4d4819d8c4
2 changed files with 10 additions and 8 deletions

View File

@ -4698,16 +4698,18 @@ int WINAPI WSARemoveServiceClass(LPGUID info)
PCSTR WINAPI WS_inet_ntop( INT family, PVOID addr, PSTR buffer, size_t len )
{
#ifdef HAVE_INET_NTOP
union generic_unix_sockaddr unix_addr;
struct WS_in6_addr *in6;
struct WS_in_addr *in;
TRACE("family %d, addr (%p), buffer (%p), len %d\n", family, addr, buffer, len);
switch (family)
{
case WS_AF_INET:
ws_sockaddr_ws2u( addr, sizeof(struct WS_sockaddr_in), &unix_addr );
return inet_ntop( AF_INET, &unix_addr, buffer, len );
in = addr;
return inet_ntop( AF_INET, &in->WS_s_addr, buffer, len );
case WS_AF_INET6:
ws_sockaddr_ws2u( addr, sizeof(struct WS_sockaddr_in6), &unix_addr );
return inet_ntop( AF_INET6, &unix_addr, buffer, len );
in6 = addr;
return inet_ntop( AF_INET6, in6->WS_s6_addr, buffer, len );
}
#else
FIXME( "not supported on this platform\n" );

View File

@ -2040,7 +2040,7 @@ static void test_addr_to_print(void)
pdst = pInetNtop(AF_INET,(void*)&in.s_addr, dst, sizeof(dst));
ok(pdst != NULL, "InetNtop failed %s\n", dst);
todo_wine ok(!strcmp(pdst, addr1_Str),"Address %s != %s\n", pdst, addr1_Str);
ok(!strcmp(pdst, addr1_Str),"Address %s != %s\n", pdst, addr1_Str);
/* Test invalid parm conditions */
pdst = pInetNtop(1, (void*)&in.s_addr, dst, sizeof(dst));
@ -2051,13 +2051,13 @@ static void test_addr_to_print(void)
memcpy(in6.u.Byte, addr2_Num, sizeof(addr2_Num));
pdst = pInetNtop(AF_INET6,(void*)&in6.s6_addr, dst6, sizeof(dst6));
ok(pdst != NULL, "InetNtop failed %s\n", dst6);
todo_wine ok(!strcmp(pdst, addr2_Str),"Address %s != %s\n", pdst, addr2_Str);
ok(!strcmp(pdst, addr2_Str),"Address %s != %s\n", pdst, addr2_Str);
/* Test an zero suffixed IPV6 address */
memcpy(in6.s6_addr, addr3_Num, sizeof(addr3_Num));
pdst = pInetNtop(AF_INET6,(void*)&in6.s6_addr, dst6, sizeof(dst6));
ok(pdst != NULL, "InetNtop failed %s\n", dst6);
todo_wine ok(!strcmp(pdst, addr3_Str),"Address %s != %s\n", pdst, addr3_Str);
ok(!strcmp(pdst, addr3_Str),"Address %s != %s\n", pdst, addr3_Str);
}
static void test_ioctlsocket(void)