GNUnet 0.28.1-dev.4-47-g3e168ca2d
 
Loading...
Searching...
No Matches
plugin_dhtu_gnunet.c File Reference

plain IP based DHT network underlay More...

Include dependency graph for plugin_dhtu_gnunet.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_DHTU_Source
 Opaque handle that the underlay offers for our address to be used when sending messages to another peer. More...
 
struct  GNUNET_DHTU_Target
 Opaque handle that the underlay offers for the target peer when sending messages to another peer. More...
 
struct  GNUNET_DHTU_PreferenceHandle
 Opaque handle expressing a preference of the DHT to keep a particular target connected. More...
 
struct  Plugin
 Handle for a plugin. More...
 

Functions

static void gnunet_try_connect (void *cls, const struct GNUNET_PeerIdentity *pid, const char *address)
 Request creation of a session with a peer at the given address.
 
static struct GNUNET_DHTU_PreferenceHandlegnunet_hold (void *cls, struct GNUNET_DHTU_Target *target)
 Request underlay to keep the connection to target alive if possible.
 
static void gnunet_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
 Do no long request underlay to keep the connection alive.
 
static void gnunet_send (void *cls, struct GNUNET_DHTU_Target *target, const void *msg, size_t msg_size, GNUNET_SCHEDULER_TaskCallback finished_cb, void *finished_cb_cls)
 Send message to some other participant over the network.
 
static void * core_connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq, enum GNUNET_CORE_PeerClass class)
 Method called whenever a given peer connects.
 
static void core_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
 Method called whenever a peer disconnects.
 
static void add_addr (void *cls, const struct GNUNET_PeerIdentity *pid, const char *addr)
 
static void peerinfo_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 Find the hello for our identity and then pass it to the DHT as a URL.
 
static void error_cb (void *cls)
 
static void sync_cb (void *cls)
 
static void core_init_cb (void *cls, const struct GNUNET_PeerIdentity *identity)
 Function called after GNUNET_CORE_connect has succeeded (or failed for good).
 
static int check_core_message (void *cls, const struct GNUNET_MessageHeader *msg)
 Anything goes, always return GNUNET_OK.
 
static void handle_core_message (void *cls, const struct GNUNET_MessageHeader *msg)
 Handle message from CORE for the DHT.
 
static void nse_cb (void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev)
 Callback to call when network size estimate is updated.
 
void * DHTU_gnunet_done (struct GNUNET_DHTU_PluginFunctions *api)
 Exit point from the plugin.
 
struct GNUNET_DHTU_PluginFunctionsDHTU_gnunet_init (struct GNUNET_DHTU_PluginEnvironment *env)
 Entry point for the plugin.
 

Detailed Description

plain IP based DHT network underlay

Author
Christian Grothoff

Definition in file plugin_dhtu_gnunet.c.

Function Documentation

◆ gnunet_try_connect()

static void gnunet_try_connect ( void *  cls,
const struct GNUNET_PeerIdentity pid,
const char *  address 
)
static

Request creation of a session with a peer at the given address.

Parameters
clsclosure (internal context for the plugin)
pidtarget identity of the peer to connect to
addresstarget address to connect to

Definition at line 188 of file plugin_dhtu_gnunet.c.

191{
192 struct Plugin *plugin = cls;
193 enum GNUNET_NetworkType nt = 0;
194 char *addr;
195 const char *eou;
196 int pfx_len;
197
198 eou = strstr (address,
199 "://");
200 if (NULL == eou)
201 {
202 GNUNET_break (0);
203 return;
204 }
205 pfx_len = eou - address;
206 eou += 3;
207 GNUNET_asprintf (&addr,
208 "%.*s-%s",
209 pfx_len,
210 address,
211 eou);
213 pid,
214 nt,
215 addr);
216 GNUNET_free (addr);
217}
static struct GNUNET_TESTING_PluginFunctions * plugin
Plugin to dynamically load a test case.
static char * address
GNS address for this phone.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
void GNUNET_TRANSPORT_application_validate(struct GNUNET_TRANSPORT_ApplicationHandle *ch, const struct GNUNET_PeerIdentity *peer, enum GNUNET_NetworkType nt, const char *addr)
An application (or a communicator) has received a HELLO (or other address data of another peer) and w...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Handle for a plugin.
Definition block.c:38

