NetworkController.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * ZeroTier One - Network Virtualization Everywhere
  3. * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/
  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. #ifndef ZT_NETWORKCONFIGMASTER_HPP
  19. #define ZT_NETWORKCONFIGMASTER_HPP
  20. #include <stdint.h>
  21. #include "Constants.hpp"
  22. #include "InetAddress.hpp"
  23. #include "Dictionary.hpp"
  24. #include "Address.hpp"
  25. #include "Identity.hpp"
  26. namespace ZeroTier {
  27. class RuntimeEnvironment;
  28. /**
  29. * Interface for network controller implementations
  30. */
  31. class NetworkController
  32. {
  33. public:
  34. /**
  35. * Return value of doNetworkConfigRequest
  36. */
  37. enum ResultCode
  38. {
  39. NETCONF_QUERY_OK = 0,
  40. NETCONF_QUERY_OBJECT_NOT_FOUND = 1,
  41. NETCONF_QUERY_ACCESS_DENIED = 2,
  42. NETCONF_QUERY_INTERNAL_SERVER_ERROR = 3,
  43. NETCONF_QUERY_IGNORE = 4
  44. };
  45. NetworkController() {}
  46. virtual ~NetworkController() {}
  47. /**
  48. * Handle a network config request, sending replies if necessary
  49. *
  50. * This call is permitted to block, and may be called concurrently from more
  51. * than one thread. Implementations must use locks if needed.
  52. *
  53. * On internal server errors, the 'error' field in result can be filled in
  54. * to indicate the error.
  55. *
  56. * @param fromAddr Originating wire address or null address if packet is not direct (or from self)
  57. * @param signingId Identity that should be used to sign results -- must include private key
  58. * @param identity Originating peer ZeroTier identity
  59. * @param nwid 64-bit network ID
  60. * @param metaData Meta-data bundled with request (empty if none)
  61. * @param result Dictionary to receive resulting signed netconf on success
  62. * @return Returns NETCONF_QUERY_OK if result dictionary is valid, or an error code on error
  63. */
  64. virtual NetworkController::ResultCode doNetworkConfigRequest(
  65. const InetAddress &fromAddr,
  66. const Identity &signingId,
  67. const Identity &identity,
  68. uint64_t nwid,
  69. const Dictionary &metaData,
  70. Dictionary &result) = 0;
  71. };
  72. } // namespace ZeroTier
  73. #endif