Author: atsushi
Date: 2007-08-27 00:42:29 -0400 (Mon, 27 Aug 2007)
New Revision: 84864

Modified:
   trunk/mcs/class/System/System.Net.NetworkInformation/ChangeLog
   trunk/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs
   trunk/mcs/class/System/System.Net.NetworkInformation/IPGlobalStatistics.cs
   trunk/mcs/class/System/System.Net.NetworkInformation/IcmpV4Statistics.cs
   trunk/mcs/class/System/System.Net.NetworkInformation/IcmpV6Statistics.cs
   
trunk/mcs/class/System/System.Net.NetworkInformation/TcpConnectionInformation.cs
   trunk/mcs/class/System/System.Net.NetworkInformation/TcpStatistics.cs
   trunk/mcs/class/System/System.Net.NetworkInformation/UdpStatistics.cs
Log:
2007-08-27  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * IPGlobalProperties.cs, TcpConnectionInformation.cs,
          TcpStatistics.cs, IPGlobalStatistics.cs, IcmpV4Statistics.cs,
          IcmpV6Statistics.cs, UdpStatistics.cs :
          initial implementation of IPGlobalProperties and its children
          for Win32 API, mostly done. Non-Windows implementation should
          follow.



Modified: trunk/mcs/class/System/System.Net.NetworkInformation/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net.NetworkInformation/ChangeLog      
2007-08-27 00:41:16 UTC (rev 84863)
+++ trunk/mcs/class/System/System.Net.NetworkInformation/ChangeLog      
2007-08-27 04:42:29 UTC (rev 84864)
@@ -1,3 +1,12 @@
+2007-08-27  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * IPGlobalProperties.cs, TcpConnectionInformation.cs,
+         TcpStatistics.cs, IPGlobalStatistics.cs, IcmpV4Statistics.cs,
+         IcmpV6Statistics.cs, UdpStatistics.cs :
+         initial implementation of IPGlobalProperties and its children
+         for Win32 API, mostly done. Non-Windows implementation should
+         follow.
+
 2007-08-13  Alan McGovern  <[EMAIL PROTECTED]>
 
        * PhysicalAddress.cs: Added patch for #82403 to fix some parsing

Modified: 
trunk/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs
===================================================================
--- trunk/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs  
2007-08-27 00:41:16 UTC (rev 84863)
+++ trunk/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs  
2007-08-27 04:42:29 UTC (rev 84864)
@@ -1,10 +1,11 @@
 //
 // System.Net.NetworkInformation.IPGlobalProperties
 //
-// Author:
+// Authors:
 //     Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//     Atsushi Enomoto ([EMAIL PROTECTED])
 //
-// Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -26,16 +27,24 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 #if NET_2_0
+using System.Net.Sockets;
+using System.Runtime.InteropServices;
+
 namespace System.Net.NetworkInformation {
        public abstract class IPGlobalProperties {
                protected IPGlobalProperties ()
                {
                }
 
-               [MonoTODO]
+               [MonoTODO ("Unimplemented on non-Windows. A marshalling issue 
on Windows")]
                public static IPGlobalProperties GetIPGlobalProperties ()
                {
-                       throw new NotImplementedException ();
+                       switch (Environment.OSVersion.Platform) {
+                       case PlatformID.Unix:
+                               throw new NotImplementedException ();
+                       default:
+                               return new Win32IPGlobalProperties ();
+                       }
                }
 
                public abstract TcpConnectionInformation [] 
GetActiveTcpConnections ();
@@ -56,6 +65,347 @@
                public abstract bool IsWinsProxy { get; }
                public abstract NetBiosNodeType NodeType { get; }
        }
+
+       class Win32IPGlobalProperties : IPGlobalProperties
+       {
+               public const int AF_INET = 2;
+               public const int AF_INET6 = 23;
+
+               // FIXME: fails at some marshaling stage
+               void FillTcpTable (out Win32_MIB_TCPTABLE tab4, out 
Win32_MIB_TCP6TABLE tab6)
+               {
+                       tab4 = null;
+                       int size4 = 0;
+                       GetTcpTable (ref tab4, ref size4, false); // get size
+                       tab4 = new Win32_MIB_TCPTABLE (size4);
+                       GetTcpTable (ref tab4, ref size4, false); // get list
+                       tab6 = null;
+                       int size6 = 0;
+                       GetTcp6Table (ref tab6, ref size6, false); // get size
+                       tab6 = new Win32_MIB_TCP6TABLE (size6);
+                       GetTcp6Table (ref tab6, ref size6, false); // get list
+
+               }
+
+               public override TcpConnectionInformation [] 
GetActiveTcpConnections ()
+               {
+                       Win32_MIB_TCPTABLE tab4 = null;
+                       Win32_MIB_TCP6TABLE tab6 = null;
+                       FillTcpTable (out tab4, out tab6);
+                       int size4 = tab4.Table.Length;
+
+                       TcpConnectionInformation [] ret = new 
TcpConnectionInformation [size4 + tab6.Table.Length];
+                       for (int i = 0; i < size4; i++)
+                               ret [i] = tab4.Table [i].TcpInfo;
+                       for (int i = 0; i < tab6.Table.Length; i++)
+                               ret [size4 + i] = tab6.Table [i].TcpInfo;
+                       return ret;
+               }
+
+               public override IPEndPoint [] GetActiveTcpListeners ()
+               {
+                       Win32_MIB_TCPTABLE tab4 = null;
+                       Win32_MIB_TCP6TABLE tab6 = null;
+                       FillTcpTable (out tab4, out tab6);
+                       int size4 = tab4.Table.Length;
+
+                       IPEndPoint [] ret = new IPEndPoint [size4 + 
tab6.Table.Length];
+                       for (int i = 0; i < size4; i++)
+                               ret [i] = tab4.Table [i].LocalEndPoint;
+                       for (int i = 0; i < tab6.Table.Length; i++)
+                               ret [size4 + i] = tab6.Table [i].LocalEndPoint;
+                       return ret;
+               }
+
+               // FIXME: fails at some marshaling stage
+               public override IPEndPoint [] GetActiveUdpListeners ()
+               {
+                       Win32_MIB_UDPTABLE tab4 = null;
+                       int size4 = 0;
+                       GetUdpTable (ref tab4, ref size4, false); // get size
+                       tab4 = new Win32_MIB_UDPTABLE (size4);
+                       GetUdpTable (ref tab4, ref size4, false); // get list
+                       Win32_MIB_UDP6TABLE tab6 = null;
+                       int size6 = 0;
+                       GetUdp6Table (ref tab6, ref size6, false); // get size
+                       tab6 = new Win32_MIB_UDP6TABLE (size6);
+                       GetUdp6Table (ref tab6, ref size6, false); // get list
+
+                       IPEndPoint [] ret = new IPEndPoint [size4 + size6];
+                       for (int i = 0; i < size4; i++)
+                               ret [i] = tab4.Table [i].LocalEndPoint;
+                       for (int i = 0; i < size6; i++)
+                               ret [size4 + i] = tab6.Table [i].LocalEndPoint;
+                       return ret;
+               }
+
+               public override IcmpV4Statistics GetIcmpV4Statistics ()
+               {
+                       if (!Socket.SupportsIPv4)
+                               throw new NetworkInformationException ();
+                       Win32_MIBICMPINFO stats;
+                       GetIcmpStatistics (out stats, AF_INET);
+                       return new Win32IcmpV4Statistics (stats);
+               }
+
+               public override IcmpV6Statistics GetIcmpV6Statistics ()
+               {
+                       if (!Socket.OSSupportsIPv6)
+                               throw new NetworkInformationException ();
+                       Win32_MIB_ICMP_EX stats;
+                       GetIcmpStatisticsEx (out stats, AF_INET6);
+                       return new Win32IcmpV6Statistics (stats);
+               }
+
+               public override IPGlobalStatistics GetIPv4GlobalStatistics ()
+               {
+                       if (!Socket.SupportsIPv4)
+                               throw new NetworkInformationException ();
+                       Win32_MIB_IPSTATS stats;
+                       GetIPStatisticsEx (out stats, AF_INET);
+                       return new Win32IPGlobalStatistics (stats);
+               }
+
+               public override IPGlobalStatistics GetIPv6GlobalStatistics ()
+               {
+                       if (!Socket.OSSupportsIPv6)
+                               throw new NetworkInformationException ();
+                       Win32_MIB_IPSTATS stats;
+                       GetIPStatisticsEx (out stats, AF_INET6);
+                       return new Win32IPGlobalStatistics (stats);
+               }
+
+               public override TcpStatistics GetTcpIPv4Statistics ()
+               {
+                       if (!Socket.SupportsIPv4)
+                               throw new NetworkInformationException ();
+                       Win32_MIB_TCPSTATS stats;
+                       GetTcpStatisticsEx (out stats, AF_INET);
+                       return new Win32TcpStatistics (stats);
+               }
+
+               public override TcpStatistics GetTcpIPv6Statistics ()
+               {
+                       if (!Socket.OSSupportsIPv6)
+                               throw new NetworkInformationException ();
+                       Win32_MIB_TCPSTATS stats;
+                       GetTcpStatisticsEx (out stats, AF_INET6);
+                       return new Win32TcpStatistics (stats);
+               }
+
+               public override UdpStatistics GetUdpIPv4Statistics ()
+               {
+                       if (!Socket.SupportsIPv4)
+                               throw new NetworkInformationException ();
+                       Win32_MIB_UDPSTATS stats;
+                       GetUdpStatisticsEx (out stats, AF_INET);
+                       return new Win32UdpStatistics (stats);
+               }
+
+               public override UdpStatistics GetUdpIPv6Statistics ()
+               {
+                       if (!Socket.OSSupportsIPv6)
+                               throw new NetworkInformationException ();
+                       Win32_MIB_UDPSTATS stats;
+                       GetUdpStatisticsEx (out stats, AF_INET6);
+                       return new Win32UdpStatistics (stats);
+               }
+
+               public override string DhcpScopeName {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public override string DomainName {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public override string HostName {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public override bool IsWinsProxy {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public override NetBiosNodeType NodeType {
+                       get { throw new NotImplementedException (); }
+               }
+
+               // PInvokes
+
+               [DllImport ("Iphlpapi.dll")]
+               static extern int GetTcpTable (ref Win32_MIB_TCPTABLE 
pTcpTable, ref int pdwSize, bool bOrder);
+
+               [DllImport ("Iphlpapi.dll")]
+               static extern int GetTcp6Table (ref Win32_MIB_TCP6TABLE 
TcpTable, ref int SizePointer, bool Order);
+
+               [DllImport ("Iphlpapi.dll")]
+               static extern int GetUdpTable (ref Win32_MIB_UDPTABLE 
pUdpTable, ref int pdwSize, bool bOrder);
+
+               [DllImport ("Iphlpapi.dll")]
+               static extern int GetUdp6Table (ref Win32_MIB_UDP6TABLE 
Udp6Table, ref int SizePointer, bool Order);
+
+               [DllImport ("Iphlpapi.dll")]
+               static extern int GetTcpStatisticsEx (out Win32_MIB_TCPSTATS 
pStats, int dwFamily);
+
+               [DllImport ("Iphlpapi.dll")]
+               static extern int GetUdpStatisticsEx (out Win32_MIB_UDPSTATS 
pStats, int dwFamily);
+
+               [DllImport ("Iphlpapi.dll")]
+               static extern int GetIcmpStatistics (out Win32_MIBICMPINFO 
pStats, int dwFamily);
+
+               [DllImport ("Iphlpapi.dll")]
+               static extern int GetIcmpStatisticsEx (out Win32_MIB_ICMP_EX 
pStats, int dwFamily);
+
+               [DllImport ("Iphlpapi.dll")]
+               static extern int GetIPStatisticsEx (out Win32_MIB_IPSTATS 
pStats, int dwFamily);
+
+               // Win32 structures
+
+               [StructLayout (LayoutKind.Explicit)]
+               struct Win32_IN6_ADDR
+               {
+                       [FieldOffset (0)]
+                       [MarshalAs ((short) UnmanagedType.U1, SizeConst = 16)]
+                       public byte [] Bytes;
+                       [FieldOffset (0)]
+                       [MarshalAs ((short) UnmanagedType.U2, SizeConst = 8)]
+                       public byte [] UInt16Array;
+                       [FieldOffset (0)]
+                       [MarshalAs ((short) UnmanagedType.U4, SizeConst = 4)]
+                       public byte [] UInt32Array;
+               }
+
+               [StructLayout (LayoutKind.Sequential)]
+               class Win32_MIB_TCPTABLE
+               {
+                       public int NumEntries;
+                       // FIXME: looks like it is wrong
+                       [MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = 
VarEnum.VT_USERDEFINED, SafeArrayUserDefinedSubType = typeof 
(Win32_MIB_TCPROW))]
+                       public Win32_MIB_TCPROW [] Table;
+
+                       public Win32_MIB_TCPTABLE (int size)
+                       {
+                               NumEntries = size;
+                               Table = new Win32_MIB_TCPROW [size];
+                       }
+               }
+
+               [StructLayout (LayoutKind.Sequential)]
+               struct Win32_MIB_TCPROW
+               {
+                       public TcpState State;
+                       public uint LocalAddr;
+                       public int LocalPort;
+                       public uint RemoteAddr;
+                       public int RemotePort;
+
+                       public IPEndPoint LocalEndPoint {
+                               get { return new IPEndPoint (LocalAddr, 
LocalPort); }
+                       }
+
+                       public IPEndPoint RemoteEndPoint {
+                               get { return new IPEndPoint (RemoteAddr, 
RemotePort); }
+                       }
+
+                       public TcpConnectionInformation TcpInfo {
+                               get { return new TcpConnectionInformationImpl 
(LocalEndPoint, RemoteEndPoint, State); }
+                       }
+               }
+
+               [StructLayout (LayoutKind.Sequential)]
+               class Win32_MIB_TCP6TABLE
+               {
+                       public int NumEntries;
+                       // FIXME: looks like it is wrong
+                       [MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = 
VarEnum.VT_USERDEFINED, SafeArrayUserDefinedSubType = typeof 
(Win32_MIB_TCP6ROW))]
+                       public Win32_MIB_TCP6ROW [] Table;
+
+                       public Win32_MIB_TCP6TABLE (int size)
+                       {
+                               NumEntries = size;
+                               Table = new Win32_MIB_TCP6ROW [size];
+                       }
+               }
+
+               [StructLayout (LayoutKind.Sequential)]
+               struct Win32_MIB_TCP6ROW
+               {
+                       public TcpState State;
+                       public Win32_IN6_ADDR LocalAddr;
+                       public uint LocalScopeId;
+                       public int LocalPort;
+                       public Win32_IN6_ADDR RemoteAddr;
+                       public uint RemoteScopeId;
+                       public int RemotePort;
+
+                       public IPEndPoint LocalEndPoint {
+                               get { return new IPEndPoint (new IPAddress 
(LocalAddr.Bytes, LocalScopeId), LocalPort); }
+                       }
+
+                       public IPEndPoint RemoteEndPoint {
+                               get { return new IPEndPoint (new IPAddress 
(RemoteAddr.Bytes, RemoteScopeId), RemotePort); }
+                       }
+
+                       public TcpConnectionInformation TcpInfo {
+                               get { return new TcpConnectionInformationImpl 
(LocalEndPoint, RemoteEndPoint, State); }
+                       }
+               }
+
+               [StructLayout (LayoutKind.Sequential)]
+               class Win32_MIB_UDPTABLE
+               {
+                       public int NumEntries;
+                       // FIXME: looks like it is wrong
+                       [MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = 
VarEnum.VT_USERDEFINED, SafeArrayUserDefinedSubType = typeof 
(Win32_MIB_UDPROW))]
+                       public Win32_MIB_UDPROW [] Table;
+
+                       public Win32_MIB_UDPTABLE (int size)
+                       {
+                               NumEntries = size;
+                               Table = new Win32_MIB_UDPROW [size];
+                       }
+               }
+
+               [StructLayout (LayoutKind.Sequential)]
+               struct Win32_MIB_UDPROW
+               {
+                       public uint LocalAddr;
+                       public int LocalPort;
+
+                       public IPEndPoint LocalEndPoint {
+                               get { return new IPEndPoint (LocalAddr, 
LocalPort); }
+                       }
+               }
+
+               [StructLayout (LayoutKind.Sequential)]
+               class Win32_MIB_UDP6TABLE
+               {
+                       public int NumEntries;
+                       // FIXME: looks like it is wrong
+                       [MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = 
VarEnum.VT_USERDEFINED, SafeArrayUserDefinedSubType = typeof 
(Win32_MIB_UDP6ROW))]
+                       public Win32_MIB_UDP6ROW [] Table;
+
+                       public Win32_MIB_UDP6TABLE (int size)
+                       {
+                               NumEntries = size;
+                               Table = new Win32_MIB_UDP6ROW [size];
+                       }
+               }
+
+               [StructLayout (LayoutKind.Sequential)]
+               struct Win32_MIB_UDP6ROW
+               {
+                       public Win32_IN6_ADDR LocalAddr;
+                       public uint LocalScopeId;
+                       public int LocalPort;
+
+                       public IPEndPoint LocalEndPoint {
+                               get { return new IPEndPoint (new IPAddress 
(LocalAddr.Bytes, LocalScopeId), LocalPort); }
+                       }
+               }
+
+       }
 }
 #endif
 

Modified: 
trunk/mcs/class/System/System.Net.NetworkInformation/IPGlobalStatistics.cs
===================================================================
--- trunk/mcs/class/System/System.Net.NetworkInformation/IPGlobalStatistics.cs  
2007-08-27 00:41:16 UTC (rev 84863)
+++ trunk/mcs/class/System/System.Net.NetworkInformation/IPGlobalStatistics.cs  
2007-08-27 04:42:29 UTC (rev 84864)
@@ -1,10 +1,11 @@
 //
 // System.Net.NetworkInformation.IPGlobalProperties
 //
-// Author:
+// Authors:
 //     Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//     Atsushi Enomoto ([EMAIL PROTECTED])
 //
-// Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -55,6 +56,110 @@
                public abstract long ReceivedPacketsWithHeadersErrors { get; }
                public abstract long ReceivedPacketsWithUnknownProtocol { get; }
        }
+
+       class Win32IPGlobalStatistics : IPGlobalStatistics 
+       {
+               Win32_MIB_IPSTATS info;
+
+               public Win32IPGlobalStatistics (Win32_MIB_IPSTATS info)
+               {
+                       this.info = info;
+               }
+
+               public override int DefaultTtl {
+                       get { return info.DefaultTTL; }
+               }
+               public override bool ForwardingEnabled {
+                       get { return info.Forwarding != 0; }
+               }
+               public override int NumberOfInterfaces {
+                       get { return info.NumIf; }
+               }
+               public override int NumberOfIPAddresses {
+                       get { return info.NumAddr; }
+               }
+               public override int NumberOfRoutes {
+                       get { return info.NumRoutes; }
+               }
+               public override long OutputPacketRequests {
+                       get { return info.OutRequests; }
+               }
+               public override long OutputPacketRoutingDiscards {
+                       get { return info.RoutingDiscards; }
+               }
+               public override long OutputPacketsDiscarded {
+                       get { return info.OutDiscards; }
+               }
+               public override long OutputPacketsWithNoRoute {
+                       get { return info.OutNoRoutes; }
+               }
+               public override long PacketFragmentFailures {
+                       get { return info.FragFails; }
+               }
+               public override long PacketReassembliesRequired {
+                       get { return info.ReasmReqds; }
+               }
+               public override long PacketReassemblyFailures {
+                       get { return info.ReasmFails; }
+               }
+               public override long PacketReassemblyTimeout {
+                       get { return info.ReasmTimeout; }
+               }
+               public override long PacketsFragmented {
+                       get { return info.FragOks; }
+               }
+               public override long PacketsReassembled {
+                       get { return info.ReasmOks; }
+               }
+               public override long ReceivedPackets {
+                       get { return info.InReceives; }
+               }
+               public override long ReceivedPacketsDelivered {
+                       get { return info.InDelivers; }
+               }
+               public override long ReceivedPacketsDiscarded {
+                       get { return info.InDiscards; }
+               }
+               public override long ReceivedPacketsForwarded {
+                       get { return info.ForwDatagrams; }
+               }
+               public override long ReceivedPacketsWithAddressErrors {
+                       get { return info.InAddrErrors; }
+               }
+               public override long ReceivedPacketsWithHeadersErrors {
+                       get { return info.InHdrErrors; }
+               }
+               public override long ReceivedPacketsWithUnknownProtocol {
+                       get { return info.InUnknownProtos; }
+               }
+       }
+
+       struct Win32_MIB_IPSTATS
+       {
+               public int Forwarding;
+               public int DefaultTTL;
+               public uint InReceives;
+               public uint InHdrErrors;
+               public uint InAddrErrors;
+               public uint ForwDatagrams;
+               public uint InUnknownProtos;
+               public uint InDiscards;
+               public uint InDelivers;
+               public uint OutRequests;
+               public uint RoutingDiscards;
+               public uint OutDiscards;
+               public uint OutNoRoutes;
+               public uint ReasmTimeout;
+               public uint ReasmReqds;
+               public uint ReasmOks;
+               public uint ReasmFails;
+               public uint FragOks;
+               public uint FragFails;
+               public uint FragCreates;
+               public int NumIf;
+               public int NumAddr;
+               public int NumRoutes;
+       }
 }
 #endif
 

