Inheritance: IPGlobalProperties
コード例 #1
0
        public override UdpStatistics GetUdpIPv6Statistics()
        {
            if (!System.Net.Sockets.Socket.OSSupportsIPv6)
            {
                throw new NetworkInformationException();
            }
            Win32_MIB_UDPSTATS info;

            Win32IPGlobalProperties.GetUdpStatisticsEx(out info, 23);
            return(new Win32UdpStatistics(info));
        }
コード例 #2
0
        public override TcpStatistics GetTcpIPv4Statistics()
        {
            if (!System.Net.Sockets.Socket.SupportsIPv4)
            {
                throw new NetworkInformationException();
            }
            Win32_MIB_TCPSTATS info;

            Win32IPGlobalProperties.GetTcpStatisticsEx(out info, 2);
            return(new Win32TcpStatistics(info));
        }
コード例 #3
0
        public override IcmpV4Statistics GetIcmpV4Statistics()
        {
            if (!System.Net.Sockets.Socket.SupportsIPv4)
            {
                throw new NetworkInformationException();
            }
            Win32_MIBICMPINFO info;

            Win32IPGlobalProperties.GetIcmpStatistics(out info, 2);
            return(new Win32IcmpV4Statistics(info));
        }
コード例 #4
0
        private unsafe void FillTcpTable(out List <Win32IPGlobalProperties.Win32_MIB_TCPROW> tab4, out List <Win32IPGlobalProperties.Win32_MIB_TCP6ROW> tab6)
        {
            tab4 = new List <Win32IPGlobalProperties.Win32_MIB_TCPROW>();
            int num = 0;

            Win32IPGlobalProperties.GetTcpTable(null, ref num, true);
            byte[] array = new byte[num];
            Win32IPGlobalProperties.GetTcpTable(array, ref num, true);
            int num2 = Marshal.SizeOf(typeof(Win32IPGlobalProperties.Win32_MIB_TCPROW));

            fixed(byte *ptr = ref (array != null && array.Length != 0)?ref array[0] : ref *null)
            {
                int num3 = Marshal.ReadInt32((IntPtr)((void *)ptr));

                for (int i = 0; i < num3; i++)
                {
                    Win32IPGlobalProperties.Win32_MIB_TCPROW win32_MIB_TCPROW = new Win32IPGlobalProperties.Win32_MIB_TCPROW();
                    Marshal.PtrToStructure((IntPtr)((void *)(ptr + i * num2 + 4)), win32_MIB_TCPROW);
                    tab4.Add(win32_MIB_TCPROW);
                }
            }

            tab6 = new List <Win32IPGlobalProperties.Win32_MIB_TCP6ROW>();
            if (Environment.OSVersion.Version.Major >= 6)
            {
                int num4 = 0;
                Win32IPGlobalProperties.GetTcp6Table(null, ref num4, true);
                byte[] array2 = new byte[num4];
                Win32IPGlobalProperties.GetTcp6Table(array2, ref num4, true);
                int num5 = Marshal.SizeOf(typeof(Win32IPGlobalProperties.Win32_MIB_TCP6ROW));
                fixed(byte *ptr2 = ref (array2 != null && array2.Length != 0)?ref array2[0] : ref *null)
                {
                    int num6 = Marshal.ReadInt32((IntPtr)((void *)ptr2));

                    for (int j = 0; j < num6; j++)
                    {
                        Win32IPGlobalProperties.Win32_MIB_TCP6ROW win32_MIB_TCP6ROW = new Win32IPGlobalProperties.Win32_MIB_TCP6ROW();
                        Marshal.PtrToStructure((IntPtr)((void *)(ptr2 + j * num5 + 4)), win32_MIB_TCP6ROW);
                        tab6.Add(win32_MIB_TCP6ROW);
                    }
                }
            }
        }
コード例 #5
0
        public unsafe override IPEndPoint[] GetActiveUdpListeners()
        {
            List <IPEndPoint> list = new List <IPEndPoint>();
            int num = 0;

            Win32IPGlobalProperties.GetUdpTable(null, ref num, true);
            byte[] array = new byte[num];
            Win32IPGlobalProperties.GetUdpTable(array, ref num, true);
            int num2 = Marshal.SizeOf(typeof(Win32IPGlobalProperties.Win32_MIB_UDPROW));

            fixed(byte *ptr = ref (array != null && array.Length != 0)?ref array[0] : ref *null)
            {
                int num3 = Marshal.ReadInt32((IntPtr)((void *)ptr));

                for (int i = 0; i < num3; i++)
                {
                    Win32IPGlobalProperties.Win32_MIB_UDPROW win32_MIB_UDPROW = new Win32IPGlobalProperties.Win32_MIB_UDPROW();
                    Marshal.PtrToStructure((IntPtr)((void *)(ptr + i * num2 + 4)), win32_MIB_UDPROW);
                    list.Add(win32_MIB_UDPROW.LocalEndPoint);
                }
            }

            if (Environment.OSVersion.Version.Major >= 6)
            {
                int num4 = 0;
                Win32IPGlobalProperties.GetUdp6Table(null, ref num4, true);
                byte[] array2 = new byte[num4];
                Win32IPGlobalProperties.GetUdp6Table(array2, ref num4, true);
                int num5 = Marshal.SizeOf(typeof(Win32IPGlobalProperties.Win32_MIB_UDP6ROW));
                fixed(byte *ptr2 = ref (array2 != null && array2.Length != 0)?ref array2[0] : ref *null)
                {
                    int num6 = Marshal.ReadInt32((IntPtr)((void *)ptr2));

                    for (int j = 0; j < num6; j++)
                    {
                        Win32IPGlobalProperties.Win32_MIB_UDP6ROW win32_MIB_UDP6ROW = new Win32IPGlobalProperties.Win32_MIB_UDP6ROW();
                        Marshal.PtrToStructure((IntPtr)((void *)(ptr2 + j * num5 + 4)), win32_MIB_UDP6ROW);
                        list.Add(win32_MIB_UDP6ROW.LocalEndPoint);
                    }
                }
            }
            return(list.ToArray());
        }