SqliteNetworkConfigMaster.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * ZeroTier One - Network Virtualization Everywhere
  3. * Copyright (C) 2011-2015 ZeroTier, Inc.
  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_SQLITENETWORKCONFIGMASTER_HPP
  28. #define ZT_SQLITENETWORKCONFIGMASTER_HPP
  29. #include <stdint.h>
  30. #include <sqlite3.h>
  31. #include <string>
  32. #include <map>
  33. #include <vector>
  34. #include "../node/Constants.hpp"
  35. #include "../node/NetworkConfigMaster.hpp"
  36. #include "../node/Mutex.hpp"
  37. namespace ZeroTier {
  38. class SqliteNetworkConfigMaster : public NetworkConfigMaster
  39. {
  40. public:
  41. SqliteNetworkConfigMaster(const Identity &signingId,const char *dbPath);
  42. virtual ~SqliteNetworkConfigMaster();
  43. virtual NetworkConfigMaster::ResultCode doNetworkConfigRequest(
  44. const InetAddress &fromAddr,
  45. uint64_t packetId,
  46. const Identity &identity,
  47. uint64_t nwid,
  48. const Dictionary &metaData,
  49. uint64_t haveRevision,
  50. Dictionary &netconf);
  51. private:
  52. Identity _signingId;
  53. std::string _dbPath;
  54. sqlite3 *_db;
  55. sqlite3_stmt *_sGetNetworkById;
  56. sqlite3_stmt *_sGetMemberByNetworkAndNodeId;
  57. sqlite3_stmt *_sCreateMember;
  58. sqlite3_stmt *_sGetNodeIdentity;
  59. sqlite3_stmt *_sCreateNode;
  60. sqlite3_stmt *_sUpdateNode;
  61. sqlite3_stmt *_sUpdateNode2;
  62. sqlite3_stmt *_sUpdateMemberClientReportedRevision;
  63. sqlite3_stmt *_sGetEtherTypesFromRuleTable;
  64. sqlite3_stmt *_sGetMulticastRates;
  65. sqlite3_stmt *_sGetActiveBridges;
  66. sqlite3_stmt *_sGetIpAssignmentsForNode;
  67. sqlite3_stmt *_sGetIpAssignmentPools;
  68. sqlite3_stmt *_sCheckIfIpIsAllocated;
  69. sqlite3_stmt *_sAllocateIp;
  70. sqlite3_stmt *_sCacheNetconf;
  71. Mutex _lock;
  72. };
  73. } // namespace ZeroTier
  74. #endif