GNUnet 0.28.0
 
Loading...
Searching...
No Matches
gnunet-service-cadet_dht.c File Reference

Information we track per peer. More...

Include dependency graph for gnunet-service-cadet_dht.c:

Go to the source code of this file.

Data Structures

struct  GCD_search_handle
 

Macros

#define STARTUP_DELAY
 How long do we wait before first announcing our presence to the DHT.
 
#define CHANGE_DELAY
 How long do we wait after we get an updated HELLO before publishing? Allows for the HELLO to be updated again quickly, for example in case multiple addresses changed and we got a partial update.
 
#define LOG(level, ...)   GNUNET_log_from (level, "cadet-dht", __VA_ARGS__)
 

Functions

static void dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, 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)
 Function to process paths received for a new peer addition.
 
static void announce_id (void *cls)
 
void GCD_hello_update ()
 Function called by the HELLO subsystem whenever OUR hello changes.
 
void GCD_init (const struct GNUNET_CONFIGURATION_Handle *c)
 Initialize the DHT subsystem.
 
void GCD_shutdown (void)
 Shut down the DHT subsystem.
 
struct GCD_search_handleGCD_search (const struct GNUNET_PeerIdentity *peer_id)
 Search DHT for paths to peeR_id.
 
void GCD_search_stop (struct GCD_search_handle *h)
 Stop DHT search started with GCD_search().
 

Variables

static struct GNUNET_DHT_Handledht_handle
 Handle to use DHT.
 
static struct GNUNET_TIME_Relative id_announce_time
 How often to PUT own ID in the DHT.
 
static unsigned long long dht_replication_level
 DHT replication level, see DHT API: GNUNET_DHT_get_start(), GNUNET_DHT_put().
 
static struct GNUNET_SCHEDULER_Taskannounce_id_task
 Task to periodically announce itself in the network.
 
static struct GNUNET_TIME_Relative announce_delay
 Delay for the next ID announce.
 

Detailed Description

Information we track per peer.

Author
Bartlomiej Polot
Christian Grothoff

Definition in file gnunet-service-cadet_dht.c.

Macro Definition Documentation

◆ STARTUP_DELAY

#define STARTUP_DELAY
Value:
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
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

How long do we wait before first announcing our presence to the DHT.

Used to wait for our HELLO to be available. Note that we also get notifications when our HELLO is ready, so this is just the maximum we wait for the first notification.

Definition at line 45 of file gnunet-service-cadet_dht.c.

