NetworkConfig.hpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  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 (unused, now always disabled)
  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. inline bool operator==(const NetworkConfig& nc) const
  216. {
  217. return (memcmp(this, &nc, sizeof(NetworkConfig)) == 0);
  218. }
  219. inline bool operator!=(const NetworkConfig& nc) const
  220. {
  221. return (! (*this == nc));
  222. }
  223. /**
  224. * Write this network config to a dictionary for transport
  225. *
  226. * @param d Dictionary
  227. * @param includeLegacy If true, include legacy fields for old node versions
  228. * @return True if dictionary was successfully created, false if e.g. overflow
  229. */
  230. bool toDictionary(Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY>& d, bool includeLegacy) const;
  231. /**
  232. * Read this network config from a dictionary
  233. *
  234. * @param d Dictionary (non-const since it might be modified during parse, should not be used after call)
  235. * @return True if dictionary was valid and network config successfully initialized
  236. */
  237. bool fromDictionary(const Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY>& d);
  238. /**
  239. * @return True if broadcast (ff:ff:ff:ff:ff:ff) address should work on this network
  240. */
  241. inline bool enableBroadcast() const
  242. {
  243. return ((this->flags & ZT_NETWORKCONFIG_FLAG_ENABLE_BROADCAST) != 0);
  244. }
  245. /**
  246. * @return True if IPv6 NDP emulation should be allowed for certain "magic" IPv6 address patterns
  247. */
  248. inline bool ndpEmulation() const
  249. {
  250. return ((this->flags & ZT_NETWORKCONFIG_FLAG_ENABLE_IPV6_NDP_EMULATION) != 0);
  251. }
  252. /**
  253. * @return Network type is public (no access control)
  254. */
  255. inline bool isPublic() const
  256. {
  257. return (this->type == ZT_NETWORK_TYPE_PUBLIC);
  258. }
  259. /**
  260. * @return Network type is private (certificate access control)
  261. */
  262. inline bool isPrivate() const
  263. {
  264. return (this->type == ZT_NETWORK_TYPE_PRIVATE);
  265. }
  266. /**
  267. * @return ZeroTier addresses of devices on this network designated as active bridges
  268. */
  269. inline std::vector<Address> activeBridges() const
  270. {
  271. std::vector<Address> r;
  272. for (unsigned int i = 0; i < specialistCount; ++i) {
  273. if ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE) != 0) {
  274. r.push_back(Address(specialists[i]));
  275. }
  276. }
  277. return r;
  278. }
  279. inline unsigned int activeBridges(Address ab[ZT_MAX_NETWORK_SPECIALISTS]) const
  280. {
  281. unsigned int c = 0;
  282. for (unsigned int i = 0; i < specialistCount; ++i) {
  283. if ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE) != 0) {
  284. ab[c++] = specialists[i];
  285. }
  286. }
  287. return c;
  288. }
  289. inline bool isActiveBridge(const Address& a) const
  290. {
  291. for (unsigned int i = 0; i < specialistCount; ++i) {
  292. if (((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE) != 0) && (a == specialists[i])) {
  293. return true;
  294. }
  295. }
  296. return false;
  297. }
  298. inline std::vector<Address> multicastReplicators() const
  299. {
  300. std::vector<Address> r;
  301. for (unsigned int i = 0; i < specialistCount; ++i) {
  302. if ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR) != 0) {
  303. r.push_back(Address(specialists[i]));
  304. }
  305. }
  306. return r;
  307. }
  308. inline unsigned int multicastReplicators(Address mr[ZT_MAX_NETWORK_SPECIALISTS]) const
  309. {
  310. unsigned int c = 0;
  311. for (unsigned int i = 0; i < specialistCount; ++i) {
  312. if ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR) != 0) {
  313. mr[c++] = specialists[i];
  314. }
  315. }
  316. return c;
  317. }
  318. inline bool isMulticastReplicator(const Address& a) const
  319. {
  320. for (unsigned int i = 0; i < specialistCount; ++i) {
  321. if (((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR) != 0) && (a == specialists[i])) {
  322. return true;
  323. }
  324. }
  325. return false;
  326. }
  327. inline std::vector<Address> alwaysContactAddresses() const
  328. {
  329. std::vector<Address> r;
  330. for (unsigned int i = 0; i < specialistCount; ++i) {
  331. if ((specialists[i] & (ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_RELAY | ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR)) != 0) {
  332. r.push_back(Address(specialists[i]));
  333. }
  334. }
  335. return r;
  336. }
  337. inline unsigned int alwaysContactAddresses(Address ac[ZT_MAX_NETWORK_SPECIALISTS]) const
  338. {
  339. unsigned int c = 0;
  340. for (unsigned int i = 0; i < specialistCount; ++i) {
  341. if ((specialists[i] & (ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_RELAY | ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR)) != 0) {
  342. ac[c++] = specialists[i];
  343. }
  344. }
  345. return c;
  346. }
  347. inline void alwaysContactAddresses(Hashtable<Address, std::vector<InetAddress> >& a) const
  348. {
  349. for (unsigned int i = 0; i < specialistCount; ++i) {
  350. if ((specialists[i] & (ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_RELAY | ZT_NETWORKCONFIG_SPECIALIST_TYPE_MULTICAST_REPLICATOR)) != 0) {
  351. a[Address(specialists[i])];
  352. }
  353. }
  354. }
  355. /**
  356. * @param fromPeer Peer attempting to bridge other Ethernet peers onto network
  357. * @return True if this network allows bridging
  358. */
  359. inline bool permitsBridging(const Address& fromPeer) const
  360. {
  361. for (unsigned int i = 0; i < specialistCount; ++i) {
  362. if ((fromPeer == specialists[i]) && ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE) != 0)) {
  363. return true;
  364. }
  365. }
  366. return false;
  367. }
  368. inline operator bool() const
  369. {
  370. return (networkId != 0);
  371. }
  372. /**
  373. * Add a specialist or mask flags if already present
  374. *
  375. * This masks the existing flags if the specialist is already here or adds
  376. * it otherwise.
  377. *
  378. * @param a Address of specialist
  379. * @param f Flags (OR of specialist role/type flags)
  380. * @return True if successfully masked or added
  381. */
  382. inline bool addSpecialist(const Address& a, const uint64_t f)
  383. {
  384. const uint64_t aint = a.toInt();
  385. for (unsigned int i = 0; i < specialistCount; ++i) {
  386. if ((specialists[i] & 0xffffffffffULL) == aint) {
  387. specialists[i] |= f;
  388. return true;
  389. }
  390. }
  391. if (specialistCount < ZT_MAX_NETWORK_SPECIALISTS) {
  392. specialists[specialistCount++] = f | aint;
  393. return true;
  394. }
  395. return false;
  396. }
  397. const Capability* capability(const uint32_t id) const
  398. {
  399. for (unsigned int i = 0; i < capabilityCount; ++i) {
  400. if (capabilities[i].id() == id) {
  401. return &(capabilities[i]);
  402. }
  403. }
  404. return (Capability*)0;
  405. }
  406. const Tag* tag(const uint32_t id) const
  407. {
  408. for (unsigned int i = 0; i < tagCount; ++i) {
  409. if (tags[i].id() == id) {
  410. return &(tags[i]);
  411. }
  412. }
  413. return (Tag*)0;
  414. }
  415. /**
  416. * Network ID that this configuration applies to
  417. */
  418. uint64_t networkId;
  419. /**
  420. * Controller-side time of config generation/issue
  421. */
  422. int64_t timestamp;
  423. /**
  424. * Max difference between timestamp and tag/capability timestamp
  425. */
  426. int64_t credentialTimeMaxDelta;
  427. /**
  428. * Controller-side revision counter for this configuration
  429. */
  430. uint64_t revision;
  431. /**
  432. * Address of device to which this config is issued
  433. */
  434. Address issuedTo;
  435. /**
  436. * If non-NULL, remote traces related to this network are sent here
  437. */
  438. Address remoteTraceTarget;
  439. /**
  440. * Flags (64-bit)
  441. */
  442. uint64_t flags;
  443. /**
  444. * Remote trace level
  445. */
  446. Trace::Level remoteTraceLevel;
  447. /**
  448. * Network MTU
  449. */
  450. unsigned int mtu;
  451. /**
  452. * Maximum number of recipients per multicast (not including active bridges)
  453. */
  454. unsigned int multicastLimit;
  455. /**
  456. * Number of specialists
  457. */
  458. unsigned int specialistCount;
  459. /**
  460. * Number of routes
  461. */
  462. unsigned int routeCount;
  463. /**
  464. * Number of ZT-managed static IP assignments
  465. */
  466. unsigned int staticIpCount;
  467. /**
  468. * Number of rule table entries
  469. */
  470. unsigned int ruleCount;
  471. /**
  472. * Number of capabilities
  473. */
  474. unsigned int capabilityCount;
  475. /**
  476. * Number of tags
  477. */
  478. unsigned int tagCount;
  479. /**
  480. * Number of certificates of ownership
  481. */
  482. unsigned int certificateOfOwnershipCount;
  483. /**
  484. * Specialist devices
  485. *
  486. * For each entry the least significant 40 bits are the device's ZeroTier
  487. * address and the most significant 24 bits are flags indicating its role.
  488. */
  489. uint64_t specialists[ZT_MAX_NETWORK_SPECIALISTS];
  490. /**
  491. * Statically defined "pushed" routes (including default gateways)
  492. */
  493. ZT_VirtualNetworkRoute routes[ZT_MAX_NETWORK_ROUTES];
  494. /**
  495. * Static IP assignments
  496. */
  497. InetAddress staticIps[ZT_MAX_ZT_ASSIGNED_ADDRESSES];
  498. /**
  499. * Base network rules
  500. */
  501. ZT_VirtualNetworkRule rules[ZT_MAX_NETWORK_RULES];
  502. /**
  503. * Capabilities for this node on this network, in ascending order of capability ID
  504. */
  505. Capability capabilities[ZT_MAX_NETWORK_CAPABILITIES];
  506. /**
  507. * Tags for this node on this network, in ascending order of tag ID
  508. */
  509. Tag tags[ZT_MAX_NETWORK_TAGS];
  510. /**
  511. * Certificates of ownership for this network member
  512. */
  513. CertificateOfOwnership certificatesOfOwnership[ZT_MAX_CERTIFICATES_OF_OWNERSHIP];
  514. /**
  515. * Network type (currently just public or private)
  516. */
  517. ZT_VirtualNetworkType type;
  518. /**
  519. * Network short name or empty string if not defined
  520. */
  521. char name[ZT_MAX_NETWORK_SHORT_NAME_LENGTH + 1];
  522. /**
  523. * Certificate of membership (for private networks)
  524. */
  525. CertificateOfMembership com;
  526. /**
  527. * Number of ZT-pushed DNS configurations
  528. */
  529. unsigned int dnsCount;
  530. /**
  531. * ZT pushed DNS configuration
  532. */
  533. ZT_VirtualNetworkDNS dns;
  534. /**
  535. * SSO enabled flag.
  536. */
  537. bool ssoEnabled;
  538. /**
  539. * SSO version
  540. */
  541. uint64_t ssoVersion;
  542. /**
  543. * Authentication URL if authentication is required
  544. */
  545. char authenticationURL[2048];
  546. /**
  547. * Time current authentication expires or 0 if external authentication is disabled
  548. *
  549. * Not used if authVersion >= 1
  550. */
  551. uint64_t authenticationExpiryTime;
  552. /**
  553. * OIDC issuer URL
  554. */
  555. char issuerURL[2048];
  556. /**
  557. * central base URL.
  558. */
  559. char centralAuthURL[2048];
  560. /**
  561. * sso nonce
  562. */
  563. char ssoNonce[128];
  564. /**
  565. * sso state
  566. */
  567. char ssoState[256];
  568. /**
  569. * oidc client id
  570. */
  571. char ssoClientID[256];
  572. /**
  573. * oidc provider
  574. *
  575. * because certain providers require specific scopes to be requested
  576. * and others to be not requested in order to make everything work
  577. * correctly
  578. **/
  579. char ssoProvider[64];
  580. };
  581. } // namespace ZeroTier
  582. #endif