GNUnet 0.26.2-106-g126384b46
 
Loading...
Searching...
No Matches

Distributed Hash Table. More...

Collaboration diagram for DHT service:

Data Structures

struct  GNUNET_DHT_HopSignature
 Message signed by a peer when doing path tracking. More...
 
struct  GNUNET_DHT_PathElement
 A (signed) path tracking a block's flow through the DHT is represented by an array of path elements, each consisting of a peer on the path and a signature by which the peer affirms its routing decision. More...
 

Macros

#define GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY
 Default republication frequency for stored data in the DHT.
 
#define GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL   16
 Maximum allowed replication level for all requests.
 

Typedefs

typedef void(* GNUNET_DHT_GetIterator) (void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *query_hash, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *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.
 
typedef 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, const struct GNUNET_HashCode *key)
 Callback called on each GET request going through the DHT.
 
typedef void(* GNUNET_DHT_MonitorGetRespCB) (void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *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.
 
typedef 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, const struct GNUNET_PeerIdentity *trunc_peer, unsigned int path_length, const struct GNUNET_DHT_PathElement *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.
 
typedef void(* GNUNET_DHT_HelloGetCallback) (void *cls, const char *hello_url)
 Signature called with the result of a HELLO GET operation.
 

Enumerations

enum  GNUNET_DHT_RouteOption {
  GNUNET_DHT_RO_NONE = 0 , GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1 , GNUNET_DHT_RO_RECORD_ROUTE = 2 , GNUNET_DHT_RO_FIND_APPROXIMATE = 4 ,
  GNUNET_DHT_RO_TRUNCATED = 8 , GNUNET_DHT_RO_LAST_HOP = 32768
}
 Options for routing. More...
 

Functions

struct GNUNET_DHT_HandleGNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
 Initialize the connection with the DHT service.
 
void GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle)
 Shutdown connection with the DHT service.
 
struct GNUNET_DHT_PutHandleGNUNET_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.
 
void GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph)
 Cancels a DHT PUT operation.
 
struct GNUNET_DHT_GetHandleGNUNET_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.
 
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.
 
void GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle)
 Stop async DHT-get.
 
struct GNUNET_DHT_MonitorHandleGNUNET_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.
 
void GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle)
 Stop monitoring.
 
char * GNUNET_DHT_pp2s (const struct GNUNET_DHT_PathElement *path, unsigned int path_len)
 Convert a peer path to a human-readable string.
 
unsigned int GNUNET_DHT_verify_path (const void *data, size_t data_size, struct GNUNET_TIME_Absolute exp_time, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_len, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_len, const struct GNUNET_PeerIdentity *me)
 Verify signatures on a path consisting of put_path and get_path in reverse order (starting at the last element of the get_path).
 
struct GNUNET_DHT_HelloGetHandleGNUNET_DHT_hello_get (struct GNUNET_DHT_Handle *dht_handle, GNUNET_DHT_HelloGetCallback cb, void *cb_cls)
 Obtain HELLO URL of the DHT identified by dht_handle.
 
void GNUNET_DHT_hello_get_cancel (struct GNUNET_DHT_HelloGetHandle *hgh)
 Cancel hello get operation.
 
