Plumbing through circuit test stuff.
This commit is contained in:
parent
5341afcdcd
commit
d3f29d09e8
5 changed files with 339 additions and 41 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "../version.h"
|
||||
#include "../include/ZeroTierOne.h"
|
||||
|
||||
#include "Constants.hpp"
|
||||
#include "Defaults.hpp"
|
||||
|
@ -1033,13 +1034,13 @@ bool IncomingPacket::_doCIRCUIT_TEST(const RuntimeEnvironment *RR,const SharedPt
|
|||
outp.append((uint64_t)timestamp);
|
||||
outp.append((uint64_t)testId);
|
||||
outp.append((uint64_t)now);
|
||||
outp.append((uint8_t)0); // vendor ID, currently unused
|
||||
outp.append((uint8_t)ZT_VENDOR_ZEROTIER);
|
||||
outp.append((uint8_t)ZT_PROTO_VERSION);
|
||||
outp.append((uint8_t)ZEROTIER_ONE_VERSION_MAJOR);
|
||||
outp.append((uint8_t)ZEROTIER_ONE_VERSION_MINOR);
|
||||
outp.append((uint16_t)ZEROTIER_ONE_VERSION_REVISION);
|
||||
outp.append((uint16_t)CIRCUIT_TEST_REPORT_PLATFORM_UNSPECIFIED);
|
||||
outp.append((uint16_t)CIRCUIT_TEST_REPORT_ARCH_UNSPECIFIED);
|
||||
outp.append((uint16_t)ZT_PLATFORM_UNSPECIFIED);
|
||||
outp.append((uint16_t)ZT_ARCHITECTURE_UNSPECIFIED);
|
||||
outp.append((uint16_t)0); // error code, currently unused
|
||||
outp.append((uint64_t)0); // flags, currently unused
|
||||
outp.append((uint64_t)packetId());
|
||||
|
|
|
@ -464,6 +464,28 @@ void Node::setNetconfMaster(void *networkControllerInstance)
|
|||
RR->localNetworkController = reinterpret_cast<NetworkController *>(networkControllerInstance);
|
||||
}
|
||||
|
||||
ZT_ResultCode Node::circuitTestBegin(ZT_CircuitTest *test,void (*reportCallback)(ZT_Node *,ZT_CircuitTest *,const ZT_CircuitTestReport *))
|
||||
{
|
||||
{
|
||||
test->_internalPtr = reinterpret_cast<void *>(reportCallback);
|
||||
Mutex::Lock _l(_circuitTests_m);
|
||||
if (std::find(_circuitTests.begin(),_circuitTests.end(),test) == _circuitTests.end())
|
||||
_circuitTests.push_back(test);
|
||||
}
|
||||
return ZT_RESULT_OK;
|
||||
}
|
||||
|
||||
void Node::circuitTestEnd(ZT_CircuitTest *test)
|
||||
{
|
||||
Mutex::Lock _l(_circuitTests_m);
|
||||
for(;;) {
|
||||
std::vector< ZT_CircuitTest * >::iterator ct(std::find(_circuitTests.begin(),_circuitTests.end(),test));
|
||||
if (ct == _circuitTests.end())
|
||||
break;
|
||||
else _circuitTests.erase(ct);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Node methods used only within node/ */
|
||||
/****************************************************************************/
|
||||
|
@ -533,6 +555,20 @@ uint64_t Node::prng()
|
|||
return _prngStream[p];
|
||||
}
|
||||
|
||||
void Node::postCircuitTestReport(const ZT_CircuitTestReport *report)
|
||||
{
|
||||
std::vector< ZT_CircuitTest * > toNotify;
|
||||
{
|
||||
Mutex::Lock _l(_circuitTests_m);
|
||||
for(std::vector< ZT_CircuitTest * >::iterator i(_circuitTests.begin());i!=_circuitTests.end();++i) {
|
||||
if ((*i)->testId == report->testId)
|
||||
toNotify.push_back(*i);
|
||||
}
|
||||
}
|
||||
for(std::vector< ZT_CircuitTest * >::iterator i(toNotify.begin());i!=toNotify.end();++i)
|
||||
(reinterpret_cast<void (*)(ZT_Node *,ZT_CircuitTest *,const ZT_CircuitTestReport *)>((*i)->_internalPtr))(reinterpret_cast<ZT_Node *>(this),*i,report);
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
||||
/****************************************************************************/
|
||||
|
@ -721,6 +757,22 @@ void ZT_Node_setNetconfMaster(ZT_Node *node,void *networkControllerInstance)
|
|||
} catch ( ... ) {}
|
||||
}
|
||||
|
||||
ZT_ResultCode ZT_Node_circuitTestBegin(ZT_Node *node,ZT_CircuitTest *test,void (*reportCallback)(ZT_Node *,ZT_CircuitTest *,const ZT_CircuitTestReport *))
|
||||
{
|
||||
try {
|
||||
return reinterpret_cast<ZeroTier::Node *>(node)->circuitTestBegin(test,reportCallback);
|
||||
} catch ( ... ) {
|
||||
return ZT_RESULT_FATAL_ERROR_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
void ZT_Node_circuitTestEnd(ZT_Node *node,ZT_CircuitTest *test)
|
||||
{
|
||||
try {
|
||||
reinterpret_cast<ZeroTier::Node *>(node)->circuitTestEnd(test);
|
||||
} catch ( ... ) {}
|
||||
}
|
||||
|
||||
int ZT_Node_addLocalInterfaceAddress(ZT_Node *node,const struct sockaddr_storage *addr,int metric,ZT_LocalInterfaceAddressTrust trust)
|
||||
{
|
||||
try {
|
||||
|
|
|
@ -109,6 +109,8 @@ public:
|
|||
int addLocalInterfaceAddress(const struct sockaddr_storage *addr,int metric,ZT_LocalInterfaceAddressTrust trust);
|
||||
void clearLocalInterfaceAddresses();
|
||||
void setNetconfMaster(void *networkControllerInstance);
|
||||
ZT_ResultCode circuitTestBegin(ZT_CircuitTest *test,void (*reportCallback)(ZT_Node *,ZT_CircuitTest *,const ZT_CircuitTestReport *));
|
||||
void circuitTestEnd(ZT_CircuitTest *test);
|
||||
|
||||
// Internal functions ------------------------------------------------------
|
||||
|
||||
|
@ -238,6 +240,13 @@ public:
|
|||
*/
|
||||
uint64_t prng();
|
||||
|
||||
/**
|
||||
* Post a circuit test report to any listeners for a given test ID
|
||||
*
|
||||
* @param report Report (includes test ID)
|
||||
*/
|
||||
void postCircuitTestReport(const ZT_CircuitTestReport *report);
|
||||
|
||||
private:
|
||||
inline SharedPtr<Network> _network(uint64_t nwid) const
|
||||
{
|
||||
|
@ -264,6 +273,9 @@ private:
|
|||
std::vector< std::pair< uint64_t, SharedPtr<Network> > > _networks;
|
||||
Mutex _networks_m;
|
||||
|
||||
std::vector< ZT_CircuitTest * > _circuitTests;
|
||||
Mutex _circuitTests_m;
|
||||
|
||||
std::vector<Path> _directPaths;
|
||||
Mutex _directPaths_m;
|
||||
|
||||
|
|
|
@ -1020,44 +1020,6 @@ public:
|
|||
VERB_CIRCUIT_TEST_REPORT = 18
|
||||
};
|
||||
|
||||
/**
|
||||
* Platforms reported in circuit tests
|
||||
*/
|
||||
enum CircuitTestReportPlatform
|
||||
{
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_UNSPECIFIED = 0,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_LINUX = 1,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_WINDOWS = 2,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_MACOS = 3,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_ANDROID = 4,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_IOS = 5,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_SOLARIS_SMARTOS = 6,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_FREEBSD = 7,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_NETBSD = 8,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_OPENBSD = 9,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_RISCOS = 10,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_VXWORKS = 11,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_FREERTOS = 12,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_SYSBIOS = 13,
|
||||
CIRCUIT_TEST_REPORT_PLATFORM_HURD = 14
|
||||
};
|
||||
|
||||
/**
|
||||
* Architectures reported in circuit tests
|
||||
*/
|
||||
enum CircuitTestReportArchitecture
|
||||
{
|
||||
CIRCUIT_TEST_REPORT_ARCH_UNSPECIFIED = 0,
|
||||
CIRCUIT_TEST_REPORT_ARCH_X86 = 1,
|
||||
CIRCUIT_TEST_REPORT_ARCH_X64 = 2,
|
||||
CIRCUIT_TEST_REPORT_ARCH_ARM32 = 3,
|
||||
CIRCUIT_TEST_REPORT_ARCH_ARM64 = 4,
|
||||
CIRCUIT_TEST_REPORT_ARCH_MIPS32 = 5,
|
||||
CIRCUIT_TEST_REPORT_ARCH_MIPS64 = 6,
|
||||
CIRCUIT_TEST_REPORT_ARCH_POWER32 = 7,
|
||||
CIRCUIT_TEST_REPORT_ARCH_POWER64 = 8
|
||||
};
|
||||
|
||||
/**
|
||||
* Error codes for VERB_ERROR
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue