gnunet-service-gns_resolver.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009-2020 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file gns/gnunet-service-gns_resolver.h
  18. * @brief GNUnet GNS service
  19. * @author Martin Schanzenbach
  20. */
  21. #ifndef GNS_RESOLVER_H
  22. #define GNS_RESOLVER_H
  23. #include "gns.h"
  24. #include "gnunet_dht_service.h"
  25. #include "gnunet_gns_service.h"
  26. #include "gnunet_namecache_service.h"
  27. /**
  28. * Initialize the resolver subsystem.
  29. * MUST be called before #GNS_resolver_lookup.
  30. *
  31. * @param nc the namecache handle
  32. * @param dht handle to the dht
  33. * @param c configuration handle
  34. * @param max_bg_queries maximum amount of background queries
  35. */
  36. void
  37. GNS_resolver_init (struct GNUNET_NAMECACHE_Handle *nc,
  38. struct GNUNET_DHT_Handle *dht,
  39. const struct GNUNET_CONFIGURATION_Handle *c,
  40. unsigned long long max_bg_queries);
  41. /**
  42. * Cleanup resolver: Terminate pending lookups
  43. */
  44. void
  45. GNS_resolver_done (void);
  46. /**
  47. * Handle for an active request.
  48. */
  49. struct GNS_ResolverHandle;
  50. /**
  51. * Function called with results for a GNS resolution.
  52. *
  53. * @param cls closure
  54. * @param rd_count number of records in @a rd
  55. * @param rd records returned for the lookup
  56. */
  57. typedef void
  58. (*GNS_ResultProcessor)(void *cls,
  59. uint32_t rd_count,
  60. const struct GNUNET_GNSRECORD_Data *rd);
  61. /**
  62. * Lookup of a record in a specific zone
  63. * calls RecordLookupProcessor on result or timeout
  64. *
  65. * @param zone the zone to perform the lookup in
  66. * @param record_type the record type to look up
  67. * @param name the name to look up
  68. * @param options options set to control local lookup
  69. * @param recursion_depth_limit how many zones to traverse
  70. * at most
  71. * @param proc the processor to call
  72. * @param proc_cls the closure to pass to @a proc
  73. * @return handle to cancel operation
  74. */
  75. struct GNS_ResolverHandle *
  76. GNS_resolver_lookup (const struct GNUNET_IDENTITY_PublicKey *zone,
  77. uint32_t record_type,
  78. const char *name,
  79. enum GNUNET_GNS_LocalOptions options,
  80. uint16_t recursion_depth_limit,
  81. GNS_ResultProcessor proc,
  82. void *proc_cls);
  83. /**
  84. * Cancel active resolution (i.e. client disconnected).
  85. *
  86. * @param rh resolution to abort
  87. */
  88. void
  89. GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh);
  90. #endif