Able to change gateway if device has both DHCP and ethernet, but the ethernet is the one plugged in.

This commit is contained in:
Tim Young 2018-10-23 08:25:04 -05:00
parent 2b92fea4cb
commit facd5d1ea1
2 changed files with 17 additions and 4 deletions

View File

@ -487,7 +487,7 @@ namespace EduNetworkBuilder
if (NB.GetComponentType(ClonedItem) == GeneralComponentType.device)
{
NetworkDevice nd = (NetworkDevice)ClonedItem;
if (nd.HasDHCPNic())
if (!nd.HasNonDHCPConnected() && nd.HasDHCPNic())
{
MessageBox.Show(NB.Translate("DC_CannotEditGateway_DHCP"));
}

View File

@ -378,9 +378,8 @@ namespace EduNetworkBuilder
public NB_IPAddress GetGateway()
{
if(CanUseDHCP)
{
if(!HasNonDHCPConnected() && CanUseDHCP)
{
foreach(NetworkCard nic in NICs)
{
if(nic.UsesDHCP)
@ -3364,6 +3363,20 @@ namespace EduNetworkBuilder
return false;
}
/// <summary>
/// Return true if this device has at least one nic that can be configured from DHCP
/// </summary>
/// <returns>True if the device has a nic that can be configured with DHCP</returns>
public bool HasNonDHCPConnected()
{
foreach (NetworkCard card in NICs)
{
if (!card.UsesDHCP && card.ConnectedTo() != null)
return true;
}
return false;
}
public bool HasLocalNic(NB_IPAddress dest)
{
foreach(NetworkCard nic in NICs)