References address, GNUNET_asprintf(), GNUNET_break, GNUNET_free, GNUNET_TRANSPORT_application_validate(), nt, and plugin.

Referenced by DHTU_gnunet_init().

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

◆ gnunet_hold()

static struct GNUNET_DHTU_PreferenceHandle * gnunet_hold ( void *  cls,
struct GNUNET_DHTU_Target target 
)
static

Request underlay to keep the connection to target alive if possible.

Hold may be called multiple times to express a strong preference to keep a connection, say because a target is in multiple tables.

Parameters
clsclosure
targetconnection to keep alive

Definition at line 229 of file plugin_dhtu_gnunet.c.

231{
232 struct Plugin *plugin = cls;
234
236 ph->target = target;
239 ph);
240 target->ph_count++;
241 if (NULL != target->ash)
243 target->ash
245 &target->pid,
248 return ph;
249}
struct GNUNET_TRANSPORT_ApplicationSuggestHandle * GNUNET_TRANSPORT_application_suggest(struct GNUNET_TRANSPORT_ApplicationHandle *ch, const struct GNUNET_PeerIdentity *peer, enum GNUNET_MQ_PriorityPreferences pk, struct GNUNET_BANDWIDTH_Value32NBO bw)
An application would like TRANSPORT to connect to a peer.
void GNUNET_TRANSPORT_application_suggest_cancel(struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh)
We no longer care about being connected to a peer.
#define GNUNET_BANDWIDTH_ZERO
Convenience definition to use for 0-bandwidth.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
@ GNUNET_MQ_PRIO_BEST_EFFORT
Best-effort traffic (e.g.
Opaque handle expressing a preference of the DHT to keep a particular target connected.
struct GNUNET_DHTU_Target * target
Target a preference was expressed for.
struct GNUNET_TRANSPORT_ApplicationSuggestHandle * ash
Transport suggest handle.
struct GNUNET_DHTU_PreferenceHandle * ph_head
Head of preferences expressed for this target.
unsigned int ph_count
Preference counter, length of the ph_head DLL.
struct GNUNET_DHTU_PreferenceHandle * ph_tail
Tail of preferences expressed for this target.
struct GNUNET_PeerIdentity pid
Identity of this peer.

References GNUNET_DHTU_Target::ash, GNUNET_BANDWIDTH_ZERO, GNUNET_CONTAINER_DLL_insert, GNUNET_MQ_PRIO_BEST_EFFORT, GNUNET_new, GNUNET_TRANSPORT_application_suggest(), GNUNET_TRANSPORT_application_suggest_cancel(), GNUNET_DHTU_Target::ph_count, GNUNET_DHTU_Target::ph_head, GNUNET_DHTU_Target::ph_tail, GNUNET_DHTU_Target::pid, plugin, and GNUNET_DHTU_PreferenceHandle::target.

Referenced by DHTU_gnunet_init().

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

◆ gnunet_drop()

static void gnunet_drop ( struct GNUNET_DHTU_PreferenceHandle ph)
static

Do no long request underlay to keep the connection alive.

Parameters
clsclosure
targetconnection to keep alive

Definition at line 259 of file plugin_dhtu_gnunet.c.

260{
261 struct GNUNET_DHTU_Target *target = ph->target;
262 struct Plugin *plugin = target->plugin;
263
265 target->ph_tail,
266 ph);
267 target->ph_count--;
268 GNUNET_free (ph);
269 if (NULL != target->ash)
271 if (0 == target->ph_count)
272 target->ash = NULL;
273 else
274 target->ash
276 &target->pid,
279}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Opaque handle that the underlay offers for the target peer when sending messages to another peer.
struct Plugin * plugin
Our plugin with its environment.

