RainflyClient.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef RainflyClient_H
  16. #define RainflyClient_H
  17. #include "benc/Dict.h"
  18. #include "benc/String.h"
  19. #include "memory/Allocator.h"
  20. #include "interface/addressable/AddrInterface.h"
  21. #include "util/log/Log.h"
  22. #include "util/events/EventBase.h"
  23. #include "crypto/random/Random.h"
  24. #include "util/Linker.h"
  25. Linker_require("interface/RainflyClient.c")
  26. #define RainflyClient_DEFAULT_MIN_SIGNATURES 2
  27. #define RainflyClient_DEFAULT_MAX_TRIES 3
  28. struct RainflyClient
  29. {
  30. int minSignatures;
  31. int maxTries;
  32. };
  33. enum RainflyClient_ResponseCode {
  34. RainflyClient_ResponseCode_NO_ERROR = 0,
  35. RainflyClient_ResponseCode_FORMAT_ERROR = 1,
  36. RainflyClient_ResponseCode_SERVER_ERROR = 2,
  37. RainflyClient_ResponseCode_NXDOMAIN = 3,
  38. RainflyClient_ResponseCode_NOT_IMPLEMENTED = 4,
  39. RainflyClient_ResponseCode_REFUSED = 5,
  40. RainflyClient_ResponseCode_XYDOMAIN = 6,
  41. RainflyClient_ResponseCode_YXRRSET = 7,
  42. RainflyClient_ResponseCode_NXRRSET = 8,
  43. RainflyClient_ResponseCode_NOT_AUTH_FOR_ZONE = 9,
  44. };
  45. struct RainflyClient_Lookup
  46. {
  47. void (* onReply)(struct RainflyClient_Lookup* promise,
  48. Dict* value,
  49. enum RainflyClient_ResponseCode code);
  50. void* userData;
  51. String* domain;
  52. struct Allocator* alloc;
  53. };
  54. struct RainflyClient_Lookup* RainflyClient_lookup(struct RainflyClient* client, String* domain);
  55. #define RainflyClient_addKey_TOO_MANY_KEYS -1
  56. int RainflyClient_addKey(struct RainflyClient* client, uint8_t key[32]);
  57. #define RainflyClient_addServer_WRONG_ADDRESS_TYPE -1
  58. int RainflyClient_addServer(struct RainflyClient* client, struct Sockaddr* addr);
  59. struct RainflyClient* RainflyClient_new(struct AddrInterface* iface,
  60. struct EventBase* base,
  61. struct Random* rand,
  62. struct Log* logger);
  63. #endif