GNUnet  0.20.0
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  HelloHandle
 Handle for a HELLO we're offering the transport. More...
 
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 hello_offered_cb (void *cls)
 Function called once a hello offer is completed. More...
 
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. More...
 
static struct GNUNET_DHTU_PreferenceHandlegnunet_hold (void *cls, struct GNUNET_DHTU_Target *target)
 Request underlay to keep the connection to target alive if possible. More...
 
static void gnunet_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
 Do no long request underlay to keep the connection alive. More...
 
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. More...
 
static void * core_connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
 Method called whenever a given peer connects. More...
 
static void core_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
 Method called whenever a peer disconnects. More...
 
static void peerinfo_cb (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
 Find the hello for our identity and then pass it to the DHT as a URL. More...
 
static void core_init_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity)
 Function called after GNUNET_CORE_connect has succeeded (or failed for good). More...
 
static int check_core_message (void *cls, const struct GNUNET_MessageHeader *msg)
 Anything goes, always return GNUNET_OK. More...
 
static void handle_core_message (void *cls, const struct GNUNET_MessageHeader *msg)
 Handle message from CORE for the DHT. More...
 
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. More...
 
void * libgnunet_plugin_dhtu_gnunet_done (void *cls)
 Exit point from the plugin. More...
 
void * libgnunet_plugin_dhtu_gnunet_init (void *cls)
 Entry point for the plugin. More...
 

Detailed Description

plain IP based DHT network underlay

Author
Christian Grothoff

Definition in file plugin_dhtu_gnunet.c.

Function Documentation

◆ hello_offered_cb()

static void hello_offered_cb ( void *  cls)
static

Function called once a hello offer is completed.

Parameters
clsa struct HelloHandle

Definition at line 214 of file plugin_dhtu_gnunet.c.

215 {
216  struct HelloHandle *hh = cls;
217  struct Plugin *plugin = hh->plugin;
218 
220  plugin->hh_tail,
221  hh);
222  GNUNET_free (hh);
223 }
struct TestcasePlugin * plugin
The process handle to the testbed service.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Handle for a HELLO we're offering the transport.
struct Plugin * plugin
Our plugin.
Handle for a plugin.
Definition: block.c:38

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, HelloHandle::plugin, and plugin.

Referenced by gnunet_try_connect().

Here is the caller graph for this function:

◆ 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 237 of file plugin_dhtu_gnunet.c.

240 {
241  struct Plugin *plugin = cls;
242  struct GNUNET_HELLO_Message *hello = NULL;
243  struct HelloHandle *hh;
245 
246  (void) pid; /* will be needed with future address URIs */
247  if (GNUNET_OK !=
249  &pubkey,
250  &hello,
252  return;
253  hh = GNUNET_new (struct HelloHandle);
254  hh->plugin = plugin;
256  plugin->hh_tail,
257  hh);
258  hh->ohh = GNUNET_TRANSPORT_offer_hello (plugin->env->cfg,
259  &hello->header,
261  hh);
262  GNUNET_free (hello);
263 }
static char * address
GNS address for this phone.
static struct GNUNET_IDENTITY_PublicKey pubkey
Public key of the zone to look in.
struct GNUNET_TRANSPORT_PluginFunctions * GPI_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
int GNUNET_HELLO_parse_uri(const char *uri, struct GNUNET_CRYPTO_EddsaPublicKey *pubkey, struct GNUNET_HELLO_Message **hello, GNUNET_HELLO_TransportPluginsFind plugins_find)
Parse a hello URI string to a hello message.
Definition: hello.c:1195
@ GNUNET_OK
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TRANSPORT_OfferHelloHandle * GNUNET_TRANSPORT_offer_hello(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_MessageHeader *hello, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Offer the transport service the HELLO of another peer.
static void hello_offered_cb(void *cls)
Function called once a hello offer is completed.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
A HELLO message is used to exchange information about transports with other peers.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_HELLO.
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
Offer handle.

References address, GNUNET_CONTAINER_DLL_insert, GNUNET_free, GNUNET_HELLO_parse_uri(), GNUNET_new, GNUNET_OK, GNUNET_TRANSPORT_offer_hello(), GPI_plugins_find(), GNUNET_HELLO_Message::header, hello_offered_cb(), HelloHandle::ohh, pid, HelloHandle::plugin, plugin, and pubkey.

Referenced by libgnunet_plugin_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 275 of file plugin_dhtu_gnunet.c.

277 {
278  struct Plugin *plugin = cls;
280 
282  ph->target = target;
284  target->ph_tail,
285  ph);
286  target->ph_count++;
287  if (NULL != target->csh)
289  target->csh
291  &target->pid,
292  target->ph_count);
293  return ph;
294 }
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest(struct GNUNET_ATS_ConnectivityHandle *ch, const struct GNUNET_PeerIdentity *peer, uint32_t strength)
We would like to receive address suggestions for a peer.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
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_ATS_ConnectivitySuggestHandle * csh
ATS preference handle for this peer, or NULL.
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::csh, GNUNET_ATS_connectivity_suggest(), GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_CONTAINER_DLL_insert, GNUNET_new, ph, 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 libgnunet_plugin_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 304 of file plugin_dhtu_gnunet.c.

