mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-03-05 13:47:49 +00:00
Docs and cleanup.
This commit is contained in:
parent
740eb6ebc4
commit
3883ac08c7
@ -47,7 +47,7 @@ const ZeroTier::MulticastGroup Network::BROADCAST(ZeroTier::MAC(0xffffffffffffUL
|
|||||||
|
|
||||||
Network::Network(const RuntimeEnvironment *renv,uint64_t nwid,void *uptr) :
|
Network::Network(const RuntimeEnvironment *renv,uint64_t nwid,void *uptr) :
|
||||||
RR(renv),
|
RR(renv),
|
||||||
_uptr(uptr),
|
_uPtr(uptr),
|
||||||
_id(nwid),
|
_id(nwid),
|
||||||
_mac(renv->identity.address(),nwid),
|
_mac(renv->identity.address(),nwid),
|
||||||
_enabled(true),
|
_enabled(true),
|
||||||
@ -89,7 +89,7 @@ Network::Network(const RuntimeEnvironment *renv,uint64_t nwid,void *uptr) :
|
|||||||
if (!_portInitialized) {
|
if (!_portInitialized) {
|
||||||
ZT_VirtualNetworkConfig ctmp;
|
ZT_VirtualNetworkConfig ctmp;
|
||||||
_externalConfig(&ctmp);
|
_externalConfig(&ctmp);
|
||||||
_portError = RR->node->configureVirtualNetworkPort(_id,&_uptr,ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP,&ctmp);
|
_portError = RR->node->configureVirtualNetworkPort(_id,&_uPtr,ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP,&ctmp);
|
||||||
_portInitialized = true;
|
_portInitialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,11 +101,11 @@ Network::~Network()
|
|||||||
|
|
||||||
char n[128];
|
char n[128];
|
||||||
if (_destroyed) {
|
if (_destroyed) {
|
||||||
RR->node->configureVirtualNetworkPort(_id,&_uptr,ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY,&ctmp);
|
RR->node->configureVirtualNetworkPort(_id,&_uPtr,ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY,&ctmp);
|
||||||
Utils::snprintf(n,sizeof(n),"networks.d/%.16llx.conf",_id);
|
Utils::snprintf(n,sizeof(n),"networks.d/%.16llx.conf",_id);
|
||||||
RR->node->dataStoreDelete(n);
|
RR->node->dataStoreDelete(n);
|
||||||
} else {
|
} else {
|
||||||
RR->node->configureVirtualNetworkPort(_id,&_uptr,ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN,&ctmp);
|
RR->node->configureVirtualNetworkPort(_id,&_uPtr,ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN,&ctmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ bool Network::applyConfiguration(const SharedPtr<NetworkConfig> &conf)
|
|||||||
portInitialized = _portInitialized;
|
portInitialized = _portInitialized;
|
||||||
_portInitialized = true;
|
_portInitialized = true;
|
||||||
}
|
}
|
||||||
_portError = RR->node->configureVirtualNetworkPort(_id,&_uptr,(portInitialized) ? ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE : ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP,&ctmp);
|
_portError = RR->node->configureVirtualNetworkPort(_id,&_uPtr,(portInitialized) ? ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE : ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP,&ctmp);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
TRACE("ignored invalid configuration for network %.16llx (configuration contains mismatched network ID or issued-to address)",(unsigned long long)_id);
|
TRACE("ignored invalid configuration for network %.16llx (configuration contains mismatched network ID or issued-to address)",(unsigned long long)_id);
|
||||||
@ -332,7 +332,7 @@ void Network::setEnabled(bool enabled)
|
|||||||
_enabled = enabled;
|
_enabled = enabled;
|
||||||
ZT_VirtualNetworkConfig ctmp;
|
ZT_VirtualNetworkConfig ctmp;
|
||||||
_externalConfig(&ctmp);
|
_externalConfig(&ctmp);
|
||||||
_portError = RR->node->configureVirtualNetworkPort(_id,&_uptr,ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE,&ctmp);
|
_portError = RR->node->configureVirtualNetworkPort(_id,&_uPtr,ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE,&ctmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @return Pointer to user PTR (modifiable user ptr used in API)
|
* @return Pointer to user PTR (modifiable user ptr used in API)
|
||||||
*/
|
*/
|
||||||
inline void **userPtr() throw() { return &_uptr; }
|
inline void **userPtr() throw() { return &_uPtr; }
|
||||||
|
|
||||||
inline bool operator==(const Network &n) const throw() { return (_id == n._id); }
|
inline bool operator==(const Network &n) const throw() { return (_id == n._id); }
|
||||||
inline bool operator!=(const Network &n) const throw() { return (_id != n._id); }
|
inline bool operator!=(const Network &n) const throw() { return (_id != n._id); }
|
||||||
@ -354,7 +354,7 @@ private:
|
|||||||
std::vector<MulticastGroup> _allMulticastGroups() const;
|
std::vector<MulticastGroup> _allMulticastGroups() const;
|
||||||
|
|
||||||
const RuntimeEnvironment *RR;
|
const RuntimeEnvironment *RR;
|
||||||
void *_uptr;
|
void *_uPtr;
|
||||||
uint64_t _id;
|
uint64_t _id;
|
||||||
MAC _mac; // local MAC address
|
MAC _mac; // local MAC address
|
||||||
volatile bool _enabled;
|
volatile bool _enabled;
|
||||||
|
@ -183,7 +183,6 @@ void Peer::received(
|
|||||||
TRACE("got %s via unknown path %s(%s), confirming...",Packet::verbString(verb),_id.address().toString().c_str(),remoteAddr.toString().c_str());
|
TRACE("got %s via unknown path %s(%s), confirming...",Packet::verbString(verb),_id.address().toString().c_str(),remoteAddr.toString().c_str());
|
||||||
|
|
||||||
if ( (_vProto >= 5) && ( !((_vMajor == 1)&&(_vMinor == 1)&&(_vRevision == 0)) ) ) {
|
if ( (_vProto >= 5) && ( !((_vMajor == 1)&&(_vMinor == 1)&&(_vRevision == 0)) ) ) {
|
||||||
// 1.1.1 and newer nodes support ECHO, which is smaller -- but 1.1.0 has a bug so use HELLO there too
|
|
||||||
Packet outp(_id.address(),RR->identity.address(),Packet::VERB_ECHO);
|
Packet outp(_id.address(),RR->identity.address(),Packet::VERB_ECHO);
|
||||||
outp.armor(_key,true);
|
outp.armor(_key,true);
|
||||||
RR->node->putPacket(localAddr,remoteAddr,outp.data(),outp.size());
|
RR->node->putPacket(localAddr,remoteAddr,outp.data(),outp.size());
|
||||||
@ -498,7 +497,6 @@ bool Peer::_checkPath(Path &p,const uint64_t now)
|
|||||||
TRACE("%s(%s) does not seem to be answering in a timely manner, checking if dead (probation == %u)",_id.address().toString().c_str(),p.address().toString().c_str(),p.probation());
|
TRACE("%s(%s) does not seem to be answering in a timely manner, checking if dead (probation == %u)",_id.address().toString().c_str(),p.address().toString().c_str(),p.probation());
|
||||||
|
|
||||||
if ( (_vProto >= 5) && ( !((_vMajor == 1)&&(_vMinor == 1)&&(_vRevision == 0)) ) ) {
|
if ( (_vProto >= 5) && ( !((_vMajor == 1)&&(_vMinor == 1)&&(_vRevision == 0)) ) ) {
|
||||||
// 1.1.1 and newer nodes support ECHO, which is smaller -- but 1.1.0 has a bug so use HELLO there too
|
|
||||||
Packet outp(_id.address(),RR->identity.address(),Packet::VERB_ECHO);
|
Packet outp(_id.address(),RR->identity.address(),Packet::VERB_ECHO);
|
||||||
outp.armor(_key,true);
|
outp.armor(_key,true);
|
||||||
p.send(RR,outp.data(),outp.size(),now);
|
p.send(RR,outp.data(),outp.size(),now);
|
||||||
|
@ -186,7 +186,7 @@ public:
|
|||||||
void pushDirectPaths(Path *path,uint64_t now,bool force);
|
void pushDirectPaths(Path *path,uint64_t now,bool force);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return All known direct paths to this peer
|
* @return All known direct paths to this peer (active or inactive)
|
||||||
*/
|
*/
|
||||||
inline std::vector<Path> paths() const
|
inline std::vector<Path> paths() const
|
||||||
{
|
{
|
||||||
@ -216,11 +216,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
inline uint64_t lastFrame() const throw() { return std::max(_lastUnicastFrame,_lastMulticastFrame); }
|
inline uint64_t lastFrame() const throw() { return std::max(_lastUnicastFrame,_lastMulticastFrame); }
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Time we last announced state TO this peer, such as multicast LIKEs
|
|
||||||
*/
|
|
||||||
inline uint64_t lastAnnouncedTo() const throw() { return _lastAnnouncedTo; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return True if this peer has sent us real network traffic recently
|
* @return True if this peer has sent us real network traffic recently
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user