2013-07-04 16:56:19 -04:00
|
|
|
/*
|
2019-08-23 09:23:39 -07:00
|
|
|
* Copyright (c)2019 ZeroTier, Inc.
|
2013-07-04 16:56:19 -04:00
|
|
|
*
|
2019-08-23 09:23:39 -07:00
|
|
|
* Use of this software is governed by the Business Source License included
|
|
|
|
* in the LICENSE.TXT file in the project's root directory.
|
2013-07-04 16:56:19 -04:00
|
|
|
*
|
2020-08-20 12:51:39 -07:00
|
|
|
* Change Date: 2025-01-01
|
2013-07-04 16:56:19 -04:00
|
|
|
*
|
2019-08-23 09:23:39 -07:00
|
|
|
* On the date above, in accordance with the Business Source License, use
|
|
|
|
* of this software will be governed by version 2.0 of the Apache License.
|
2013-07-04 16:56:19 -04:00
|
|
|
*/
|
2019-08-23 09:23:39 -07:00
|
|
|
/****/
|
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
|
|
|
|
2017-07-06 16:11:11 -07:00
|
|
|
#include <string.h>
|
2013-09-17 15:53:59 -04:00
|
|
|
|
2013-08-01 17:32:37 -04:00
|
|
|
#include "Constants.hpp"
|
2017-07-06 10:25:36 -07:00
|
|
|
#include "Utils.hpp"
|
2013-07-04 16:56:19 -04:00
|
|
|
#include "Identity.hpp"
|
|
|
|
|
|
|
|
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;
|
2013-07-04 16:56:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds global state for an instance of ZeroTier::Node
|
|
|
|
*/
|
|
|
|
class RuntimeEnvironment
|
|
|
|
{
|
|
|
|
public:
|
2015-03-31 18:17:11 -07:00
|
|
|
RuntimeEnvironment(Node *n) :
|
2015-10-20 15:27:53 -07:00
|
|
|
node(n)
|
|
|
|
,localNetworkController((NetworkController *)0)
|
2018-01-25 09:57:02 -05:00
|
|
|
,rtmem((void *)0)
|
2015-10-20 15:27:53 -07:00
|
|
|
,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()
|
|
|
|
{
|
2017-07-06 16:11:11 -07: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
|
|
|
|
Node *const node;
|
|
|
|
|
2015-04-15 15:12:09 -07:00
|
|
|
// This is set externally to an instance of this base class
|
|
|
|
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.
|
|
|
|
void *rtmem;
|
|
|
|
|
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
|
|
|
|
2017-07-07 16:58:05 -07:00
|
|
|
Trace *t;
|
2013-07-04 16:56:19 -04:00
|
|
|
Switch *sw;
|
2014-10-29 13:57:37 -07:00
|
|
|
Multicaster *mc;
|
2013-07-04 16:56:19 -04:00
|
|
|
Topology *topology;
|
2015-04-06 20:17:21 -07:00
|
|
|
SelfAwareness *sa;
|
2021-09-01 21:37:49 -07:00
|
|
|
Bond *bc;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ZeroTier
|
|
|
|
|
|
|
|
#endif
|