RuntimeEnvironment.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * ZeroTier One - Network Virtualization Everywhere
  3. * Copyright (C) 2011-2015 ZeroTier, Inc.
  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. * --
  19. *
  20. * ZeroTier may be used and distributed under the terms of the GPLv3, which
  21. * are available at: http://www.gnu.org/licenses/gpl-3.0.html
  22. *
  23. * If you would like to embed ZeroTier into a commercial application or
  24. * redistribute it in a modified binary form, please contact ZeroTier Networks
  25. * LLC. Start here: http://www.zerotier.com/
  26. */
  27. #ifndef ZT_RUNTIMEENVIRONMENT_HPP
  28. #define ZT_RUNTIMEENVIRONMENT_HPP
  29. #include <string>
  30. #include "Constants.hpp"
  31. #include "Identity.hpp"
  32. namespace ZeroTier {
  33. class NodeConfig;
  34. class Switch;
  35. class Topology;
  36. class CMWC4096;
  37. class Node;
  38. class Multicaster;
  39. class AntiRecursion;
  40. class NetworkConfigMaster;
  41. class SelfAwareness;
  42. /**
  43. * Holds global state for an instance of ZeroTier::Node
  44. */
  45. class RuntimeEnvironment
  46. {
  47. public:
  48. RuntimeEnvironment(Node *n) :
  49. node(n),
  50. identity(),
  51. netconfMaster((NetworkConfigMaster *)0),
  52. prng((CMWC4096 *)0),
  53. sw((Switch *)0),
  54. mc((Multicaster *)0),
  55. antiRec((AntiRecursion *)0),
  56. topology((Topology *)0),
  57. sa((SelfAwareness *)0)
  58. {
  59. }
  60. // Node instance that owns this RuntimeEnvironment
  61. Node *const node;
  62. // This node's identity
  63. Identity identity;
  64. // This is set externally to an instance of this base class if netconf functionality is enabled
  65. NetworkConfigMaster *netconfMaster;
  66. /*
  67. * Order matters a bit here. These are constructed in this order
  68. * and then deleted in the opposite order on Node exit. The order ensures
  69. * that things that are needed are there before they're needed.
  70. *
  71. * These are constant and never null after startup unless indicated.
  72. */
  73. CMWC4096 *prng;
  74. Switch *sw;
  75. Multicaster *mc;
  76. AntiRecursion *antiRec;
  77. Topology *topology;
  78. SelfAwareness *sa;
  79. };
  80. } // namespace ZeroTier
  81. #endif