示例#1
0
        /// <summary>
        /// Provides Internet Protocol version 4 (IPv4) statistical data for the local
        /// computer.
        /// </summary>
        /// <returns>
        /// An OpenNETCF.Net.NetworkInformation.IPGlobalStatistics object that provides
        /// IPv4 traffic statistics for the local computer.
        /// </returns>
        /// <exception cref="OpenNETCF.Net.NetworkInformation">The call to the Win32 function GetIpStatistics failed.</exception>
        public IPGlobalStatistics GetIPv4GlobalStatistics()
        {
            MibIpStats stats     = new MibIpStats();
            int        errorCode = NativeMethods.GetIpStatisticsEx(out stats, System.Net.Sockets.AddressFamily.InterNetwork);

            if (errorCode != NativeMethods.NO_ERROR)
            {
                throw new NetworkInformationException(errorCode);
            }

            return(new IPGlobalStatistics(stats));
        }
示例#2
0
        /// <summary>
        /// Provides Internet Protocol version 6 (IPv6) statistical data for the local
        ///  computer.
        /// </summary>
        /// <returns>
        /// An OpenNETCF.Net.NetworkInformation.IPGlobalStatistics object that provides
        /// IPv6 traffic statistics for the local computer.
        /// </returns>
        /// <exception cref="OpenNETCF.Net.NetworkInformation.NetworkInformationException">The call to the Win32 function GetIpStatistics failed.</exception>
        /// <exception cref="System.PlatformNotSupportedException">The local computer is not running an operating system that supports IPv6.</exception>
        public IPGlobalStatistics GetIPv6GlobalStatistics()
        {
            MibIpStats stats     = new MibIpStats();
            int        errorCode = NativeMethods.GetIpStatisticsEx(out stats, System.Net.Sockets.AddressFamily.InterNetworkV6);

            if (errorCode == NativeMethods.NOT_SUPPORTED)
            {
                throw new System.PlatformNotSupportedException("The local device does not support IPv6");
            }

            if (errorCode != NativeMethods.NO_ERROR)
            {
                throw new NetworkInformationException(errorCode);
            }

            return(new IPGlobalStatistics(stats));
        }
示例#3
0
 internal static extern int GetIpStatisticsEx(out MibIpStats stats, AddressFamily dwFamily);
示例#4
0
 internal static extern int SetIpStatistics(ref MibIpStats stats);
 /// <summary>
 /// Initializes a new instance of the System.Net.NetworkInformation.IPGlobalStatistics
 /// class.
 /// </summary>
 /// <param name="stats"></param>
 internal IPGlobalStatistics(MibIpStats stats)
 {
     m_stats = stats;
 }