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
757ea81a
Commit
757ea81a
authored
Sep 05, 2023
by
Hans Leidekker
Committed by
Alexandre Julliard
Sep 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ipconfig: Call GetAdaptersAddresses() in a loop.
parent
3f9f4a4a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
30 deletions
+24
-30
ipconfig.c
programs/ipconfig/ipconfig.c
+24
-30
No files found.
programs/ipconfig/ipconfig.c
View file @
757ea81a
...
...
@@ -138,23 +138,32 @@ static BOOL socket_address_to_string(WCHAR *buf, DWORD len, SOCKET_ADDRESS *addr
buf
,
&
len
)
==
0
;
}
static
void
print_basic_information
(
void
)
static
IP_ADAPTER_ADDRESSES
*
get_adapters
(
void
)
{
IP_ADAPTER_ADDRESSES
*
adapters
;
ULONG
out
=
0
;
ULONG
err
,
size
=
4096
;
IP_ADAPTER_ADDRESSES
*
tmp
,
*
ret
;
if
(
GetAdaptersAddresses
(
AF_UNSPEC
,
GAA_FLAG_INCLUDE_GATEWAYS
,
NULL
,
NULL
,
&
out
)
==
ERROR_BUFFER_OVERFLOW
)
if
(
!
(
ret
=
malloc
(
size
)))
return
NULL
;
err
=
GetAdaptersAddresses
(
AF_UNSPEC
,
GAA_FLAG_INCLUDE_GATEWAYS
,
NULL
,
ret
,
&
size
);
while
(
err
==
ERROR_BUFFER_OVERFLOW
)
{
adapters
=
malloc
(
out
);
if
(
!
(
tmp
=
realloc
(
ret
,
size
)))
break
;
ret
=
tmp
;
err
=
GetAdaptersAddresses
(
AF_UNSPEC
,
GAA_FLAG_INCLUDE_GATEWAYS
,
NULL
,
ret
,
&
size
);
}
if
(
err
==
ERROR_SUCCESS
)
return
ret
;
free
(
ret
);
return
NULL
;
}
static
void
print_basic_information
(
void
)
{
IP_ADAPTER_ADDRESSES
*
adapters
,
*
p
;
adapters
=
get_adapters
();
if
(
!
adapters
)
exit
(
1
);
if
(
GetAdaptersAddresses
(
AF_UNSPEC
,
GAA_FLAG_INCLUDE_GATEWAYS
,
NULL
,
adapters
,
&
out
)
==
ERROR_SUCCESS
)
{
IP_ADAPTER_ADDRESSES
*
p
;
for
(
p
=
adapters
;
p
;
p
=
p
->
Next
)
{
IP_ADAPTER_UNICAST_ADDRESS
*
addr
;
...
...
@@ -192,10 +201,7 @@ static void print_basic_information(void)
ipconfig_printfW
(
L"
\n
"
);
}
}
free
(
adapters
);
}
}
static
const
WCHAR
*
nodetype_to_string
(
DWORD
type
)
...
...
@@ -260,8 +266,8 @@ static const WCHAR *boolean_to_string(int value)
static
void
print_full_information
(
void
)
{
FIXED_INFO
*
info
;
IP_ADAPTER_ADDRESSES
*
adapters
;
ULONG
out
=
0
;
IP_ADAPTER_ADDRESSES
*
adapters
,
*
p
;
ULONG
out
;
if
(
GetNetworkParams
(
NULL
,
&
out
)
==
ERROR_BUFFER_OVERFLOW
)
{
...
...
@@ -291,24 +297,15 @@ static void print_full_information(void)
free
(
info
);
}
if
(
GetAdaptersAddresses
(
AF_UNSPEC
,
GAA_FLAG_INCLUDE_GATEWAYS
,
NULL
,
NULL
,
&
out
)
==
ERROR_BUFFER_OVERFLOW
)
{
adapters
=
malloc
(
out
);
adapters
=
get_adapters
();
if
(
!
adapters
)
exit
(
1
);
if
(
GetAdaptersAddresses
(
AF_UNSPEC
,
GAA_FLAG_INCLUDE_GATEWAYS
,
NULL
,
adapters
,
&
out
)
==
ERROR_SUCCESS
)
{
IP_ADAPTER_ADDRESSES
*
p
;
for
(
p
=
adapters
;
p
;
p
=
p
->
Next
)
{
IP_ADAPTER_UNICAST_ADDRESS
*
addr
;
WCHAR
physaddr_buf
[
3
*
MAX_ADAPTER_ADDRESS_LENGTH
];
WCHAR
physaddr_buf
[
3
*
MAX_ADAPTER_ADDRESS_LENGTH
],
addr_buf
[
54
];
IP_ADAPTER_GATEWAY_ADDRESS_LH
*
gateway
;
WCHAR
addr_buf
[
54
];
ipconfig_message_printfW
(
STRING_ADAPTER_FRIENDLY
,
iftype_to_string
(
p
->
IfType
),
p
->
FriendlyName
);
ipconfig_printfW
(
L"
\n
"
);
...
...
@@ -346,10 +343,7 @@ static void print_full_information(void)
ipconfig_printfW
(
L"
\n
"
);
}
}
free
(
adapters
);
}
}
int
__cdecl
wmain
(
int
argc
,
WCHAR
*
argv
[])
...
...
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