gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35195 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r35195 - gnunet/src/transport
Date: Mon, 9 Feb 2015 15:28:45 +0100

Author: grothoff
Date: 2015-02-09 15:28:45 +0100 (Mon, 09 Feb 2015)
New Revision: 35195

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport_clients.c
   gnunet/src/transport/gnunet-service-transport_hello.c
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/gnunet-service-transport_plugins.c
   gnunet/src/transport/gnunet-service-transport_validation.c
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/plugin_transport_udp_broadcasting.c
   gnunet/src/transport/plugin_transport_wlan.c
   gnunet/src/transport/transport_api.c
Log:
-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

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2015-02-09 14:27:59 UTC 
(rev 35194)
+++ gnunet/src/transport/gnunet-service-transport.c     2015-02-09 14:28:45 UTC 
(rev 35195)
@@ -215,6 +215,11 @@
 {
   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 @@
 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 @@
               "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,

Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c     2015-02-09 
14:27:59 UTC (rev 35194)
+++ gnunet/src/transport/gnunet-service-transport_clients.c     2015-02-09 
14:28:45 UTC (rev 35195)
@@ -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 @@
                       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 (&notify_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 (&notify_client_about_neighbour,
+                            tc);
+  }
+  GNUNET_SERVER_receive_done (client,
+                              GNUNET_OK);
 }
 
 
@@ -791,35 +810,6 @@
 
 
 /**
- * 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
  *
  * @param cls closure (always NULL)
@@ -850,10 +840,7 @@
   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 @@
 {
   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) &&

Modified: gnunet/src/transport/gnunet-service-transport_hello.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_hello.c       2015-02-09 
14:27:59 UTC (rev 35194)
+++ gnunet/src/transport/gnunet-service-transport_hello.c       2015-02-09 
14:28:45 UTC (rev 35195)
@@ -90,28 +90,33 @@
 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 @@
 /**
  * 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 @@
  * @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 @@
 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 @@
  *
  * @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 @@
 /**
  * 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 @@
  * @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 @@
   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;

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-02-09 
14:27:59 UTC (rev 35194)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-02-09 
14:28:45 UTC (rev 35195)
@@ -3711,7 +3711,9 @@
     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);
 }
 
 

Modified: gnunet/src/transport/gnunet-service-transport_plugins.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_plugins.c     2015-02-09 
14:27:59 UTC (rev 35194)
+++ gnunet/src/transport/gnunet-service-transport_plugins.c     2015-02-09 
14:28:45 UTC (rev 35195)
@@ -108,15 +108,19 @@
   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 @@
     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 @@
     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 @@
   {
     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 @@
                   _("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);

Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c  2015-02-09 
14:27:59 UTC (rev 35194)
+++ gnunet/src/transport/gnunet-service-transport_validation.c  2015-02-09 
14:28:45 UTC (rev 35195)
@@ -526,7 +526,12 @@
     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 @@
               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 @@
                          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));

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2015-02-09 14:27:59 UTC (rev 
35194)
+++ gnunet/src/transport/plugin_transport_tcp.c 2015-02-09 14:28:45 UTC (rev 
35195)
@@ -559,7 +559,8 @@
   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 @@
   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 @@
   }
 
   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 @@
   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;

Modified: gnunet/src/transport/plugin_transport_udp_broadcasting.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp_broadcasting.c    2015-02-09 
14:27:59 UTC (rev 35194)
+++ gnunet/src/transport/plugin_transport_udp_broadcasting.c    2015-02-09 
14:28:45 UTC (rev 35195)
@@ -545,11 +545,10 @@
                  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"));

Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2015-02-09 14:27:59 UTC 
(rev 35194)
+++ gnunet/src/transport/plugin_transport_wlan.c        2015-02-09 14:28:45 UTC 
(rev 35195)
@@ -1681,10 +1681,12 @@
   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;
 
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1706,7 +1708,7 @@
       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,

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2015-02-09 14:27:59 UTC (rev 
35194)
+++ gnunet/src/transport/transport_api.c        2015-02-09 14:28:45 UTC (rev 
35195)
@@ -355,7 +355,7 @@
    * 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 @@
       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 @@
       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 @@
   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 @@
   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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]