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
0b5a6c70
Commit
0b5a6c70
authored
Jul 08, 2021
by
Huw Davies
Committed by
Alexandre Julliard
Jul 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iphlpapi: Implement IfGetEntry2Ex() on top of nsi.
Signed-off-by:
Huw Davies
<
huw@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f41f028c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
98 deletions
+58
-98
iphlpapi.spec
dlls/iphlpapi/iphlpapi.spec
+1
-0
iphlpapi_main.c
dlls/iphlpapi/iphlpapi_main.c
+37
-55
iphlpapi.c
dlls/iphlpapi/tests/iphlpapi.c
+18
-43
netioapi.h
include/netioapi.h
+2
-0
No files found.
dlls/iphlpapi/iphlpapi.spec
View file @
0b5a6c70
...
...
@@ -89,6 +89,7 @@
@ stub GetIcmpStatsFromStack
@ stdcall GetIfEntry( ptr )
@ stdcall GetIfEntry2( ptr )
@ stdcall GetIfEntry2Ex( long ptr )
@ stub GetIfEntryFromStack
#@ stub GetIfStackTable
@ stdcall GetIfTable( ptr ptr long )
...
...
dlls/iphlpapi/iphlpapi_main.c
View file @
0b5a6c70
...
...
@@ -1778,61 +1778,6 @@ DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
return
ret
;
}
/******************************************************************
* GetIfEntry2 (IPHLPAPI.@)
*/
DWORD
WINAPI
GetIfEntry2
(
MIB_IF_ROW2
*
row2
)
{
DWORD
ret
;
char
buf
[
MAX_ADAPTER_NAME
],
*
name
;
MIB_IFROW
row
;
TRACE
(
"%p
\n
"
,
row2
);
if
(
!
row2
||
(
!
(
name
=
getInterfaceNameByIndex
(
row2
->
InterfaceIndex
,
buf
))
&&
!
(
name
=
getInterfaceNameByIndex
(
row2
->
InterfaceLuid
.
Info
.
NetLuidIndex
,
buf
))))
{
return
ERROR_INVALID_PARAMETER
;
}
if
((
ret
=
getInterfaceEntryByName
(
name
,
&
row
)))
return
ret
;
if
((
ret
=
getInterfaceStatsByName
(
name
,
&
row
)))
return
ret
;
memset
(
row2
,
0
,
sizeof
(
*
row2
)
);
row2
->
InterfaceIndex
=
row
.
dwIndex
;
ConvertInterfaceIndexToLuid
(
row2
->
InterfaceIndex
,
&
row2
->
InterfaceLuid
);
ConvertInterfaceLuidToGuid
(
&
row2
->
InterfaceLuid
,
&
row2
->
InterfaceGuid
);
row2
->
Type
=
row
.
dwType
;
row2
->
Mtu
=
row
.
dwMtu
;
MultiByteToWideChar
(
CP_UNIXCP
,
0
,
(
const
char
*
)
row
.
bDescr
,
-
1
,
row2
->
Description
,
ARRAY_SIZE
(
row2
->
Description
)
);
MultiByteToWideChar
(
CP_UNIXCP
,
0
,
(
const
char
*
)
row
.
bDescr
,
-
1
,
row2
->
Alias
,
ARRAY_SIZE
(
row2
->
Alias
)
);
row2
->
PhysicalAddressLength
=
row
.
dwPhysAddrLen
;
memcpy
(
&
row2
->
PhysicalAddress
,
&
row
.
bPhysAddr
,
row
.
dwPhysAddrLen
);
memcpy
(
&
row2
->
PermanentPhysicalAddress
,
&
row
.
bPhysAddr
,
row
.
dwPhysAddrLen
);
row2
->
OperStatus
=
row
.
dwOperStatus
==
MIB_IF_OPER_STATUS_OPERATIONAL
?
IfOperStatusUp
:
IfOperStatusDown
;
row2
->
AdminStatus
=
NET_IF_ADMIN_STATUS_UP
;
row2
->
MediaConnectState
=
MediaConnectStateConnected
;
row2
->
ConnectionType
=
NET_IF_CONNECTION_DEDICATED
;
row2
->
TransmitLinkSpeed
=
row2
->
ReceiveLinkSpeed
=
row
.
dwSpeed
;
row2
->
AccessType
=
(
row2
->
Type
==
MIB_IF_TYPE_LOOPBACK
)
?
NET_IF_ACCESS_LOOPBACK
:
NET_IF_ACCESS_BROADCAST
;
row2
->
InterfaceAndOperStatusFlags
.
ConnectorPresent
=
row2
->
Type
!=
MIB_IF_TYPE_LOOPBACK
;
row2
->
InterfaceAndOperStatusFlags
.
HardwareInterface
=
row2
->
Type
!=
MIB_IF_TYPE_LOOPBACK
;
/* stats */
row2
->
InOctets
=
row
.
dwInOctets
;
row2
->
InUcastPkts
=
row
.
dwInUcastPkts
;
row2
->
InNUcastPkts
=
row
.
dwInNUcastPkts
;
row2
->
InDiscards
=
row
.
dwInDiscards
;
row2
->
InErrors
=
row
.
dwInErrors
;
row2
->
InUnknownProtos
=
row
.
dwInUnknownProtos
;
row2
->
OutOctets
=
row
.
dwOutOctets
;
row2
->
OutUcastPkts
=
row
.
dwOutUcastPkts
;
row2
->
OutNUcastPkts
=
row
.
dwOutNUcastPkts
;
row2
->
OutDiscards
=
row
.
dwOutDiscards
;
row2
->
OutErrors
=
row
.
dwOutErrors
;
return
NO_ERROR
;
}
static
int
IfTableSorter
(
const
void
*
a
,
const
void
*
b
)
{
int
ret
;
...
...
@@ -1983,6 +1928,43 @@ static void if_row2_fill( MIB_IF_ROW2 *row, struct nsi_ndis_ifinfo_rw *rw, struc
}
/******************************************************************
* GetIfEntry2Ex (IPHLPAPI.@)
*/
DWORD
WINAPI
GetIfEntry2Ex
(
MIB_IF_TABLE_LEVEL
level
,
MIB_IF_ROW2
*
row
)
{
DWORD
err
;
struct
nsi_ndis_ifinfo_rw
rw
;
struct
nsi_ndis_ifinfo_dynamic
dyn
;
struct
nsi_ndis_ifinfo_static
stat
;
TRACE
(
"(%d, %p)
\n
"
,
level
,
row
);
if
(
level
!=
MibIfTableNormal
)
FIXME
(
"level %u not fully supported
\n
"
,
level
);
if
(
!
row
)
return
ERROR_INVALID_PARAMETER
;
if
(
!
row
->
InterfaceLuid
.
Value
)
{
if
(
!
row
->
InterfaceIndex
)
return
ERROR_INVALID_PARAMETER
;
err
=
ConvertInterfaceIndexToLuid
(
row
->
InterfaceIndex
,
&
row
->
InterfaceLuid
);
if
(
err
)
return
err
;
}
err
=
NsiGetAllParameters
(
1
,
&
NPI_MS_NDIS_MODULEID
,
NSI_NDIS_IFINFO_TABLE
,
&
row
->
InterfaceLuid
,
sizeof
(
row
->
InterfaceLuid
),
&
rw
,
sizeof
(
rw
),
&
dyn
,
sizeof
(
dyn
),
&
stat
,
sizeof
(
stat
)
);
if
(
!
err
)
if_row2_fill
(
row
,
&
rw
,
&
dyn
,
&
stat
);
return
err
;
}
/******************************************************************
* GetIfEntry2 (IPHLPAPI.@)
*/
DWORD
WINAPI
GetIfEntry2
(
MIB_IF_ROW2
*
row
)
{
return
GetIfEntry2Ex
(
MibIfTableNormal
,
row
);
}
/******************************************************************
* GetIfTable2Ex (IPHLPAPI.@)
*/
DWORD
WINAPI
GetIfTable2Ex
(
MIB_IF_TABLE_LEVEL
level
,
MIB_IF_TABLE2
**
table
)
...
...
dlls/iphlpapi/tests/iphlpapi.c
View file @
0b5a6c70
...
...
@@ -53,9 +53,6 @@
static
HMODULE
hLibrary
=
NULL
;
static
DWORD
(
WINAPI
*
pAllocateAndGetTcpExTableFromStack
)(
void
**
,
BOOL
,
HANDLE
,
DWORD
,
DWORD
);
static
DWORD
(
WINAPI
*
pGetIfEntry2
)(
PMIB_IF_ROW2
);
static
DWORD
(
WINAPI
*
pGetIfTable2
)(
PMIB_IF_TABLE2
*
);
static
DWORD
(
WINAPI
*
pGetIfTable2Ex
)(
MIB_IF_TABLE_LEVEL
,
PMIB_IF_TABLE2
*
);
static
DWORD
(
WINAPI
*
pGetTcp6Table
)(
PMIB_TCP6TABLE
,
PDWORD
,
BOOL
);
static
DWORD
(
WINAPI
*
pGetUdp6Table
)(
PMIB_UDP6TABLE
,
PDWORD
,
BOOL
);
static
DWORD
(
WINAPI
*
pGetUnicastIpAddressEntry
)(
MIB_UNICASTIPADDRESS_ROW
*
);
...
...
@@ -64,7 +61,6 @@ static DWORD (WINAPI *pGetExtendedTcpTable)(PVOID,PDWORD,BOOL,ULONG,TCP_TABLE_CL
static
DWORD
(
WINAPI
*
pGetExtendedUdpTable
)(
PVOID
,
PDWORD
,
BOOL
,
ULONG
,
UDP_TABLE_CLASS
,
ULONG
);
static
DWORD
(
WINAPI
*
pCreateSortedAddressPairs
)(
const
PSOCKADDR_IN6
,
ULONG
,
const
PSOCKADDR_IN6
,
ULONG
,
ULONG
,
PSOCKADDR_IN6_PAIR
*
,
ULONG
*
);
static
void
(
WINAPI
*
pFreeMibTable
)(
void
*
);
static
DWORD
(
WINAPI
*
pConvertLengthToIpv4Mask
)(
ULONG
,
ULONG
*
);
static
DWORD
(
WINAPI
*
pParseNetworkString
)(
const
WCHAR
*
,
DWORD
,
NET_ADDRESS_INFO
*
,
USHORT
*
,
BYTE
*
);
static
DWORD
(
WINAPI
*
pNotifyUnicastIpAddressChange
)(
ADDRESS_FAMILY
,
PUNICAST_IPADDRESS_CHANGE_CALLBACK
,
...
...
@@ -76,9 +72,6 @@ static void loadIPHlpApi(void)
hLibrary
=
LoadLibraryA
(
"iphlpapi.dll"
);
if
(
hLibrary
)
{
pAllocateAndGetTcpExTableFromStack
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"AllocateAndGetTcpExTableFromStack"
);
pGetIfEntry2
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"GetIfEntry2"
);
pGetIfTable2
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"GetIfTable2"
);
pGetIfTable2Ex
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"GetIfTable2Ex"
);
pGetTcp6Table
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"GetTcp6Table"
);
pGetUdp6Table
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"GetUdp6Table"
);
pGetUnicastIpAddressEntry
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"GetUnicastIpAddressEntry"
);
...
...
@@ -86,7 +79,6 @@ static void loadIPHlpApi(void)
pGetExtendedTcpTable
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"GetExtendedTcpTable"
);
pGetExtendedUdpTable
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"GetExtendedUdpTable"
);
pCreateSortedAddressPairs
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"CreateSortedAddressPairs"
);
pFreeMibTable
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"FreeMibTable"
);
pConvertLengthToIpv4Mask
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"ConvertLengthToIpv4Mask"
);
pParseNetworkString
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"ParseNetworkString"
);
pNotifyUnicastIpAddressChange
=
(
void
*
)
GetProcAddress
(
hLibrary
,
"NotifyUnicastIpAddressChange"
);
...
...
@@ -1576,7 +1568,7 @@ static void test_CreateSortedAddressPairs(void)
ok
(
pair_count
>=
1
,
"got %u
\n
"
,
pair_count
);
ok
(
pair
[
0
].
SourceAddress
!=
NULL
,
"src address not set
\n
"
);
ok
(
pair
[
0
].
DestinationAddress
!=
NULL
,
"dst address not set
\n
"
);
p
FreeMibTable
(
pair
);
FreeMibTable
(
pair
);
dst
[
1
].
sin6_family
=
AF_INET6
;
dst
[
1
].
sin6_addr
.
u
.
Word
[
5
]
=
0xffff
;
...
...
@@ -1593,7 +1585,7 @@ static void test_CreateSortedAddressPairs(void)
ok
(
pair
[
0
].
DestinationAddress
!=
NULL
,
"dst address not set
\n
"
);
ok
(
pair
[
1
].
SourceAddress
!=
NULL
,
"src address not set
\n
"
);
ok
(
pair
[
1
].
DestinationAddress
!=
NULL
,
"dst address not set
\n
"
);
p
FreeMibTable
(
pair
);
FreeMibTable
(
pair
);
}
static
DWORD
get_interface_index
(
void
)
...
...
@@ -1862,27 +1854,22 @@ static void test_GetIfEntry2(void)
MIB_IF_ROW2
row
;
NET_IFINDEX
index
;
if
(
!
pGetIfEntry2
)
{
win_skip
(
"GetIfEntry2 not available
\n
"
);
return
;
}
if
(
!
(
index
=
get_interface_index
()))
{
skip
(
"no suitable interface found
\n
"
);
return
;
}
ret
=
p
GetIfEntry2
(
NULL
);
ret
=
GetIfEntry2
(
NULL
);
ok
(
ret
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
ret
);
memset
(
&
row
,
0
,
sizeof
(
row
)
);
ret
=
p
GetIfEntry2
(
&
row
);
ret
=
GetIfEntry2
(
&
row
);
ok
(
ret
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
ret
);
memset
(
&
row
,
0
,
sizeof
(
row
)
);
row
.
InterfaceIndex
=
index
;
ret
=
p
GetIfEntry2
(
&
row
);
ret
=
GetIfEntry2
(
&
row
);
ok
(
ret
==
NO_ERROR
,
"got %u
\n
"
,
ret
);
ok
(
row
.
InterfaceIndex
==
index
,
"got %u
\n
"
,
index
);
}
...
...
@@ -1892,17 +1879,11 @@ static void test_GetIfTable2(void)
DWORD
ret
;
MIB_IF_TABLE2
*
table
;
if
(
!
pGetIfTable2
)
{
win_skip
(
"GetIfTable2 not available
\n
"
);
return
;
}
table
=
NULL
;
ret
=
p
GetIfTable2
(
&
table
);
ret
=
GetIfTable2
(
&
table
);
ok
(
ret
==
NO_ERROR
,
"got %u
\n
"
,
ret
);
ok
(
table
!=
NULL
,
"table not set
\n
"
);
p
FreeMibTable
(
table
);
FreeMibTable
(
table
);
}
static
void
test_GetIfTable2Ex
(
void
)
...
...
@@ -1910,35 +1891,29 @@ static void test_GetIfTable2Ex(void)
DWORD
ret
;
MIB_IF_TABLE2
*
table
;
if
(
!
pGetIfTable2Ex
)
{
win_skip
(
"GetIfTable2Ex not available
\n
"
);
return
;
}
table
=
NULL
;
ret
=
p
GetIfTable2Ex
(
MibIfTableNormal
,
&
table
);
ret
=
GetIfTable2Ex
(
MibIfTableNormal
,
&
table
);
ok
(
ret
==
NO_ERROR
,
"got %u
\n
"
,
ret
);
ok
(
table
!=
NULL
,
"table not set
\n
"
);
p
FreeMibTable
(
table
);
FreeMibTable
(
table
);
table
=
NULL
;
ret
=
p
GetIfTable2Ex
(
MibIfTableRaw
,
&
table
);
ret
=
GetIfTable2Ex
(
MibIfTableRaw
,
&
table
);
ok
(
ret
==
NO_ERROR
,
"got %u
\n
"
,
ret
);
ok
(
table
!=
NULL
,
"table not set
\n
"
);
p
FreeMibTable
(
table
);
FreeMibTable
(
table
);
table
=
NULL
;
ret
=
p
GetIfTable2Ex
(
MibIfTableNormalWithoutStatistics
,
&
table
);
ret
=
GetIfTable2Ex
(
MibIfTableNormalWithoutStatistics
,
&
table
);
ok
(
ret
==
NO_ERROR
||
broken
(
ret
==
ERROR_INVALID_PARAMETER
),
"got %u
\n
"
,
ret
);
ok
(
table
!=
NULL
||
broken
(
!
table
),
"table not set
\n
"
);
p
FreeMibTable
(
table
);
FreeMibTable
(
table
);
table
=
NULL
;
ret
=
p
GetIfTable2Ex
(
3
,
&
table
);
ret
=
GetIfTable2Ex
(
3
,
&
table
);
ok
(
ret
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
ret
);
ok
(
!
table
,
"table should not be set
\n
"
);
p
FreeMibTable
(
table
);
FreeMibTable
(
table
);
}
static
void
test_GetUnicastIpAddressEntry
(
void
)
...
...
@@ -2070,12 +2045,12 @@ static void test_GetUnicastIpAddressTable(void)
ret
=
pGetUnicastIpAddressTable
(
AF_INET
,
&
table
);
ok
(
ret
==
NO_ERROR
,
"got %u
\n
"
,
ret
);
trace
(
"GetUnicastIpAddressTable(AF_INET): NumEntries %u
\n
"
,
table
->
NumEntries
);
pFreeMibTable
(
table
);
FreeMibTable
(
table
);
ret
=
pGetUnicastIpAddressTable
(
AF_INET6
,
&
table
);
ok
(
ret
==
NO_ERROR
,
"got %u
\n
"
,
ret
);
trace
(
"GetUnicastIpAddressTable(AF_INET6): NumEntries %u
\n
"
,
table
->
NumEntries
);
pFreeMibTable
(
table
);
FreeMibTable
(
table
);
ret
=
pGetUnicastIpAddressTable
(
AF_UNSPEC
,
&
table
);
ok
(
ret
==
NO_ERROR
,
"got %u
\n
"
,
ret
);
...
...
@@ -2099,7 +2074,7 @@ static void test_GetUnicastIpAddressTable(void)
trace
(
"CreationTimeStamp: %08x%08x
\n
"
,
table
->
Table
[
i
].
CreationTimeStamp
.
HighPart
,
table
->
Table
[
i
].
CreationTimeStamp
.
LowPart
);
}
pFreeMibTable
(
table
);
FreeMibTable
(
table
);
}
static
void
test_ConvertLengthToIpv4Mask
(
void
)
...
...
include/netioapi.h
View file @
0b5a6c70
...
...
@@ -251,7 +251,9 @@ DWORD WINAPI ConvertInterfaceNameToLuidW(const WCHAR*,NET_LUID*);
DWORD
WINAPI
ConvertLengthToIpv4Mask
(
ULONG
,
ULONG
*
);
void
WINAPI
FreeMibTable
(
void
*
);
DWORD
WINAPI
GetIfEntry2
(
MIB_IF_ROW2
*
);
DWORD
WINAPI
GetIfEntry2Ex
(
MIB_IF_TABLE_LEVEL
,
MIB_IF_ROW2
*
);
DWORD
WINAPI
GetIfTable2
(
MIB_IF_TABLE2
**
);
DWORD
WINAPI
GetIfTable2Ex
(
MIB_IF_TABLE_LEVEL
,
MIB_IF_TABLE2
**
);
DWORD
WINAPI
GetIpInterfaceTable
(
ADDRESS_FAMILY
,
MIB_IPINTERFACE_TABLE
**
);
DWORD
WINAPI
GetUnicastIpAddressEntry
(
MIB_UNICASTIPADDRESS_ROW
*
);
PCHAR
WINAPI
if_indextoname
(
NET_IFINDEX
,
PCHAR
);
...
...
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