Пример #1
0
        private string inet_ntoa(NetAddress address)
        {
            IntPtr        num      = Marshal.AllocHGlobal(Marshal.SizeOf((object)address));
            StringBuilder addr_str = new StringBuilder();

            addr_str.Capacity = 46;
            Marshal.StructureToPtr((object)address, num, true);
            NetInterfaceConfig.sigar_net_address_to_string(IntPtr.Zero, num, addr_str);
            return(addr_str.ToString());
        }
Пример #2
0
        internal static NetInterfaceConfig NativeGet(Hyperic.Sigar.Sigar sigar, string name)
        {
            System.Type type  = typeof(NetInterfaceConfig);
            IntPtr      num   = Marshal.AllocHGlobal(Marshal.SizeOf(type));
            int         errno = NetInterfaceConfig.sigar_net_interface_config_get(sigar.sigar.Handle, name, num);

            if (errno != 0)
            {
                Marshal.FreeHGlobal(num);
                throw Hyperic.Sigar.Sigar.FindException(sigar, errno);
            }
            NetInterfaceConfig structure = (NetInterfaceConfig)Marshal.PtrToStructure(num, type);

            Marshal.FreeHGlobal(num);
            return(structure);
        }
Пример #3
0
        internal static NetInterfaceConfig NativeGet(Sigar sigar,
                                                     string name)
        {
            Type   type = typeof(NetInterfaceConfig);
            IntPtr ptr  = Marshal.AllocHGlobal(Marshal.SizeOf(type));

            int status = sigar_net_interface_config_get(sigar.sigar.Handle,
                                                        name, ptr);

            if (status != Sigar.OK)
            {
                Marshal.FreeHGlobal(ptr);
                throw Sigar.FindException(sigar, status);
            }

            NetInterfaceConfig ifconfig =
                (NetInterfaceConfig)Marshal.PtrToStructure(ptr, type);

            Marshal.FreeHGlobal(ptr);

            return(ifconfig);
        }