NetworkConfigMaster.hpp 2.8 KB

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