Constants.hpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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: 2023-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_CONSTANTS_HPP
  14. #define ZT_CONSTANTS_HPP
  15. #include "../include/ZeroTierOne.h"
  16. //
  17. // This include file also auto-detects and canonicalizes some environment
  18. // information defines:
  19. //
  20. // __LINUX__
  21. // __APPLE__
  22. // __BSD__ (OSX also defines this)
  23. // __UNIX_LIKE__ (Linux, BSD, etc.)
  24. // __WINDOWS__
  25. //
  26. // Also makes sure __BYTE_ORDER is defined reasonably.
  27. //
  28. // Hack: make sure __GCC__ is defined on old GCC compilers
  29. #ifndef __GCC__
  30. #if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
  31. #define __GCC__
  32. #endif
  33. #endif
  34. #if defined(__linux__) || defined(linux) || defined(__LINUX__) || defined(__linux)
  35. #ifndef __LINUX__
  36. #define __LINUX__
  37. #endif
  38. #ifndef __UNIX_LIKE__
  39. #define __UNIX_LIKE__
  40. #endif
  41. #include <endian.h>
  42. #endif
  43. #ifdef __APPLE__
  44. #define likely(x) __builtin_expect((x),1)
  45. #define unlikely(x) __builtin_expect((x),0)
  46. #include <TargetConditionals.h>
  47. #ifndef __UNIX_LIKE__
  48. #define __UNIX_LIKE__
  49. #endif
  50. #ifndef __BSD__
  51. #define __BSD__
  52. #endif
  53. #include <machine/endian.h>
  54. #endif
  55. #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
  56. #ifndef __UNIX_LIKE__
  57. #define __UNIX_LIKE__
  58. #endif
  59. #ifndef __BSD__
  60. #define __BSD__
  61. #endif
  62. #include <machine/endian.h>
  63. #ifndef __BYTE_ORDER
  64. #define __BYTE_ORDER _BYTE_ORDER
  65. #define __LITTLE_ENDIAN _LITTLE_ENDIAN
  66. #define __BIG_ENDIAN _BIG_ENDIAN
  67. #endif
  68. #endif
  69. #if defined(_WIN32) || defined(_WIN64)
  70. #ifndef __WINDOWS__
  71. #define __WINDOWS__
  72. #endif
  73. #ifndef NOMINMAX
  74. #define NOMINMAX
  75. #endif
  76. #pragma warning(disable : 4290)
  77. #pragma warning(disable : 4996)
  78. #pragma warning(disable : 4101)
  79. #undef __UNIX_LIKE__
  80. #undef __BSD__
  81. #include <WinSock2.h>
  82. #include <Windows.h>
  83. #endif
  84. #ifdef __NetBSD__
  85. #ifndef RTF_MULTICAST
  86. #define RTF_MULTICAST 0x20000000
  87. #endif
  88. #endif
  89. // Define ZT_NO_TYPE_PUNNING to disable reckless casts on anything other than x86/x64.
  90. #if (!(defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86) || defined(__X86__) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) || defined(__386)))
  91. #ifndef ZT_NO_TYPE_PUNNING
  92. #define ZT_NO_TYPE_PUNNING
  93. #endif
  94. #endif
  95. // Assume little endian if not defined
  96. #if (defined(__APPLE__) || defined(__WINDOWS__)) && (!defined(__BYTE_ORDER))
  97. #undef __BYTE_ORDER
  98. #undef __LITTLE_ENDIAN
  99. #undef __BIG_ENDIAN
  100. #define __BIG_ENDIAN 4321
  101. #define __LITTLE_ENDIAN 1234
  102. #define __BYTE_ORDER 1234
  103. #endif
  104. #ifdef __WINDOWS__
  105. #define ZT_PATH_SEPARATOR '\\'
  106. #define ZT_PATH_SEPARATOR_S "\\"
  107. #define ZT_EOL_S "\r\n"
  108. #else
  109. #define ZT_PATH_SEPARATOR '/'
  110. #define ZT_PATH_SEPARATOR_S "/"
  111. #define ZT_EOL_S "\n"
  112. #endif
  113. #ifndef __BYTE_ORDER
  114. #include <endian.h>
  115. #endif
  116. #if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) || defined(__clang__)
  117. #ifndef likely
  118. #define likely(x) __builtin_expect((x),1)
  119. #endif
  120. #ifndef unlikely
  121. #define unlikely(x) __builtin_expect((x),0)
  122. #endif
  123. #else
  124. #ifndef likely
  125. #define likely(x) (x)
  126. #endif
  127. #ifndef unlikely
  128. #define unlikely(x) (x)
  129. #endif
  130. #endif
  131. #ifdef __WINDOWS__
  132. #define ZT_PACKED_STRUCT(D) __pragma(pack(push,1)) D __pragma(pack(pop))
  133. #else
  134. #define ZT_PACKED_STRUCT(D) D __attribute__((packed))
  135. #endif
  136. /**
  137. * Length of a ZeroTier address in bytes
  138. */
  139. #define ZT_ADDRESS_LENGTH 5
  140. /**
  141. * Length of a hexadecimal ZeroTier address
  142. */
  143. #define ZT_ADDRESS_LENGTH_HEX 10
  144. /**
  145. * Addresses beginning with this byte are reserved for the joy of in-band signaling
  146. */
  147. #define ZT_ADDRESS_RESERVED_PREFIX 0xff
  148. /**
  149. * Default MTU used for Ethernet tap device
  150. */
  151. #define ZT_DEFAULT_MTU 2800
  152. /**
  153. * Maximum number of packet fragments we'll support (protocol max: 16)
  154. */
  155. #define ZT_MAX_PACKET_FRAGMENTS 7
  156. /**
  157. * Size of RX queue
  158. */
  159. #define ZT_RX_QUEUE_SIZE 32
  160. /**
  161. * Size of TX queue
  162. */
  163. #define ZT_TX_QUEUE_SIZE 32
  164. /**
  165. * Length of secret key in bytes -- 256-bit -- do not change
  166. */
  167. #define ZT_PEER_SECRET_KEY_LENGTH 32
  168. /**
  169. * Minimum delay between timer task checks to prevent thrashing
  170. */
  171. #define ZT_CORE_TIMER_TASK_GRANULARITY 500
  172. /**
  173. * How often Topology::clean() and Network::clean() and similar are called, in ms
  174. */
  175. #define ZT_HOUSEKEEPING_PERIOD 60000
  176. /**
  177. * Delay between WHOIS retries in ms
  178. */
  179. #define ZT_WHOIS_RETRY_DELAY 500
  180. /**
  181. * Transmit queue entry timeout
  182. */
  183. #define ZT_TRANSMIT_QUEUE_TIMEOUT 5000
  184. /**
  185. * Receive queue entry timeout
  186. */
  187. #define ZT_RECEIVE_QUEUE_TIMEOUT 5000
  188. /**
  189. * Maximum number of ZT hops allowed (this is not IP hops/TTL)
  190. *
  191. * The protocol allows up to 7, but we limit it to something smaller.
  192. */
  193. #define ZT_RELAY_MAX_HOPS 3
  194. /**
  195. * Expire time for multicast 'likes' and indirect multicast memberships in ms
  196. */
  197. #define ZT_MULTICAST_LIKE_EXPIRE 600000
  198. /**
  199. * Period for multicast LIKE announcements
  200. */
  201. #define ZT_MULTICAST_ANNOUNCE_PERIOD 120000
  202. /**
  203. * Delay between explicit MULTICAST_GATHER requests for a given multicast channel
  204. */
  205. #define ZT_MULTICAST_EXPLICIT_GATHER_DELAY (ZT_MULTICAST_LIKE_EXPIRE / 10)
  206. /**
  207. * Timeout for outgoing multicasts
  208. *
  209. * This is how long we wait for explicit or implicit gather results.
  210. */
  211. #define ZT_MULTICAST_TRANSMIT_TIMEOUT 5000
  212. /**
  213. * Delay between checks of peer pings, etc., and also related housekeeping tasks
  214. */
  215. #define ZT_PING_CHECK_INVERVAL 5000
  216. /**
  217. * How often the local.conf file is checked for changes (service, should be moved there)
  218. */
  219. #define ZT_LOCAL_CONF_FILE_CHECK_INTERVAL 10000
  220. /**
  221. * How frequently to check for changes to the system's network interfaces. When
  222. * the service decides to use this constant it's because we want to react more
  223. * quickly to new interfaces that pop up or go down.
  224. */
  225. #define ZT_MULTIPATH_BINDER_REFRESH_PERIOD 5000
  226. /**
  227. * Packets are only used for QoS/ACK statistical sampling if their packet ID is divisible by
  228. * this integer. This is to provide a mechanism for both peers to agree on which packets need
  229. * special treatment without having to exchange information. Changing this value would be
  230. * a breaking change and would necessitate a protocol version upgrade. Since each incoming and
  231. * outgoing packet ID is checked against this value its evaluation is of the form:
  232. * (id & (divisor - 1)) == 0, thus the divisor must be a power of 2.
  233. *
  234. * This value is set at (16) so that given a normally-distributed RNG output we will sample
  235. * 1/16th (or ~6.25%) of packets.
  236. */
  237. #define ZT_PATH_QOS_ACK_PROTOCOL_DIVISOR 0x10
  238. /**
  239. * Time horizon for VERB_QOS_MEASUREMENT and VERB_ACK packet processing cutoff
  240. */
  241. #define ZT_PATH_QOS_ACK_CUTOFF_TIME 30000
  242. /**
  243. * Maximum number of VERB_QOS_MEASUREMENT and VERB_ACK packets allowed to be
  244. * processed within cutoff time. Separate totals are kept for each type but
  245. * the limit is the same for both.
  246. *
  247. * This limits how often this peer will compute statistical estimates
  248. * of various QoS measures from a VERB_QOS_MEASUREMENT or VERB_ACK packets to
  249. * CUTOFF_LIMIT times per CUTOFF_TIME milliseconds per peer to prevent
  250. * this from being useful for DOS amplification attacks.
  251. */
  252. #define ZT_PATH_QOS_ACK_CUTOFF_LIMIT 128
  253. /**
  254. * Path choice history window size. This is used to keep track of which paths were
  255. * previously selected so that we can maintain a target allocation over time.
  256. */
  257. #define ZT_MULTIPATH_PROPORTION_WIN_SZ 128
  258. /**
  259. * How often we will sample packet latency. Should be at least greater than ZT_PING_CHECK_INVERVAL
  260. * since we will record a 0 bit/s measurement if no valid latency measurement was made within this
  261. * window of time.
  262. */
  263. #define ZT_PATH_LATENCY_SAMPLE_INTERVAL (ZT_MULTIPATH_PEER_PING_PERIOD * 2)
  264. /**
  265. * Interval used for rate-limiting the computation of path quality estimates.
  266. */
  267. #define ZT_PATH_QUALITY_COMPUTE_INTERVAL 1000
  268. /**
  269. * Number of samples to consider when computing real-time path statistics
  270. */
  271. #define ZT_PATH_QUALITY_METRIC_REALTIME_CONSIDERATION_WIN_SZ 128
  272. /**
  273. * Number of samples to consider when computing performing long-term path quality analysis.
  274. * By default this value is set to ZT_PATH_QUALITY_METRIC_REALTIME_CONSIDERATION_WIN_SZ but can
  275. * be set to any value greater than that to observe longer-term path quality behavior.
  276. */
  277. #define ZT_PATH_QUALITY_METRIC_WIN_SZ ZT_PATH_QUALITY_METRIC_REALTIME_CONSIDERATION_WIN_SZ
  278. /**
  279. * Maximum acceptable Packet Delay Variance (PDV) over a path
  280. */
  281. #define ZT_PATH_MAX_PDV 1000
  282. /**
  283. * Maximum acceptable time interval between expectation and receipt of at least one ACK over a path
  284. */
  285. #define ZT_PATH_MAX_AGE 30000
  286. /**
  287. * Maximum acceptable mean latency over a path
  288. */
  289. #define ZT_PATH_MAX_MEAN_LATENCY 1000
  290. /**
  291. * How much each factor contributes to the "stability" score of a path
  292. */
  293. #define ZT_PATH_CONTRIB_PDV (1.0 / 3.0)
  294. #define ZT_PATH_CONTRIB_LATENCY (1.0 / 3.0)
  295. #define ZT_PATH_CONTRIB_THROUGHPUT_DISTURBANCE (1.0 / 3.0)
  296. /**
  297. * How much each factor contributes to the "quality" score of a path
  298. */
  299. #define ZT_PATH_CONTRIB_STABILITY (0.75 / 3.0)
  300. #define ZT_PATH_CONTRIB_THROUGHPUT (1.50 / 3.0)
  301. #define ZT_PATH_CONTRIB_SCOPE (0.75 / 3.0)
  302. /**
  303. * How often a QoS packet is sent
  304. */
  305. #define ZT_PATH_QOS_INTERVAL 3000
  306. /**
  307. * Min and max acceptable sizes for a VERB_QOS_MEASUREMENT packet
  308. */
  309. #define ZT_PATH_MIN_QOS_PACKET_SZ 8 + 1
  310. #define ZT_PATH_MAX_QOS_PACKET_SZ 1400
  311. /**
  312. * How many ID:sojourn time pairs in a single QoS packet
  313. */
  314. #define ZT_PATH_QOS_TABLE_SIZE ((ZT_PATH_MAX_QOS_PACKET_SZ * 8) / (64 + 16))
  315. /**
  316. * Maximum number of outgoing packets we monitor for QoS information
  317. */
  318. #define ZT_PATH_MAX_OUTSTANDING_QOS_RECORDS 128
  319. /**
  320. * Timeout for QoS records
  321. */
  322. #define ZT_PATH_QOS_TIMEOUT (ZT_PATH_QOS_INTERVAL * 2)
  323. /**
  324. * How often the service tests the path throughput
  325. */
  326. #define ZT_PATH_THROUGHPUT_MEASUREMENT_INTERVAL (ZT_PATH_ACK_INTERVAL * 8)
  327. /**
  328. * Minimum amount of time between each ACK packet
  329. */
  330. #define ZT_PATH_ACK_INTERVAL 1000
  331. /**
  332. * How often an aggregate link statistics report is emitted into this tracing system
  333. */
  334. #define ZT_PATH_AGGREGATE_STATS_REPORT_INTERVAL 60000
  335. /**
  336. * How much an aggregate link's component paths can vary from their target allocation
  337. * before the link is considered to be in a state of imbalance.
  338. */
  339. #define ZT_PATH_IMBALANCE_THRESHOLD 0.20
  340. /**
  341. * Max allowable time spent in any queue
  342. */
  343. #define ZT_QOS_TARGET 5 // ms
  344. /**
  345. * Time period where the time spent in the queue by a packet should fall below
  346. * target at least once
  347. */
  348. #define ZT_QOS_INTERVAL 100 // ms
  349. /**
  350. * The number of bytes that each queue is allowed to send during each DRR cycle.
  351. * This approximates a single-byte-based fairness queuing scheme
  352. */
  353. #define ZT_QOS_QUANTUM ZT_DEFAULT_MTU
  354. /**
  355. * The maximum total number of packets that can be queued among all
  356. * active/inactive, old/new queues
  357. */
  358. #define ZT_QOS_MAX_ENQUEUED_PACKETS 1024
  359. /**
  360. * Number of QoS queues (buckets)
  361. */
  362. #define ZT_QOS_NUM_BUCKETS 9
  363. /**
  364. * All unspecified traffic is put in this bucket. Anything in a bucket with a smaller
  365. * value is de-prioritized. Anything in a bucket with a higher value is prioritized over
  366. * other traffic.
  367. */
  368. #define ZT_QOS_DEFAULT_BUCKET 0
  369. /**
  370. * How frequently to send heartbeats over in-use paths
  371. */
  372. #define ZT_PATH_HEARTBEAT_PERIOD 14000
  373. /**
  374. * Do not accept HELLOs over a given path more often than this
  375. */
  376. #define ZT_PATH_HELLO_RATE_LIMIT 1000
  377. /**
  378. * Delay between full-fledge pings of directly connected peers
  379. */
  380. #define ZT_PEER_PING_PERIOD 60000
  381. /**
  382. * Delay between full-fledge pings of directly connected peers.
  383. *
  384. * With multipath bonding enabled ping peers more often to measure
  385. * packet loss and latency. This uses more bandwidth so is disabled
  386. * by default to avoid increasing idle bandwidth use for regular
  387. * links.
  388. */
  389. #define ZT_MULTIPATH_PEER_PING_PERIOD 5000
  390. /**
  391. * Paths are considered expired if they have not sent us a real packet in this long
  392. */
  393. #define ZT_PEER_PATH_EXPIRATION ((ZT_PEER_PING_PERIOD * 4) + 3000)
  394. /**
  395. * How often to retry expired paths that we're still remembering
  396. */
  397. #define ZT_PEER_EXPIRED_PATH_TRIAL_PERIOD (ZT_PEER_PING_PERIOD * 10)
  398. /**
  399. * Timeout for overall peer activity (measured from last receive)
  400. */
  401. #ifndef ZT_SDK
  402. #define ZT_PEER_ACTIVITY_TIMEOUT 500000
  403. #else
  404. #define ZT_PEER_ACTIVITY_TIMEOUT 30000
  405. #endif
  406. /**
  407. * General rate limit timeout for multiple packet types (HELLO, etc.)
  408. */
  409. #define ZT_PEER_GENERAL_INBOUND_RATE_LIMIT 500
  410. /**
  411. * General limit for max RTT for requests over the network
  412. */
  413. #define ZT_GENERAL_RTT_LIMIT 5000
  414. /**
  415. * Delay between requests for updated network autoconf information
  416. *
  417. * Don't lengthen this as it affects things like QoS / uptime monitoring
  418. * via ZeroTier Central. This is the heartbeat, basically.
  419. */
  420. #define ZT_NETWORK_AUTOCONF_DELAY 60000
  421. /**
  422. * Minimum interval between attempts by relays to unite peers
  423. *
  424. * When a relay gets a packet destined for another peer, it sends both peers
  425. * a RENDEZVOUS message no more than this often. This instructs the peers
  426. * to attempt NAT-t and gives each the other's corresponding IP:port pair.
  427. */
  428. #define ZT_MIN_UNITE_INTERVAL 30000
  429. /**
  430. * How often should peers try memorized or statically defined paths?
  431. */
  432. #define ZT_TRY_MEMORIZED_PATH_INTERVAL 30000
  433. /**
  434. * Sanity limit on maximum bridge routes
  435. *
  436. * If the number of bridge routes exceeds this, we cull routes from the
  437. * bridges with the most MACs behind them until it doesn't. This is a
  438. * sanity limit to prevent memory-filling DOS attacks, nothing more. No
  439. * physical LAN has anywhere even close to this many nodes. Note that this
  440. * does not limit the size of ZT virtual LANs, only bridge routing.
  441. */
  442. #define ZT_MAX_BRIDGE_ROUTES 67108864
  443. /**
  444. * If there is no known L2 bridging route, spam to up to this many active bridges
  445. */
  446. #define ZT_MAX_BRIDGE_SPAM 32
  447. /**
  448. * Interval between direct path pushes in milliseconds
  449. */
  450. #define ZT_DIRECT_PATH_PUSH_INTERVAL 15000
  451. /**
  452. * Interval between direct path pushes in milliseconds if we already have a path
  453. */
  454. #define ZT_DIRECT_PATH_PUSH_INTERVAL_HAVEPATH 120000
  455. /**
  456. * Time horizon for push direct paths cutoff
  457. */
  458. #define ZT_PUSH_DIRECT_PATHS_CUTOFF_TIME 30000
  459. /**
  460. * Maximum number of direct path pushes within cutoff time
  461. *
  462. * This limits response to PUSH_DIRECT_PATHS to CUTOFF_LIMIT responses
  463. * per CUTOFF_TIME milliseconds per peer to prevent this from being
  464. * useful for DOS amplification attacks.
  465. */
  466. #define ZT_PUSH_DIRECT_PATHS_CUTOFF_LIMIT 8
  467. /**
  468. * Maximum number of paths per IP scope (e.g. global, link-local) and family (e.g. v4/v6)
  469. */
  470. #define ZT_PUSH_DIRECT_PATHS_MAX_PER_SCOPE_AND_FAMILY 8
  471. /**
  472. * Time horizon for VERB_NETWORK_CREDENTIALS cutoff
  473. */
  474. #define ZT_PEER_CREDENTIALS_CUTOFF_TIME 60000
  475. /**
  476. * Maximum number of VERB_NETWORK_CREDENTIALS within cutoff time
  477. */
  478. #define ZT_PEER_CREDEITIALS_CUTOFF_LIMIT 15
  479. /**
  480. * WHOIS rate limit (we allow these to be pretty fast)
  481. */
  482. #define ZT_PEER_WHOIS_RATE_LIMIT 100
  483. /**
  484. * General rate limit for other kinds of rate-limited packets (HELLO, credential request, etc.) both inbound and outbound
  485. */
  486. #define ZT_PEER_GENERAL_RATE_LIMIT 1000
  487. /**
  488. * Don't do expensive identity validation more often than this
  489. *
  490. * IPv4 and IPv6 address prefixes are hashed down to 14-bit (0-16383) integers
  491. * using the first 24 bits for IPv4 or the first 48 bits for IPv6. These are
  492. * then rate limited to one identity validation per this often milliseconds.
  493. */
  494. #if (defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(__AMD64) || defined(__AMD64__) || defined(_M_X64) || defined(_M_AMD64))
  495. // AMD64 machines can do anywhere from one every 50ms to one every 10ms. This provides plenty of margin.
  496. #define ZT_IDENTITY_VALIDATION_SOURCE_RATE_LIMIT 2000
  497. #else
  498. #if (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86) || defined(_X86_) || defined(__I86__))
  499. // 32-bit Intel machines usually average about one every 100ms
  500. #define ZT_IDENTITY_VALIDATION_SOURCE_RATE_LIMIT 5000
  501. #else
  502. // This provides a safe margin for ARM, MIPS, etc. that usually average one every 250-400ms
  503. #define ZT_IDENTITY_VALIDATION_SOURCE_RATE_LIMIT 10000
  504. #endif
  505. #endif
  506. /**
  507. * How long is a path or peer considered to have a trust relationship with us (for e.g. relay policy) since last trusted established packet?
  508. */
  509. #define ZT_TRUST_EXPIRATION 600000
  510. /**
  511. * Enable support for older network configurations from older (pre-1.1.6) controllers
  512. */
  513. #define ZT_SUPPORT_OLD_STYLE_NETCONF 1
  514. /**
  515. * Desired buffer size for UDP sockets (used in service and osdep but defined here)
  516. */
  517. #if (defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(__AMD64) || defined(__AMD64__))
  518. #define ZT_UDP_DESIRED_BUF_SIZE 1048576
  519. #else
  520. #define ZT_UDP_DESIRED_BUF_SIZE 131072
  521. #endif
  522. /**
  523. * Desired / recommended min stack size for threads (used on some platforms to reset thread stack size)
  524. */
  525. #define ZT_THREAD_MIN_STACK_SIZE 1048576
  526. // Exceptions thrown in core ZT code
  527. #define ZT_EXCEPTION_OUT_OF_BOUNDS 100
  528. #define ZT_EXCEPTION_OUT_OF_MEMORY 101
  529. #define ZT_EXCEPTION_PRIVATE_KEY_REQUIRED 102
  530. #define ZT_EXCEPTION_INVALID_ARGUMENT 103
  531. #define ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_TYPE 200
  532. #define ZT_EXCEPTION_INVALID_SERIALIZED_DATA_OVERFLOW 201
  533. #define ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN 202
  534. #define ZT_EXCEPTION_INVALID_SERIALIZED_DATA_BAD_ENCODING 203
  535. #endif