GNUnet  0.10.x
gnunet_dht_service.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2004-2013, 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
35 #ifndef GNUNET_DHT_SERVICE_H
36 #define GNUNET_DHT_SERVICE_H
37 
38 #include "gnunet_util_lib.h"
39 #include "gnunet_block_lib.h"
40 #include "gnunet_hello_lib.h"
41 
42 #ifdef __cplusplus
43 extern "C"
44 {
45 #if 0 /* keep Emacsens' auto-indent happy */
46 }
47 #endif
48 #endif
49 
50 
54 #define GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 60)
55 
56 
57 
61 struct GNUNET_DHT_Handle;
62 
67 
71 struct GNUNET_DHT_FindPeerHandle;
72 
73 
82 
88 
94 
99 
104 
109 };
110 
111 
120 struct GNUNET_DHT_Handle *
122  unsigned int ht_len);
123 
124 
130 void
132 
133 
134 /* *************** Standard API: get and put ******************* */
135 
136 
140 struct GNUNET_DHT_PutHandle;
141 
142 
161 struct GNUNET_DHT_PutHandle *
163  const struct GNUNET_HashCode *key,
164  uint32_t desired_replication_level,
166  enum GNUNET_BLOCK_Type type,
167  size_t size,
168  const void *data,
169  struct GNUNET_TIME_Absolute exp,
171  void *cont_cls);
172 
173 
185 void
187 
188 
206 typedef void
208  struct GNUNET_TIME_Absolute exp,
209  const struct GNUNET_HashCode *key,
210  const struct GNUNET_PeerIdentity *get_path,
211  unsigned int get_path_length,
212  const struct GNUNET_PeerIdentity *put_path,
213  unsigned int put_path_length,
214  enum GNUNET_BLOCK_Type type,
215  size_t size,
216  const void *data);
217 
218 
235 struct GNUNET_DHT_GetHandle *
237  enum GNUNET_BLOCK_Type type,
238  const struct GNUNET_HashCode *key,
239  uint32_t desired_replication_level,
241  const void *xquery,
242  size_t xquery_size,
244  void *iter_cls);
245 
246 
257 void
259  unsigned int num_results,
260  const struct GNUNET_HashCode *results);
261 
267 void
269 
270 
271 /* *************** Extended API: monitor ******************* */
272 
277 
290 typedef void
293  enum GNUNET_BLOCK_Type type,
294  uint32_t hop_count,
295  uint32_t desired_replication_level,
296  unsigned int path_length,
297  const struct GNUNET_PeerIdentity *path,
298  const struct GNUNET_HashCode *key);
299 
300 
315 typedef void
317  enum GNUNET_BLOCK_Type type,
318  const struct GNUNET_PeerIdentity *get_path,
319  unsigned int get_path_length,
320  const struct GNUNET_PeerIdentity *put_path,
321  unsigned int put_path_length,
322  struct GNUNET_TIME_Absolute exp,
323  const struct GNUNET_HashCode *key,
324  const void *data,
325  size_t size);
326 
327 
343 typedef void
346  enum GNUNET_BLOCK_Type type,
347  uint32_t hop_count,
348  uint32_t desired_replication_level,
349  unsigned int path_length,
350  const struct GNUNET_PeerIdentity *path,
351  struct GNUNET_TIME_Absolute exp,
352  const struct GNUNET_HashCode *key,
353  const void *data,
354  size_t size);
355 
356 
357 
372  enum GNUNET_BLOCK_Type type,
373  const struct GNUNET_HashCode *key,
377  void *cb_cls);
378 
379 
387 void
389 
390 
391 #if 0 /* keep Emacsens' auto-indent happy */
392 {
393 #endif
394 #ifdef __cplusplus
395 }
396 #endif
397 
398 #endif
399  /* end of group dht */
We should keep track of the route that the message took in the P2P network.
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
Definition: dht_api.c:1030
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
void(* GNUNET_DHT_MonitorGetRespCB)(void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
Callback called on each GET reply going through the DHT.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
GNUNET_DHT_GetIterator iter
Iterator to call on data receipt.
Definition: dht_api.c:82
void GNUNET_DHT_monitor_stop(struct GNUNET_DHT_MonitorHandle *handle)
Stop monitoring.
Definition: dht_api.c:1234
void(* GNUNET_DHT_MonitorGetCB)(void *cls, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, const struct GNUNET_HashCode *key)
Callback called on each GET request going through the DHT.
GNUNET_DHT_MonitorGetRespCB get_resp_cb
Callback for each received message of type get response.
Definition: dht_api.c:181
uint32_t desired_replication_level
Desired replication level.
Definition: dht_api.c:118
static int get_cb(void *cls, const struct GNUNET_HashCode *key, void *value)
Function called during GET to find matching blocks.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
Connection to the DHT service.
Definition: dht_api.c:198
static struct GNUNET_DHT_GetHandle * get_handle
Handle for the get request.
void * iter_cls
Closure for iter.
Definition: dht_api.c:87
Possible message option for query key randomization.
Flag given to monitors if this was the last hop for a GET/PUT.
This is a &#39;FIND-PEER&#39; request, so approximate results are fine.
struct GNUNET_DHT_MonitorHandle * GNUNET_DHT_monitor_start(struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, GNUNET_DHT_MonitorGetCB get_cb, GNUNET_DHT_MonitorGetRespCB get_resp_cb, GNUNET_DHT_MonitorPutCB put_cb, void *cb_cls)
Start monitoring the local DHT service.
Definition: dht_api.c:1195
GNUNET_SCHEDULER_TaskCallback cont
Continuation to call when done.
Definition: dht_api.c:57
void * cont_cls
Closure for cont.
Definition: dht_api.c:67
void(* GNUNET_DHT_GetIterator)(void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data)
Iterator called on each result obtained for a DHT operation that expects a reply. ...
void(* GNUNET_DHT_MonitorPutCB)(void *cls, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
Callback called on each PUT request going through the DHT.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
A 512-bit hashcode.
GNUNET_DHT_RouteOption
Options for routing.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1150
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_DHT_PutHandle * GNUNET_DHT_put(struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, size_t size, const void *data, struct GNUNET_TIME_Absolute exp, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Perform a PUT operation storing data in the DHT.
Definition: dht_api.c:961
static unsigned int size
Size of the "table".
Definition: peer.c:66
void GNUNET_DHT_get_filter_known_results(struct GNUNET_DHT_GetHandle *get_handle, unsigned int num_results, const struct GNUNET_HashCode *results)
Tell the DHT not to return any of the following known results to this client.
Definition: dht_api.c:1121
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition: dht_api.c:885
size_t xquery_size
Size of the extended query, allocated at the end of this struct.
Definition: dht_api.c:113
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:913
Handle to a GET request.
Definition: dht_api.c:78
The identity of the host (wraps the signing key of the peer).
Handle to a PUT request.
Definition: dht_api.c:43
configuration data
Definition: configuration.c:83
struct GNUNET_DHT_GetHandle * GNUNET_DHT_get_start(struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, const void *xquery, size_t xquery_size, GNUNET_DHT_GetIterator iter, void *iter_cls)
Perform an asynchronous GET operation on the DHT identified.
Definition: dht_api.c:1062
static unsigned int results
Definition: gnunet-search.c:52
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
static int put_cb(void *cls, const struct GNUNET_HashCode *key, void *value)
Function called during PUT to detect if an equivalent block already exists.
uint32_t data
The data value.
Each peer along the way should look at &#39;enc&#39; (otherwise only the k-peers closest to the key should lo...
Handle to a monitoring request.
Definition: dht_api.c:147
void * cb_cls
Closure for get_cb, put_cb and get_resp_cb.
Definition: dht_api.c:191