void GNUNET_DHT_hello_offer (struct GNUNET_DHT_Handle *dht_handle, const char *url, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
 Offer HELLO URL of the DHT identified by dht_handle.
 

Detailed Description

Distributed Hash Table.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY

#define GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY
Value:
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition time.c:486

Default republication frequency for stored data in the DHT.

Definition at line 59 of file gnunet_dht_service.h.

88{
93
100
106
111
116
122};
123
124
126
131{
136
141
146
152
157};
158
159
166{
172
184
185};
186
187
189
198struct GNUNET_DHT_Handle *
200 unsigned int ht_len);
201
202
208void
210
211
212/* *************** Standard API: get and put ******************* */
213
214
219
220
241 const struct GNUNET_HashCode *key,
242 uint32_t desired_replication_level,
245 size_t size,
246 const void *data,
247 struct GNUNET_TIME_Absolute exp,
249 void *cont_cls);
250
251
263void
265
266
287typedef void
288(*GNUNET_DHT_GetIterator) (void *cls,
289 struct GNUNET_TIME_Absolute exp,
290 const struct GNUNET_HashCode *query_hash,
291 const struct GNUNET_PeerIdentity *trunc_peer,
292 const struct GNUNET_DHT_PathElement *get_path,
293 unsigned int get_path_length,
294 const struct GNUNET_DHT_PathElement *put_path,
295 unsigned int put_path_length,
297 size_t size,
298 const void *data);
299
300
320 const struct GNUNET_HashCode *key,
323 const void *xquery,
324 size_t xquery_size,
326 void *iter_cls);
327
328
339void
341 unsigned int num_results,
342 const struct GNUNET_HashCode *results);
343
349void
351
352
353/* *************** Extended API: monitor ******************* */
354
359
370typedef void
371(*GNUNET_DHT_MonitorGetCB) (void *cls,
374 uint32_t hop_count,
375 uint32_t desired_replication_level,
376 const struct GNUNET_HashCode *key);
377
378
396typedef void
397(*GNUNET_DHT_MonitorGetRespCB) (void *cls,
399 const struct GNUNET_PeerIdentity *trunc_peer,
400 const struct GNUNET_DHT_PathElement *get_path,
401 unsigned int get_path_length,
402 const struct GNUNET_DHT_PathElement *put_path,
403 unsigned int put_path_length,
404 struct GNUNET_TIME_Absolute exp,
405 const struct GNUNET_HashCode *key,
406 const void *data,
407 size_t size);
408
409
428typedef void
429(*GNUNET_DHT_MonitorPutCB) (void *cls,
432 uint32_t hop_count,
433 uint32_t desired_replication_level,
434 const struct GNUNET_PeerIdentity *trunc_peer,
435 unsigned int path_length,
436 const struct GNUNET_DHT_PathElement *path,
437 struct GNUNET_TIME_Absolute exp,
438 const struct GNUNET_HashCode *key,
439 const void *data,
440 size_t size);
441
442
458 const struct GNUNET_HashCode *key,
462 void *cb_cls);
463
464
472void
474
475
483char *
484GNUNET_DHT_pp2s (const struct GNUNET_DHT_PathElement *path,
485 unsigned int path_len);
486
487
508unsigned int
509GNUNET_DHT_verify_path (const void *data,
510 size_t data_size,
511 struct GNUNET_TIME_Absolute exp_time,
512 const struct GNUNET_PeerIdentity *trunc_peer,
513 const struct GNUNET_DHT_PathElement *put_path,
514 unsigned int put_path_len,
515 const struct GNUNET_DHT_PathElement *get_path,
516 unsigned int get_path_len,
517 const struct GNUNET_PeerIdentity *me);
518
519
524
525
532typedef void
533(*GNUNET_DHT_HelloGetCallback)(void *cls,
534 const char *hello_url);
535
536
548 void *cb_cls);
549
550
556void
558
559
570void
572 const char *url,
574 void *cb_cls);
575
576
577#if 0 /* keep Emacsens' auto-indent happy */
578{
579#endif
580#ifdef __cplusplus
581}
582#endif
583
584#endif
585
/* end of group dht */
587
/* end of group addition */
589
/* end of group addition */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static GNUNET_NETWORK_STRUCT_END struct GNUNET_PeerIdentity me
Our own peer identity.
static void get_cb(void *cls, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid)
Process a datum that was stored in the datastore.
static void put_cb(void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
Continuation called to notify client about result of the operation.
static struct GNUNET_DHT_Handle * dht_handle
Handle to the DHT.
static struct GNUNET_DHT_GetHandle * get_handle
Handle for the get request.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static unsigned int results
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
Definition dht_api.c:1150
GNUNET_DHT_RouteOption
Options for routing.
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:1087
char * GNUNET_DHT_pp2s(const struct GNUNET_DHT_PathElement *path, unsigned int path_len)
Convert a peer path to a human-readable string.
Definition dht_api.c:1332
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:1036
void GNUNET_DHT_hello_get_cancel(struct GNUNET_DHT_HelloGetHandle *hgh)
Cancel hello get operation.
Definition dht_api.c:1470
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition dht_api.c:1239
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:1215
void(* GNUNET_DHT_GetIterator)(void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *query_hash, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *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_MonitorGetRespCB)(void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *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.
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, const struct GNUNET_HashCode *key)
Callback called on each GET request going through the DHT.
void(* GNUNET_DHT_HelloGetCallback)(void *cls, const char *hello_url)
Signature called with the result of a HELLO GET operation.
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:1272
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:1166
struct GNUNET_DHT_HelloGetHandle * GNUNET_DHT_hello_get(struct GNUNET_DHT_Handle *dht_handle, GNUNET_DHT_HelloGetCallback cb, void *cb_cls)
Obtain HELLO URL of the DHT identified by dht_handle.
Definition dht_api.c:1446
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition dht_api.c:1059
void GNUNET_DHT_hello_offer(struct GNUNET_DHT_Handle *dht_handle, const char *url, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Offer HELLO URL of the DHT identified by dht_handle.
Definition dht_api.c:1482
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, const struct GNUNET_PeerIdentity *trunc_peer, unsigned int path_length, const struct GNUNET_DHT_PathElement *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.
unsigned int GNUNET_DHT_verify_path(const void *data, size_t data_size, struct GNUNET_TIME_Absolute exp_time, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_len, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_len, const struct GNUNET_PeerIdentity *me)
Verify signatures on a path consisting of put_path and get_path in reverse order (starting at the las...
Definition dht_api.c:1355
void GNUNET_DHT_monitor_stop(struct GNUNET_DHT_MonitorHandle *handle)
Stop monitoring.
Definition dht_api.c:1304
@ GNUNET_DHT_RO_TRUNCATED
Flag set if the path was truncated.
@ GNUNET_DHT_RO_NONE
Default.
@ GNUNET_DHT_RO_RECORD_ROUTE
We should keep track of the route that the message took in the P2P network.
@ GNUNET_DHT_RO_LAST_HOP
Flag given to monitors if this was the last hop for a GET/PUT.
@ GNUNET_DHT_RO_FIND_APPROXIMATE
Approximate results are fine.
@ GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
Each peer along the way should process the request (otherwise only peers locally closest to the key w...
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_PACKED
gcc-ism to get packed structs.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
static unsigned int size
Size of the "table".
Definition peer.c:68
an ECC signature using EdDSA.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
Handle to a GET request.
Definition dht_api.c:79
GNUNET_DHT_GetIterator iter
Iterator to call on data receipt.
Definition dht_api.c:83
void * iter_cls
Closure for iter.
Definition dht_api.c:88
size_t xquery_size
Size of the extended query, allocated at the end of this struct.
Definition dht_api.c:114
uint32_t desired_replication_level
Desired replication level.
Definition dht_api.c:119
Connection to the DHT service.
Definition dht_api.c:235
Handle to get a HELLO URL from the DHT for manual bootstrapping.
Definition dht_api.c:201
GNUNET_DHT_HelloGetCallback cb
Function to call with the result.
Definition dht_api.c:216
void * cb_cls
Closure for cb.
Definition dht_api.c:221
Message signed by a peer when doing path tracking.
struct GNUNET_CRYPTO_SignaturePurpose purpose
Must be GNUNET_SIGNATURE_PURPOSE_DHT_HOP.
struct GNUNET_HashCode h_data
Hash over the payload of the block.
struct GNUNET_TIME_AbsoluteNBO expiration_time
Expiration time of the block.
struct GNUNET_PeerIdentity pred
Previous hop the message was received from.
struct GNUNET_PeerIdentity succ
Next hop the message was forwarded to.
Handle to a monitoring request.
Definition dht_api.c:149
GNUNET_DHT_MonitorGetRespCB get_resp_cb
Callback for each received message of type get response.
Definition dht_api.c:183
void * cb_cls
Closure for get_cb, put_cb and get_resp_cb.
Definition dht_api.c:193
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...
struct GNUNET_PeerIdentity pred
Previous peer on the path (matches "pred" in the signed field).
struct GNUNET_CRYPTO_EddsaSignature sig
Signature affirming the hop of type GNUNET_SIGNATURE_PURPOSE_DHT_HOP.
Handle to a PUT request.
Definition dht_api.c:43
void * cont_cls
Closure for cont.
Definition dht_api.c:67
GNUNET_SCHEDULER_TaskCallback cont
Continuation to call when done.
Definition dht_api.c:57
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.

◆ GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL

#define GNUNET_DHT_MAXIMUM_REPLICATION_LEVEL   16

Maximum allowed replication level for all requests.

Definition at line 66 of file gnunet_dht_service.h.

Typedef Documentation

◆ GNUNET_DHT_GetIterator

typedef void(* GNUNET_DHT_GetIterator) (void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *query_hash, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *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.

Parameters
clsclosure
expwhen will this value expire
query_hashkey of the query
trunc_peerpeer where the path was truncated, or NULL if the path is complete
get_pathpeers on reply path (or NULL if not recorded) [0] = datastore's first neighbor, [length - 1] = local peer
get_path_lengthnumber of entries in get_path
put_pathpeers on the PUT path (or NULL if not recorded) [0] = origin, [length - 1] = datastore
put_path_lengthnumber of entries in put_path, note that the last signature will be all zeros as we did not forward and thus did not sign!
typetype of the result
sizenumber of bytes in data
datapointer to the result data

Definition at line 288 of file gnunet_dht_service.h.

◆ GNUNET_DHT_MonitorGetCB

typedef 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, const struct GNUNET_HashCode *key)

Callback called on each GET request going through the DHT.

Parameters
clsClosure.
optionsOptions, for instance RecordRoute, DemultiplexEverywhere.
typeThe type of data in the request.
hop_countHop count so far.
desired_replication_levelDesired replication level.
keyKey of the requested data.

Definition at line 371 of file gnunet_dht_service.h.

◆ GNUNET_DHT_MonitorGetRespCB

typedef void(* GNUNET_DHT_MonitorGetRespCB) (void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *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.

Parameters
clsClosure.
typeThe type of data in the result.
trunc_peerpeer where the path was truncated, or NULL if the path is complete
get_pathPeers on GET path (or NULL if not recorded). note that the last signature will be all zeros as we did not forward and thus did not sign!
get_path_lengthnumber of entries in get_path.
put_pathpeers on the PUT path (or NULL if not recorded).
put_path_lengthnumber of entries in get_path.
expExpiration time of the data.
keyKey of the data.
dataPointer to the result data.
sizeNumber of bytes in data.

Definition at line 397 of file gnunet_dht_service.h.

◆ GNUNET_DHT_MonitorPutCB

typedef 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, const struct GNUNET_PeerIdentity *trunc_peer, unsigned int path_length, const struct GNUNET_DHT_PathElement *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.

Parameters
clsClosure.
optionsOptions, for instance RecordRoute, DemultiplexEverywhere.
typeThe type of data in the request.
hop_countHop count so far.
desired_replication_levelDesired replication level.
trunc_peerpeer where the path was truncated, or NULL if the path is complete
path_lengthnumber of entries in path (or 0 if not recorded).
pathpeers on the PUT path (or NULL if not recorded). note that the last signature will be all zeros as we did not forward and thus did not sign!
expExpiration time of the data.
keyKey under which data is to be stored.
dataPointer to the data carried.
sizeNumber of bytes in data.

Definition at line 429 of file gnunet_dht_service.h.

◆ GNUNET_DHT_HelloGetCallback

typedef void(* GNUNET_DHT_HelloGetCallback) (void *cls, const char *hello_url)

Signature called with the result of a HELLO GET operation.

Parameters
clsclosure
hello_urlthe resulting HELLO URL, NULL on error

Definition at line 533 of file gnunet_dht_service.h.

Enumeration Type Documentation

◆ GNUNET_DHT_RouteOption

Options for routing.

Enumerator
GNUNET_DHT_RO_NONE 

Default.

Do nothing special.

GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE 

Each peer along the way should process the request (otherwise only peers locally closest to the key when the random walk is over should look at it).

GNUNET_DHT_RO_RECORD_ROUTE 

We should keep track of the route that the message took in the P2P network.

GNUNET_DHT_RO_FIND_APPROXIMATE 

Approximate results are fine.

GNUNET_DHT_RO_TRUNCATED 

Flag set if the path was truncated.

GNUNET_DHT_RO_LAST_HOP 

Flag given to monitors if this was the last hop for a GET/PUT.

This is only used for internal processing.

Definition at line 88 of file gnunet_dht_service.h.

Function Documentation

◆ GNUNET_DHT_connect()

struct GNUNET_DHT_Handle * GNUNET_DHT_connect ( const struct GNUNET_CONFIGURATION_Handle cfg,
unsigned int  ht_len 
)

Initialize the connection with the DHT service.

Parameters
cfgconfiguration to use
ht_lensize of the internal hash table to use for processing multiple GET/FIND requests in parallel
Returns
NULL on error

Definition at line 1036 of file dht_api.c.

1038{
1039 struct GNUNET_DHT_Handle *handle;
1040
1042 handle->cfg = cfg;
1043 handle->uid_gen
1045 UINT64_MAX);
1046 handle->active_requests
1048 GNUNET_YES);
1049 if (GNUNET_NO == try_connect (handle))
1050 {
1052 return NULL;
1053 }
1054 return handle;
1055}
static enum GNUNET_GenericReturnValue try_connect(struct GNUNET_DHT_Handle *h)
Try to (re)connect to the DHT service.
Definition dht_api.c:992
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Generate a random unsigned 64-bit value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_new(type)
Allocate a struct or union of the given type.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
Definition vpn_api.c:39

References cfg, GNUNET_VPN_Handle::cfg, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64(), GNUNET_DHT_disconnect(), GNUNET_new, GNUNET_NO, GNUNET_YES, handle, and try_connect().

Referenced by advertise_dns_exit(), dht_ca(), dht_ca(), dht_connect(), GCD_init(), run(), run(), run(), run(), run(), run(), run(), run(), run(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_disconnect()

void GNUNET_DHT_disconnect ( struct GNUNET_DHT_Handle handle)

Shutdown connection with the DHT service.

Parameters
handleconnection to shut down

Definition at line 1059 of file dht_api.c.

1060{
1061 struct GNUNET_DHT_PutHandle *ph;
1062
1063 GNUNET_assert (0 ==
1064 GNUNET_CONTAINER_multihashmap_size (handle->active_requests));
1065 while (NULL != (ph = handle->put_head))
1066 {
1067 if (NULL != ph->cont)
1068 ph->cont (ph->cont_cls);
1070 }
1071 if (NULL != handle->mq)
1072 {
1074 handle->mq = NULL;
1075 }
1076 if (NULL != handle->reconnect_task)
1077 {
1078 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
1079 handle->reconnect_task = NULL;
1080 }
1083}
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition mq.c:700
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition vpn_api.c:44

References GNUNET_DHT_PutHandle::cont, GNUNET_DHT_PutHandle::cont_cls, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_DHT_put_cancel(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), handle, and GNUNET_VPN_Handle::mq.

Referenced by cleanup(), cleanup(), cleanup_task(), cleanup_task(), cleanup_task(), cleanup_task(), dht_da(), dht_da(), dht_disconnect(), GCD_shutdown(), GNUNET_DHT_connect(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_put()

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.

Parameters
handlehandle to DHT service
keythe key to store under
desired_replication_levelestimate of how many nearest peers this request should reach
optionsrouting options for this message
typetype of the value
sizenumber of bytes in data; must be less than 64k
datathe data to store
expdesired expiration time for the value
contcontinuation to call when done (transmitting request to service) You must not call GNUNET_DHT_disconnect in this continuation
cont_clsclosure for cont
Returns
handle to cancel the "PUT" operation, NULL on error (size too big)

Definition at line 1087 of file dht_api.c.

1097{
1098 struct GNUNET_MQ_Envelope *env;
1099 struct GNUNET_DHT_ClientPutMessage *put_msg;
1100 size_t msize;
1101 struct GNUNET_DHT_PutHandle *ph;
1102
1103 if (0 == size)
1104 {
1105 GNUNET_break (0);
1106 return NULL;
1107 }
1108 msize = sizeof(struct GNUNET_DHT_ClientPutMessage) + size;
1109 if ((msize >= GNUNET_MAX_MESSAGE_SIZE) ||
1111 {
1112 GNUNET_break (0);
1113 return NULL;
1114 }
1115 if (NULL == handle->mq)
1116 return NULL;
1118 "Sending PUT for %s to DHT via %p\n",
1119 GNUNET_h2s (key),
1120 handle);
1121 ph = GNUNET_new (struct GNUNET_DHT_PutHandle);
1122 ph->dht_handle = handle;
1123 ph->cont = cont;
1124 ph->cont_cls = cont_cls;
1126 handle->put_tail,
1127 ph);
1128 env = GNUNET_MQ_msg_extra (put_msg,
1129 size,
1133 ph);
1134 ph->env = env;
1135 put_msg->type = htonl ((uint32_t) type);
1136 put_msg->options = htonl ((uint32_t) options);
1138 put_msg->expiration = GNUNET_TIME_absolute_hton (exp);
1139 put_msg->key = *key;
1140 GNUNET_memcpy (&put_msg[1],
1141 data,
1142 size);
1144 env);
1145 return ph;
1146}
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
static void handle_put_cont(void *cls)
Process a MQ PUT transmission notification.
Definition dht_api.c:970
#define LOG(kind,...)
Definition dht_api.c:36
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition mq.c:305
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
Definition mq.c:655
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT
Client wants to store item in DHT.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition time.c:636
Message to insert data into the DHT, sent from clients to DHT service.
Definition dht.h:200
struct GNUNET_HashCode key
The key to store the value under.
Definition dht.h:229
uint32_t type
The type of data to insert.
Definition dht.h:209
uint32_t options
Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
Definition dht.h:214
uint32_t desired_replication_level
Replication level for this message.
Definition dht.h:219
struct GNUNET_TIME_AbsoluteNBO expiration
How long should this data persist?
Definition dht.h:224
struct GNUNET_DHT_Handle * dht_handle
Main handle to this DHT api.
Definition dht_api.c:62
struct GNUNET_MQ_Envelope * env
Envelope from the PUT operation.
Definition dht_api.c:72

References GNUNET_DHT_PutHandle::cont, GNUNET_DHT_PutHandle::cont_cls, data, GNUNET_DHT_ClientPutMessage::desired_replication_level, GNUNET_DHT_PutHandle::dht_handle, env, GNUNET_DHT_PutHandle::env, GNUNET_DHT_ClientPutMessage::expiration, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_new, GNUNET_TIME_absolute_hton(), handle, handle_put_cont(), key, GNUNET_DHT_ClientPutMessage::key, LOG, GNUNET_VPN_Handle::mq, options, GNUNET_DHT_ClientPutMessage::options, size, type, and GNUNET_DHT_ClientPutMessage::type.

Referenced by announce_id(), delayed_put(), do_dht_put(), initiate_put_from_pipe_trigger(), process_dht_put_content(), regex_iterator(), run(), and sign_accept_block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_put_cancel()

void GNUNET_DHT_put_cancel ( struct GNUNET_DHT_PutHandle ph)

Cancels a DHT PUT operation.

Note that the PUT request may still go out over the network (we can't stop that); However, if the PUT has not yet been sent to the service, cancelling the PUT will stop this from happening (but there is no way for the user of this API to tell if that is the case). The only use for this API is to prevent a later call to 'cont' from GNUNET_DHT_put (e.g. because the system is shutting down).

Parameters
phput operation to cancel ('cont' will no longer be called)

Definition at line 1150 of file dht_api.c.

1151{
1152 struct GNUNET_DHT_Handle *handle = ph->dht_handle;
1153
1154 if (NULL != ph->env)
1156 NULL,
1157 NULL);
1159 handle->put_tail,
1160 ph);
1161 GNUNET_free (ph);
1162}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.

References GNUNET_DHT_PutHandle::dht_handle, GNUNET_DHT_PutHandle::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_notify_sent(), and handle.

Referenced by cleanup(), do_dht_put(), do_disconnect(), do_shutdown(), GNUNET_DHT_disconnect(), GSF_put_done_(), handle_put_cont(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_get_start()

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.

See also #GNUNET_BLOCK_evaluate.

Parameters
handlehandle to the DHT service
typeexpected type of the response object
keythe key to look up
desired_replication_levelestimate of how many nearest peers this request should reach
optionsrouting options for this message
xqueryextended query data (can be NULL, depending on type)
xquery_sizenumber of bytes in xquery
iterfunction to call on each result
iter_clsclosure for iter
Returns
handle to stop the async get

Definition at line 1166 of file dht_api.c.

1175{
1176 struct GNUNET_DHT_GetHandle *gh;
1177 size_t msize;
1178
1179 msize = sizeof(struct GNUNET_DHT_ClientGetMessage) + xquery_size;
1180 if ((msize >= GNUNET_MAX_MESSAGE_SIZE) ||
1181 (xquery_size >= GNUNET_MAX_MESSAGE_SIZE))
1182 {
1183 GNUNET_break (0);
1184 return NULL;
1185 }
1187 "Sending query for %s to DHT %p\n",
1188 GNUNET_h2s (key),
1189 handle);
1190 gh = GNUNET_malloc (sizeof(struct GNUNET_DHT_GetHandle)
1191 + xquery_size);
1192 gh->iter = iter;
1193 gh->iter_cls = iter_cls;
1194 gh->dht_handle = handle;
1195 gh->key = *key;
1196 gh->unique_id = ++handle->uid_gen;
1197 gh->xquery_size = xquery_size;
1199 gh->type = type;
1200 gh->options = options;
1201 GNUNET_memcpy (&gh[1],
1202 xquery,
1203 xquery_size);
1204 GNUNET_CONTAINER_multihashmap_put (handle->active_requests,
1205 &gh->key,
1206 gh,
1208 if (NULL != handle->mq)
1209 send_get (gh);
1210 return gh;
1211}
static void send_get(struct GNUNET_DHT_GetHandle *gh)
Send GET message for a get_handle to DHT.
Definition dht_api.c:316
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_malloc(size)
Wrapper around malloc.
DHT GET message sent from clients to service.
Definition dht.h:72
uint32_t desired_replication_level
Replication level for this message.
Definition dht.h:86
enum GNUNET_BLOCK_Type type
Type of the block we are looking for.
Definition dht_api.c:124
struct GNUNET_HashCode key
Key that this get request is for.
Definition dht_api.c:104
uint64_t unique_id
Unique identifier for this request (for key collisions).
Definition dht_api.c:109
struct GNUNET_DHT_Handle * dht_handle
Main handle to this DHT api.
Definition dht_api.c:93
enum GNUNET_DHT_RouteOption options
Routing options.
Definition dht_api.c:129

References GNUNET_DHT_ClientGetMessage::desired_replication_level, GNUNET_DHT_GetHandle::desired_replication_level, GNUNET_DHT_GetHandle::dht_handle, GNUNET_break, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_malloc, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, handle, GNUNET_DHT_GetHandle::iter, GNUNET_DHT_GetHandle::iter_cls, key, GNUNET_DHT_GetHandle::key, LOG, GNUNET_VPN_Handle::mq, options, GNUNET_DHT_GetHandle::options, send_get(), type, GNUNET_DHT_GetHandle::type, GNUNET_DHT_GetHandle::unique_id, and GNUNET_DHT_GetHandle::xquery_size.

Referenced by delayed_get(), GCD_search(), GSF_dht_lookup_(), regex_find_path(), REGEX_INTERNAL_search(), regex_next_edge(), run(), run(), and start_dht_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_get_filter_known_results()

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.

Parameters
get_handleget operation for which results should be filtered
num_resultsnumber of results to be blocked that are provided in this call (size of the results array)
resultsarray of hash codes over the data of the results to be blocked

Definition at line 1215 of file dht_api.c.

1218{
1219 unsigned int needed;
1220 unsigned int had;
1221
1223 needed = had + num_results;
1224 if (needed > get_handle->seen_results_size)
1227 needed);
1229 results,
1230 num_results * sizeof(struct GNUNET_HashCode));
1231 get_handle->seen_results_end += num_results;
1232 if (NULL != get_handle->dht_handle->mq)
1234 had);
1235}
static void send_get_known_results(struct GNUNET_DHT_GetHandle *gh, unsigned int transmission_offset_start)
Send GET message(s) for indicating which results are already known for a get_handle to DHT.
Definition dht_api.c:348
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
unsigned int seen_results_end
Offset into the seen_results array marking the end of the positions that are actually used.
Definition dht_api.c:141
struct GNUNET_HashCode * seen_results
Array of hash codes over the results that we have already seen.
Definition dht_api.c:99
unsigned int seen_results_size
Size of the seen_results array.
Definition dht_api.c:135
struct GNUNET_MQ_Handle * mq
Connection to DHT service.
Definition dht_api.c:244

References GNUNET_DHT_GetHandle::dht_handle, get_handle, GNUNET_array_grow, GNUNET_memcpy, GNUNET_DHT_Handle::mq, results, GNUNET_DHT_GetHandle::seen_results, GNUNET_DHT_GetHandle::seen_results_end, GNUNET_DHT_GetHandle::seen_results_size, and send_get_known_results().

Referenced by GSF_dht_lookup_(), and GSF_pending_request_update_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_get_stop()

void GNUNET_DHT_get_stop ( struct GNUNET_DHT_GetHandle get_handle)

Stop async DHT-get.

Frees associated resources.

Parameters
get_handleGET operation to stop.

Definition at line 1239 of file dht_api.c.

1240{
1242
1244 "Sending STOP for %s to DHT via %p\n",
1246 handle);
1247 if (NULL != handle->mq)
1248 {
1249 struct GNUNET_MQ_Envelope *env;
1250 struct GNUNET_DHT_ClientGetStopMessage *stop_msg;
1251
1252 env = GNUNET_MQ_msg (stop_msg,
1254 stop_msg->reserved = htonl (0);
1255 stop_msg->unique_id = get_handle->unique_id;
1256 stop_msg->key = get_handle->key;
1258 env);
1259 }
1262 &get_handle->key,
1263 get_handle));
1266 0);
1268}
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP
Client wants to stop search in DHT.
Message which indicates the DHT should cancel outstanding requests and discard any state.
Definition dht.h:44
uint64_t unique_id
Unique ID identifying this request.
Definition dht.h:58
struct GNUNET_HashCode key
Key of this request.
Definition dht.h:63
uint32_t reserved
Always zero.
Definition dht.h:53

