aboutsummaryrefslogtreecommitdiff
path: root/src/dhtu/plugin_dhtu_gnunet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dhtu/plugin_dhtu_gnunet.c')
-rw-r--r--src/dhtu/plugin_dhtu_gnunet.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index 9597ebdc0..ccd329e8e 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -26,6 +26,7 @@
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_dhtu_plugin.h" 28#include "gnunet_dhtu_plugin.h"
29#include "gnunet_core_service.h"
29 30
30/** 31/**
31 * Handle for a private key used by this underlay. 32 * Handle for a private key used by this underlay.
@@ -134,6 +135,12 @@ struct Plugin
134 * Callbacks into the DHT. 135 * Callbacks into the DHT.
135 */ 136 */
136 struct GNUNET_DHTU_PluginEnvironment *env; 137 struct GNUNET_DHTU_PluginEnvironment *env;
138
139 /**
140 * Handle to the CORE service.
141 */
142 struct GNUNET_CORE_Handle *core;
143
137}; 144};
138 145
139 146
@@ -290,6 +297,60 @@ ip_send (void *cls,
290} 297}
291 298
292 299
300
301/**
302 * Method called whenever a given peer connects.
303 *
304 * @param cls closure
305 * @param peer peer identity this notification is about
306 * @return closure associated with @a peer. given to mq callbacks and
307 * #GNUNET_CORE_DisconnectEventHandler
308 */
309static void *
310core_connect_cb (void *cls,
311 const struct GNUNET_PeerIdentity *peer,
312 struct GNUNET_MQ_Handle *mq)
313{
314 return NULL;
315}
316
317
318/**
319 * Method called whenever a peer disconnects.
320 *
321 * @param cls closure
322 * @param peer peer identity this notification is about
323 * @param peer_cls closure associated with peer. given in
324 * #GNUNET_CORE_ConnectEventHandler
325 */
326static void
327core_disconnect_cb (void *cls,
328 const struct GNUNET_PeerIdentity *peer,
329 void *peer_cls)
330{
331}
332
333
334/**
335 * Function called after #GNUNET_CORE_connect has succeeded (or failed
336 * for good). Note that the private key of the peer is intentionally
337 * not exposed here; if you need it, your process should try to read
338 * the private key file directly (which should work if you are
339 * authorized...). Implementations of this function must not call
340 * #GNUNET_CORE_disconnect (other than by scheduling a new task to
341 * do this later).
342 *
343 * @param cls closure
344 * @param my_identity ID of this peer, NULL if we failed
345 */
346static void
347core_init_cb (void *cls,
348 const struct GNUNET_PeerIdentity *my_identity)
349{
350 struct Plugin *plugin = cls;
351}
352
353
293/** 354/**
294 * Entry point for the plugin. 355 * Entry point for the plugin.
295 * 356 *
@@ -302,6 +363,9 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
302 struct GNUNET_DHTU_PluginEnvironment *env = cls; 363 struct GNUNET_DHTU_PluginEnvironment *env = cls;
303 struct GNUNET_DHTU_PluginFunctions *api; 364 struct GNUNET_DHTU_PluginFunctions *api;
304 struct Plugin *plugin; 365 struct Plugin *plugin;
366 struct GNUNET_MQ_MessageHandler handlers[] = {
367 GNUNET_MQ_handler_end ()
368 };
305 369
306 plugin = GNUNET_new (struct Plugin); 370 plugin = GNUNET_new (struct Plugin);
307 plugin->env = env; 371 plugin->env = env;
@@ -313,6 +377,12 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
313 api->hold = &ip_hold; 377 api->hold = &ip_hold;
314 api->drop = &ip_drop; 378 api->drop = &ip_drop;
315 api->send = &ip_send; 379 api->send = &ip_send;
380 plugin->core = GNUNET_CORE_connect (env->cfg,
381 plugin,
382 &core_init_cb,
383 &core_connect_cb,
384 &core_disconnect_cb,
385 handlers);
316 return api; 386 return api;
317} 387}
318 388
@@ -329,6 +399,7 @@ libgnunet_plugin_dhtu_gnunet_done (void *cls)
329 struct GNUNET_DHTU_PluginFunctions *api = cls; 399 struct GNUNET_DHTU_PluginFunctions *api = cls;
330 struct Plugin *plugin = api->cls; 400 struct Plugin *plugin = api->cls;
331 401
402 GNUNET_CORE_disconnect (plugin->core);
332 GNUNET_free (plugin); 403 GNUNET_free (plugin);
333 GNUNET_free (api); 404 GNUNET_free (api);
334 return NULL; 405 return NULL;