Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
2fa64f52
Commit
2fa64f52
authored
Apr 27, 2009
by
Jeff Latimer
Committed by
Alexandre Julliard
Apr 29, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: IPv6 functionality for WSAAddressToStringA.
parent
7d78bf4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
19 deletions
+32
-19
socket.c
dlls/ws2_32/socket.c
+29
-10
sock.c
dlls/ws2_32/tests/sock.c
+3
-9
No files found.
dlls/ws2_32/socket.c
View file @
2fa64f52
...
@@ -4922,7 +4922,7 @@ INT WINAPI WSAAddressToStringA( LPSOCKADDR sockaddr, DWORD len,
...
@@ -4922,7 +4922,7 @@ INT WINAPI WSAAddressToStringA( LPSOCKADDR sockaddr, DWORD len,
LPDWORD
lenstr
)
LPDWORD
lenstr
)
{
{
DWORD
size
;
DWORD
size
;
CHAR
buffer
[
22
];
/* 12 digits + 3 dots + '
:' + 5 digits + '\0' */
CHAR
buffer
[
54
];
/* 32 digits + 7':' + '[' + '%" + 5 digits + ']
:' + 5 digits + '\0' */
CHAR
*
p
;
CHAR
*
p
;
TRACE
(
"(%p, %d, %p, %p, %p)
\n
"
,
sockaddr
,
len
,
info
,
string
,
lenstr
);
TRACE
(
"(%p, %d, %p, %p, %p)
\n
"
,
sockaddr
,
len
,
info
,
string
,
lenstr
);
...
@@ -4931,17 +4931,36 @@ INT WINAPI WSAAddressToStringA( LPSOCKADDR sockaddr, DWORD len,
...
@@ -4931,17 +4931,36 @@ INT WINAPI WSAAddressToStringA( LPSOCKADDR sockaddr, DWORD len,
if
(
!
string
||
!
lenstr
)
return
SOCKET_ERROR
;
if
(
!
string
||
!
lenstr
)
return
SOCKET_ERROR
;
/* sin_family is guaranteed to be the first u_short */
/* sin_family is guaranteed to be the first u_short */
if
(((
SOCKADDR_IN
*
)
sockaddr
)
->
sin_family
!=
AF_INET
)
return
SOCKET_ERROR
;
switch
(((
SOCKADDR_IN
*
)
sockaddr
)
->
sin_family
)
{
case
WS_AF_INET
:
sprintf
(
buffer
,
"%u.%u.%u.%u:%u"
,
(
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
=
strchr
(
buffer
,
':'
);
if
(
!
((
SOCKADDR_IN
*
)
sockaddr
)
->
sin_port
)
*
p
=
0
;
break
;
sprintf
(
buffer
,
"%u.%u.%u.%u:%u"
,
case
WS_AF_INET6
:
(
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
),
struct
WS_sockaddr_in6
*
sockaddr6
=
(
LPSOCKADDR_IN6
)
sockaddr
;
(
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
=
strchr
(
buffer
,
':'
);
if
(
!
WS_inet_ntop
(
WS_AF_INET6
,
&
sockaddr6
->
sin6_addr
,
buffer
,
sizeof
(
buffer
)))
if
(
!
((
SOCKADDR_IN
*
)
sockaddr
)
->
sin_port
)
*
p
=
0
;
{
WSASetLastError
(
WSAEINVAL
);
return
SOCKET_ERROR
;
}
break
;
}
default:
WSASetLastError
(
WSAEINVAL
);
return
SOCKET_ERROR
;
}
size
=
strlen
(
buffer
)
+
1
;
size
=
strlen
(
buffer
)
+
1
;
...
...
dlls/ws2_32/tests/sock.c
View file @
2fa64f52
...
@@ -1371,12 +1371,9 @@ static void test_WSAAddressToStringA(void)
...
@@ -1371,12 +1371,9 @@ static void test_WSAAddressToStringA(void)
memcpy
(
sockaddr6
.
sin6_addr
.
s6_addr
,
addr6_1
,
sizeof
(
addr6_1
));
memcpy
(
sockaddr6
.
sin6_addr
.
s6_addr
,
addr6_1
,
sizeof
(
addr6_1
));
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr6
,
sizeof
(
sockaddr6
),
NULL
,
address6
,
&
len
);
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr6
,
sizeof
(
sockaddr6
),
NULL
,
address6
,
&
len
);
todo_wine
{
ok
(
!
ret
,
"WSAAddressToStringA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
ok
(
!
ret
,
"WSAAddressToStringA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
ok
(
!
strcmp
(
address6
,
expect6_1
),
"Expected: %s, got: %s
\n
"
,
expect6_1
,
address6
);
ok
(
!
strcmp
(
address6
,
expect6_1
),
"Expected: %s, got: %s
\n
"
,
expect6_1
,
address6
);
ok
(
len
==
sizeof
(
expect6_1
),
"Got size %d
\n
"
,
len
);
ok
(
len
==
sizeof
(
expect6_1
),
"Got size %d
\n
"
,
len
);
}
/* Test a longer IPv6 address */
/* Test a longer IPv6 address */
len
=
sizeof
(
address6
);
len
=
sizeof
(
address6
);
...
@@ -1387,12 +1384,9 @@ static void test_WSAAddressToStringA(void)
...
@@ -1387,12 +1384,9 @@ static void test_WSAAddressToStringA(void)
memcpy
(
sockaddr6
.
sin6_addr
.
s6_addr
,
addr6_2
,
sizeof
(
addr6_2
));
memcpy
(
sockaddr6
.
sin6_addr
.
s6_addr
,
addr6_2
,
sizeof
(
addr6_2
));
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr6
,
sizeof
(
sockaddr6
),
NULL
,
address6
,
&
len
);
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr6
,
sizeof
(
sockaddr6
),
NULL
,
address6
,
&
len
);
todo_wine
{
ok
(
!
ret
,
"WSAAddressToStringA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
ok
(
!
ret
,
"WSAAddressToStringA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
ok
(
!
strcmp
(
address6
,
expect6_2
),
"Expected: %s, got: %s
\n
"
,
expect6_2
,
address6
);
ok
(
!
strcmp
(
address6
,
expect6_2
),
"Expected: %s, got: %s
\n
"
,
expect6_2
,
address6
);
ok
(
len
==
sizeof
(
expect6_2
),
"Got size %d
\n
"
,
len
);
ok
(
len
==
sizeof
(
expect6_2
),
"Got size %d
\n
"
,
len
);
}
/* Test IPv6 address and port number */
/* Test IPv6 address and port number */
len
=
sizeof
(
address6
);
len
=
sizeof
(
address6
);
...
@@ -1403,9 +1397,9 @@ static void test_WSAAddressToStringA(void)
...
@@ -1403,9 +1397,9 @@ static void test_WSAAddressToStringA(void)
memcpy
(
sockaddr6
.
sin6_addr
.
s6_addr
,
addr6_3
,
sizeof
(
addr6_3
));
memcpy
(
sockaddr6
.
sin6_addr
.
s6_addr
,
addr6_3
,
sizeof
(
addr6_3
));
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr6
,
sizeof
(
sockaddr6
),
NULL
,
address6
,
&
len
);
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr6
,
sizeof
(
sockaddr6
),
NULL
,
address6
,
&
len
);
ok
(
!
ret
,
"WSAAddressToStringA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
todo_wine
todo_wine
{
{
ok
(
!
ret
,
"WSAAddressToStringA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
ok
(
!
strcmp
(
address6
,
expect6_3
),
"Expected: %s, got: %s
\n
"
,
expect6_3
,
address6
);
ok
(
!
strcmp
(
address6
,
expect6_3
),
"Expected: %s, got: %s
\n
"
,
expect6_3
,
address6
);
ok
(
len
==
sizeof
(
expect6_3
),
"Got size %d
\n
"
,
len
);
ok
(
len
==
sizeof
(
expect6_3
),
"Got size %d
\n
"
,
len
);
}
}
...
@@ -1419,9 +1413,9 @@ static void test_WSAAddressToStringA(void)
...
@@ -1419,9 +1413,9 @@ static void test_WSAAddressToStringA(void)
memcpy
(
sockaddr6
.
sin6_addr
.
s6_addr
,
addr6_3
,
sizeof
(
addr6_3
));
memcpy
(
sockaddr6
.
sin6_addr
.
s6_addr
,
addr6_3
,
sizeof
(
addr6_3
));
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr6
,
sizeof
(
sockaddr6
),
NULL
,
address6
,
&
len
);
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr6
,
sizeof
(
sockaddr6
),
NULL
,
address6
,
&
len
);
ok
(
!
ret
,
"WSAAddressToStringA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
todo_wine
todo_wine
{
{
ok
(
!
ret
,
"WSAAddressToStringA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
ok
(
!
strcmp
(
address6
,
expect6_3_2
),
"Expected: %s, got: %s
\n
"
,
expect6_3_2
,
address6
);
ok
(
!
strcmp
(
address6
,
expect6_3_2
),
"Expected: %s, got: %s
\n
"
,
expect6_3_2
,
address6
);
ok
(
len
==
sizeof
(
expect6_3_2
),
"Got size %d
\n
"
,
len
);
ok
(
len
==
sizeof
(
expect6_3_2
),
"Got size %d
\n
"
,
len
);
}
}
...
@@ -1435,9 +1429,9 @@ static void test_WSAAddressToStringA(void)
...
@@ -1435,9 +1429,9 @@ static void test_WSAAddressToStringA(void)
memcpy
(
sockaddr6
.
sin6_addr
.
s6_addr
,
addr6_3
,
sizeof
(
addr6_3
));
memcpy
(
sockaddr6
.
sin6_addr
.
s6_addr
,
addr6_3
,
sizeof
(
addr6_3
));
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr6
,
sizeof
(
sockaddr6
),
NULL
,
address6
,
&
len
);
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr6
,
sizeof
(
sockaddr6
),
NULL
,
address6
,
&
len
);
ok
(
!
ret
,
"WSAAddressToStringA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
todo_wine
todo_wine
{
{
ok
(
!
ret
,
"WSAAddressToStringA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
ok
(
!
strcmp
(
address6
,
expect6_3_3
),
"Expected: %s, got: %s
\n
"
,
expect6_3_3
,
address6
);
ok
(
!
strcmp
(
address6
,
expect6_3_3
),
"Expected: %s, got: %s
\n
"
,
expect6_3_3
,
address6
);
ok
(
len
==
sizeof
(
expect6_3_3
),
"Got size %d
\n
"
,
len
);
ok
(
len
==
sizeof
(
expect6_3_3
),
"Got size %d
\n
"
,
len
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment