NetworkConfig.hpp 18 KB

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