mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 11:26:10 +00:00
ws2_32: IPv6 functionality for WSAAddressToStringW.
This commit is contained in:
parent
c620ec8f72
commit
4a8e36548d
2 changed files with 14 additions and 35 deletions
|
@ -5001,42 +5001,30 @@ INT WINAPI WSAAddressToStringA( LPSOCKADDR sockaddr, DWORD len,
|
|||
*
|
||||
* NOTES
|
||||
* The 'info' parameter is ignored.
|
||||
*
|
||||
* BUGS
|
||||
* Only supports AF_INET addresses.
|
||||
*/
|
||||
INT WINAPI WSAAddressToStringW( LPSOCKADDR sockaddr, DWORD len,
|
||||
LPWSAPROTOCOL_INFOW info, LPWSTR string,
|
||||
LPDWORD lenstr )
|
||||
{
|
||||
DWORD size;
|
||||
WCHAR buffer[22]; /* 12 digits + 3 dots + ':' + 5 digits + '\0' */
|
||||
static const WCHAR format[] = { '%','u','.','%','u','.','%','u','.','%','u',':','%','u',0 };
|
||||
WCHAR *p;
|
||||
INT ret;
|
||||
DWORD size, sizew;
|
||||
WCHAR buffer[54]; /* 32 digits + 7':' + '[' + '%" + 5 digits + ']:' + 5 digits + '\0' */
|
||||
CHAR bufAddr[54];
|
||||
|
||||
TRACE( "(%p, %x, %p, %p, %p)\n", sockaddr, len, info, string, lenstr );
|
||||
TRACE( "(%p, %d, %p, %p, %p)\n", sockaddr, len, info, string, lenstr );
|
||||
|
||||
if (!sockaddr || len < sizeof(SOCKADDR_IN)) return SOCKET_ERROR;
|
||||
if (!string || !lenstr) return SOCKET_ERROR;
|
||||
size = *lenstr;
|
||||
ret = WSAAddressToStringA(sockaddr, len, NULL, bufAddr, &size);
|
||||
|
||||
/* sin_family is guaranteed to be the first u_short */
|
||||
if (((SOCKADDR_IN *)sockaddr)->sin_family != AF_INET) return SOCKET_ERROR;
|
||||
if (ret) return ret;
|
||||
|
||||
sprintfW( buffer, format,
|
||||
(unsigned int)(ntohl( ((SOCKADDR_IN *)sockaddr)->sin_addr.WS_s_addr ) >> 24 & 0xff),
|
||||
(unsigned int)(ntohl( ((SOCKADDR_IN *)sockaddr)->sin_addr.WS_s_addr ) >> 16 & 0xff),
|
||||
(unsigned int)(ntohl( ((SOCKADDR_IN *)sockaddr)->sin_addr.WS_s_addr ) >> 8 & 0xff),
|
||||
(unsigned int)(ntohl( ((SOCKADDR_IN *)sockaddr)->sin_addr.WS_s_addr ) & 0xff),
|
||||
ntohs( ((SOCKADDR_IN *)sockaddr)->sin_port ) );
|
||||
|
||||
p = strchrW( buffer, ':' );
|
||||
if (!((SOCKADDR_IN *)sockaddr)->sin_port) *p = 0;
|
||||
|
||||
size = strlenW( buffer ) + 1;
|
||||
sizew = sizeof( buffer );
|
||||
MultiByteToWideChar( CP_ACP, 0, bufAddr, size, buffer, sizew );
|
||||
|
||||
if (*lenstr < size)
|
||||
{
|
||||
*lenstr = size;
|
||||
WSASetLastError(WSAEFAULT);
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -1575,13 +1575,9 @@ static void test_WSAAddressToStringW(void)
|
|||
memcpy (sockaddr6.sin6_addr.s6_addr, addr6_1, sizeof(addr6_1));
|
||||
|
||||
ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len );
|
||||
todo_wine
|
||||
{
|
||||
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
|
||||
|
||||
ok( !lstrcmpW( address6, expect6_1 ), "Wrong string returned\n" );
|
||||
ok( len == sizeof(expect6_1)/sizeof(WCHAR), "Got %d\n", len);
|
||||
}
|
||||
|
||||
/* Test a longer IPv6 address */
|
||||
len = sizeof(address6)/sizeof(WCHAR);
|
||||
|
@ -1592,13 +1588,10 @@ static void test_WSAAddressToStringW(void)
|
|||
memcpy (sockaddr6.sin6_addr.s6_addr, addr6_2, sizeof(addr6_2));
|
||||
|
||||
ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len );
|
||||
todo_wine
|
||||
{
|
||||
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
|
||||
|
||||
ok( !lstrcmpW( address6, expect6_2 ), "Wrong string returned\n" );
|
||||
ok( len == sizeof(expect6_2)/sizeof(WCHAR), "Got %d\n", len);
|
||||
}
|
||||
|
||||
/* Test IPv6 address and port number */
|
||||
len = sizeof(address6)/sizeof(WCHAR);
|
||||
|
@ -1609,10 +1602,9 @@ static void test_WSAAddressToStringW(void)
|
|||
memcpy (sockaddr6.sin6_addr.s6_addr, addr6_3, sizeof(addr6_3));
|
||||
|
||||
ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len );
|
||||
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
|
||||
todo_wine
|
||||
{
|
||||
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
|
||||
|
||||
ok( !lstrcmpW( address6, expect6_3 ), "Wrong string returned\n" );
|
||||
ok( len == sizeof(expect6_3)/sizeof(WCHAR), "Got %d\n", len);
|
||||
}
|
||||
|
@ -1626,9 +1618,9 @@ static void test_WSAAddressToStringW(void)
|
|||
memcpy (sockaddr6.sin6_addr.s6_addr, addr6_3, sizeof(addr6_3));
|
||||
|
||||
ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len );
|
||||
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
|
||||
todo_wine
|
||||
{
|
||||
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
|
||||
ok( !lstrcmpW( address6, expect6_3_2 ), "Wrong string returned\n" );
|
||||
ok( len == sizeof(expect6_3_2)/sizeof(WCHAR), "Got %d\n", len);
|
||||
}
|
||||
|
@ -1642,10 +1634,9 @@ static void test_WSAAddressToStringW(void)
|
|||
memcpy (sockaddr6.sin6_addr.s6_addr, addr6_3, sizeof(addr6_3));
|
||||
|
||||
ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len );
|
||||
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
|
||||
todo_wine
|
||||
{
|
||||
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
|
||||
|
||||
ok( !lstrcmpW( address6, expect6_3_3 ), "Wrong string returned\n" );
|
||||
ok( len == sizeof(expect6_3_3)/sizeof(WCHAR), "Got %d\n", len);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue