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
134bf22b
Commit
134bf22b
authored
Jun 19, 2016
by
Bruno Jesus
Committed by
Alexandre Julliard
Jun 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Ensure default route IP addresses are returned first in gethostbyname.
Signed-off-by:
Bruno Jesus
<
00cpxxx@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
7a9b36ca
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
socket.c
dlls/ws2_32/socket.c
+16
-5
sock.c
dlls/ws2_32/tests/sock.c
+0
-1
No files found.
dlls/ws2_32/socket.c
View file @
134bf22b
...
...
@@ -596,7 +596,7 @@ struct per_thread_data
struct
route
{
struct
in_addr
addr
;
IF_INDEX
interface
;
DWORD
metric
;
DWORD
metric
,
default_route
;
};
static
INT
num_startup
;
/* reference counter */
...
...
@@ -6044,7 +6044,14 @@ struct WS_hostent* WINAPI WS_gethostbyaddr(const char *addr, int len, int type)
*/
static
int
WS_compare_routes_by_metric_asc
(
const
void
*
left
,
const
void
*
right
)
{
return
((
const
struct
route
*
)
left
)
->
metric
-
((
const
struct
route
*
)
right
)
->
metric
;
const
struct
route
*
a
=
left
,
*
b
=
right
;
if
(
a
->
default_route
&&
b
->
default_route
)
return
a
->
default_route
-
b
->
default_route
;
if
(
a
->
default_route
&&
!
b
->
default_route
)
return
-
1
;
if
(
b
->
default_route
&&
!
a
->
default_route
)
return
1
;
return
a
->
metric
-
b
->
metric
;
}
/***********************************************************************
...
...
@@ -6061,7 +6068,7 @@ static int WS_compare_routes_by_metric_asc(const void *left, const void *right)
*/
static
struct
WS_hostent
*
WS_get_local_ips
(
char
*
hostname
)
{
int
numroutes
=
0
,
i
,
j
;
int
numroutes
=
0
,
i
,
j
,
default_routes
=
0
;
DWORD
n
;
PIP_ADAPTER_INFO
adapters
=
NULL
,
k
;
struct
WS_hostent
*
hostlist
=
NULL
;
...
...
@@ -6088,10 +6095,13 @@ static struct WS_hostent* WS_get_local_ips( char *hostname )
for
(
n
=
0
;
n
<
routes
->
dwNumEntries
;
n
++
)
{
IF_INDEX
ifindex
;
DWORD
ifmetric
;
DWORD
ifmetric
,
ifdefault
=
0
;
BOOL
exists
=
FALSE
;
if
(
routes
->
table
[
n
].
u1
.
ForwardType
!=
MIB_IPROUTE_TYPE_DIRECT
)
/* Check if this is a default route (there may be more than one) */
if
(
!
routes
->
table
[
n
].
dwForwardDest
)
ifdefault
=
++
default_routes
;
else
if
(
routes
->
table
[
n
].
u1
.
ForwardType
!=
MIB_IPROUTE_TYPE_DIRECT
)
continue
;
ifindex
=
routes
->
table
[
n
].
dwForwardIfIndex
;
ifmetric
=
routes
->
table
[
n
].
dwForwardMetric1
;
...
...
@@ -6112,6 +6122,7 @@ static struct WS_hostent* WS_get_local_ips( char *hostname )
goto
cleanup
;
/* Memory allocation error, fail gracefully */
route_addrs
[
numroutes
].
interface
=
ifindex
;
route_addrs
[
numroutes
].
metric
=
ifmetric
;
route_addrs
[
numroutes
].
default_route
=
ifdefault
;
/* If no IP is found in the next step (for whatever reason)
* then fall back to the magic loopback address.
*/
...
...
dlls/ws2_32/tests/sock.c
View file @
134bf22b
...
...
@@ -4556,7 +4556,6 @@ static void test_gethostbyname(void)
}
}
}
todo_wine
ok
(
found_default
,
"failed to find the first IP from gethostbyname!
\n
"
);
cleanup:
...
...
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