60{
64 struct GNUNET_DHT_GetHandle *dhtget;
65};
66
67
71static struct GNUNET_DHT_Handle *dht_handle;
72
77
81static unsigned long long dht_replication_level;
82
87
92
93
111static void
112dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
113 const struct GNUNET_HashCode *key,
114 const struct GNUNET_PeerIdentity *trunc_peer,
115 const struct GNUNET_DHT_PathElement *get_path,
116 unsigned int get_path_length,
117 const struct GNUNET_DHT_PathElement *put_path,
118 unsigned int put_path_length,
120 size_t size,
121 const void *data)
122{
123 const struct GNUNET_MessageHeader *hello = data;
124 struct CadetPeer *peer;
125
126 (void) trunc_peer;
127 GCPP_try_path_from_dht (get_path,
128 get_path_length,
129 put_path,
130 put_path_length);
131
132
133 if (0 == put_path_length)
134 return;
135 peer = GCP_get (&put_path[0].pred,
136 GNUNET_YES);
138 "Got HELLO for %s\n",
139 GCP_2s (peer));
140 GCP_set_hello (peer,
141 hello);
142}
143
144
145static void
146announce_id (void*cls)
147{
148 const struct GNUNET_PeerIdentity *my_identity;
149 struct GNUNET_HashCode phash;
150 const struct GNUNET_MessageHeader *hello;
151 size_t size;
152 size_t block_size;
153 void *block;
155 struct GNUNET_TIME_Relative next_put;
156
158 if (NULL == my_identity)
159 {
163 NULL);
164 return;
165 }
166
167 hello = GCH_get_mine ();
168 size = (NULL != hello) ? ntohs (hello->size) : 0;
169 if (0 == size)
170 {
174 }
175 else
176 {
179 }
180
181 /* Call again in id_announce_time, unless HELLO expires first,
182 * but wait at least 1s. */
183 next_put
185 next_put
186 = GNUNET_TIME_relative_min (next_put,
188 next_put
189 = GNUNET_TIME_relative_max (next_put,
194 NULL);
196 "# DHT announce",
197 1,
198 GNUNET_NO);
199 memset (&phash,
200 0,
201 sizeof(phash));
202 GNUNET_memcpy (&phash, my_identity,
203 sizeof(*my_identity));
204 if ((0 == size) ||
207 &block,
208 &block_size,
209 &expiration)))
210 return;
211
213 "Announcing my HELLO (%lu bytes) in the DHT\n",
214 (unsigned long) block_size);
215 GNUNET_DHT_put (dht_handle, /* DHT handle */
216 &phash, /* Key to use */
217 dht_replication_level, /* Replication level */
219 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, /* DHT options */
220 GNUNET_BLOCK_TYPE_DHT_HELLO, /* Block type */
221 block_size, /* Size of the data */
222 (const char *) block, /* Data itself */
223 expiration, /* Data expiration */
224 NULL, /* Continuation */
225 NULL); /* Continuation closure */
226 GNUNET_free (block);
227}
228
229
230void
232{
233 if (NULL == announce_id_task)
234 return; /* too early */
239 NULL);
240}
241
242
243void
245{
246 if (GNUNET_OK !=
248 "CADET",
249 "DHT_REPLICATION_LEVEL",
251 {
253 "CADET",
254 "DHT_REPLICATION_LEVEL",
255 "USING DEFAULT");
257 }
258
259 if (GNUNET_OK !=
261 "CADET",
262 "ID_ANNOUNCE_TIME",
264 {
266 "CADET",
267 "ID_ANNOUNCE_TIME",
268 "MISSING");
270 return;
271 }
272
274 64);
275 GNUNET_break (NULL != dht_handle);
279 NULL);
280}
281
282
283void
284GCD_shutdown (void)
285{
286 if (NULL != dht_handle)
287 {
289 dht_handle = NULL;
290 }
291 if (NULL != announce_id_task)
292 {
294 announce_id_task = NULL;
295 }
296}
297
298
299struct GCD_search_handle *
301{
302 struct GNUNET_HashCode phash;
303 struct GCD_search_handle *h;
304
306 "# DHT search",
307 1,
308 GNUNET_NO);
309 memset (&phash,
310 0,
311 sizeof(phash));
312 GNUNET_memcpy (&phash,
313 peer_id,
314 sizeof(*peer_id));
315
316 h = GNUNET_new (struct GCD_search_handle);
317 h->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */
319 &phash, /* key to search */
320 dht_replication_level, /* replication level */
323 NULL, /* xquery */
324 0, /* xquery bits */
326 h);
328 "Starting DHT GET for peer %s (%p)\n",
330 h);
331 return h;
332}
333
334
335void
337{
339 "Stopping DHT GET %p\n",
340 h);
341 GNUNET_DHT_get_stop (h->dhtget);
342 GNUNET_free (h);
343}
344
345
346/* end of gnunet-service-cadet_dht.c */
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
static char * peer_id
Option –peer.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_PILS_Handle * pils
Handle to PILS.
Definition gnunet-pils.c:44
static struct GNUNET_SCHEDULER_Task * announce_id_task
Task to periodically announce itself in the network.
static struct GNUNET_TIME_Relative id_announce_time
How often to PUT own ID in the DHT.
#define CHANGE_DELAY
How long do we wait after we get an updated HELLO before publishing? Allows for the HELLO to be updat...
static unsigned long long dht_replication_level
DHT replication level, see DHT API: GNUNET_DHT_get_start(), GNUNET_DHT_put().
static struct GNUNET_TIME_Relative announce_delay
Delay for the next ID announce.
void GCD_search_stop(struct GCD_search_handle *h)
Stop DHT search started with GCD_search().
static void announce_id(void *cls)
static struct GNUNET_DHT_Handle * dht_handle
Handle to use DHT.
void GCD_hello_update()
Function called by the HELLO subsystem whenever OUR hello changes.
void GCD_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the DHT subsystem.
struct GCD_search_handle * GCD_search(const struct GNUNET_PeerIdentity *peer_id)
Search DHT for paths to peeR_id.
#define STARTUP_DELAY
How long do we wait before first announcing our presence to the DHT.
#define LOG(level,...)
static void dht_get_id_handler(void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, 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)
Function to process paths received for a new peer addition.
void GCD_shutdown(void)
Shut down the DHT subsystem.
struct GNUNET_MessageHeader * GCH_get_mine()
Get own hello message.
void GCPP_try_path_from_dht(const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length)
Create a peer path based on the result of a DHT lookup.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer structure associated with the peer.
void GCP_set_hello(struct CadetPeer *cp, const struct GNUNET_MessageHeader *hello)
We got a HELLO for a cp, remember it, and possibly trigger adequate actions (like trying to connect).
const char * GCP_2s(const struct CadetPeer *cp)
Get the static string for a peer ID.
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
@ GNUNET_BLOCK_TYPE_DHT_HELLO
Type of a block that contains a DHT-NG HELLO for a peer.
const struct GNUNET_PeerIdentity * GNUNET_PILS_get_identity(const struct GNUNET_PILS_Handle *handle)
Return the current peer identity of a given handle.
Definition pils_api.c:727
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
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:1086
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_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition dht_api.c:1238
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:1165
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition dht_api.c:1058
@ GNUNET_DHT_RO_RECORD_ROUTE
We should keep track of the route that the message took in the P2P network.
@ GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
Each peer along the way should process the request (otherwise only peers locally closest to the key w...
enum GNUNET_GenericReturnValue GNUNET_HELLO_dht_msg_to_block(const struct GNUNET_MessageHeader *hello, const struct GNUNET_PeerIdentity *pid, void **block, size_t *block_size, struct GNUNET_TIME_Absolute *block_expiration)
Convert a DHT hello message to a HELLO block.
Definition hello-uri.c:1044
struct GNUNET_TIME_Absolute GNUNET_HELLO_get_expiration_time_from_msg(const struct GNUNET_MessageHeader *msg)
Get the expiration time for this HELLO.
Definition hello-uri.c:633
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:572
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1283
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
Definition time.c:344
struct GNUNET_TIME_Relative GNUNET_TIME_relative_max(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the maximum of two relative time values.
Definition time.c:352
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition time.c:406
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition time.c:452
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static unsigned int size
Size of the "table".
Definition peer.c:68
Struct containing all information regarding a given peer.
struct GNUNET_MessageHeader * hello
Hello message of the peer.
Handle to a GET request.
Definition dht_api.c:79
Connection to the DHT service.
Definition dht_api.c:235
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...
A 512-bit hashcode.
Header for all communications.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition scheduler.c:141
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.

◆ CHANGE_DELAY

#define CHANGE_DELAY
Value:

How long do we wait after we get an updated HELLO before publishing? Allows for the HELLO to be updated again quickly, for example in case multiple addresses changed and we got a partial update.

Definition at line 53 of file gnunet-service-cadet_dht.c.

◆ LOG

#define LOG (   level,
  ... 
)    GNUNET_log_from (level, "cadet-dht", __VA_ARGS__)

Definition at line 57 of file gnunet-service-cadet_dht.c.

Function Documentation

◆ dht_get_id_handler()

static void dht_get_id_handler ( void *  cls,
struct GNUNET_TIME_Absolute  exp,
const struct GNUNET_HashCode key,
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 
)
static

Function to process paths received for a new peer addition.

The recorded paths form the initial tunnel, which can be optimized later. Called on each result obtained for the DHT search.

Parameters
clsclosure
expwhen will this value expire
keykey of the result
trunc_peerpeer proceeding with invalid signature, or NULL
get_pathpath of the get request
get_path_lengthlength of get_path
put_pathpath of the put request
put_path_lengthlength of the put_path
typetype of the result
sizenumber of bytes in data
datapointer to the result data

Definition at line 113 of file gnunet-service-cadet_dht.c.

123{
124 const struct GNUNET_MessageHeader *hello = data;
125 struct CadetPeer *peer;
126
127 (void) trunc_peer;
128 GCPP_try_path_from_dht (get_path,
129 get_path_length,
130 put_path,
131 put_path_length);
132
133
134 if (0 == put_path_length)
135 return;
136 peer = GCP_get (&put_path[0].pred,
137 GNUNET_YES);
139 "Got HELLO for %s\n",
140 GCP_2s (peer));
141 GCP_set_hello (peer,
142 hello);
143}

