aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_dht_service.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-27 20:54:22 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-27 20:54:22 +0000
commit0faa3eaa142563dc765f21e71dfe6960bb631036 (patch)
tree0998499a3e7c49400960512b40679323b83baa11 /src/include/gnunet_dht_service.h
parent2c1f4adf15a0c5052f1835ceba460aba6acb23e4 (diff)
downloadgnunet-0faa3eaa142563dc765f21e71dfe6960bb631036.tar.gz
gnunet-0faa3eaa142563dc765f21e71dfe6960bb631036.zip
move
Diffstat (limited to 'src/include/gnunet_dht_service.h')
-rw-r--r--src/include/gnunet_dht_service.h220
1 files changed, 220 insertions, 0 deletions
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h
new file mode 100644
index 000000000..904357c92
--- /dev/null
+++ b/src/include/gnunet_dht_service.h
@@ -0,0 +1,220 @@
1/*
2 This file is part of GNUnet
3 (C) 2004, 2005, 2006, 2008, 2009, 2011 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19 */
20
21/**
22 * @file include/gnunet_dht_service.h
23 * @brief API to the DHT service
24 * @author Christian Grothoff
25 */
26
27#ifndef GNUNET_DHT_SERVICE_H
28#define GNUNET_DHT_SERVICE_H
29
30#include "gnunet_util_lib.h"
31#include "gnunet_block_lib.h"
32#include "gnunet_hello_lib.h"
33
34#ifdef __cplusplus
35extern "C"
36{
37#if 0 /* keep Emacsens' auto-indent happy */
38}
39#endif
40#endif
41
42
43/**
44 * Connection to the DHT service.
45 */
46struct GNUNET_DHT_Handle;
47
48/**
49 * Handle to control a get operation.
50 */
51struct GNUNET_DHT_GetHandle;
52
53/**
54 * Handle to control a find peer operation.
55 */
56struct GNUNET_DHT_FindPeerHandle;
57
58
59/**
60 * Options for routing.
61 */
62enum GNUNET_DHT_RouteOption
63{
64 /**
65 * Default. Do nothing special.
66 */
67 GNUNET_DHT_RO_NONE = 0,
68
69 /**
70 * Each peer along the way should look at 'enc' (otherwise
71 * only the k-peers closest to the key should look at it).
72 */
73 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1,
74
75 /**
76 * We should keep track of the route that the message
77 * took in the P2P network.
78 */
79 GNUNET_DHT_RO_RECORD_ROUTE = 2,
80
81 /**
82 * This is a 'FIND-PEER' request, so approximate results are fine.
83 */
84 GNUNET_DHT_RO_FIND_PEER = 4,
85
86 /**
87 * Possible message option for query key randomization.
88 */
89 GNUNET_DHT_RO_BART = 8
90};
91
92
93/**
94 * Initialize the connection with the DHT service.
95 *
96 * @param cfg configuration to use
97 * @param ht_len size of the internal hash table to use for
98 * processing multiple GET/FIND requests in parallel
99 * @return NULL on error
100 */
101struct GNUNET_DHT_Handle *
102GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
103 unsigned int ht_len);
104
105
106/**
107 * Shutdown connection with the DHT service.
108 *
109 * @param handle connection to shut down
110 */
111void
112GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle);
113
114
115/* *************** Standard API: get and put ******************* */
116
117/**
118 * Perform a PUT operation storing data in the DHT.
119 *
120 * @param handle handle to DHT service
121 * @param key the key to store under
122 * @param desired_replication_level estimate of how many
123 * nearest peers this request should reach
124 * @param options routing options for this message
125 * @param type type of the value
126 * @param size number of bytes in data; must be less than 64k
127 * @param data the data to store
128 * @param exp desired expiration time for the value
129 * @param timeout how long to wait for transmission of this request
130 * @param cont continuation to call when done (transmitting request to service)
131 * @param cont_cls closure for cont
132 */
133void
134GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key,
135 uint32_t desired_replication_level,
136 enum GNUNET_DHT_RouteOption options,
137 enum GNUNET_BLOCK_Type type, size_t size, const char *data,
138 struct GNUNET_TIME_Absolute exp,
139 struct GNUNET_TIME_Relative timeout, GNUNET_SCHEDULER_Task cont,
140 void *cont_cls);
141
142
143/**
144 * Iterator called on each result obtained for a DHT
145 * operation that expects a reply
146 *
147 * @param cls closure
148 * @param exp when will this value expire
149 * @param key key of the result
150 * @param get_path peers on reply path (or NULL if not recorded)
151 * @param get_path_length number of entries in get_path
152 * @param put_path peers on the PUT path (or NULL if not recorded)
153 * @param put_path_length number of entries in get_path
154 * @param type type of the result
155 * @param size number of bytes in data
156 * @param data pointer to the result data
157 */
158typedef void (*GNUNET_DHT_GetIterator) (void *cls,
159 struct GNUNET_TIME_Absolute exp,
160 const GNUNET_HashCode * key,
161 const struct GNUNET_PeerIdentity *get_path,
162 unsigned int get_path_length,
163 const struct GNUNET_PeerIdentity *put_path,
164 unsigned int put_path_length,
165 enum GNUNET_BLOCK_Type type,
166 size_t size, const void *data);
167
168
169
170/**
171 * Perform an asynchronous GET operation on the DHT identified. See
172 * also "GNUNET_BLOCK_evaluate".
173 *
174 * @param handle handle to the DHT service
175 * @param timeout how long to wait for transmission of this request to the service
176 * @param type expected type of the response object
177 * @param key the key to look up
178 * @param desired_replication_level estimate of how many
179 nearest peers this request should reach
180 * @param options routing options for this message
181 * @param xquery extended query data (can be NULL, depending on type)
182 * @param xquery_size number of bytes in xquery
183 * @param iter function to call on each result
184 * @param iter_cls closure for iter
185 *
186 * @return handle to stop the async get
187 */
188struct GNUNET_DHT_GetHandle *
189GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
190 struct GNUNET_TIME_Relative timeout,
191 enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * key,
192 uint32_t desired_replication_level,
193 enum GNUNET_DHT_RouteOption options,
194 const void *xquery,
195 size_t xquery_size, GNUNET_DHT_GetIterator iter,
196 void *iter_cls);
197
198
199/**
200 * Stop async DHT-get. Frees associated resources.
201 *
202 * @param get_handle GET operation to stop.
203 *
204 * On return get_handle will no longer be valid, caller
205 * must not use again!!!
206 */
207void
208GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle);
209
210
211#if 0 /* keep Emacsens' auto-indent happy */
212{
213#endif
214#ifdef __cplusplus
215}
216#endif
217
218
219#endif
220/* gnunet_dht_service.h */