示例#1
0
        public static NetworkInterface [] GetAllNetworkInterfaces()
        {
#if MONOTOUCH
            return(MacOsNetworkInterface.ImplGetAllNetworkInterfaces());
#else
            if (runningOnUnix)
            {
                try {
                    if (Platform.IsMacOS)
                    {
                        return(MacOsNetworkInterface.ImplGetAllNetworkInterfaces());
                    }
                    else
                    {
                        return(LinuxNetworkInterface.ImplGetAllNetworkInterfaces());
                    }
                } catch (SystemException ex) {
                    throw ex;
                } catch {
                    return(new NetworkInterface [0]);
                }
            }
            else
            {
                if (Environment.OSVersion.Version >= windowsVer51)
                {
                    return(Win32NetworkInterface2.ImplGetAllNetworkInterfaces());
                }
                return(new NetworkInterface [0]);
            }
#endif
        }
示例#2
0
        public static NetworkInterface[] GetAllNetworkInterfaces()
        {
            if (runningOnUnix)
            {
                bool   flag   = false;
                IntPtr intPtr = Marshal.AllocHGlobal(8192);
                if (uname(intPtr) == 0)
                {
                    string a = Marshal.PtrToStringAnsi(intPtr);
                    if (a == "Darwin")
                    {
                        flag = true;
                    }
                }
                Marshal.FreeHGlobal(intPtr);
                try
                {
                    if (flag)
                    {
                        return(MacOsNetworkInterface.ImplGetAllNetworkInterfaces());
                    }
                    return(LinuxNetworkInterface.ImplGetAllNetworkInterfaces());

                    IL_005f :;
                }
                catch (SystemException ex)
                {
                    throw ex;
                    IL_0067 :;
                }
                catch
                {
                    return(new NetworkInterface[0]);

                    IL_007a :;
                }
            }
            if (Environment.OSVersion.Version >= windowsVer51)
            {
                return(Win32NetworkInterface2.ImplGetAllNetworkInterfaces());
            }
            return(new NetworkInterface[0]);
        }
示例#3
0
        public static NetworkInterface [] GetAllNetworkInterfaces()
        {
            if (runningOnUnix)
            {
                bool   darwin = false;
                IntPtr buf    = Marshal.AllocHGlobal(8192);
                if (uname(buf) == 0)
                {
                    string os = Marshal.PtrToStringAnsi(buf);
                    if (os == "Darwin")
                    {
                        darwin = true;
                    }
                }
                Marshal.FreeHGlobal(buf);

                try {
                    if (darwin)
                    {
                        return(MacOsNetworkInterface.ImplGetAllNetworkInterfaces());
                    }
                    else
                    {
                        return(LinuxNetworkInterface.ImplGetAllNetworkInterfaces());
                    }
                } catch (SystemException ex) {
                    throw ex;
                } catch {
                    return(new NetworkInterface [0]);
                }
            }
            else
            {
                if (Environment.OSVersion.Version >= windowsVer51)
                {
                    return(Win32NetworkInterface2.ImplGetAllNetworkInterfaces());
                }
                return(new NetworkInterface [0]);
            }
        }