IP assignment and change cleanup -- leave IPs that were never configured via ZT static assignment alone.

This commit is contained in:
Adam Ierymenko 2014-09-05 15:35:09 -07:00
commit d02ecfb288
2 changed files with 41 additions and 47 deletions

View file

@ -115,50 +115,6 @@ public:
*/
virtual std::set<InetAddress> ips() const = 0;
/**
* Set this tap's IP addresses to exactly this set of IPs
*
* New IPs are created. Any IP that overlaps with the network of an IP in
* this list is removed, but other IPs are left intact.
*
* @param ips IP addresses with netmask in port field
*/
inline void setIps(const std::set<InetAddress> &allIps)
{
for(std::set<InetAddress>::iterator i(allIps.begin());i!=allIps.end();++i)
addIP(*i);
std::set<InetAddress> myIps(ips());
#ifdef __APPLE__
bool haveV6LinkLocal = false;
for(std::set<InetAddress>::iterator i(myIps.begin());i!=myIps.end();++i) {
if (i->isLinkLocal()) {
if (i->isV6())
haveV6LinkLocal = true;
} else if (!allIps.count(*i)) {
for(std::set<InetAddress>::const_iterator i2(allIps.begin());i2!=allIps.end();++i2) {
if (i->sameNetworkAs(*i2)) {
removeIP(*i);
break;
}
}
}
}
if (!haveV6LinkLocal)
addIP(InetAddress::makeIpv6LinkLocal(_mac));
#else
for(std::set<InetAddress>::iterator i(myIps.begin());i!=myIps.end();++i) {
if ((!i->isLinkLocal())&&(!allIps.count(*i))) {
for(std::set<InetAddress>::const_iterator i2(allIps.begin());i2!=allIps.end();++i2) {
if (i->sameNetworkAs(*i2)) {
removeIP(*i);
break;
}
}
}
}
#endif
}
/**
* Put a frame, making it available to the OS for processing
*