Trace.hpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Copyright (c)2013-2020 ZeroTier, Inc.
  3. *
  4. * Use of this software is governed by the Business Source License included
  5. * in the LICENSE.TXT file in the project's root directory.
  6. *
  7. * Change Date: 2024-01-01
  8. *
  9. * On the date above, in accordance with the Business Source License, use
  10. * of this software will be governed by version 2.0 of the Apache License.
  11. */
  12. /****/
  13. #ifndef ZT_TRACE_HPP
  14. #define ZT_TRACE_HPP
  15. #include <cstdio>
  16. #include <cstdint>
  17. #include <cstring>
  18. #include <cstdlib>
  19. #include "../include/ZeroTierOne.h"
  20. #include "Constants.hpp"
  21. #include "SharedPtr.hpp"
  22. #include "Packet.hpp"
  23. #include "Credential.hpp"
  24. #include "InetAddress.hpp"
  25. #include "Dictionary.hpp"
  26. #include "Mutex.hpp"
  27. #include "Hashtable.hpp"
  28. namespace ZeroTier {
  29. class RuntimeEnvironment;
  30. class Address;
  31. class Identity;
  32. class Peer;
  33. class Path;
  34. class Network;
  35. class MAC;
  36. class CertificateOfMembership;
  37. class CertificateOfOwnership;
  38. class Revocation;
  39. class Tag;
  40. class Capability;
  41. struct NetworkConfig;
  42. /**
  43. * Remote tracing and trace logging handler
  44. */
  45. class Trace
  46. {
  47. public:
  48. class RuleResultLog
  49. {
  50. public:
  51. ZT_ALWAYS_INLINE RuleResultLog() { this->clear(); }
  52. ZT_ALWAYS_INLINE void log(const unsigned int rn,const uint8_t thisRuleMatches,const uint8_t thisSetMatches) { _l[rn >> 1U] |= ( ((thisRuleMatches + 1U) << 2U) | (thisSetMatches + 1U) ) << ((rn & 1U) << 2U); }
  53. ZT_ALWAYS_INLINE void logSkipped(const unsigned int rn,const uint8_t thisSetMatches) { _l[rn >> 1U] |= (thisSetMatches + 1U) << ((rn & 1U) << 2U); }
  54. ZT_ALWAYS_INLINE void clear() { memset(_l,0,sizeof(_l)); }
  55. ZT_ALWAYS_INLINE const uint8_t *data() const { return _l; }
  56. ZT_ALWAYS_INLINE unsigned int sizeBytes() const { return (ZT_MAX_NETWORK_RULES / 2); }
  57. private:
  58. uint8_t _l[ZT_MAX_NETWORK_RULES / 2];
  59. };
  60. inline Trace(const RuntimeEnvironment *renv)
  61. {
  62. }
  63. inline void resettingPathsInScope(void *const tPtr,const Address &reporter,const InetAddress &reporterPhysicalAddress,const InetAddress &myPhysicalAddress,const InetAddress::IpScope scope)
  64. {
  65. }
  66. inline void peerConfirmingUnknownPath(void *const tPtr,const uint64_t networkId,Peer &peer,const SharedPtr<Path> &path,const uint64_t packetId,const Packet::Verb verb)
  67. {
  68. }
  69. inline void peerLinkNowRedundant(void *const tPtr,Peer &peer)
  70. {
  71. }
  72. inline void peerLinkNoLongerRedundant(void *const tPtr,Peer &peer)
  73. {
  74. }
  75. inline void peerLinkAggregateStatistics(void *const tPtr,Peer &peer)
  76. {
  77. }
  78. inline void peerLearnedNewPath(void *const tPtr,const uint64_t networkId,Peer &peer,const SharedPtr<Path> &newPath,const uint64_t packetId)
  79. {
  80. }
  81. inline void incomingPacketMessageAuthenticationFailure(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const unsigned int hops,const char *reason)
  82. {
  83. }
  84. 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)
  85. {
  86. }
  87. inline void incomingPacketDroppedHELLO(void *const tPtr,const SharedPtr<Path> &path,const uint64_t packetId,const Address &source,const char *reason)
  88. {
  89. }
  90. 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)
  91. {
  92. }
  93. 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)
  94. {
  95. }
  96. 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)
  97. {
  98. }
  99. inline void networkConfigRequestSent(void *const tPtr,const Network &network,const Address &controller)
  100. {
  101. }
  102. inline void networkFilter(
  103. void *const tPtr,
  104. const Network &network,
  105. const RuleResultLog &primaryRuleSetLog,
  106. const RuleResultLog *const matchingCapabilityRuleSetLog,
  107. const Capability *const matchingCapability,
  108. const Address &ztSource,
  109. const Address &ztDest,
  110. const MAC &macSource,
  111. const MAC &macDest,
  112. const uint8_t *const frameData,
  113. const unsigned int frameLen,
  114. const unsigned int etherType,
  115. const unsigned int vlanId,
  116. const bool noTee,
  117. const bool inbound,
  118. const int accept)
  119. {
  120. }
  121. inline void credentialRejected(void *const tPtr,const CertificateOfMembership &c,const char *reason)
  122. {
  123. }
  124. inline void credentialRejected(void *const tPtr,const CertificateOfOwnership &c,const char *reason)
  125. {
  126. }
  127. inline void credentialRejected(void *const tPtr,const Capability &c,const char *reason)
  128. {
  129. }
  130. inline void credentialRejected(void *const tPtr,const Tag &c,const char *reason)
  131. {
  132. }
  133. inline void credentialRejected(void *const tPtr,const Revocation &c,const char *reason)
  134. {
  135. }
  136. };
  137. } // namespace ZeroTier
  138. #endif