@@ -384,8 +384,6 @@ class Win32IPGlobalProperties : IPGlobalProperties
384
384
public const int AF_INET = 2 ;
385
385
public const int AF_INET6 = 23 ;
386
386
387
- // FIXME: it might be getting wrong table. I'm getting
388
- // different results from .NET 2.0.
389
387
unsafe void FillTcpTable ( out List < Win32_MIB_TCPROW > tab4 , out List < Win32_MIB_TCP6ROW > tab6 )
390
388
{
391
389
tab4 = new List < Win32_MIB_TCPROW > ( ) ;
@@ -651,16 +649,16 @@ class Win32_MIB_TCPROW
651
649
{
652
650
public TcpState State ;
653
651
public uint LocalAddr ;
654
- public int LocalPort ;
652
+ public uint LocalPort ;
655
653
public uint RemoteAddr ;
656
- public int RemotePort ;
654
+ public uint RemotePort ;
657
655
658
656
public IPEndPoint LocalEndPoint {
659
- get { return new IPEndPoint ( LocalAddr , LocalPort ) ; }
657
+ get { return new IPEndPoint ( LocalAddr , ntohs ( ( ushort ) LocalPort ) ) ; }
660
658
}
661
659
662
660
public IPEndPoint RemoteEndPoint {
663
- get { return new IPEndPoint ( RemoteAddr , RemotePort ) ; }
661
+ get { return new IPEndPoint ( RemoteAddr , ntohs ( ( ushort ) RemotePort ) ) ; }
664
662
}
665
663
666
664
public TcpConnectionInformation TcpInfo {
@@ -674,17 +672,17 @@ class Win32_MIB_TCP6ROW
674
672
public TcpState State ;
675
673
public Win32_IN6_ADDR LocalAddr ;
676
674
public uint LocalScopeId ;
677
- public int LocalPort ;
675
+ public uint LocalPort ;
678
676
public Win32_IN6_ADDR RemoteAddr ;
679
677
public uint RemoteScopeId ;
680
- public int RemotePort ;
678
+ public uint RemotePort ;
681
679
682
680
public IPEndPoint LocalEndPoint {
683
- get { return new IPEndPoint ( new IPAddress ( LocalAddr . Bytes , LocalScopeId ) , LocalPort ) ; }
681
+ get { return new IPEndPoint ( new IPAddress ( LocalAddr . Bytes , LocalScopeId ) , ntohs ( ( ushort ) LocalPort ) ) ; }
684
682
}
685
683
686
684
public IPEndPoint RemoteEndPoint {
687
- get { return new IPEndPoint ( new IPAddress ( RemoteAddr . Bytes , RemoteScopeId ) , RemotePort ) ; }
685
+ get { return new IPEndPoint ( new IPAddress ( RemoteAddr . Bytes , RemoteScopeId ) , ntohs ( ( ushort ) RemotePort ) ) ; }
688
686
}
689
687
690
688
public TcpConnectionInformation TcpInfo {
@@ -708,10 +706,10 @@ class Win32_MIB_UDP6ROW
708
706
{
709
707
public Win32_IN6_ADDR LocalAddr ;
710
708
public uint LocalScopeId ;
711
- public int LocalPort ;
709
+ public uint LocalPort ;
712
710
713
711
public IPEndPoint LocalEndPoint {
714
- get { return new IPEndPoint ( new IPAddress ( LocalAddr . Bytes , LocalScopeId ) , LocalPort ) ; }
712
+ get { return new IPEndPoint ( new IPAddress ( LocalAddr . Bytes , LocalScopeId ) , ntohs ( ( ushort ) LocalPort ) ) ; }
715
713
}
716
714
}
717
715
}
0 commit comments