Capability.hpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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_CAPABILITY_HPP
  14. #define ZT_CAPABILITY_HPP
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include "Constants.hpp"
  19. #include "Credential.hpp"
  20. #include "Address.hpp"
  21. #include "C25519.hpp"
  22. #include "Utils.hpp"
  23. #include "Buffer.hpp"
  24. #include "Identity.hpp"
  25. #include "../include/ZeroTierOne.h"
  26. namespace ZeroTier {
  27. class RuntimeEnvironment;
  28. /**
  29. * A set of grouped and signed network flow rules
  30. *
  31. * On the sending side the sender does the following for each packet:
  32. *
  33. * (1) Evaluates its capabilities in ascending order of ID to determine
  34. * which capability allows it to transmit this packet.
  35. * (2) If it has not done so lately, it then sends this capability to the
  36. * receiving peer ("presents" it).
  37. * (3) The sender then sends the packet.
  38. *
  39. * On the receiving side the receiver evaluates the capabilities presented
  40. * by the sender. If any valid un-expired capability allows this packet it
  41. * is accepted.
  42. *
  43. * Note that this is after evaluation of network scope rules and only if
  44. * network scope rules do not deliver an explicit match.
  45. *
  46. * Capabilities support a chain of custody. This is currently unused but
  47. * in the future would allow the publication of capabilities that can be
  48. * handed off between nodes. Limited transferability of capabilities is
  49. * a feature of true capability based security.
  50. */
  51. class Capability : public Credential
  52. {
  53. friend class Credential;
  54. public:
  55. static inline Credential::Type credentialType() { return Credential::CREDENTIAL_TYPE_CAPABILITY; }
  56. inline Capability() :
  57. _nwid(0),
  58. _ts(0),
  59. _id(0),
  60. _maxCustodyChainLength(0),
  61. _ruleCount(0)
  62. {
  63. memset(_rules,0,sizeof(_rules));
  64. memset(_custody,0,sizeof(_custody));
  65. }
  66. /**
  67. * @param id Capability ID
  68. * @param nwid Network ID
  69. * @param ts Timestamp (at controller)
  70. * @param mccl Maximum custody chain length (1 to create non-transferable capability)
  71. * @param rules Network flow rules for this capability
  72. * @param ruleCount Number of flow rules
  73. */
  74. inline Capability(uint32_t id,uint64_t nwid,int64_t ts,unsigned int mccl,const ZT_VirtualNetworkRule *rules,unsigned int ruleCount) :
  75. _nwid(nwid),
  76. _ts(ts),
  77. _id(id),
  78. _maxCustodyChainLength((mccl > 0) ? ((mccl < ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH) ? mccl : (unsigned int)ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH) : 1),
  79. _ruleCount((ruleCount < ZT_MAX_CAPABILITY_RULES) ? ruleCount : ZT_MAX_CAPABILITY_RULES)
  80. {
  81. if (_ruleCount > 0)
  82. memcpy(_rules,rules,sizeof(ZT_VirtualNetworkRule) * _ruleCount);
  83. }
  84. /**
  85. * @return Rules -- see ruleCount() for size of array
  86. */
  87. ZT_ALWAYS_INLINE const ZT_VirtualNetworkRule *rules() const { return _rules; }
  88. /**
  89. * @return Number of rules in rules()
  90. */
  91. ZT_ALWAYS_INLINE unsigned int ruleCount() const { return _ruleCount; }
  92. /**
  93. * @return ID and evaluation order of this capability in network
  94. */
  95. ZT_ALWAYS_INLINE uint32_t id() const { return _id; }
  96. /**
  97. * @return Network ID for which this capability was issued
  98. */
  99. ZT_ALWAYS_INLINE uint64_t networkId() const { return _nwid; }
  100. /**
  101. * @return Timestamp
  102. */
  103. ZT_ALWAYS_INLINE int64_t timestamp() const { return _ts; }
  104. /**
  105. * @return Last 'to' address in chain of custody
  106. */
  107. inline Address issuedTo() const
  108. {
  109. Address i2;
  110. for(unsigned int i=0;i<ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH;++i) {
  111. if (!_custody[i].to)
  112. return i2;
  113. else i2 = _custody[i].to;
  114. }
  115. return i2;
  116. }
  117. /**
  118. * Sign this capability and add signature to its chain of custody
  119. *
  120. * If this returns false, this object should be considered to be
  121. * in an undefined state and should be discarded. False can be returned
  122. * if there is no more room for signatures (max chain length reached)
  123. * or if the 'from' identity does not include a secret key to allow
  124. * it to sign anything.
  125. *
  126. * @param from Signing identity (must have secret)
  127. * @param to Recipient of this signature
  128. * @return True if signature successful and chain of custody appended
  129. */
  130. inline bool sign(const Identity &from,const Address &to)
  131. {
  132. try {
  133. for(unsigned int i=0;((i<_maxCustodyChainLength)&&(i<ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH));++i) {
  134. if (!(_custody[i].to)) {
  135. Buffer<(sizeof(Capability) * 2)> tmp;
  136. this->serialize(tmp,true);
  137. _custody[i].to = to;
  138. _custody[i].from = from.address();
  139. _custody[i].signatureLength = from.sign(tmp.data(),tmp.size(),_custody[i].signature,sizeof(_custody[i].signature));
  140. return true;
  141. }
  142. }
  143. } catch ( ... ) {}
  144. return false;
  145. }
  146. /**
  147. * Verify this capability's chain of custody and signatures
  148. *
  149. * @param RR Runtime environment to provide for peer lookup, etc.
  150. */
  151. inline Credential::VerifyResult verify(const RuntimeEnvironment *RR,void *tPtr) const { return _verify(RR,tPtr,*this); }
  152. template<unsigned int C>
  153. static inline void serializeRules(Buffer<C> &b,const ZT_VirtualNetworkRule *rules,unsigned int ruleCount)
  154. {
  155. for(unsigned int i=0;i<ruleCount;++i) {
  156. // Each rule consists of its 8-bit type followed by the size of that type's
  157. // field followed by field data. The inclusion of the size will allow non-supported
  158. // rules to be ignored but still parsed.
  159. b.append((uint8_t)rules[i].t);
  160. switch((ZT_VirtualNetworkRuleType)(rules[i].t & 0x3f)) {
  161. default:
  162. b.append((uint8_t)0);
  163. break;
  164. case ZT_NETWORK_RULE_ACTION_TEE:
  165. case ZT_NETWORK_RULE_ACTION_WATCH:
  166. case ZT_NETWORK_RULE_ACTION_REDIRECT:
  167. b.append((uint8_t)14);
  168. b.append((uint64_t)rules[i].v.fwd.address);
  169. b.append((uint32_t)rules[i].v.fwd.flags);
  170. b.append((uint16_t)rules[i].v.fwd.length); // unused for redirect
  171. break;
  172. case ZT_NETWORK_RULE_MATCH_SOURCE_ZEROTIER_ADDRESS:
  173. case ZT_NETWORK_RULE_MATCH_DEST_ZEROTIER_ADDRESS:
  174. b.append((uint8_t)5);
  175. Address(rules[i].v.zt).appendTo(b);
  176. break;
  177. case ZT_NETWORK_RULE_MATCH_VLAN_ID:
  178. b.append((uint8_t)2);
  179. b.append((uint16_t)rules[i].v.vlanId);
  180. break;
  181. case ZT_NETWORK_RULE_MATCH_VLAN_PCP:
  182. b.append((uint8_t)1);
  183. b.append((uint8_t)rules[i].v.vlanPcp);
  184. break;
  185. case ZT_NETWORK_RULE_MATCH_VLAN_DEI:
  186. b.append((uint8_t)1);
  187. b.append((uint8_t)rules[i].v.vlanDei);
  188. break;
  189. case ZT_NETWORK_RULE_MATCH_MAC_SOURCE:
  190. case ZT_NETWORK_RULE_MATCH_MAC_DEST:
  191. b.append((uint8_t)6);
  192. b.append(rules[i].v.mac,6);
  193. break;
  194. case ZT_NETWORK_RULE_MATCH_IPV4_SOURCE:
  195. case ZT_NETWORK_RULE_MATCH_IPV4_DEST:
  196. b.append((uint8_t)5);
  197. b.append(&(rules[i].v.ipv4.ip),4);
  198. b.append((uint8_t)rules[i].v.ipv4.mask);
  199. break;
  200. case ZT_NETWORK_RULE_MATCH_IPV6_SOURCE:
  201. case ZT_NETWORK_RULE_MATCH_IPV6_DEST:
  202. b.append((uint8_t)17);
  203. b.append(rules[i].v.ipv6.ip,16);
  204. b.append((uint8_t)rules[i].v.ipv6.mask);
  205. break;
  206. case ZT_NETWORK_RULE_MATCH_IP_TOS:
  207. b.append((uint8_t)3);
  208. b.append((uint8_t)rules[i].v.ipTos.mask);
  209. b.append((uint8_t)rules[i].v.ipTos.value[0]);
  210. b.append((uint8_t)rules[i].v.ipTos.value[1]);
  211. break;
  212. case ZT_NETWORK_RULE_MATCH_IP_PROTOCOL:
  213. b.append((uint8_t)1);
  214. b.append((uint8_t)rules[i].v.ipProtocol);
  215. break;
  216. case ZT_NETWORK_RULE_MATCH_ETHERTYPE:
  217. b.append((uint8_t)2);
  218. b.append((uint16_t)rules[i].v.etherType);
  219. break;
  220. case ZT_NETWORK_RULE_MATCH_ICMP:
  221. b.append((uint8_t)3);
  222. b.append((uint8_t)rules[i].v.icmp.type);
  223. b.append((uint8_t)rules[i].v.icmp.code);
  224. b.append((uint8_t)rules[i].v.icmp.flags);
  225. break;
  226. case ZT_NETWORK_RULE_MATCH_IP_SOURCE_PORT_RANGE:
  227. case ZT_NETWORK_RULE_MATCH_IP_DEST_PORT_RANGE:
  228. b.append((uint8_t)4);
  229. b.append((uint16_t)rules[i].v.port[0]);
  230. b.append((uint16_t)rules[i].v.port[1]);
  231. break;
  232. case ZT_NETWORK_RULE_MATCH_CHARACTERISTICS:
  233. b.append((uint8_t)8);
  234. b.append((uint64_t)rules[i].v.characteristics);
  235. break;
  236. case ZT_NETWORK_RULE_MATCH_FRAME_SIZE_RANGE:
  237. b.append((uint8_t)4);
  238. b.append((uint16_t)rules[i].v.frameSize[0]);
  239. b.append((uint16_t)rules[i].v.frameSize[1]);
  240. break;
  241. case ZT_NETWORK_RULE_MATCH_RANDOM:
  242. b.append((uint8_t)4);
  243. b.append((uint32_t)rules[i].v.randomProbability);
  244. break;
  245. case ZT_NETWORK_RULE_MATCH_TAGS_DIFFERENCE:
  246. case ZT_NETWORK_RULE_MATCH_TAGS_BITWISE_AND:
  247. case ZT_NETWORK_RULE_MATCH_TAGS_BITWISE_OR:
  248. case ZT_NETWORK_RULE_MATCH_TAGS_BITWISE_XOR:
  249. case ZT_NETWORK_RULE_MATCH_TAGS_EQUAL:
  250. case ZT_NETWORK_RULE_MATCH_TAG_SENDER:
  251. case ZT_NETWORK_RULE_MATCH_TAG_RECEIVER:
  252. b.append((uint8_t)8);
  253. b.append((uint32_t)rules[i].v.tag.id);
  254. b.append((uint32_t)rules[i].v.tag.value);
  255. break;
  256. case ZT_NETWORK_RULE_MATCH_INTEGER_RANGE:
  257. b.append((uint8_t)19);
  258. b.append((uint64_t)rules[i].v.intRange.start);
  259. b.append((uint64_t)(rules[i].v.intRange.start + (uint64_t)rules[i].v.intRange.end)); // more future-proof
  260. b.append((uint16_t)rules[i].v.intRange.idx);
  261. b.append((uint8_t)rules[i].v.intRange.format);
  262. break;
  263. }
  264. }
  265. }
  266. template<unsigned int C>
  267. static inline void deserializeRules(const Buffer<C> &b,unsigned int &p,ZT_VirtualNetworkRule *rules,unsigned int &ruleCount,const unsigned int maxRuleCount)
  268. {
  269. while ((ruleCount < maxRuleCount)&&(p < b.size())) {
  270. rules[ruleCount].t = (uint8_t)b[p++];
  271. const unsigned int fieldLen = (unsigned int)b[p++];
  272. switch((ZT_VirtualNetworkRuleType)(rules[ruleCount].t & 0x3f)) {
  273. default:
  274. break;
  275. case ZT_NETWORK_RULE_ACTION_TEE:
  276. case ZT_NETWORK_RULE_ACTION_WATCH:
  277. case ZT_NETWORK_RULE_ACTION_REDIRECT:
  278. rules[ruleCount].v.fwd.address = b.template at<uint64_t>(p);
  279. rules[ruleCount].v.fwd.flags = b.template at<uint32_t>(p + 8);
  280. rules[ruleCount].v.fwd.length = b.template at<uint16_t>(p + 12);
  281. break;
  282. case ZT_NETWORK_RULE_MATCH_SOURCE_ZEROTIER_ADDRESS:
  283. case ZT_NETWORK_RULE_MATCH_DEST_ZEROTIER_ADDRESS:
  284. rules[ruleCount].v.zt = Address(b.field(p,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH).toInt();
  285. break;
  286. case ZT_NETWORK_RULE_MATCH_VLAN_ID:
  287. rules[ruleCount].v.vlanId = b.template at<uint16_t>(p);
  288. break;
  289. case ZT_NETWORK_RULE_MATCH_VLAN_PCP:
  290. rules[ruleCount].v.vlanPcp = (uint8_t)b[p];
  291. break;
  292. case ZT_NETWORK_RULE_MATCH_VLAN_DEI:
  293. rules[ruleCount].v.vlanDei = (uint8_t)b[p];
  294. break;
  295. case ZT_NETWORK_RULE_MATCH_MAC_SOURCE:
  296. case ZT_NETWORK_RULE_MATCH_MAC_DEST:
  297. memcpy(rules[ruleCount].v.mac,b.field(p,6),6);
  298. break;
  299. case ZT_NETWORK_RULE_MATCH_IPV4_SOURCE:
  300. case ZT_NETWORK_RULE_MATCH_IPV4_DEST:
  301. memcpy(&(rules[ruleCount].v.ipv4.ip),b.field(p,4),4);
  302. rules[ruleCount].v.ipv4.mask = (uint8_t)b[p + 4];
  303. break;
  304. case ZT_NETWORK_RULE_MATCH_IPV6_SOURCE:
  305. case ZT_NETWORK_RULE_MATCH_IPV6_DEST:
  306. memcpy(rules[ruleCount].v.ipv6.ip,b.field(p,16),16);
  307. rules[ruleCount].v.ipv6.mask = (uint8_t)b[p + 16];
  308. break;
  309. case ZT_NETWORK_RULE_MATCH_IP_TOS:
  310. rules[ruleCount].v.ipTos.mask = (uint8_t)b[p];
  311. rules[ruleCount].v.ipTos.value[0] = (uint8_t)b[p+1];
  312. rules[ruleCount].v.ipTos.value[1] = (uint8_t)b[p+2];
  313. break;
  314. case ZT_NETWORK_RULE_MATCH_IP_PROTOCOL:
  315. rules[ruleCount].v.ipProtocol = (uint8_t)b[p];
  316. break;
  317. case ZT_NETWORK_RULE_MATCH_ETHERTYPE:
  318. rules[ruleCount].v.etherType = b.template at<uint16_t>(p);
  319. break;
  320. case ZT_NETWORK_RULE_MATCH_ICMP:
  321. rules[ruleCount].v.icmp.type = (uint8_t)b[p];
  322. rules[ruleCount].v.icmp.code = (uint8_t)b[p+1];
  323. rules[ruleCount].v.icmp.flags = (uint8_t)b[p+2];
  324. break;
  325. case ZT_NETWORK_RULE_MATCH_IP_SOURCE_PORT_RANGE:
  326. case ZT_NETWORK_RULE_MATCH_IP_DEST_PORT_RANGE:
  327. rules[ruleCount].v.port[0] = b.template at<uint16_t>(p);
  328. rules[ruleCount].v.port[1] = b.template at<uint16_t>(p + 2);
  329. break;
  330. case ZT_NETWORK_RULE_MATCH_CHARACTERISTICS:
  331. rules[ruleCount].v.characteristics = b.template at<uint64_t>(p);
  332. break;
  333. case ZT_NETWORK_RULE_MATCH_FRAME_SIZE_RANGE:
  334. rules[ruleCount].v.frameSize[0] = b.template at<uint16_t>(p);
  335. rules[ruleCount].v.frameSize[1] = b.template at<uint16_t>(p + 2);
  336. break;
  337. case ZT_NETWORK_RULE_MATCH_RANDOM:
  338. rules[ruleCount].v.randomProbability = b.template at<uint32_t>(p);
  339. break;
  340. case ZT_NETWORK_RULE_MATCH_TAGS_DIFFERENCE:
  341. case ZT_NETWORK_RULE_MATCH_TAGS_BITWISE_AND:
  342. case ZT_NETWORK_RULE_MATCH_TAGS_BITWISE_OR:
  343. case ZT_NETWORK_RULE_MATCH_TAGS_BITWISE_XOR:
  344. case ZT_NETWORK_RULE_MATCH_TAGS_EQUAL:
  345. case ZT_NETWORK_RULE_MATCH_TAG_SENDER:
  346. case ZT_NETWORK_RULE_MATCH_TAG_RECEIVER:
  347. rules[ruleCount].v.tag.id = b.template at<uint32_t>(p);
  348. rules[ruleCount].v.tag.value = b.template at<uint32_t>(p + 4);
  349. break;
  350. case ZT_NETWORK_RULE_MATCH_INTEGER_RANGE:
  351. rules[ruleCount].v.intRange.start = b.template at<uint64_t>(p);
  352. rules[ruleCount].v.intRange.end = (uint32_t)(b.template at<uint64_t>(p + 8) - rules[ruleCount].v.intRange.start);
  353. rules[ruleCount].v.intRange.idx = b.template at<uint16_t>(p + 16);
  354. rules[ruleCount].v.intRange.format = (uint8_t)b[p + 18];
  355. break;
  356. }
  357. p += fieldLen;
  358. ++ruleCount;
  359. }
  360. }
  361. template<unsigned int C>
  362. inline void serialize(Buffer<C> &b,const bool forSign = false) const
  363. {
  364. if (forSign) b.append((uint64_t)0x7f7f7f7f7f7f7f7fULL);
  365. // These are the same between Tag and Capability
  366. b.append(_nwid);
  367. b.append(_ts);
  368. b.append(_id);
  369. b.append((uint16_t)_ruleCount);
  370. serializeRules(b,_rules,_ruleCount);
  371. b.append((uint8_t)_maxCustodyChainLength);
  372. if (!forSign) {
  373. for(unsigned int i=0;;++i) {
  374. if ((i < _maxCustodyChainLength)&&(i < ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH)&&(_custody[i].to)) {
  375. _custody[i].to.appendTo(b);
  376. _custody[i].from.appendTo(b);
  377. b.append((uint8_t)1);
  378. b.append((uint16_t)_custody[i].signatureLength);
  379. b.append(_custody[i].signature,_custody[i].signatureLength);
  380. } else {
  381. b.append((unsigned char)0,ZT_ADDRESS_LENGTH); // zero 'to' terminates chain
  382. break;
  383. }
  384. }
  385. }
  386. // This is the size of any additional fields, currently 0.
  387. b.append((uint16_t)0);
  388. if (forSign) b.append((uint64_t)0x7f7f7f7f7f7f7f7fULL);
  389. }
  390. template<unsigned int C>
  391. inline unsigned int deserialize(const Buffer<C> &b,unsigned int startAt = 0)
  392. {
  393. *this = Capability();
  394. unsigned int p = startAt;
  395. _nwid = b.template at<uint64_t>(p); p += 8;
  396. _ts = b.template at<uint64_t>(p); p += 8;
  397. _id = b.template at<uint32_t>(p); p += 4;
  398. const unsigned int rc = b.template at<uint16_t>(p); p += 2;
  399. if (rc > ZT_MAX_CAPABILITY_RULES)
  400. throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_OVERFLOW;
  401. deserializeRules(b,p,_rules,_ruleCount,rc);
  402. _maxCustodyChainLength = (unsigned int)b[p++];
  403. if ((_maxCustodyChainLength < 1)||(_maxCustodyChainLength > ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH))
  404. throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_OVERFLOW;
  405. for(unsigned int i=0;;++i) {
  406. const Address to(b.field(p,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH); p += ZT_ADDRESS_LENGTH;
  407. if (!to)
  408. break;
  409. if ((i >= _maxCustodyChainLength)||(i >= ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH))
  410. throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_OVERFLOW;
  411. _custody[i].to = to;
  412. _custody[i].from.setTo(b.field(p,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH); p += ZT_ADDRESS_LENGTH;
  413. if (b[p++] == 1) {
  414. _custody[i].signatureLength = b.template at<uint16_t>(p);
  415. if (_custody[i].signatureLength > sizeof(_custody[i].signature))
  416. throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_INVALID_CRYPTOGRAPHIC_TOKEN;
  417. p += 2;
  418. memcpy(_custody[i].signature,b.field(p,_custody[i].signatureLength),_custody[i].signatureLength); p += _custody[i].signatureLength;
  419. } else {
  420. p += 2 + b.template at<uint16_t>(p);
  421. }
  422. }
  423. p += 2 + b.template at<uint16_t>(p);
  424. if (p > b.size())
  425. throw ZT_EXCEPTION_INVALID_SERIALIZED_DATA_OVERFLOW;
  426. return (p - startAt);
  427. }
  428. // Provides natural sort order by ID
  429. ZT_ALWAYS_INLINE bool operator<(const Capability &c) const { return (_id < c._id); }
  430. ZT_ALWAYS_INLINE bool operator==(const Capability &c) const { return (memcmp(this,&c,sizeof(Capability)) == 0); }
  431. ZT_ALWAYS_INLINE bool operator!=(const Capability &c) const { return (memcmp(this,&c,sizeof(Capability)) != 0); }
  432. private:
  433. uint64_t _nwid;
  434. int64_t _ts;
  435. uint32_t _id;
  436. unsigned int _maxCustodyChainLength;
  437. unsigned int _ruleCount;
  438. ZT_VirtualNetworkRule _rules[ZT_MAX_CAPABILITY_RULES];
  439. struct {
  440. Address to;
  441. Address from;
  442. unsigned int signatureLength;
  443. uint8_t signature[ZT_SIGNATURE_BUFFER_SIZE];
  444. } _custody[ZT_MAX_CAPABILITY_CUSTODY_CHAIN_LENGTH];
  445. };
  446. } // namespace ZeroTier
  447. #endif