NetworkConfig.hpp 18 KB

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