Follow up patch for Click: Bug 760 - IP address removal can be painful

This commit is contained in:
Alexander D'souza
2013-07-18 14:07:56 +02:00
parent 9659e95a7d
commit ac7c84ab0b
2 changed files with 24 additions and 0 deletions

View File

@@ -434,6 +434,29 @@ Ipv4L3ClickProtocol::RemoveAddress (uint32_t i, uint32_t addressIndex)
return false;
}
bool
Ipv4L3ClickProtocol::RemoveAddress (uint32_t i, Ipv4Address address)
{
NS_LOG_FUNCTION (this << i << address);
if (address == Ipv4Address::GetLoopback())
{
NS_LOG_WARN ("Cannot remove loopback address.");
return false;
}
Ptr<Ipv4Interface> interface = GetInterface (i);
Ipv4InterfaceAddress ifAddr = interface->RemoveAddress (address);
if (ifAddr != Ipv4InterfaceAddress ())
{
if (m_routingProtocol != 0)
{
m_routingProtocol->NotifyRemoveAddress (i, ifAddr);
}
return true;
}
return false;
}
Ipv4Address
Ipv4L3ClickProtocol::SelectSourceAddress (Ptr<const NetDevice> device,
Ipv4Address dst, Ipv4InterfaceAddress::InterfaceAddressScope_e scope)

View File

@@ -215,6 +215,7 @@ public:
Ipv4InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const;
uint32_t GetNAddresses (uint32_t interface) const;
bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex);
bool RemoveAddress (uint32_t interfaceIndex, Ipv4Address address);
Ipv4Address SelectSourceAddress (Ptr<const NetDevice> device,
Ipv4Address dst, Ipv4InterfaceAddress::InterfaceAddressScope_e scope);