Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
95827a82
Commit
95827a82
authored
Mar 02, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iphlpapi: Moved AllocateAndGetUdpTableFromStack implementation to ipstats.c.
parent
3ce9eb0f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
62 deletions
+42
-62
iphlpapi_main.c
dlls/iphlpapi/iphlpapi_main.c
+1
-55
ipstats.c
dlls/iphlpapi/ipstats.c
+39
-2
ipstats.h
dlls/iphlpapi/ipstats.h
+2
-5
No files found.
dlls/iphlpapi/iphlpapi_main.c
View file @
95827a82
...
...
@@ -352,57 +352,6 @@ DWORD WINAPI AllocateAndGetTcpTableFromStack(PMIB_TCPTABLE *ppTcpTable,
}
static
int
UdpTableSorter
(
const
void
*
a
,
const
void
*
b
)
{
int
ret
;
if
(
a
&&
b
)
{
const
MIB_UDPROW
*
rowA
=
(
const
MIB_UDPROW
*
)
a
;
const
MIB_UDPROW
*
rowB
=
(
const
MIB_UDPROW
*
)
b
;
ret
=
rowA
->
dwLocalAddr
-
rowB
->
dwLocalAddr
;
if
(
ret
==
0
)
ret
=
rowA
->
dwLocalPort
-
rowB
->
dwLocalPort
;
}
else
ret
=
0
;
return
ret
;
}
/******************************************************************
* AllocateAndGetUdpTableFromStack (IPHLPAPI.@)
*
* Get the UDP listener table.
* Like GetUdpTable(), but allocate the returned table from heap.
*
* PARAMS
* ppUdpTable [Out] pointer into which the MIB_UDPTABLE 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 ppUdpTable is NULL, whatever GetUdpTable()
* returns otherwise.
*/
DWORD
WINAPI
AllocateAndGetUdpTableFromStack
(
PMIB_UDPTABLE
*
ppUdpTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
)
{
DWORD
ret
;
TRACE
(
"ppUdpTable %p, bOrder %d, heap %p, flags 0x%08x
\n
"
,
ppUdpTable
,
bOrder
,
heap
,
flags
);
ret
=
getUdpTable
(
ppUdpTable
,
heap
,
flags
);
if
(
!
ret
&&
bOrder
)
qsort
((
*
ppUdpTable
)
->
table
,
(
*
ppUdpTable
)
->
dwNumEntries
,
sizeof
(
MIB_UDPROW
),
UdpTableSorter
);
TRACE
(
"returning %d
\n
"
,
ret
);
return
ret
;
}
/******************************************************************
* CreateIpForwardEntry (IPHLPAPI.@)
*
...
...
@@ -1650,7 +1599,7 @@ DWORD WINAPI GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
if
(
!
pdwSize
)
return
ERROR_INVALID_PARAMETER
;
ret
=
getUdpTable
(
&
table
,
GetProcessHeap
(),
0
);
ret
=
AllocateAndGetUdpTableFromStack
(
&
table
,
bOrder
,
GetProcessHeap
(),
0
);
if
(
!
ret
)
{
DWORD
size
=
FIELD_OFFSET
(
MIB_UDPTABLE
,
table
[
table
->
dwNumEntries
]
);
if
(
!
pUdpTable
||
*
pdwSize
<
size
)
{
...
...
@@ -1660,9 +1609,6 @@ DWORD WINAPI GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
else
{
*
pdwSize
=
size
;
memcpy
(
pUdpTable
,
table
,
size
);
if
(
bOrder
)
qsort
(
pUdpTable
->
table
,
pUdpTable
->
dwNumEntries
,
sizeof
(
MIB_UDPROW
),
UdpTableSorter
);
}
HeapFree
(
GetProcessHeap
(),
0
,
table
);
}
...
...
dlls/iphlpapi/ipstats.c
View file @
95827a82
...
...
@@ -1454,12 +1454,43 @@ static MIB_UDPTABLE *append_udp_row( HANDLE heap, DWORD flags, MIB_UDPTABLE *tab
return
table
;
}
DWORD
getUdpTable
(
PMIB_UDPTABLE
*
ppUdpTable
,
HANDLE
heap
,
DWORD
flags
)
static
int
compare_udp_rows
(
const
void
*
a
,
const
void
*
b
)
{
const
MIB_UDPROW
*
rowA
=
a
;
const
MIB_UDPROW
*
rowB
=
b
;
int
ret
;
if
((
ret
=
rowA
->
dwLocalAddr
-
rowB
->
dwLocalAddr
)
!=
0
)
return
ret
;
return
rowA
->
dwLocalPort
-
rowB
->
dwLocalPort
;
}
/******************************************************************
* AllocateAndGetUdpTableFromStack (IPHLPAPI.@)
*
* Get the UDP listener table.
* Like GetUdpTable(), but allocate the returned table from heap.
*
* PARAMS
* ppUdpTable [Out] pointer into which the MIB_UDPTABLE 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 ppUdpTable is NULL, whatever GetUdpTable()
* returns otherwise.
*/
DWORD
WINAPI
AllocateAndGetUdpTableFromStack
(
PMIB_UDPTABLE
*
ppUdpTable
,
BOOL
bOrder
,
HANDLE
heap
,
DWORD
flags
)
{
MIB_UDPTABLE
*
table
;
MIB_UDPROW
row
;
DWORD
ret
=
NO_ERROR
,
count
=
16
;
TRACE
(
"table %p, bOrder %d, heap %p, flags 0x%08x
\n
"
,
ppUdpTable
,
bOrder
,
heap
,
flags
);
if
(
!
ppUdpTable
)
return
ERROR_INVALID_PARAMETER
;
if
(
!
(
table
=
HeapAlloc
(
heap
,
flags
,
FIELD_OFFSET
(
MIB_UDPTABLE
,
table
[
count
]
))))
...
...
@@ -1496,8 +1527,14 @@ DWORD getUdpTable(PMIB_UDPTABLE *ppUdpTable, HANDLE heap, DWORD flags)
#endif
if
(
!
table
)
return
ERROR_OUTOFMEMORY
;
if
(
!
ret
)
*
ppUdpTable
=
table
;
if
(
!
ret
)
{
if
(
bOrder
&&
table
->
dwNumEntries
)
qsort
(
table
->
table
,
table
->
dwNumEntries
,
sizeof
(
row
),
compare_udp_rows
);
*
ppUdpTable
=
table
;
}
else
HeapFree
(
heap
,
flags
,
table
);
TRACE
(
"returning ret %u table %p
\n
"
,
ret
,
table
);
return
ret
;
}
...
...
dlls/iphlpapi/ipstats.h
View file @
95827a82
...
...
@@ -72,11 +72,6 @@ DWORD getArpTable(PMIB_IPNETTABLE *ppIpNetTable, HANDLE heap, DWORD flags);
/* Returns the number of entries in the UDP state table. */
DWORD
getNumUdpEntries
(
void
);
/* Allocates the UDP state table from heap and returns it to you in *ppUdpTable.
* Returns NO_ERROR on success, something else on failure.
*/
DWORD
getUdpTable
(
PMIB_UDPTABLE
*
ppUdpTable
,
HANDLE
heap
,
DWORD
flags
);
/* Returns the number of entries in the TCP state table. */
DWORD
getNumTcpEntries
(
void
);
...
...
@@ -85,4 +80,6 @@ DWORD getNumTcpEntries(void);
*/
DWORD
getTcpTable
(
PMIB_TCPTABLE
*
ppTcpTable
,
HANDLE
heap
,
DWORD
flags
);
DWORD
WINAPI
AllocateAndGetUdpTableFromStack
(
PMIB_UDPTABLE
*
ppUdpTable
,
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