When wireless nic changed, push ssid and key to all similar nics on that device

This commit is contained in:
Tim Young 2015-08-19 15:13:51 -06:00
parent 8f971cf5ed
commit 5ee1170a01
3 changed files with 28 additions and 7 deletions

View File

@ -302,7 +302,7 @@ namespace EduNetworkBuilder
private void btnNicEdit_Click(object sender, EventArgs e) private void btnNicEdit_Click(object sender, EventArgs e)
{ {
//open a window to change the settings on the nic //open a window to change the settings on the nic
if (ClonedItem.GetType().ToString() == "EduNetworkBuilder.NetworkDevice") if (NB.GetComponentType(ClonedItem) == GeneralComponentType.device)
{ {
NetworkDevice ndCLonedItem = (NetworkDevice)ClonedItem; NetworkDevice ndCLonedItem = (NetworkDevice)ClonedItem;
ndCLonedItem.EditNic(lbNics.SelectedIndex +1); //Skip the loopback nic ndCLonedItem.EditNic(lbNics.SelectedIndex +1); //Skip the loopback nic
@ -396,12 +396,7 @@ namespace EduNetworkBuilder
private void lbNics_DoubleClick(object sender, EventArgs e) private void lbNics_DoubleClick(object sender, EventArgs e)
{ {
if (NB.GetComponentType(ClonedItem) == GeneralComponentType.device) btnNicEdit_Click(sender,e); //We want this code in just one location
{
NetworkDevice nd = (NetworkDevice)ClonedItem;
nd.EditNic(lbNics.SelectedIndex + 1); //skip the loopback device
UpdateForm();
}
} }
private void btnGateway_Click(object sender, EventArgs e) private void btnGateway_Click(object sender, EventArgs e)

View File

@ -176,6 +176,10 @@ namespace EduNetworkBuilder
{ {
MyNicToEdit.EncryptionKey = tbVPNEncrypt.Text; MyNicToEdit.EncryptionKey = tbVPNEncrypt.Text;
} }
if(tbSSID != null)
{
MyNicToEdit.SSID = tbSSID.Text;
}
Close(); Close();
} }

View File

@ -619,11 +619,33 @@ namespace EduNetworkBuilder
nic.EditInterface(ifIndex); nic.EditInterface(ifIndex);
} }
} }
/// <summary>
/// Duplicate the ssid and key to all NICs of identical type on this device
/// </summary>
/// <param name="SSID">The ssid to set everything to</param>
/// <param name="Key">the Key to set everything to</param>
/// <param name="NType">the type of nic (must be a wireless type)</param>
private void duplicateSSIDnKey(string SSID, string Key, NicType NType)
{
if (NType != NicType.wport && NType != NicType.wlan) return; // Not a wireless port. Do nothing.
foreach(NetworkCard NC in NICs)
{
if(NC.GetNicType == NType)
{
NC.SSID = SSID;
NC.WirelessKey = Key;
}
}
}
public void EditNic(int index) public void EditNic(int index)
{ {
if (index < 0) return; if (index < 0) return;
if (index > NICs.Count) return; if (index > NICs.Count) return;
NICs[index].Edit(); NICs[index].Edit();
//If the nic was a wireless, make sure we copy the ssid and key to all other of identical type
if (NICs[index].GetNicType == NicType.wport || NICs[index].GetNicType == NicType.wlan)
duplicateSSIDnKey(NICs[index].SSID, NICs[index].WirelessKey, NICs[index].GetNicType);
} }
public void DeleteNic(int index) public void DeleteNic(int index)
{ {