References GNUNET_DHT_GetHandle::dht_handle, env, get_handle, GNUNET_array_grow, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_YES, handle, GNUNET_DHT_ClientGetStopMessage::key, GNUNET_DHT_GetHandle::key, LOG, GNUNET_VPN_Handle::mq, GNUNET_DHT_ClientGetStopMessage::reserved, GNUNET_DHT_GetHandle::seen_results, GNUNET_DHT_GetHandle::seen_results_end, GNUNET_DHT_ClientGetStopMessage::unique_id, and GNUNET_DHT_GetHandle::unique_id.

Referenced by cancel_get(), clean_request(), cleanup(), cleanup_task(), do_shutdown(), GCD_search_stop(), get_iter(), get_result_iterator(), GNS_resolver_lookup_cancel(), GSF_dht_lookup_(), GSF_pending_request_cancel_(), handle_dht_response(), and regex_cancel_dht_get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_monitor_start()

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.

Parameters
handleHandle to the DHT service.
typeType of blocks that are of interest.
keyKey of data of interest, NULL for all.
get_cbCallback to process monitored get messages.
get_resp_cbCallback to process monitored get response messages.
put_cbCallback to process monitored put messages.
cb_clsClosure for callbacks
Returns
Handle to stop monitoring.

Definition at line 1272 of file dht_api.c.

