mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Make that an arbitrary tag to identify persistent taps...
This commit is contained in:
parent
dbb509a302
commit
2536352e5d
4 changed files with 9 additions and 4 deletions
|
@ -146,9 +146,9 @@ static Mutex __tapCreateLock;
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
EthernetTap::EthernetTap(
|
EthernetTap::EthernetTap(
|
||||||
const RuntimeEnvironment *renv,
|
const RuntimeEnvironment *renv,
|
||||||
|
const char *tag,
|
||||||
const MAC &mac,
|
const MAC &mac,
|
||||||
unsigned int mtu,
|
unsigned int mtu,
|
||||||
const char *desc,
|
|
||||||
void (*handler)(void *,const MAC &,const MAC &,unsigned int,const Buffer<4096> &),
|
void (*handler)(void *,const MAC &,const MAC &,unsigned int,const Buffer<4096> &),
|
||||||
void *arg)
|
void *arg)
|
||||||
throw(std::runtime_error) :
|
throw(std::runtime_error) :
|
||||||
|
@ -247,9 +247,9 @@ EthernetTap::EthernetTap(
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
EthernetTap::EthernetTap(
|
EthernetTap::EthernetTap(
|
||||||
const RuntimeEnvironment *renv,
|
const RuntimeEnvironment *renv,
|
||||||
|
const char *tag,
|
||||||
const MAC &mac,
|
const MAC &mac,
|
||||||
unsigned int mtu,
|
unsigned int mtu,
|
||||||
const char *desc,
|
|
||||||
void (*handler)(void *,const MAC &,const MAC &,unsigned int,const Buffer<4096> &),
|
void (*handler)(void *,const MAC &,const MAC &,unsigned int,const Buffer<4096> &),
|
||||||
void *arg)
|
void *arg)
|
||||||
throw(std::runtime_error) :
|
throw(std::runtime_error) :
|
||||||
|
|
|
@ -60,6 +60,7 @@ public:
|
||||||
* Handler arguments: arg,from,to,etherType,data
|
* Handler arguments: arg,from,to,etherType,data
|
||||||
*
|
*
|
||||||
* @param renv Runtime environment
|
* @param renv Runtime environment
|
||||||
|
* @param tag A tag used to identify persistent taps at the OS layer (e.g. nwid in hex)
|
||||||
* @param mac MAC address of device
|
* @param mac MAC address of device
|
||||||
* @param mtu MTU of device
|
* @param mtu MTU of device
|
||||||
* @param desc If non-NULL, a description (not used on all OSes)
|
* @param desc If non-NULL, a description (not used on all OSes)
|
||||||
|
@ -69,9 +70,9 @@ public:
|
||||||
*/
|
*/
|
||||||
EthernetTap(
|
EthernetTap(
|
||||||
const RuntimeEnvironment *renv,
|
const RuntimeEnvironment *renv,
|
||||||
|
const char *tag,
|
||||||
const MAC &mac,
|
const MAC &mac,
|
||||||
unsigned int mtu,
|
unsigned int mtu,
|
||||||
const char *desc,
|
|
||||||
void (*handler)(void *,const MAC &,const MAC &,unsigned int,const Buffer<4096> &),
|
void (*handler)(void *,const MAC &,const MAC &,unsigned int,const Buffer<4096> &),
|
||||||
void *arg)
|
void *arg)
|
||||||
throw(std::runtime_error);
|
throw(std::runtime_error);
|
||||||
|
|
|
@ -139,6 +139,9 @@ Network::~Network()
|
||||||
SharedPtr<Network> Network::newInstance(const RuntimeEnvironment *renv,uint64_t id)
|
SharedPtr<Network> Network::newInstance(const RuntimeEnvironment *renv,uint64_t id)
|
||||||
throw(std::runtime_error)
|
throw(std::runtime_error)
|
||||||
{
|
{
|
||||||
|
char tag[32];
|
||||||
|
sprintf(tag,"%.16llx",(unsigned long long)id);
|
||||||
|
|
||||||
// We construct Network via a static method to ensure that it is immediately
|
// We construct Network via a static method to ensure that it is immediately
|
||||||
// wrapped in a SharedPtr<>. Otherwise if there is traffic on the Ethernet
|
// wrapped in a SharedPtr<>. Otherwise if there is traffic on the Ethernet
|
||||||
// tap device, a SharedPtr<> wrap can occur in the Ethernet frame handler
|
// tap device, a SharedPtr<> wrap can occur in the Ethernet frame handler
|
||||||
|
@ -150,7 +153,7 @@ SharedPtr<Network> Network::newInstance(const RuntimeEnvironment *renv,uint64_t
|
||||||
nw->_rlLimit.bytesPerSecond = ZT_MULTICAST_DEFAULT_BYTES_PER_SECOND;
|
nw->_rlLimit.bytesPerSecond = ZT_MULTICAST_DEFAULT_BYTES_PER_SECOND;
|
||||||
nw->_rlLimit.maxBalance = ZT_MULTICAST_DEFAULT_RATE_MAX_BALANCE;
|
nw->_rlLimit.maxBalance = ZT_MULTICAST_DEFAULT_RATE_MAX_BALANCE;
|
||||||
nw->_rlLimit.minBalance = ZT_MULTICAST_DEFAULT_RATE_MIN_BALANCE;
|
nw->_rlLimit.minBalance = ZT_MULTICAST_DEFAULT_RATE_MIN_BALANCE;
|
||||||
nw->_tap = new EthernetTap(renv,renv->identity.address().toMAC(),ZT_IF_MTU,(const char *)0,&_CBhandleTapData,nw.ptr());
|
nw->_tap = new EthernetTap(renv,tag,renv->identity.address().toMAC(),ZT_IF_MTU,&_CBhandleTapData,nw.ptr());
|
||||||
nw->_id = id;
|
nw->_id = id;
|
||||||
nw->_lastConfigUpdate = 0;
|
nw->_lastConfigUpdate = 0;
|
||||||
nw->_destroyOnDelete = false;
|
nw->_destroyOnDelete = false;
|
||||||
|
|
|
@ -118,6 +118,7 @@ public:
|
||||||
* @return Number of characters actually written
|
* @return Number of characters actually written
|
||||||
*/
|
*/
|
||||||
static unsigned int unhex(const char *hex,void *buf,unsigned int len);
|
static unsigned int unhex(const char *hex,void *buf,unsigned int len);
|
||||||
|
static inline unsigned int unhex(const std::string &hex,void *buf,unsigned int len) { return unhex(hex.c_str(),buf,len); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param buf Buffer to fill
|
* @param buf Buffer to fill
|
||||||
|
|
Loading…
Add table
Reference in a new issue