2 This file is part of GNUnet
3 (C) 2004, 2005, 2006, 2008, 2009 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_dht_service.h
23 * @brief API to the DHT service
24 * @author Christian Grothoff
27 #ifndef GNUNET_DHT_SERVICE_H
28 #define GNUNET_DHT_SERVICE_H
30 #include "gnunet_util_lib.h"
35 #if 0 /* keep Emacsens' auto-indent happy */
42 * Connection to the DHT service.
44 struct GNUNET_DHT_Handle;
48 * Initialize the connection with the DHT service.
50 * @param cfg configuration to use
51 * @param sched scheduler to use
52 * @return NULL on error
54 struct GNUNET_DHT_Handle *
55 GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
56 struct GNUNET_SCHEDULER_Handle *sched);
60 * Shutdown connection with the DHT service.
62 * @param h connection to shut down
65 GNUNET_DHT_connect (struct GNUNET_DHT_Handle *h);
69 * Handle to control a GET operation.
71 struct GNUNET_DHT_GetHandle;
75 * Iterator called on each result obtained for a GET
79 * @param exp when will this value expire
80 * @param key key of the result
81 * @param type type of the result
82 * @param size number of bytes in data
83 * @param data pointer to the result data
85 typedef void (*GNUNET_DHT_Iterator)(void *cls,
86 struct GNUNET_TIME_Absolute exp,
87 const GNUNET_HashCode * key,
94 * Perform an asynchronous GET operation on the DHT identified.
96 * @param h handle to the DHT service
97 * @param type expected type of the response object
98 * @param key the key to look up
99 * @param iter function to call on each result
100 * @param iter_cls closure for iter
101 * @return handle to stop the async get
103 struct GNUNET_DHT_GetHandle *
104 GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h,
106 const GNUNET_HashCode * key,
107 GNUNET_DHT_Iterator iter,
112 * Stop async DHT-get. Frees associated resources.
114 * @param record GET operation to stop.
117 GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *record);
121 * Perform a PUT operation on the DHT identified by 'table' storing
122 * a binding of 'key' to 'value'. The peer does not have to be part
123 * of the table (if so, we will attempt to locate a peer that is!)
125 * @param h handle to DHT service
126 * @param key the key to store under
127 * @param type type of the value
128 * @param size number of bytes in data; must be less than 64k
129 * @param data the data to store
130 * @param exp desired expiration time for the value
131 * @param cont continuation to call when done;
132 * reason will be TIMEOUT on error,
133 * reason will be PREREQ_DONE on success
134 * @param cont_cls closure for cont
137 int GNUNET_DHT_put (struct GNUNET_DHT_Handle *h,
138 const GNUNET_HashCode * key,
142 struct GNUNET_TIME_Relative exp,
143 GNUNET_SCHEDULER_Task cont,
147 #if 0 /* keep Emacsens' auto-indent happy */
156 /* gnunet_dht_service.h */