1279{
1281
1283 mh->get_cb = get_cb;
1284 mh->get_resp_cb = get_resp_cb;
1285 mh->put_cb = put_cb;
1286 mh->cb_cls = cb_cls;
1287 mh->type = type;
1288 mh->dht_handle = handle;
1289 if (NULL != key)
1290 {
1291 mh->key = GNUNET_new (struct GNUNET_HashCode);
1292 *mh->key = *key;
1293 }
1294 GNUNET_CONTAINER_DLL_insert (handle->monitor_head,
1295 handle->monitor_tail,
1296 mh);
1297 if (NULL != handle->mq)
1299 return mh;
1300}
static void send_monitor_start(struct GNUNET_DHT_MonitorHandle *mh)
Send GNUNET_MESSAGE_TYPE_DHT_MONITOR_START message.
Definition dht_api.c:415
static struct GNUNET_CADET_Handle * mh
Cadet handle.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.

References GNUNET_DHT_MonitorHandle::cb_cls, get_cb(), GNUNET_DHT_MonitorHandle::get_resp_cb, GNUNET_CONTAINER_DLL_insert, GNUNET_new, handle, key, mh, GNUNET_VPN_Handle::mq, put_cb(), send_monitor_start(), and type.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_monitor_stop()

void GNUNET_DHT_monitor_stop ( struct GNUNET_DHT_MonitorHandle handle)

