mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-29 15:43:52 +00:00
Network build fixes and cleanup of remaining internal references to _tap
This commit is contained in:
parent
488f5bf977
commit
a86300c58f
@ -252,12 +252,12 @@ enum ZT1_VirtualNetworkStatus
|
||||
/**
|
||||
* Waiting for network configuration (also means revision == 0)
|
||||
*/
|
||||
ZT1_NETWORK_STATUS_WAITING = 0,
|
||||
ZT1_NETWORK_STATUS_REQUESTING_CONFIGURATION = 0,
|
||||
|
||||
/**
|
||||
* Configuration received and we are authorized
|
||||
*/
|
||||
ZT1_NETWORK_STATUS_AUTHORIZED = 1,
|
||||
ZT1_NETWORK_STATUS_OK = 1,
|
||||
|
||||
/**
|
||||
* Netconf master told us 'nope'
|
||||
@ -267,7 +267,12 @@ enum ZT1_VirtualNetworkStatus
|
||||
/**
|
||||
* Netconf master exists, but this virtual network does not
|
||||
*/
|
||||
ZT1_NETWORK_STATUS_NOT_FOUND = 3
|
||||
ZT1_NETWORK_STATUS_NOT_FOUND = 3,
|
||||
|
||||
/**
|
||||
* Initialization of network failed or other internal error
|
||||
*/
|
||||
ZT1_NETWORK_STATUS_INITIALIZATION_FAILED = 4
|
||||
};
|
||||
|
||||
/**
|
||||
|
11
node/MAC.hpp
11
node/MAC.hpp
@ -48,17 +48,6 @@ public:
|
||||
MAC() throw() : _m(0ULL) {}
|
||||
MAC(const MAC &m) throw() : _m(m._m) {}
|
||||
|
||||
/**
|
||||
* @param octet Single octet to fill entire MAC with (e.g. 0xff for broadcast)
|
||||
*/
|
||||
MAC(const unsigned char octet) throw() :
|
||||
_m( ((((uint64_t)octet) & 0xffULL) << 40) |
|
||||
((((uint64_t)octet) & 0xffULL) << 32) |
|
||||
((((uint64_t)octet) & 0xffULL) << 24) |
|
||||
((((uint64_t)octet) & 0xffULL) << 16) |
|
||||
((((uint64_t)octet) & 0xffULL) << 8) |
|
||||
(((uint64_t)octet) & 0xffULL) ) {}
|
||||
|
||||
MAC(const unsigned char a,const unsigned char b,const unsigned char c,const unsigned char d,const unsigned char e,const unsigned char f) throw() :
|
||||
_m( ((((uint64_t)a) & 0xffULL) << 40) |
|
||||
((((uint64_t)b) & 0xffULL) << 32) |
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
// the Multicast Group ADI field. Making V4 ARP work is basically why
|
||||
// ADI was added, as well as handling other things that want mindless
|
||||
// Ethernet broadcast to all.
|
||||
return MulticastGroup(MAC((unsigned char)0xff),Utils::ntoh(*((const uint32_t *)ip.rawIpData())));
|
||||
return MulticastGroup(MAC(0xffffffffffffULL),Utils::ntoh(*((const uint32_t *)ip.rawIpData())));
|
||||
} else if (ip.isV6()) {
|
||||
// IPv6 is better designed in this respect. We can compute the IPv6
|
||||
// multicast address directly from the IP address, and it gives us
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
const ZeroTier::MulticastGroup Network::BROADCAST(ZeroTier::MAC(0xff),0);
|
||||
const ZeroTier::MulticastGroup Network::BROADCAST(ZeroTier::MAC(0xffffffffffffULL),0);
|
||||
|
||||
Network::Network(const RuntimeEnvironment *renv,uint64_t nwid) :
|
||||
RR(renv),
|
||||
@ -113,7 +113,7 @@ Network::~Network()
|
||||
Utils::snprintf(n,sizeof(n),"networks.d/%.16llx.mcerts",_id);
|
||||
Mutex::Lock _l(_lock);
|
||||
|
||||
if ((!_config)||(_config.isPublic())||(_membershipCertificates.size() == 0)) {
|
||||
if ((!_config)||(_config->isPublic())||(_membershipCertificates.size() == 0)) {
|
||||
RR->node->dataStoreDelete(n);
|
||||
return;
|
||||
}
|
||||
@ -141,8 +141,8 @@ public:
|
||||
if ( ( (p->hasActiveDirectPath(_now)) && (_network->isAllowed(p->address())) ) || (std::find(_supernodeAddresses.begin(),_supernodeAddresses.end(),p->address()) != _supernodeAddresses.end()) ) {
|
||||
Packet outp(p->address(),RR->identity.address(),Packet::VERB_MULTICAST_LIKE);
|
||||
|
||||
std::set<MulticastGroup> mgs(_network->multicastGroups());
|
||||
for(std::set<MulticastGroup>::iterator mg(mgs.begin());mg!=mgs.end();++mg) {
|
||||
std::vector<MulticastGroup> mgs(_network->multicastGroups());
|
||||
for(std::vector<MulticastGroup>::iterator mg(mgs.begin());mg!=mgs.end();++mg) {
|
||||
if ((outp.size() + 18) > ZT_UDP_DEFAULT_PAYLOAD_MTU) {
|
||||
outp.armor(p->key(),true);
|
||||
p->send(RR,outp.data(),outp.size(),_now);
|
||||
@ -194,7 +194,7 @@ bool Network::applyConfiguration(const SharedPtr<NetworkConfig> &conf)
|
||||
int Network::setConfiguration(const Dictionary &conf,bool saveToDisk)
|
||||
{
|
||||
try {
|
||||
SharedPtr<NetworkConfig> newConfig(new NetworkConfig(conf)); // throws if invalid
|
||||
const SharedPtr<NetworkConfig> newConfig(new NetworkConfig(conf)); // throws if invalid
|
||||
{
|
||||
Mutex::Lock _l(_lock);
|
||||
if ((_config)&&(*_config == *newConfig))
|
||||
@ -368,19 +368,18 @@ void Network::clean()
|
||||
}
|
||||
}
|
||||
|
||||
Network::Status Network::status() const
|
||||
ZT1_VirtualNetworkStatus Network::status() const
|
||||
{
|
||||
Mutex::Lock _l(_lock);
|
||||
switch(_netconfFailure) {
|
||||
case NETCONF_FAILURE_ACCESS_DENIED:
|
||||
return NETWORK_ACCESS_DENIED;
|
||||
return ZT1_NETWORK_STATUS_ACCESS_DENIED;
|
||||
case NETCONF_FAILURE_NOT_FOUND:
|
||||
return NETWORK_NOT_FOUND;
|
||||
return ZT1_NETWORK_STATUS_NOT_FOUND;
|
||||
case NETCONF_FAILURE_NONE:
|
||||
return ((_lastConfigUpdate > 0) ? ((_tap) ? NETWORK_OK : NETWORK_INITIALIZING) : NETWORK_WAITING_FOR_FIRST_AUTOCONF);
|
||||
//case NETCONF_FAILURE_INIT_FAILED:
|
||||
return ((_lastConfigUpdate > 0) ? ZT1_NETWORK_STATUS_OK : ZT1_NETWORK_STATUS_REQUESTING_CONFIGURATION);
|
||||
default:
|
||||
return NETWORK_INITIALIZATION_FAILED;
|
||||
return ZT1_NETWORK_STATUS_INITIALIZATION_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -413,8 +412,6 @@ void Network::setEnabled(bool enabled)
|
||||
{
|
||||
Mutex::Lock _l(_lock);
|
||||
_enabled = enabled;
|
||||
if (_tap)
|
||||
_tap->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void Network::destroy()
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../include/ZeroTierOne.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@ -46,8 +48,6 @@
|
||||
#include "MulticastGroup.hpp"
|
||||
#include "MAC.hpp"
|
||||
#include "Dictionary.hpp"
|
||||
#include "Identity.hpp"
|
||||
#include "InetAddress.hpp"
|
||||
#include "BandwidthAccount.hpp"
|
||||
#include "Multicaster.hpp"
|
||||
#include "NetworkConfig.hpp"
|
||||
@ -78,20 +78,6 @@ public:
|
||||
*/
|
||||
static const MulticastGroup BROADCAST;
|
||||
|
||||
/**
|
||||
* Possible network states
|
||||
*/
|
||||
enum Status
|
||||
{
|
||||
NETWORK_INITIALIZING = 0, // Creating tap device and setting up state
|
||||
NETWORK_WAITING_FOR_FIRST_AUTOCONF = 1, // Waiting for initial setup with netconf master
|
||||
NETWORK_OK = 2, // Network is up, seems to be working
|
||||
NETWORK_ACCESS_DENIED = 3, // Netconf node reported permission denied
|
||||
NETWORK_NOT_FOUND = 4, // Netconf node reported network not found
|
||||
NETWORK_INITIALIZATION_FAILED = 5, // Cannot initialize device (OS/installation problem?)
|
||||
NETWORK_NO_MORE_DEVICES = 6 // OS cannot create any more tap devices (some OSes have a limit)
|
||||
};
|
||||
|
||||
/**
|
||||
* @return Network ID
|
||||
*/
|
||||
@ -206,7 +192,7 @@ public:
|
||||
/**
|
||||
* @return Status of this network
|
||||
*/
|
||||
Status status() const;
|
||||
ZT1_VirtualNetworkStatus status() const;
|
||||
|
||||
/**
|
||||
* Update and check multicast rate balance for a multicast group
|
||||
|
Loading…
x
Reference in New Issue
Block a user