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
074069b8
Commit
074069b8
authored
Sep 05, 2023
by
Hans Leidekker
Committed by
Alexandre Julliard
Sep 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wsdapi/tests: Call GetAdaptersAddresses() in a loop.
parent
1b83a376
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
31 deletions
+25
-31
discovery.c
dlls/wsdapi/tests/discovery.c
+25
-31
No files found.
dlls/wsdapi/tests/discovery.c
View file @
074069b8
...
@@ -331,26 +331,34 @@ cleanup_addresses:
...
@@ -331,26 +331,34 @@ cleanup_addresses:
freeaddrinfo
(
interfaceAddr
);
freeaddrinfo
(
interfaceAddr
);
}
}
static
IP_ADAPTER_ADDRESSES
*
get_adapters
(
ULONG
family
)
{
ULONG
err
,
size
=
4096
;
IP_ADAPTER_ADDRESSES
*
tmp
,
*
ret
;
if
(
!
(
ret
=
malloc
(
size
)))
return
NULL
;
err
=
GetAdaptersAddresses
(
family
,
0
,
NULL
,
ret
,
&
size
);
while
(
err
==
ERROR_BUFFER_OVERFLOW
)
{
if
(
!
(
tmp
=
realloc
(
ret
,
size
)))
break
;
ret
=
tmp
;
err
=
GetAdaptersAddresses
(
family
,
0
,
NULL
,
ret
,
&
size
);
}
if
(
err
==
ERROR_SUCCESS
)
return
ret
;
free
(
ret
);
return
NULL
;
}
static
BOOL
start_listening_on_all_addresses
(
messageStorage
*
msgStorage
,
ULONG
family
)
static
BOOL
start_listening_on_all_addresses
(
messageStorage
*
msgStorage
,
ULONG
family
)
{
{
IP_ADAPTER_ADDRESSES
*
adapterAddresses
=
NULL
,
*
adapterAddress
;
IP_ADAPTER_ADDRESSES
*
adapterAddresses
,
*
adapterAddress
;
ULONG
bufferSize
=
0
;
LPSOCKADDR
sockaddr
;
LPSOCKADDR
sockaddr
;
DWORD
addressLength
;
DWORD
addressLength
;
char
address
[
64
];
char
address
[
64
];
BOOL
ret
=
FALSE
;
BOOL
ret
=
FALSE
;
ULONG
retVal
;
retVal
=
GetAdaptersAddresses
(
family
,
0
,
NULL
,
NULL
,
&
bufferSize
);
/* family should be AF_INET or AF_INET6 */
if
(
retVal
!=
ERROR_BUFFER_OVERFLOW
)
goto
cleanup
;
/* Get size of buffer for adapters */
adapterAddresses
=
malloc
(
bufferSize
);
if
(
adapterAddresses
==
NULL
)
goto
cleanup
;
/* Get list of adapters */
adapterAddresses
=
get_adapters
(
family
);
/* family should be AF_INET or AF_INET6 */
retVal
=
GetAdaptersAddresses
(
family
,
0
,
NULL
,
adapterAddresses
,
&
bufferSize
);
if
(
!
adapterAddresses
)
return
FALSE
;
if
(
retVal
!=
ERROR_SUCCESS
)
goto
cleanup
;
for
(
adapterAddress
=
adapterAddresses
;
adapterAddress
!=
NULL
;
adapterAddress
=
adapterAddress
->
Next
)
for
(
adapterAddress
=
adapterAddresses
;
adapterAddress
!=
NULL
;
adapterAddress
=
adapterAddress
->
Next
)
{
{
...
@@ -378,14 +386,11 @@ cleanup:
...
@@ -378,14 +386,11 @@ cleanup:
static
BOOL
send_udp_multicast_of_type
(
const
char
*
data
,
int
length
,
ULONG
family
)
static
BOOL
send_udp_multicast_of_type
(
const
char
*
data
,
int
length
,
ULONG
family
)
{
{
IP_ADAPTER_ADDRESSES
*
adapter_addresses
=
NULL
,
*
adapter_addr
;
IP_ADAPTER_ADDRESSES
*
adapter_addresses
,
*
adapter_addr
;
static
const
struct
in6_addr
i_addr_zero
;
static
const
struct
in6_addr
i_addr_zero
;
struct
addrinfo
*
multi_address
;
struct
addrinfo
*
multi_address
;
ULONG
bufferSize
=
0
;
LPSOCKADDR
sockaddr
;
LPSOCKADDR
sockaddr
;
BOOL
ret
=
FALSE
;
const
char
ttl
=
8
;
const
char
ttl
=
8
;
ULONG
retval
;
SOCKET
s
;
SOCKET
s
;
/* Resolve the multicast address */
/* Resolve the multicast address */
...
@@ -397,16 +402,8 @@ static BOOL send_udp_multicast_of_type(const char *data, int length, ULONG famil
...
@@ -397,16 +402,8 @@ static BOOL send_udp_multicast_of_type(const char *data, int length, ULONG famil
if
(
multi_address
==
NULL
)
if
(
multi_address
==
NULL
)
return
FALSE
;
return
FALSE
;
/* Get size of buffer for adapters */
adapter_addresses
=
get_adapters
(
family
);
retval
=
GetAdaptersAddresses
(
family
,
0
,
NULL
,
NULL
,
&
bufferSize
);
if
(
!
adapter_addresses
)
return
FALSE
;
if
(
retval
!=
ERROR_BUFFER_OVERFLOW
)
goto
cleanup
;
adapter_addresses
=
malloc
(
bufferSize
);
if
(
adapter_addresses
==
NULL
)
goto
cleanup
;
/* Get list of adapters */
retval
=
GetAdaptersAddresses
(
family
,
0
,
NULL
,
adapter_addresses
,
&
bufferSize
);
if
(
retval
!=
ERROR_SUCCESS
)
goto
cleanup
;
for
(
adapter_addr
=
adapter_addresses
;
adapter_addr
!=
NULL
;
adapter_addr
=
adapter_addr
->
Next
)
for
(
adapter_addr
=
adapter_addresses
;
adapter_addr
!=
NULL
;
adapter_addr
=
adapter_addr
->
Next
)
{
{
...
@@ -433,12 +430,9 @@ static BOOL send_udp_multicast_of_type(const char *data, int length, ULONG famil
...
@@ -433,12 +430,9 @@ static BOOL send_udp_multicast_of_type(const char *data, int length, ULONG famil
closesocket
(
s
);
closesocket
(
s
);
}
}
ret
=
TRUE
;
cleanup:
freeaddrinfo
(
multi_address
);
freeaddrinfo
(
multi_address
);
free
(
adapter_addresses
);
free
(
adapter_addresses
);
return
ret
;
return
TRUE
;
}
}
typedef
struct
IWSDiscoveryPublisherNotifyImpl
{
typedef
struct
IWSDiscoveryPublisherNotifyImpl
{
...
...
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