NetworkConfigMaster.hpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_NETWORKCONFIGMASTER_HPP
  28. #define ZT_NETWORKCONFIGMASTER_HPP
  29. #include <stdint.h>
  30. #include "Constants.hpp"
  31. #include "InetAddress.hpp"
  32. #include "Dictionary.hpp"
  33. #include "Address.hpp"
  34. #include "Identity.hpp"
  35. namespace ZeroTier {
  36. class RuntimeEnvironment;
  37. /**
  38. * Interface for network configuration (netconf) master implementations
  39. */
  40. class NetworkConfigMaster
  41. {
  42. public:
  43. /**
  44. * Return value of doNetworkConfigRequest
  45. */
  46. enum ResultCode
  47. {
  48. NETCONF_QUERY_OK = 0,
  49. NETCONF_QUERY_OK_BUT_NOT_NEWER = 1,
  50. NETCONF_QUERY_OBJECT_NOT_FOUND = 2,
  51. NETCONF_QUERY_ACCESS_DENIED = 3,
  52. NETCONF_QUERY_INTERNAL_SERVER_ERROR = 4
  53. };
  54. NetworkConfigMaster() {}
  55. virtual ~NetworkConfigMaster() {}
  56. /**
  57. * Handle a network config request, sending replies if necessary
  58. *
  59. * This call is permitted to block, and may be called concurrently from more
  60. * than one thread. Implementations must use locks if needed.
  61. *
  62. * On internal server errors, the 'error' field in result can be filled in
  63. * to indicate the error.
  64. *
  65. * @param fromAddr Originating IP address
  66. * @param packetId 64-bit packet ID
  67. * @param member Originating peer ZeroTier identity
  68. * @param nwid 64-bit network ID
  69. * @param metaData Meta-data bundled with request (empty if none)
  70. * @param haveRevision Network revision ID sent by requesting peer or 0 if none
  71. * @param result Dictionary to receive resulting signed netconf on success
  72. * @return Returns NETCONF_QUERY_OK if result dictionary is valid, or an error code on error
  73. */
  74. virtual NetworkConfigMaster::ResultCode doNetworkConfigRequest(
  75. const InetAddress &fromAddr,
  76. uint64_t packetId,
  77. const Identity &identity,
  78. uint64_t nwid,
  79. const Dictionary &metaData,
  80. uint64_t haveRevision,
  81. Dictionary &result) = 0;
  82. };
  83. } // namespace ZeroTier
  84. #endif