Network.hpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. /*
  2. * ZeroTier One - Global Peer to Peer Ethernet
  3. * Copyright (C) 2012-2013 ZeroTier Networks LLC
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * --
  19. *
  20. * ZeroTier may be used and distributed under the terms of the GPLv3, which
  21. * are available at: http://www.gnu.org/licenses/gpl-3.0.html
  22. *
  23. * If you would like to embed ZeroTier into a commercial application or
  24. * redistribute it in a modified binary form, please contact ZeroTier Networks
  25. * LLC. Start here: http://www.zerotier.com/
  26. */
  27. #ifndef _ZT_NETWORK_HPP
  28. #define _ZT_NETWORK_HPP
  29. #include <stdint.h>
  30. #include <string>
  31. #include <set>
  32. #include <map>
  33. #include <vector>
  34. #include <algorithm>
  35. #include <stdexcept>
  36. #include "Constants.hpp"
  37. #include "Utils.hpp"
  38. #include "EthernetTap.hpp"
  39. #include "Address.hpp"
  40. #include "Mutex.hpp"
  41. #include "SharedPtr.hpp"
  42. #include "AtomicCounter.hpp"
  43. #include "MulticastGroup.hpp"
  44. #include "NonCopyable.hpp"
  45. #include "MAC.hpp"
  46. #include "Dictionary.hpp"
  47. #include "Identity.hpp"
  48. #include "InetAddress.hpp"
  49. #include "BandwidthAccount.hpp"
  50. #include "CertificateOfMembership.hpp"
  51. namespace ZeroTier {
  52. class RuntimeEnvironment;
  53. class NodeConfig;
  54. /**
  55. * A virtual LAN
  56. *
  57. * Networks can be open or closed. Each network has an ID whose most
  58. * significant 40 bits are the ZeroTier address of the node that should
  59. * be contacted for network configuration. The least significant 24
  60. * bits are arbitrary, allowing up to 2^24 networks per managing
  61. * node.
  62. *
  63. * Open networks do not track membership. Anyone is allowed to communicate
  64. * over them.
  65. *
  66. * Closed networks track membership by way of timestamped signatures. When
  67. * the network requests its configuration, one of the fields returned is
  68. * a signature for the identity of the peer on the network. This signature
  69. * includes a timestamp. When a peer communicates with other peers on a
  70. * closed network, it periodically (and pre-emptively) propagates this
  71. * signature to the peers with which it is communicating. Peers reject
  72. * packets with an error if no recent signature is on file.
  73. */
  74. class Network : NonCopyable
  75. {
  76. friend class SharedPtr<Network>;
  77. friend class NodeConfig;
  78. public:
  79. /**
  80. * Preload and rates of accrual for multicast group bandwidth limits
  81. *
  82. * Key is multicast group in lower case hex format: MAC (without :s) /
  83. * ADI (hex). Value is preload, maximum balance, and rate of accrual in
  84. * hex.
  85. */
  86. class MulticastRates : private Dictionary
  87. {
  88. public:
  89. /**
  90. * Preload and accrual parameter tuple
  91. */
  92. struct Rate
  93. {
  94. Rate() {}
  95. Rate(uint32_t pl,uint32_t maxb,uint32_t acc)
  96. {
  97. preload = pl;
  98. maxBalance = maxb;
  99. accrual = acc;
  100. }
  101. uint32_t preload;
  102. uint32_t maxBalance;
  103. uint32_t accrual;
  104. };
  105. MulticastRates() {}
  106. MulticastRates(const char *s) : Dictionary(s) {}
  107. MulticastRates(const std::string &s) : Dictionary(s) {}
  108. inline std::string toString() const { return Dictionary::toString(); }
  109. /**
  110. * A very minimal default rate, fast enough for ARP
  111. */
  112. static const Rate GLOBAL_DEFAULT_RATE;
  113. /**
  114. * @return Default rate, or GLOBAL_DEFAULT_RATE if not specified
  115. */
  116. inline Rate defaultRate() const
  117. {
  118. Rate r;
  119. const_iterator dfl(find("*"));
  120. if (dfl == end())
  121. return GLOBAL_DEFAULT_RATE;
  122. return _toRate(dfl->second);
  123. }
  124. /**
  125. * Get the rate for a given multicast group
  126. *
  127. * @param mg Multicast group
  128. * @return Rate or default() rate if not specified
  129. */
  130. inline Rate get(const MulticastGroup &mg) const
  131. {
  132. const_iterator r(find(mg.toString()));
  133. if (r == end())
  134. return defaultRate();
  135. return _toRate(r->second);
  136. }
  137. private:
  138. static inline Rate _toRate(const std::string &s)
  139. {
  140. char tmp[16384];
  141. Utils::scopy(tmp,sizeof(tmp),s.c_str());
  142. Rate r(0,0,0);
  143. char *saveptr = (char *)0;
  144. unsigned int fn = 0;
  145. for(char *f=Utils::stok(tmp,",",&saveptr);(f);f=Utils::stok((char *)0,",",&saveptr)) {
  146. switch(fn++) {
  147. case 0:
  148. r.preload = (uint32_t)Utils::hexStrToULong(f);
  149. break;
  150. case 1:
  151. r.maxBalance = (uint32_t)Utils::hexStrToULong(f);
  152. break;
  153. case 2:
  154. r.accrual = (uint32_t)Utils::hexStrToULong(f);
  155. break;
  156. }
  157. }
  158. return r;
  159. }
  160. };
  161. /**
  162. * A network configuration for a given node
  163. *
  164. * Configuration fields:
  165. *
  166. * nwid=<hex network ID> (required)
  167. * name=short name
  168. * desc=long(er) description
  169. * com=Serialized certificate of membership
  170. * mr=MulticastRates (serialized dictionary)
  171. * md=multicast propagation depth
  172. * mpb=multicast propagation prefix bits (2^mpb packets are sent by origin)
  173. * o=open network? (1 or 0, default false if missing)
  174. * et=ethertype whitelist (comma-delimited list of ethertypes in decimal)
  175. * v4s=IPv4 static assignments / netmasks (comma-delimited)
  176. * v6s=IPv6 static assignments / netmasks (comma-delimited)
  177. *
  178. * Notes:
  179. *
  180. * If zero appears in the 'et' list, the sense is inverted. It becomes an
  181. * ethertype blacklist instead of a whitelist and anything not blacklisted
  182. * is permitted.
  183. */
  184. class Config : private Dictionary
  185. {
  186. public:
  187. Config() {}
  188. Config(const char *s) : Dictionary(s) {}
  189. Config(const std::string &s) : Dictionary(s) {}
  190. inline std::string toString() const { return Dictionary::toString(); }
  191. /**
  192. * @return True if configuration is valid and contains required fields
  193. */
  194. inline operator bool() const throw() { return (find("nwid") != end()); }
  195. /**
  196. * @return Network ID
  197. * @throws std::invalid_argument Network ID field missing
  198. */
  199. inline uint64_t networkId() const
  200. throw(std::invalid_argument)
  201. {
  202. return Utils::hexStrToU64(get("nwid").c_str());
  203. }
  204. /**
  205. * Get this network's short name, or its ID in hex if unspecified
  206. *
  207. * @return Short name of this network (e.g. "earth")
  208. */
  209. inline std::string name() const
  210. {
  211. const_iterator n(find("name"));
  212. if (n == end())
  213. return get("nwid");
  214. return n->second;
  215. }
  216. /**
  217. * @return Long description of network or empty string if not present
  218. */
  219. inline std::string desc() const
  220. {
  221. return get("desc",std::string());
  222. }
  223. /**
  224. * @return Certificate of membership for this network, or empty cert if none
  225. */
  226. inline CertificateOfMembership certificateOfMembership() const
  227. {
  228. const_iterator cm(find("com"));
  229. if (cm == end())
  230. return CertificateOfMembership();
  231. else return CertificateOfMembership(cm->second);
  232. }
  233. /**
  234. * @return True if this network emulates IPv4 ARP for assigned addresses
  235. */
  236. inline bool emulateArp() const
  237. {
  238. const_iterator e(find("eARP"));
  239. if (e == end())
  240. return false;
  241. else return (e->second == "1");
  242. }
  243. /**
  244. * @return True if this network emulates IPv6 NDP for assigned addresses
  245. */
  246. inline bool emulateNdp() const
  247. {
  248. const_iterator e(find("eNDP"));
  249. if (e == end())
  250. return false;
  251. else return (e->second == "1");
  252. }
  253. /**
  254. * @return ARP cache TTL in seconds or 0 for no ARP caching
  255. */
  256. inline unsigned int arpCacheTtl() const
  257. {
  258. const_iterator ttl(find("cARP"));
  259. if (ttl == end())
  260. return 0;
  261. return Utils::hexStrToUInt(ttl->second.c_str());
  262. }
  263. /**
  264. * @return NDP cache TTL in seconds or 0 for no NDP caching
  265. */
  266. inline unsigned int ndpCacheTtl() const
  267. {
  268. const_iterator ttl(find("cNDP"));
  269. if (ttl == end())
  270. return 0;
  271. return Utils::hexStrToUInt(ttl->second.c_str());
  272. }
  273. /**
  274. * @return Multicast rates for this network
  275. */
  276. inline MulticastRates multicastRates() const
  277. {
  278. const_iterator mr(find("mr"));
  279. if (mr == end())
  280. return MulticastRates();
  281. else return MulticastRates(mr->second);
  282. }
  283. /**
  284. * @return Number of bits in propagation prefix for this network
  285. */
  286. inline unsigned int multicastPrefixBits() const
  287. {
  288. const_iterator mpb(find("mpb"));
  289. if (mpb == end())
  290. return ZT_DEFAULT_MULTICAST_PREFIX_BITS;
  291. unsigned int tmp = Utils::hexStrToUInt(mpb->second.c_str());
  292. if (tmp)
  293. return tmp;
  294. else return ZT_DEFAULT_MULTICAST_PREFIX_BITS;
  295. }
  296. /**
  297. * @return Maximum multicast propagation depth for this network
  298. */
  299. inline unsigned int multicastDepth() const
  300. {
  301. const_iterator md(find("md"));
  302. if (md == end())
  303. return ZT_DEFAULT_MULTICAST_DEPTH;
  304. unsigned int tmp = Utils::hexStrToUInt(md->second.c_str());
  305. if (tmp)
  306. return tmp;
  307. else return ZT_DEFAULT_MULTICAST_DEPTH;
  308. }
  309. /**
  310. * @return True if this is an open non-access-controlled network
  311. */
  312. inline bool isOpen() const
  313. {
  314. const_iterator o(find("o"));
  315. if (o == end())
  316. return false;
  317. else if (!o->second.length())
  318. return false;
  319. else return (o->second[0] == '1');
  320. }
  321. /**
  322. * @return Network ethertype whitelist
  323. */
  324. inline std::set<unsigned int> etherTypes() const
  325. {
  326. char tmp[16384];
  327. char *saveptr = (char *)0;
  328. std::set<unsigned int> et;
  329. if (!Utils::scopy(tmp,sizeof(tmp),get("et","").c_str()))
  330. return et; // sanity check, packet can't really be that big
  331. for(char *f=Utils::stok(tmp,",",&saveptr);(f);f=Utils::stok((char *)0,",",&saveptr)) {
  332. unsigned int t = Utils::hexStrToUInt(f);
  333. if (t)
  334. et.insert(t);
  335. }
  336. return et;
  337. }
  338. /**
  339. * @return All static addresses / netmasks, IPv4 or IPv6
  340. */
  341. inline std::set<InetAddress> staticAddresses() const
  342. {
  343. std::set<InetAddress> sa;
  344. std::vector<std::string> ips(Utils::split(get("v4s","").c_str(),",","",""));
  345. for(std::vector<std::string>::const_iterator i(ips.begin());i!=ips.end();++i)
  346. sa.insert(InetAddress(*i));
  347. ips = Utils::split(get("v6s","").c_str(),",","","");
  348. for(std::vector<std::string>::const_iterator i(ips.begin());i!=ips.end();++i)
  349. sa.insert(InetAddress(*i));
  350. return sa;
  351. }
  352. };
  353. /**
  354. * Status for networks
  355. */
  356. enum Status
  357. {
  358. NETWORK_WAITING_FOR_FIRST_AUTOCONF,
  359. NETWORK_OK,
  360. NETWORK_ACCESS_DENIED,
  361. NETWORK_NOT_FOUND
  362. };
  363. /**
  364. * @param s Status
  365. * @return String description
  366. */
  367. static const char *statusString(const Status s)
  368. throw();
  369. private:
  370. // Only NodeConfig can create, only SharedPtr can delete
  371. // Actual construction happens in newInstance()
  372. Network()
  373. throw() :
  374. _tap((EthernetTap *)0)
  375. {
  376. }
  377. ~Network();
  378. /**
  379. * Create a new Network instance and restore any saved state
  380. *
  381. * If there is no saved state, a dummy .conf is created on disk to remember
  382. * this network across restarts.
  383. *
  384. * @param renv Runtime environment
  385. * @param id Network ID
  386. * @return Reference counted pointer to new network
  387. * @throws std::runtime_error Unable to create tap device or other fatal error
  388. */
  389. static SharedPtr<Network> newInstance(const RuntimeEnvironment *renv,uint64_t id)
  390. throw(std::runtime_error);
  391. /**
  392. * Causes all persistent disk presence to be erased on delete
  393. */
  394. inline void destroyOnDelete()
  395. throw()
  396. {
  397. _destroyOnDelete = true;
  398. }
  399. public:
  400. /**
  401. * @return Network ID
  402. */
  403. inline uint64_t id() const throw() { return _id; }
  404. /**
  405. * @return Ethernet tap
  406. */
  407. inline EthernetTap &tap() throw() { return *_tap; }
  408. /**
  409. * @return Address of network's controlling node
  410. */
  411. inline Address controller() throw() { return Address(_id >> 24); }
  412. /**
  413. * @return Network ID in hexadecimal form
  414. */
  415. inline std::string idString()
  416. {
  417. char buf[64];
  418. Utils::snprintf(buf,sizeof(buf),"%.16llx",(unsigned long long)_id);
  419. return std::string(buf);
  420. }
  421. /**
  422. * @return True if network is open (no membership required)
  423. */
  424. inline bool isOpen() const
  425. throw()
  426. {
  427. Mutex::Lock _l(_lock);
  428. return _isOpen;
  429. }
  430. /**
  431. * @return True if this network emulates IPv4 ARP for assigned addresses
  432. */
  433. inline bool emulateArp() const
  434. throw()
  435. {
  436. Mutex::Lock _l(_lock);
  437. return _emulateArp;
  438. }
  439. /**
  440. * @return True if this network emulates IPv6 NDP for assigned addresses
  441. */
  442. inline bool emulateNdp() const
  443. throw()
  444. {
  445. Mutex::Lock _l(_lock);
  446. return _emulateNdp;
  447. }
  448. /**
  449. * Update multicast groups for this network's tap
  450. *
  451. * @return True if internal multicast group set has changed
  452. */
  453. inline bool updateMulticastGroups()
  454. {
  455. Mutex::Lock _l(_lock);
  456. return _tap->updateMulticastGroups(_multicastGroups);
  457. }
  458. /**
  459. * @return Latest set of multicast groups for this network's tap
  460. */
  461. inline std::set<MulticastGroup> multicastGroups() const
  462. {
  463. Mutex::Lock _l(_lock);
  464. return _multicastGroups;
  465. }
  466. /**
  467. * Set or update this network's configuration
  468. *
  469. * This is called by PacketDecoder when an update comes over the wire, or
  470. * internally when an old config is reloaded from disk.
  471. *
  472. * @param conf Configuration in key/value dictionary form
  473. * @param saveToDisk IF true (default), write config to disk
  474. */
  475. void setConfiguration(const Config &conf,bool saveToDisk = true);
  476. /**
  477. * Causes this network to request an updated configuration from its master node now
  478. */
  479. void requestConfiguration();
  480. /**
  481. * Add or update a membership certificate
  482. *
  483. * The certificate must already have been validated via signature checking.
  484. *
  485. * @param cert Certificate of membership
  486. */
  487. void addMembershipCertificate(const CertificateOfMembership &cert);
  488. /**
  489. * Push our membership certificate to a peer
  490. *
  491. * @param peer Destination peer address
  492. * @param force If true, push even if we've already done so within required time frame
  493. * @param now Current time
  494. */
  495. inline void pushMembershipCertificate(const Address &peer,bool force,uint64_t now)
  496. {
  497. Mutex::Lock _l(_lock);
  498. if (!_isOpen)
  499. _pushMembershipCertificate(peer,force,now);
  500. }
  501. /**
  502. * Push membership certificate to a packed zero-terminated array of addresses
  503. *
  504. * This pushes to all peers in peers[] (length must be a multiple of 5) until
  505. * len is reached or a null address is encountered.
  506. *
  507. * @param peers Packed array of 5-byte big-endian addresses
  508. * @param len Length of peers[] in total, MUST be a multiple of 5
  509. * @param force If true, push even if we've already done so within required time frame
  510. * @param now Current time
  511. */
  512. inline void pushMembershipCertificate(const void *peers,unsigned int len,bool force,uint64_t now)
  513. {
  514. Mutex::Lock _l(_lock);
  515. if (!_isOpen) {
  516. for(unsigned int i=0;i<len;i+=ZT_ADDRESS_LENGTH) {
  517. Address a((char *)peers + i,ZT_ADDRESS_LENGTH);
  518. if (a)
  519. _pushMembershipCertificate(a,force,now);
  520. else break;
  521. }
  522. }
  523. }
  524. /**
  525. * @param peer Peer address to check
  526. * @return True if peer is allowed to communicate on this network
  527. */
  528. bool isAllowed(const Address &peer) const;
  529. /**
  530. * Perform cleanup and possibly save state
  531. */
  532. void clean();
  533. /**
  534. * @return Time of last updated configuration or 0 if none
  535. */
  536. inline uint64_t lastConfigUpdate() const throw() { return _lastConfigUpdate; }
  537. /**
  538. * Force this network's status to a particular state based on config reply
  539. */
  540. inline void forceStatusTo(const Status s)
  541. throw()
  542. {
  543. Mutex::Lock _l(_lock);
  544. _status = s;
  545. }
  546. /**
  547. * @return Status of this network
  548. */
  549. inline Status status() const
  550. throw()
  551. {
  552. Mutex::Lock _l(_lock);
  553. return _status;
  554. }
  555. /**
  556. * @return True if this network is in "OK" status and can accept traffic from us
  557. */
  558. inline bool isUp() const
  559. throw()
  560. {
  561. Mutex::Lock _l(_lock);
  562. return ((_status == NETWORK_OK)&&(_ready));
  563. }
  564. /**
  565. * Determine whether frames of a given ethernet type are allowed on this network
  566. *
  567. * @param etherType Ethernet frame type
  568. * @return True if network permits this type
  569. */
  570. inline bool permitsEtherType(unsigned int etherType) const
  571. throw()
  572. {
  573. if (!etherType)
  574. return false;
  575. else if (etherType > 65535)
  576. return false;
  577. else if ((_etWhitelist[0] & 1)) // if type 0 is in the whitelist, sense is inverted from whitelist to blacklist
  578. return ((_etWhitelist[etherType / 8] & (unsigned char)(1 << (etherType & 7))) == 0);
  579. else return ((_etWhitelist[etherType / 8] & (unsigned char)(1 << (etherType & 7))) != 0);
  580. }
  581. /**
  582. * Update multicast balance for an address and multicast group, return whether packet is allowed
  583. *
  584. * @param a Address that wants to send/relay packet
  585. * @param mg Multicast group
  586. * @param bytes Size of packet
  587. * @return True if packet is within budget
  588. */
  589. inline bool updateAndCheckMulticastBalance(const Address &a,const MulticastGroup &mg,unsigned int bytes)
  590. {
  591. Mutex::Lock _l(_lock);
  592. std::pair<Address,MulticastGroup> k(a,mg);
  593. std::map< std::pair<Address,MulticastGroup>,BandwidthAccount >::iterator bal(_multicastRateAccounts.find(k));
  594. if (bal == _multicastRateAccounts.end()) {
  595. MulticastRates::Rate r(_mcRates.get(mg));
  596. bal = _multicastRateAccounts.insert(std::pair< std::pair<Address,MulticastGroup>,BandwidthAccount >(k,BandwidthAccount(r.preload,r.maxBalance,r.accrual))).first;
  597. }
  598. return bal->second.deduct(bytes);
  599. }
  600. /**
  601. * @param fromPeer Peer attempting to bridge other Ethernet peers onto network
  602. * @return True if this network allows bridging
  603. */
  604. inline bool permitsBridging(const Address &fromPeer) const
  605. throw()
  606. {
  607. return false; // TODO: bridging not implemented yet
  608. }
  609. /**
  610. * @return Bits in multicast restriciton prefix
  611. */
  612. inline unsigned int multicastPrefixBits() const throw() { return _multicastPrefixBits; }
  613. /**
  614. * @return Max depth (TTL) for a multicast frame
  615. */
  616. inline unsigned int multicastDepth() const throw() { return _multicastDepth; }
  617. private:
  618. static void _CBhandleTapData(void *arg,const MAC &from,const MAC &to,unsigned int etherType,const Buffer<4096> &data);
  619. void _pushMembershipCertificate(const Address &peer,bool force,uint64_t now);
  620. void _restoreState();
  621. void _dumpMulticastCerts();
  622. const RuntimeEnvironment *_r;
  623. // Multicast bandwidth accounting for peers on this network
  624. std::map< std::pair<Address,MulticastGroup>,BandwidthAccount > _multicastRateAccounts;
  625. // Tap and tap multicast memberships for this node on this network
  626. EthernetTap *_tap;
  627. std::set<MulticastGroup> _multicastGroups;
  628. // Membership certificates supplied by other peers on this network
  629. std::map<Address,CertificateOfMembership> _membershipCertificates;
  630. // The last time we sent a membership certificate to a given peer
  631. std::map<Address,uint64_t> _lastPushedMembershipCertificate;
  632. // Configuration from network master node -- and some memoized fields from
  633. // the most recent _configuration we have.
  634. Config _configuration;
  635. CertificateOfMembership _myCertificate;
  636. MulticastRates _mcRates;
  637. std::set<InetAddress> _staticAddresses;
  638. bool _isOpen;
  639. bool _emulateArp;
  640. bool _emulateNdp;
  641. unsigned int _arpCacheTtl;
  642. unsigned int _ndpCacheTtl;
  643. unsigned int _multicastPrefixBits;
  644. unsigned int _multicastDepth;
  645. // Network status
  646. Status _status;
  647. // Ethertype whitelist bit field, set from config, for really fast lookup
  648. unsigned char _etWhitelist[65536 / 8];
  649. // Network ID -- master node is most significant 40 bits
  650. uint64_t _id;
  651. volatile uint64_t _lastConfigUpdate;
  652. volatile bool _destroyOnDelete;
  653. volatile bool _ready;
  654. Mutex _lock;
  655. AtomicCounter __refCount;
  656. };
  657. } // naemspace ZeroTier
  658. #endif