From fded1f454a7d820f746d5c6045a82af3a433b48c Mon Sep 17 00:00:00 2001 From: Tim Young Date: Wed, 6 Mar 2019 09:43:39 +0300 Subject: [PATCH] Add functions to find the devices connected to this device --- EduNetworkBuilder/NetworkDevice.cs | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index 57d44e5..310c24a 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -655,6 +655,53 @@ namespace EduNetworkBuilder } } + /// + /// Return the list of devices connected to this device + /// + /// A list of devices + List ConnectedTo() + { + List connected = new List(); + foreach(NetworkCard nic in NICs) + { + NetworkDevice nd = ConnectedTo(nic); + if (nd != null) connected.Add(nd); + } + return connected; + } + + /// + /// return the device this nic is attached to + /// + /// + /// + NetworkDevice ConnectedTo(NetworkCard NIC) + { + return NIC.ConnectedTo(); + } + /// + /// return the device this nic is attached to + /// + /// the network card ID + /// + NetworkDevice ConnectedTo(HostNicID NIC) + { + NetworkCard nic = NicFromID(NIC); + if (nic == null) return null; + return nic.ConnectedTo(); + } + /// + /// return the device this nic is attached to + /// + /// The network card name + /// + NetworkDevice ConnectedTo(string nicname) + { + NetworkCard nic = NicFromName(nicname); + if (nic == null) return null; + return nic.ConnectedTo(); + } + /// /// Check to see if the device has a link to the specified host ///