References data, GCP_2s(), GCP_get(), GCP_set_hello(), GCPP_try_path_from_dht(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, CadetPeer::hello, and LOG.

Referenced by GCD_search().

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

◆ announce_id()

static void announce_id ( void *  cls)
static

Definition at line 147 of file gnunet-service-cadet_dht.c.

148{
149 const struct GNUNET_PeerIdentity *my_identity;
150 struct GNUNET_HashCode phash;
151 const struct GNUNET_MessageHeader *hello;
152 size_t size;
153 size_t block_size;
154 void *block;
156 struct GNUNET_TIME_Relative next_put;
157
159 if (NULL == my_identity)
160 {
164 NULL);
165 return;
166 }
167
168 hello = GCH_get_mine ();
169 size = (NULL != hello) ? ntohs (hello->size) : 0;
170 if (0 == size)
171 {
175 }
176 else
177 {
180 }
181
182 /* Call again in id_announce_time, unless HELLO expires first,
183 * but wait at least 1s. */
184 next_put
186 next_put
187 = GNUNET_TIME_relative_min (next_put,
189 next_put
190 = GNUNET_TIME_relative_max (next_put,
195 NULL);
197 "# DHT announce",
198 1,
199 GNUNET_NO);
200 memset (&phash,
201 0,
202 sizeof(phash));
203 GNUNET_memcpy (&phash, my_identity,
204 sizeof(*my_identity));
205 if ((0 == size) ||
208 &block,
209 &block_size,
210 &expiration)))
211 return;
212
214 "Announcing my HELLO (%lu bytes) in the DHT\n",
215 (unsigned long) block_size);
216 GNUNET_DHT_put (dht_handle, /* DHT handle */
217 &phash, /* Key to use */
218 dht_replication_level, /* Replication level */
220 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, /* DHT options */
221 GNUNET_BLOCK_TYPE_DHT_HELLO, /* Block type */
222 block_size, /* Size of the data */
223 (const char *) block, /* Data itself */
224 expiration, /* Data expiration */
225 NULL, /* Continuation */
226 NULL); /* Continuation closure */
227 GNUNET_free (block);
228}

