RuntimeEnvironment.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * ZeroTier One - Network Virtualization Everywhere
  3. * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef ZT_RUNTIMEENVIRONMENT_HPP
  19. #define ZT_RUNTIMEENVIRONMENT_HPP
  20. #include <string>
  21. #include "Constants.hpp"
  22. #include "Identity.hpp"
  23. #include "Mutex.hpp"
  24. namespace ZeroTier {
  25. class NodeConfig;
  26. class Switch;
  27. class Topology;
  28. class Node;
  29. class Multicaster;
  30. class NetworkController;
  31. class SelfAwareness;
  32. class Cluster;
  33. /**
  34. * Holds global state for an instance of ZeroTier::Node
  35. */
  36. class RuntimeEnvironment
  37. {
  38. public:
  39. RuntimeEnvironment(Node *n) :
  40. node(n)
  41. ,identity()
  42. ,localNetworkController((NetworkController *)0)
  43. ,sw((Switch *)0)
  44. ,mc((Multicaster *)0)
  45. ,topology((Topology *)0)
  46. ,sa((SelfAwareness *)0)
  47. #ifdef ZT_ENABLE_CLUSTER
  48. ,cluster((Cluster *)0)
  49. #endif
  50. {
  51. }
  52. // Node instance that owns this RuntimeEnvironment
  53. Node *const node;
  54. // This node's identity
  55. Identity identity;
  56. std::string publicIdentityStr;
  57. std::string secretIdentityStr;
  58. // This is set externally to an instance of this base class
  59. NetworkController *localNetworkController;
  60. /*
  61. * Order matters a bit here. These are constructed in this order
  62. * and then deleted in the opposite order on Node exit. The order ensures
  63. * that things that are needed are there before they're needed.
  64. *
  65. * These are constant and never null after startup unless indicated.
  66. */
  67. Switch *sw;
  68. Multicaster *mc;
  69. Topology *topology;
  70. SelfAwareness *sa;
  71. #ifdef ZT_ENABLE_CLUSTER
  72. Cluster *cluster;
  73. #endif
  74. };
  75. } // namespace ZeroTier
  76. #endif