References GNUNET_DHTU_Target::ash, GNUNET_BANDWIDTH_ZERO, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_PRIO_BEST_EFFORT, GNUNET_TRANSPORT_application_suggest(), GNUNET_TRANSPORT_application_suggest_cancel(), GNUNET_DHTU_Target::ph_count, GNUNET_DHTU_Target::ph_head, GNUNET_DHTU_Target::ph_tail, GNUNET_DHTU_Target::pid, plugin, GNUNET_DHTU_Target::plugin, and GNUNET_DHTU_PreferenceHandle::target.

Referenced by DHTU_gnunet_init().

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

◆ gnunet_send()

static void gnunet_send ( void *  cls,
struct GNUNET_DHTU_Target target,
const void *  msg,
size_t  msg_size,
GNUNET_SCHEDULER_TaskCallback  finished_cb,
void *  finished_cb_cls 
)
static

Send message to some other participant over the network.

Note that sending is not guaranteeing that the other peer actually received the message. For any given target, the DHT must wait for the finished_cb to be called before calling send() again.

Parameters
clsclosure (internal context for the plugin)
targetreceiver identification
msgmessage
msg_sizenumber of bytes in msg
finished_cbfunction called once transmission is done (not called if target disconnects, then only the disconnect_cb is called).
finished_cb_clsclosure for finished_cb

Definition at line 298 of file plugin_dhtu_gnunet.c.

304{
305 struct GNUNET_MQ_Envelope *env;
306 struct GNUNET_MessageHeader *cmsg;
307
308 env = GNUNET_MQ_msg_extra (cmsg,
309 msg_size,
313 finished_cb_cls);
314 memcpy (&cmsg[1],
315 msg,
316 msg_size);
317 GNUNET_MQ_send (target->mq,
318 env);
319}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
static void finished_cb(void *cls, enum GNUNET_GenericReturnValue rv)
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:337
#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:687
#define GNUNET_MESSAGE_TYPE_DHT_CORE
Encapsulation of DHT messages in CORE service.
struct GNUNET_MQ_Handle * mq
CORE MQ to send messages to this peer.
Header for all communications.

References env, finished_cb(), GNUNET_MESSAGE_TYPE_DHT_CORE, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_DHTU_Target::mq, and msg.

Referenced by DHTU_gnunet_init().

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

◆ core_connect_cb()

static void * core_connect_cb ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_MQ_Handle mq,
enum GNUNET_CORE_PeerClass  class 
)
static

Method called whenever a given peer connects.

Parameters
clsclosure
peerpeer identity this notification is about
classclass of the connecting peer
Returns
closure associated with peer. given to mq callbacks and GNUNET_CORE_DisconnectEventHandler

Definition at line 332 of file plugin_dhtu_gnunet.c.

336{
337 struct Plugin *plugin = cls;
338 struct GNUNET_DHTU_Target *target;
339
340 target = GNUNET_new (struct GNUNET_DHTU_Target);
341 target->plugin = plugin;
342 target->mq = mq;
343 target->pid = *peer;
344 plugin->env->connect_cb (plugin->env->cls,
345 target,
346 &target->pid,
347 &target->app_ctx);
348 return target;
349}
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.
void * app_ctx
Application context for this target.
void * cls
Closure to pass to start_testcase.

References GNUNET_DHTU_Target::app_ctx, GNUNET_TESTING_PluginFunctions::cls, GNUNET_new, mq, GNUNET_DHTU_Target::mq, GNUNET_DHTU_Target::pid, plugin, and GNUNET_DHTU_Target::plugin.

Referenced by DHTU_gnunet_init().

Here is the caller graph for this function:

◆ core_disconnect_cb()

static void core_disconnect_cb ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  peer_cls 
)
static

Method called whenever a peer disconnects.

Parameters
clsclosure
peerpeer identity this notification is about
peer_clsclosure associated with peer. given in GNUNET_CORE_ConnectEventHandler

Definition at line 361 of file plugin_dhtu_gnunet.c.

364{
365 struct Plugin *plugin = cls;
366 struct GNUNET_DHTU_Target *target = peer_cls;
367
368 plugin->env->disconnect_cb (target->app_ctx);
369 if (NULL != target->ash)
371 GNUNET_free (target);
372}

