|
|
@ -19,10 +19,8 @@ namespace SBRL.Utilities |
|
|
|
foreach (NetworkInterface nic in nics) |
|
|
|
{ |
|
|
|
Console.WriteLine("Id: {0}, Description: {1}", nic.Id, nic.Description); |
|
|
|
IPInterfaceProperties ipProps = nic.GetIPProperties(); |
|
|
|
IPv4InterfaceProperties ip4Props = ipProps.GetIPv4Properties(); |
|
|
|
if (nic.Id == targetInterfaceName) |
|
|
|
return ip4Props.Index; |
|
|
|
return nic.GetIPv4Index(); |
|
|
|
} |
|
|
|
throw new Exception($"Error: Can't find network interface with the name {targetInterfaceName}."); |
|
|
|
} |
|
|
@ -51,6 +49,13 @@ namespace SBRL.Utilities |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static int GetIPv4Index(this NetworkInterface nic) |
|
|
|
{ |
|
|
|
IPInterfaceProperties ipProps = nic.GetIPProperties(); |
|
|
|
IPv4InterfaceProperties ip4Props = ipProps.GetIPv4Properties(); |
|
|
|
return ip4Props.Index; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|