Stop monitoring.

On return handle will no longer be valid, caller must not use it anymore.

Parameters
handleThe handle to the monitor request returned by GNUNET_DHT_monitor_start().

Definition at line 1304 of file dht_api.c.

1305{
1306 struct GNUNET_DHT_Handle *handle = mh->dht_handle;
1308 struct GNUNET_MQ_Envelope *env;
1309
1310 GNUNET_CONTAINER_DLL_remove (handle->monitor_head,
1311 handle->monitor_tail,
1312 mh);
1313 env = GNUNET_MQ_msg (m,
1315 m->type = htonl (mh->type);
1316 m->get = htons (NULL != mh->get_cb);
1317 m->get_resp = htons (NULL != mh->get_resp_cb);
1318 m->put = htons (NULL != mh->put_cb);
1319 if (NULL != mh->key)
1320 {
1321 m->filter_key = htons (1);
1322 m->key = *mh->key;
1323 }
1325 env);
1326 GNUNET_free (mh->key);
1327 GNUNET_free (mh);
1328}
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition gnunet-arm.c:103
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP
Stop information about transiting messages.
Message to request monitoring messages, clients -> DHT service.
Definition dht.h:291

References env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP, GNUNET_MQ_msg, GNUNET_MQ_send(), handle, m, mh, and GNUNET_VPN_Handle::mq.

