2 This file is part of GNUnet
3 (C) 2012, 2013 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 3, 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_namecache_service.h
23 * @brief API that can be used to store naming information on a GNUnet node;
24 * Naming information can either be records for which this peer/user
25 * is authoritative, or blocks which are cached, encrypted naming
26 * data from other peers.
27 * @author Christian Grothoff
29 #ifndef GNUNET_NAMECACHE_SERVICE_H
30 #define GNUNET_NAMECACHE_SERVICE_H
32 #include "gnunet_util_lib.h"
33 #include "gnunet_block_lib.h"
34 #include "gnunet_namestore_service.h"
39 #if 0 /* keep Emacsens' auto-indent happy */
48 struct GNUNET_NAMECACHE_QueueEntry;
51 * Handle to the namecache service.
53 struct GNUNET_NAMECACHE_Handle;
56 * Maximum size of a value that can be stored in the namecache.
58 #define GNUNET_NAMECACHE_MAX_VALUE_SIZE (63 * 1024)
62 * Connect to the namecache service.
64 * @param cfg configuration to use
65 * @return handle to use to access the service
67 struct GNUNET_NAMECACHE_Handle *
68 GNUNET_NAMECACHE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
72 * Disconnect from the namecache service (and free associated
73 * resources). Must not be called from within operation callbacks of
76 * @param h handle to the namecache
79 GNUNET_NAMECACHE_disconnect (struct GNUNET_NAMECACHE_Handle *h);
83 * Continuation called to notify client about result of the
87 * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate)
88 * #GNUNET_NO if content was already there or not found
89 * #GNUNET_YES (or other positive value) on success
90 * @param emsg NULL on success, otherwise an error message
92 typedef void (*GNUNET_NAMECACHE_ContinuationWithStatus) (void *cls,
99 * Store an item in the namecache. If the item is already present,
100 * it is replaced with the new record.
102 * @param h handle to the namecache
103 * @param block block to store
104 * @param cont continuation to call when done
105 * @param cont_cls closure for @a cont
106 * @return handle to abort the request
108 struct GNUNET_NAMECACHE_QueueEntry *
109 GNUNET_NAMECACHE_block_cache (struct GNUNET_NAMECACHE_Handle *h,
110 const struct GNUNET_GNSRECORD_Block *block,
111 GNUNET_NAMECACHE_ContinuationWithStatus cont,
116 * Process a record that was stored in the namecache.
119 * @param block block that was stored in the namecache
121 typedef void (*GNUNET_NAMECACHE_BlockProcessor) (void *cls,
122 const struct GNUNET_GNSRECORD_Block *block);
126 * Get a result for a particular key from the namecache. The processor
127 * will only be called once.
129 * @param h handle to the namecache
130 * @param derived_hash hash of zone key combined with name to lookup
131 * then at the end once with NULL
132 * @param proc function to call on the matching block, or with
133 * NULL if there is no matching block
134 * @param proc_cls closure for @a proc
135 * @return a handle that can be used to cancel
137 struct GNUNET_NAMECACHE_QueueEntry *
138 GNUNET_NAMECACHE_lookup_block (struct GNUNET_NAMECACHE_Handle *h,
139 const struct GNUNET_HashCode *derived_hash,
140 GNUNET_NAMECACHE_BlockProcessor proc, void *proc_cls);
144 * Cancel a namecache operation. The final callback from the
145 * operation must not have been done yet. Must be called on any
146 * namecache operation that has not yet completed prior to calling
147 * #GNUNET_NAMECACHE_disconnect.
149 * @param qe operation to cancel
152 GNUNET_NAMECACHE_cancel (struct GNUNET_NAMECACHE_QueueEntry *qe);
155 #if 0 /* keep Emacsens' auto-indent happy */
162 /* end of gnunet_namecache_service.h */