Modified: 
trunk/mcs/class/System/System.Net.NetworkInformation/IcmpV4Statistics.cs
===================================================================
--- trunk/mcs/class/System/System.Net.NetworkInformation/IcmpV4Statistics.cs    
2007-08-27 00:41:16 UTC (rev 84863)
+++ trunk/mcs/class/System/System.Net.NetworkInformation/IcmpV4Statistics.cs    
2007-08-27 04:42:29 UTC (rev 84864)
@@ -1,10 +1,11 @@
 //
 // System.Net.NetworkInformation.IcmpV4Statistics
 //
-// Author:
+// Authors:
 //     Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//     Atsushi Enomoto ([EMAIL PROTECTED])
 //
-// Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -59,6 +60,119 @@
                public abstract long TimestampRequestsReceived { get; }
                public abstract long TimestampRequestsSent { get; }
        }
+
+       class Win32IcmpV4Statistics : IcmpV4Statistics
+       {
+               Win32_MIBICMPSTATS iin, iout;
+
+               public Win32IcmpV4Statistics (Win32_MIBICMPINFO info)
+               {
+                       iin = info.InStats;
+                       iout = info.OutStats;
+               }
+
+               public override long AddressMaskRepliesReceived {
+                       get { return iin.AddrMaskReps; }
+               }
+               public override long AddressMaskRepliesSent {
+                       get { return iout.AddrMaskReps; }
+               }
+               public override long AddressMaskRequestsReceived {
+                       get { return iin.AddrMasks; }
+               }
+               public override long AddressMaskRequestsSent {
+                       get { return iout.AddrMasks; }
+               }
+               public override long DestinationUnreachableMessagesReceived {
+                       get { return iin.DestUnreachs; }
+               }
+               public override long DestinationUnreachableMessagesSent {
+                       get { return iout.DestUnreachs; }
+               }
+               public override long EchoRepliesReceived {
+                       get { return iin.EchoReps; }
+               }
+               public override long EchoRepliesSent {
+                       get { return iout.EchoReps; }
+               }
+               public override long EchoRequestsReceived {
+                       get { return iin.Echos; }
+               }
+               public override long EchoRequestsSent {
+                       get { return iout.Echos; }
+               }
+               public override long ErrorsReceived {
+                       get { return iin.Errors; }
+               }
+               public override long ErrorsSent {
+                       get { return iout.Errors; }
+               }
+               public override long MessagesReceived {
+                       get { return iin.Msgs; }
+               }
+               public override long MessagesSent {
+                       get { return iout.Msgs; }
+               }
+               public override long ParameterProblemsReceived {
+                       get { return iin.ParmProbs; }
+               }
+               public override long ParameterProblemsSent {
+                       get { return iout.ParmProbs; }
+               }
+               public override long RedirectsReceived {
+                       get { return iin.Redirects; }
+               }
+               public override long RedirectsSent {
+                       get { return iout.Redirects; }
+               }
+               public override long SourceQuenchesReceived {
+                       get { return iin.SrcQuenchs; }
+               }
+               public override long SourceQuenchesSent {
+                       get { return iout.SrcQuenchs; }
+               }
+               public override long TimeExceededMessagesReceived {
+                       get { return iin.TimeExcds; }
+               }
+               public override long TimeExceededMessagesSent {
+                       get { return iout.TimeExcds; }
+               }
+               public override long TimestampRepliesReceived {
+                       get { return iin.TimestampReps; }
+               }
+               public override long TimestampRepliesSent {
+                       get { return iout.TimestampReps; }
+               }
+               public override long TimestampRequestsReceived {
+                       get { return iin.Timestamps; }
+               }
+               public override long TimestampRequestsSent {
+                       get { return iout.Timestamps; }
+               }
+       }
+
+       struct Win32_MIBICMPINFO
+       {
+               public Win32_MIBICMPSTATS InStats;
+               public Win32_MIBICMPSTATS OutStats;
+       }
+
+       struct Win32_MIBICMPSTATS
+       {
+               public uint Msgs;
+               public uint Errors;
+               public uint DestUnreachs;
+               public uint TimeExcds;
+               public uint ParmProbs;
+               public uint SrcQuenchs;
+               public uint Redirects;
+               public uint Echos;
+               public uint EchoReps;
+               public uint Timestamps;
+               public uint TimestampReps;
+               public uint AddrMasks;
+               public uint AddrMaskReps;
+       }
 }
 #endif
 

