gnunet_namestore_plugin.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2012, 2013 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. 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. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. /**
  18. * @author Christian Grothoff
  19. *
  20. * @file
  21. * Plugin API for the namestore database backend
  22. *
  23. * @defgroup namestore-plugin Name Store service plugin API
  24. * Plugin API for the namestore database backend
  25. * @{
  26. */
  27. #ifndef GNUNET_NAMESTORE_PLUGIN_H
  28. #define GNUNET_NAMESTORE_PLUGIN_H
  29. #include "gnunet_util_lib.h"
  30. #include "gnunet_namestore_service.h"
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #if 0 /* keep Emacsens' auto-indent happy */
  35. }
  36. #endif
  37. #endif
  38. /**
  39. * Function called by for each matching record.
  40. *
  41. * @param cls closure
  42. * @param zone_key private key of the zone
  43. * @param label name that is being mapped (at most 255 characters long)
  44. * @param rd_count number of entries in @a rd array
  45. * @param rd array of records with data to store
  46. */
  47. typedef void (*GNUNET_NAMESTORE_RecordIterator) (void *cls,
  48. const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key,
  49. const char *label,
  50. unsigned int rd_count,
  51. const struct GNUNET_GNSRECORD_Data *rd);
  52. /**
  53. * @brief struct returned by the initialization function of the plugin
  54. */
  55. struct GNUNET_NAMESTORE_PluginFunctions
  56. {
  57. /**
  58. * Closure to pass to all plugin functions.
  59. */
  60. void *cls;
  61. /**
  62. * Store a record in the datastore for which we are the authority.
  63. * Removes any existing record in the same zone with the same name.
  64. *
  65. * @param cls closure (internal context for the plugin)
  66. * @param zone private key of the zone
  67. * @param label name of the record in the zone
  68. * @param rd_count number of entries in @a rd array, 0 to delete all records
  69. * @param rd array of records with data to store
  70. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  71. */
  72. int (*store_records) (void *cls,
  73. const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
  74. const char *label,
  75. unsigned int rd_count,
  76. const struct GNUNET_GNSRECORD_Data *rd);
  77. /**
  78. * Lookup records in the datastore for which we are the authority.
  79. *
  80. * @param cls closure (internal context for the plugin)
  81. * @param zone private key of the zone
  82. * @param label name of the record in the zone
  83. * @param iter function to call with the result
  84. * @param iter_cls closure for @a iter
  85. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  86. */
  87. int (*lookup_records) (void *cls,
  88. const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
  89. const char *label,
  90. GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
  91. /**
  92. * Iterate over the results for a particular zone in the
  93. * datastore. Will return at most one result to the iterator.
  94. *
  95. * @param cls closure (internal context for the plugin)
  96. * @param zone private key of the zone, NULL for all zones
  97. * @param offset offset in the list of all matching records
  98. * @param iter function to call with the result
  99. * @param iter_cls closure for @a iter
  100. * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
  101. */
  102. int (*iterate_records) (void *cls,
  103. const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
  104. uint64_t offset,
  105. GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
  106. /**
  107. * Look for an existing PKEY delegation record for a given public key.
  108. * Returns at most one result to the iterator.
  109. *
  110. * @param cls closure (internal context for the plugin)
  111. * @param zone private key of the zone to look up in, never NULL
  112. * @param value_zone public key of the target zone (value), never NULL
  113. * @param iter function to call with the result
  114. * @param iter_cls closure for @a iter
  115. * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
  116. */
  117. int (*zone_to_name) (void *cls,
  118. const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
  119. const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone,
  120. GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
  121. };
  122. #if 0 /* keep Emacsens' auto-indent happy */
  123. {
  124. #endif
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128. #endif
  129. /** @} */ /* end of group */