References GNUNET_DHTU_Target::app_ctx, GNUNET_DHTU_Target::ash, GNUNET_free, GNUNET_TRANSPORT_application_suggest_cancel(), and plugin.

Referenced by DHTU_gnunet_init().

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

◆ add_addr()

static void add_addr ( void *  cls,
const struct GNUNET_PeerIdentity pid,
const char *  addr 
)
static

Definition at line 376 of file plugin_dhtu_gnunet.c.

379{
380 struct Plugin *plugin = cls;
381
383 "peerinfo_cb addr %s\n",
384 addr);
385 plugin->env->address_add_cb (plugin->env->cls,
386 addr,
387 &plugin->src,
388 &plugin->src.app_ctx);
389}
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG

References GNUNET_TESTING_PluginFunctions::cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and plugin.

Referenced by peerinfo_cb().

Here is the caller graph for this function:

◆ peerinfo_cb()

static void peerinfo_cb ( void *  cls,
const struct GNUNET_PEERSTORE_Record record,
const char *  emsg 
)
static

Find the hello for our identity and then pass it to the DHT as a URL.

Note that we only add addresses, never remove them, due to limitations of the current peerinfo/core/transport APIs. This will change with TNG.

Parameters
clsa struct Plugin
peerid of the peer, NULL for last call
hellohello message for the peer (can be NULL)
err_msgmessage

Definition at line 405 of file plugin_dhtu_gnunet.c.

408{
409 const struct GNUNET_PeerIdentity *my_identity;
410 struct Plugin *plugin = cls;
412 struct GNUNET_MessageHeader *hello;
413
414 if (NULL != emsg)
415 {
416 /* @a record is NULL in this case. */
418 "Got failure from PEERSTORE: %s\n",
419 emsg);
420 GNUNET_PEERSTORE_monitor_next (plugin->peerstore_notify, 1);
421 return;
422 }
423 if (NULL == record)
424 {
425 GNUNET_break (0);
426 GNUNET_PEERSTORE_monitor_next (plugin->peerstore_notify, 1);
427 return;
428 }
429 hello = record->value;
430 if (NULL == hello)
431 {
432 GNUNET_PEERSTORE_monitor_next (plugin->peerstore_notify, 1);
433 return;
434 }
436 if (! my_identity)
437 {
438 GNUNET_PEERSTORE_monitor_next (plugin->peerstore_notify, 1);
439 return;
440 }
441 if (0 != GNUNET_memcmp (&record->peer, my_identity))
442 {
443 GNUNET_PEERSTORE_monitor_next (plugin->peerstore_notify, 1);
444 return;
445 }
447 if (NULL == parser)
448 {
449 /* PEERSTORE values are unvalidated blobs from remote peers;
450 #GNUNET_HELLO_parser_iterate() would dereference NULL here. */
452 "HELLO from PEERSTORE cannot be parsed!\n");
453 GNUNET_PEERSTORE_monitor_next (plugin->peerstore_notify, 1);
454 return;
455 }
457 add_addr,
458 plugin);
460 GNUNET_PEERSTORE_monitor_next (plugin->peerstore_notify, 1);
461}
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static struct GNUNET_PeerIdentity my_identity
Identity of this 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:875
void GNUNET_HELLO_parser_free(struct GNUNET_HELLO_Parser *parser)
Release resources of a builder.
Definition hello-uri.c:380
const struct GNUNET_PeerIdentity * GNUNET_HELLO_parser_iterate(const struct GNUNET_HELLO_Parser *parser, GNUNET_HELLO_UriCallback uc, void *uc_cls)
Iterate over URIs in a parser.
Definition hello-uri.c:1052
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_msg(const struct GNUNET_MessageHeader *msg, const struct GNUNET_PeerIdentity *pid)
Parse msg.
Definition hello-uri.c:416
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
@ GNUNET_ERROR_TYPE_WARNING
void GNUNET_PEERSTORE_monitor_next(struct GNUNET_PEERSTORE_Monitor *zm, uint64_t limit)
Calls the monitor processor specified in GNUNET_PEERSTORE_monitor_start for the next record(s).
static void add_addr(void *cls, const struct GNUNET_PeerIdentity *pid, const char *addr)
Context for parsing HELLOs.
Definition hello-uri.c:233
The identity of the host (wraps the signing key of the peer).

