2025-08-06 12:10:18 -04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
2013-07-04 16:56:19 -04:00
|
|
|
*
|
2025-08-06 12:10:18 -04:00
|
|
|
* (c) ZeroTier, Inc.
|
|
|
|
|
* https://www.zerotier.com/
|
2013-07-04 16:56:19 -04:00
|
|
|
*/
|
|
|
|
|
|
2013-12-06 16:49:20 -08:00
|
|
|
#ifndef ZT_RUNTIMEENVIRONMENT_HPP
|
|
|
|
|
#define ZT_RUNTIMEENVIRONMENT_HPP
|
2013-07-04 16:56:19 -04:00
|
|
|
|
2013-08-01 17:32:37 -04:00
|
|
|
#include "Constants.hpp"
|
2013-07-04 16:56:19 -04:00
|
|
|
#include "Identity.hpp"
|
2025-07-03 11:26:23 -04:00
|
|
|
#include "Utils.hpp"
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
2013-07-04 16:56:19 -04:00
|
|
|
|
|
|
|
|
namespace ZeroTier {
|
|
|
|
|
|
|
|
|
|
class NodeConfig;
|
|
|
|
|
class Switch;
|
|
|
|
|
class Topology;
|
2013-08-30 15:02:12 -04:00
|
|
|
class Node;
|
2014-09-30 16:28:25 -07:00
|
|
|
class Multicaster;
|
2015-04-15 15:12:09 -07:00
|
|
|
class NetworkController;
|
2015-04-06 20:17:21 -07:00
|
|
|
class SelfAwareness;
|
2017-07-07 16:58:05 -07:00
|
|
|
class Trace;
|
2021-09-01 21:37:49 -07:00
|
|
|
class Bond;
|
2024-08-18 15:07:18 -07:00
|
|
|
class PacketMultiplexer;
|
2013-07-04 16:56:19 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Holds global state for an instance of ZeroTier::Node
|
|
|
|
|
*/
|
2025-07-03 11:26:23 -04:00
|
|
|
class RuntimeEnvironment {
|
|
|
|
|
public:
|
|
|
|
|
RuntimeEnvironment(Node* n) : node(n), localNetworkController((NetworkController*)0), rtmem((void*)0), sw((Switch*)0), mc((Multicaster*)0), topology((Topology*)0), sa((SelfAwareness*)0)
|
2013-07-04 16:56:19 -04:00
|
|
|
{
|
2018-01-25 07:11:59 -05:00
|
|
|
publicIdentityStr[0] = (char)0;
|
|
|
|
|
secretIdentityStr[0] = (char)0;
|
2017-07-06 10:25:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~RuntimeEnvironment()
|
|
|
|
|
{
|
2025-07-03 11:26:23 -04:00
|
|
|
Utils::burn(secretIdentityStr, sizeof(secretIdentityStr));
|
2013-07-04 16:56:19 -04:00
|
|
|
}
|
|
|
|
|
|
2015-03-31 18:17:11 -07:00
|
|
|
// Node instance that owns this RuntimeEnvironment
|
2025-07-03 11:26:23 -04:00
|
|
|
Node* const node;
|
2015-03-31 18:17:11 -07:00
|
|
|
|
2015-04-15 15:12:09 -07:00
|
|
|
// This is set externally to an instance of this base class
|
2025-07-03 11:26:23 -04:00
|
|
|
NetworkController* localNetworkController;
|
2014-07-31 14:09:32 -07:00
|
|
|
|
2018-01-25 09:57:02 -05:00
|
|
|
// Memory actually occupied by Trace, Switch, etc.
|
2025-07-03 11:26:23 -04:00
|
|
|
void* rtmem;
|
2018-01-25 09:57:02 -05:00
|
|
|
|
2018-01-25 07:11:59 -05:00
|
|
|
/* Order matters a bit here. These are constructed in this order
|
2013-11-06 10:38:19 -05:00
|
|
|
* and then deleted in the opposite order on Node exit. The order ensures
|
|
|
|
|
* that things that are needed are there before they're needed.
|
|
|
|
|
*
|
2018-01-25 07:11:59 -05:00
|
|
|
* These are constant and never null after startup unless indicated. */
|
2013-07-25 17:53:57 -04:00
|
|
|
|
2025-07-03 11:26:23 -04:00
|
|
|
Trace* t;
|
|
|
|
|
Switch* sw;
|
|
|
|
|
Multicaster* mc;
|
|
|
|
|
Topology* topology;
|
|
|
|
|
SelfAwareness* sa;
|
|
|
|
|
Bond* bc;
|
|
|
|
|
PacketMultiplexer* pm;
|
2018-01-25 07:11:59 -05:00
|
|
|
|
|
|
|
|
// This node's identity and string representations thereof
|
|
|
|
|
Identity identity;
|
|
|
|
|
char publicIdentityStr[ZT_IDENTITY_STRING_BUFFER_LENGTH];
|
|
|
|
|
char secretIdentityStr[ZT_IDENTITY_STRING_BUFFER_LENGTH];
|
2013-07-04 16:56:19 -04:00
|
|
|
};
|
|
|
|
|
|
2025-07-03 11:26:23 -04:00
|
|
|
} // namespace ZeroTier
|
2013-07-04 16:56:19 -04:00
|
|
|
|
|
|
|
|
#endif
|