From: Christian Grothoff Date: Sun, 31 Jul 2016 15:42:37 +0000 (+0000) Subject: convering more services to new core MQ API X-Git-Tag: initial-import-from-subversion-38251~441 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=406c7d2d2d126c994a1fff13470b1f96439c6f9d;p=oweals%2Fgnunet.git convering more services to new core MQ API --- diff --git a/src/hello/hello.c b/src/hello/hello.c index b200846f5..f9b21aa4f 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c @@ -30,42 +30,6 @@ #include "gnunet_util_lib.h" #include "gnunet_transport_plugin.h" -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * A HELLO message is used to exchange information about - * transports with other peers. This struct is always - * followed by the actual network addresses which have - * the format: - * - * 1) transport-name (0-terminated) - * 2) address-length (uint16_t, network byte order; possibly - * unaligned!) - * 3) address expiration (`struct GNUNET_TIME_AbsoluteNBO`); possibly - * unaligned!) - * 4) address (address-length bytes; possibly unaligned!) - */ -struct GNUNET_HELLO_Message -{ - /** - * Type will be #GNUNET_MESSAGE_TYPE_HELLO. - */ - struct GNUNET_MessageHeader header; - - /** - * Use in F2F mode: Do not gossip this HELLO message - */ - uint32_t friend_only GNUNET_PACKED; - - /** - * The public key of the peer. - */ - struct GNUNET_CRYPTO_EddsaPublicKey publicKey; - -}; -GNUNET_NETWORK_STRUCT_END - - /** * Context used for building our own URI. */ diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index 21fab323b..44db59949 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c @@ -47,12 +47,7 @@ static int provide_hostlist; /** * Handle to hostlist server's connect handler */ -static GNUNET_CORE_ConnectEventHandler server_ch; - -/** - * Handle to hostlist server's disconnect handler - */ -static GNUNET_CORE_DisconnectEventHandler server_dh; +static GNUNET_CORE_ConnecTEventHandler server_ch; #endif @@ -81,17 +76,17 @@ static struct GNUNET_CORE_Handle *core; /** * Handle to the hostlist client's advertisement handler */ -static GNUNET_CORE_MessageCallback client_adv_handler; +static GNUNET_HOSTLIST_UriHandler client_adv_handler; /** * Handle to hostlist client's connect handler */ -static GNUNET_CORE_ConnectEventHandler client_ch; +static GNUNET_CORE_ConnecTEventHandler client_ch; /** * Handle to hostlist client's disconnect handler */ -static GNUNET_CORE_DisconnectEventHandler client_dh; +static GNUNET_CORE_DisconnecTEventHandler client_dh; GNUNET_NETWORK_STRUCT_BEGIN @@ -146,17 +141,49 @@ core_init (void *cls, * Core handler for p2p hostlist advertisements * * @param cls closure - * @param peer identity of the sender * @param message advertisement message we got - * @return #GNUNET_OK on success + * @return #GNUNET_OK if message is well-formed */ static int -advertisement_handler (void *cls, - const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message) +check_advertisement (void *cls, + const struct GNUNET_MessageHeader *message) { + size_t size; + size_t uri_size; + const char *uri; + + size = ntohs (message->size); + if (size <= sizeof (struct GNUNET_MessageHeader)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + uri = (const char *) &message[1]; + uri_size = size - sizeof (struct GNUNET_MessageHeader); + if (uri[uri_size - 1] != '\0') + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + + +/** + * Core handler for p2p hostlist advertisements + * + * @param cls closure + * @param message advertisement message we got + * @return #GNUNET_OK on success + */ +static void +handle_advertisement (void *cls, + const struct GNUNET_MessageHeader *message) +{ + const char *uri = (const char *) &message[1]; + GNUNET_assert (NULL != client_adv_handler); - return (*client_adv_handler) (cls, peer, message); + (void) (*client_adv_handler) (uri); } @@ -166,20 +193,33 @@ advertisement_handler (void *cls, * * @param cls closure * @param peer peer identity this notification is about + * @param mq queue for sending messages to @a peer + * @return peer */ -static void -connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) +static void * +connect_handler (void *cls, + const struct GNUNET_PeerIdentity *peer, + struct GNUNET_MQ_Handle *mq) { - if (0 == memcmp (&me, peer, sizeof (struct GNUNET_PeerIdentity))) - return; + if (0 == memcmp (&me, + peer, + sizeof (struct GNUNET_PeerIdentity))) + return NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "A new peer connected, notifying client and server\n"); if (NULL != client_ch) - (*client_ch) (cls, peer); + GNUNET_assert (NULL == + (*client_ch) (cls, + peer, + mq)); #if HAVE_MHD if (NULL != server_ch) - (*server_ch) (cls, peer); + GNUNET_assert (NULL == + (*server_ch) (cls, + peer, + mq)); #endif + return (void *) peer; } @@ -192,18 +232,18 @@ connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) */ static void disconnect_handler (void *cls, - const struct GNUNET_PeerIdentity *peer) + const struct GNUNET_PeerIdentity *peer, + void *internal_cls) { - if (0 == memcmp (&me, peer, sizeof (struct GNUNET_PeerIdentity))) + if (0 == memcmp (&me, + peer, + sizeof (struct GNUNET_PeerIdentity))) return; /* call hostlist client disconnect handler */ if (NULL != client_dh) - (*client_dh) (cls, peer); -#if HAVE_MHD - /* call hostlist server disconnect handler */ - if (NULL != server_dh) - (*server_dh) (cls, peer); -#endif + (*client_dh) (cls, + peer, + NULL); } @@ -220,7 +260,7 @@ cleaning_task (void *cls) "Hostlist daemon is shutting down\n"); if (NULL != core) { - GNUNET_CORE_disconnect (core); + GNUNET_CORE_disconnecT (core); core = NULL; } if (bootstrapping) @@ -235,7 +275,8 @@ cleaning_task (void *cls) #endif if (NULL != stats) { - GNUNET_STATISTICS_destroy (stats, GNUNET_NO); + GNUNET_STATISTICS_destroy (stats, + GNUNET_NO); stats = NULL; } } @@ -255,12 +296,15 @@ run (void *cls, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - static const struct GNUNET_CORE_MessageHandler learn_handlers[] = { - {&advertisement_handler, GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT, 0}, - {NULL, 0, 0} + GNUNET_MQ_hd_var_size (advertisement, + GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT, + struct GNUNET_MessageHeader); + struct GNUNET_MQ_MessageHandler learn_handlers[] = { + make_advertisement_handler (NULL), + GNUNET_MQ_handler_end () }; - static const struct GNUNET_CORE_MessageHandler no_learn_handlers[] = { - {NULL, 0, 0} + struct GNUNET_MQ_MessageHandler no_learn_handlers[] = { + GNUNET_MQ_handler_end () }; if ((! bootstrapping) && (! learning) #if HAVE_MHD @@ -279,24 +323,27 @@ run (void *cls, return; } if (bootstrapping) - GNUNET_HOSTLIST_client_start (cfg, stats, + GNUNET_HOSTLIST_client_start (cfg, + stats, &client_ch, &client_dh, &client_adv_handler, learning); core = - GNUNET_CORE_connect (cfg, NULL, + GNUNET_CORE_connecT (cfg, + NULL, &core_init, &connect_handler, &disconnect_handler, - NULL, GNUNET_NO, - NULL, GNUNET_NO, learning ? learn_handlers : no_learn_handlers); #if HAVE_MHD if (provide_hostlist) - GNUNET_HOSTLIST_server_start (cfg, stats, core, &server_ch, &server_dh, + GNUNET_HOSTLIST_server_start (cfg, + stats, + core, + &server_ch, advertising); #endif GNUNET_SCHEDULER_add_shutdown (&cleaning_task, diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index 9f6413898..c1a2c2721 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2001-2010, 2014 GNUnet e.V. + Copyright (C) 2001-2010, 2014, 2016 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -1187,14 +1187,20 @@ task_hostlist_saving (void *cls) * * @param cls closure * @param peer peer identity this notification is about + * @param mq message queue for transmissions to @a peer */ -static void -handler_connect (void *cls, const struct GNUNET_PeerIdentity *peer) +static void * +handler_connect (void *cls, + const struct GNUNET_PeerIdentity *peer, + struct GNUNET_MQ_Handle *mq) { GNUNET_assert (stat_connection_count < UINT_MAX); stat_connection_count++; - GNUNET_STATISTICS_update (stats, gettext_noop ("# active connections"), 1, + GNUNET_STATISTICS_update (stats, + gettext_noop ("# active connections"), + 1, GNUNET_NO); + return NULL; } @@ -1205,11 +1211,15 @@ handler_connect (void *cls, const struct GNUNET_PeerIdentity *peer) * @param peer peer identity this notification is about */ static void -handler_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) +handler_disconnect (void *cls, + const struct GNUNET_PeerIdentity *peer, + void *internal_cls) { GNUNET_assert (stat_connection_count > 0); stat_connection_count--; - GNUNET_STATISTICS_update (stats, gettext_noop ("# active connections"), -1, + GNUNET_STATISTICS_update (stats, + gettext_noop ("# active connections"), + -1, GNUNET_NO); } @@ -1217,63 +1227,44 @@ handler_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) /** * Method called whenever an advertisement message arrives. * - * @param cls closure (always NULL) - * @param peer the peer sending the message - * @param message the actual message - * @return #GNUNET_OK to keep the connection open, - * #GNUNET_SYSERR to close it (signal serious error) + * @param uri the advertised URI */ -static int -handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message) +static void +handler_advertisement (const char *uri) { - size_t size; size_t uri_size; - const struct GNUNET_MessageHeader *incoming; - const char *uri; struct Hostlist *hostlist; - GNUNET_assert (ntohs (message->type) == - GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT); - size = ntohs (message->size); - if (size <= sizeof (struct GNUNET_MessageHeader)) - { - GNUNET_break_op (0); - return GNUNET_SYSERR; - } - incoming = (const struct GNUNET_MessageHeader *) message; - uri = (const char *) &incoming[1]; - uri_size = size - sizeof (struct GNUNET_MessageHeader); - if (uri[uri_size - 1] != '\0') - { - GNUNET_break_op (0); - return GNUNET_SYSERR; - } + uri_size = strlen (uri) + 1; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Hostlist client recieved advertisement from `%s' containing URI `%s'\n", - GNUNET_i2s (peer), uri); + "Hostlist client recieved advertisement containing URI `%s'\n", + uri); if (GNUNET_NO != linked_list_contains (uri)) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URI `%s' is already known\n", uri); - return GNUNET_OK; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "URI `%s' is already known\n", + uri); + return; } if (GNUNET_NO == stat_testing_allowed) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Currently not accepting new advertisements: interval between to advertisements is not reached\n"); - return GNUNET_SYSERR; + return; } if (GNUNET_YES == stat_testing_hostlist) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Currently not accepting new advertisements: we are already testing a hostlist\n"); - return GNUNET_SYSERR; + return; } hostlist = GNUNET_malloc (sizeof (struct Hostlist) + uri_size); hostlist->hostlist_uri = (const char *) &hostlist[1]; - GNUNET_memcpy (&hostlist[1], uri, uri_size); + GNUNET_memcpy (&hostlist[1], + uri, + uri_size); hostlist->time_creation = GNUNET_TIME_absolute_get (); hostlist->quality = HOSTLIST_INITIAL; hostlist_to_test = hostlist; @@ -1282,7 +1273,8 @@ handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer, stat_testing_allowed = GNUNET_NO; ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (TESTING_INTERVAL, - &task_testing_intervall_reset, NULL); + &task_testing_intervall_reset, + NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing new hostlist advertisements is locked for the next %s\n", @@ -1290,9 +1282,8 @@ handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer, GNUNET_YES)); ti_download_dispatcher_task = - GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL); - - return GNUNET_OK; + GNUNET_SCHEDULER_add_now (&task_download_dispatcher, + NULL); } @@ -1557,9 +1548,9 @@ save_hostlist_file (int shutdown) int GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_STATISTICS_Handle *st, - GNUNET_CORE_ConnectEventHandler *ch, - GNUNET_CORE_DisconnectEventHandler *dh, - GNUNET_CORE_MessageCallback *msgh, + GNUNET_CORE_ConnecTEventHandler *ch, + GNUNET_CORE_DisconnecTEventHandler *dh, + GNUNET_HOSTLIST_UriHandler *msgh, int learn) { char *filename; @@ -1578,23 +1569,31 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, /* Read proxy configuration */ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, - "HOSTLIST", "PROXY", &proxy)) + "HOSTLIST", + "PROXY", + &proxy)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found proxy host: `%s'\n", proxy); /* proxy username */ - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, - "HOSTLIST", "PROXY_USERNAME", &proxy_username)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (cfg, + "HOSTLIST", + "PROXY_USERNAME", + &proxy_username)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Found proxy username name: `%s'\n", - proxy_username); + "Found proxy username name: `%s'\n", + proxy_username); } /* proxy password */ - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, - "HOSTLIST", "PROXY_PASSWORD", &proxy_password)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (cfg, + "HOSTLIST", + "PROXY_PASSWORD", + &proxy_password)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found proxy password name: `%s'\n", @@ -1659,7 +1658,8 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, load_hostlist_file (); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostlists will be saved to file again in %s\n", - GNUNET_STRINGS_relative_time_to_string (SAVING_INTERVAL, GNUNET_YES)); + GNUNET_STRINGS_relative_time_to_string (SAVING_INTERVAL, + GNUNET_YES)); ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVAL, &task_hostlist_saving, @@ -1671,8 +1671,10 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, _("Learning is not enabled on this peer\n")); *msgh = NULL; if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", - "HOSTLISTFILE", &filename)) + GNUNET_CONFIGURATION_get_value_filename (cfg, + "HOSTLIST", + "HOSTLISTFILE", + &filename)) { if (GNUNET_YES == GNUNET_DISK_file_test (filename)) { @@ -1706,9 +1708,10 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, } else { - ti_check_download = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &stat_timeout_task, - NULL); + ti_check_download + = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, + &stat_timeout_task, + NULL); } return GNUNET_OK; } diff --git a/src/hostlist/gnunet-daemon-hostlist_client.h b/src/hostlist/gnunet-daemon-hostlist_client.h index 15e913adb..dd80d4a48 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.h +++ b/src/hostlist/gnunet-daemon-hostlist_client.h @@ -30,6 +30,15 @@ #include "gnunet_util_lib.h" +/** + * Function that handles an advertised URI. + * + * @param uri 0-termianted URI of a hostlist + */ +typedef void +(*GNUNET_HOSTLIST_UriHandler)(const char *uri); + + /** * Start downloading hostlists from hostlist servers as necessary. * @@ -44,9 +53,9 @@ int GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_STATISTICS_Handle *st, - GNUNET_CORE_ConnectEventHandler *ch, - GNUNET_CORE_DisconnectEventHandler *dh, - GNUNET_CORE_MessageCallback *msgh, + GNUNET_CORE_ConnecTEventHandler *ch, + GNUNET_CORE_DisconnecTEventHandler *dh, + GNUNET_HOSTLIST_UriHandler *msgh, int learn); diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c b/src/hostlist/gnunet-daemon-hostlist_server.c index 40820e557..b01dbc09e 100644 --- a/src/hostlist/gnunet-daemon-hostlist_server.c +++ b/src/hostlist/gnunet-daemon-hostlist_server.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2008, 2009, 2010, 2014 GNUnet e.V. + Copyright (C) 2008, 2009, 2010, 2014, 2016 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -101,12 +101,6 @@ static int advertising; */ static char *hostlist_uri; -/** - * Map of peer identities to `struct GNUNET_CORE_TransmitHandle *` for - * pending hostlist server advertisements. - */ -static struct GNUNET_CONTAINER_MultiPeerMap *advertisements; - /** * Context for #host_processor(). @@ -436,47 +430,34 @@ access_handler_callback (void *cls, * @param buf buffer to copy message to * @return number of bytes copied to @a buf */ -static size_t -adv_transmit_ready (void *cls, - size_t size, - void *buf) +static void +adv_transmit (struct GNUNET_MQ_Handle *mq) { - const struct GNUNET_PeerIdentity *peer = cls; static uint64_t hostlist_adv_count; - size_t transmission_size; + const void *extra; + uint64_t flags; size_t uri_size; /* Including \0 termination! */ - struct GNUNET_MessageHeader header; - char *cbuf; - struct GNUNET_CORE_TransmitHandle *th; - - th = GNUNET_CONTAINER_multipeermap_get (advertisements, - peer); - GNUNET_assert (NULL != th); - GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multipeermap_remove (advertisements, - peer, - th)); - if (NULL == buf) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmission failed, buffer invalid!\n"); - return 0; - } + struct GNUNET_MessageHeader *header; + struct GNUNET_MQ_Envelope *env; + + extra = GNUNET_CORE_get_mq_options (GNUNET_YES, + GNUNET_CORE_PRIO_BEST_EFFORT, + &flags); uri_size = strlen (hostlist_uri) + 1; - transmission_size = sizeof (struct GNUNET_MessageHeader) + uri_size; - header.type = htons (GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT); - header.size = htons (transmission_size); - GNUNET_assert (size >= transmission_size); - GNUNET_memcpy (buf, - &header, - sizeof (struct GNUNET_MessageHeader)); - cbuf = buf; - GNUNET_memcpy (&cbuf[sizeof (struct GNUNET_MessageHeader)], - hostlist_uri, - uri_size); + env = GNUNET_MQ_msg_extra (header, + uri_size, + GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT); + GNUNET_memcpy (&header[1], + hostlist_uri, + uri_size); + GNUNET_MQ_env_set_options (env, + flags, + extra); + GNUNET_MQ_send (mq, + env); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent advertisement message: Copied %u bytes into buffer!\n", - (unsigned int) transmission_size); + (unsigned int) uri_size); hostlist_adv_count++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " # Sent advertisement message: %llu\n", @@ -484,7 +465,6 @@ adv_transmit_ready (void *cls, GNUNET_STATISTICS_update (stats, gettext_noop ("# hostlist advertisements send"), 1, GNUNET_NO); - return transmission_size; } @@ -493,78 +473,39 @@ adv_transmit_ready (void *cls, * * @param cls closure * @param peer peer identity this notification is about + * @param mq queue for transmission to @a peer + * @return NULL (must!) */ -static void +static void * connect_handler (void *cls, - const struct GNUNET_PeerIdentity *peer) + const struct GNUNET_PeerIdentity *peer, + struct GNUNET_MQ_Handle *mq) { size_t size; - struct GNUNET_CORE_TransmitHandle *th; if (! advertising) - return; + return NULL; if (NULL == hostlist_uri) - return; + return NULL; size = strlen (hostlist_uri) + 1; if (size + sizeof (struct GNUNET_MessageHeader) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); - return; + return NULL; } size += sizeof (struct GNUNET_MessageHeader); if (NULL == core) { GNUNET_break (0); - return; + return NULL; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked CORE to transmit advertisement message with a size of %u bytes to peer `%s'\n", (unsigned int) size, GNUNET_i2s (peer)); - if (NULL == - (th = GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES, - GNUNET_CORE_PRIO_BEST_EFFORT, - GNUNET_ADV_TIMEOUT, - peer, - size, - &adv_transmit_ready, - (void *) peer)) ) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Advertisement message could not be queued by core\n")); - } - GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multipeermap_put (advertisements, - peer, - th, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); -} - - -/** - * Method called whenever a given peer disconnects. - * - * @param cls closure - * @param peer peer identity this notification is about - */ -static void -disconnect_handler (void *cls, - const struct GNUNET_PeerIdentity *peer) -{ - struct GNUNET_CORE_TransmitHandle *th; - - if (! advertising) - return; - th = GNUNET_CONTAINER_multipeermap_get (advertisements, - peer); - if (NULL == th) - return; - GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multipeermap_remove (advertisements, - peer, - th)); - GNUNET_CORE_notify_transmit_ready_cancel (th); + adv_transmit (mq); + return NULL; } @@ -696,7 +637,6 @@ prepare_daemon (struct MHD_Daemon *daemon_handle) * @param st statistics handle to use * @param co core handle to use * @param[out] server_ch set to handler for CORE connect events - * @param[out] server_dh set to handler for CORE disconnect events * @param advertise #GNUNET_YES if we should advertise our hostlist * @return #GNUNET_OK on success */ @@ -704,8 +644,7 @@ int GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_STATISTICS_Handle *st, struct GNUNET_CORE_Handle *co, - GNUNET_CORE_ConnectEventHandler *server_ch, - GNUNET_CORE_DisconnectEventHandler *server_dh, + GNUNET_CORE_ConnecTEventHandler *server_ch, int advertise) { unsigned long long port; @@ -730,8 +669,6 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Advertising enabled on this hostlist server\n"); - advertisements = GNUNET_CONTAINER_multipeermap_create (8, - GNUNET_NO); } cfg = c; stats = st; @@ -797,11 +734,15 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, } else ipv4 = NULL; - if (GNUNET_CONFIGURATION_have_value (cfg, "HOSTLIST", "BINDTOIPV6")) + if (GNUNET_CONFIGURATION_have_value (cfg, + "HOSTLIST", + "BINDTOIPV6")) { if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", - "BINDTOIP", &ipv6)) + GNUNET_CONFIGURATION_get_value_string (cfg, + "HOSTLIST", + "BINDTOIP", + &ipv6)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("BINDTOIP does not a valid IPv4 address! Ignoring BINDTOIPV6.\n")); @@ -892,7 +833,6 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, core = co; *server_ch = &connect_handler; - *server_dh = &disconnect_handler; if (NULL != daemon_handle_v4) hostlist_task_v4 = prepare_daemon (daemon_handle_v4); if (NULL != daemon_handle_v6) @@ -958,13 +898,6 @@ GNUNET_HOSTLIST_server_stop () GNUNET_PEERINFO_disconnect (peerinfo); peerinfo = NULL; } - if (NULL != advertisements) - { - GNUNET_break (0 == - GNUNET_CONTAINER_multipeermap_size (advertisements)); - GNUNET_CONTAINER_multipeermap_destroy (advertisements); - advertisements = NULL; - } cfg = NULL; stats = NULL; core = NULL; diff --git a/src/hostlist/gnunet-daemon-hostlist_server.h b/src/hostlist/gnunet-daemon-hostlist_server.h index f70e22fd9..f18ad0ca2 100644 --- a/src/hostlist/gnunet-daemon-hostlist_server.h +++ b/src/hostlist/gnunet-daemon-hostlist_server.h @@ -39,7 +39,6 @@ * @param st statistics handle to use * @param co core handle to use * @param[out] server_ch set to handler for CORE connect events - * @param[out] server_dh set to handler for CORE disconnect events * @param advertise #GNUNET_YES if we should advertise our hostlist * @return #GNUNET_OK on success */ @@ -47,9 +46,8 @@ int GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_STATISTICS_Handle *st, struct GNUNET_CORE_Handle *core, - GNUNET_CORE_ConnectEventHandler *server_ch, - GNUNET_CORE_DisconnectEventHandler *server_dh, - int advertise); + GNUNET_CORE_ConnecTEventHandler *server_ch, + int advertise); /** diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index 54f219ad8..041898abd 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet - Copyright (C) 2009, 2010, 2011, 2012 GNUnet e.V. + Copyright (C) 2009, 2010, 2011, 2012, 2016 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -63,9 +63,9 @@ static char *current_adv_uri; static const struct GNUNET_CONFIGURATION_Handle *cfg; -static struct GNUNET_SCHEDULER_Task * timeout_task; +static struct GNUNET_SCHEDULER_Task *timeout_task; -static struct GNUNET_SCHEDULER_Task * check_task; +static struct GNUNET_SCHEDULER_Task *check_task; static struct PeerContext adv_peer; @@ -81,8 +81,9 @@ static struct GNUNET_STATISTICS_GetHandle *advsent_stat; static void shutdown_testcase () { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown testcase....\n"); - if (timeout_task != NULL) + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Shutdown testcase....\n"); + if (NULL != timeout_task) { GNUNET_SCHEDULER_cancel (timeout_task); timeout_task = NULL; @@ -112,7 +113,7 @@ shutdown_testcase () GNUNET_STATISTICS_destroy (learn_peer.stats, GNUNET_NO); learn_peer.stats = NULL; } - if (check_task != NULL) + if (NULL != check_task) { GNUNET_SCHEDULER_cancel (check_task); check_task = NULL; @@ -124,20 +125,24 @@ shutdown_testcase () } if (NULL != adv_peer.core) { - GNUNET_CORE_disconnect (adv_peer.core); + GNUNET_CORE_disconnecT (adv_peer.core); adv_peer.core = NULL; } if (NULL != learn_peer.core) { - GNUNET_CORE_disconnect (learn_peer.core); + GNUNET_CORE_disconnecT (learn_peer.core); learn_peer.core = NULL; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Killing hostlist server ARM process.\n"); - if (0 != GNUNET_OS_process_kill (adv_peer.arm_proc, GNUNET_TERM_SIG)) - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); - if (GNUNET_OS_process_wait (adv_peer.arm_proc) != GNUNET_OK) - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); + if (0 != GNUNET_OS_process_kill (adv_peer.arm_proc, + GNUNET_TERM_SIG)) + GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, + "kill"); + if (GNUNET_OK != + GNUNET_OS_process_wait (adv_peer.arm_proc)) + GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, + "waitpid"); GNUNET_OS_process_destroy (adv_peer.arm_proc); adv_peer.arm_proc = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -156,6 +161,7 @@ shutdown_testcase () "Shutdown complete....\n"); } + /** * Timeout, give up. */ @@ -185,10 +191,14 @@ do_shutdown (void *cls) static int -process_downloads (void *cls, const char *subsystem, const char *name, - uint64_t value, int is_persistent) +process_downloads (void *cls, + const char *subsystem, + const char *name, + uint64_t value, + int is_persistent) { - if ((value >= 2) && (learned_hostlist_downloaded == GNUNET_NO)) + if ( (value >= 2) && + (GNUNET_NO == learned_hostlist_downloaded) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer has successfully downloaded advertised URI\n"); @@ -210,18 +220,25 @@ process_uris_recv_done (void *cls, int success) static int -process_uris_recv (void *cls, const char *subsystem, const char *name, - uint64_t value, int is_persistent) +process_uris_recv (void *cls, + const char *subsystem, + const char *name, + uint64_t value, + int is_persistent) { - if (((struct PeerContext *) cls == &learn_peer) && (value == 1) && - (learned_hostlist_saved == GNUNET_NO)) + struct PeerContext *pc = cls; + if ( (pc == &learn_peer) && + (value == 1) && + (learned_hostlist_saved == GNUNET_NO) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer has successfully saved advertised URI\n"); learned_hostlist_saved = GNUNET_YES; - if ((learned_hostlist_downloaded == GNUNET_YES) && (adv_sent == GNUNET_YES)) + if ( (learned_hostlist_downloaded == GNUNET_YES) && + (adv_sent == GNUNET_YES) ) { - GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); + GNUNET_SCHEDULER_add_now (&do_shutdown, + NULL); } } return GNUNET_OK; @@ -239,7 +256,8 @@ static int process_adv_sent (void *cls, const char *subsystem, const char *name, - uint64_t value, int is_persistent) + uint64_t value, + int is_persistent) { if ((value >= 1) && (adv_sent == GNUNET_NO)) { @@ -249,7 +267,8 @@ process_adv_sent (void *cls, if ((learned_hostlist_downloaded == GNUNET_YES) && (learned_hostlist_saved == GNUNET_YES)) { - GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); + GNUNET_SCHEDULER_add_now (&do_shutdown, + NULL); } } return GNUNET_OK; @@ -273,8 +292,11 @@ check_statistics (void *cls) if (NULL != download_stats) GNUNET_STATISTICS_get_cancel (download_stats); download_stats = - GNUNET_STATISTICS_get (learn_peer.stats, "hostlist", stat, - &process_downloads_done, &process_downloads, + GNUNET_STATISTICS_get (learn_peer.stats, + "hostlist", + stat, + &process_downloads_done, + &process_downloads, &learn_peer); if (NULL != urisrecv_stat) GNUNET_STATISTICS_get_cancel (urisrecv_stat); @@ -293,55 +315,64 @@ check_statistics (void *cls) GNUNET_STATISTICS_get (adv_peer.stats, "hostlist", gettext_noop ("# hostlist advertisements send"), &process_adv_sent_done, - &process_adv_sent, NULL); + &process_adv_sent, + NULL); } check_task = - GNUNET_SCHEDULER_add_delayed (CHECK_INTERVAL, &check_statistics, NULL); + GNUNET_SCHEDULER_add_delayed (CHECK_INTERVAL, + &check_statistics, + NULL); } -/** - * Core handler for p2p hostlist advertisements - */ static int -ad_arrive_handler (void *cls, - const struct GNUNET_PeerIdentity *peer, +check_ad_arrive (void *cls, + const struct GNUNET_MessageHeader *message) +{ + const char *end = (const char *) &message[1]; + if ('\0' != end[ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - 1]) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + + +static void +handle_ad_arrive (void *cls, const struct GNUNET_MessageHeader *message) { char *hostname; char *expected_uri; unsigned long long port; - const struct GNUNET_MessageHeader *incoming; const char *end; - if (-1 == - GNUNET_CONFIGURATION_get_value_number (adv_peer.cfg, "HOSTLIST", - "HTTPPORT", &port)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (adv_peer.cfg, + "HOSTLIST", + "HTTPPORT", + &port)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not read advertising server's configuration\n"); - return GNUNET_SYSERR; + return; } if (GNUNET_SYSERR == - GNUNET_CONFIGURATION_get_value_string (adv_peer.cfg, "HOSTLIST", - "EXTERNAL_DNS_NAME", &hostname)) + GNUNET_CONFIGURATION_get_value_string (adv_peer.cfg, + "HOSTLIST", + "EXTERNAL_DNS_NAME", + &hostname)) hostname = GNUNET_RESOLVER_local_fqdn_get (); - GNUNET_asprintf (&expected_uri, "http://%s:%u/", + GNUNET_asprintf (&expected_uri, + "http://%s:%u/", hostname != NULL ? hostname : "localhost", (unsigned int) port); - incoming = (const struct GNUNET_MessageHeader *) message; - end = (const char *) &incoming[1]; - if ('\0' != - end[ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - 1]) - { - GNUNET_break (0); - GNUNET_free (expected_uri); - GNUNET_free_non_null (hostname); - return GNUNET_SYSERR; - } + end = (const char *) &message[1]; current_adv_uri = GNUNET_strdup (end); - if (0 == strcmp (expected_uri, current_adv_uri)) + if (0 == strcmp (expected_uri, + current_adv_uri)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received hostlist advertisement with URI `%s' as expected\n", @@ -352,25 +383,24 @@ ad_arrive_handler (void *cls, else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected URI `%s' and received URI `%s' differ\n", - expected_uri, current_adv_uri); + expected_uri, + current_adv_uri); GNUNET_free (expected_uri); GNUNET_free_non_null (hostname); - return GNUNET_OK; } -/** - * List of handlers if we are learning. - */ -static struct GNUNET_CORE_MessageHandler learn_handlers[] = { - {&ad_arrive_handler, GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT, 0}, - {NULL, 0, 0} -}; - - static void -setup_learn_peer (struct PeerContext *p, const char *cfgname) +setup_learn_peer (struct PeerContext *p, + const char *cfgname) { + GNUNET_MQ_hd_var_size (ad_arrive, + GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT, + struct GNUNET_MessageHeader); + struct GNUNET_MQ_MessageHandler learn_handlers[] = { + make_ad_arrive_handler (NULL), + GNUNET_MQ_handler_end () + }; char *filename; unsigned int result; char *binary; @@ -383,9 +413,13 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname) binary, "gnunet-service-arm", "-c", cfgname, NULL); - GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); + GNUNET_assert (GNUNET_OK == + GNUNET_CONFIGURATION_load (p->cfg, + cfgname)); if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (p->cfg, "HOSTLIST", "HOSTLISTFILE", + GNUNET_CONFIGURATION_get_value_string (p->cfg, + "HOSTLIST", + "HOSTLISTFILE", &filename)) { if (GNUNET_YES == GNUNET_DISK_file_test (filename)) @@ -393,34 +427,43 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname) result = UNLINK (filename); if (result == 0) GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Hostlist file `%s' was removed\n"), filename); + _("Hostlist file `%s' was removed\n"), + filename); } GNUNET_free (filename); } - p->core = - GNUNET_CORE_connect (p->cfg, NULL, NULL, NULL, NULL, NULL, GNUNET_NO, - NULL, GNUNET_NO, learn_handlers); + p->core = GNUNET_CORE_connecT (p->cfg, + NULL, + NULL, + NULL, + NULL, + learn_handlers); GNUNET_assert (NULL != p->core); - p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg); + p->stats = GNUNET_STATISTICS_create ("hostlist", + p->cfg); GNUNET_assert (NULL != p->stats); GNUNET_free (binary); } static void -setup_adv_peer (struct PeerContext *p, const char *cfgname) +setup_adv_peer (struct PeerContext *p, + const char *cfgname) { char *binary; binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + GNUNET_OS_start_process (GNUNET_YES, + GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, NULL, binary, "gnunet-service-arm", "-c", cfgname, NULL); - GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); + GNUNET_assert (GNUNET_OK == + GNUNET_CONFIGURATION_load (p->cfg, + cfgname)); p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg); GNUNET_assert (NULL != p->stats); GNUNET_free (binary); @@ -428,7 +471,9 @@ setup_adv_peer (struct PeerContext *p, const char *cfgname) static void -run (void *cls, char *const *args, const char *cfgfile, +run (void *cls, + char *const *args, + const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { timeout = GNUNET_NO; @@ -440,12 +485,17 @@ run (void *cls, char *const *args, const char *cfgfile, cfg = c; - setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf"); - setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf"); - timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); - + setup_adv_peer (&adv_peer, + "test_learning_adv_peer.conf"); + setup_learn_peer (&learn_peer, + "test_learning_learn_peer.conf"); + timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, + &timeout_error, + NULL); check_task = - GNUNET_SCHEDULER_add_delayed (CHECK_INTERVAL, &check_statistics, NULL); + GNUNET_SCHEDULER_add_delayed (CHECK_INTERVAL, + &check_statistics, + NULL); } @@ -463,13 +513,18 @@ check () GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, - "test-gnunet-daemon-hostlist-learning", "nohelp", options, - &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, + argv, + "test-gnunet-daemon-hostlist-learning", + "nohelp", + options, + &run, + NULL); failed = GNUNET_NO; if (timeout == GNUNET_YES) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Testcase timeout\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Testcase timeout\n"); failed = GNUNET_YES; } if (adv_arrived != GNUNET_YES) @@ -522,7 +577,8 @@ main (int argc, char *argv[]) ret = check (); GNUNET_DISK_directory_remove ("/tmp/test-gnunet-hostlist-peer-1"); GNUNET_DISK_directory_remove ("/tmp/test-gnunet-hostlist-peer-2"); - if (GNUNET_YES == GNUNET_DISK_file_test ("hostlists_learn_peer.file")) + if (GNUNET_YES == + GNUNET_DISK_file_test ("hostlists_learn_peer.file")) { if (0 == UNLINK ("hostlists_learn_peer.file")) GNUNET_log (GNUNET_ERROR_TYPE_INFO, diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index eb752660c..dc2450248 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h @@ -198,13 +198,41 @@ GNUNET_HELLO_address_check_option (const struct GNUNET_HELLO_Address *address, #define GNUNET_HELLO_address_free(addr) GNUNET_free(addr) +GNUNET_NETWORK_STRUCT_BEGIN + /** * A HELLO message is used to exchange information about - * transports with other peers. This struct is guaranteed - * to start with a `struct GNUNET_MessageHeader`, everything else - * should be internal to the HELLO library. + * transports with other peers. This struct is always + * followed by the actual network addresses which have + * the format: + * + * 1) transport-name (0-terminated) + * 2) address-length (uint16_t, network byte order; possibly + * unaligned!) + * 3) address expiration (`struct GNUNET_TIME_AbsoluteNBO`); possibly + * unaligned!) + * 4) address (address-length bytes; possibly unaligned!) */ -struct GNUNET_HELLO_Message; +struct GNUNET_HELLO_Message +{ + /** + * Type will be #GNUNET_MESSAGE_TYPE_HELLO. + */ + struct GNUNET_MessageHeader header; + + /** + * Use in F2F mode: Do not gossip this HELLO message + */ + uint32_t friend_only GNUNET_PACKED; + + /** + * The public key of the peer. + */ + struct GNUNET_CRYPTO_EddsaPublicKey publicKey; + +}; +GNUNET_NETWORK_STRUCT_END + /** diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 262f85c8d..2b6780c08 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c @@ -1494,7 +1494,7 @@ run (void *cls, }; struct GNUNET_MQ_MessageHandler core_handlers[] = { make_p2p_estimate_handler (NULL), - GNUNET_MQ_handler_end (), + GNUNET_MQ_handler_end () }; char *proof; struct GNUNET_CRYPTO_EddsaPrivateKey *pk; diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c index 9f3162690..0f67977a1 100644 --- a/src/revocation/gnunet-service-revocation.c +++ b/src/revocation/gnunet-service-revocation.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2013, 2014 GNUnet e.V. + Copyright (C) 2013, 2014, 2016 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public Licerevocation as published @@ -68,7 +68,7 @@ struct PeerEntry /** * Tasked used to trigger the set union operation. */ - struct GNUNET_SCHEDULER_Task * transmit_task; + struct GNUNET_SCHEDULER_Task *transmit_task; /** * Handle to active set union operation (over revocation sets). @@ -164,43 +164,10 @@ new_peer_entry(const struct GNUNET_PeerIdentity *peer) &peer_entry->id, peer_entry, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); - peer_entry->mq = GNUNET_CORE_mq_create (core_api, peer); return peer_entry; } -/** - * Delete a PeerEntry for the given peer - * - * @param peer the identity of the peer to delete - */ -static void -delete_peer_entry(const struct GNUNET_PeerIdentity *peer) -{ - struct PeerEntry *peer_entry; - - peer_entry = GNUNET_CONTAINER_multipeermap_get (peers, - peer); - GNUNET_assert (NULL != peer_entry); - GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multipeermap_remove (peers, - peer, - peer_entry)); - GNUNET_MQ_destroy (peer_entry->mq); - if (NULL != peer_entry->transmit_task) - { - GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); - peer_entry->transmit_task = NULL; - } - if (NULL != peer_entry->so) - { - GNUNET_SET_operation_cancel (peer_entry->so); - peer_entry->so = NULL; - } - GNUNET_free (peer_entry); -} - - /** * An revoke message has been received, check that it is well-formed. * @@ -293,6 +260,10 @@ do_flood (void *cls, struct GNUNET_MQ_Envelope *e; struct RevokeMessage *cp; + if (NULL == pe->mq) + return GNUNET_OK; /* peer connected to us via SET, + but we have no direct CORE + connection for flooding */ e = GNUNET_MQ_msg (cp, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE); *cp = *rm; @@ -432,21 +403,16 @@ handle_revoke_message (void *cls, * Core handler for flooded revocation messages. * * @param cls closure unused - * @param message message - * @param peer peer identity this message is from (ignored) + * @param rm revocation message */ -static int -handle_p2p_revoke_message (void *cls, - const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message) +static void +handle_p2p_revoke (void *cls, + const struct RevokeMessage *rm) { - const struct RevokeMessage *rm; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received REVOKE message from peer\n"); - rm = (const struct RevokeMessage *) message; - GNUNET_break_op (GNUNET_SYSERR != publicize_rm (rm)); - return GNUNET_OK; + "Received REVOKE message\n"); + GNUNET_break_op (GNUNET_SYSERR != + publicize_rm (rm)); } @@ -483,9 +449,8 @@ add_revocation (void *cls, return; } rm = element->data; - (void) handle_p2p_revoke_message (NULL, - &peer_entry->id, - &rm->header); + (void) handle_p2p_revoke (NULL, + rm); GNUNET_STATISTICS_update (stats, gettext_noop ("# revocation messages received via set union"), 1, GNUNET_NO); @@ -556,9 +521,10 @@ transmit_task_cb (void *cls) * @param cls closure * @param peer peer identity this notification is about */ -static void +static void * handle_core_connect (void *cls, - const struct GNUNET_PeerIdentity *peer) + const struct GNUNET_PeerIdentity *peer, + struct GNUNET_MQ_Handle *mq) { struct PeerEntry *peer_entry; struct GNUNET_HashCode my_hash; @@ -568,7 +534,7 @@ handle_core_connect (void *cls, &my_identity, sizeof (my_identity))) { - return; + return NULL; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -586,9 +552,11 @@ handle_core_connect (void *cls, and CADET+SET were faster and already produced a #handle_revocation_union_request() for us to deal with. This should be rare, but isn't impossible. */ - return; + peer_entry->mq = mq; + return peer_entry; } - peer_entry = new_peer_entry(peer); + peer_entry = new_peer_entry (peer); + peer_entry->mq = mq; GNUNET_CRYPTO_hash (&my_identity, sizeof (my_identity), &my_hash); @@ -606,6 +574,7 @@ handle_core_connect (void *cls, &transmit_task_cb, peer_entry); } + return peer_entry; } @@ -615,22 +584,38 @@ handle_core_connect (void *cls, * * @param cls closure * @param peer peer identity this notification is about + * @param internal_cls our `struct PeerEntry` for this peer */ static void handle_core_disconnect (void *cls, - const struct GNUNET_PeerIdentity *peer) + const struct GNUNET_PeerIdentity *peer, + void *internal_cls) { + struct PeerEntry *peer_entry = internal_cls; + if (0 == memcmp (peer, &my_identity, sizeof (my_identity))) - { return; - } - + GNUNET_assert (NULL != peer_entry); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' disconnected from us\n", GNUNET_i2s (peer)); - delete_peer_entry(peer); + GNUNET_assert (GNUNET_YES == + GNUNET_CONTAINER_multipeermap_remove (peers, + peer, + peer_entry)); + if (NULL != peer_entry->transmit_task) + { + GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); + peer_entry->transmit_task = NULL; + } + if (NULL != peer_entry->so) + { + GNUNET_SET_operation_cancel (peer_entry->so); + peer_entry->so = NULL; + } + GNUNET_free (peer_entry); GNUNET_STATISTICS_update (stats, "# peers connected", -1, @@ -676,7 +661,7 @@ shutdown_task (void *cls) } if (NULL != core_api) { - GNUNET_CORE_disconnect (core_api); + GNUNET_CORE_disconnecT (core_api); core_api = NULL; } if (NULL != stats) @@ -762,7 +747,7 @@ handle_revocation_union_request (void *cls, other_peer); if (NULL == peer_entry) { - peer_entry = new_peer_entry(other_peer); + peer_entry = new_peer_entry (other_peer); } peer_entry->so = GNUNET_SET_accept (request, GNUNET_SET_RESULT_ADDED, @@ -792,6 +777,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { + GNUNET_MQ_hd_fixed_size (p2p_revoke, + GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, + struct RevokeMessage); static const struct GNUNET_SERVER_MessageHandler handlers[] = { {&handle_query_message, NULL, GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, sizeof (struct QueryMessage)}, @@ -799,10 +787,9 @@ run (void *cls, sizeof (struct RevokeMessage)}, {NULL, NULL, 0, 0} }; - static const struct GNUNET_CORE_MessageHandler core_handlers[] = { - {&handle_p2p_revoke_message, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, - sizeof (struct RevokeMessage)}, - {NULL, 0, 0} + struct GNUNET_MQ_MessageHandler core_handlers[] = { + make_p2p_revoke_handler (NULL), + GNUNET_MQ_handler_end () }; char *fn; uint64_t left; @@ -823,10 +810,13 @@ run (void *cls, } cfg = c; srv = server; - revocation_map = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO); + revocation_map = GNUNET_CONTAINER_multihashmap_create (16, + GNUNET_NO); nc = GNUNET_SERVER_notification_context_create (server, 1); if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, "REVOCATION", "WORKBITS", + GNUNET_CONFIGURATION_get_value_number (cfg, + "REVOCATION", + "WORKBITS", &revocation_work_required)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, @@ -907,16 +897,12 @@ run (void *cls, GNUNET_YES); GNUNET_SERVER_add_handlers (srv, handlers); /* Connect to core service and register core handlers */ - core_api = GNUNET_CORE_connect (cfg, /* Main configuration */ - NULL, /* Closure passed to functions */ - &core_init, /* Call core_init once connected */ - &handle_core_connect, /* Handle connects */ - &handle_core_disconnect, /* Handle disconnects */ - NULL, /* Don't want notified about all incoming messages */ - GNUNET_NO, /* For header only inbound notification */ - NULL, /* Don't want notified about all outbound messages */ - GNUNET_NO, /* For header only outbound notification */ - core_handlers); /* Register these handlers */ + core_api = GNUNET_CORE_connecT (cfg, /* Main configuration */ + NULL, /* Closure passed to functions */ + &core_init, /* Call core_init once connected */ + &handle_core_connect, /* Handle connects */ + &handle_core_disconnect, /* Handle disconnects */ + core_handlers); /* Register these handlers */ if (NULL == core_api) { GNUNET_SCHEDULER_shutdown (); diff --git a/src/revocation/test_revocation.c b/src/revocation/test_revocation.c index e63486c8d..ba659d9d8 100644 --- a/src/revocation/test_revocation.c +++ b/src/revocation/test_revocation.c @@ -280,9 +280,10 @@ identity_disconnect_adapter (void *cls, } -static void +static void * connect_cb (void *cls, - const struct GNUNET_PeerIdentity *peer) + const struct GNUNET_PeerIdentity *peer, + struct GNUNET_MQ_Handle *mq) { static int connects = 0; @@ -308,6 +309,7 @@ connect_cb (void *cls, &identity_disconnect_adapter, &testpeers[1]); } + return NULL; } @@ -335,10 +337,11 @@ core_connect_adapter (void *cls, struct TestPeer *me = cls; me->cfg = cfg; - me->ch = GNUNET_CORE_connect (cfg, me, NULL, - &connect_cb, NULL, - NULL, GNUNET_NO, - NULL, GNUNET_NO, + me->ch = GNUNET_CORE_connecT (cfg, + me, + NULL, + &connect_cb, + NULL, NULL); if (NULL == me->ch) GNUNET_log(GNUNET_ERROR_TYPE_ERROR, @@ -353,7 +356,7 @@ core_disconnect_adapter (void *cls, { struct TestPeer *me = cls; - GNUNET_CORE_disconnect (me->ch); + GNUNET_CORE_disconnecT (me->ch); me->ch = NULL; } diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index e623ae46c..f56cd4bc8 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2007-2015 GNUnet e.V. + Copyright (C) 2007-2016 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -70,10 +70,10 @@ struct Peer struct GNUNET_PeerIdentity pid; /** - * Our handle for the request to transmit HELLOs to this peer; NULL - * if no such request is pending. + * Our handle for transmitting to this peer; NULL + * if peer is not connected. */ - struct GNUNET_CORE_TransmitHandle *hello_req; + struct GNUNET_MQ_Handle *mq; /** * Pointer to the HELLO message of this peer; can be NULL. @@ -117,11 +117,6 @@ struct Peer */ int is_friend; - /** - * Are we connected to this peer right now? - */ - int is_connected; - }; @@ -264,16 +259,11 @@ free_peer (void *cls, { struct Peer *pos = value; - GNUNET_break (GNUNET_NO == pos->is_connected); + GNUNET_break (NULL == pos->mq); GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (peers, pid, pos)); - if (NULL != pos->hello_req) - { - GNUNET_CORE_notify_transmit_ready_cancel (pos->hello_req); - pos->hello_req = NULL; - } if (NULL != pos->hello_delay_task) { GNUNET_SCHEDULER_cancel (pos->hello_delay_task); @@ -329,7 +319,7 @@ attempt_connect (struct Peer *pos) } if (pos->is_friend) strength *= 2; /* friends always count more */ - if (pos->is_connected) + if (NULL != pos->mq) strength *= 2; /* existing connections preferred */ if (strength == pos->strength) return; /* nothing to do */ @@ -378,8 +368,8 @@ make_peer (const struct GNUNET_PeerIdentity *peer, { ret->hello = GNUNET_malloc (GNUNET_HELLO_size (hello)); GNUNET_memcpy (ret->hello, - hello, - GNUNET_HELLO_size (hello)); + hello, + GNUNET_HELLO_size (hello)); } GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (peers, @@ -419,20 +409,6 @@ setup_filter (struct Peer *peer) } -/** - * Function to fill send buffer with HELLO. - * - * @param cls `struct Peer` of the target peer - * @param size number of bytes available in @a buf - * @param buf where the callee should write the message - * @return number of bytes written to @a buf - */ -static size_t -hello_advertising_ready (void *cls, - size_t size, - void *buf); - - /** * Closure for #find_advertisable_hello(). */ @@ -492,7 +468,8 @@ find_advertisable_hello (void *cls, hs = GNUNET_HELLO_size (pos->hello); if (hs > fah->max_size) return GNUNET_YES; - GNUNET_CRYPTO_hash (&fah->peer->pid, sizeof (struct GNUNET_PeerIdentity), &hc); + GNUNET_CRYPTO_hash (&fah->peer->pid, + sizeof (struct GNUNET_PeerIdentity), &hc); if (GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (pos->filter, &hc)) @@ -512,13 +489,13 @@ schedule_next_hello (void *cls) { struct Peer *pl = cls; struct FindAdvHelloContext fah; - size_t next_want; + struct GNUNET_MQ_Envelope *env; + size_t want; struct GNUNET_TIME_Relative delay; + struct GNUNET_HashCode hc; pl->hello_delay_task = NULL; - GNUNET_assert (GNUNET_YES == pl->is_connected); - if (pl->hello_req != NULL) - return; /* did not finish sending the previous one */ + GNUNET_assert (NULL != pl->mq); /* find applicable HELLOs */ fah.peer = pl; fah.result = NULL; @@ -533,18 +510,37 @@ schedule_next_hello (void *cls) pl); if (NULL == fah.result) return; - next_want = GNUNET_HELLO_size (fah.result->hello); delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed); - if (0 == delay.rel_value_us) - { - /* now! */ - pl->hello_req = - GNUNET_CORE_notify_transmit_ready (handle, GNUNET_YES, - GNUNET_CORE_PRIO_BEST_EFFORT, - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - &pl->pid, next_want, - &hello_advertising_ready, pl); - } + if (0 != delay.rel_value_us) + return; + + want = GNUNET_HELLO_size (fah.result->hello); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Sending HELLO with %u bytes", + (unsigned int) want); + env = GNUNET_MQ_msg_copy (&fah.result->hello->header); + GNUNET_MQ_send (pl->mq, + env); + + /* avoid sending this one again soon */ + GNUNET_CRYPTO_hash (&pl->pid, + sizeof (struct GNUNET_PeerIdentity), + &hc); + GNUNET_CONTAINER_bloomfilter_add (fah.result->filter, + &hc); + + GNUNET_STATISTICS_update (stats, + gettext_noop ("# HELLO messages gossipped"), + 1, + GNUNET_NO); + /* prepare to send the next one */ + if (NULL != pl->hello_delay_task) + GNUNET_SCHEDULER_cancel (pl->hello_delay_task); + pl->next_hello_allowed + = GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY); + pl->hello_delay_task + = GNUNET_SCHEDULER_add_now (&schedule_next_hello, + pl); } @@ -568,14 +564,9 @@ reschedule_hellos (void *cls, if (skip == peer) return GNUNET_YES; - if (!peer->is_connected) + if (NULL == peer->mq) return GNUNET_YES; - if (peer->hello_req != NULL) - { - GNUNET_CORE_notify_transmit_ready_cancel (peer->hello_req); - peer->hello_req = NULL; - } - if (peer->hello_delay_task != NULL) + if (NULL != peer->hello_delay_task) { GNUNET_SCHEDULER_cancel (peer->hello_delay_task); peer->hello_delay_task = NULL; @@ -591,12 +582,17 @@ reschedule_hellos (void *cls, * * @param cls closure * @param peer peer identity this notification is about + * @param mq message queue for communicating with @a peer + * @return our `struct Peer` for @a peer */ -static void +static void * connect_notify (void *cls, - const struct GNUNET_PeerIdentity *peer) + const struct GNUNET_PeerIdentity *peer, + struct GNUNET_MQ_Handle *mq) { struct Peer *pos; + uint64_t flags; + const void *extra; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core told us that we are connecting to `%s'\n", @@ -604,8 +600,13 @@ connect_notify (void *cls, if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) - return; - + return NULL; + extra = GNUNET_CORE_get_mq_options (GNUNET_YES, + GNUNET_CORE_PRIO_BEST_EFFORT, + &flags); + GNUNET_MQ_set_options (mq, + flags, + extra); connection_count++; GNUNET_STATISTICS_set (stats, gettext_noop ("# peers connected"), @@ -621,9 +622,9 @@ connect_notify (void *cls, } else { - GNUNET_assert (GNUNET_NO == pos->is_connected); + GNUNET_assert (NULL == pos->mq); } - pos->is_connected = GNUNET_YES; + pos->mq = mq; if (pos->is_friend) { friend_count++; @@ -638,6 +639,7 @@ connect_notify (void *cls, reschedule_hellos (NULL, peer, pos); + return pos; } @@ -682,38 +684,27 @@ add_peer_task (void *cls) * * @param cls closure * @param peer peer identity this notification is about + * @param internal_cls the `struct Peer` for this peer */ static void disconnect_notify (void *cls, - const struct GNUNET_PeerIdentity *peer) + const struct GNUNET_PeerIdentity *peer, + void *internal_cls) { - struct Peer *pos; + struct Peer *pos = internal_cls; - if (0 == memcmp (&my_identity, - peer, - sizeof (struct GNUNET_PeerIdentity))) - return; + if (NULL == pos) + return; /* myself, we're shutting down */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core told us that we disconnected from `%s'\n", GNUNET_i2s (peer)); - pos = GNUNET_CONTAINER_multipeermap_get (peers, peer); - if (NULL == pos) + if (NULL == pos->mq) { GNUNET_break (0); return; } - if (GNUNET_YES != pos->is_connected) - { - GNUNET_break (0); - return; - } - pos->is_connected = GNUNET_NO; + pos->mq = NULL; connection_count--; - if (NULL != pos->hello_req) - { - GNUNET_CORE_notify_transmit_ready_cancel (pos->hello_req); - pos->hello_req = NULL; - } if (NULL != pos->hello_delay_task) { GNUNET_SCHEDULER_cancel (pos->hello_delay_task); @@ -891,7 +882,7 @@ process_peer (void *cls, GNUNET_CONTAINER_bloomfilter_free (pos->filter); pos->filter = NULL; } - if ( (GNUNET_NO == pos->is_connected) && + if ( (NULL == pos->mq) && (GNUNET_NO == pos->is_friend) ) free_peer (NULL, &pos->pid, @@ -911,7 +902,7 @@ process_peer (void *cls, /** - * Function called after #GNUNET_CORE_connect has succeeded + * Function called after #GNUNET_CORE_connecT has succeeded * (or failed for good). * * @param cls closure @@ -1021,115 +1012,76 @@ done_offer_hello (void *cls) * This function is called whenever an encrypted HELLO message is * received. * - * @param cls closure - * @param other the other peer involved (sender or receiver, NULL - * for loopback messages where we are both sender and receiver) + * @param cls closure with the peer identity of the sender * @param message the actual HELLO message - * @return #GNUNET_OK to keep the connection open, - * #GNUNET_SYSERR to close it (signal serious error) + * @return #GNUNET_OK if @a message is well-formed + * #GNUNET_SYSERR if @a message is invalid */ static int -handle_encrypted_hello (void *cls, - const struct GNUNET_PeerIdentity *other, - const struct GNUNET_MessageHeader *message) +check_hello (void *cls, + const struct GNUNET_HELLO_Message *message) { - struct Peer *peer; struct GNUNET_PeerIdentity pid; - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received encrypted HELLO from peer `%s'", - GNUNET_i2s (other)); + if (GNUNET_OK != - GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) message, &pid)) + GNUNET_HELLO_get_id (message, + &pid)) { GNUNET_break_op (0); return GNUNET_SYSERR; } + return GNUNET_OK; +} + + +/** + * This function is called whenever an encrypted HELLO message is + * received. + * + * @param cls closure with the peer identity of the sender + * @param message the actual HELLO message + */ +static void +handle_hello (void *cls, + const struct GNUNET_HELLO_Message *message) +{ + const struct GNUNET_PeerIdentity *other = cls; + struct Peer *peer; + struct GNUNET_PeerIdentity pid; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received encrypted HELLO from peer `%s'", + GNUNET_i2s (other)); + GNUNET_assert (GNUNET_OK == + GNUNET_HELLO_get_id (message, + &pid)); GNUNET_STATISTICS_update (stats, gettext_noop ("# HELLO messages received"), 1, GNUNET_NO); - peer = GNUNET_CONTAINER_multipeermap_get (peers, &pid); + peer = GNUNET_CONTAINER_multipeermap_get (peers, + &pid); if (NULL == peer) { if ( (GNUNET_YES == friends_only) || (friend_count < minimum_friend_count) ) - return GNUNET_OK; + return; } else { if ( (GNUNET_YES != peer->is_friend) && (GNUNET_YES == friends_only) ) - return GNUNET_OK; + return; if ((GNUNET_YES != peer->is_friend) && (friend_count < minimum_friend_count)) - return GNUNET_OK; + return; } if (NULL != oh) GNUNET_TRANSPORT_offer_hello_cancel (oh); oh = GNUNET_TRANSPORT_offer_hello (cfg, - message, + &message->header, &done_offer_hello, NULL); - return GNUNET_OK; -} - - -/** - * Function to fill send buffer with HELLO. - * - * @param cls `struct Peer` of the target peer - * @param size number of bytes available in buf - * @param buf where the callee should write the message - * @return number of bytes written to buf - */ -static size_t -hello_advertising_ready (void *cls, - size_t size, - void *buf) -{ - struct Peer *pl = cls; - struct FindAdvHelloContext fah; - size_t want; - struct GNUNET_HashCode hc; - - pl->hello_req = NULL; - GNUNET_assert (GNUNET_YES == pl->is_connected); - /* find applicable HELLOs */ - fah.peer = pl; - fah.result = NULL; - fah.max_size = size; - fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; - GNUNET_CONTAINER_multipeermap_iterate (peers, - &find_advertisable_hello, - &fah); - want = 0; - if (NULL != fah.result) - { - want = GNUNET_HELLO_size (fah.result->hello); - GNUNET_assert (want <= size); - GNUNET_memcpy (buf, - fah.result->hello, - want); - GNUNET_CRYPTO_hash (&pl->pid, - sizeof (struct GNUNET_PeerIdentity), - &hc); - GNUNET_CONTAINER_bloomfilter_add (fah.result->filter, - &hc); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending HELLO with %u bytes", - (unsigned int) want); - GNUNET_STATISTICS_update (stats, - gettext_noop ("# HELLO messages gossipped"), 1, - GNUNET_NO); - } - - if (pl->hello_delay_task != NULL) - GNUNET_SCHEDULER_cancel (pl->hello_delay_task); - pl->next_hello_allowed = - GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY); - pl->hello_delay_task = GNUNET_SCHEDULER_add_now (&schedule_next_hello, pl); - return want; } @@ -1149,7 +1101,7 @@ cleaning_task (void *cls) } if (NULL != handle) { - GNUNET_CORE_disconnect (handle); + GNUNET_CORE_disconnecT (handle); handle = NULL; } whitelist_peers (); @@ -1195,9 +1147,12 @@ run (void *cls, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { - static struct GNUNET_CORE_MessageHandler handlers[] = { - {&handle_encrypted_hello, GNUNET_MESSAGE_TYPE_HELLO, 0}, - {NULL, 0, 0} + GNUNET_MQ_hd_var_size (hello, + GNUNET_MESSAGE_TYPE_HELLO, + struct GNUNET_HELLO_Message); + struct GNUNET_MQ_MessageHandler handlers[] = { + make_hello_handler (NULL), + GNUNET_MQ_handler_end () }; unsigned long long opt; @@ -1234,14 +1189,12 @@ run (void *cls, &blacklist_check, NULL); ats = GNUNET_ATS_connectivity_init (cfg); - handle = - GNUNET_CORE_connect (cfg, NULL, - &core_init, - &connect_notify, - &disconnect_notify, - NULL, GNUNET_NO, - NULL, GNUNET_NO, - handlers); + handle = GNUNET_CORE_connecT (cfg, + NULL, + &core_init, + &connect_notify, + &disconnect_notify, + handlers); GNUNET_SCHEDULER_add_shutdown (&cleaning_task, NULL); if (NULL == handle) @@ -1290,7 +1243,8 @@ main (int argc, char *const *argv) /** * MINIMIZE heap size (way below 128k) since this process doesn't need much. */ -void __attribute__ ((constructor)) GNUNET_ARM_memory_init () +void __attribute__ ((constructor)) +GNUNET_ARM_memory_init () { mallopt (M_TRIM_THRESHOLD, 4 * 1024); mallopt (M_TOP_PAD, 1 * 1024);