Files
Dec2017-Script-Dump/System/Net/NetworkInformation/NetworkInterface.cs
T
2026-06-04 11:42:34 +02:00

192 lines
8.4 KiB
C#

using System;
using System.IO;
using System.Runtime.InteropServices;
namespace System.Net.NetworkInformation
{
/// <summary>Provides configuration and statistical information for a network interface.</summary>
// Token: 0x020001A2 RID: 418
public abstract class NetworkInterface
{
// Token: 0x06000DE1 RID: 3553
[DllImport("libc")]
private static extern int uname(IntPtr buf);
/// <summary>Returns objects that describe the network interfaces on the local computer.</summary>
/// <returns>A <see cref="T:System.Net.NetworkInformation.NetworkInterface" /> array that contains objects that describe the available network interfaces, or an empty array if no interfaces are detected.</returns>
/// <exception cref="T:System.Net.NetworkInformation.NetworkInformationException">A Windows system function call failed. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// <IPermission class="System.Net.NetworkInformation.NetworkInformationPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Access="Read" />
/// </PermissionSet>
// Token: 0x06000DE2 RID: 3554 RVA: 0x00026E24 File Offset: 0x00025024
[global::System.MonoTODO("Only works on Linux and Windows")]
public static NetworkInterface[] GetAllNetworkInterfaces()
{
if (NetworkInterface.runningOnUnix)
{
bool flag = false;
IntPtr intPtr = Marshal.AllocHGlobal(8192);
if (NetworkInterface.uname(intPtr) == 0)
{
string text = Marshal.PtrToStringAnsi(intPtr);
if (text == "Darwin")
{
flag = true;
}
}
Marshal.FreeHGlobal(intPtr);
try
{
if (flag)
{
return MacOsNetworkInterface.ImplGetAllNetworkInterfaces();
}
return LinuxNetworkInterface.ImplGetAllNetworkInterfaces();
}
catch (SystemException ex)
{
throw ex;
}
catch
{
return new NetworkInterface[0];
}
}
if (Environment.OSVersion.Version >= NetworkInterface.windowsVer51)
{
return Win32NetworkInterface2.ImplGetAllNetworkInterfaces();
}
return new NetworkInterface[0];
}
/// <summary>Indicates whether any network connection is available.</summary>
/// <returns>true if a network connection is available; otherwise, false.</returns>
// Token: 0x06000DE3 RID: 3555 RVA: 0x00026F0C File Offset: 0x0002510C
[global::System.MonoTODO("Always returns true")]
public static bool GetIsNetworkAvailable()
{
return true;
}
// Token: 0x06000DE4 RID: 3556 RVA: 0x00026F10 File Offset: 0x00025110
internal static string ReadLine(string path)
{
string text;
using (FileStream fileStream = File.OpenRead(path))
{
using (StreamReader streamReader = new StreamReader(fileStream))
{
text = streamReader.ReadLine();
}
}
return text;
}
/// <summary>Gets the index of the IPv4 loopback interface.</summary>
/// <returns>A <see cref="T:System.Int32" /> that contains the index for the IPv4 loopback interface.</returns>
/// <exception cref="T:System.Net.NetworkInformation.NetworkInformationException">This property is not valid on computers running only Ipv6.</exception>
// Token: 0x17000483 RID: 1155
// (get) Token: 0x06000DE5 RID: 3557 RVA: 0x00026F90 File Offset: 0x00025190
[global::System.MonoTODO("Only works on Linux. Returns 0 on other systems.")]
public static int LoopbackInterfaceIndex
{
get
{
if (NetworkInterface.runningOnUnix)
{
try
{
return UnixNetworkInterface.IfNameToIndex("lo");
}
catch
{
return 0;
}
return 0;
}
return 0;
}
}
/// <summary>Returns an object that describes the configuration of this network interface.</summary>
/// <returns>An <see cref="T:System.Net.NetworkInformation.IPInterfaceProperties" /> object that describes this network interface.</returns>
// Token: 0x06000DE6 RID: 3558
public abstract IPInterfaceProperties GetIPProperties();
/// <summary>Gets the IPv4 statistics.</summary>
/// <returns>An <see cref="T:System.Net.NetworkInformation.IPv4InterfaceStatistics" /> object.</returns>
// Token: 0x06000DE7 RID: 3559
public abstract IPv4InterfaceStatistics GetIPv4Statistics();
/// <summary>Returns the Media Access Control (MAC) or physical address for this adapter.</summary>
/// <returns>A <see cref="T:System.Net.NetworkInformation.PhysicalAddress" /> object that contains the physical address.</returns>
// Token: 0x06000DE8 RID: 3560
public abstract PhysicalAddress GetPhysicalAddress();
/// <summary>Gets a <see cref="T:System.Boolean" /> value that indicates whether the interface supports the specified protocol.</summary>
/// <returns>true if the specified protocol is supported; otherwise, false.</returns>
/// <param name="networkInterfaceComponent">A <see cref="T:System.Net.NetworkInformation.NetworkInterfaceComponent" /> value.</param>
// Token: 0x06000DE9 RID: 3561
public abstract bool Supports(NetworkInterfaceComponent networkInterfaceComponent);
/// <summary>Gets the description of the interface.</summary>
/// <returns>A <see cref="T:System.String" /> that describes this interface.</returns>
// Token: 0x17000484 RID: 1156
// (get) Token: 0x06000DEA RID: 3562
public abstract string Description { get; }
/// <summary>Gets the identifier of the network adapter.</summary>
/// <returns>A <see cref="T:System.String" /> that contains the identifier.</returns>
// Token: 0x17000485 RID: 1157
// (get) Token: 0x06000DEB RID: 3563
public abstract string Id { get; }
/// <summary>Gets a <see cref="T:System.Boolean" /> value that indicates whether the network interface is set to only receive data packets.</summary>
/// <returns>true if the interface only receives network traffic; otherwise, false.</returns>
/// <exception cref="T:System.PlatformNotSupportedException">This property is not valid on computers running operating systems earlier than Windows XP. </exception>
// Token: 0x17000486 RID: 1158
// (get) Token: 0x06000DEC RID: 3564
public abstract bool IsReceiveOnly { get; }
/// <summary>Gets the name of the network adapter.</summary>
/// <returns>A <see cref="T:System.String" /> that contains the adapter name.</returns>
// Token: 0x17000487 RID: 1159
// (get) Token: 0x06000DED RID: 3565
public abstract string Name { get; }
/// <summary>Gets the interface type.</summary>
/// <returns>An <see cref="T:System.Net.NetworkInformation.NetworkInterfaceType" /> value that specifies the network interface type.</returns>
// Token: 0x17000488 RID: 1160
// (get) Token: 0x06000DEE RID: 3566
public abstract NetworkInterfaceType NetworkInterfaceType { get; }
/// <summary>Gets the current operational state of the network connection.</summary>
/// <returns>One of the <see cref="T:System.Net.NetworkInformation.OperationalStatus" /> values.</returns>
// Token: 0x17000489 RID: 1161
// (get) Token: 0x06000DEF RID: 3567
public abstract OperationalStatus OperationalStatus { get; }
/// <summary>Gets the speed of the network interface.</summary>
/// <returns>A <see cref="T:System.Int64" /> value that specifies the speed in bits per second.</returns>
// Token: 0x1700048A RID: 1162
// (get) Token: 0x06000DF0 RID: 3568
public abstract long Speed { get; }
/// <summary>Gets a <see cref="T:System.Boolean" /> value that indicates whether the network interface is enabled to receive multicast packets.</summary>
/// <returns>true if the interface receives multicast packets; otherwise, false.</returns>
/// <exception cref="T:System.PlatformNotSupportedException">This property is not valid on computers running operating systems earlier than Windows XP. </exception>
// Token: 0x1700048B RID: 1163
// (get) Token: 0x06000DF1 RID: 3569
public abstract bool SupportsMulticast { get; }
// Token: 0x04000C91 RID: 3217
private static Version windowsVer51 = new Version(5, 1);
// Token: 0x04000C92 RID: 3218
internal static readonly bool runningOnUnix = Environment.OSVersion.Platform == PlatformID.Unix;
}
}