Modified: 
trunk/mcs/class/System/System.Net.NetworkInformation/IcmpV6Statistics.cs
===================================================================
--- trunk/mcs/class/System/System.Net.NetworkInformation/IcmpV6Statistics.cs    
2007-08-27 00:41:16 UTC (rev 84863)
+++ trunk/mcs/class/System/System.Net.NetworkInformation/IcmpV6Statistics.cs    
2007-08-27 04:42:29 UTC (rev 84864)
@@ -1,10 +1,11 @@
 //
 // System.Net.NetworkInformation.IcmpV6Statistics
 //
-// Author:
+// Authors:
 //     Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//     Atsushi Enomoto ([EMAIL PROTECTED])
 //
-// Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -26,6 +27,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 #if NET_2_0
+using System.Runtime.InteropServices;
+
 namespace System.Net.NetworkInformation {
        public abstract class IcmpV6Statistics {
                protected IcmpV6Statistics ()
@@ -65,6 +68,147 @@
                public abstract long TimeExceededMessagesReceived { get; }
                public abstract long TimeExceededMessagesSent { get; }
        }
+
+       class IcmpV6MessageTypes
+       {
+               public const int DestinationUnreachable = 1;
+               public const int PacketTooBig = 2;
+               public const int TimeExceeded = 3;
+               public const int ParameterProblem = 4;
+               public const int EchoRequest = 128;
+               public const int EchoReply = 129;
+               public const int GroupMembershipQuery = 130;
+               public const int GroupMembershipReport = 131;
+               public const int GroupMembershipReduction = 132;
+               public const int RouterSolicitation = 133;
+               public const int RouterAdvertisement = 134;
+               public const int NeighborSolicitation = 135;
+               public const int NeighborAdvertisement = 136;
+               public const int Redirect = 137;
+               public const int RouterRenumbering = 138;
+       }
+
+       class Win32IcmpV6Statistics : IcmpV6Statistics
+       {
+               Win32_MIBICMPSTATS_EX iin, iout;
+
+               public Win32IcmpV6Statistics (Win32_MIB_ICMP_EX info)
+               {
+                       iin = info.InStats;
+                       iout = info.OutStats;
+               }
+
+               public override long DestinationUnreachableMessagesReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.DestinationUnreachable]; }
+               }
+               public override long DestinationUnreachableMessagesSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.DestinationUnreachable]; }
+               }
+               public override long EchoRepliesReceived {
+                       get { return iin.Counts [IcmpV6MessageTypes.EchoReply]; 
}
+               }
+               public override long EchoRepliesSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.EchoReply]; }
+               }
+               public override long EchoRequestsReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.EchoRequest]; }
+               }
+               public override long EchoRequestsSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.EchoRequest]; }
+               }
+               public override long ErrorsReceived {
+                       get { return iin.Errors; }
+               }
+               public override long ErrorsSent {
+                       get { return iout.Errors; }
+               }
+               public override long MembershipQueriesReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.GroupMembershipQuery]; }
+               }
+               public override long MembershipQueriesSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.GroupMembershipQuery]; }
+               }
+               public override long MembershipReductionsReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.GroupMembershipReduction]; }
+               }
+               public override long MembershipReductionsSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.GroupMembershipReduction]; }
+               }
+               public override long MembershipReportsReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.GroupMembershipReport]; }
+               }
+               public override long MembershipReportsSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.GroupMembershipReport]; }
+               }
+               public override long MessagesReceived {
+                       get { return iin.Msgs; }
+               }
+               public override long MessagesSent {
+                       get { return iout.Msgs; }
+               }
+               public override long NeighborAdvertisementsReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.NeighborAdvertisement]; }
+               }
+               public override long NeighborAdvertisementsSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.NeighborAdvertisement]; }
+               }
+               public override long NeighborSolicitsReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.NeighborSolicitation]; }
+               }
+               public override long NeighborSolicitsSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.NeighborSolicitation]; }
+               }
+               public override long PacketTooBigMessagesReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.PacketTooBig]; }
+               }
+               public override long PacketTooBigMessagesSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.PacketTooBig]; }
+               }
+               public override long ParameterProblemsReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.ParameterProblem]; }
+               }
+               public override long ParameterProblemsSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.ParameterProblem]; }
+               }
+               public override long RedirectsReceived {
+                       get { return iin.Counts [IcmpV6MessageTypes.Redirect]; }
+               }
+               public override long RedirectsSent {
+                       get { return iout.Counts [IcmpV6MessageTypes.Redirect]; 
}
+               }
+               public override long RouterAdvertisementsReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.RouterAdvertisement]; }
+               }
+               public override long RouterAdvertisementsSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.RouterAdvertisement]; }
+               }
+               public override long RouterSolicitsReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.RouterSolicitation]; }
+               }
+               public override long RouterSolicitsSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.RouterSolicitation]; }
+               }
+               public override long TimeExceededMessagesReceived {
+                       get { return iin.Counts 
[IcmpV6MessageTypes.TimeExceeded]; }
+               }
+               public override long TimeExceededMessagesSent {
+                       get { return iout.Counts 
[IcmpV6MessageTypes.TimeExceeded]; }
+               }
+       }
+
+       struct Win32_MIB_ICMP_EX
+       {
+               public Win32_MIBICMPSTATS_EX InStats;
+               public Win32_MIBICMPSTATS_EX OutStats;
+       }
+
+       struct Win32_MIBICMPSTATS_EX
+       {
+               public uint Msgs;
+               public uint Errors;
+               [MarshalAs (UnmanagedType.ByValArray, SizeConst = 256)]
+               public uint [] Counts;
+       }
 }
 #endif
 