Referenced by cleanup_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_pp2s()

char * GNUNET_DHT_pp2s ( const struct GNUNET_DHT_PathElement path,
unsigned int  path_len 
)

Convert a peer path to a human-readable string.

Parameters
patharray of path elements to convert to a string
path_lenlength of the path array
Returns
string representing the array of pids

Definition at line 1332 of file dht_api.c.

1334{
1335 char *buf;
1336 size_t off;
1337 size_t plen = path_len * 5 + 1;
1338
1339 GNUNET_assert (path_len < UINT32_MAX / 5);
1340 off = 0;
1341 buf = GNUNET_malloc (plen);
1342 for (unsigned int i = 0; i < path_len; i++)
1343 {
1344 off += GNUNET_snprintf (&buf[off],
1345 plen - off,
1346 "%s%s",
1347 GNUNET_i2s (&path[i].pred),
1348 (i == path_len - 1) ? "" : "-");
1349 }
1350 return buf;
1351}
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.

References GNUNET_assert, GNUNET_i2s(), GNUNET_malloc, and GNUNET_snprintf().

Referenced by process_client_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_verify_path()

unsigned int GNUNET_DHT_verify_path ( const void *  data,
size_t  data_size,
struct GNUNET_TIME_Absolute  exp_time,
const struct GNUNET_PeerIdentity trunc_peer,
const struct GNUNET_DHT_PathElement put_path,
unsigned int  put_path_len,
const struct GNUNET_DHT_PathElement get_path,
unsigned int  get_path_len,
const struct GNUNET_PeerIdentity me 
)

Verify signatures on a path consisting of put_path and get_path in reverse order (starting at the last element of the get_path).

Note that the last signature on the path is never verified as that is the slot where our peer (me) would need to sign.

Parameters
datapayload (the block)
data_sizenumber of bytes in data
exp_timeexpiration time of data
trunc_peerpeer which signature was broken or where the path was truncated, NULL if path is not truncated
get_patharray of path elements to verify
get_path_lenlength of the get_path array
put_patharray of path elements to verify
put_path_lenlength of the put_path array
meour own peer identity (needed to verify the last element)
Returns
0 on success, otherwise the index of the last path element that succeeded with verification; get_path_len + put_path_len if no signature was valid

Definition at line 1355 of file dht_api.c.

1364{
1365 static struct GNUNET_PeerIdentity zero;
1366 struct GNUNET_DHT_HopSignature hs = {
1368 .purpose.size = htonl (sizeof (hs)),
1369 .expiration_time = GNUNET_TIME_absolute_hton (exp_time)
1370 };
1371 unsigned int i;
1372
1373 if (0 == get_path_len + put_path_len)
1374 return 0;
1376 "%s is verifying signatures with GPL: %u PPL: %u!\n",
1377 GNUNET_i2s (me),
1378 get_path_len,
1379 put_path_len);
1380 for (unsigned int j = 0; j<put_path_len; j++)
1382 "PP%u=%s\n",
1383 j,
1384 GNUNET_i2s (&put_path[j].pred));
1385 for (unsigned int j = 0; j<get_path_len; j++)
1387 "GP%u=%s\n",
1388 j,
1389 GNUNET_i2s (&get_path[j].pred));
1391 data_size,
1392 &hs.h_data);
1393 i = put_path_len + get_path_len;
1394 while (i > 0)
1395 {
1396 const struct GNUNET_PeerIdentity *pred;
1397 const struct GNUNET_PeerIdentity *succ;
1398 const struct GNUNET_DHT_PathElement *pe;
1399
1400 i--;
1401 if (0 == i)
1402 {
1403 pred = (NULL == bpid) ? &zero : bpid;
1404 }
1405 else
1406 {
1407 unsigned int off = i - 1;
1408
1409 pred = (off >= put_path_len)
1410 ? &get_path[off - put_path_len].pred
1411 : &put_path[off].pred;
1412 }
1413 if (i == get_path_len + put_path_len - 1)
1414 {
1415 succ = me;
1416 }
1417 else
1418 {
1419 unsigned int off = i + 1;
1420
1421 succ = (off >= put_path_len)
1422 ? &get_path[off - put_path_len].pred
1423 : &put_path[off].pred;
1424 }
1425 hs.pred = *pred;
1426 hs.succ = *succ;
1427 pe = (i >= put_path_len)
1428 ? &get_path[i - put_path_len]
1429 : &put_path[i];
1430 if (GNUNET_OK !=
1433 &hs,
1434 &pe->sig,
1435 &pe->pred.public_key))
1436 {
1437 GNUNET_break_op (0);
1438 return i + 1;
1439 }
1440 }
1441 return i;
1442}
static const struct GNUNET_CRYPTO_BlindablePrivateKey zero
Public key of all zeros.
#define GNUNET_SIGNATURE_PURPOSE_DHT_HOP
Signature by which a peer affirms that it forwarded a message in the DHT.
#define GNUNET_CRYPTO_eddsa_verify(purp, ps, sig, pub)
Verify EdDSA signature.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition crypto_hash.c:41
#define GNUNET_log(kind,...)
@ GNUNET_OK
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
struct GNUNET_CRYPTO_EddsaPublicKey public_key

