Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
334875f3
Commit
334875f3
authored
Sep 13, 2013
by
Huw Davies
Committed by
Alexandre Julliard
Sep 13, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iphlpapi: Move dns server enumeration to a single function.
parent
01d5632e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
29 deletions
+47
-29
iphlpapi_main.c
dlls/iphlpapi/iphlpapi_main.c
+47
-29
No files found.
dlls/iphlpapi/iphlpapi_main.c
View file @
334875f3
...
...
@@ -933,45 +933,59 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
return
ERROR_SUCCESS
;
}
static
int
get_dns_servers
(
SOCKADDR_STORAGE
*
servers
,
int
num
)
{
int
i
;
SOCKADDR_STORAGE
*
addr
;
initialise_resolver
();
/* AF_INET6 not yet enumerated */
if
(
!
servers
||
!
num
)
{
num
=
_res
.
nscount
;
return
num
;
}
for
(
i
=
0
,
addr
=
servers
;
addr
<
(
servers
+
num
)
&&
i
<
_res
.
nscount
;
i
++
)
{
*
(
struct
sockaddr_in
*
)
addr
=
_res
.
nsaddr_list
[
i
];
memset
(
(
char
*
)
addr
+
sizeof
(
struct
sockaddr_in
),
0
,
sizeof
(
SOCKADDR_STORAGE
)
-
sizeof
(
struct
sockaddr_in
)
);
addr
++
;
}
return
addr
-
servers
;
}
static
ULONG
get_dns_server_addresses
(
PIP_ADAPTER_DNS_SERVER_ADDRESS
address
,
ULONG
*
len
)
{
int
num
=
get_dns_servers
(
NULL
,
0
);
DWORD
size
;
initialise_resolver
();
/* FIXME: no support for IPv6 DNS server addresses. Doing so requires
* sizeof SOCKADDR_STORAGE instead, and using _res._u._ext.nsaddrs when
* available.
*/
size
=
_res
.
nscount
*
(
sizeof
(
IP_ADAPTER_DNS_SERVER_ADDRESS
)
+
sizeof
(
SOCKADDR
));
size
=
num
*
(
sizeof
(
IP_ADAPTER_DNS_SERVER_ADDRESS
)
+
sizeof
(
SOCKADDR_STORAGE
));
if
(
!
address
||
*
len
<
size
)
{
*
len
=
size
;
return
ERROR_BUFFER_OVERFLOW
;
}
*
len
=
size
;
if
(
_res
.
nscount
>
0
)
if
(
num
>
0
)
{
PIP_ADAPTER_DNS_SERVER_ADDRESS
addr
;
PIP_ADAPTER_DNS_SERVER_ADDRESS
addr
=
address
;
SOCKADDR_STORAGE
*
sock_addrs
=
(
SOCKADDR_STORAGE
*
)(
address
+
num
);
int
i
;
for
(
i
=
0
,
addr
=
address
;
i
<
_res
.
nscount
&&
addr
;
i
++
,
addr
=
addr
->
Next
)
get_dns_servers
(
sock_addrs
,
num
);
for
(
i
=
0
;
i
<
num
;
i
++
,
addr
=
addr
->
Next
)
{
SOCKADDR_IN
*
sin
;
addr
->
Address
.
iSockaddrLength
=
sizeof
(
SOCKADDR
);
addr
->
Address
.
lpSockaddr
=
(
LPSOCKADDR
)((
PBYTE
)
addr
+
sizeof
(
IP_ADAPTER_DNS_SERVER_ADDRESS
));
sin
=
(
SOCKADDR_IN
*
)
addr
->
Address
.
lpSockaddr
;
sin
->
sin_family
=
WS_AF_INET
;
sin
->
sin_port
=
_res
.
nsaddr_list
[
i
].
sin_port
;
memcpy
(
&
sin
->
sin_addr
,
&
_res
.
nsaddr_list
[
i
].
sin_addr
,
sizeof
(
sin
->
sin_addr
));
if
(
i
==
_res
.
nscount
-
1
)
addr
->
u
.
s
.
Length
=
sizeof
(
*
addr
);
addr
->
Address
.
iSockaddrLength
=
sizeof
(
SOCKADDR_IN
);
addr
->
Address
.
lpSockaddr
=
(
SOCKADDR
*
)(
sock_addrs
+
i
);
if
(
i
==
num
-
1
)
addr
->
Next
=
NULL
;
else
addr
->
Next
=
(
PIP_ADAPTER_DNS_SERVER_ADDRESS
)((
PBYTE
)
addr
+
sizeof
(
IP_ADAPTER_DNS_SERVER_ADDRESS
)
+
sizeof
(
SOCKADDR
));
addr
->
Next
=
addr
+
1
;
}
}
return
ERROR_SUCCESS
;
...
...
@@ -1623,28 +1637,32 @@ static DWORD get_dns_server_list(PIP_ADDR_STRING list,
PIP_ADDR_STRING
firstDynamic
,
DWORD
*
len
)
{
DWORD
size
;
int
num
=
get_dns_servers
(
NULL
,
0
);
initialise_resolver
();
size
=
_res
.
nscount
*
sizeof
(
IP_ADDR_STRING
);
size
=
num
*
sizeof
(
IP_ADDR_STRING
);
if
(
!
list
||
*
len
<
size
)
{
*
len
=
size
;
return
ERROR_BUFFER_OVERFLOW
;
}
*
len
=
size
;
if
(
_res
.
nscount
>
0
)
{
if
(
num
>
0
)
{
PIP_ADDR_STRING
ptr
;
int
i
;
SOCKADDR_STORAGE
*
addr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
num
*
sizeof
(
SOCKADDR_STORAGE
)
);
get_dns_servers
(
addr
,
num
);
for
(
i
=
0
,
ptr
=
list
;
i
<
_res
.
nscount
&&
ptr
;
i
++
,
ptr
=
ptr
->
Next
)
{
toIPAddressString
(
_res
.
nsaddr_list
[
i
].
sin_addr
.
s_addr
,
for
(
i
=
0
,
ptr
=
list
;
i
<
num
;
i
++
,
ptr
=
ptr
->
Next
)
{
toIPAddressString
(((
struct
sockaddr_in
*
)(
addr
+
i
))
->
sin_addr
.
s_addr
,
ptr
->
IpAddress
.
String
);
if
(
i
==
_res
.
nscount
-
1
)
if
(
i
==
num
-
1
)
ptr
->
Next
=
NULL
;
else
if
(
i
==
0
)
ptr
->
Next
=
firstDynamic
;
else
ptr
->
Next
=
(
PIP_ADDR_STRING
)((
PBYTE
)
ptr
+
sizeof
(
IP_ADDR_STRING
));
}
HeapFree
(
GetProcessHeap
(),
0
,
addr
);
}
return
ERROR_SUCCESS
;
}
...
...
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