aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dhtu/Makefile.am1
-rw-r--r--src/dhtu/plugin_dhtu_gnunet.c71
-rw-r--r--src/include/gnunet_hello_lib.h7
-rw-r--r--src/include/gnunet_mq_lib.h21
-rw-r--r--src/include/gnunet_transport_service.h21
5 files changed, 103 insertions, 18 deletions
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am
index 4bc96f236..f4b968526 100644
--- a/src/dhtu/Makefile.am
+++ b/src/dhtu/Makefile.am
@@ -28,6 +28,7 @@ libgnunet_plugin_dhtu_ip_la_LDFLAGS = \
28libgnunet_plugin_dhtu_gnunet_la_SOURCES = \ 28libgnunet_plugin_dhtu_gnunet_la_SOURCES = \
29 plugin_dhtu_gnunet.c 29 plugin_dhtu_gnunet.c
30libgnunet_plugin_dhtu_gnunet_la_LIBADD = \ 30libgnunet_plugin_dhtu_gnunet_la_LIBADD = \
31 $(top_builddir)/src/core/libgnunetcore.la \
31 $(top_builddir)/src/util/libgnunetutil.la \ 32 $(top_builddir)/src/util/libgnunetutil.la \
32 $(XLIBS) \ 33 $(XLIBS) \
33 $(LTLIBINTL) 34 $(LTLIBINTL)
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;
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
index fff0045aa..74eca999d 100644
--- a/src/include/gnunet_hello_lib.h
+++ b/src/include/gnunet_hello_lib.h
@@ -268,9 +268,10 @@ GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address,
268 * @return number of bytes written or 0, #GNUNET_SYSERR to signal the 268 * @return number of bytes written or 0, #GNUNET_SYSERR to signal the
269 * end of the iteration. 269 * end of the iteration.
270 */ 270 */
271typedef ssize_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, 271typedef ssize_t
272 size_t max, 272(*GNUNET_HELLO_GenerateAddressListCallback) (void *cls,
273 void *buf); 273 size_t max,
274 void *buf);
274 275
275 276
276/** 277/**
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h
index 37bba8c1b..765647a98 100644
--- a/src/include/gnunet_mq_lib.h
+++ b/src/include/gnunet_mq_lib.h
@@ -331,9 +331,10 @@ typedef int (*GNUNET_MQ_MessageValidationCallback) (
331 * @param msg the message to send 331 * @param msg the message to send
332 * @param impl_state state of the implementation 332 * @param impl_state state of the implementation
333 */ 333 */
334typedef void (*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq, 334typedef void
335 const struct GNUNET_MessageHeader *msg, 335(*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq,
336 void *impl_state); 336 const struct GNUNET_MessageHeader *msg,
337 void *impl_state);
337 338
338 339
339/** 340/**
@@ -345,8 +346,9 @@ typedef void (*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq,
345 * @param mq the message queue to destroy 346 * @param mq the message queue to destroy
346 * @param impl_state state of the implementation 347 * @param impl_state state of the implementation
347 */ 348 */
348typedef void (*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq, 349typedef void
349 void *impl_state); 350(*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq,
351 void *impl_state);
350 352
351 353
352/** 354/**
@@ -355,8 +357,9 @@ typedef void (*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq,
355 * @param mq message queue 357 * @param mq message queue
356 * @param impl_state state specific to the implementation 358 * @param impl_state state specific to the implementation
357 */ 359 */
358typedef void (*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq, 360typedef void
359 void *impl_state); 361(*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq,
362 void *impl_state);
360 363
361 364
362/** 365/**
@@ -368,7 +371,9 @@ typedef void (*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq,
368 * @param cls closure 371 * @param cls closure
369 * @param error error code 372 * @param error error code
370 */ 373 */
371typedef void (*GNUNET_MQ_ErrorHandler) (void *cls, enum GNUNET_MQ_Error error); 374typedef void
375(*GNUNET_MQ_ErrorHandler) (void *cls,
376 enum GNUNET_MQ_Error error);
372 377
373 378
374/** 379/**
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index d190eff92..545bb28d2 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -115,7 +115,8 @@ struct GNUNET_TRANSPORT_AddressToStringContext;
115 * if #GNUNET_NO: address was invalid (or not supported) 115 * if #GNUNET_NO: address was invalid (or not supported)
116 * if #GNUNET_SYSERR: communication error (IPC error) 116 * if #GNUNET_SYSERR: communication error (IPC error)
117 */ 117 */
118typedef void (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls, 118typedef void
119(*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
119 const char *address, 120 const char *address,
120 int res); 121 int res);
121 122
@@ -326,7 +327,8 @@ struct GNUNET_TRANSPORT_PeerMonitoringContext;
326 * @param state current state this peer is in 327 * @param state current state this peer is in
327 * @param state_timeout timeout for the current state of the peer 328 * @param state_timeout timeout for the current state of the peer
328 */ 329 */
329typedef void (*GNUNET_TRANSPORT_PeerIterateCallback) ( 330typedef void
331(*GNUNET_TRANSPORT_PeerIterateCallback) (
330 void *cls, 332 void *cls,
331 const struct GNUNET_PeerIdentity *peer, 333 const struct GNUNET_PeerIdentity *peer,
332 const struct GNUNET_HELLO_Address *address, 334 const struct GNUNET_HELLO_Address *address,
@@ -394,7 +396,8 @@ struct GNUNET_TRANSPORT_Blacklist;
394 * @param pid peer to approve or disapproave 396 * @param pid peer to approve or disapproave
395 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not 397 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
396 */ 398 */
397typedef int (*GNUNET_TRANSPORT_BlacklistCallback) ( 399typedef int
400(*GNUNET_TRANSPORT_BlacklistCallback) (
398 void *cls, 401 void *cls,
399 const struct GNUNET_PeerIdentity *pid); 402 const struct GNUNET_PeerIdentity *pid);
400 403
@@ -541,7 +544,8 @@ struct GNUNET_TRANSPORT_SessionInfo
541 * NULL with @a session being non-NULL if the monitor 544 * NULL with @a session being non-NULL if the monitor
542 * was being cancelled while sessions were active 545 * was being cancelled while sessions were active
543 */ 546 */
544typedef void (*GNUNET_TRANSPORT_SessionMonitorCallback) ( 547typedef void
548(*GNUNET_TRANSPORT_SessionMonitorCallback) (
545 void *cls, 549 void *cls,
546 struct GNUNET_TRANSPORT_PluginSession *session, 550 struct GNUNET_TRANSPORT_PluginSession *session,
547 void **session_ctx, 551 void **session_ctx,
@@ -593,7 +597,8 @@ struct GNUNET_TRANSPORT_CoreHandle;
593 * @param mq message queue to use to transmit to @a peer 597 * @param mq message queue to use to transmit to @a peer
594 * @return closure to use in MQ handlers 598 * @return closure to use in MQ handlers
595 */ 599 */
596typedef void *(*GNUNET_TRANSPORT_NotifyConnect) ( 600typedef void *
601(*GNUNET_TRANSPORT_NotifyConnect) (
597 void *cls, 602 void *cls,
598 const struct GNUNET_PeerIdentity *peer, 603 const struct GNUNET_PeerIdentity *peer,
599 struct GNUNET_MQ_Handle *mq); 604 struct GNUNET_MQ_Handle *mq);
@@ -610,7 +615,8 @@ typedef void *(*GNUNET_TRANSPORT_NotifyConnect) (
610 * @param handlers_cls closure of the handlers, was returned from the 615 * @param handlers_cls closure of the handlers, was returned from the
611 * connect notification callback 616 * connect notification callback
612 */ 617 */
613typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) ( 618typedef void
619(*GNUNET_TRANSPORT_NotifyDisconnect) (
614 void *cls, 620 void *cls,
615 const struct GNUNET_PeerIdentity *peer, 621 const struct GNUNET_PeerIdentity *peer,
616 void *handler_cls); 622 void *handler_cls);
@@ -632,7 +638,8 @@ typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) (
632 * @param handlers_cls closure of the handlers, was returned from the 638 * @param handlers_cls closure of the handlers, was returned from the
633 * connect notification callback 639 * connect notification callback
634 */ 640 */
635typedef void (*GNUNET_TRANSPORT_NotifyExcessBandwidth) ( 641typedef void
642(*GNUNET_TRANSPORT_NotifyExcessBandwidth) (
636 void *cls, 643 void *cls,
637 const struct GNUNET_PeerIdentity *neighbour, 644 const struct GNUNET_PeerIdentity *neighbour,
638 void *handlers_cls); 645 void *handlers_cls);