11use std:: ffi:: { c_ulong, c_void} ;
22use std:: net:: { IpAddr , Ipv4Addr , Ipv6Addr } ;
33
4+ use super :: statics:: UDP_TABLE_OWNER_PID ;
45use crate :: Protocol ;
5- use crate :: platform:: target_os:: c_iphlpapi:: GetExtendedTcpTable ;
66use crate :: platform:: target_os:: proto_listener:: ProtoListener ;
7- use crate :: platform:: target_os:: statics:: FALSE ;
87use crate :: platform:: windows:: statics:: {
98 AF_INET , AF_INET6 , ERROR_INSUFFICIENT_BUFFER , NO_ERROR , TCP_TABLE_OWNER_PID_ALL ,
109} ;
1110use crate :: platform:: windows:: tcp_table:: TcpTable ;
1211use crate :: platform:: windows:: tcp6_table:: Tcp6Table ;
1312use crate :: platform:: windows:: udp_table:: UdpTable ;
1413use crate :: platform:: windows:: udp6_table:: Udp6Table ;
15-
16- use super :: c_iphlpapi:: GetExtendedUdpTable ;
17- use super :: statics:: UDP_TABLE_OWNER_PID ;
14+ use windows:: Win32 :: NetworkManagement :: IpHelper :: { GetExtendedTcpTable , GetExtendedUdpTable } ;
1815
1916pub ( super ) trait SocketTable {
2017 fn get_table ( ) -> crate :: Result < Vec < u8 > > ;
@@ -178,9 +175,9 @@ fn get_udp_table(address_family: c_ulong) -> crate::Result<Vec<u8>> {
178175 let mut table_size: c_ulong = 0 ;
179176 let mut err_code = unsafe {
180177 GetExtendedUdpTable (
181- std :: ptr :: null_mut ( ) ,
178+ None ,
182179 & raw mut table_size,
183- FALSE ,
180+ false ,
184181 address_family,
185182 UDP_TABLE_OWNER_PID ,
186183 0 ,
@@ -192,9 +189,9 @@ fn get_udp_table(address_family: c_ulong) -> crate::Result<Vec<u8>> {
192189 table = Vec :: < u8 > :: with_capacity ( table_size as usize ) ;
193190 err_code = unsafe {
194191 GetExtendedUdpTable (
195- table. as_mut_ptr ( ) . cast :: < c_void > ( ) ,
192+ Some ( table. as_mut_ptr ( ) . cast :: < c_void > ( ) ) ,
196193 & raw mut table_size,
197- FALSE ,
194+ false ,
198195 address_family,
199196 UDP_TABLE_OWNER_PID ,
200197 0 ,
@@ -216,9 +213,9 @@ fn get_tcp_table(address_family: c_ulong) -> crate::Result<Vec<u8>> {
216213 let mut table_size: c_ulong = 0 ;
217214 let mut err_code = unsafe {
218215 GetExtendedTcpTable (
219- std :: ptr :: null_mut ( ) ,
216+ None ,
220217 & raw mut table_size,
221- FALSE ,
218+ false ,
222219 address_family,
223220 TCP_TABLE_OWNER_PID_ALL ,
224221 0 ,
@@ -230,9 +227,9 @@ fn get_tcp_table(address_family: c_ulong) -> crate::Result<Vec<u8>> {
230227 table = Vec :: < u8 > :: with_capacity ( table_size as usize ) ;
231228 err_code = unsafe {
232229 GetExtendedTcpTable (
233- table. as_mut_ptr ( ) . cast :: < c_void > ( ) ,
230+ Some ( table. as_mut_ptr ( ) . cast :: < c_void > ( ) ) ,
234231 & raw mut table_size,
235- FALSE ,
232+ false ,
236233 address_family,
237234 TCP_TABLE_OWNER_PID_ALL ,
238235 0 ,
0 commit comments