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
44f30a64
Commit
44f30a64
authored
Mar 02, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iphlpapi: Moved AllocateAndGetIpForwardTableFromStack implementation to ipstats.c.
parent
b406213c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
70 deletions
+43
-70
iphlpapi_main.c
dlls/iphlpapi/iphlpapi_main.c
+2
-62
ipstats.c
dlls/iphlpapi/ipstats.c
+40
-2
ipstats.h
dlls/iphlpapi/ipstats.h
+1
-6
No files found.
dlls/iphlpapi/iphlpapi_main.c
View file @
44f30a64
...
...
@@ -189,63 +189,6 @@ DWORD WINAPI AllocateAndGetIpAddrTableFromStack(PMIB_IPADDRTABLE *ppIpAddrTable,
}
static
int
IpForwardTableSorter
(
const
void
*
a
,
const
void
*
b
)
{
int
ret
;
if
(
a
&&
b
)
{
const
MIB_IPFORWARDROW
*
rowA
=
(
const
MIB_IPFORWARDROW
*
)
a
;
const
MIB_IPFORWARDROW
*
rowB
=
(
const
MIB_IPFORWARDROW
*
)
b
;
ret
=
rowA
->
dwForwardDest
-
rowB
->
dwForwardDest
;
if
(
ret
==
0
)
{
ret
=
rowA
->
dwForwardProto
-
rowB
->
dwForwardProto
;
if
(
ret
==
0
)
{
ret
=
rowA
->
dwForwardPolicy
-
rowB
->
dwForwardPolicy
;
if
(
ret
==
0
)
ret
=
rowA
->
dwForwardNextHop
-
rowB
->
dwForwardNextHop
;
}
}
}
else
ret
=
0
;
return
ret
;
}
/******************************************************************
* AllocateAndGetIpForwardTableFromStack (IPHLPAPI.@)
*
* Get the route table.
* Like GetIpForwardTable(), but allocate the returned table from heap.
*
* PARAMS
* ppIpForwardTable [Out] pointer into which the MIB_IPFORWARDTABLE is
* allocated and returned.
* bOrder [In] whether to sort the table
* heap [In] heap from which the table is allocated
* flags [In] flags to HeapAlloc
*
* RETURNS
* ERROR_INVALID_PARAMETER if ppIfTable is NULL, other error codes
* on failure, NO_ERROR on success.
*/
DWORD
WINAPI
AllocateAndGetIpForwardTableFromStack
(
PMIB_IPFORWARDTABLE
*
ppIpForwardTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
)
{
DWORD
ret
;
TRACE
(
"ppIpForwardTable %p, bOrder %d, heap %p, flags 0x%08x
\n
"
,
ppIpForwardTable
,
bOrder
,
heap
,
flags
);
ret
=
getRouteTable
(
ppIpForwardTable
,
heap
,
flags
);
if
(
!
ret
&&
bOrder
)
qsort
((
*
ppIpForwardTable
)
->
table
,
(
*
ppIpForwardTable
)
->
dwNumEntries
,
sizeof
(
MIB_IPFORWARDROW
),
IpForwardTableSorter
);
TRACE
(
"returning %d
\n
"
,
ret
);
return
ret
;
}
/******************************************************************
* CreateIpForwardEntry (IPHLPAPI.@)
*
...
...
@@ -535,7 +478,7 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
ret
=
getIPAddrTable
(
&
ipAddrTable
,
GetProcessHeap
(),
0
);
if
(
!
ret
)
ret
=
getRouteTable
(
&
routeTable
,
GetProcessHeap
(),
0
);
ret
=
AllocateAndGetIpForwardTableFromStack
(
&
routeTable
,
FALSE
,
GetProcessHeap
(),
0
);
if
(
!
ret
)
table
=
getNonLoopbackInterfaceIndexTable
();
if
(
table
)
{
...
...
@@ -1101,7 +1044,7 @@ DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSi
if
(
!
pdwSize
)
return
ERROR_INVALID_PARAMETER
;
ret
=
getRouteTable
(
&
table
,
GetProcessHeap
(),
0
);
ret
=
AllocateAndGetIpForwardTableFromStack
(
&
table
,
bOrder
,
GetProcessHeap
(),
0
);
if
(
!
ret
)
{
DWORD
size
=
FIELD_OFFSET
(
MIB_IPFORWARDTABLE
,
table
[
table
->
dwNumEntries
]
);
if
(
!
pIpForwardTable
||
*
pdwSize
<
size
)
{
...
...
@@ -1111,9 +1054,6 @@ DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSi
else
{
*
pdwSize
=
size
;
memcpy
(
pIpForwardTable
,
table
,
size
);
if
(
bOrder
)
qsort
(
pIpForwardTable
->
table
,
pIpForwardTable
->
dwNumEntries
,
sizeof
(
MIB_IPFORWARDROW
),
IpForwardTableSorter
);
}
HeapFree
(
GetProcessHeap
(),
0
,
table
);
}
...
...
dlls/iphlpapi/ipstats.c
View file @
44f30a64
...
...
@@ -1065,12 +1065,44 @@ static MIB_IPFORWARDTABLE *append_ipforward_row( HANDLE heap, DWORD flags, MIB_I
return
table
;
}
DWORD
getRouteTable
(
PMIB_IPFORWARDTABLE
*
ppIpForwardTable
,
HANDLE
heap
,
DWORD
flags
)
static
int
compare_ipforward_rows
(
const
void
*
a
,
const
void
*
b
)
{
const
MIB_IPFORWARDROW
*
rowA
=
a
;
const
MIB_IPFORWARDROW
*
rowB
=
b
;
int
ret
;
if
((
ret
=
rowA
->
dwForwardDest
-
rowB
->
dwForwardDest
)
!=
0
)
return
ret
;
if
((
ret
=
rowA
->
dwForwardProto
-
rowB
->
dwForwardProto
)
!=
0
)
return
ret
;
if
((
ret
=
rowA
->
dwForwardPolicy
-
rowB
->
dwForwardPolicy
)
!=
0
)
return
ret
;
return
rowA
->
dwForwardNextHop
-
rowB
->
dwForwardNextHop
;
}
/******************************************************************
* AllocateAndGetIpForwardTableFromStack (IPHLPAPI.@)
*
* Get the route table.
* Like GetIpForwardTable(), but allocate the returned table from heap.
*
* PARAMS
* ppIpForwardTable [Out] pointer into which the MIB_IPFORWARDTABLE is
* allocated and returned.
* bOrder [In] whether to sort the table
* heap [In] heap from which the table is allocated
* flags [In] flags to HeapAlloc
*
* RETURNS
* ERROR_INVALID_PARAMETER if ppIfTable is NULL, other error codes
* on failure, NO_ERROR on success.
*/
DWORD
WINAPI
AllocateAndGetIpForwardTableFromStack
(
PMIB_IPFORWARDTABLE
*
ppIpForwardTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
)
{
MIB_IPFORWARDTABLE
*
table
;
MIB_IPFORWARDROW
row
;
DWORD
ret
=
NO_ERROR
,
count
=
16
;
TRACE
(
"table %p, bOrder %d, heap %p, flags 0x%08x
\n
"
,
ppIpForwardTable
,
bOrder
,
heap
,
flags
);
if
(
!
ppIpForwardTable
)
return
ERROR_INVALID_PARAMETER
;
if
(
!
(
table
=
HeapAlloc
(
heap
,
flags
,
FIELD_OFFSET
(
MIB_IPFORWARDTABLE
,
table
[
count
]
))))
...
...
@@ -1225,8 +1257,14 @@ done:
#endif
if
(
!
table
)
return
ERROR_OUTOFMEMORY
;
if
(
!
ret
)
*
ppIpForwardTable
=
table
;
if
(
!
ret
)
{
if
(
bOrder
&&
table
->
dwNumEntries
)
qsort
(
table
->
table
,
table
->
dwNumEntries
,
sizeof
(
row
),
compare_ipforward_rows
);
*
ppIpForwardTable
=
table
;
}
else
HeapFree
(
heap
,
flags
,
table
);
TRACE
(
"returning ret %u table %p
\n
"
,
ret
,
table
);
return
ret
;
}
...
...
dlls/iphlpapi/ipstats.h
View file @
44f30a64
...
...
@@ -55,12 +55,6 @@ DWORD getUDPStats(MIB_UDPSTATS *stats);
/* Returns the number of entries in the route table. */
DWORD
getNumRoutes
(
void
);
/* Allocates the route table from heap and returns it to you in
* *ppIpForwardTable. Returns NO_ERROR on success, something else on failure.
*/
DWORD
getRouteTable
(
PMIB_IPFORWARDTABLE
*
ppIpForwardTable
,
HANDLE
heap
,
DWORD
flags
);
/* Returns the number of entries in the arp table. */
DWORD
getNumArpEntries
(
void
);
...
...
@@ -73,5 +67,6 @@ DWORD getNumTcpEntries(void);
DWORD
WINAPI
AllocateAndGetUdpTableFromStack
(
PMIB_UDPTABLE
*
ppUdpTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
);
DWORD
WINAPI
AllocateAndGetTcpTableFromStack
(
PMIB_TCPTABLE
*
ppTcpTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
);
DWORD
WINAPI
AllocateAndGetIpNetTableFromStack
(
PMIB_IPNETTABLE
*
ppIpNetTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
);
DWORD
WINAPI
AllocateAndGetIpForwardTableFromStack
(
PMIB_IPFORWARDTABLE
*
ppIpForwardTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
);
#endif
/* ndef WINE_IPSTATS_H_ */
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