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
bc08fb99
Commit
bc08fb99
authored
Mar 02, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iphlpapi: Moved AllocateAndGetTcpTableFromStack implementation to ipstats.c.
parent
95827a82
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
72 deletions
+44
-72
iphlpapi_main.c
dlls/iphlpapi/iphlpapi_main.c
+1
-65
ipstats.c
dlls/iphlpapi/ipstats.c
+42
-2
ipstats.h
dlls/iphlpapi/ipstats.h
+1
-5
No files found.
dlls/iphlpapi/iphlpapi_main.c
View file @
bc08fb99
...
...
@@ -291,67 +291,6 @@ DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable,
}
static
int
TcpTableSorter
(
const
void
*
a
,
const
void
*
b
)
{
int
ret
;
if
(
a
&&
b
)
{
const
MIB_TCPROW
*
rowA
=
a
;
const
MIB_TCPROW
*
rowB
=
b
;
ret
=
ntohl
(
rowA
->
dwLocalAddr
)
-
ntohl
(
rowB
->
dwLocalAddr
);
if
(
ret
==
0
)
{
ret
=
ntohs
((
unsigned
short
)
rowA
->
dwLocalPort
)
-
ntohs
((
unsigned
short
)
rowB
->
dwLocalPort
);
if
(
ret
==
0
)
{
ret
=
ntohl
(
rowA
->
dwRemoteAddr
)
-
ntohl
(
rowB
->
dwRemoteAddr
);
if
(
ret
==
0
)
ret
=
ntohs
((
unsigned
short
)
rowA
->
dwRemotePort
)
-
ntohs
((
unsigned
short
)
rowB
->
dwRemotePort
);
}
}
}
else
ret
=
0
;
return
ret
;
}
/******************************************************************
* AllocateAndGetTcpTableFromStack (IPHLPAPI.@)
*
* Get the TCP connection table.
* Like GetTcpTable(), but allocate the returned table from heap.
*
* PARAMS
* ppTcpTable [Out] pointer into which the MIB_TCPTABLE 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 ppTcpTable is NULL, whatever GetTcpTable()
* returns otherwise.
*/
DWORD
WINAPI
AllocateAndGetTcpTableFromStack
(
PMIB_TCPTABLE
*
ppTcpTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
)
{
DWORD
ret
;
TRACE
(
"ppTcpTable %p, bOrder %d, heap %p, flags 0x%08x
\n
"
,
ppTcpTable
,
bOrder
,
heap
,
flags
);
*
ppTcpTable
=
NULL
;
ret
=
getTcpTable
(
ppTcpTable
,
heap
,
flags
);
if
(
!
ret
&&
bOrder
)
qsort
((
*
ppTcpTable
)
->
table
,
(
*
ppTcpTable
)
->
dwNumEntries
,
sizeof
(
MIB_TCPROW
),
TcpTableSorter
);
TRACE
(
"returning %d
\n
"
,
ret
);
return
ret
;
}
/******************************************************************
* CreateIpForwardEntry (IPHLPAPI.@)
*
...
...
@@ -1525,7 +1464,7 @@ DWORD WINAPI GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder)
if
(
!
pdwSize
)
return
ERROR_INVALID_PARAMETER
;
ret
=
getTcpTable
(
&
table
,
GetProcessHeap
(),
0
);
ret
=
AllocateAndGetTcpTableFromStack
(
&
table
,
bOrder
,
GetProcessHeap
(),
0
);
if
(
!
ret
)
{
DWORD
size
=
FIELD_OFFSET
(
MIB_TCPTABLE
,
table
[
table
->
dwNumEntries
]
);
if
(
!
pTcpTable
||
*
pdwSize
<
size
)
{
...
...
@@ -1535,9 +1474,6 @@ DWORD WINAPI GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder)
else
{
*
pdwSize
=
size
;
memcpy
(
pTcpTable
,
table
,
size
);
if
(
bOrder
)
qsort
(
pTcpTable
->
table
,
pTcpTable
->
dwNumEntries
,
sizeof
(
MIB_TCPROW
),
TcpTableSorter
);
}
HeapFree
(
GetProcessHeap
(),
0
,
table
);
}
...
...
dlls/iphlpapi/ipstats.c
View file @
bc08fb99
...
...
@@ -1591,12 +1591,46 @@ static DWORD TCPStateToMIBState (int state)
}
DWORD
getTcpTable
(
PMIB_TCPTABLE
*
ppTcpTable
,
HANDLE
heap
,
DWORD
flags
)
static
int
compare_tcp_rows
(
const
void
*
a
,
const
void
*
b
)
{
const
MIB_TCPROW
*
rowA
=
a
;
const
MIB_TCPROW
*
rowB
=
b
;
int
ret
;
if
((
ret
=
ntohl
(
rowA
->
dwLocalAddr
)
-
ntohl
(
rowB
->
dwLocalAddr
))
!=
0
)
return
ret
;
if
((
ret
=
ntohs
((
unsigned
short
)
rowA
->
dwLocalPort
)
-
ntohs
((
unsigned
short
)
rowB
->
dwLocalPort
))
!=
0
)
return
ret
;
if
((
ret
=
ntohl
(
rowA
->
dwRemoteAddr
)
-
ntohl
(
rowB
->
dwRemoteAddr
))
!=
0
)
return
ret
;
return
ntohs
((
unsigned
short
)
rowA
->
dwRemotePort
)
-
ntohs
((
unsigned
short
)
rowB
->
dwRemotePort
);
}
/******************************************************************
* AllocateAndGetTcpTableFromStack (IPHLPAPI.@)
*
* Get the TCP connection table.
* Like GetTcpTable(), but allocate the returned table from heap.
*
* PARAMS
* ppTcpTable [Out] pointer into which the MIB_TCPTABLE 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 ppTcpTable is NULL, whatever GetTcpTable()
* returns otherwise.
*/
DWORD
WINAPI
AllocateAndGetTcpTableFromStack
(
PMIB_TCPTABLE
*
ppTcpTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
)
{
MIB_TCPTABLE
*
table
;
MIB_TCPROW
row
;
DWORD
ret
=
NO_ERROR
,
count
=
16
;
TRACE
(
"table %p, bOrder %d, heap %p, flags 0x%08x
\n
"
,
ppTcpTable
,
bOrder
,
heap
,
flags
);
if
(
!
ppTcpTable
)
return
ERROR_INVALID_PARAMETER
;
if
(
!
(
table
=
HeapAlloc
(
heap
,
flags
,
FIELD_OFFSET
(
MIB_TCPTABLE
,
table
[
count
]
))))
...
...
@@ -1713,7 +1747,13 @@ DWORD getTcpTable(PMIB_TCPTABLE *ppTcpTable, HANDLE heap, DWORD flags)
#endif
if
(
!
table
)
return
ERROR_OUTOFMEMORY
;
if
(
!
ret
)
*
ppTcpTable
=
table
;
if
(
!
ret
)
{
if
(
bOrder
&&
table
->
dwNumEntries
)
qsort
(
table
->
table
,
table
->
dwNumEntries
,
sizeof
(
row
),
compare_tcp_rows
);
*
ppTcpTable
=
table
;
}
else
HeapFree
(
heap
,
flags
,
table
);
TRACE
(
"returning ret %u table %p
\n
"
,
ret
,
table
);
return
ret
;
}
dlls/iphlpapi/ipstats.h
View file @
bc08fb99
...
...
@@ -75,11 +75,7 @@ DWORD getNumUdpEntries(void);
/* Returns the number of entries in the TCP state table. */
DWORD
getNumTcpEntries
(
void
);
/* Allocates the TCP state table from heap and returns it to you in *ppTcpTable.
* Returns NO_ERROR on success, something else on failure.
*/
DWORD
getTcpTable
(
PMIB_TCPTABLE
*
ppTcpTable
,
HANDLE
heap
,
DWORD
flags
);
DWORD
WINAPI
AllocateAndGetUdpTableFromStack
(
PMIB_UDPTABLE
*
ppUdpTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
);
DWORD
WINAPI
AllocateAndGetTcpTableFromStack
(
PMIB_TCPTABLE
*
ppTcpTable
,
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