mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-20 14:06:54 +02:00
More cleanup and build fixes, almost builds again!
This commit is contained in:
parent
ef64e6a336
commit
8bae0acaf9
4 changed files with 289 additions and 634 deletions
345
CMakeLists.txt
345
CMakeLists.txt
|
@ -1,143 +1,208 @@
|
|||
cmake_minimum_required(VERSION 3.15)
|
||||
project(ZeroTierOne)
|
||||
cmake_minimum_required (VERSION 3.8)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.15)
|
||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||
else()
|
||||
cmake_policy(VERSION 3.15)
|
||||
endif()
|
||||
|
||||
include_directories(controller)
|
||||
include_directories(ext)
|
||||
include_directories(ext/json)
|
||||
include_directories(include)
|
||||
include_directories(node)
|
||||
include_directories(osdep)
|
||||
include_directories(root)
|
||||
if(WIN32)
|
||||
# If building on Windows, set minimum target to Windows 7
|
||||
set(CMAKE_SYSTEM_VERSION "7" CACHE STRING INTERNAL FORCE)
|
||||
endif(WIN32)
|
||||
|
||||
add_executable(ZeroTierOne
|
||||
controller/CMakeLists.txt
|
||||
controller/DB.cpp
|
||||
controller/DB.hpp
|
||||
controller/DBMirrorSet.cpp
|
||||
controller/DBMirrorSet.hpp
|
||||
controller/EmbeddedNetworkController.cpp
|
||||
controller/EmbeddedNetworkController.hpp
|
||||
controller/FileDB.cpp
|
||||
controller/FileDB.hpp
|
||||
controller/LFDB.cpp
|
||||
controller/LFDB.hpp
|
||||
controller/PostgreSQL.cpp
|
||||
controller/PostgreSQL.hpp
|
||||
controller/RabbitMQ.cpp
|
||||
controller/RabbitMQ.hpp
|
||||
ext/json/json.hpp
|
||||
include/ZeroTierCore.h
|
||||
include/ZeroTierDebug.h
|
||||
node/Address.hpp
|
||||
node/AES.cpp
|
||||
node/AES.hpp
|
||||
node/AtomicCounter.hpp
|
||||
node/Buffer.hpp
|
||||
node/C25519.cpp
|
||||
node/C25519.hpp
|
||||
node/Capability.hpp
|
||||
node/CertificateOfMembership.hpp
|
||||
node/CertificateOfOwnership.hpp
|
||||
node/CMakeLists.txt
|
||||
node/Constants.hpp
|
||||
node/Credential.cpp
|
||||
node/Credential.hpp
|
||||
node/Dictionary.hpp
|
||||
node/ECC384.cpp
|
||||
node/ECC384.hpp
|
||||
node/Endpoint.hpp
|
||||
node/Hashtable.hpp
|
||||
node/Identity.cpp
|
||||
node/Identity.hpp
|
||||
node/IncomingPacket.cpp
|
||||
node/IncomingPacket.hpp
|
||||
node/InetAddress.cpp
|
||||
node/InetAddress.hpp
|
||||
node/Locator.hpp
|
||||
node/MAC.hpp
|
||||
node/Membership.cpp
|
||||
node/Membership.hpp
|
||||
node/Meter.hpp
|
||||
node/MulticastGroup.hpp
|
||||
node/Mutex.hpp
|
||||
node/Network.cpp
|
||||
node/Network.hpp
|
||||
node/NetworkConfig.cpp
|
||||
node/NetworkConfig.hpp
|
||||
node/NetworkController.hpp
|
||||
node/Node.cpp
|
||||
node/Node.hpp
|
||||
node/OS.hpp
|
||||
node/Packet.cpp
|
||||
node/Packet.hpp
|
||||
node/Path.cpp
|
||||
node/Path.hpp
|
||||
node/Peer.cpp
|
||||
node/Peer.hpp
|
||||
node/Poly1305.cpp
|
||||
node/Poly1305.hpp
|
||||
node/README.md
|
||||
node/Revocation.hpp
|
||||
node/RingBuffer.hpp
|
||||
node/RuntimeEnvironment.hpp
|
||||
node/Salsa20.cpp
|
||||
node/Salsa20.hpp
|
||||
node/ScopedPtr.hpp
|
||||
node/SelfAwareness.cpp
|
||||
node/SelfAwareness.hpp
|
||||
node/SHA512.cpp
|
||||
node/SHA512.hpp
|
||||
node/SharedPtr.hpp
|
||||
node/Str.hpp
|
||||
node/Switch.cpp
|
||||
node/Switch.hpp
|
||||
node/Tag.hpp
|
||||
node/Topology.hpp
|
||||
node/Trace.cpp
|
||||
node/Trace.hpp
|
||||
node/Utils.cpp
|
||||
node/Utils.hpp
|
||||
osdep/Arp.cpp
|
||||
osdep/Arp.hpp
|
||||
osdep/BlockingQueue.hpp
|
||||
osdep/BSDEthernetTap.cpp
|
||||
osdep/BSDEthernetTap.hpp
|
||||
osdep/CMakeLists.txt
|
||||
osdep/EthernetTap.cpp
|
||||
osdep/EthernetTap.hpp
|
||||
osdep/freebsd_getifmaddrs.c
|
||||
osdep/freebsd_getifmaddrs.h
|
||||
osdep/LinuxEthernetTap.cpp
|
||||
osdep/LinuxEthernetTap.hpp
|
||||
osdep/LinuxNetLink.cpp
|
||||
osdep/LinuxNetLink.hpp
|
||||
osdep/MacEthernetTap.cpp
|
||||
osdep/MacEthernetTap.hpp
|
||||
osdep/MacEthernetTapAgent.c
|
||||
osdep/MacEthernetTapAgent.h
|
||||
osdep/MacKextEthernetTap.cpp
|
||||
osdep/MacKextEthernetTap.hpp
|
||||
osdep/ManagedRoute.cpp
|
||||
osdep/ManagedRoute.hpp
|
||||
osdep/NeighborDiscovery.cpp
|
||||
osdep/NeighborDiscovery.hpp
|
||||
osdep/NetBSDEthernetTap.cpp
|
||||
osdep/NetBSDEthernetTap.hpp
|
||||
osdep/OSUtils.cpp
|
||||
osdep/OSUtils.hpp
|
||||
osdep/README.md
|
||||
osdep/Thread.hpp
|
||||
osdep/WindowsEthernetTap.cpp
|
||||
osdep/WindowsEthernetTap.hpp
|
||||
root/CMakeLists.txt
|
||||
root/geoip-html.h
|
||||
root/root.cpp
|
||||
AUTHORS.md
|
||||
CMakeLists.txt
|
||||
LICENSE.txt
|
||||
OFFICIAL-RELEASE-STEPS.md
|
||||
README.md
|
||||
RELEASE-NOTES.md
|
||||
selftest.cpp)
|
||||
set(ZEROTIER_ONE_VERSION_MAJOR 2 CACHE INTERNAL "")
|
||||
set(ZEROTIER_ONE_VERSION_MINOR 0 CACHE INTERNAL "")
|
||||
set(ZEROTIER_ONE_VERSION_REVISION 0 CACHE INTERNAL "")
|
||||
set(ZEROTIER_ONE_VERSION_BUILD 0 CACHE INTERNAL "")
|
||||
|
||||
set(default_build_type "Release")
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
set(default_build_type "Debug")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
||||
STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
option(BUILD_CENTRAL_CONTROLLER "Build ZeroTier Central Controller" OFF)
|
||||
option(ZT_TRACE "Trace Messages" OFF)
|
||||
option(ZT_DEBUG_TRACE "Debug Trace Messages" OFF)
|
||||
|
||||
if (BUILD_CENTRAL_CONTROLLER)
|
||||
find_package(PostgreSQL REQUIRED)
|
||||
set(ENABLE_SSL_SUPPORT OFF)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
set(BUILD_EXAMPLES OFF)
|
||||
set(BUILD_TOOLS OFF)
|
||||
set(BUILD_TESTS OFF)
|
||||
set(BUILD_API_DOCS OFF)
|
||||
add_subdirectory("ext/librabbitmq")
|
||||
endif(BUILD_CENTRAL_CONTROLLER)
|
||||
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X Deployment Version")
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_definitions(-DZT_TRACE)
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
project(zerotier
|
||||
DESCRIPTION "ZeroTier Network Hypervisor"
|
||||
LANGUAGES CXX C)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DNOMINMAX)
|
||||
else(WIN32)
|
||||
if(APPLE)
|
||||
|
||||
message("Setting macOS Compiler Flags ${CMAKE_BUILD_TYPE}")
|
||||
add_compile_options(
|
||||
-Wall
|
||||
-Wno-deprecated
|
||||
-mmacosx-version-min=10.9
|
||||
$<$<CONFIG:Debug>:-g>
|
||||
$<$<CONFIG:DEBUG>:-O0>
|
||||
$<$<CONFIG:RELEASE>:-Ofast>
|
||||
$<$<CONFIG:RELEASE>:-fPIE>
|
||||
$<$<CONFIG:RELEASE>:-flto>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:-Ofast>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:-fPIE>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:-g>
|
||||
)
|
||||
add_link_options(
|
||||
-mmacosx-version-min=10.9
|
||||
$<$<CONFIG:RELEASE>:-flto>
|
||||
)
|
||||
|
||||
elseif (
|
||||
CMAKE_SYSTEM_NAME MATCHES "Linux" OR
|
||||
CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR
|
||||
CMAKE_SYSTEM_NAME MATCHES "OpenBSD" OR
|
||||
CMAKE_SYSTEM_NAME MATCHES "NetBSD"
|
||||
)
|
||||
|
||||
message("Setting Linux/BSD Compiler Flags (${CMAKE_BUILD_TYPE})")
|
||||
add_compile_options(
|
||||
-Wall
|
||||
-Wno-deprecated
|
||||
$<$<CONFIG:Debug>:-g>
|
||||
$<$<CONFIG:DEBUG>:-O0>
|
||||
$<$<CONFIG:RELEASE>:-O3>
|
||||
$<$<CONFIG:RELEASE>:-fPIE>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:-O3>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:-fPIE>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:-g>
|
||||
)
|
||||
|
||||
endif(APPLE)
|
||||
endif(WIN32)
|
||||
|
||||
if (
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "amd64" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "i386" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "i486" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "i586" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "i686"
|
||||
)
|
||||
message("Adding SSE and AES-NI flags for processor ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
add_compile_options(
|
||||
-maes
|
||||
-mmmx
|
||||
-mrdrnd
|
||||
-mpclmul
|
||||
-msse
|
||||
-msse2
|
||||
-msse3
|
||||
-msse4.1
|
||||
)
|
||||
endif()
|
||||
|
||||
if(ZT_TRACE)
|
||||
add_definitions(-DZT_TRACE)
|
||||
endif()
|
||||
if(ZT_DEBUG_TRACE)
|
||||
add_definitions(-DZT_DEBUG_TRACE)
|
||||
endif()
|
||||
|
||||
add_subdirectory(node)
|
||||
add_subdirectory(controller)
|
||||
add_subdirectory(osdep)
|
||||
add_subdirectory(root)
|
||||
add_subdirectory(go/native)
|
||||
|
||||
#if(WIN32)
|
||||
# add_subdirectory("windows/WinUI")
|
||||
# add_subdirectory("windows/copyutil")
|
||||
# add_definitions(-DNOMINMAX)
|
||||
#endif(WIN32)
|
||||
|
||||
set(
|
||||
zt_osdep
|
||||
zt_core
|
||||
zt_controller
|
||||
zt_go_native
|
||||
)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/version.h.in
|
||||
${CMAKE_BINARY_DIR}/version.h
|
||||
)
|
||||
|
||||
#set(src
|
||||
# one.cpp
|
||||
# "ext/http-parser/http_parser.c"
|
||||
#)
|
||||
#set(headers
|
||||
# "ext/http-parser/http_parser.h"
|
||||
#)
|
||||
|
||||
if(WIN32)
|
||||
set(libs ${libs} wsock32 ws2_32 rpcrt4 iphlpapi)
|
||||
else(WIN32)
|
||||
set(libs ${libs} pthread)
|
||||
endif(WIN32)
|
||||
|
||||
#if(WIN32)
|
||||
# set(libs ${libs} wsock32 ws2_32 rpcrt4 iphlpapi)
|
||||
# set(src
|
||||
# ${src}
|
||||
# "windows/ZeroTierOne/ServiceBase.cpp"
|
||||
# "windows/ZeroTierOne/ServiceInstaller.cpp"
|
||||
# "windows/ZeroTierOne/ZeroTierOneService.cpp"
|
||||
# "windows/ZeroTierOne/ZeroTierOne.rc"
|
||||
# )
|
||||
# set(headers
|
||||
# ${headers}
|
||||
# "windows/ZeroTierOne/ServiceBase.h"
|
||||
# "windows/ZeroTierOne/ServiceInstaller.h"
|
||||
# "windows/ZeroTierOne/ZeroTierOneService.h"
|
||||
# )
|
||||
#else(WIN32)
|
||||
# set(libs ${libs} pthread resolv)
|
||||
#endif(WIN32)
|
||||
|
||||
#if(BUILD_CENTRAL_CONTROLLER)
|
||||
# set(libs ${libs} rabbitmq-static ${PostgreSQL_LIBRARIES})
|
||||
#endif(BUILD_CENTRAL_CONTROLLER)
|
||||
|
||||
#add_executable(${PROJECT_NAME} ${src} ${headers})
|
||||
#target_link_libraries(${PROJECT_NAME} ${libs})
|
||||
#target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT zerotier
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/go
|
||||
COMMAND go build -trimpath -ldflags -s -o ../build/zerotier cmd/zerotier/zerotier.go
|
||||
DEPENDS zt_osdep zt_core zt_go_native
|
||||
)
|
||||
add_custom_target(build_zerotier ALL DEPENDS zerotier)
|
||||
|
||||
add_executable(zerotier-selftest selftest.cpp)
|
||||
target_link_libraries(zerotier-selftest ${libs} zt_core zt_osdep)
|
||||
target_compile_features(zerotier-selftest PUBLIC cxx_std_11)
|
||||
|
|
|
@ -68,7 +68,6 @@ set(core_src
|
|||
SelfAwareness.cpp
|
||||
SHA512.cpp
|
||||
Switch.cpp
|
||||
Trace.cpp
|
||||
Utils.cpp
|
||||
)
|
||||
|
||||
|
|
433
node/Trace.cpp
433
node/Trace.cpp
|
@ -1,433 +0,0 @@
|
|||
/*
|
||||
* Copyright (c)2019 ZeroTier, Inc.
|
||||
*
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file in the project's root directory.
|
||||
*
|
||||
* Change Date: 2023-01-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2.0 of the Apache License.
|
||||
*/
|
||||
/****/
|
||||
|
||||
//#define ZT_TRACE
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
#include "Trace.hpp"
|
||||
#include "RuntimeEnvironment.hpp"
|
||||
#include "Switch.hpp"
|
||||
#include "Node.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include "Dictionary.hpp"
|
||||
#include "CertificateOfMembership.hpp"
|
||||
#include "CertificateOfOwnership.hpp"
|
||||
#include "Tag.hpp"
|
||||
#include "Capability.hpp"
|
||||
#include "Revocation.hpp"
|
||||
#include "../include/ZeroTierDebug.h"
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
#ifdef ZT_TRACE
|
||||
static void ZT_LOCAL_TRACE(void *const tPtr,const RuntimeEnvironment *const RR,const char *const fmt,...)
|
||||
{
|
||||
char traceMsgBuf[2048];
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
vsnprintf(traceMsgBuf,sizeof(traceMsgBuf),fmt,ap);
|
||||
va_end(ap);
|
||||
traceMsgBuf[sizeof(traceMsgBuf) - 1] = (char)0;
|
||||
RR->node->postEvent(tPtr,ZT_EVENT_TRACE,traceMsgBuf);
|
||||
}
|
||||
#else
|
||||
#define ZT_LOCAL_TRACE(...)
|
||||
#endif
|
||||
|
||||
void Trace::resettingPathsInScope(void *const tPtr,const Address &reporter,const InetAddress &reporterPhysicalAddress,const InetAddress &myPhysicalAddress,const InetAddress::IpScope scope)
|
||||
{
|
||||
#ifdef ZT_TRACE
|
||||
char tmp[128];
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"RESET and revalidate paths in scope %d; new phy address %s reported by trusted peer %.10llx",(int)scope,myPhysicalAddress.toIpString(tmp),reporter.toInt());
|
||||
#endif
|
||||
}
|
||||
|
||||
void Trace::peerConfirmingUnknownPath(void *const tPtr,const uint64_t networkId,Peer &peer,const SharedPtr<Path> &path,const uint64_t packetId,const Packet::Verb verb)
|
||||
{
|
||||
char tmp[128];
|
||||
if (!path) return; // sanity check
|
||||
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"trying unknown path %s to %.10llx (packet %.16llx verb %d local socket %lld network %.16llx)",path->address().toString(tmp),peer.address().toInt(),packetId,(double)verb,path->localSocket(),networkId);
|
||||
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
if (networkId) { Mutex::Lock l(_byNet_m); _byNet.get(networkId,byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_NORMAL)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__PEER_CONFIRMING_UNKNOWN_PATH_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_ID,packetId);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_VERB,(uint64_t)verb);
|
||||
if (networkId)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,networkId);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_ZTADDR,peer.address());
|
||||
if (path) {
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_PHYADDR,path->address().toString(tmp));
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__LOCAL_SOCKET,path->localSocket());
|
||||
}
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::peerLinkNowRedundant(void *const tPtr,Peer &peer)
|
||||
{
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"link to peer %.10llx is fully redundant",peer.address().toInt());
|
||||
}
|
||||
|
||||
void Trace::peerLinkNoLongerRedundant(void *const tPtr,Peer &peer)
|
||||
{
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"link to peer %.10llx is no longer redundant",peer.address().toInt());
|
||||
}
|
||||
|
||||
void Trace::peerLinkAggregateStatistics(void *const tPtr,Peer &peer)
|
||||
{
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"link to peer %.10llx is composed of (%d) physical paths %s, has packet delay variance (%.0f ms), mean latency (%.0f ms)",
|
||||
peer.address().toInt(),
|
||||
peer.aggregateLinkPhysicalPathCount(),
|
||||
peer.interfaceListStr(),
|
||||
peer.computeAggregateLinkPacketDelayVariance(),
|
||||
peer.computeAggregateLinkMeanLatency());
|
||||
}
|
||||
|
||||
void Trace::peerLearnedNewPath(void *const tPtr,const uint64_t networkId,Peer &peer,const SharedPtr<Path> &newPath,const uint64_t packetId)
|
||||
{
|
||||
char tmp[128];
|
||||
if (!newPath) return; // sanity check
|
||||
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"learned new path %s to %.10llx (packet %.16llx local socket %lld network %.16llx)",newPath->address().toString(tmp),peer.address().toInt(),packetId,newPath->localSocket(),networkId);
|
||||
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
if (networkId) { Mutex::Lock l(_byNet_m); _byNet.get(networkId,byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_NORMAL)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__PEER_LEARNED_NEW_PATH_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_ID,packetId);
|
||||
if (networkId)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,networkId);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_ZTADDR,peer.address());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_PHYADDR,newPath->address().toString(tmp));
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__LOCAL_SOCKET,newPath->localSocket());
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::outgoingNetworkFrameDropped(void *const tPtr,const SharedPtr<Network> &network,const MAC &sourceMac,const MAC &destMac,const unsigned int etherType,const unsigned int vlanId,const unsigned int frameLen,const char *reason)
|
||||
{
|
||||
#ifdef ZT_TRACE
|
||||
char tmp[128],tmp2[128];
|
||||
#endif
|
||||
if (!network) return; // sanity check
|
||||
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"%.16llx DROP frame %s -> %s etherType %.4x size %u (%s)",network->id(),sourceMac.toString(tmp),destMac.toString(tmp2),etherType,frameLen,(reason) ? reason : "unknown reason");
|
||||
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
{ Mutex::Lock l(_byNet_m); _byNet.get(network->id(),byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_VERBOSE)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__OUTGOING_NETWORK_FRAME_DROPPED_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,network->id());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__SOURCE_MAC,sourceMac.toInt());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__DEST_MAC,destMac.toInt());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__ETHERTYPE,(uint64_t)etherType);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__VLAN_ID,(uint64_t)vlanId);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__FRAME_LENGTH,(uint64_t)frameLen);
|
||||
if (reason)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REASON,reason);
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::incomingNetworkAccessDenied(void *const tPtr,const SharedPtr<Network> &network,const SharedPtr<Path> &path,const uint64_t packetId,const unsigned int packetLength,const Address &source,const Packet::Verb verb,bool credentialsRequested)
|
||||
{
|
||||
char tmp[128];
|
||||
if (!network) return; // sanity check
|
||||
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"%.16llx DENIED packet from %.10llx(%s) verb %d size %u%s",network->id(),source.toInt(),(path) ? (path->address().toString(tmp)) : "???",(int)verb,packetLength,credentialsRequested ? " (credentials requested)" : " (credentials not requested)");
|
||||
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
{ Mutex::Lock l(_byNet_m); _byNet.get(network->id(),byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_NORMAL)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__INCOMING_NETWORK_ACCESS_DENIED_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_ID,packetId);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_VERB,(uint64_t)verb);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_ZTADDR,source);
|
||||
if (path) {
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_PHYADDR,path->address().toString(tmp));
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__LOCAL_SOCKET,path->localSocket());
|
||||
}
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,network->id());
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::incomingNetworkFrameDropped(void *const tPtr,const SharedPtr<Network> &network,const SharedPtr<Path> &path,const uint64_t packetId,const unsigned int packetLength,const Address &source,const Packet::Verb verb,const MAC &sourceMac,const MAC &destMac,const char *reason)
|
||||
{
|
||||
char tmp[128];
|
||||
if (!network) return; // sanity check
|
||||
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"%.16llx DROPPED frame from %.10llx(%s) verb %d size %u",network->id(),source.toInt(),(path) ? (path->address().toString(tmp)) : "???",(int)verb,packetLength);
|
||||
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
{ Mutex::Lock l(_byNet_m); _byNet.get(network->id(),byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_VERBOSE)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__INCOMING_NETWORK_FRAME_DROPPED_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_ID,packetId);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_VERB,(uint64_t)verb);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_ZTADDR,source);
|
||||
if (path) {
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_PHYADDR,path->address().toString(tmp));
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__LOCAL_SOCKET,path->localSocket());
|
||||
}
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,network->id());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__SOURCE_MAC,sourceMac.toInt());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__DEST_MAC,destMac.toInt());
|
||||
if (reason)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REASON,reason);
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::incomingPacketMessageAuthenticationFailure(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const unsigned int hops,const char *reason)
|
||||
{
|
||||
char tmp[128];
|
||||
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"MAC failed for packet %.16llx from %.10llx(%s)",packetId,source.toInt(),(path) ? path->address().toString(tmp) : "???");
|
||||
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__PACKET_MAC_FAILURE_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_ID,packetId);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_HOPS,(uint64_t)hops);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_ZTADDR,source);
|
||||
if (path) {
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_PHYADDR,path->address().toString(tmp));
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__LOCAL_SOCKET,path->localSocket());
|
||||
}
|
||||
if (reason)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REASON,reason);
|
||||
_spamToAllNetworks(tPtr,d,Trace::LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
void Trace::incomingPacketInvalid(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const unsigned int hops,const Packet::Verb verb,const char *reason)
|
||||
{
|
||||
char tmp[128];
|
||||
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"INVALID packet %.16llx from %.10llx(%s) (%s)",packetId,source.toInt(),(path) ? path->address().toString(tmp) : "???",(reason) ? reason : "unknown reason");
|
||||
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__PACKET_INVALID_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_ID,packetId);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_VERB,(uint64_t)verb);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_ZTADDR,source);
|
||||
if (path) {
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_PHYADDR,path->address().toString(tmp));
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__LOCAL_SOCKET,path->localSocket());
|
||||
}
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_HOPS,(uint64_t)hops);
|
||||
if (reason)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REASON,reason);
|
||||
_spamToAllNetworks(tPtr,d,Trace::LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
void Trace::incomingPacketDroppedHELLO(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const char *reason)
|
||||
{
|
||||
char tmp[128];
|
||||
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"DROPPED HELLO from %.10llx(%s) (%s)",source.toInt(),(path) ? path->address().toString(tmp) : "???",(reason) ? reason : "???");
|
||||
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__PACKET_INVALID_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__PACKET_ID,packetId);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_ZTADDR,source);
|
||||
if (path) {
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REMOTE_PHYADDR,path->address().toString(tmp));
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__LOCAL_SOCKET,path->localSocket());
|
||||
}
|
||||
if (reason)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REASON,reason);
|
||||
_spamToAllNetworks(tPtr,d,Trace::LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
void Trace::networkConfigRequestSent(void *const tPtr,const Network &network,const Address &controller)
|
||||
{
|
||||
ZT_LOCAL_TRACE(tPtr,RR,"requesting configuration for network %.16llx",network.id());
|
||||
}
|
||||
|
||||
void Trace::networkFilter(
|
||||
void *const tPtr,
|
||||
const Network &network,
|
||||
const RuleResultLog &primaryRuleSetLog,
|
||||
const RuleResultLog *const matchingCapabilityRuleSetLog,
|
||||
const Capability *const matchingCapability,
|
||||
const Address &ztSource,
|
||||
const Address &ztDest,
|
||||
const MAC &macSource,
|
||||
const MAC &macDest,
|
||||
const uint8_t *const frameData,
|
||||
const unsigned int frameLen,
|
||||
const unsigned int etherType,
|
||||
const unsigned int vlanId,
|
||||
const bool noTee,
|
||||
const bool inbound,
|
||||
const int accept)
|
||||
{
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
{ Mutex::Lock l(_byNet_m); _byNet.get(network.id(),byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_RULES)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__NETWORK_FILTER_TRACE_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,network.id());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__SOURCE_ZTADDR,ztSource);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__DEST_ZTADDR,ztDest);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__SOURCE_MAC,macSource.toInt());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__DEST_MAC,macDest.toInt());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__ETHERTYPE,(uint64_t)etherType);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__VLAN_ID,(uint64_t)vlanId);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__FILTER_FLAG_NOTEE,noTee ? "1" : "0");
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__FILTER_FLAG_INBOUND,inbound ? "1" : "0");
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__FILTER_RESULT,(int64_t)accept);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__FILTER_BASE_RULE_LOG,(const char *)primaryRuleSetLog.data(),(int)primaryRuleSetLog.sizeBytes());
|
||||
if (matchingCapabilityRuleSetLog)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__FILTER_CAP_RULE_LOG,(const char *)matchingCapabilityRuleSetLog->data(),(int)matchingCapabilityRuleSetLog->sizeBytes());
|
||||
if (matchingCapability)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__FILTER_CAP_ID,(uint64_t)matchingCapability->id());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__FRAME_LENGTH,(uint64_t)frameLen);
|
||||
if (frameLen > 0)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__FRAME_DATA,(const char *)frameData,(frameLen > 256) ? (int)256 : (int)frameLen);
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::credentialRejected(void *const tPtr,const CertificateOfMembership &c,const char *reason)
|
||||
{
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
if (c.networkId()) { Mutex::Lock l(_byNet_m); _byNet.get(c.networkId(),byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_VERBOSE)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__CREDENTIAL_REJECTED_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,c.networkId());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TYPE,(uint64_t)c.credentialType());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ID,(uint64_t)c.id());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TIMESTAMP,c.timestamp());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ISSUED_TO,c.issuedTo());
|
||||
if (reason)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REASON,reason);
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::credentialRejected(void *const tPtr,const CertificateOfOwnership &c,const char *reason)
|
||||
{
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
if (c.networkId()) { Mutex::Lock l(_byNet_m); _byNet.get(c.networkId(),byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_VERBOSE)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__CREDENTIAL_REJECTED_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,c.networkId());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TYPE,(uint64_t)c.credentialType());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ID,(uint64_t)c.id());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TIMESTAMP,c.timestamp());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ISSUED_TO,c.issuedTo());
|
||||
if (reason)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REASON,reason);
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::credentialRejected(void *const tPtr,const Capability &c,const char *reason)
|
||||
{
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
if (c.networkId()) { Mutex::Lock l(_byNet_m); _byNet.get(c.networkId(),byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_VERBOSE)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__CREDENTIAL_REJECTED_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,c.networkId());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TYPE,(uint64_t)c.credentialType());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ID,(uint64_t)c.id());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TIMESTAMP,c.timestamp());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ISSUED_TO,c.issuedTo());
|
||||
if (reason)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REASON,reason);
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::credentialRejected(void *const tPtr,const Tag &c,const char *reason)
|
||||
{
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
if (c.networkId()) { Mutex::Lock l(_byNet_m); _byNet.get(c.networkId(),byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_VERBOSE)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__CREDENTIAL_REJECTED_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,c.networkId());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TYPE,(uint64_t)c.credentialType());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ID,(uint64_t)c.id());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TIMESTAMP,c.timestamp());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ISSUED_TO,c.issuedTo());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_INFO,(uint64_t)c.value());
|
||||
if (reason)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REASON,reason);
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::credentialRejected(void *const tPtr,const Revocation &c,const char *reason)
|
||||
{
|
||||
std::pair<Address,Trace::Level> byn;
|
||||
if (c.networkId()) { Mutex::Lock l(_byNet_m); _byNet.get(c.networkId(),byn); }
|
||||
|
||||
if ((byn.first)&&((int)byn.second >= (int)Trace::LEVEL_VERBOSE)) {
|
||||
Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> d;
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__EVENT,ZT_REMOTE_TRACE_EVENT__CREDENTIAL_REJECTED_S);
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__NETWORK_ID,c.networkId());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_TYPE,(uint64_t)c.credentialType());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_ID,(uint64_t)c.id());
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__CREDENTIAL_REVOCATION_TARGET,c.target());
|
||||
if (reason)
|
||||
d.add(ZT_REMOTE_TRACE_FIELD__REASON,reason);
|
||||
_send(tPtr,d,byn.first);
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::_send(void *const tPtr,const Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> &d,const Address &dest)
|
||||
{
|
||||
Packet outp(dest,RR->identity.address(),Packet::VERB_REMOTE_TRACE);
|
||||
outp.appendCString(d.data());
|
||||
outp.compress();
|
||||
RR->sw->send(tPtr,outp,true);
|
||||
}
|
||||
|
||||
void Trace::_spamToAllNetworks(void *const tPtr,const Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> &d,const Level level)
|
||||
{
|
||||
Mutex::Lock l(_byNet_m);
|
||||
Hashtable< uint64_t,std::pair< Address,Trace::Level > >::Iterator i(_byNet);
|
||||
uint64_t *k = (uint64_t *)0;
|
||||
std::pair<Address,Trace::Level> *v = (std::pair<Address,Trace::Level> *)0;
|
||||
while (i.next(k,v)) {
|
||||
if ((v)&&(v->first)&&((int)v->second >= (int)level))
|
||||
_send(tPtr,d,v->first);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
144
node/Trace.hpp
144
node/Trace.hpp
|
@ -52,70 +52,86 @@ struct NetworkConfig;
|
|||
class Trace
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Trace verbosity level
|
||||
*/
|
||||
enum Level
|
||||
{
|
||||
LEVEL_NORMAL = 0,
|
||||
LEVEL_VERBOSE = 10,
|
||||
LEVEL_RULES = 15,
|
||||
LEVEL_DEBUG = 20
|
||||
};
|
||||
|
||||
/**
|
||||
* Filter rule evaluation result log
|
||||
*
|
||||
* Each rule in a rule set gets a four-bit log entry. A log entry
|
||||
* of zero means not evaluated. Otherwise each four-bit log entry
|
||||
* contains two two-bit values of 01 for 'false' and 10 for 'true'.
|
||||
* As with four-bit rules an 00 value here means this was not
|
||||
* evaluated or was not relevant.
|
||||
*/
|
||||
class RuleResultLog
|
||||
{
|
||||
public:
|
||||
inline RuleResultLog() {}
|
||||
ZT_ALWAYS_INLINE RuleResultLog() { this->clear(); }
|
||||
|
||||
inline void log(const unsigned int rn,const uint8_t thisRuleMatches,const uint8_t thisSetMatches)
|
||||
ZT_ALWAYS_INLINE void log(const unsigned int rn,const uint8_t thisRuleMatches,const uint8_t thisSetMatches)
|
||||
{
|
||||
_l[rn >> 1] |= ( ((thisRuleMatches + 1) << 2) | (thisSetMatches + 1) ) << ((rn & 1) << 2);
|
||||
_l[rn >> 1U] |= ( ((thisRuleMatches + 1U) << 2U) | (thisSetMatches + 1U) ) << ((rn & 1U) << 2U);
|
||||
}
|
||||
inline void logSkipped(const unsigned int rn,const uint8_t thisSetMatches)
|
||||
ZT_ALWAYS_INLINE void logSkipped(const unsigned int rn,const uint8_t thisSetMatches)
|
||||
{
|
||||
_l[rn >> 1] |= (thisSetMatches + 1) << ((rn & 1) << 2);
|
||||
_l[rn >> 1U] |= (thisSetMatches + 1U) << ((rn & 1U) << 2U);
|
||||
}
|
||||
|
||||
inline void clear()
|
||||
{
|
||||
memset(_l,0,sizeof(_l));
|
||||
}
|
||||
ZT_ALWAYS_INLINE void clear() { memset(_l,0,sizeof(_l)); }
|
||||
|
||||
inline const uint8_t *data() const { return _l; }
|
||||
inline unsigned int sizeBytes() const { return (ZT_MAX_NETWORK_RULES / 2); }
|
||||
ZT_ALWAYS_INLINE const uint8_t *data() const { return _l; }
|
||||
ZT_ALWAYS_INLINE unsigned int sizeBytes() const { return (ZT_MAX_NETWORK_RULES / 2); }
|
||||
|
||||
private:
|
||||
uint8_t _l[ZT_MAX_NETWORK_RULES / 2];
|
||||
};
|
||||
|
||||
inline Trace(const RuntimeEnvironment *renv) :
|
||||
RR(renv),
|
||||
_byNet(8) {}
|
||||
inline Trace(const RuntimeEnvironment *renv)
|
||||
{
|
||||
}
|
||||
|
||||
void resettingPathsInScope(void *const tPtr,const Address &reporter,const InetAddress &reporterPhysicalAddress,const InetAddress &myPhysicalAddress,const InetAddress::IpScope scope);
|
||||
void peerConfirmingUnknownPath(void *const tPtr,const uint64_t networkId,Peer &peer,const SharedPtr<Path> &path,const uint64_t packetId,const Packet::Verb verb);
|
||||
void peerLinkNowRedundant(void *const tPtr,Peer &peer);
|
||||
void peerLinkNoLongerRedundant(void *const tPtr,Peer &peer);
|
||||
void peerLinkAggregateStatistics(void *const tPtr,Peer &peer);
|
||||
void peerLearnedNewPath(void *const tPtr,const uint64_t networkId,Peer &peer,const SharedPtr<Path> &newPath,const uint64_t packetId);
|
||||
void incomingPacketMessageAuthenticationFailure(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const unsigned int hops,const char *reason);
|
||||
void incomingPacketInvalid(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const unsigned int hops,const Packet::Verb verb,const char *reason);
|
||||
void incomingPacketDroppedHELLO(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const char *reason);
|
||||
void outgoingNetworkFrameDropped(void *const tPtr,const SharedPtr<Network> &network,const MAC &sourceMac,const MAC &destMac,const unsigned int etherType,const unsigned int vlanId,const unsigned int frameLen,const char *reason);
|
||||
void incomingNetworkAccessDenied(void *const tPtr,const SharedPtr<Network> &network,const SharedPtr<Path> &path,const uint64_t packetId,const unsigned int packetLength,const Address &source,const Packet::Verb verb,bool credentialsRequested);
|
||||
void incomingNetworkFrameDropped(void *const tPtr,const SharedPtr<Network> &network,const SharedPtr<Path> &path,const uint64_t packetId,const unsigned int packetLength,const Address &source,const Packet::Verb verb,const MAC &sourceMac,const MAC &destMac,const char *reason);
|
||||
void networkConfigRequestSent(void *const tPtr,const Network &network,const Address &controller);
|
||||
void networkFilter(
|
||||
inline void resettingPathsInScope(void *const tPtr,const Address &reporter,const InetAddress &reporterPhysicalAddress,const InetAddress &myPhysicalAddress,const InetAddress::IpScope scope)
|
||||
{
|
||||
}
|
||||
|
||||
inline void peerConfirmingUnknownPath(void *const tPtr,const uint64_t networkId,Peer &peer,const SharedPtr<Path> &path,const uint64_t packetId,const Packet::Verb verb)
|
||||
{
|
||||
}
|
||||
|
||||
inline void peerLinkNowRedundant(void *const tPtr,Peer &peer)
|
||||
{
|
||||
}
|
||||
|
||||
inline void peerLinkNoLongerRedundant(void *const tPtr,Peer &peer)
|
||||
{
|
||||
}
|
||||
|
||||
inline void peerLinkAggregateStatistics(void *const tPtr,Peer &peer)
|
||||
{
|
||||
}
|
||||
|
||||
inline void peerLearnedNewPath(void *const tPtr,const uint64_t networkId,Peer &peer,const SharedPtr<Path> &newPath,const uint64_t packetId)
|
||||
{
|
||||
}
|
||||
|
||||
inline void incomingPacketMessageAuthenticationFailure(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const unsigned int hops,const char *reason)
|
||||
{
|
||||
}
|
||||
|
||||
inline void incomingPacketInvalid(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const unsigned int hops,const Packet::Verb verb,const char *reason)
|
||||
{
|
||||
}
|
||||
|
||||
inline void incomingPacketDroppedHELLO(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const char *reason)
|
||||
{
|
||||
}
|
||||
|
||||
inline void outgoingNetworkFrameDropped(void *const tPtr,const SharedPtr<Network> &network,const MAC &sourceMac,const MAC &destMac,const unsigned int etherType,const unsigned int vlanId,const unsigned int frameLen,const char *reason)
|
||||
{
|
||||
}
|
||||
|
||||
inline void incomingNetworkAccessDenied(void *const tPtr,const SharedPtr<Network> &network,const SharedPtr<Path> &path,const uint64_t packetId,const unsigned int packetLength,const Address &source,const Packet::Verb verb,bool credentialsRequested)
|
||||
{
|
||||
}
|
||||
|
||||
inline void incomingNetworkFrameDropped(void *const tPtr,const SharedPtr<Network> &network,const SharedPtr<Path> &path,const uint64_t packetId,const unsigned int packetLength,const Address &source,const Packet::Verb verb,const MAC &sourceMac,const MAC &destMac,const char *reason)
|
||||
{
|
||||
}
|
||||
|
||||
inline void networkConfigRequestSent(void *const tPtr,const Network &network,const Address &controller)
|
||||
{
|
||||
}
|
||||
|
||||
inline void networkFilter(
|
||||
void *const tPtr,
|
||||
const Network &network,
|
||||
const RuleResultLog &primaryRuleSetLog,
|
||||
|
@ -131,21 +147,29 @@ public:
|
|||
const unsigned int vlanId,
|
||||
const bool noTee,
|
||||
const bool inbound,
|
||||
const int accept);
|
||||
void credentialRejected(void *const tPtr,const CertificateOfMembership &c,const char *reason);
|
||||
void credentialRejected(void *const tPtr,const CertificateOfOwnership &c,const char *reason);
|
||||
void credentialRejected(void *const tPtr,const Capability &c,const char *reason);
|
||||
void credentialRejected(void *const tPtr,const Tag &c,const char *reason);
|
||||
void credentialRejected(void *const tPtr,const Revocation &c,const char *reason);
|
||||
const int accept)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
const RuntimeEnvironment *const RR;
|
||||
inline void credentialRejected(void *const tPtr,const CertificateOfMembership &c,const char *reason)
|
||||
{
|
||||
}
|
||||
|
||||
void _send(void *const tPtr,const Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> &d,const Address &dest);
|
||||
void _spamToAllNetworks(void *const tPtr,const Dictionary<ZT_MAX_REMOTE_TRACE_SIZE> &d,const Level level);
|
||||
inline void credentialRejected(void *const tPtr,const CertificateOfOwnership &c,const char *reason)
|
||||
{
|
||||
}
|
||||
|
||||
Hashtable< uint64_t,std::pair< Address,Trace::Level > > _byNet;
|
||||
Mutex _byNet_m;
|
||||
inline void credentialRejected(void *const tPtr,const Capability &c,const char *reason)
|
||||
{
|
||||
}
|
||||
|
||||
inline void credentialRejected(void *const tPtr,const Tag &c,const char *reason)
|
||||
{
|
||||
}
|
||||
|
||||
inline void credentialRejected(void *const tPtr,const Revocation &c,const char *reason)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
|
Loading…
Add table
Reference in a new issue