Choose which tap to use (feth or kext) on Mac based on Darwin version.

This commit is contained in:
Adam Ierymenko 2019-08-07 18:20:17 -05:00
parent aca31c7055
commit 237c379866
No known key found for this signature in database
GPG Key ID: 1657198823E52A61
3 changed files with 7 additions and 30 deletions

View File

@ -19,7 +19,7 @@ ZT_VERSION_BUILD=$(shell cat version.h | grep -F VERSION_BUILD | cut -d ' ' -f 3
DEFS+=-DZT_BUILD_PLATFORM=$(ZT_BUILD_PLATFORM) -DZT_BUILD_ARCHITECTURE=$(ZT_BUILD_ARCHITECTURE)
include objects.mk
ONE_OBJS+=osdep/MacEthernetTap.o ext/http-parser/http_parser.o
ONE_OBJS+=osdep/MacEthernetTap.o osdep/MacKextEthernetTap.o ext/http-parser/http_parser.o
ifeq ($(ZT_CONTROLLER),1)
LIBS+=-lpq -lrabbitmq

View File

@ -34,6 +34,7 @@ ONE_OBJS=\
controller/LFDB.o \
controller/PostgreSQL.o \
controller/RabbitMQ.o \
osdep/EthernetTap.o \
osdep/ManagedRoute.o \
osdep/Http.o \
osdep/OSUtils.o \

View File

@ -118,30 +118,7 @@ namespace ZeroTier { typedef VirtualTap EthernetTap; }
#else
#ifdef __APPLE__
#include "../osdep/MacEthernetTap.hpp"
namespace ZeroTier { typedef MacEthernetTap EthernetTap; }
#endif // __APPLE__
#ifdef __LINUX__
#include "../osdep/LinuxEthernetTap.hpp"
namespace ZeroTier { typedef LinuxEthernetTap EthernetTap; }
#endif // __LINUX__
#ifdef __WINDOWS__
#include "../osdep/WindowsEthernetTap.hpp"
namespace ZeroTier { typedef WindowsEthernetTap EthernetTap; }
#endif // __WINDOWS__
#ifdef __FreeBSD__
#include "../osdep/BSDEthernetTap.hpp"
namespace ZeroTier { typedef BSDEthernetTap EthernetTap; }
#endif // __FreeBSD__
#ifdef __NetBSD__
#include "../osdep/NetBSDEthernetTap.hpp"
namespace ZeroTier { typedef NetBSDEthernetTap EthernetTap; }
#endif // __NetBSD__
#ifdef __OpenBSD__
#include "../osdep/BSDEthernetTap.hpp"
namespace ZeroTier { typedef BSDEthernetTap EthernetTap; }
#endif // __OpenBSD__
#include "../osdep/EthernetTap.hpp"
#endif // ZT_SDK
@ -543,7 +520,7 @@ public:
settings.allowDefault = false;
}
EthernetTap *tap;
std::shared_ptr<EthernetTap> tap;
ZT_VirtualNetworkConfig config; // memcpy() of raw config from core
std::vector<InetAddress> managedIps;
std::list< SharedPtr<ManagedRoute> > managedRoutes;
@ -955,8 +932,6 @@ public:
{
Mutex::Lock _l(_nets_m);
for(std::map<uint64_t,NetworkState>::iterator n(_nets.begin());n!=_nets.end();++n)
delete n->second.tap;
_nets.clear();
}
@ -2142,7 +2117,8 @@ public:
char friendlyName[128];
OSUtils::ztsnprintf(friendlyName,sizeof(friendlyName),"ZeroTier One [%.16llx]",nwid);
n.tap = new EthernetTap(
n.tap = EthernetTap::newInstance(
nullptr,
_homePath.c_str(),
MAC(nwc->mac),
nwc->mtu,
@ -2232,7 +2208,7 @@ public:
std::string winInstanceId(n.tap->instanceId());
#endif
*nuptr = (void *)0;
delete n.tap;
n.tap.reset();
_nets.erase(nwid);
#if defined(__WINDOWS__) && !defined(ZT_SDK)
if ((op == ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY)&&(winInstanceId.length() > 0))