References data, data_size, GNUNET_break_op, GNUNET_CRYPTO_eddsa_verify, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_DHT_HOP, GNUNET_TIME_absolute_hton(), GNUNET_DHT_HopSignature::h_data, me, GNUNET_DHT_HopSignature::pred, GNUNET_DHT_PathElement::pred, GNUNET_PeerIdentity::public_key, GNUNET_CRYPTO_SignaturePurpose::purpose, GNUNET_DHT_HopSignature::purpose, GNUNET_DHT_PathElement::sig, GNUNET_DHT_HopSignature::succ, and zero.

Referenced by cb_path_signed(), forward_reply(), GDS_CLIENTS_handle_reply(), GDS_helper_put_message_get_size(), GDS_NEIGHBOURS_handle_reply(), get_result_iterator(), handle_dht_p2p_put(), and handle_dht_p2p_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_hello_get()

struct GNUNET_DHT_HelloGetHandle * GNUNET_DHT_hello_get ( struct GNUNET_DHT_Handle dht_handle,
GNUNET_DHT_HelloGetCallback  cb,
void *  cb_cls 
)

Obtain HELLO URL of the DHT identified by dht_handle.

Parameters
dht_handleDHT to query
cbfunction to call with the result
cb_clsclosure for cb
Returns
NULL on failure

Definition at line 1446 of file dht_api.c.

1449{
1450 struct GNUNET_DHT_HelloGetHandle *hgh;
1451 struct GNUNET_MessageHeader *hdr;
1452 struct GNUNET_MQ_Envelope *env;
1453
1455 hgh->cb = cb;
1456 hgh->cb_cls = cb_cls;
1457 hgh->dht_handle = dht_handle;
1460 hgh);
1461 env = GNUNET_MQ_msg (hdr,
1464 env);
1465 return hgh;
1466}
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_GET
Client requests DHT service's HELLO URL.
struct GNUNET_DHT_HelloGetHandle * hgh_tail
DLL.
Definition dht_api.c:274
struct GNUNET_DHT_HelloGetHandle * hgh_head
DLL.
Definition dht_api.c:269
struct GNUNET_DHT_Handle * dht_handle
Connection to the DHT service.
Definition dht_api.c:226
Header for all communications.

References GNUNET_DHT_HelloGetHandle::cb, GNUNET_DHT_HelloGetHandle::cb_cls, dht_handle, GNUNET_DHT_HelloGetHandle::dht_handle, env, GNUNET_CONTAINER_DLL_insert, GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_GET, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_DHT_Handle::hgh_head, GNUNET_DHT_Handle::hgh_tail, and GNUNET_DHT_Handle::mq.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DHT_hello_get_cancel()

void GNUNET_DHT_hello_get_cancel ( struct GNUNET_DHT_HelloGetHandle hgh)

Cancel hello get operation.

Parameters
[in]hghoperation to cancel.

Definition at line 1470 of file dht_api.c.

1471{
1473
1476 hgh);
1477 GNUNET_free (hgh);
1478}

References dht_handle, GNUNET_DHT_HelloGetHandle::dht_handle, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_DHT_Handle::hgh_head, and GNUNET_DHT_Handle::hgh_tail.

Referenced by cleanup_task(), and handle_client_hello().

Here is the caller graph for this function:

◆ GNUNET_DHT_hello_offer()

void GNUNET_DHT_hello_offer ( struct GNUNET_DHT_Handle dht_handle,
const char *  url,
GNUNET_SCHEDULER_TaskCallback  cb,
void *  cb_cls 
)

Offer HELLO URL of the DHT identified by dht_handle.

Callback may be invoked once, only way to cancel is to disconnect dht_handle.

Parameters
dht_handleDHT to query
urlURL with a HELLO to offer to the DHT
cbfunction called when done
cb_clsclosure for cb

Definition at line 1482 of file dht_api.c.

1486{
1487 struct GNUNET_MessageHeader *hdr;
1488 size_t slen = strlen (url) + 1;
1489 struct GNUNET_MQ_Envelope *env;
1490
1491 env = GNUNET_MQ_msg_extra (hdr,
1492 slen,
1494 memcpy (&hdr[1],
1495 url,
1496 slen);
1498 cb,
1499 cb_cls);
1501 env);
1502}
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_URL
HELLO URL send between client and service (in either direction).

References dht_handle, env, GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_URL, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), and GNUNET_DHT_Handle::mq.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function: