RuntimeEnvironment.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_RUNTIMEENVIRONMENT_HPP
  14. #define ZT_RUNTIMEENVIRONMENT_HPP
  15. #include "Constants.hpp"
  16. #include "Utils.hpp"
  17. #include "Identity.hpp"
  18. #include "AES.hpp"
  19. namespace ZeroTier {
  20. class VL1;
  21. class VL2;
  22. class Topology;
  23. class Node;
  24. class NetworkController;
  25. class SelfAwareness;
  26. class Trace;
  27. class Expect;
  28. /**
  29. * ZeroTier::Node execution context
  30. *
  31. * This just holds pointers and various other information used by all the
  32. * various moving parts of a node. It's stored or passed as 'RR' to give it
  33. * a common name througout the code.
  34. */
  35. class RuntimeEnvironment
  36. {
  37. public:
  38. ZT_ALWAYS_INLINE RuntimeEnvironment(Node *n) noexcept :
  39. node(n),
  40. localNetworkController(nullptr),
  41. rtmem(nullptr),
  42. t(nullptr),
  43. expect(nullptr),
  44. vl2(nullptr),
  45. vl1(nullptr),
  46. topology(nullptr),
  47. sa(nullptr)
  48. {
  49. publicIdentityStr[0] = (char)0;
  50. secretIdentityStr[0] = (char)0;
  51. }
  52. ZT_ALWAYS_INLINE ~RuntimeEnvironment()
  53. {
  54. Utils::burn(secretIdentityStr,sizeof(secretIdentityStr));
  55. }
  56. // Node instance that owns this RuntimeEnvironment
  57. Node *const node;
  58. // This is set externally to an instance of this base class
  59. NetworkController *localNetworkController;
  60. // Memory actually occupied by Trace, Switch, etc.
  61. void *rtmem;
  62. Trace *t;
  63. Expect *expect;
  64. VL2 *vl2;
  65. VL1 *vl1;
  66. Topology *topology;
  67. SelfAwareness *sa;
  68. // This node's identity and string representations thereof
  69. Identity identity;
  70. char publicIdentityStr[ZT_IDENTITY_STRING_BUFFER_LENGTH];
  71. char secretIdentityStr[ZT_IDENTITY_STRING_BUFFER_LENGTH];
  72. // AES keyed with a hash of this node's identity secret keys for local cache encryption at rest (where needed).
  73. AES localCacheSymmetric;
  74. };
  75. } // namespace ZeroTier
  76. #endif