check for broken wireless links
This commit is contained in:
parent
5ee1170a01
commit
1bf394833d
@ -1122,6 +1122,23 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
}
|
||||
|
||||
public bool DoAllVerifyLinks()
|
||||
{
|
||||
NetworkLink nl;
|
||||
bool didanything = false;
|
||||
NetworkComponent nc;
|
||||
for (int i = NetComponents.Count -1; i >= 0; i-- )
|
||||
{
|
||||
nc = NetComponents[i];
|
||||
if (NB.GetComponentType(nc) == GeneralComponentType.link)
|
||||
{
|
||||
nl = (NetworkLink)nc;
|
||||
didanything = nl.VerifyLinkIntegrity() || didanything;
|
||||
}
|
||||
}
|
||||
return didanything;
|
||||
}
|
||||
|
||||
public void DoAllClearArp()
|
||||
{
|
||||
NetworkDevice nd;
|
||||
|
@ -343,6 +343,19 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLinks()
|
||||
{
|
||||
bool didanything = false;
|
||||
//Remove links if needed
|
||||
didanything = didanything || myNetwork.DoAllVerifyLinks();
|
||||
|
||||
//now, update wireless links if we can.
|
||||
|
||||
//If we have done anything, check for tests being completed
|
||||
if (didanything)
|
||||
myNetwork.TestForCompletion(true);
|
||||
}
|
||||
|
||||
public void UpdateForm()
|
||||
{
|
||||
UpdateMenu();
|
||||
@ -606,11 +619,15 @@ namespace EduNetworkBuilder
|
||||
|
||||
private void pbNetworkView_Edit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ItemClickedOn.GetNetType() == NetworkComponentType.microwave || ItemClickedOn.GetNetType() == NetworkComponentType.fluorescent)
|
||||
return;
|
||||
if (ItemClickedOn != null)
|
||||
{
|
||||
|
||||
DeviceConfig editwindow = new DeviceConfig(ItemClickedOn);
|
||||
editwindow.ShowDialog();
|
||||
}
|
||||
UpdateLinks();
|
||||
myNetwork.TestForCompletion(true);
|
||||
pbNetworkView.Update();
|
||||
pbNetworkView.Invalidate();
|
||||
@ -631,6 +648,7 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
myNetwork.RemoveComponent(ItemClickedOn);
|
||||
}
|
||||
UpdateLinks();
|
||||
myNetwork.TestForCompletion(true);
|
||||
pbNetworkView.Update();
|
||||
pbNetworkView.Invalidate();
|
||||
@ -717,17 +735,8 @@ namespace EduNetworkBuilder
|
||||
|
||||
if (duration.TotalMilliseconds < 250)
|
||||
{
|
||||
//This mouse-up is part of a double-click operation.
|
||||
if(ItemClickedOn!= null)
|
||||
{
|
||||
if (ItemClickedOn.GetNetType() == NetworkComponentType.microwave || ItemClickedOn.GetNetType() == NetworkComponentType.fluorescent)
|
||||
return;
|
||||
DeviceConfig editwindow = new DeviceConfig(ItemClickedOn);
|
||||
editwindow.ShowDialog();
|
||||
pbNetworkView.Update();
|
||||
pbNetworkView.Invalidate();
|
||||
myNetwork.TestForCompletion(true);
|
||||
}
|
||||
//This mouse-up is part of a double-click operation. Do an edit
|
||||
pbNetworkView_Edit_Click(sender, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -803,6 +812,7 @@ namespace EduNetworkBuilder
|
||||
if (Math.Abs(ClickedLocation.X - ClickLocation.X) > 5 || Math.Abs(ClickedLocation.Y - ClickLocation.Y) > 5)
|
||||
{
|
||||
ItemClickedOn.ChangeLocation(CenteredLocation);
|
||||
UpdateLinks();
|
||||
pbNetworkView.Invalidate();
|
||||
}
|
||||
}
|
||||
@ -812,6 +822,7 @@ namespace EduNetworkBuilder
|
||||
|
||||
private void pbNetworkView_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
myNetwork.Print(e);
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,13 @@ namespace EduNetworkBuilder
|
||||
get { return myNicType; }
|
||||
}
|
||||
|
||||
public bool isWireless()
|
||||
{
|
||||
if (myNicType == NicType.wport || myNicType == NicType.wlan)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasIP(UInt32 IP)
|
||||
{
|
||||
if (myNicType == NicType.port) return false;
|
||||
|
@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using System.Xml;
|
||||
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace EduNetworkBuilder
|
||||
{
|
||||
@ -25,6 +25,47 @@ namespace EduNetworkBuilder
|
||||
myNet.MarkAsLinked(source, GetUniqueIdentifier);
|
||||
myNet.MarkAsLinked(dest, GetUniqueIdentifier);
|
||||
theLinkType = type;
|
||||
NetworkDevice sDev = myNet.GetDeviceFromID(source);
|
||||
NetworkDevice dDev = myNet.GetDeviceFromID(dest);
|
||||
if (sDev == null || dDev == null) return;
|
||||
NetworkCard sNic = sDev.NicFromID(source);
|
||||
NetworkCard dNic = dDev.NicFromID(dest);
|
||||
NetworkCard AccessPoint = null;
|
||||
NetworkCard Client = null;
|
||||
bool IsWireless = false;
|
||||
if(sNic != null && dNic != null)
|
||||
{
|
||||
if(sNic.GetNicType == NicType.wport)
|
||||
{
|
||||
AccessPoint = sNic;
|
||||
Client = dNic;
|
||||
IsWireless = true;
|
||||
}
|
||||
if(dNic.GetNicType == NicType.wport)
|
||||
{
|
||||
AccessPoint = dNic;
|
||||
Client = sNic;
|
||||
IsWireless = true;
|
||||
}
|
||||
if(IsWireless && AccessPoint != null && Client != null)
|
||||
{
|
||||
bool donesomething=false;
|
||||
if(AccessPoint.SSID != Client.SSID)
|
||||
{
|
||||
donesomething = true;
|
||||
Client.SSID = AccessPoint.SSID;
|
||||
}
|
||||
if (AccessPoint.WirelessKey != Client.WirelessKey)
|
||||
{
|
||||
donesomething = true;
|
||||
Client.WirelessKey = AccessPoint.WirelessKey;
|
||||
}
|
||||
if(donesomething)
|
||||
{
|
||||
MessageBox.Show("The SSID and Key have been updated on the client.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NetworkLink(XmlNode theNode)
|
||||
@ -126,6 +167,39 @@ namespace EduNetworkBuilder
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check that the link works. If not, drop the link. It usually only
|
||||
/// fails in wireless if the ssid and key do not match
|
||||
/// </summary>
|
||||
public bool VerifyLinkIntegrity()
|
||||
{
|
||||
Network myNet = NB.GetNetwork();
|
||||
if (myNet == null) return false;
|
||||
NetworkDevice sDev = myNet.GetDeviceFromID(SrcNic);
|
||||
NetworkDevice dDev = myNet.GetDeviceFromID(DstNic);
|
||||
if (sDev == null || dDev == null) return false;
|
||||
NetworkCard sNic = sDev.NicFromID(SrcNic);
|
||||
NetworkCard dNic = dDev.NicFromID(DstNic);
|
||||
bool deleteme=false;
|
||||
if (sNic != null && dNic != null)
|
||||
{
|
||||
if (sNic.GetNicType == NicType.wport || dNic.GetNicType == NicType.wport)
|
||||
{
|
||||
if (sNic.WirelessKey != dNic.WirelessKey)
|
||||
deleteme = true;
|
||||
if (sNic.SSID != dNic.SSID)
|
||||
deleteme = true;
|
||||
}
|
||||
}
|
||||
if (sNic.isWireless() != dNic.isWireless())
|
||||
deleteme = true;
|
||||
if(deleteme)
|
||||
{
|
||||
sDev.RemoveLinkTo(dDev.hostname); //this removes this link
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Print(Image BaseImage, bool DrawTitle)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user