On link editor, only show nics that match (wlan/wport)

This commit is contained in:
Tim Young 2015-08-09 15:01:18 -06:00
parent 4b3d3d8f4f
commit 0b974171f6
3 changed files with 16 additions and 4 deletions

View File

@ -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<string> dstNics = myNet.NetworkCardForHostList(lbDstHost.SelectedItem.ToString(),true,true);
List<string> dstNics = myNet.NetworkCardForHostList(lbDstHost.SelectedItem.ToString(), true, true, srcNicType);
foreach (string tString in dstNics)
{
lbDstNic.Items.Add(tString);

View File

@ -732,7 +732,7 @@ namespace EduNetworkBuilder
return false;
}
public List<string> NetworkCardForHostList(string hostname, bool OnlyUnused = true, bool OnlyLinkable = false)
public List<string> NetworkCardForHostList(string hostname, bool OnlyUnused = true, bool OnlyLinkable = false, NicType fromNIC = NicType.none)
{
List<string> theList = new List<string>();
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));
}
}
}

View File

@ -621,7 +621,7 @@ namespace EduNetworkBuilder
}
}
public List<string> NetworkCardStrings(bool OnlyUnused=true, bool OnlyLinkable=false)
public List<string> NetworkCardStrings(bool OnlyUnused=true, bool OnlyLinkable=false, NicType fromNic = NicType.none)
{
List<string> macStrings = new List<string>();
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)