References announce_delay, announce_id(), announce_id_task, CHANGE_DELAY, dht_handle, dht_replication_level, expiration, GCH_get_mine(), GNUNET_BLOCK_TYPE_DHT_HELLO, GNUNET_DHT_put(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_dht_msg_to_block(), GNUNET_HELLO_get_expiration_time_from_msg(), GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_PILS_get_identity(), GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_max(), GNUNET_TIME_relative_min(), GNUNET_TIME_STD_BACKOFF, GNUNET_TIME_UNIT_SECONDS, id_announce_time, LOG, my_identity, pils, GNUNET_MessageHeader::size, size, and stats.

Referenced by announce_id(), GCD_hello_update(), and GCD_init().

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

◆ GCD_hello_update()

void GCD_hello_update ( void  )

Function called by the HELLO subsystem whenever OUR hello changes.

Re-triggers the DHT PUT immediately.

Definition at line 232 of file gnunet-service-cadet_dht.c.

233{
234 if (NULL == announce_id_task)
235 return; /* too early */
240 NULL);
241}

References announce_id(), announce_id_task, CHANGE_DELAY, GNUNET_SCHEDULER_add_delayed(), and GNUNET_SCHEDULER_cancel().

Referenced by sign_hello_cb().

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

◆ GCD_init()

void GCD_init ( const struct GNUNET_CONFIGURATION_Handle c)

Initialize the DHT subsystem.

Parameters
cConfiguration.

Definition at line 245 of file gnunet-service-cadet_dht.c.

246{
247 if (GNUNET_OK !=
249 "CADET",
250 "DHT_REPLICATION_LEVEL",
252 {
254 "CADET",
255 "DHT_REPLICATION_LEVEL",
256 "USING DEFAULT");
258 }
259
260 if (GNUNET_OK !=
262 "CADET",
263 "ID_ANNOUNCE_TIME",
265 {
267 "CADET",
268 "ID_ANNOUNCE_TIME",
269 "MISSING");
271 return;
272 }
273
275 64);
276 GNUNET_break (NULL != dht_handle);
280 NULL);
281}