References add_addr(), GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_HELLO_parser_free(), GNUNET_HELLO_parser_from_msg(), GNUNET_HELLO_parser_iterate(), GNUNET_log, GNUNET_memcmp, GNUNET_PEERSTORE_monitor_next(), GNUNET_PILS_get_identity(), my_identity, plugin, and record().

Referenced by core_init_cb().

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

◆ error_cb()

static void error_cb ( void *  cls)
static

Definition at line 465 of file plugin_dhtu_gnunet.c.

466{
468 "Error in PEERSTORE monitoring\n");
469}

References GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.

Referenced by core_init_cb().

Here is the caller graph for this function:

◆ sync_cb()

static void sync_cb ( void *  cls)
static

Definition at line 473 of file plugin_dhtu_gnunet.c.

474{
476 "Done with initial PEERSTORE iteration during monitoring\n");
477}

References GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.

Referenced by core_init_cb().

Here is the caller graph for this function:

◆ core_init_cb()

static void core_init_cb ( void *  cls,
const struct GNUNET_PeerIdentity identity 
)
static

Function called after GNUNET_CORE_connect has succeeded (or failed for good).

Note that the private key of the peer is intentionally not exposed here; if you need it, your process should try to read the private key file directly (which should work if you are authorized...). Implementations of this function must not call GNUNET_CORE_disconnect (other than by scheduling a new task to do this later).

Parameters
clsclosure
my_identityID of this peer, NULL if we failed

Definition at line 493 of file plugin_dhtu_gnunet.c.

