diff options
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/LinuxEthernetTap.cpp | 27 | ||||
-rw-r--r-- | osdep/OSUtils.cpp | 2 | ||||
-rw-r--r-- | osdep/WindowsEthernetTap.cpp | 2 |
3 files changed, 17 insertions, 14 deletions
diff --git a/osdep/LinuxEthernetTap.cpp b/osdep/LinuxEthernetTap.cpp index 6ef42744..06bbbada 100644 --- a/osdep/LinuxEthernetTap.cpp +++ b/osdep/LinuxEthernetTap.cpp @@ -146,18 +146,21 @@ LinuxEthernetTap::LinuxEthernetTap( OSUtils::ztsnprintf(procpath,sizeof(procpath),"/proc/sys/net/ipv4/conf/%s",ifr.ifr_name); } while (stat(procpath,&sbuf) == 0); // try zt#++ until we find one that does not exist #else - char devno = 0; + uint64_t trial = 0; // incremented in the very unlikely event of a name collision with another network do { - uint64_t tmp2[2]; - tmp2[0] = Utils::hton(nwid); - tmp2[1] = 0; - char tmp3[17]; + const uint64_t nwid40 = (nwid ^ (nwid >> 24)) + trial++; + uint8_t tmp2[5]; + char tmp3[11]; + tmp2[0] = (uint8_t)((nwid40 >> 32) & 0xff); + tmp2[1] = (uint8_t)((nwid40 >> 24) & 0xff); + tmp2[2] = (uint8_t)((nwid40 >> 16) & 0xff); + tmp2[3] = (uint8_t)((nwid40 >> 8) & 0xff); + tmp2[4] = (uint8_t)(nwid40 & 0xff); tmp3[0] = 'z'; - tmp3[1] = 't' + (devno++); - _base32_5_to_8(reinterpret_cast<const uint8_t *>(tmp2),tmp3 + 2); - _base32_5_to_8(reinterpret_cast<const uint8_t *>(tmp2) + 5,tmp3 + 10); - tmp3[15] = (char)0; - memcpy(ifr.ifr_name,tmp3,16); + tmp3[1] = 't'; + _base32_5_to_8(tmp2,tmp3 + 2); + tmp3[10] = (char)0; + memcpy(ifr.ifr_name,tmp3,11); OSUtils::ztsnprintf(procpath,sizeof(procpath),"/proc/sys/net/ipv4/conf/%s",ifr.ifr_name); } while (stat(procpath,&sbuf) == 0); #endif @@ -286,7 +289,7 @@ bool LinuxEthernetTap::addIpSyn(std::vector<InetAddress> ips) if (cpid == 0) { OSUtils::redirectUnixOutputs("/dev/null",(const char *)0); setenv("PATH", "/sbin:/bin:/usr/sbin:/usr/bin", 1); - // We must know if there is at least (one) of each protocol version so we + // We must know if there is at least (one) of each protocol version so we // can properly enumerate address/netmask combinations in the ifcfg-dev file for(int i=0; i<(int)ips.size(); i++) { if (ips[i].isV4()) @@ -318,7 +321,7 @@ bool LinuxEthernetTap::addIpSyn(std::vector<InetAddress> ips) if (ips[i].isV4()) ::execlp("ip","ip","addr","add",ips[i].toString(iptmp),"broadcast",ips[i].broadcast().toIpString(iptmp2),"dev",_dev.c_str(),(const char *)0); else - ::execlp("ip","ip","addr","add",ips[i].toString(iptmp),"dev",_dev.c_str(),(const char *)0); + ::execlp("ip","ip","addr","add",ips[i].toString(iptmp),"dev",_dev.c_str(),(const char *)0); } ::_exit(-1); } else if (cpid > 0) { diff --git a/osdep/OSUtils.cpp b/osdep/OSUtils.cpp index aa531243..cadd4e6b 100644 --- a/osdep/OSUtils.cpp +++ b/osdep/OSUtils.cpp @@ -381,7 +381,7 @@ std::vector<std::string> OSUtils::split(const char *s,const char *const sep,cons std::string OSUtils::platformDefaultHomePath() { #ifdef __QNAP__ - char *cmd = "/sbin/getcfg ZeroTier Install_Path -f /etc/config/qpkg.conf"; + char *cmd = "/sbin/getcfg zerotier Install_Path -f /etc/config/qpkg.conf"; char buf[128]; FILE *fp; if ((fp = popen(cmd, "r")) == NULL) { diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp index 64ab3943..aa96d33a 100644 --- a/osdep/WindowsEthernetTap.cpp +++ b/osdep/WindowsEthernetTap.cpp @@ -841,7 +841,7 @@ void WindowsEthernetTap::scanMulticastGroups(std::vector<MulticastGroup> &added, // pretty much anything work... IPv4, IPv6, IPX, oldskool Netbios, who knows... unsigned char mcastbuf[TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS_OUTPUT_BUF_SIZE]; DWORD bytesReturned = 0; - if (DeviceIoControl(t,TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS,(LPVOID)0,0,(LPVOID)mcastbuf,sizeof(mcastbuf),&bytesReturned,NULL)) { + if (DeviceIoControl(t,TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS,(LPVOID)mcastbuf,sizeof(mcastbuf),(LPVOID)mcastbuf,sizeof(mcastbuf),&bytesReturned,NULL)) { if ((bytesReturned > 0)&&(bytesReturned <= TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS_OUTPUT_BUF_SIZE)) { // sanity check MAC mac; DWORD i = 0; |