Modified: 
trunk/mcs/class/System/System.Net.NetworkInformation/TcpConnectionInformation.cs
===================================================================
--- 
trunk/mcs/class/System/System.Net.NetworkInformation/TcpConnectionInformation.cs
    2007-08-27 00:41:16 UTC (rev 84863)
+++ 
trunk/mcs/class/System/System.Net.NetworkInformation/TcpConnectionInformation.cs
    2007-08-27 04:42:29 UTC (rev 84864)
@@ -1,10 +1,11 @@
 //
 // System.Net.NetworkInformation.TcpConnectionInformation
 //
-// Author:
+// Authors:
 //     Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//     Atsushi Enomoto ([EMAIL PROTECTED])
 //
-// Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -38,6 +39,30 @@
                public abstract IPEndPoint RemoteEndPoint { get; }
                public abstract TcpState State { get; }
        }
+
+       class TcpConnectionInformationImpl : TcpConnectionInformation
+       {
+               IPEndPoint local;
+               IPEndPoint remote;
+               TcpState state;
+
+               public TcpConnectionInformationImpl (IPEndPoint local, 
IPEndPoint remote, TcpState state)
+               {
+                       this.local = local;
+                       this.remote = remote;
+                       this.state = state;
+               }
+
+               public override IPEndPoint LocalEndPoint {
+                       get { return local; }
+               }
+               public override IPEndPoint RemoteEndPoint {
+                       get { return remote; }
+               }
+               public override TcpState State {
+                       get { return state; }
+               }
+       }
 }
 #endif
 

