Add functions to find the devices connected to this device

This commit is contained in:
Tim Young 2019-03-06 09:43:39 +03:00
parent a72aec9f9a
commit fded1f454a
1 changed files with 47 additions and 0 deletions

View File

@ -655,6 +655,53 @@ namespace EduNetworkBuilder
}
}
/// <summary>
/// Return the list of devices connected to this device
/// </summary>
/// <returns>A list of devices</returns>
List<NetworkDevice> ConnectedTo()
{
List<NetworkDevice> connected = new List<NetworkDevice>();
foreach(NetworkCard nic in NICs)
{
NetworkDevice nd = ConnectedTo(nic);
if (nd != null) connected.Add(nd);
}
return connected;
}
/// <summary>
/// return the device this nic is attached to
/// </summary>
/// <param name="NIC"></param>
/// <returns></returns>
NetworkDevice ConnectedTo(NetworkCard NIC)
{
return NIC.ConnectedTo();
}
/// <summary>
/// return the device this nic is attached to
/// </summary>
/// <param name="NIC">the network card ID</param>
/// <returns></returns>
NetworkDevice ConnectedTo(HostNicID NIC)
{
NetworkCard nic = NicFromID(NIC);
if (nic == null) return null;
return nic.ConnectedTo();
}
/// <summary>
/// return the device this nic is attached to
/// </summary>
/// <param name="nicname">The network card name</param>
/// <returns></returns>
NetworkDevice ConnectedTo(string nicname)
{
NetworkCard nic = NicFromName(nicname);
if (nic == null) return null;
return nic.ConnectedTo();
}
/// <summary>
/// Check to see if the device has a link to the specified host
/// </summary>