2 This file is part of GNUnet
3 (C) 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_namestore_plugin.h
23 * @brief plugin API for the namestore database backend
24 * @author Christian Grothoff
26 #ifndef GNUNET_NAMESTORE_PLUGIN_H
27 #define GNUNET_NAMESTORE_PLUGIN_H
29 #include "gnunet_common.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_namestore_service.h"
36 #if 0 /* keep Emacsens' auto-indent happy */
43 * Function called by for each matching record.
46 * @param zone_key public key of the zone
47 * @param expire when does the corresponding block in the DHT expire (until
48 * when should we never do a DHT lookup for the same name again)?
49 * @param name name that is being mapped (at most 255 characters long)
50 * @param rd_count number of entries in 'rd' array
51 * @param rd array of records with data to store
52 * @param signature signature of the record block, NULL if signature is unavailable (i.e.
53 * because the user queried for a particular record type only)
55 typedef void (*GNUNET_NAMESTORE_RecordIterator) (void *cls,
56 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
57 struct GNUNET_TIME_Absolute expire,
60 const struct GNUNET_NAMESTORE_RecordData *rd,
61 const struct GNUNET_CRYPTO_RsaSignature *signature);
65 * @brief struct returned by the initialization function of the plugin
67 struct GNUNET_NAMESTORE_PluginFunctions
71 * Closure to pass to all plugin functions.
76 * Store a record in the datastore. Removes any existing record in the
77 * same zone with the same name.
79 * @param cls closure (internal context for the plugin)
80 * @param zone_key public key of the zone
81 * @param expire when does the corresponding block in the DHT expire (until
82 * when should we never do a DHT lookup for the same name again)?
83 * @param name name that is being mapped (at most 255 characters long)
84 * @param rd_count number of entries in 'rd' array
85 * @param rd array of records with data to store
86 * @param signature signature of the record block, NULL if signature is unavailable (i.e.
87 * because the user queried for a particular record type only)
88 * @return GNUNET_OK on success, else GNUNET_SYSERR
90 int (*put_records) (void *cls,
91 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
92 struct GNUNET_TIME_Absolute expire,
95 const struct GNUNET_NAMESTORE_RecordData *rd,
96 const struct GNUNET_CRYPTO_RsaSignature *signature);
100 * Removes any existing record in the given zone with the same name.
102 * @param cls closure (internal context for the plugin)
103 * @param zone hash of the public key of the zone
104 * @param name name to remove (at most 255 characters long)
105 * @return GNUNET_OK on success
107 int (*remove_records) (void *cls,
108 const GNUNET_HashCode *zone,
113 * Iterate over the results for a particular key and zone in the
114 * datastore. Will return at most one result to the iterator.
116 * @param cls closure (internal context for the plugin)
117 * @param zone hash of public key of the zone, NULL to iterate over all zones
118 * @param name name as '\0' terminated string, NULL to iterate over all records of the zone
119 * @param offset offset in the list of all matching records
120 * @param iter function to call with the result
121 * @param iter_cls closure for iter
122 * @return GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error
124 int (*iterate_records) (void *cls,
125 const GNUNET_HashCode *zone,
128 GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
132 * Look for an existing PKEY delegation record for a given public key.
133 * Returns at most one result to the iterator.
135 * @param cls closure (internal context for the plugin)
136 * @param zone hash of public key of the zone to look up in, never NULL
137 * @param value_zone hash of the public key of the target zone (value), never NULL
138 * @param iter function to call with the result
139 * @param iter_cls closure for iter
140 * @return GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error
142 int (*zone_to_name) (void *cls,
143 const GNUNET_HashCode *zone,
144 const GNUNET_HashCode *value_zone,
145 GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
149 * Delete an entire zone (all records). Not used in normal operation.
151 * @param cls closure (internal context for the plugin)
152 * @param zone zone to delete
154 void (*delete_zone) (void *cls,
155 const GNUNET_HashCode *zone);
161 #if 0 /* keep Emacsens' auto-indent happy */
168 /* end of gnunet_namestore_plugin.h */