Modified: trunk/mcs/class/System/System.Net.NetworkInformation/TcpStatistics.cs
===================================================================
--- trunk/mcs/class/System/System.Net.NetworkInformation/TcpStatistics.cs       
2007-08-27 00:41:16 UTC (rev 84863)
+++ trunk/mcs/class/System/System.Net.NetworkInformation/TcpStatistics.cs       
2007-08-27 04:42:29 UTC (rev 84864)
@@ -1,10 +1,11 @@
 //
 // System.Net.NetworkInformation.TcpStatistics
 //
-// Author:
+// Authors:
 //     Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//     Atsushi Enomoto ([EMAIL PROTECTED])
 //
-// Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -47,6 +48,92 @@
                public abstract long SegmentsResent { get; }
                public abstract long SegmentsSent { get; }
        }
+
+       class Win32TcpStatistics : TcpStatistics
+       {
+               Win32_MIB_TCPSTATS info;
+
+               public Win32TcpStatistics (Win32_MIB_TCPSTATS info)
+               {
+                       this.info = info;
+               }
+
+               public override long ConnectionsAccepted {
+                       get { return info.PassiveOpens; }
+               }
+
+               public override long ConnectionsInitiated {
+                       get { return info.ActiveOpens; }
+               }
+
+               public override long CumulativeConnections {
+                       get { return info.NumConns; }
+               }
+
+               public override long CurrentConnections {
+                       get { return info.CurrEstab; }
+               }
+
+               public override long ErrorsReceived {
+                       get { return info.InErrs; }
+               }
+
+               public override long FailedConnectionAttempts {
+                       get { return info.AttemptFails; }
+               }
+
+               public override long MaximumConnections {
+                       get { return info.MaxConn; }
+               }
+
+               public override long MaximumTransmissionTimeout {
+                       get { return info.RtoMax; }
+               }
+
+               public override long MinimumTransmissionTimeout {
+                       get { return info.RtoMin; }
+               }
+
+               public override long ResetConnections {
+                       get { return info.EstabResets; }
+               }
+
+               public override long ResetsSent {
+                       get { return info.OutRsts; }
+               }
+
+               public override long SegmentsReceived {
+                       get { return info.InSegs; }
+               }
+
+               public override long SegmentsResent {
+                       get { return info.RetransSegs; }
+               }
+
+               public override long SegmentsSent {
+                       get { return info.OutSegs; }
+               }
+       }
+
+       struct Win32_MIB_TCPSTATS
+       {
+               public uint RtoAlgorithm;
+               public uint RtoMin;
+               public uint RtoMax;
+               public uint MaxConn;
+               public uint ActiveOpens;
+               public uint PassiveOpens;
+               public uint AttemptFails;
+               public uint EstabResets;
+               public uint CurrEstab;
+               public uint InSegs;
+               public uint OutSegs;
+               public uint RetransSegs;
+               public uint InErrs;
+               public uint OutRsts;
+               public uint NumConns;
+       }
+
 }
 #endif
 

