summaryrefslogtreecommitdiff
path: root/osdep
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-12-12 12:55:14 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-12-12 12:55:14 -0800
commit39fb4b1b4277d1a1761ce3316d30e9bda4277073 (patch)
tree07094d1bd34e20b6973be9c2bc5ab6c7cd5b6081 /osdep
parent3864a2e111e90c9af221fb8735849e8e4b12d3ab (diff)
parent697520f1f554e4cf7c2257ab60a0d44c7bb00325 (diff)
downloadinfinitytier-39fb4b1b4277d1a1761ce3316d30e9bda4277073.tar.gz
infinitytier-39fb4b1b4277d1a1761ce3316d30e9bda4277073.zip
Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev
Diffstat (limited to 'osdep')
-rw-r--r--osdep/WindowsEthernetTap.cpp51
1 files changed, 30 insertions, 21 deletions
diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp
index ea62e82a..a9ff31d3 100644
--- a/osdep/WindowsEthernetTap.cpp
+++ b/osdep/WindowsEthernetTap.cpp
@@ -672,6 +672,7 @@ bool WindowsEthernetTap::addIp(const InetAddress &ip)
{
if (!ip.netmaskBits()) // sanity check... netmask of 0.0.0.0 is WUT?
return false;
+
Mutex::Lock _l(_assignedIps_m);
if (std::find(_assignedIps.begin(),_assignedIps.end(),ip) != _assignedIps.end())
return true;
@@ -682,6 +683,9 @@ bool WindowsEthernetTap::addIp(const InetAddress &ip)
bool WindowsEthernetTap::removeIp(const InetAddress &ip)
{
+ if (ip.isV6())
+ return true;
+
{
Mutex::Lock _l(_assignedIps_m);
std::vector<InetAddress>::iterator aip(std::find(_assignedIps.begin(),_assignedIps.end(),ip));
@@ -713,18 +717,20 @@ bool WindowsEthernetTap::removeIp(const InetAddress &ip)
DeleteUnicastIpAddressEntry(&(ipt->Table[i]));
FreeMibTable(ipt);
- std::vector<std::string> regIps(_getRegistryIPv4Value("IPAddress"));
- std::vector<std::string> regSubnetMasks(_getRegistryIPv4Value("SubnetMask"));
- std::string ipstr(ip.toIpString());
- for(std::vector<std::string>::iterator rip(regIps.begin()),rm(regSubnetMasks.begin());((rip!=regIps.end())&&(rm!=regSubnetMasks.end()));++rip,++rm) {
- if (*rip == ipstr) {
- regIps.erase(rip);
- regSubnetMasks.erase(rm);
- _setRegistryIPv4Value("IPAddress",regIps);
- _setRegistryIPv4Value("SubnetMask",regSubnetMasks);
- break;
- }
- }
+ if (ip.isV4()) {
+ std::vector<std::string> regIps(_getRegistryIPv4Value("IPAddress"));
+ std::vector<std::string> regSubnetMasks(_getRegistryIPv4Value("SubnetMask"));
+ std::string ipstr(ip.toIpString());
+ for (std::vector<std::string>::iterator rip(regIps.begin()), rm(regSubnetMasks.begin()); ((rip != regIps.end()) && (rm != regSubnetMasks.end())); ++rip, ++rm) {
+ if (*rip == ipstr) {
+ regIps.erase(rip);
+ regSubnetMasks.erase(rm);
+ _setRegistryIPv4Value("IPAddress", regIps);
+ _setRegistryIPv4Value("SubnetMask", regSubnetMasks);
+ break;
+ }
+ }
+ }
return true;
}
@@ -1195,15 +1201,18 @@ void WindowsEthernetTap::_syncIps()
CreateUnicastIpAddressEntry(&ipr);
}
- std::string ipStr(aip->toString());
- std::vector<std::string> regIps(_getRegistryIPv4Value("IPAddress"));
- if (std::find(regIps.begin(),regIps.end(),ipStr) == regIps.end()) {
- std::vector<std::string> regSubnetMasks(_getRegistryIPv4Value("SubnetMask"));
- regIps.push_back(ipStr);
- regSubnetMasks.push_back(aip->netmask().toIpString());
- _setRegistryIPv4Value("IPAddress",regIps);
- _setRegistryIPv4Value("SubnetMask",regSubnetMasks);
- }
+ if (aip->isV4())
+ {
+ std::string ipStr(aip->toIpString());
+ std::vector<std::string> regIps(_getRegistryIPv4Value("IPAddress"));
+ if (std::find(regIps.begin(), regIps.end(), ipStr) == regIps.end()) {
+ std::vector<std::string> regSubnetMasks(_getRegistryIPv4Value("SubnetMask"));
+ regIps.push_back(ipStr);
+ regSubnetMasks.push_back(aip->netmask().toIpString());
+ _setRegistryIPv4Value("IPAddress", regIps);
+ _setRegistryIPv4Value("SubnetMask", regSubnetMasks);
+ }
+ }
}
}