References announce_delay, announce_id(), announce_id_task, dht_handle, dht_replication_level, GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_DHT_connect(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log_config_invalid(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_UNIT_SECONDS, id_announce_time, and STARTUP_DELAY.

Referenced by run().

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

◆ GCD_shutdown()

void GCD_shutdown ( void  )

Shut down the DHT subsystem.

Definition at line 285 of file gnunet-service-cadet_dht.c.

286{
287 if (NULL != dht_handle)
288 {
290 dht_handle = NULL;
291 }
292 if (NULL != announce_id_task)
293 {
295 announce_id_task = NULL;
296 }
297}

References announce_id_task, dht_handle, GNUNET_DHT_disconnect(), and GNUNET_SCHEDULER_cancel().

Referenced by shutdown_rest().

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

◆ GCD_search()

struct GCD_search_handle * GCD_search ( const struct GNUNET_PeerIdentity peer_id)

Search DHT for paths to peeR_id.

Parameters
peer_idpeer to search for
Returns
handle to abort search

Definition at line 301 of file gnunet-service-cadet_dht.c.

302{
303 struct GNUNET_HashCode phash;
304 struct GCD_search_handle *h;
305
307 "# DHT search",
308 1,
309 GNUNET_NO);
310 memset (&phash,
311 0,
312 sizeof(phash));
313 GNUNET_memcpy (&phash,
314 peer_id,
315 sizeof(*peer_id));
316
317 h = GNUNET_new (struct GCD_search_handle);
318 h->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */
320 &phash, /* key to search */
321 dht_replication_level, /* replication level */
324 NULL, /* xquery */
325 0, /* xquery bits */
327 h);
329 "Starting DHT GET for peer %s (%p)\n",
331 h);
332 return h;
333}

References dht_get_id_handler(), dht_handle, dht_replication_level, GNUNET_BLOCK_TYPE_DHT_HELLO, GNUNET_DHT_get_start(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), h, LOG, peer_id, and stats.

Referenced by consider_peer_activate(), and GCP_path_entry_remove().

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

◆ GCD_search_stop()

void GCD_search_stop ( struct GCD_search_handle h)

Stop DHT search started with GCD_search().

Parameters
hhandle to search to stop

Definition at line 337 of file gnunet-service-cadet_dht.c.

338{
340 "Stopping DHT GET %p\n",
341 h);
342 GNUNET_DHT_get_stop (h->dhtget);
343 GNUNET_free (h);
344}

References GNUNET_DHT_get_stop(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, h, and LOG.

Referenced by consider_peer_activate(), destroy_peer(), and GCP_path_entry_add().

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

Variable Documentation

◆ dht_handle

struct GNUNET_DHT_Handle* dht_handle
static

Handle to use DHT.

Definition at line 72 of file gnunet-service-cadet_dht.c.

Referenced by announce_id(), GCD_init(), GCD_search(), and GCD_shutdown().

◆ id_announce_time

struct GNUNET_TIME_Relative id_announce_time
static

How often to PUT own ID in the DHT.

Definition at line 77 of file gnunet-service-cadet_dht.c.

Referenced by announce_id(), and GCD_init().

◆ dht_replication_level

unsigned long long dht_replication_level
static

DHT replication level, see DHT API: GNUNET_DHT_get_start(), GNUNET_DHT_put().

Definition at line 82 of file gnunet-service-cadet_dht.c.

Referenced by announce_id(), GCD_init(), and GCD_search().

◆ announce_id_task

struct GNUNET_SCHEDULER_Task* announce_id_task
static

Task to periodically announce itself in the network.

Definition at line 87 of file gnunet-service-cadet_dht.c.

Referenced by announce_id(), GCD_hello_update(), GCD_init(), and GCD_shutdown().

◆ announce_delay

struct GNUNET_TIME_Relative announce_delay
static

Delay for the next ID announce.

Definition at line 92 of file gnunet-service-cadet_dht.c.

Referenced by announce_id(), and GCD_init().