Rename netconf to controller and NetworkConfigMaster to NetworkController for consistency.

This commit is contained in:
Adam Ierymenko 2015-04-15 15:12:09 -07:00
parent 871473255b
commit 6369c264e2
21 changed files with 103 additions and 130 deletions

View file

@ -38,7 +38,7 @@
#include "Topology.hpp"
#include "Switch.hpp"
#include "Peer.hpp"
#include "NetworkConfigMaster.hpp"
#include "NetworkController.hpp"
#include "SelfAwareness.hpp"
namespace ZeroTier {
@ -361,14 +361,14 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *RR,const SharedPtr<Peer> &p
if (dict.length()) {
if (nw->setConfiguration(Dictionary(dict)) == 2) { // 2 == accepted and actually new
/* If this configuration was indeed new, we do another
* netconf request with its revision. We do this in
* order to (a) tell the netconf server we got it (it
* controller request with its revision. We do this in
* order to (a) tell the network controller we got it (it
* won't send a duplicate if ts == current), and (b)
* get another one if the netconf is changing rapidly
* get another one if the controller is changing rapidly
* until we finally have the final version.
*
* Note that we don't do this for netconf masters with
* versions <= 1.0.3, since those regenerate a new netconf
* Note that we don't do this for network controllers with
* versions <= 1.0.3, since those regenerate a new controller
* with a new revision every time. In that case this double
* confirmation would create a race condition. */
const SharedPtr<NetworkConfig> nc(nw->config2());
@ -672,10 +672,10 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,cons
const uint64_t pid = packetId();
peer->received(RR,_remoteAddress,_linkDesperation,h,pid,Packet::VERB_NETWORK_CONFIG_REQUEST,0,Packet::VERB_NOP);
if (RR->netconfMaster) {
if (RR->localNetworkController) {
Dictionary netconf;
switch(RR->netconfMaster->doNetworkConfigRequest((h > 0) ? InetAddress() : _remoteAddress,peer->identity(),nwid,metaData,haveRevision,netconf)) {
case NetworkConfigMaster::NETCONF_QUERY_OK: {
switch(RR->localNetworkController->doNetworkConfigRequest((h > 0) ? InetAddress() : _remoteAddress,peer->identity(),nwid,metaData,haveRevision,netconf)) {
case NetworkController::NETCONF_QUERY_OK: {
const std::string netconfStr(netconf.toString());
if (netconfStr.length() > 0xffff) { // sanity check since field ix 16-bit
TRACE("NETWORK_CONFIG_REQUEST failed: internal error: netconf size %u is too large",(unsigned int)netconfStr.length());
@ -694,9 +694,9 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,cons
}
}
} break;
case NetworkConfigMaster::NETCONF_QUERY_OK_BUT_NOT_NEWER: // nothing to do -- netconf has not changed
case NetworkController::NETCONF_QUERY_OK_BUT_NOT_NEWER: // nothing to do -- netconf has not changed
break;
case NetworkConfigMaster::NETCONF_QUERY_OBJECT_NOT_FOUND: {
case NetworkController::NETCONF_QUERY_OBJECT_NOT_FOUND: {
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
outp.append(pid);
@ -705,7 +705,7 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,cons
outp.armor(peer->key(),true);
RR->node->putPacket(_remoteAddress,outp.data(),outp.size(),_linkDesperation);
} break;
case NetworkConfigMaster::NETCONF_QUERY_ACCESS_DENIED: {
case NetworkController::NETCONF_QUERY_ACCESS_DENIED: {
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
outp.append(pid);
@ -714,11 +714,11 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,cons
outp.armor(peer->key(),true);
RR->node->putPacket(_remoteAddress,outp.data(),outp.size(),_linkDesperation);
} break;
case NetworkConfigMaster::NETCONF_QUERY_INTERNAL_SERVER_ERROR:
case NetworkController::NETCONF_QUERY_INTERNAL_SERVER_ERROR:
TRACE("NETWORK_CONFIG_REQUEST failed: internal error: %s",netconf.get("error","(unknown)").c_str());
break;
default:
TRACE("NETWORK_CONFIG_REQUEST failed: invalid return value from NetworkConfigMaster::doNetworkConfigRequest()");
TRACE("NETWORK_CONFIG_REQUEST failed: invalid return value from NetworkController::doNetworkConfigRequest()");
break;
}
} else {

View file

@ -36,7 +36,7 @@
#include "Switch.hpp"
#include "Packet.hpp"
#include "Buffer.hpp"
#include "NetworkConfigMaster.hpp"
#include "NetworkController.hpp"
namespace ZeroTier {
@ -243,21 +243,21 @@ int Network::setConfiguration(const Dictionary &conf,bool saveToDisk)
void Network::requestConfiguration()
{
if (_id == ZT_TEST_NETWORK_ID) // pseudo-network-ID, no netconf master
if (_id == ZT_TEST_NETWORK_ID) // pseudo-network-ID, uses locally generated static config
return;
if (controller() == RR->identity.address()) {
if (RR->netconfMaster) {
if (RR->localNetworkController) {
SharedPtr<NetworkConfig> nconf(config2());
Dictionary newconf;
switch(RR->netconfMaster->doNetworkConfigRequest(InetAddress(),RR->identity,_id,Dictionary(),(nconf) ? nconf->revision() : (uint64_t)0,newconf)) {
case NetworkConfigMaster::NETCONF_QUERY_OK:
switch(RR->localNetworkController->doNetworkConfigRequest(InetAddress(),RR->identity,_id,Dictionary(),(nconf) ? nconf->revision() : (uint64_t)0,newconf)) {
case NetworkController::NETCONF_QUERY_OK:
this->setConfiguration(newconf,true);
return;
case NetworkConfigMaster::NETCONF_QUERY_OBJECT_NOT_FOUND:
case NetworkController::NETCONF_QUERY_OBJECT_NOT_FOUND:
this->setNotFound();
return;
case NetworkConfigMaster::NETCONF_QUERY_ACCESS_DENIED:
case NetworkController::NETCONF_QUERY_ACCESS_DENIED:
this->setAccessDenied();
return;
default:
@ -269,7 +269,7 @@ void Network::requestConfiguration()
}
}
TRACE("requesting netconf for network %.16llx from netconf master %s",(unsigned long long)_id,controller().toString().c_str());
TRACE("requesting netconf for network %.16llx from controller %s",(unsigned long long)_id,controller().toString().c_str());
Packet outp(controller(),RR->identity.address(),Packet::VERB_NETWORK_CONFIG_REQUEST);
outp.append((uint64_t)_id);
outp.append((uint16_t)0); // no meta-data
@ -304,7 +304,7 @@ void Network::addMembershipCertificate(const CertificateOfMembership &cert,bool
SharedPtr<Peer> signer(RR->topology->getPeer(cert.signedBy()));
if (!signer) {
// This would be rather odd, since this is our netconf master... could happen
// This would be rather odd, since this is our controller... could happen
// if we get packets before we've gotten config.
RR->sw->requestWhois(cert.signedBy());
return;

View file

@ -88,7 +88,7 @@ public:
inline uint64_t id() const throw() { return _id; }
/**
* @return Address of network's netconf master (most significant 40 bits of ID)
* @return Address of network's controller (most significant 40 bits of ID)
*/
inline Address controller() throw() { return Address(_id >> 24); }
@ -148,7 +148,7 @@ public:
int setConfiguration(const Dictionary &conf,bool saveToDisk = true);
/**
* Set netconf failure to 'access denied' -- called in IncomingPacket when netconf master reports this
* Set netconf failure to 'access denied' -- called in IncomingPacket when controller reports this
*/
inline void setAccessDenied()
{
@ -157,7 +157,7 @@ public:
}
/**
* Set netconf failure to 'not found' -- called by PacketDecider when netconf master reports this
* Set netconf failure to 'not found' -- called by PacketDecider when controller reports this
*/
inline void setNotFound()
{

View file

@ -109,7 +109,7 @@ void NetworkConfig::_fromDictionary(const Dictionary &d)
throw std::invalid_argument("configuration contains zero network ID");
_timestamp = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP).c_str());
_revision = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_REVISION,"1").c_str()); // older netconf masters don't send this, so default to 1
_revision = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_REVISION,"1").c_str()); // older controllers don't send this, so default to 1
memset(_etWhitelist,0,sizeof(_etWhitelist));
std::vector<std::string> ets(Utils::split(d.get(ZT_NETWORKCONFIG_DICT_KEY_ALLOWED_ETHERNET_TYPES).c_str(),",","",""));

View file

@ -68,9 +68,9 @@ namespace ZeroTier {
#define ZT_NETWORKCONFIG_DICT_KEY_RELAYS "rl"
/**
* Network configuration received from netconf master nodes
* Network configuration received from network controller nodes
*
* This is an immutable value object created from a dictionary received from netconf master.
* This is an immutable value object created from a dictionary received from controller.
*/
class NetworkConfig
{
@ -102,10 +102,10 @@ public:
* Create an instance of a NetworkConfig for the test network ID
*
* The test network ID is defined as ZT_TEST_NETWORK_ID. This is a
* "fake" network with no real netconf master and default options.
* "fake" network with no real controller and default options.
*
* @param self This node's ZT address
* @return Configured instance of netconf for test network ID
* @return Configuration for test network ID
*/
static SharedPtr<NetworkConfig> createTestNetworkConfig(const Address &self);

View file

@ -43,7 +43,7 @@ class RuntimeEnvironment;
/**
* Interface for network configuration (netconf) master implementations
*/
class NetworkConfigMaster
class NetworkController
{
public:
/**
@ -58,8 +58,8 @@ public:
NETCONF_QUERY_INTERNAL_SERVER_ERROR = 4
};
NetworkConfigMaster() {}
virtual ~NetworkConfigMaster() {}
NetworkController() {}
virtual ~NetworkController() {}
/**
* Handle a network config request, sending replies if necessary
@ -78,7 +78,7 @@ public:
* @param result Dictionary to receive resulting signed netconf on success
* @return Returns NETCONF_QUERY_OK if result dictionary is valid, or an error code on error
*/
virtual NetworkConfigMaster::ResultCode doNetworkConfigRequest(
virtual NetworkController::ResultCode doNetworkConfigRequest(
const InetAddress &fromAddr,
const Identity &identity,
uint64_t nwid,

View file

@ -30,7 +30,7 @@
#include "Constants.hpp"
#include "Node.hpp"
#include "RuntimeEnvironment.hpp"
#include "NetworkConfigMaster.hpp"
#include "NetworkController.hpp"
#include "CMWC4096.hpp"
#include "Switch.hpp"
#include "Multicaster.hpp"
@ -407,9 +407,9 @@ void Node::freeQueryResult(void *qr)
::free(qr);
}
void Node::setNetconfMaster(void *networkConfigMasterInstance)
void Node::setNetconfMaster(void *networkControllerInstance)
{
RR->netconfMaster = reinterpret_cast<NetworkConfigMaster *>(networkConfigMasterInstance);
RR->localNetworkController = reinterpret_cast<NetworkController *>(networkControllerInstance);
}
/****************************************************************************/
@ -654,10 +654,10 @@ void ZT1_Node_freeQueryResult(ZT1_Node *node,void *qr)
} catch ( ... ) {}
}
void ZT1_Node_setNetconfMaster(ZT1_Node *node,void *networkConfigMasterInstance)
void ZT1_Node_setNetconfMaster(ZT1_Node *node,void *networkControllerInstance)
{
try {
reinterpret_cast<ZeroTier::Node *>(node)->setNetconfMaster(networkConfigMasterInstance);
reinterpret_cast<ZeroTier::Node *>(node)->setNetconfMaster(networkControllerInstance);
} catch ( ... ) {}
}

View file

@ -105,7 +105,7 @@ public:
ZT1_VirtualNetworkConfig *networkConfig(uint64_t nwid) const;
ZT1_VirtualNetworkList *networks() const;
void freeQueryResult(void *qr);
void setNetconfMaster(void *networkConfigMasterInstance);
void setNetconfMaster(void *networkControllerInstance);
// Internal functions ------------------------------------------------------

View file

@ -42,7 +42,7 @@ class CMWC4096;
class Node;
class Multicaster;
class AntiRecursion;
class NetworkConfigMaster;
class NetworkController;
class SelfAwareness;
/**
@ -54,7 +54,7 @@ public:
RuntimeEnvironment(Node *n) :
node(n),
identity(),
netconfMaster((NetworkConfigMaster *)0),
localNetworkController((NetworkController *)0),
prng((CMWC4096 *)0),
sw((Switch *)0),
mc((Multicaster *)0),
@ -72,8 +72,8 @@ public:
std::string publicIdentityStr;
std::string secretIdentityStr;
// This is set externally to an instance of this base class if netconf functionality is enabled
NetworkConfigMaster *netconfMaster;
// This is set externally to an instance of this base class
NetworkController *localNetworkController;
/*
* Order matters a bit here. These are constructed in this order