NetworkConfig.hpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /*
  2. * Copyright (c)2019 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: 2025-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_NETWORKCONFIG_HPP
  14. #define ZT_NETWORKCONFIG_HPP
  15. #include <stdint.h>
  16. #include <string.h>
  17. #include <stdlib.h>
  18. #include <vector>
  19. #include <stdexcept>
  20. #include <algorithm>
  21. #include "../include/ZeroTierOne.h"
  22. #include "Constants.hpp"
  23. #include "Buffer.hpp"
  24. #include "DNS.hpp"
  25. #include "InetAddress.hpp"
  26. #include "MulticastGroup.hpp"
  27. #include "Address.hpp"
  28. #include "CertificateOfMembership.hpp"
  29. #include "CertificateOfOwnership.hpp"
  30. #include "Capability.hpp"
  31. #include "Tag.hpp"
  32. #include "Dictionary.hpp"
  33. #include "Hashtable.hpp"
  34. #include "Identity.hpp"
  35. #include "Utils.hpp"
  36. #include "Trace.hpp"
  37. /**
  38. * Default maximum time delta for COMs, tags, and capabilities
  39. *
  40. * The current value is two hours, providing ample time for a controller to
  41. * experience fail-over, etc.
  42. */
  43. #define ZT_NETWORKCONFIG_DEFAULT_CREDENTIAL_TIME_MAX_MAX_DELTA 7200000ULL
  44. /**
  45. * Default minimum credential TTL and maxDelta for COM timestamps
  46. *
  47. * This is just slightly over three minutes and provides three retries for
  48. * all currently online members to refresh.
  49. */
  50. #define ZT_NETWORKCONFIG_DEFAULT_CREDENTIAL_TIME_MIN_MAX_DELTA 185000ULL
  51. /**
  52. * Flag: enable broadcast
  53. */
  54. #define ZT_NETWORKCONFIG_FLAG_ENABLE_BROADCAST 0x0000000000000002ULL
  55. /**
  56. * Flag: enable IPv6 NDP emulation for certain V6 address patterns
  57. */
  58. #define ZT_NETWORKCONFIG_FLAG_ENABLE_IPV6_NDP_EMULATION 0x0000000000000004ULL
  59. /**
  60. * Flag: result of unrecognized MATCH entries in a rules table: match if set, no-match if clear
  61. */
  62. #define ZT_NETWORKCONFIG_FLAG_RULES_RESULT_OF_UNSUPPORTED_MATCH 0x0000000000000008ULL
  63. /**
  64. * Flag: disable frame compression
  65. */
  66. #define ZT_NETWORKCONFIG_FLAG_DISABLE_COMPRESSION 0x0000000000000010ULL
  67. /**
  68. * Device can bridge to other Ethernet networks and gets unknown recipient multicasts
  69. */
  70. #define ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE 0x0000020000000000ULL
  71. /**
  72. * Anchors are stable devices on this network that can act like roots when none are up
  73. */
  74. #define ZT_NETWORKCONFIG_SPECIALIST_TYPE_ANCHOR 0x0000040000000000ULL
  75. /**
  76. * Designated multicast replicators replicate multicast in place of sender-side replication
  77. */
  78. #define ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR 0x0000080000000000ULL
  79. namespace ZeroTier {
  80. // Dictionary capacity needed for max size network config
  81. #define ZT_NETWORKCONFIG_DICT_CAPACITY (4096 + (sizeof(ZT_VirtualNetworkRule) * ZT_MAX_NETWORK_RULES) + (sizeof(Capability) * ZT_MAX_NETWORK_CAPABILITIES) + (sizeof(Tag) * ZT_MAX_NETWORK_TAGS) + (sizeof(CertificateOfOwnership) * ZT_MAX_CERTIFICATES_OF_OWNERSHIP))
  82. // Dictionary capacity needed for max size network meta-data
  83. #define ZT_NETWORKCONFIG_METADATA_DICT_CAPACITY 1024
  84. // Network config version
  85. #define ZT_NETWORKCONFIG_VERSION 7
  86. // Fields for meta-data sent with network config requests
  87. // Network config version
  88. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_VERSION "v"
  89. // Protocol version (see Packet.hpp)
  90. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_PROTOCOL_VERSION "pv"
  91. // Software vendor
  92. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_NODE_VENDOR "vend"
  93. // Software major version
  94. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_NODE_MAJOR_VERSION "majv"
  95. // Software minor version
  96. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_NODE_MINOR_VERSION "minv"
  97. // Software revision
  98. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_NODE_REVISION "revv"
  99. // Rules engine revision
  100. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_RULES_ENGINE_REV "revr"
  101. // Maximum number of rules per network this node can accept
  102. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_NETWORK_RULES "mr"
  103. // Maximum number of capabilities this node can accept
  104. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_NETWORK_CAPABILITIES "mc"
  105. // Maximum number of rules per capability this node can accept
  106. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_CAPABILITY_RULES "mcr"
  107. // Maximum number of tags this node can accept
  108. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_NETWORK_TAGS "mt"
  109. // Network join authorization token (if any)
  110. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_AUTH "a"
  111. // Network configuration meta-data flags
  112. #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_FLAGS "f"
  113. // These dictionary keys are short so they don't take up much room.
  114. // By convention we use upper case for binary blobs, but it doesn't really matter.
  115. // network config version
  116. #define ZT_NETWORKCONFIG_DICT_KEY_VERSION "v"
  117. // network ID
  118. #define ZT_NETWORKCONFIG_DICT_KEY_NETWORK_ID "nwid"
  119. // integer(hex)
  120. #define ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP "ts"
  121. // integer(hex)
  122. #define ZT_NETWORKCONFIG_DICT_KEY_REVISION "r"
  123. // address of member
  124. #define ZT_NETWORKCONFIG_DICT_KEY_ISSUED_TO "id"
  125. // remote trace target
  126. #define ZT_NETWORKCONFIG_DICT_KEY_REMOTE_TRACE_TARGET "tt"
  127. // remote trace level
  128. #define ZT_NETWORKCONFIG_DICT_KEY_REMOTE_TRACE_LEVEL "tl"
  129. // flags(hex)
  130. #define ZT_NETWORKCONFIG_DICT_KEY_FLAGS "f"
  131. // integer(hex)
  132. #define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_LIMIT "ml"
  133. // network type (hex)
  134. #define ZT_NETWORKCONFIG_DICT_KEY_TYPE "t"
  135. // text
  136. #define ZT_NETWORKCONFIG_DICT_KEY_NAME "n"
  137. // network MTU
  138. #define ZT_NETWORKCONFIG_DICT_KEY_MTU "mtu"
  139. // credential time max delta in ms
  140. #define ZT_NETWORKCONFIG_DICT_KEY_CREDENTIAL_TIME_MAX_DELTA "ctmd"
  141. // binary serialized certificate of membership
  142. #define ZT_NETWORKCONFIG_DICT_KEY_COM "C"
  143. // specialists (binary array of uint64_t)
  144. #define ZT_NETWORKCONFIG_DICT_KEY_SPECIALISTS "S"
  145. // routes (binary blob)
  146. #define ZT_NETWORKCONFIG_DICT_KEY_ROUTES "RT"
  147. // static IPs (binary blob)
  148. #define ZT_NETWORKCONFIG_DICT_KEY_STATIC_IPS "I"
  149. // rules (binary blob)
  150. #define ZT_NETWORKCONFIG_DICT_KEY_RULES "R"
  151. // capabilities (binary blobs)
  152. #define ZT_NETWORKCONFIG_DICT_KEY_CAPABILITIES "CAP"
  153. // tags (binary blobs)
  154. #define ZT_NETWORKCONFIG_DICT_KEY_TAGS "TAG"
  155. // tags (binary blobs)
  156. #define ZT_NETWORKCONFIG_DICT_KEY_CERTIFICATES_OF_OWNERSHIP "COO"
  157. // dns (binary blobs)
  158. #define ZT_NETWORKCONFIG_DICT_KEY_DNS "DNS"
  159. // sso enabld
  160. #define ZT_NETWORKCONFIG_DICT_KEY_SSO_ENABLED "ssoe"
  161. // authentication URL
  162. #define ZT_NETWORKCONFIG_DICT_KEY_AUTHENTICATION_URL "aurl"
  163. // authentication expiry
  164. #define ZT_NETWORKCONFIG_DICT_KEY_AUTHENTICATION_EXPIRY_TIME "aexpt"
  165. // Legacy fields -- these are obsoleted but are included when older clients query
  166. // boolean (now a flag)
  167. #define ZT_NETWORKCONFIG_DICT_KEY_ENABLE_BROADCAST_OLD "eb"
  168. // IP/bits[,IP/bits,...]
  169. // Note that IPs that end in all zeroes are routes with no assignment in them.
  170. #define ZT_NETWORKCONFIG_DICT_KEY_IPV4_STATIC_OLD "v4s"
  171. // IP/bits[,IP/bits,...]
  172. // Note that IPs that end in all zeroes are routes with no assignment in them.
  173. #define ZT_NETWORKCONFIG_DICT_KEY_IPV6_STATIC_OLD "v6s"
  174. // 0/1
  175. #define ZT_NETWORKCONFIG_DICT_KEY_PRIVATE_OLD "p"
  176. // integer(hex)[,integer(hex),...]
  177. #define ZT_NETWORKCONFIG_DICT_KEY_ALLOWED_ETHERNET_TYPES_OLD "et"
  178. // string-serialized CertificateOfMembership
  179. #define ZT_NETWORKCONFIG_DICT_KEY_CERTIFICATE_OF_MEMBERSHIP_OLD "com"
  180. // node[,node,...]
  181. #define ZT_NETWORKCONFIG_DICT_KEY_ACTIVE_BRIDGES_OLD "ab"
  182. // node;IP/port[,node;IP/port]
  183. #define ZT_NETWORKCONFIG_DICT_KEY_RELAYS_OLD "rl"
  184. // End legacy fields
  185. /**
  186. * Network configuration received from network controller nodes
  187. *
  188. * This is a memcpy()'able structure and is safe (in a crash sense) to modify
  189. * without locks.
  190. */
  191. class NetworkConfig
  192. {
  193. public:
  194. NetworkConfig() :
  195. networkId(0),
  196. timestamp(0),
  197. credentialTimeMaxDelta(0),
  198. revision(0),
  199. issuedTo(),
  200. remoteTraceTarget(),
  201. flags(0),
  202. remoteTraceLevel(Trace::LEVEL_NORMAL),
  203. mtu(0),
  204. multicastLimit(0),
  205. specialistCount(0),
  206. routeCount(0),
  207. staticIpCount(0),
  208. ruleCount(0),
  209. capabilityCount(0),
  210. tagCount(0),
  211. certificateOfOwnershipCount(0),
  212. capabilities(),
  213. tags(),
  214. certificatesOfOwnership(),
  215. type(ZT_NETWORK_TYPE_PRIVATE),
  216. dnsCount(0),
  217. ssoEnabled(false),
  218. authenticationURL(),
  219. authenticationExpiryTime(0)
  220. {
  221. name[0] = 0;
  222. memset(specialists, 0, sizeof(uint64_t)*ZT_MAX_NETWORK_SPECIALISTS);
  223. memset(routes, 0, sizeof(ZT_VirtualNetworkRoute)*ZT_MAX_NETWORK_ROUTES);
  224. memset(staticIps, 0, sizeof(InetAddress)*ZT_MAX_ZT_ASSIGNED_ADDRESSES);
  225. memset(rules, 0, sizeof(ZT_VirtualNetworkRule)*ZT_MAX_NETWORK_RULES);
  226. memset(&dns, 0, sizeof(ZT_VirtualNetworkDNS));
  227. }
  228. /**
  229. * Write this network config to a dictionary for transport
  230. *
  231. * @param d Dictionary
  232. * @param includeLegacy If true, include legacy fields for old node versions
  233. * @return True if dictionary was successfully created, false if e.g. overflow
  234. */
  235. bool toDictionary(Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d,bool includeLegacy) const;
  236. /**
  237. * Read this network config from a dictionary
  238. *
  239. * @param d Dictionary (non-const since it might be modified during parse, should not be used after call)
  240. * @return True if dictionary was valid and network config successfully initialized
  241. */
  242. bool fromDictionary(const Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d);
  243. /**
  244. * @return True if broadcast (ff:ff:ff:ff:ff:ff) address should work on this network
  245. */
  246. inline bool enableBroadcast() const { return ((this->flags & ZT_NETWORKCONFIG_FLAG_ENABLE_BROADCAST) != 0); }
  247. /**
  248. * @return True if IPv6 NDP emulation should be allowed for certain "magic" IPv6 address patterns
  249. */
  250. inline bool ndpEmulation() const { return ((this->flags & ZT_NETWORKCONFIG_FLAG_ENABLE_IPV6_NDP_EMULATION) != 0); }
  251. /**
  252. * @return True if frames should not be compressed
  253. */
  254. inline bool disableCompression() const
  255. {
  256. #ifndef ZT_DISABLE_COMPRESSION
  257. return ((this->flags & ZT_NETWORKCONFIG_FLAG_DISABLE_COMPRESSION) != 0);
  258. #else
  259. /* Compression is disabled for libzt builds since it causes non-obvious chaotic
  260. interference with lwIP's TCP congestion algorithm. Compression is also disabled
  261. for some NAS builds due to the usage of low-performance processors in certain
  262. older and budget models. */
  263. return false;
  264. #endif
  265. }
  266. /**
  267. * @return Network type is public (no access control)
  268. */
  269. inline bool isPublic() const { return (this->type == ZT_NETWORK_TYPE_PUBLIC); }
  270. /**
  271. * @return Network type is private (certificate access control)
  272. */
  273. inline bool isPrivate() const { return (this->type == ZT_NETWORK_TYPE_PRIVATE); }
  274. /**
  275. * @return ZeroTier addresses of devices on this network designated as active bridges
  276. */
  277. inline std::vector<Address> activeBridges() const
  278. {
  279. std::vector<Address> r;
  280. for(unsigned int i=0;i<specialistCount;++i) {
  281. if ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE) != 0)
  282. r.push_back(Address(specialists[i]));
  283. }
  284. return r;
  285. }
  286. inline unsigned int activeBridges(Address ab[ZT_MAX_NETWORK_SPECIALISTS]) const
  287. {
  288. unsigned int c = 0;
  289. for(unsigned int i=0;i<specialistCount;++i) {
  290. if ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE) != 0)
  291. ab[c++] = specialists[i];
  292. }
  293. return c;
  294. }
  295. inline bool isActiveBridge(const Address &a) const
  296. {
  297. for(unsigned int i=0;i<specialistCount;++i) {
  298. if (((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE) != 0)&&(a == specialists[i]))
  299. return true;
  300. }
  301. return false;
  302. }
  303. inline std::vector<Address> anchors() const
  304. {
  305. std::vector<Address> r;
  306. for(unsigned int i=0;i<specialistCount;++i) {
  307. if ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_ANCHOR) != 0)
  308. r.push_back(Address(specialists[i]));
  309. }
  310. return r;
  311. }
  312. inline std::vector<Address> multicastReplicators() const
  313. {
  314. std::vector<Address> r;
  315. for(unsigned int i=0;i<specialistCount;++i) {
  316. if ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR) != 0)
  317. r.push_back(Address(specialists[i]));
  318. }
  319. return r;
  320. }
  321. inline unsigned int multicastReplicators(Address mr[ZT_MAX_NETWORK_SPECIALISTS]) const
  322. {
  323. unsigned int c = 0;
  324. for(unsigned int i=0;i<specialistCount;++i) {
  325. if ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR) != 0)
  326. mr[c++] = specialists[i];
  327. }
  328. return c;
  329. }
  330. inline bool isMulticastReplicator(const Address &a) const
  331. {
  332. for(unsigned int i=0;i<specialistCount;++i) {
  333. if (((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR) != 0)&&(a == specialists[i]))
  334. return true;
  335. }
  336. return false;
  337. }
  338. inline std::vector<Address> alwaysContactAddresses() const
  339. {
  340. std::vector<Address> r;
  341. for(unsigned int i=0;i<specialistCount;++i) {
  342. if ((specialists[i] & (ZT_NETWORKCONFIG_SPECIALIST_TYPE_ANCHOR | ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR)) != 0)
  343. r.push_back(Address(specialists[i]));
  344. }
  345. return r;
  346. }
  347. inline unsigned int alwaysContactAddresses(Address ac[ZT_MAX_NETWORK_SPECIALISTS]) const
  348. {
  349. unsigned int c = 0;
  350. for(unsigned int i=0;i<specialistCount;++i) {
  351. if ((specialists[i] & (ZT_NETWORKCONFIG_SPECIALIST_TYPE_ANCHOR | ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR)) != 0)
  352. ac[c++] = specialists[i];
  353. }
  354. return c;
  355. }
  356. inline void alwaysContactAddresses(Hashtable< Address,std::vector<InetAddress> > &a) const
  357. {
  358. for(unsigned int i=0;i<specialistCount;++i) {
  359. if ((specialists[i] & (ZT_NETWORKCONFIG_SPECIALIST_TYPE_ANCHOR | ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR)) != 0) {
  360. a[Address(specialists[i])];
  361. }
  362. }
  363. }
  364. /**
  365. * @param fromPeer Peer attempting to bridge other Ethernet peers onto network
  366. * @return True if this network allows bridging
  367. */
  368. inline bool permitsBridging(const Address &fromPeer) const
  369. {
  370. for(unsigned int i=0;i<specialistCount;++i) {
  371. if ((fromPeer == specialists[i])&&((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE) != 0))
  372. return true;
  373. }
  374. return false;
  375. }
  376. inline operator bool() const { return (networkId != 0); }
  377. inline bool operator==(const NetworkConfig &nc) const { return (memcmp(this,&nc,sizeof(NetworkConfig)) == 0); }
  378. inline bool operator!=(const NetworkConfig &nc) const { return (!(*this == nc)); }
  379. /**
  380. * Add a specialist or mask flags if already present
  381. *
  382. * This masks the existing flags if the specialist is already here or adds
  383. * it otherwise.
  384. *
  385. * @param a Address of specialist
  386. * @param f Flags (OR of specialist role/type flags)
  387. * @return True if successfully masked or added
  388. */
  389. inline bool addSpecialist(const Address &a,const uint64_t f)
  390. {
  391. const uint64_t aint = a.toInt();
  392. for(unsigned int i=0;i<specialistCount;++i) {
  393. if ((specialists[i] & 0xffffffffffULL) == aint) {
  394. specialists[i] |= f;
  395. return true;
  396. }
  397. }
  398. if (specialistCount < ZT_MAX_NETWORK_SPECIALISTS) {
  399. specialists[specialistCount++] = f | aint;
  400. return true;
  401. }
  402. return false;
  403. }
  404. const Capability *capability(const uint32_t id) const
  405. {
  406. for(unsigned int i=0;i<capabilityCount;++i) {
  407. if (capabilities[i].id() == id)
  408. return &(capabilities[i]);
  409. }
  410. return (Capability *)0;
  411. }
  412. const Tag *tag(const uint32_t id) const
  413. {
  414. for(unsigned int i=0;i<tagCount;++i) {
  415. if (tags[i].id() == id)
  416. return &(tags[i]);
  417. }
  418. return (Tag *)0;
  419. }
  420. /**
  421. * Network ID that this configuration applies to
  422. */
  423. uint64_t networkId;
  424. /**
  425. * Controller-side time of config generation/issue
  426. */
  427. int64_t timestamp;
  428. /**
  429. * Max difference between timestamp and tag/capability timestamp
  430. */
  431. int64_t credentialTimeMaxDelta;
  432. /**
  433. * Controller-side revision counter for this configuration
  434. */
  435. uint64_t revision;
  436. /**
  437. * Address of device to which this config is issued
  438. */
  439. Address issuedTo;
  440. /**
  441. * If non-NULL, remote traces related to this network are sent here
  442. */
  443. Address remoteTraceTarget;
  444. /**
  445. * Flags (64-bit)
  446. */
  447. uint64_t flags;
  448. /**
  449. * Remote trace level
  450. */
  451. Trace::Level remoteTraceLevel;
  452. /**
  453. * Network MTU
  454. */
  455. unsigned int mtu;
  456. /**
  457. * Maximum number of recipients per multicast (not including active bridges)
  458. */
  459. unsigned int multicastLimit;
  460. /**
  461. * Number of specialists
  462. */
  463. unsigned int specialistCount;
  464. /**
  465. * Number of routes
  466. */
  467. unsigned int routeCount;
  468. /**
  469. * Number of ZT-managed static IP assignments
  470. */
  471. unsigned int staticIpCount;
  472. /**
  473. * Number of rule table entries
  474. */
  475. unsigned int ruleCount;
  476. /**
  477. * Number of capabilities
  478. */
  479. unsigned int capabilityCount;
  480. /**
  481. * Number of tags
  482. */
  483. unsigned int tagCount;
  484. /**
  485. * Number of certificates of ownership
  486. */
  487. unsigned int certificateOfOwnershipCount;
  488. /**
  489. * Specialist devices
  490. *
  491. * For each entry the least significant 40 bits are the device's ZeroTier
  492. * address and the most significant 24 bits are flags indicating its role.
  493. */
  494. uint64_t specialists[ZT_MAX_NETWORK_SPECIALISTS];
  495. /**
  496. * Statically defined "pushed" routes (including default gateways)
  497. */
  498. ZT_VirtualNetworkRoute routes[ZT_MAX_NETWORK_ROUTES];
  499. /**
  500. * Static IP assignments
  501. */
  502. InetAddress staticIps[ZT_MAX_ZT_ASSIGNED_ADDRESSES];
  503. /**
  504. * Base network rules
  505. */
  506. ZT_VirtualNetworkRule rules[ZT_MAX_NETWORK_RULES];
  507. /**
  508. * Capabilities for this node on this network, in ascending order of capability ID
  509. */
  510. Capability capabilities[ZT_MAX_NETWORK_CAPABILITIES];
  511. /**
  512. * Tags for this node on this network, in ascending order of tag ID
  513. */
  514. Tag tags[ZT_MAX_NETWORK_TAGS];
  515. /**
  516. * Certificates of ownership for this network member
  517. */
  518. CertificateOfOwnership certificatesOfOwnership[ZT_MAX_CERTIFICATES_OF_OWNERSHIP];
  519. /**
  520. * Network type (currently just public or private)
  521. */
  522. ZT_VirtualNetworkType type;
  523. /**
  524. * Network short name or empty string if not defined
  525. */
  526. char name[ZT_MAX_NETWORK_SHORT_NAME_LENGTH + 1];
  527. /**
  528. * Certificate of membership (for private networks)
  529. */
  530. CertificateOfMembership com;
  531. /**
  532. * Number of ZT-pushed DNS configurations
  533. */
  534. unsigned int dnsCount;
  535. /**
  536. * ZT pushed DNS configuration
  537. */
  538. ZT_VirtualNetworkDNS dns;
  539. /**
  540. * SSO enabled flag.
  541. */
  542. bool ssoEnabled;
  543. /**
  544. * Authentication URL if authentication is required
  545. */
  546. char authenticationURL[2048];
  547. /**
  548. * Time current authentication expires or 0 if external authentication is disabled
  549. */
  550. uint64_t authenticationExpiryTime;
  551. };
  552. } // namespace ZeroTier
  553. #endif