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
986732a5
Commit
986732a5
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: Call GetAdaptersAddresses() in a loop.
parent
22c293bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
62 deletions
+27
-62
network.c
dlls/wsdapi/network.c
+27
-62
No files found.
dlls/wsdapi/network.c
View file @
986732a5
...
...
@@ -97,44 +97,37 @@ static DWORD WINAPI sending_thread(LPVOID lpParam)
return
0
;
}
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
send_udp_multicast_of_type
(
char
*
data
,
int
length
,
int
max_initial_delay
,
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
;
sending_thread_params
*
send_params
;
ULONG
bufferSize
=
0
;
LPSOCKADDR
sockaddr
;
BOOL
ret
=
FALSE
;
HANDLE
thread_handle
;
const
char
ttl
=
8
;
ULONG
retval
;
SOCKET
s
;
/* Get size of buffer for adapters */
retval
=
GetAdaptersAddresses
(
family
,
0
,
NULL
,
NULL
,
&
bufferSize
);
if
(
retval
!=
ERROR_BUFFER_OVERFLOW
)
{
WARN
(
"GetAdaptorsAddresses failed with error %08lx
\n
"
,
retval
);
goto
cleanup
;
}
adapter_addresses
=
malloc
(
bufferSize
);
if
(
adapter_addresses
==
NULL
)
{
WARN
(
"Out of memory allocating space for adapter information
\n
"
);
goto
cleanup
;
}
/* Get list of adapters */
retval
=
GetAdaptersAddresses
(
family
,
0
,
NULL
,
adapter_addresses
,
&
bufferSize
);
if
(
retval
!=
ERROR_SUCCESS
)
{
WARN
(
"GetAdaptorsAddresses failed with error %08lx
\n
"
,
retval
);
goto
cleanup
;
}
adapter_addresses
=
get_adapters
(
family
);
if
(
!
adapter_addresses
)
return
FALSE
;
for
(
adapter_addr
=
adapter_addresses
;
adapter_addr
!=
NULL
;
adapter_addr
=
adapter_addr
->
Next
)
{
...
...
@@ -211,12 +204,8 @@ static BOOL send_udp_multicast_of_type(char *data, int length, int max_initial_d
CloseHandle
(
thread_handle
);
}
ret
=
TRUE
;
cleanup:
free
(
adapter_addresses
);
return
ret
;
return
TRUE
;
}
BOOL
send_udp_multicast
(
IWSDiscoveryPublisherImpl
*
impl
,
char
*
data
,
int
length
,
int
max_initial_delay
)
...
...
@@ -504,36 +493,12 @@ cleanup:
static
BOOL
start_listening_on_all_addresses
(
IWSDiscoveryPublisherImpl
*
impl
,
ULONG
family
)
{
IP_ADAPTER_ADDRESSES
*
adapter_addresses
=
NULL
,
*
adapter_address
;
IP_ADAPTER_ADDRESSES
*
adapter_addresses
,
*
adapter_address
;
int
valid_listeners
=
0
;
ULONG
bufferSize
=
0
;
ULONG
ret
;
ret
=
GetAdaptersAddresses
(
family
,
0
,
NULL
,
NULL
,
&
bufferSize
);
/* family should be AF_INET or AF_INET6 */
if
(
ret
!=
ERROR_BUFFER_OVERFLOW
)
{
WARN
(
"GetAdaptorsAddresses failed with error %08lx
\n
"
,
ret
);
adapter_addresses
=
get_adapters
(
family
);
/* family should be AF_INET or AF_INET6 */
if
(
!
adapter_addresses
)
return
FALSE
;
}
/* Get size of buffer for adapters */
adapter_addresses
=
malloc
(
bufferSize
);
if
(
adapter_addresses
==
NULL
)
{
WARN
(
"Out of memory allocating space for adapter information
\n
"
);
return
FALSE
;
}
/* Get list of adapters */
ret
=
GetAdaptersAddresses
(
family
,
0
,
NULL
,
adapter_addresses
,
&
bufferSize
);
if
(
ret
!=
ERROR_SUCCESS
)
{
WARN
(
"GetAdaptorsAddresses failed with error %08lx
\n
"
,
ret
);
goto
cleanup
;
}
for
(
adapter_address
=
adapter_addresses
;
adapter_address
!=
NULL
;
adapter_address
=
adapter_address
->
Next
)
{
...
...
@@ -554,7 +519,7 @@ static BOOL start_listening_on_all_addresses(IWSDiscoveryPublisherImpl *impl, UL
cleanup:
free
(
adapter_addresses
);
return
(
ret
==
ERROR_SUCCESS
)
&&
(
valid_listeners
>
0
)
;
return
valid_listeners
>
0
;
}
HRESULT
send_udp_unicast
(
char
*
data
,
int
length
,
IWSDUdpAddress
*
remote_addr
,
int
max_initial_delay
)
...
...
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