Modified: trunk/mcs/class/System/System.Net.NetworkInformation/UdpStatistics.cs
===================================================================
--- trunk/mcs/class/System/System.Net.NetworkInformation/UdpStatistics.cs       
2007-08-27 00:41:16 UTC (rev 84863)
+++ trunk/mcs/class/System/System.Net.NetworkInformation/UdpStatistics.cs       
2007-08-27 04:42:29 UTC (rev 84864)
@@ -1,10 +1,11 @@
 //
 // System.Net.NetworkInformation.UdpStatistics
 //
-// Author:
+// Authors:
 //     Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//     Atsushi Enomoto ([EMAIL PROTECTED])
 //
-// Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2006-2007 Novell, Inc. (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -38,6 +39,45 @@
                public abstract long IncomingDatagramsWithErrors { get; }
                public abstract int UdpListeners { get; }
        }
+
+       class Win32UdpStatistics : UdpStatistics
+       {
+               Win32_MIB_UDPSTATS info;
+
+               public Win32UdpStatistics (Win32_MIB_UDPSTATS info)
+               {
+                       this.info = info;
+               }
+
+               public override long DatagramsReceived {
+                       get { return info.InDatagrams; }
+               }
+
+               public override long DatagramsSent {
+                       get { return info.OutDatagrams; }
+               }
+
+               public override long IncomingDatagramsDiscarded {
+                       get { return info.NoPorts; }
+               }
+
+               public override long IncomingDatagramsWithErrors {
+                       get { return info.InErrors; }
+               }
+
+               public override int UdpListeners {
+                       get { return info.NumAddrs; }
+               }
+       }
+
+       struct Win32_MIB_UDPSTATS
+       {
+               public uint InDatagrams;
+               public uint NoPorts;
+               public uint InErrors;
+               public uint OutDatagrams;
+               public int NumAddrs;
+       }
 }
 #endif
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to