diff --git a/EduNetworkBuilder/LinkEditor.cs b/EduNetworkBuilder/LinkEditor.cs index d04c069..d29d11e 100644 --- a/EduNetworkBuilder/LinkEditor.cs +++ b/EduNetworkBuilder/LinkEditor.cs @@ -68,6 +68,7 @@ namespace EduNetworkBuilder { processing = true; Network myNet = NB.GetNetwork(); + NicType srcNicType = NicType.none; string SrcHost=""; if (lbSrcHost.SelectedItem != null) SrcHost = lbSrcHost.SelectedItem.ToString(); @@ -76,7 +77,14 @@ namespace EduNetworkBuilder DstHost = lbDstHost.SelectedItem.ToString(); string SrcNic = ""; if (lbSrcNic.SelectedItem != null) + { SrcNic = lbSrcNic.SelectedItem.ToString(); + int sNicIndex = lbSrcNic.SelectedIndex; + NetworkDevice Src = myNet.ItemFromName(lbSrcHost.SelectedItem.ToString()); + NetworkCard sNic = null; + if(Src != null) sNic = Src.NicFromName(lbSrcNic.SelectedItem.ToString()); + if(sNic != null) srcNicType = sNic.GetNicType; + } string DstNic = ""; if (lbDstNic.SelectedItem != null) DstNic = lbDstNic.SelectedItem.ToString(); @@ -136,7 +144,7 @@ namespace EduNetworkBuilder lbDstNic.Items.Clear(); if (lbDstHost.SelectedIndex >= 0) { - List dstNics = myNet.NetworkCardForHostList(lbDstHost.SelectedItem.ToString(),true,true); + List dstNics = myNet.NetworkCardForHostList(lbDstHost.SelectedItem.ToString(), true, true, srcNicType); foreach (string tString in dstNics) { lbDstNic.Items.Add(tString); diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index b40c2ed..9f23d0d 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -732,7 +732,7 @@ namespace EduNetworkBuilder return false; } - public List NetworkCardForHostList(string hostname, bool OnlyUnused = true, bool OnlyLinkable = false) + public List NetworkCardForHostList(string hostname, bool OnlyUnused = true, bool OnlyLinkable = false, NicType fromNIC = NicType.none) { List theList = new List(); NetworkDevice tDevice; @@ -743,7 +743,7 @@ namespace EduNetworkBuilder if(nc.hostname == hostname) { tDevice = (NetworkDevice)nc; - theList.AddRange(tDevice.NetworkCardStrings(OnlyUnused,OnlyLinkable)); + theList.AddRange(tDevice.NetworkCardStrings(OnlyUnused,OnlyLinkable, fromNIC)); } } } diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index bc50e89..7ba48c0 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -621,7 +621,7 @@ namespace EduNetworkBuilder } } - public List NetworkCardStrings(bool OnlyUnused=true, bool OnlyLinkable=false) + public List NetworkCardStrings(bool OnlyUnused=true, bool OnlyLinkable=false, NicType fromNic = NicType.none) { List macStrings = new List(); int counter = 0; @@ -632,6 +632,10 @@ namespace EduNetworkBuilder CanUse = nic.ConnectedLink == -1; //if it is not linked to anything if (OnlyLinkable && nic.GetNicType == NicType.vpn) CanUse = false; if (OnlyLinkable && nic.GetNicType == NicType.tun) CanUse = false; + if (fromNic != NicType.none && + fromNic == NicType.wlan && nic.GetNicType != NicType.wport) CanUse = false; + if (fromNic != NicType.none && + fromNic == NicType.wport && nic.GetNicType != NicType.wlan) CanUse = false; if (nic.GetNicType != NicType.lo && (nic.GetNicType != NicType.management_interface || OnlyUnused == false)) { if(CanUse)