From b11627a8bc37a51455538f45484f3eae1ce195de Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 7 Aug 2019 18:45:04 -0500 Subject: [PATCH] add SDK VirtualTap to new factory method --- osdep/EthernetTap.cpp | 15 ++++++++++++++- service/OneService.cpp | 22 ---------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/osdep/EthernetTap.cpp b/osdep/EthernetTap.cpp index a10db55fe..21618a582 100644 --- a/osdep/EthernetTap.cpp +++ b/osdep/EthernetTap.cpp @@ -31,7 +31,6 @@ #include #ifdef __APPLE__ -#include #include #include "MacEthernetTap.hpp" #include "MacKextEthernetTap.hpp" @@ -57,6 +56,12 @@ #include "BSDEthernetTap.hpp" #endif // __OpenBSD__ +#ifdef ZT_SDK +#include "../controller/EmbeddedNetworkController.hpp" +#include "../node/Node.hpp" +#include "../include/VirtualTap.hpp" +#endif + namespace ZeroTier { std::shared_ptr EthernetTap::newInstance( @@ -70,6 +75,11 @@ std::shared_ptr EthernetTap::newInstance( void (*handler)(void *,void *,uint64_t,const MAC &,const MAC &,unsigned int,unsigned int,const void *,unsigned int), void *arg) { + +#ifdef ZT_SDK + return std::shared_ptr(new VirtualTap(homePath,mac,mtu,metric,nwid,friendlyName,handler,arg)); +#else // not ZT_SDK + #ifdef __APPLE__ char osrelease[256]; size_t size = sizeof(osrelease); @@ -77,6 +87,7 @@ std::shared_ptr EthernetTap::newInstance( char *dotAt = strchr(osrelease,'.'); if (dotAt) { *dotAt = (char)0; + printf("%s\n",osrelease); // The "feth" virtual Ethernet device type appeared in Darwin 17.x.x. Older versions // (Sierra and earlier) must use the a kernel extension. if (strtol(osrelease,(char **)0,10) < 17) { @@ -108,6 +119,8 @@ std::shared_ptr EthernetTap::newInstance( return std::shared_ptr(new BSDEthernetTap(homePath,mac,mtu,metric,nwid,friendlyName,handler,arg)); #endif // __OpenBSD__ +#endif // ZT_SDK? + return std::shared_ptr(); } diff --git a/service/OneService.cpp b/service/OneService.cpp index a434f4846..b38e8f427 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -100,30 +100,8 @@ using json = nlohmann::json; #include "../controller/EmbeddedNetworkController.hpp" #include "../controller/RabbitMQ.hpp" - -#ifdef ZT_USE_TEST_TAP - -#include "../osdep/TestEthernetTap.hpp" -namespace ZeroTier { typedef TestEthernetTap EthernetTap; } - -#else - -#ifdef ZT_SDK - -#include "../controller/EmbeddedNetworkController.hpp" -#include "../node/Node.hpp" -// Use the virtual netcon endpoint instead of a tun/tap port driver -#include "../include/VirtualTap.hpp" -namespace ZeroTier { typedef VirtualTap EthernetTap; } - -#else - #include "../osdep/EthernetTap.hpp" -#endif // ZT_SDK - -#endif // ZT_USE_TEST_TAP - #ifndef ZT_SOFTWARE_UPDATE_DEFAULT #define ZT_SOFTWARE_UPDATE_DEFAULT "disable" #endif