495{
496 struct Plugin *plugin = cls;
497
498 if (NULL == identity)
499 return;
500
501 plugin->peerstore_notify = GNUNET_PEERSTORE_monitor_start (plugin->env->cfg,
503 "peerstore",
504 NULL,
506 &error_cb,
507 NULL,
508 &sync_cb,
509 NULL,
511 plugin);
512}
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
@ GNUNET_YES
struct GNUNET_PEERSTORE_Monitor * GNUNET_PEERSTORE_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, int iterate_first, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Request watching a given key The monitoring can be filtered to contain only records matching peer and...
#define GNUNET_PEERSTORE_HELLO_KEY
Key used for storing HELLO in the peerstore.
static void sync_cb(void *cls)
static void error_cb(void *cls)
static void peerinfo_cb(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
Find the hello for our identity and then pass it to the DHT as a URL.

References error_cb(), GNUNET_PEERSTORE_HELLO_KEY, GNUNET_PEERSTORE_monitor_start(), GNUNET_YES, identity, peerinfo_cb(), plugin, and sync_cb().

Referenced by DHTU_gnunet_init().

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

◆ check_core_message()

static int check_core_message ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Anything goes, always return GNUNET_OK.

Parameters
clsunused
msgmessage to check
Returns
GNUNET_OK if all is fine

Definition at line 523 of file plugin_dhtu_gnunet.c.

525{
526 (void) cls;
527 (void) msg;
528 return GNUNET_OK;
529}
@ GNUNET_OK

References GNUNET_OK, and msg.

◆ handle_core_message()

static void handle_core_message ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Handle message from CORE for the DHT.

Passes it to the DHT logic.

Parameters
clsa struct GNUNET_DHTU_Target of the sender
msgthe message we received

Definition at line 540 of file plugin_dhtu_gnunet.c.

542{
543 struct GNUNET_DHTU_Target *origin = cls;
544 struct Plugin *plugin = origin->plugin;
545
546 plugin->env->receive_cb (plugin->env->cls,
547 &origin->app_ctx,
548 &plugin->src.app_ctx,
549 &msg[1],
550 ntohs (msg->size) - sizeof (*msg));
551}
static char origin[GNUNET_DNSPARSER_MAX_NAME_LENGTH]
Current origin.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References GNUNET_TESTING_PluginFunctions::cls, msg, origin, plugin, and GNUNET_MessageHeader::size.

◆ nse_cb()

static void nse_cb ( void *  cls,
struct GNUNET_TIME_Absolute  timestamp,
double  logestimate,
double  std_dev 
)
static

Callback to call when network size estimate is updated.

Parameters
clsclosure
timestamptime when the estimate was received from the server (or created by the server)
logestimatethe log(Base 2) value of the current network size estimate
std_devstandard deviation for the estimate

Definition at line 563 of file plugin_dhtu_gnunet.c.

567{
568 struct Plugin *plugin = cls;
569
570 plugin->env->network_size_cb (plugin->env->cls,
571 timestamp,
572 logestimate,
573 std_dev);
574}
static uint64_t timestamp(void)
Get current timestamp.

References GNUNET_TESTING_PluginFunctions::cls, plugin, and timestamp().

Referenced by DHTU_gnunet_init().

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

◆ DHTU_gnunet_done()

void * DHTU_gnunet_done ( struct GNUNET_DHTU_PluginFunctions api)

Exit point from the plugin.

Parameters
clsclosure (our struct Plugin)
Returns
NULL

Definition at line 584 of file plugin_dhtu_gnunet.c.

585{
586 struct Plugin *plugin = api->cls;
587
588 if (NULL != plugin->nse)
590 plugin->env->network_size_cb (plugin->env->cls,
592 0.0,
593 0.0);
594 if (NULL != plugin->core)
596 if (NULL != plugin->transport)
598 if (NULL != plugin->peerstore_notify)
599 GNUNET_PEERSTORE_monitor_stop (plugin->peerstore_notify);
600 if (NULL != plugin->peerstore)
602 // GPI_plugins_unload ();
603 if (plugin->pils)
607 return NULL;
608}
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition pils_api.c:647
void GNUNET_TRANSPORT_application_done(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Shutdown TRANSPORT application client.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition core_api.c:744
void GNUNET_NSE_disconnect(struct GNUNET_NSE_Handle *h)
Disconnect from network size estimation service.
Definition nse_api.c:192
void GNUNET_PEERSTORE_monitor_stop(struct GNUNET_PEERSTORE_Monitor *zm)
Stop monitoring.
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the PEERSTORE service.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
void * cls
Closure for all of the callbacks.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition block.c:47

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_TESTING_PluginFunctions::cls, GNUNET_CORE_disconnect(), GNUNET_free, GNUNET_NSE_disconnect(), GNUNET_PEERSTORE_disconnect(), GNUNET_PEERSTORE_monitor_stop(), GNUNET_PILS_disconnect(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TRANSPORT_application_done(), and plugin.

Referenced by DHTU_gnunet_init(), and shutdown_task().

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

◆ DHTU_gnunet_init()

struct GNUNET_DHTU_PluginFunctions * DHTU_gnunet_init ( struct GNUNET_DHTU_PluginEnvironment env)

Entry point for the plugin.

Parameters
clsclosure (the struct GNUNET_DHTU_PluginEnvironment)
Returns
the plugin's API

Definition at line 618 of file plugin_dhtu_gnunet.c.

619{
620 struct GNUNET_DHTU_PluginFunctions *api;
621 struct Plugin *plugin;
623 GNUNET_MQ_hd_var_size (core_message,
626 NULL),
628 };
629 const struct GNUNET_CORE_ServiceInfo service_info = {
631 .version = { 1, 0 },
632 .version_max = { 1, 0 },
633 .version_min = { 1, 0 },
634 };
635
636 plugin = GNUNET_new (struct Plugin);
638 env->cfg, NULL, NULL);
639 plugin->env = env;
641 api->cls = plugin;
643 api->hold = &gnunet_hold;
644 api->drop = &gnunet_drop;
645 api->send = &gnunet_send;
646 plugin->peerstore = GNUNET_PEERSTORE_connect (env->cfg);
647 plugin->transport = GNUNET_TRANSPORT_application_init (env->cfg);
648 plugin->core = GNUNET_CORE_connect (env->cfg,
649 plugin,
653 handlers,
654 &service_info);
655 plugin->nse = GNUNET_NSE_connect (env->cfg,
656 &nse_cb,
657 plugin);
658 if ( (NULL == plugin->transport) ||
659 (NULL == plugin->core) ||
660 (NULL == plugin->nse) )
661 {
662 GNUNET_break (0);
663 DHTU_gnunet_done (api);
664 return NULL;
665 }
666 // GPI_plugins_load (env->cfg);
667 return api;
668}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition 003.c:1
struct GNUNET_PILS_Handle * GNUNET_PILS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
Connect to the PILS service.
Definition pils_api.c:624
struct GNUNET_TRANSPORT_ApplicationHandle * GNUNET_TRANSPORT_application_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the TRANSPORT application client handle.
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers, const struct GNUNET_CORE_ServiceInfo *service_info)
Connect to the core service.
Definition core_api.c:698
@ GNUNET_CORE_SERVICE_DHT
Identifier for dht (distributed hash table) service.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_NSE_Handle * GNUNET_NSE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NSE_Callback func, void *func_cls)
Connect to the network size estimation service.
Definition nse_api.c:164
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
static void * core_connect_cb(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq, enum GNUNET_CORE_PeerClass class)
Method called whenever a given peer connects.
void * DHTU_gnunet_done(struct GNUNET_DHTU_PluginFunctions *api)
Exit point from the plugin.
static void gnunet_drop(struct GNUNET_DHTU_PreferenceHandle *ph)
Do no long request underlay to keep the connection alive.
static void core_disconnect_cb(void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
Method called whenever a peer disconnects.
static void core_init_cb(void *cls, const struct GNUNET_PeerIdentity *identity)
Function called after GNUNET_CORE_connect has succeeded (or failed for good).
static void gnunet_try_connect(void *cls, const struct GNUNET_PeerIdentity *pid, const char *address)
Request creation of a session with a peer at the given address.
static void nse_cb(void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev)
Callback to call when network size estimate is updated.
static struct GNUNET_DHTU_PreferenceHandle * gnunet_hold(void *cls, struct GNUNET_DHTU_Target *target)
Request underlay to keep the connection to target alive if possible.
static void gnunet_send(void *cls, struct GNUNET_DHTU_Target *target, const void *msg, size_t msg_size, GNUNET_SCHEDULER_TaskCallback finished_cb, void *finished_cb_cls)
Send message to some other participant over the network.
Gnunet service info - identifying compatibility with a range of version of a service communicating ov...
enum GNUNET_CORE_Service service
Identifier of the service on top of CORE.
struct returned by the initialization function of the plugin
void(* try_connect)(void *cls, const struct GNUNET_PeerIdentity *pid, const char *address)
Request creation of a session with a peer at the given address.
void * cls
Closure to pass to all plugin functions.
struct GNUNET_DHTU_PreferenceHandle *(* hold)(void *cls, struct GNUNET_DHTU_Target *target)
Request underlay to keep the connection to target alive if possible.
void(* drop)(struct GNUNET_DHTU_PreferenceHandle *ph)
Do no longer request underlay to keep the connection alive.
void(* send)(void *cls, struct GNUNET_DHTU_Target *target, const void *msg, size_t msg_size, GNUNET_SCHEDULER_TaskCallback finished_cb, void *finished_cb_cls)
Send message to some other participant over the network.
Message handler for a specific message type.

References GNUNET_DHTU_PluginFunctions::cls, core_connect_cb(), core_disconnect_cb(), core_init_cb(), DHTU_gnunet_done(), GNUNET_DHTU_PluginFunctions::drop, env, GNUNET_break, GNUNET_CORE_connect(), GNUNET_CORE_SERVICE_DHT, gnunet_drop(), gnunet_hold(), GNUNET_MESSAGE_TYPE_DHT_CORE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_NSE_connect(), GNUNET_PEERSTORE_connect(), GNUNET_PILS_connect(), gnunet_send(), GNUNET_TRANSPORT_application_init(), gnunet_try_connect(), handlers, GNUNET_DHTU_PluginFunctions::hold, nse_cb(), plugin, GNUNET_DHTU_PluginFunctions::send, GNUNET_CORE_ServiceInfo::service, and GNUNET_DHTU_PluginFunctions::try_connect.

Referenced by load_underlay().

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