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
93323bcf
Commit
93323bcf
authored
Jun 13, 2017
by
Owen Rudge
Committed by
Alexandre Julliard
Jun 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32/tests: Test IP address conversion in getaddrinfo.
Signed-off-by:
Bruno Jesus
<
bjesus@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
accf5ef5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
1 deletion
+107
-1
sock.c
dlls/ws2_32/tests/sock.c
+107
-1
No files found.
dlls/ws2_32/tests/sock.c
View file @
93323bcf
...
...
@@ -7335,11 +7335,35 @@ static void test_GetAddrInfoW(void)
ok
(
result2
==
NULL
,
"got %p
\n
"
,
result2
);
}
static
void
verify_ipv6_addrinfo
(
ADDRINFOA
*
result
,
const
char
*
expectedIp
)
{
SOCKADDR_IN6
*
sockaddr6
;
char
ipBuffer
[
256
];
const
char
*
ret
;
ok
(
result
->
ai_family
==
AF_INET6
,
"ai_family == %d
\n
"
,
result
->
ai_family
);
ok
(
result
->
ai_addrlen
>=
sizeof
(
struct
sockaddr_in6
),
"ai_addrlen == %d
\n
"
,
(
int
)
result
->
ai_addrlen
);
ok
(
result
->
ai_addr
!=
NULL
,
"ai_addr == NULL
\n
"
);
if
(
result
->
ai_addr
!=
NULL
)
{
sockaddr6
=
(
SOCKADDR_IN6
*
)
result
->
ai_addr
;
ok
(
sockaddr6
->
sin6_family
==
AF_INET6
,
"ai_addr->sin6_family == %d
\n
"
,
sockaddr6
->
sin6_family
);
ok
(
sockaddr6
->
sin6_port
==
0
,
"ai_addr->sin6_port == %d
\n
"
,
sockaddr6
->
sin6_port
);
ZeroMemory
(
ipBuffer
,
sizeof
(
ipBuffer
));
ret
=
pInetNtop
(
AF_INET6
,
&
sockaddr6
->
sin6_addr
,
ipBuffer
,
sizeof
(
ipBuffer
));
ok
(
ret
!=
NULL
,
"inet_ntop failed (%d)
\n
"
,
WSAGetLastError
());
ok
(
strcmp
(
ipBuffer
,
expectedIp
)
==
0
,
"ai_addr->sin6_addr == '%s' (expected '%s')
\n
"
,
ipBuffer
,
expectedIp
);
}
}
static
void
test_getaddrinfo
(
void
)
{
int
i
,
ret
;
ADDRINFOA
*
result
,
*
result2
,
*
p
,
hint
;
CHAR
name
[
256
];
SOCKADDR_IN
*
sockaddr
;
CHAR
name
[
256
],
*
ip
;
DWORD
size
=
sizeof
(
name
);
if
(
!
pgetaddrinfo
||
!
pfreeaddrinfo
)
...
...
@@ -7469,6 +7493,88 @@ static void test_getaddrinfo(void)
ok
(
WSAGetLastError
()
==
WSAHOST_NOT_FOUND
,
"expected 11001, got %d
\n
"
,
WSAGetLastError
());
ok
(
result
==
NULL
,
"got %p
\n
"
,
result
);
/* Test IPv4 address conversion */
result
=
NULL
;
ret
=
pgetaddrinfo
(
"192.168.1.253"
,
NULL
,
NULL
,
&
result
);
ok
(
!
ret
,
"getaddrinfo failed with %d
\n
"
,
ret
);
ok
(
result
->
ai_family
==
AF_INET
,
"ai_family == %d
\n
"
,
result
->
ai_family
);
ok
(
result
->
ai_addrlen
>=
sizeof
(
struct
sockaddr_in
),
"ai_addrlen == %d
\n
"
,
(
int
)
result
->
ai_addrlen
);
ok
(
result
->
ai_addr
!=
NULL
,
"ai_addr == NULL
\n
"
);
sockaddr
=
(
SOCKADDR_IN
*
)
result
->
ai_addr
;
ok
(
sockaddr
->
sin_family
==
AF_INET
,
"ai_addr->sin_family == %d
\n
"
,
sockaddr
->
sin_family
);
ok
(
sockaddr
->
sin_port
==
0
,
"ai_addr->sin_port == %d
\n
"
,
sockaddr
->
sin_port
);
ip
=
inet_ntoa
(
sockaddr
->
sin_addr
);
ok
(
strcmp
(
ip
,
"192.168.1.253"
)
==
0
,
"sockaddr->ai_addr == '%s'
\n
"
,
ip
);
pfreeaddrinfo
(
result
);
/* Test IPv4 address conversion with port */
result
=
NULL
;
hint
.
ai_flags
=
AI_NUMERICHOST
;
ret
=
pgetaddrinfo
(
"192.168.1.253:1024"
,
NULL
,
&
hint
,
&
result
);
hint
.
ai_flags
=
0
;
ok
(
ret
==
WSAHOST_NOT_FOUND
,
"getaddrinfo returned unexpected result: %d
\n
"
,
ret
);
ok
(
result
==
NULL
,
"expected NULL, got %p
\n
"
,
result
);
/* Test IPv6 address conversion */
result
=
NULL
;
SetLastError
(
0xdeadbeef
);
ret
=
pgetaddrinfo
(
"2a00:2039:dead:beef:cafe::6666"
,
NULL
,
NULL
,
&
result
);
if
(
result
!=
NULL
)
{
ok
(
!
ret
,
"getaddrinfo failed with %d
\n
"
,
ret
);
verify_ipv6_addrinfo
(
result
,
"2a00:2039:dead:beef:cafe::6666"
);
pfreeaddrinfo
(
result
);
/* Test IPv6 address conversion with brackets */
result
=
NULL
;
ret
=
pgetaddrinfo
(
"[beef::cafe]"
,
NULL
,
NULL
,
&
result
);
ok
(
!
ret
,
"getaddrinfo failed with %d
\n
"
,
ret
);
verify_ipv6_addrinfo
(
result
,
"beef::cafe"
);
pfreeaddrinfo
(
result
);
/* Test IPv6 address conversion with brackets and hints */
memset
(
&
hint
,
0
,
sizeof
(
ADDRINFOA
));
hint
.
ai_flags
=
AI_NUMERICHOST
;
hint
.
ai_family
=
AF_INET6
;
result
=
NULL
;
ret
=
pgetaddrinfo
(
"[beef::cafe]"
,
NULL
,
&
hint
,
&
result
);
ok
(
!
ret
,
"getaddrinfo failed with %d
\n
"
,
ret
);
verify_ipv6_addrinfo
(
result
,
"beef::cafe"
);
pfreeaddrinfo
(
result
);
memset
(
&
hint
,
0
,
sizeof
(
ADDRINFOA
));
hint
.
ai_flags
=
AI_NUMERICHOST
;
hint
.
ai_family
=
AF_INET
;
result
=
NULL
;
ret
=
pgetaddrinfo
(
"[beef::cafe]"
,
NULL
,
&
hint
,
&
result
);
ok
(
ret
==
WSAHOST_NOT_FOUND
,
"getaddrinfo failed with %d
\n
"
,
ret
);
/* Test IPv6 address conversion with brackets and port */
result
=
NULL
;
ret
=
pgetaddrinfo
(
"[beef::cafe]:10239"
,
NULL
,
NULL
,
&
result
);
ok
(
!
ret
,
"getaddrinfo failed with %d
\n
"
,
ret
);
verify_ipv6_addrinfo
(
result
,
"beef::cafe"
);
pfreeaddrinfo
(
result
);
/* Test IPv6 address conversion with unmatched brackets */
result
=
NULL
;
hint
.
ai_flags
=
AI_NUMERICHOST
;
ret
=
pgetaddrinfo
(
"[beef::cafe"
,
NULL
,
&
hint
,
&
result
);
ok
(
ret
==
WSAHOST_NOT_FOUND
,
"getaddrinfo failed with %d
\n
"
,
ret
);
ret
=
pgetaddrinfo
(
"beef::cafe]"
,
NULL
,
&
hint
,
&
result
);
ok
(
ret
==
WSAHOST_NOT_FOUND
,
"getaddrinfo failed with %d
\n
"
,
ret
);
}
else
{
ok
(
ret
==
WSAHOST_NOT_FOUND
,
"getaddrinfo failed with %d
\n
"
,
ret
);
win_skip
(
"getaddrinfo does not support IPV6
\n
"
);
}
hint
.
ai_flags
=
0
;
for
(
i
=
0
;
i
<
(
sizeof
(
hinttests
)
/
sizeof
(
hinttests
[
0
]));
i
++
)
{
hint
.
ai_family
=
hinttests
[
i
].
family
;
...
...
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