From 5c9428b3b3f25d91b2649b74f860920609b14761 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 9 Mar 2018 16:34:19 -0500 Subject: [PATCH] Swap bytes for port number (case 1006506) --- .../System.Net.NetworkInformation/IPGlobalProperties.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs b/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs index b93b53ae0a28..7246735678d0 100644 --- a/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs +++ b/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs @@ -622,6 +622,9 @@ public override NetBiosNodeType NodeType { [DllImport ("iphlpapi.dll")] static extern int GetIpStatisticsEx (out Win32_MIB_IPSTATS pStats, int dwFamily); + [DllImport ("Ws2_32.dll")] + static extern ushort ntohs (ushort netshort); + // Win32 structures [StructLayout (LayoutKind.Explicit)] @@ -682,10 +685,10 @@ public TcpConnectionInformation TcpInfo { class Win32_MIB_UDPROW { public uint LocalAddr; - public int LocalPort; + public uint LocalPort; public IPEndPoint LocalEndPoint { - get { return new IPEndPoint (LocalAddr, LocalPort); } + get { return new IPEndPoint (LocalAddr, ntohs((ushort)LocalPort)); } } }