305 {
306  struct GNUNET_DHTU_Target *target = ph->target;
307  struct Plugin *plugin = target->plugin;
308 
310  target->ph_tail,
311  ph);
312  target->ph_count--;
313  GNUNET_free (ph);
314  if (NULL != target->csh)
316  if (0 == target->ph_count)
317  target->csh = NULL;
318  else
319  target->csh
321  &target->pid,
322  target->ph_count);
323 }
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::csh, GNUNET_ATS_connectivity_suggest(), GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, ph, GNUNET_DHTU_Target::ph_count, GNUNET_DHTU_Target::ph_head, GNUNET_DHTU_Target::ph_tail, GNUNET_DHTU_Target::pid, GNUNET_DHTU_Target::plugin, and plugin.

Referenced by libgnunet_plugin_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 342 of file plugin_dhtu_gnunet.c.

348 {
349  struct GNUNET_MQ_Envelope *env;
350  struct GNUNET_MessageHeader *cmsg;
351 
352  env = GNUNET_MQ_msg_extra (cmsg,
353  msg_size,
356  finished_cb,
357  finished_cb_cls);
358  memcpy (&cmsg[1],
359  msg,
360  msg_size);
361  GNUNET_MQ_send (target->mq,
362  env);
363 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void finished_cb(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:304
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
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:638
#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 libgnunet_plugin_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 
)
static

Method called whenever a given peer connects.

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

Definition at line 375 of file plugin_dhtu_gnunet.c.

378 {
379  struct Plugin *plugin = cls;
380  struct GNUNET_DHTU_Target *target;
381 
382  target = GNUNET_new (struct GNUNET_DHTU_Target);
383  target->plugin = plugin;
384  target->mq = mq;
385  target->pid = *peer;
386  plugin->env->connect_cb (plugin->env->cls,
387  target,
388  &target->pid,
389  &target->app_ctx);
390  return target;
391 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
void * app_ctx
Application context for this target.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References GNUNET_DHTU_Target::app_ctx, GNUNET_new, mq, GNUNET_DHTU_Target::mq, peer, GNUNET_DHTU_Target::pid, GNUNET_DHTU_Target::plugin, and plugin.

Referenced by libgnunet_plugin_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 403 of file plugin_dhtu_gnunet.c.

406 {
407  struct Plugin *plugin = cls;
408  struct GNUNET_DHTU_Target *target = peer_cls;
409 
410  plugin->env->disconnect_cb (target->app_ctx);
411  if (NULL != target->csh)
413  GNUNET_free (target);
414 }

References GNUNET_DHTU_Target::app_ctx, GNUNET_DHTU_Target::csh, GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_free, and plugin.

Referenced by libgnunet_plugin_dhtu_gnunet_init().

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

◆ peerinfo_cb()

static void peerinfo_cb ( void *  cls,
const struct GNUNET_PeerIdentity peer,
const struct GNUNET_HELLO_Message hello,
const char *  err_msg 
)
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 430 of file plugin_dhtu_gnunet.c.

434 {
435  struct Plugin *plugin = cls;
436  char *addr;
437 
438  if (NULL == hello)
439  return;
440  if (NULL == peer)
441  return;
442  if (0 !=
444  &plugin->my_identity))
445  return;
446  addr = GNUNET_HELLO_compose_uri (hello,
448  if (NULL == addr)
449  return;
450  plugin->env->address_add_cb (plugin->env->cls,
451  addr,
452  &plugin->src,
453  &plugin->src.app_ctx);
454  GNUNET_free (addr);
455 }
char * GNUNET_HELLO_compose_uri(const struct GNUNET_HELLO_Message *hello, GNUNET_HELLO_TransportPluginsFind plugins_find)
Compose a hello URI string from a hello message.
Definition: hello.c:1007
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.

References GNUNET_free, GNUNET_HELLO_compose_uri(), GNUNET_memcmp, GPI_plugins_find(), peer, and plugin.

Referenced by core_init_cb().

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

◆ core_init_cb()

static void core_init_cb ( void *  cls,
const struct GNUNET_PeerIdentity my_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 471 of file plugin_dhtu_gnunet.c.

473 {
474  struct Plugin *plugin = cls;
475 
476  plugin->my_identity = *my_identity;
477  plugin->nc = GNUNET_PEERINFO_notify (plugin->env->cfg,
478  GNUNET_NO,
479  &peerinfo_cb,
480  plugin);
481 }
struct GNUNET_PeerIdentity my_identity
Our peer identity.
@ GNUNET_NO
struct GNUNET_PEERINFO_NotifyContext * GNUNET_PEERINFO_notify(const struct GNUNET_CONFIGURATION_Handle *cfg, int include_friend_only, GNUNET_PEERINFO_Processor callback, void *callback_cls)
Call a method whenever our known information about peers changes.
static void peerinfo_cb(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
Find the hello for our identity and then pass it to the DHT as a URL.

References GNUNET_NO, GNUNET_PEERINFO_notify(), my_identity, peerinfo_cb(), and plugin.

Referenced by libgnunet_plugin_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 492 of file plugin_dhtu_gnunet.c.

494 {
495  (void) cls;
496  (void) msg;
497  return GNUNET_OK;
498 }

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 509 of file plugin_dhtu_gnunet.c.

511 {
512  struct GNUNET_DHTU_Target *origin = cls;
513  struct Plugin *plugin = origin->plugin;
514 
515  plugin->env->receive_cb (plugin->env->cls,
516  &origin->app_ctx,
517  &plugin->src.app_ctx,
518  &msg[1],
519  ntohs (msg->size) - sizeof (*msg));
520 }
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 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 532 of file plugin_dhtu_gnunet.c.

536 {
537  struct Plugin *plugin = cls;
538 
539  plugin->env->network_size_cb (plugin->env->cls,
540  timestamp,
541  logestimate,
542  std_dev);
543 }

References plugin.

Referenced by libgnunet_plugin_dhtu_gnunet_init().

Here is the caller graph for this function:

◆ libgnunet_plugin_dhtu_gnunet_done()

void* libgnunet_plugin_dhtu_gnunet_done ( void *  cls)

Exit point from the plugin.

Parameters
clsclosure (our struct Plugin)
Returns
NULL

Definition at line 553 of file plugin_dhtu_gnunet.c.

554 {
555  struct GNUNET_DHTU_PluginFunctions *api = cls;
556  struct Plugin *plugin = api->cls;
557  struct HelloHandle *hh;
558 
559  while (NULL != (hh = plugin->hh_head))
560  {
562  plugin->hh_tail,
563  hh);
565  GNUNET_free (hh);
566  }
567  if (NULL != plugin->nse)
569  plugin->env->network_size_cb (plugin->env->cls,
571  0.0,
572  0.0);
573  if (NULL != plugin->core)
575  if (NULL != plugin->ats)
577  if (NULL != plugin->nc)
581  GNUNET_free (api);
582  return NULL;
583 }
void GPI_plugins_unload()
Unload all plugins.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:729
void GNUNET_NSE_disconnect(struct GNUNET_NSE_Handle *h)
Disconnect from network size estimation service.
Definition: nse_api.c:193
void GNUNET_PEERINFO_notify_cancel(struct GNUNET_PEERINFO_NotifyContext *nc)
Stop notifying about changes.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
void GNUNET_TRANSPORT_offer_hello_cancel(struct GNUNET_TRANSPORT_OfferHelloHandle *ohh)
Cancel the request to transport to offer the HELLO message.
void * cls
Closure for all of the callbacks.
struct returned by the initialization function of the plugin
void * cls
Closure to pass to all plugin functions.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_DHTU_PluginFunctions::cls, GNUNET_ATS_connectivity_done(), GNUNET_CONTAINER_DLL_remove, GNUNET_CORE_disconnect(), GNUNET_free, GNUNET_NSE_disconnect(), GNUNET_PEERINFO_notify_cancel(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TRANSPORT_offer_hello_cancel(), GPI_plugins_unload(), HelloHandle::ohh, and plugin.

Referenced by libgnunet_plugin_dhtu_gnunet_init().

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

◆ libgnunet_plugin_dhtu_gnunet_init()

void* libgnunet_plugin_dhtu_gnunet_init ( void *  cls)

Entry point for the plugin.

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

Definition at line 593 of file plugin_dhtu_gnunet.c.

594 {
596  struct GNUNET_DHTU_PluginFunctions *api;
597  struct Plugin *plugin;
599  GNUNET_MQ_hd_var_size (core_message,
601  struct GNUNET_MessageHeader,
602  NULL),
604  };
605 
606  plugin = GNUNET_new (struct Plugin);
607  plugin->env = env;
609  api->cls = plugin;
611  api->hold = &gnunet_hold;
612  api->drop = &gnunet_drop;
613  api->send = &gnunet_send;
615  plugin->core = GNUNET_CORE_connect (env->cfg,
616  plugin,
617  &core_init_cb,
620  handlers);
621  plugin->nse = GNUNET_NSE_connect (env->cfg,
622  &nse_cb,
623  plugin);
624  if ( (NULL == plugin->ats) ||
625  (NULL == plugin->core) ||
626  (NULL == plugin->nse) )
627  {
628  GNUNET_break (0);
629  GNUNET_free (api);
631  return NULL;
632  }
633  GPI_plugins_load (env->cfg);
634  return api;
635 }
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
void GPI_plugins_load(const struct GNUNET_CONFIGURATION_Handle *cfg)
Load and initialize all plugins.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion 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)
Connect to the core service.
Definition: core_api.c:691
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#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:165
void * libgnunet_plugin_dhtu_gnunet_done(void *cls)
Exit point from the plugin.
static void * core_connect_cb(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects.
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 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_PreferenceHandle * gnunet_hold(void *cls, struct GNUNET_DHTU_Target *target)
Request underlay to keep the connection to target alive if possible.
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 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_init_cb(void *cls, const struct GNUNET_PeerIdentity *my_identity)
Function called after GNUNET_CORE_connect has succeeded (or failed for good).
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
void * cls
Closure to use for callbacks.
struct GNUNET_DHTU_PreferenceHandle *(* hold)(void *cls, struct GNUNET_DHTU_Target *target)
Request underlay to keep the connection to target alive if possible.
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(* 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_PluginEnvironment::cls, GNUNET_DHTU_PluginFunctions::cls, core_connect_cb(), core_disconnect_cb(), core_init_cb(), GNUNET_DHTU_PluginFunctions::drop, env, GNUNET_ATS_connectivity_init(), GNUNET_break, GNUNET_CORE_connect(), gnunet_drop(), GNUNET_free, gnunet_hold(), GNUNET_MESSAGE_TYPE_DHT_CORE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_NSE_connect(), gnunet_send(), gnunet_try_connect(), GPI_plugins_load(), handlers, GNUNET_DHTU_PluginFunctions::hold, libgnunet_plugin_dhtu_gnunet_done(), nse_cb(), plugin, GNUNET_DHTU_PluginFunctions::send, and GNUNET_DHTU_PluginFunctions::try_connect.

Here is the call graph for this function: