mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Builds and runs on Unix with EthernetTap changes, now for Windows... and for what we did this for: a refactor of the Windows tap connector.
This commit is contained in:
parent
6c60305a96
commit
0b8d6c7f4a
1 changed files with 15 additions and 6 deletions
|
@ -30,13 +30,19 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "Constants.hpp"
|
||||||
#include "Network.hpp"
|
#include "Network.hpp"
|
||||||
#include "RuntimeEnvironment.hpp"
|
#include "RuntimeEnvironment.hpp"
|
||||||
#include "NodeConfig.hpp"
|
#include "NodeConfig.hpp"
|
||||||
#include "Switch.hpp"
|
#include "Switch.hpp"
|
||||||
#include "Packet.hpp"
|
#include "Packet.hpp"
|
||||||
#include "Buffer.hpp"
|
#include "Buffer.hpp"
|
||||||
#include "EthernetTap.hpp"
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
#include "WindowsEthernetTap.hpp"
|
||||||
|
#else
|
||||||
|
#include "UnixEthernetTap.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ZT_NETWORK_CERT_WRITE_BUF_SIZE 131072
|
#define ZT_NETWORK_CERT_WRITE_BUF_SIZE 131072
|
||||||
|
|
||||||
|
@ -60,17 +66,21 @@ Network::~Network()
|
||||||
{
|
{
|
||||||
Thread::join(_setupThread);
|
Thread::join(_setupThread);
|
||||||
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
std::string devPersistentId;
|
std::string devPersistentId;
|
||||||
if (_tap) {
|
if (_tap) {
|
||||||
devPersistentId = _tap->persistentId();
|
devPersistentId = _tap->persistentId();
|
||||||
delete _tap;
|
delete _tap;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (_destroyOnDelete) {
|
if (_destroyOnDelete) {
|
||||||
Utils::rm(std::string(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".conf"));
|
Utils::rm(std::string(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".conf"));
|
||||||
Utils::rm(std::string(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".mcerts"));
|
Utils::rm(std::string(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".mcerts"));
|
||||||
|
#ifdef __WINDOWS__
|
||||||
if (devPersistentId.length())
|
if (devPersistentId.length())
|
||||||
EthernetTap::deletePersistentTapDevice(_r,devPersistentId.c_str());
|
WindowsEthernetTap::deletePersistentTapDevice(_r,devPersistentId.c_str());
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// Causes flush of membership certs to disk
|
// Causes flush of membership certs to disk
|
||||||
clean();
|
clean();
|
||||||
|
@ -282,18 +292,17 @@ void Network::threadMain()
|
||||||
// registry to mark persistent instance of the tap device.
|
// registry to mark persistent instance of the tap device.
|
||||||
char tag[24];
|
char tag[24];
|
||||||
Utils::snprintf(tag,sizeof(tag),"%.16llx",(unsigned long long)_id);
|
Utils::snprintf(tag,sizeof(tag),"%.16llx",(unsigned long long)_id);
|
||||||
|
_tap = new WindowsEthernetTap(_r,tag,_mac,ZT_IF_MTU,&_CBhandleTapData,this);
|
||||||
#else
|
#else
|
||||||
// Unix tries to get the same device name next time, if possible.
|
// Unix tries to get the same device name next time, if possible.
|
||||||
std::string tagstr;
|
std::string tagstr;
|
||||||
char lcentry[128];
|
char lcentry[128];
|
||||||
Utils::snprintf(lcentry,sizeof(lcentry),"_dev_for_%.16llx",(unsigned long long)_id);
|
Utils::snprintf(lcentry,sizeof(lcentry),"_dev_for_%.16llx",(unsigned long long)_id);
|
||||||
tagstr = _nc->getLocalConfig(lcentry);
|
tagstr = _nc->getLocalConfig(lcentry);
|
||||||
|
|
||||||
const char *tag = (tagstr.length() > 0) ? tagstr.c_str() : (const char *)0;
|
const char *tag = (tagstr.length() > 0) ? tagstr.c_str() : (const char *)0;
|
||||||
#endif
|
_tap = new UnixEthernetTap(_r,tag,_mac,ZT_IF_MTU,&_CBhandleTapData,this);
|
||||||
|
|
||||||
_tap = new EthernetTap(_r,tag,_mac,ZT_IF_MTU,&_CBhandleTapData,this);
|
|
||||||
|
|
||||||
#ifndef __WINDOWS__
|
|
||||||
std::string dn(_tap->deviceName());
|
std::string dn(_tap->deviceName());
|
||||||
if ((!tag)||(dn != tag))
|
if ((!tag)||(dn != tag))
|
||||||
_nc->putLocalConfig(lcentry,dn);
|
_nc->putLocalConfig(lcentry,dn);
|
||||||
|
|
Loading…
Add table
Reference in a new issue