From 72a2c1b9542d68eab32f483a1c53eeec19bc12b3 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 9 Feb 2015 14:28:45 +0000 Subject: -do only send HELLO to clients once on startup, do only send fully initialized HELLO to clients if we can help it, even the first one; do not perform blacklist check twice for try_connect --- src/transport/gnunet-service-transport.c | 26 +++++-- src/transport/gnunet-service-transport_clients.c | 79 ++++++++++----------- src/transport/gnunet-service-transport_hello.c | 80 +++++++++++++--------- .../gnunet-service-transport_neighbours.c | 4 +- src/transport/gnunet-service-transport_plugins.c | 29 +++++--- .../gnunet-service-transport_validation.c | 10 ++- src/transport/plugin_transport_tcp.c | 18 +++-- src/transport/plugin_transport_udp_broadcasting.c | 7 +- src/transport/plugin_transport_wlan.c | 10 +-- src/transport/transport_api.c | 14 ++-- 10 files changed, 162 insertions(+), 115 deletions(-) (limited to 'src/transport') diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 336925f4f..65519914a 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -215,6 +215,11 @@ transmit_our_hello (void *cls, { const struct GNUNET_MessageHeader *hello = cls; + if (0 == + memcmp (peer, + &GST_my_identity, + sizeof (struct GNUNET_PeerIdentity))) + return; /* not to ourselves */ if (GNUNET_NO == GST_neighbours_test_connected (peer)) return; @@ -236,8 +241,13 @@ static void process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Broadcasting HELLO to clients\n"); GST_clients_broadcast (hello, GNUNET_NO); - GST_neighbours_iterate (&transmit_our_hello, (void *) hello); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Broadcasting HELLO to neighbours\n"); + GST_neighbours_iterate (&transmit_our_hello, + (void *) hello); } @@ -1051,14 +1061,18 @@ run (void *cls, "Limiting number of sockets to %u: validation %u, neighbors: %u\n", max_fd, (max_fd / 3), (max_fd / 3) * 2); - friend_only = GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, "topology", - "FRIENDS-ONLY"); + friend_only = GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, + "topology", + "FRIENDS-ONLY"); if (GNUNET_SYSERR == friend_only) friend_only = GNUNET_NO; /* According to topology defaults */ /* start subsystems */ - GST_hello_start (friend_only, &process_hello_update, NULL ); - GNUNET_assert(NULL != GST_hello_get()); - GST_blacklist_start (GST_server, GST_cfg, &GST_my_identity); + GST_hello_start (friend_only, + &process_hello_update, + NULL); + GST_blacklist_start (GST_server, + GST_cfg, + &GST_my_identity); is = GNUNET_ATS_scanner_init (); GST_ats_connect = GNUNET_ATS_connectivity_init (GST_cfg); GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 8e0b3fe68..cea1dc14e 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2010-2014 Christian Grothoff (and other contributing authors) + Copyright (C) 2010-2015 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -613,38 +613,57 @@ clients_handle_start (void *cls, const struct GNUNET_MessageHeader *message) { const struct StartMessage *start; + const struct GNUNET_MessageHeader *hello; struct TransportClient *tc; uint32_t options; tc = lookup_client (client); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Client %p sent START\n", tc); if (NULL != tc) { /* got 'start' twice from the same client, not allowed */ GNUNET_break (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, + GNUNET_SYSERR); return; } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Client %p sent START\n", + client); start = (const struct StartMessage *) message; options = ntohl (start->options); if ((0 != (1 & options)) && (0 != - memcmp (&start->self, &GST_my_identity, + memcmp (&start->self, + &GST_my_identity, sizeof (struct GNUNET_PeerIdentity)))) { /* client thinks this is a different peer, reject */ GNUNET_break (0); - GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + GNUNET_SERVER_receive_done (client, + GNUNET_SYSERR); return; } tc = setup_client (client); tc->send_payload = (0 != (2 & options)); - unicast (tc, - GST_hello_get (), - GNUNET_NO); - GST_neighbours_iterate (¬ify_client_about_neighbour, tc); - GNUNET_SERVER_receive_done (client, GNUNET_OK); + hello = GST_hello_get (); + if (NULL == hello) + { + /* We are during startup and should have no neighbours, hence + iteration with NULL must work. The HELLO will be sent to + all clients once it has been created, so this should happen + next anyway, and certainly before we get neighbours. */ + GST_neighbours_iterate (NULL, NULL); + } + else + { + unicast (tc, + hello, + GNUNET_NO); + GST_neighbours_iterate (¬ify_client_about_neighbour, + tc); + } + GNUNET_SERVER_receive_done (client, + GNUNET_OK); } @@ -790,35 +809,6 @@ clients_handle_send (void *cls, } -/** - * Try to initiate a connection to the given peer if the blacklist - * allowed it. - * - * @param cls closure (unused, NULL) - * @param peer identity of peer that was tested - * @param result #GNUNET_OK if the connection is allowed, - * #GNUNET_NO if not - */ -static void -try_connect_if_allowed (void *cls, - const struct GNUNET_PeerIdentity *peer, - int result) -{ - if (GNUNET_OK != result) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Blacklist refuses connection attempt to peer `%s'\n"), - GNUNET_i2s (peer)); - return; /* not allowed */ - } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Blacklist allows connection attempt to peer `%s'\n", - GNUNET_i2s (peer)); - - GST_neighbours_try_connect (peer); -} - - /** * Handle request connect message * @@ -850,10 +840,7 @@ clients_handle_request_connect (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received a request connect message for peer `%s'\n", GNUNET_i2s (&trcm->peer)); - (void) GST_blacklist_test_allowed (&trcm->peer, - NULL, - &try_connect_if_allowed, - NULL); + GST_neighbours_try_connect (&trcm->peer); GNUNET_SERVER_receive_done (client, GNUNET_OK); } @@ -1590,6 +1577,10 @@ GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, { struct TransportClient *tc; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Asked to broadcast message of type %u with %u bytes\n", + (unsigned int) ntohs (msg->type), + (unsigned int) ntohs (msg->size)); for (tc = clients_head; NULL != tc; tc = tc->next) { if ( (GNUNET_YES == may_drop) && diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c index d59b0f1b4..7b5f79a4a 100644 --- a/src/transport/gnunet-service-transport_hello.c +++ b/src/transport/gnunet-service-transport_hello.c @@ -90,28 +90,33 @@ static struct GNUNET_HELLO_Message *our_hello; static GST_HelloCallback hello_cb; /** - * Closure for 'hello_cb'. + * Closure for #hello_cb. */ static void *hello_cb_cls; /** * Head of my addresses. */ -struct OwnAddressList *oal_head; +static struct OwnAddressList *oal_head; /** * Tail of my addresses. */ -struct OwnAddressList *oal_tail; +static struct OwnAddressList *oal_tail; /** - * Identifier of 'refresh_hello' task. + * Should we use a friend-only HELLO? + */ +static int friend_option; + +/** + * Identifier of #refresh_hello_task(). */ static struct GNUNET_SCHEDULER_Task * hello_task; /** - * Closure for 'address_generator'. + * Closure for #address_generator(). */ struct GeneratorContext { @@ -130,14 +135,16 @@ struct GeneratorContext /** * Add an address from the 'OwnAddressList' to the buffer. * - * @param cls the 'struct GeneratorContext' + * @param cls the `struct GeneratorContext` * @param max maximum number of bytes left * @param buf where to write the address - * @return bytes written or GNUNET_SYSERR to signal the + * @return bytes written or #GNUNET_SYSERR to signal the * end of the iteration. */ static ssize_t -address_generator (void *cls, size_t max, void *buf) +address_generator (void *cls, + size_t max, + void *buf) { struct GeneratorContext *gc = cls; ssize_t ret; @@ -159,35 +166,40 @@ address_generator (void *cls, size_t max, void *buf) * @param tc scheduler context */ static void -refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +refresh_hello_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GeneratorContext gc; - int friend_only; hello_task = NULL; gc.addr_pos = oal_head; gc.expiration = GNUNET_TIME_relative_to_absolute (hello_expiration); - - friend_only = GNUNET_HELLO_is_friend_only (our_hello); - GNUNET_free (our_hello); + GNUNET_free_non_null (our_hello); our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key, &address_generator, - &gc, friend_only); + &gc, + friend_option); GNUNET_assert (NULL != our_hello); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Refreshed my %s `%s', new size is %d\n", - (GNUNET_YES == GNUNET_HELLO_is_friend_only (our_hello)) ? "friend-only" : "public", - "HELLO", GNUNET_HELLO_size (our_hello)); - GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# refreshed my HELLO"), 1, + "Refreshed my %s HELLO, new size is %d\n", + (GNUNET_YES == friend_option) ? "friend-only" : "public", + GNUNET_HELLO_size (our_hello)); + GNUNET_STATISTICS_update (GST_stats, + gettext_noop ("# refreshed my HELLO"), + 1, GNUNET_NO); if (NULL != hello_cb) - hello_cb (hello_cb_cls, GST_hello_get ()); - GNUNET_PEERINFO_add_peer (GST_peerinfo, our_hello, NULL, NULL); + hello_cb (hello_cb_cls, + GST_hello_get ()); + GNUNET_PEERINFO_add_peer (GST_peerinfo, + our_hello, + NULL, + NULL); hello_task = - GNUNET_SCHEDULER_add_delayed (HELLO_REFRESH_PERIOD, &refresh_hello_task, + GNUNET_SCHEDULER_add_delayed (HELLO_REFRESH_PERIOD, + &refresh_hello_task, NULL); - } @@ -198,9 +210,10 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void refresh_hello () { - if (hello_task != NULL) + if (NULL != hello_task) GNUNET_SCHEDULER_cancel (hello_task); - hello_task = GNUNET_SCHEDULER_add_now (&refresh_hello_task, NULL); + hello_task = GNUNET_SCHEDULER_add_now (&refresh_hello_task, + NULL); } @@ -209,16 +222,16 @@ refresh_hello () * * @param friend_only use a friend only hello * @param cb function to call whenever our HELLO changes - * @param cb_cls closure for cb + * @param cb_cls closure for @a cb */ void -GST_hello_start (int friend_only, GST_HelloCallback cb, void *cb_cls) +GST_hello_start (int friend_only, + GST_HelloCallback cb, + void *cb_cls) { hello_cb = cb; hello_cb_cls = cb_cls; - our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key, - NULL, NULL, friend_only); - GNUNET_assert (NULL != our_hello); + friend_option = friend_only; refresh_hello (); } @@ -259,7 +272,7 @@ GST_hello_get () /** * Add or remove an address from this peer's HELLO message. * - * @param addremove GNUNET_YES to add, GNUNET_NO to remove + * @param addremove #GNUNET_YES to add, #GNUNET_NO to remove * @param address address to add or remove */ void @@ -303,8 +316,8 @@ GST_hello_modify_addresses (int addremove, * @param sig location where to cache PONG signatures for this address [set] * @param sig_expiration how long until the current 'sig' expires? * (ZERO if sig was never created) [set] - * @return GNUNET_YES if this is one of our addresses, - * GNUNET_NO if not + * @return #GNUNET_YES if this is one of our addresses, + * #GNUNET_NO if not */ int GST_hello_test_address (const struct GNUNET_HELLO_Address *address, @@ -314,7 +327,8 @@ GST_hello_test_address (const struct GNUNET_HELLO_Address *address, struct OwnAddressList *al; for (al = oal_head; al != NULL; al = al->next) - if (0 == GNUNET_HELLO_address_cmp (address, al->address)) + if (0 == GNUNET_HELLO_address_cmp (address, + al->address)) { *sig = &al->pong_signature; *sig_expiration = &al->pong_sig_expires; diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 15bb0bdab..315d32131 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -3711,7 +3711,9 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls) return; /* can happen during shutdown */ ic.cb = cb; ic.cb_cls = cb_cls; - GNUNET_CONTAINER_multipeermap_iterate (neighbours, &neighbours_iterate, &ic); + GNUNET_CONTAINER_multipeermap_iterate (neighbours, + &neighbours_iterate, + &ic); } diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c index 3e0e6601d..79f7f4ddd 100644 --- a/src/transport/gnunet-service-transport_plugins.c +++ b/src/transport/gnunet-service-transport_plugins.c @@ -108,15 +108,19 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, int fail; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (GST_cfg, "TRANSPORT", - "NEIGHBOUR_LIMIT", &tneigh)) + GNUNET_CONFIGURATION_get_value_number (GST_cfg, + "TRANSPORT", + "NEIGHBOUR_LIMIT", + &tneigh)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Transport service is lacking NEIGHBOUR_LIMIT option.\n")); return; } if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (GST_cfg, "TRANSPORT", "PLUGINS", + GNUNET_CONFIGURATION_get_value_string (GST_cfg, + "TRANSPORT", + "PLUGINS", &plugs)) return; GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -127,7 +131,9 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' transport plugin\n"), pos); - GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", pos); + GNUNET_asprintf (&libname, + "libgnunet_plugin_transport_%s", + pos); plug = GNUNET_new (struct TransportPlugin); plug->short_name = GNUNET_strdup (pos); plug->lib_name = libname; @@ -143,7 +149,9 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, plug->env.update_address_metrics = metric_update_cb; plug->env.max_connections = tneigh; plug->env.stats = GST_stats; - GNUNET_CONTAINER_DLL_insert (plugins_head, plugins_tail, plug); + GNUNET_CONTAINER_DLL_insert (plugins_head, + plugins_tail, + plug); } GNUNET_free (plugs); next = plugins_head; @@ -151,13 +159,16 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, { plug = next; next = plug->next; - plug->api = GNUNET_PLUGIN_load (plug->lib_name, &plug->env); + plug->api = GNUNET_PLUGIN_load (plug->lib_name, + &plug->env); if (NULL == plug->api) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to load transport plugin for `%s'\n"), plug->lib_name); - GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug); + GNUNET_CONTAINER_DLL_remove (plugins_head, + plugins_tail, + plug); GNUNET_free (plug->short_name); GNUNET_free (plug->lib_name); GNUNET_free (plug); @@ -258,7 +269,9 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, _("Did not load plugin `%s' due to missing functions\n"), plug->lib_name); GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api)); - GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug); + GNUNET_CONTAINER_DLL_remove (plugins_head, + plugins_tail, + plug); GNUNET_free (plug->short_name); GNUNET_free (plug->lib_name); GNUNET_free (plug); diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index abf15debf..a2fb3c853 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -526,7 +526,12 @@ transmit_ping_if_allowed (void *cls, cleanup_validation_entry (NULL, pid, ve); return; } - + hello = GST_hello_get (); + if (NULL == hello) + { + GNUNET_break (0); + return; + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s' `%s' `%s'\n", GNUNET_i2s (pid), @@ -534,7 +539,6 @@ transmit_ping_if_allowed (void *cls, ve->address->transport_name); slen = strlen (ve->address->transport_name) + 1; - hello = GST_hello_get (); hsize = ntohs (hello->size); tsize = sizeof (struct TransportPingMessage) + ve->address->address_length + @@ -900,7 +904,7 @@ GST_validation_start (unsigned int max_fds) validations_running, GNUNET_NO); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Validation uses a fast start threshold of %u connections and a delay between of %s\n ", + "Validation uses a fast start threshold of %u connections and a delay of %s\n", validations_fast_start_threshold, GNUNET_STRINGS_relative_time_to_string (validation_delay, GNUNET_YES)); diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 0087cfee3..3f20d30a5 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -559,7 +559,8 @@ tcp_nat_port_map_callback (void *cls, void *arg; size_t args; - LOG(GNUNET_ERROR_TYPE_INFO, "NAT notification to %s address `%s'\n", + LOG(GNUNET_ERROR_TYPE_INFO, + "NAT notification to %s address `%s'\n", (GNUNET_YES == add_remove) ? "add" : "remove", GNUNET_a2s (addr, addrlen)); /* convert 'addr' to our internal format */ @@ -2133,7 +2134,8 @@ handle_tcp_nat_probe (void *cls, const struct sockaddr_in *s4; const struct sockaddr_in6 *s6; - LOG(GNUNET_ERROR_TYPE_DEBUG, "Received NAT probe\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received NAT probe\n"); /* We have received a TCP NAT probe, meaning we (hopefully) initiated * a connection to this peer by running gnunet-nat-client. This peer * received the punch message and now wants us to use the new connection @@ -2157,7 +2159,7 @@ handle_tcp_nat_probe (void *cls, } session = GNUNET_CONTAINER_multipeermap_get (plugin->nat_wait_conns, - &tcp_nat_probe->clientIdentity); + &tcp_nat_probe->clientIdentity); if (session == NULL) { LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -2877,8 +2879,14 @@ libgnunet_plugin_transport_tcp_init (void *cls) else { plugin->nat = GNUNET_NAT_register (plugin->env->cfg, - GNUNET_YES, 0, 0, NULL, NULL, NULL, - &try_connection_reversal, plugin); + GNUNET_YES, + 0, + 0, + NULL, + NULL, + NULL, + &try_connection_reversal, + plugin); } api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); api->cls = plugin; diff --git a/src/transport/plugin_transport_udp_broadcasting.c b/src/transport/plugin_transport_udp_broadcasting.c index d9596c0a6..413c79564 100644 --- a/src/transport/plugin_transport_udp_broadcasting.c +++ b/src/transport/plugin_transport_udp_broadcasting.c @@ -545,11 +545,10 @@ setup_broadcast (struct Plugin *plugin, struct sockaddr_in6 *server_addrv6, struct sockaddr_in *server_addrv4) { - const struct GNUNET_MessageHeader *hello; - - hello = plugin->env->get_our_hello (); if (GNUNET_YES == - GNUNET_HELLO_is_friend_only ((const struct GNUNET_HELLO_Message *) hello)) + GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, + "topology", + "FRIENDS-ONLY")) { LOG (GNUNET_ERROR_TYPE_WARNING, _("Disabling HELLO broadcasting due to friend-to-friend only configuration!\n")); diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index a5a72e8cc..42b7d8669 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -1681,9 +1681,11 @@ send_hello_beacon (void *cls, const struct GNUNET_MessageHeader *hello; hello = plugin->env->get_our_hello (); - hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); - GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU); - size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size; + if (NULL != hello) + { + hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); + GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU); + size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size; { char buf[size] GNUNET_ALIGN; @@ -1706,7 +1708,7 @@ send_hello_beacon (void *cls, GNUNET_STATISTICS_update (plugin->env->stats, _("# HELLO beacons sent"), 1, GNUNET_NO); - } + } } plugin->beacon_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (HELLO_BEACON_SCALING_FACTOR, diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 2da1a90d6..2da6e9a54 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -355,7 +355,7 @@ struct GNUNET_TRANSPORT_Handle * The current HELLO message for this peer. Updated * whenever transports change their addresses. */ - struct GNUNET_HELLO_Message *my_hello; + struct GNUNET_MessageHeader *my_hello; /** * My client connection to the transport service. @@ -655,7 +655,8 @@ demultiplexer (void *cls, break; } LOG (GNUNET_ERROR_TYPE_DEBUG, - "Receiving (my own) `%s' message, I am `%4s'.\n", "HELLO", + "Receiving (my own) HELLO message (%u bytes), I am `%4s'.\n", + (unsigned int) size, GNUNET_i2s (&me)); GNUNET_free_non_null (h->my_hello); h->my_hello = NULL; @@ -664,14 +665,13 @@ demultiplexer (void *cls, GNUNET_break (0); break; } - h->my_hello = GNUNET_malloc (size); - memcpy (h->my_hello, msg, size); + h->my_hello = GNUNET_copy_message (msg); hwl = h->hwl_head; while (NULL != hwl) { next_hwl = hwl->next; hwl->rec (hwl->rec_cls, - (const struct GNUNET_MessageHeader *) h->my_hello); + h->my_hello); hwl = next_hwl; } break; @@ -1668,7 +1668,7 @@ call_hello_update_cb_async (void *cls, GNUNET_assert (NULL != ghh->notify_task); ghh->notify_task = NULL; ghh->rec (ghh->rec_cls, - (const struct GNUNET_MessageHeader *) ghh->handle->my_hello); + ghh->handle->my_hello); } @@ -1696,7 +1696,7 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle, hwl->rec_cls = rec_cls; hwl->handle = handle; GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl); - if (handle->my_hello != NULL) + if (NULL != handle->my_hello) hwl->notify_task = GNUNET_SCHEDULER_add_now (&call_hello_update_cb_async, hwl); return hwl; -- cgit v1.2.3