gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r31313 - gnunet/src/transport
Date: Thu, 12 Dec 2013 17:17:10 +0100

Author: grothoff
Date: 2013-12-12 17:17:10 +0100 (Thu, 12 Dec 2013)
New Revision: 31313

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport.h
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/gnunet-service-transport_neighbours.h
   gnunet/src/transport/gnunet-service-transport_plugins.h
   gnunet/src/transport/gnunet-service-transport_validation.c
   gnunet/src/transport/gnunet-service-transport_validation.h
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/test_transport_defaults.conf
   gnunet/src/transport/transport.conf.in
Log:
-be stricter during handshake, close sessions with broken interactions 
aggressively

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2013-12-12 15:51:28 UTC 
(rev 31312)
+++ gnunet/src/transport/gnunet-service-transport.c     2013-12-12 16:17:10 UTC 
(rev 31313)
@@ -124,7 +124,6 @@
 }
 
 
-
 /**
  * We received some payload.  Prepare to pass it on to our clients.
  *
@@ -178,14 +177,36 @@
 
 
 /**
+ * Force plugin to terminate session due to communication
+ * issue.
+ *
+ * @param plugin_name name of the plugin
+ * @param session session to termiante
+ */
+static void
+kill_session (const char *plugin_name,
+              struct Session *session)
+{
+  struct GNUNET_TRANSPORT_PluginFunctions *plugin;
+
+  plugin = GST_plugins_find (plugin_name);
+  if (NULL == plugin)
+  {
+    GNUNET_break (0);
+    return;
+  }
+  plugin->disconnect_session (plugin->cls,
+                              session);
+}
+
+
+/**
  * Function called by the transport for each received message.
- * This function should also be called with "NULL" for the
- * message to signal that the other peer disconnected.
  *
  * @param cls closure, const char* with the name of the plugin we received the 
message from
  * @param peer (claimed) identity of the other peer
  * @param message the message, NULL if we only care about
- *                learning about the delay until we should receive again -- 
FIXME!
+ *                learning about the delay until we should receive again
  * @param session identifier used for this session (NULL for plugins
  *                that do not offer bi-directional communication to the sender
  *                using the same "connection")
@@ -236,30 +257,57 @@
     /* Legacy HELLO message, discard  */
     return ret;
   case GNUNET_MESSAGE_TYPE_HELLO:
-    GST_validation_handle_hello (message);
+    if (GNUNET_OK !=
+        GST_validation_handle_hello (message))
+    {
+      GNUNET_break_op (0);
+      kill_session (plugin_name, session);
+    }
     return ret;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
                 "Processing `%s' from `%s'\n", "PING",
                 (sender_address !=
                  NULL) ? GST_plugins_a2s (&address) : 
TRANSPORT_SESSION_INBOUND_STRING);
-    GST_validation_handle_ping (peer, message, &address, session);
+    if (GNUNET_OK !=
+        GST_validation_handle_ping (peer, message, &address, session))
+      kill_session (plugin_name, session);
     break;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
                 "Processing `%s' from `%s'\n", "PONG",
                 (sender_address !=
                  NULL) ? GST_plugins_a2s (&address) : 
TRANSPORT_SESSION_INBOUND_STRING);
-    GST_validation_handle_pong (peer, message);
+    if (GNUNET_OK !=
+        GST_validation_handle_pong (peer, message))
+    {
+      GNUNET_break_op (0);
+      kill_session (plugin_name, session);
+    }
     break;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT:
-    GST_neighbours_handle_connect (message, peer, &address, session);
+    if (GNUNET_OK !=
+        GST_neighbours_handle_connect (message, peer, &address, session))
+    {
+      GNUNET_break_op (0);
+      kill_session (plugin_name, session);
+    }
     break;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK:
-    GST_neighbours_handle_connect_ack (message, peer, &address, session);
+    if (GNUNET_OK !=
+        GST_neighbours_handle_connect_ack (message, peer, &address, session))
+    {
+      GNUNET_break_op (0);
+      kill_session (plugin_name, session);
+    }
     break;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
-    GST_neighbours_handle_session_ack (message, peer, &address, session);
+    if (GNUNET_OK !=
+        GST_neighbours_handle_session_ack (message, peer, &address, session))
+    {
+      GNUNET_break_op (0);
+      kill_session (plugin_name, session);
+    }
     break;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
     GST_neighbours_handle_disconnect_message (peer, message);
@@ -370,6 +418,7 @@
                             size_t addrlen)
 {
   struct GNUNET_ATS_Information ats;
+
   ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
   ats.value = htonl (GNUNET_ATS_NET_UNSPECIFIED);
   if (GST_ats == NULL)
@@ -381,9 +430,10 @@
       ((addr->sa_family != AF_INET6) && (addrlen != sizeof (struct 
sockaddr_in6))) &&
       (addr->sa_family != AF_UNIX))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed address with length %u 
`%s'\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Malformed address with length %u `%s'\n",
                 addrlen,
-                GNUNET_a2s(addr, addrlen));
+                GNUNET_a2s (addr, addrlen));
     GNUNET_break (0);
     return ats;
   }
@@ -621,8 +671,8 @@
     return;
   }
   GST_neighbours_switch_to_address (&address->peer, address, session, ats,
-                                         ats_count, bandwidth_in,
-                                         bandwidth_out);
+                                    ats_count, bandwidth_in,
+                                    bandwidth_out);
 }
 
 

Modified: gnunet/src/transport/gnunet-service-transport.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport.h     2013-12-12 15:51:28 UTC 
(rev 31312)
+++ gnunet/src/transport/gnunet-service-transport.h     2013-12-12 16:17:10 UTC 
(rev 31313)
@@ -101,7 +101,7 @@
  */
 void
 GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
-                                                                               
 struct Session *session);
+                     struct Session *session);
 
 
 /**
@@ -111,7 +111,7 @@
  * @param address the address
  * @param session the session
  * @param ats performance information
- * @param ats_count number of elements in ats
+ * @param ats_count number of elements in @a ats
  */
 void
 GST_ats_update_metrics (const struct GNUNET_PeerIdentity *peer,

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2013-12-12 
15:51:28 UTC (rev 31312)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2013-12-12 
16:17:10 UTC (rev 31313)
@@ -774,7 +774,7 @@
  * Release its resources and give appropriate notifications
  * to ATS and other subsystems.
  *
- * @param na address we are done with; 'na' itself must NOT be 'free'd, only 
the contents!
+ * @param na address we are done with; @a na itself must NOT be 'free'd, only 
the contents!
  */
 static void
 free_address (struct NeighbourAddress *na)
@@ -1817,10 +1817,15 @@
   struct NeighbourMapEntry *n;
 
   bcc->bc = NULL;
+  GNUNET_CONTAINER_DLL_remove (bc_head,
+                              bc_tail,
+                              bcc);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Connection to new address of peer `%s' based on blacklist is 
`%s'\n",
               GNUNET_i2s (peer),
               (GNUNET_OK == result) ? "allowed" : "FORBIDDEN");
+  if (GNUNET_OK == result)
+    GST_ats_add_address (bcc->na.address, bcc->na.session);
   if (NULL == (n = lookup_neighbour (peer)))
     goto cleanup; /* nobody left to care about new address */
   switch (n->state)
@@ -1831,7 +1836,8 @@
     free_neighbour (n, GNUNET_NO);
     break;
   case S_INIT_ATS:
-    /* still waiting on ATS suggestion */
+    /* waiting on ATS suggestion; still, pass address to ATS as a
+       possibility */
     break;
   case S_INIT_BLACKLIST:
     /* check if the address the blacklist was fine with matches
@@ -1877,20 +1883,21 @@
     }
     break;
   case S_CONNECT_RECV_BLACKLIST_INBOUND:
-    if (GNUNET_OK == result)
-       GST_ats_add_address (bcc->na.address, bcc->na.session);
-
     n->state = S_CONNECT_RECV_ATS;
     n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
     GNUNET_ATS_reset_backoff (GST_ats, peer);
     n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer);
     break;
   case S_CONNECT_RECV_ATS:
-    /* still waiting on ATS suggestion, don't care about blacklist */
+    /* waiting on ATS suggestion, don't care about blacklist */
     break;
   case S_CONNECT_RECV_BLACKLIST:
     if (GNUNET_YES != address_matches (&bcc->na, &n->primary_address))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Blacklist result ignored, as it is not for our primary 
address\n");
       break; /* result for an address we currently don't care about */
+    }
     if (GNUNET_OK == result)
     {
       n->timeout = GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT);
@@ -1903,10 +1910,20 @@
     }
     else
     {
-      // FIXME: should also possibly destroy session with plugin!?
+      struct GNUNET_TRANSPORT_PluginFunctions *plugin;
+
+      plugin = GST_plugins_find (bcc->na.address->transport_name);
+      if ( (NULL != plugin) &&
+           (NULL != bcc->na.session) )
+      {
+        plugin->disconnect_session (plugin->cls,
+                                    bcc->na.session);
+        break;
+      }
+      GNUNET_break (NULL != plugin);
       GNUNET_ATS_address_destroyed (GST_ats,
-                                   bcc->na.address,
-                                   NULL);
+                                    bcc->na.address,
+                                    NULL);
       free_address (&n->primary_address);
       n->state = S_INIT_ATS;
       n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
@@ -2016,9 +2033,6 @@
   }
  cleanup:
   GNUNET_HELLO_address_free (bcc->na.address);
-  GNUNET_CONTAINER_DLL_remove (bc_head,
-                              bc_tail,
-                              bcc);
   GNUNET_free (bcc);
 }
 
@@ -2042,7 +2056,7 @@
   struct BlackListCheckContext *bcc;
   struct GST_BlacklistCheck *bc;
 
-  bcc = GNUNET_malloc (sizeof (struct BlackListCheckContext));
+  bcc = GNUNET_new (struct BlackListCheckContext);
   bcc->na.address = GNUNET_HELLO_address_copy (address);
   bcc->na.session = session;
   bcc->na.connect_timestamp = ts;
@@ -2067,8 +2081,9 @@
  * @param address address of the other peer, NULL if other peer
  *                       connected to us
  * @param session session to use (or NULL)
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
                                const struct GNUNET_PeerIdentity *peer,
                                const struct GNUNET_HELLO_Address *address,
@@ -2084,14 +2099,19 @@
   if (ntohs (message->size) != sizeof (struct SessionConnectMessage))
   {
     GNUNET_break_op (0);
-    return;
+    return GNUNET_SYSERR;
   }
   GNUNET_STATISTICS_update (GST_stats,
                             gettext_noop
                             ("# CONNECT messages received"),
                             1, GNUNET_NO);
   if (NULL == neighbours)
-    return; /* we're shutting down */
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                _("CONNECT request from peer `%s' ignored due impending 
shutdown\n"),
+                GNUNET_i2s (peer));
+    return GNUNET_OK; /* we're shutting down */
+  }
   scm = (const struct SessionConnectMessage *) message;
   GNUNET_break_op (0 == ntohl (scm->reserved));
   ts = GNUNET_TIME_absolute_ntoh (scm->timestamp);
@@ -2169,9 +2189,9 @@
                 "Unhandled state `%s'\n",
                 print_state (n->state));
     GNUNET_break (0);
-    free_neighbour (n, GNUNET_NO);
-    break;
+    return GNUNET_SYSERR;
   }
+  return GNUNET_OK;
 }
 
 
@@ -2485,33 +2505,32 @@
 
 }
 
+
 void
 GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
-                 const struct GNUNET_HELLO_Address *address,
-                 struct Session *session,
-                 const struct GNUNET_MessageHeader *message)
+                                 const struct GNUNET_HELLO_Address *address,
+                                 struct Session *session,
+                                 const struct GNUNET_MessageHeader *message)
 {
   struct NeighbourMapEntry *n;
+
   n = lookup_neighbour (peer);
   if (NULL == n)
-  {
-      return;
-  }
+    return;
   n->util_total_bytes_recv += ntohs(message->size);
 }
 
+
 void
 GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
-                 const struct GNUNET_HELLO_Address *address,
-                 struct Session *session,
-                 const struct GNUNET_MessageHeader *message)
+                                    const struct GNUNET_HELLO_Address *address,
+                                    struct Session *session,
+                                    const struct GNUNET_MessageHeader *message)
 {
   struct NeighbourMapEntry *n;
   n = lookup_neighbour (peer);
   if (NULL == n)
-  {
-      return;
-  }
+    return;
   n->util_payload_bytes_recv += ntohs(message->size);
 }
 
@@ -2779,8 +2798,9 @@
  * @param address address of the other peer, NULL if other peer
  *                       connected to us
  * @param session session to use (or NULL)
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
                                    const struct GNUNET_PeerIdentity *peer,
                                    const struct GNUNET_HELLO_Address *address,
@@ -2797,7 +2817,7 @@
   if (ntohs (message->size) != sizeof (struct SessionConnectMessage))
   {
     GNUNET_break_op (0);
-    return;
+    return GNUNET_SYSERR;
   }
   GNUNET_STATISTICS_update (GST_stats,
                             gettext_noop
@@ -2811,7 +2831,7 @@
                               gettext_noop
                               ("# unexpected CONNECT_ACK messages (no peer)"),
                               1, GNUNET_NO);
-    return;
+    return GNUNET_SYSERR;
   }
   ts = GNUNET_TIME_absolute_ntoh (scm->timestamp);
   switch (n->state)
@@ -2819,7 +2839,7 @@
   case S_NOT_CONNECTED:
     GNUNET_break (0);
     free_neighbour (n, GNUNET_NO);
-    return;
+    return GNUNET_SYSERR;
   case S_INIT_ATS:
   case S_INIT_BLACKLIST:
     GNUNET_STATISTICS_update (GST_stats,
@@ -2829,7 +2849,11 @@
     break;
   case S_CONNECT_SENT:
     if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us)
-      break; /* ACK does not match our original CONNECT message */
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  "CONNECT_ACK ignored as the timestamp does not match our 
CONNECT request\n");
+      return GNUNET_OK;
+    }
     n->state = S_CONNECTED;
     n->timeout = GNUNET_TIME_relative_to_absolute 
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
     GNUNET_STATISTICS_set (GST_stats,
@@ -2901,7 +2925,7 @@
                               gettext_noop
                               ("# unexpected CONNECT_ACK messages 
(disconnecting)"),
                               1, GNUNET_NO);
-    break;
+    return GNUNET_SYSERR;
   case S_DISCONNECT_FINISHED:
     GNUNET_assert (0);
     break;
@@ -2910,8 +2934,9 @@
                 "Unhandled state `%s'\n",
                 print_state (n->state));
     GNUNET_break (0);
-    break;
+    return GNUNET_SYSERR;
   }
+  return GNUNET_OK;
 }
 
 
@@ -2939,7 +2964,8 @@
     bcc_next = bcc->next;
     if (bcc->na.session == session)
     {
-      GST_blacklist_test_cancel (bcc->bc);
+      if (NULL != bcc->bc)
+        GST_blacklist_test_cancel (bcc->bc);
       GNUNET_HELLO_address_free (bcc->na.address);
       GNUNET_CONTAINER_DLL_remove (bc_head,
                                   bc_tail,
@@ -3057,8 +3083,9 @@
  * @param address address of the other peer, NULL if other peer
  *                       connected to us
  * @param session session to use (or NULL)
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
                                   const struct GNUNET_PeerIdentity *peer,
                                   const struct GNUNET_HELLO_Address *address,
@@ -3072,14 +3099,14 @@
   if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
   {
     GNUNET_break_op (0);
-    return;
+    return GNUNET_SYSERR;
   }
   GNUNET_STATISTICS_update (GST_stats,
                             gettext_noop
                             ("# SESSION_ACK messages received"),
                             1, GNUNET_NO);
   if (NULL == (n = lookup_neighbour (peer)))
-    return;
+    return GNUNET_SYSERR;
   /* check if we are in a plausible state for having sent
      a CONNECT_ACK.  If not, return, otherwise break */
   if ( ( (S_CONNECT_RECV_ACK != n->state) &&
@@ -3094,7 +3121,7 @@
     GNUNET_STATISTICS_update (GST_stats,
                               gettext_noop ("# unexpected SESSION_ACK 
messages"), 1,
                               GNUNET_NO);
-    return;
+    return GNUNET_SYSERR;
   }
   n->state = S_CONNECTED;
   n->timeout = GNUNET_TIME_relative_to_absolute 
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
@@ -3113,6 +3140,7 @@
               n->primary_address.bandwidth_in,
               n->primary_address.bandwidth_out,
               GNUNET_YES);
+  return GNUNET_OK;
 }
 
 

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.h  2013-12-12 
15:51:28 UTC (rev 31312)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.h  2013-12-12 
16:17:10 UTC (rev 31313)
@@ -48,7 +48,7 @@
  */
 void
 GST_neighbours_start (void *cls,
-                                                                       
NotifyConnect connect_cb,
+                      NotifyConnect connect_cb,
                       GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb,
                       GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb,
                       unsigned int max_fds);
@@ -74,7 +74,7 @@
  * Test if we're connected to the given peer.
  *
  * @param target peer to test
- * @return GNUNET_YES if we are connected, GNUNET_NO if not
+ * @return #GNUNET_YES if we are connected, #GNUNET_NO if not
  */
 int
 GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target);
@@ -84,7 +84,7 @@
  * Function called after the transmission is done.
  *
  * @param cls closure
- * @param success GNUNET_OK on success, GNUNET_NO on failure, GNUNET_SYSERR if 
we're not connected
+ * @param success #GNUNET_OK on success, #GNUNET_NO on failure, #GNUNET_SYSERR 
if we're not connected
  */
 typedef void (*GST_NeighbourSendContinuation) (void *cls, int success,
                                                size_t bytes_payload,
@@ -96,10 +96,10 @@
  *
  * @param target destination
  * @param msg message to send
- * @param msg_size number of bytes in msg
+ * @param msg_size number of bytes in @a msg
  * @param timeout when to fail with timeout
  * @param cont function to call when done
- * @param cont_cls closure for 'cont'
+ * @param cont_cls closure for @a cont
  */
 void
 GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
@@ -114,8 +114,8 @@
  *
  * @param sender sender of the message
  * @param size size of the message
- * @param do_forward set to GNUNET_YES if the message should be forwarded to 
clients
- *                   GNUNET_NO if the neighbour is not connected or violates 
the quota
+ * @param do_forward set to #GNUNET_YES if the message should be forwarded to 
clients
+ *                   #GNUNET_NO if the neighbour is not connected or violates 
the quota
  * @return how long to wait before reading more from this sender
  */
 struct GNUNET_TIME_Relative
@@ -185,7 +185,7 @@
  * Iterate over all connected neighbours.
  *
  * @param cb function to call
- * @param cb_cls closure for cb
+ * @param cb_cls closure for @a cb
  */
 void
 GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls);
@@ -196,7 +196,7 @@
  *
  * @param peer identity of the peer where the session died
  * @param session session that is gone
- * @return GNUNET_YES if this was a session used, GNUNET_NO if
+ * @return #GNUNET_YES if this was a session used, #GNUNET_NO if
  *        this session was not in use
  */
 int
@@ -206,26 +206,30 @@
 
 void
 GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
-                 const struct GNUNET_HELLO_Address *address,
-                 struct Session *session,
-                 const struct GNUNET_MessageHeader *message);
+                                 const struct GNUNET_HELLO_Address *address,
+                                 struct Session *session,
+                                 const struct GNUNET_MessageHeader *message);
 
+
 void
 GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
-                 const struct GNUNET_HELLO_Address *address,
-                 struct Session *session,
-                 const struct GNUNET_MessageHeader *message);
+                                    const struct GNUNET_HELLO_Address *address,
+                                    struct Session *session,
+                                    const struct GNUNET_MessageHeader 
*message);
 
+
 void
 GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer,
-    size_t size);
+                                    size_t size);
 
+
 void
 GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer,
-                     const struct GNUNET_HELLO_Address *address,
-                     struct Session *session,
-                     size_t size);
+                                 const struct GNUNET_HELLO_Address *address,
+                                 struct Session *session,
+                                 size_t size);
 
+
 /**
  * For an existing neighbour record, set the active connection to
  * use the given address.
@@ -241,12 +245,12 @@
  */
 void
 GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
-                                       const struct GNUNET_HELLO_Address
-                                       *address, struct Session *session,
-                                       const struct GNUNET_ATS_Information 
*ats,
-                                       uint32_t ats_count,
-                                       struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_in,
-                                       struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out);
+                                  const struct GNUNET_HELLO_Address *address,
+                                  struct Session *session,
+                                  const struct GNUNET_ATS_Information *ats,
+                                  uint32_t ats_count,
+                                  struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_in,
+                                  struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out);
 
 
 /**
@@ -258,8 +262,9 @@
  * @param address address of the other peer, NULL if other peer
  *                       connected to us
  * @param session session to use (or NULL)
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
                                const struct GNUNET_PeerIdentity *peer,
                                const struct GNUNET_HELLO_Address *address,
@@ -275,8 +280,9 @@
  * @param address address of the other peer, NULL if other peer
  *                       connected to us
  * @param session session to use (or NULL)
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
                                    const struct GNUNET_PeerIdentity *peer,
                                    const struct GNUNET_HELLO_Address *address,
@@ -285,15 +291,17 @@
 
 /**
  * We received a 'SESSION_ACK' message from the other peer.
- * FIXME: describe what this means!
+ * If we sent a 'CONNECT_ACK' last, this means we are now
+ * connected.  Otherwise, do nothing.
  *
  * @param message possibly a 'struct SessionConnectMessage' (check format)
  * @param peer identity of the peer to switch the address for
  * @param address address of the other peer, NULL if other peer
  *                       connected to us
  * @param session session to use (or NULL)
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
                                   const struct GNUNET_PeerIdentity *peer,
                                   const struct GNUNET_HELLO_Address *address,

Modified: gnunet/src/transport/gnunet-service-transport_plugins.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_plugins.h     2013-12-12 
15:51:28 UTC (rev 31312)
+++ gnunet/src/transport/gnunet-service-transport_plugins.h     2013-12-12 
16:17:10 UTC (rev 31313)
@@ -70,6 +70,7 @@
 struct GNUNET_TRANSPORT_PluginFunctions *
 GST_plugins_find (const char *name);
 
+
 /**
  * Obtain the plugin API based on a the stripped plugin name after the 
underscore.
  *

Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c  2013-12-12 
15:51:28 UTC (rev 31312)
+++ gnunet/src/transport/gnunet-service-transport_validation.c  2013-12-12 
16:17:10 UTC (rev 31313)
@@ -931,8 +931,9 @@
  * @param hdr the PING
  * @param sender_address the sender address as we got it
  * @param session session we got the PING from
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
                             const struct GNUNET_MessageHeader *hdr,
                             const struct GNUNET_HELLO_Address *sender_address,
@@ -956,7 +957,7 @@
   if (ntohs (hdr->size) < sizeof (struct TransportPingMessage))
   {
     GNUNET_break_op (0);
-    return;
+    return GNUNET_SYSERR;
   }
   ping = (const struct TransportPingMessage *) hdr;
   if (0 !=
@@ -967,7 +968,7 @@
                               gettext_noop
                               ("# PING message for different peer received"), 
1,
                               GNUNET_NO);
-    return;
+    return GNUNET_SYSERR;
   }
   GNUNET_STATISTICS_update (GST_stats,
                             gettext_noop ("# PING messages received"), 1,
@@ -986,7 +987,7 @@
     if (NULL == addrend)
     {
       GNUNET_break_op (0);
-      return;
+      return GNUNET_SYSERR;
     }
     addrend++;
     slen = strlen (addr) + 1;
@@ -998,38 +999,40 @@
 
     if (NULL == address.transport_name)
     {
-       GNUNET_break (0);
+      GNUNET_break (0);
     }
 
     if (0 != strstr (address.transport_name, "_client"))
-               {
-       plugin_name = GNUNET_strdup (address.transport_name);
-       pos = strstr (plugin_name, "_client");
-       GNUNET_assert (NULL != pos);
-       GNUNET_snprintf (pos, strlen ("_server") + 1, "%s", "_server");
-               }
+    {
+      plugin_name = GNUNET_strdup (address.transport_name);
+      pos = strstr (plugin_name, "_client");
+      GNUNET_assert (NULL != pos);
+      GNUNET_snprintf (pos, strlen ("_server") + 1, "%s", "_server");
+    }
     else
-       plugin_name = GNUNET_strdup (address.transport_name);
+      plugin_name = GNUNET_strdup (address.transport_name);
 
     if (NULL == (papi = GST_plugins_find (plugin_name)))
     {
       /* we don't have the plugin for this address */
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Plugin `%s' not available, cannot 
confirm having this address \n",
-               plugin_name);
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  _("Plugin `%s' not available, cannot confirm having this 
address\n"),
+                  plugin_name);
       GNUNET_free (plugin_name);
-      return;
+      return GNUNET_SYSERR;
     }
     GNUNET_free (plugin_name);
     if (GNUNET_OK != papi->check_address (papi->cls, addrend, alen))
-               {
+    {
       GNUNET_STATISTICS_update (GST_stats,
                                 gettext_noop
                                 ("# failed address checks during validation"), 
1,
                                 GNUNET_NO);
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Address `%s' is not one of my 
addresses, not confirming PING\n",
-               GST_plugins_a2s (&address));
-       return;
-               }
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  _("Address `%s' is not one of my addresses, not confirming 
PING\n"),
+                  GST_plugins_a2s (&address));
+      return GNUNET_SYSERR;
+    }
     else
     {
       GNUNET_STATISTICS_update (GST_stats,
@@ -1046,10 +1049,10 @@
       if (GNUNET_NO == buggy)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "Not confirming PING from peer `%s' with address `%s' 
since I cannot confirm having this address.\n",
+                    _("Not confirming PING from peer `%s' with address `%s' 
since I cannot confirm having this address.\n"),
                     GNUNET_i2s (sender),
                     GST_plugins_a2s (&address));
-        return;
+        return GNUNET_SYSERR;
       }
       else
       {
@@ -1145,8 +1148,8 @@
                         NULL, NULL);
       if (-1 != ret)
         GST_neighbours_notify_data_sent (sender,
-            sender_address, session, pong->header.size);
-
+                                         sender_address, session,
+                                         pong->header.size);
     }
   }
   if (ret != -1)
@@ -1160,7 +1163,7 @@
                               ("# PONGs unicast via reliable transport"), 1,
                               GNUNET_NO);
     GNUNET_free (pong);
-    return;
+    return GNUNET_OK;
   }
 
   /* no reliable method found, try transmission via all known addresses */
@@ -1168,13 +1171,15 @@
                             gettext_noop
                             ("# PONGs multicast to all available addresses"), 
1,
                             GNUNET_NO);
-  GST_validation_get_addresses (sender, &multicast_pong, pong);
+  GST_validation_get_addresses (sender,
+                                &multicast_pong, pong);
   GNUNET_free (pong);
+  return GNUNET_OK;
 }
 
 
 /**
- * Context for the 'validate_address' function
+ * Context for the #validate_address_iterator() function
  */
 struct ValidateAddressContext
 {
@@ -1187,6 +1192,7 @@
    * Public key of the peer whose address is being validated.
    */
   struct GNUNET_CRYPTO_EddsaPublicKey public_key;
+
 };
 
 
@@ -1194,7 +1200,7 @@
  * Iterator callback to go over all addresses and try to validate them
  * (unless blocked or already validated).
  *
- * @param cls pointer to a 'struct ValidateAddressContext'
+ * @param cls pointer to a `struct ValidateAddressContext`
  * @param address the address
  * @param expiration expiration time
  * @return #GNUNET_OK (keep the address)
@@ -1218,7 +1224,7 @@
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Starting validation for fresh address %s\n",
-              GST_plugins_a2s (ve->address));
+                GST_plugins_a2s (ve->address));
     ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
   }
   return GNUNET_OK;
@@ -1252,8 +1258,9 @@
  *
  * @param sender peer sending the PONG
  * @param hdr the PONG
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
                             const struct GNUNET_MessageHeader *hdr)
 {
@@ -1272,7 +1279,7 @@
   if (ntohs (hdr->size) < sizeof (struct TransportPongMessage))
   {
     GNUNET_break_op (0);
-    return;
+    return GNUNET_SYSERR;
   }
   GNUNET_STATISTICS_update (GST_stats,
                             gettext_noop ("# PONG messages received"), 1,
@@ -1288,7 +1295,7 @@
   if (NULL == addr)
   {
     GNUNET_break_op (0);
-    return;
+    return GNUNET_SYSERR;
   }
   addr++;
   slen = strlen (tname) + 1;
@@ -1304,13 +1311,13 @@
                               gettext_noop
                               ("# PONGs dropped, no matching pending 
validation"),
                               1, GNUNET_NO);
-    return;
+    return GNUNET_OK;
   }
   /* now check that PONG is well-formed */
   if (0 != memcmp (&ve->pid, sender, sizeof (struct GNUNET_PeerIdentity)))
   {
     GNUNET_break_op (0);
-    return;
+    return GNUNET_SYSERR;
   }
   if (GNUNET_TIME_absolute_get_remaining
       (GNUNET_TIME_absolute_ntoh (pong->expiration)).rel_value_us == 0)
@@ -1319,7 +1326,7 @@
                               gettext_noop
                               ("# PONGs dropped, signature expired"), 1,
                               GNUNET_NO);
-    return;
+    return GNUNET_SYSERR;
   }
 
   sig_res = GNUNET_SYSERR;
@@ -1348,13 +1355,20 @@
                                           &pong->purpose, &pong->signature,
                                           &ve->public_key);
     if (sig_res == GNUNET_SYSERR)
+    {
+      GNUNET_break_op (0);
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "Failed to verify: invalid signature on address %s:%s from 
peer `%s'\n",
-                  tname, GST_plugins_a2s (ve->address),GNUNET_i2s (sender));
+                  tname,
+                  GST_plugins_a2s (ve->address),
+                  GNUNET_i2s (sender));
+    }
   }
-
   if (sig_res == GNUNET_SYSERR)
-    return;
+  {
+    GNUNET_break_op (0);
+    return GNUNET_SYSERR;
+  }
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Address validated for peer `%s' with plugin `%s': `%s'\n",
@@ -1367,6 +1381,7 @@
   ve->latency = GNUNET_TIME_absolute_get_duration (ve->send_time);
   {
     struct GNUNET_ATS_Information ats[2];
+
     ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
     ats[0].value = htonl ((uint32_t) ve->latency.rel_value_us);
     ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
@@ -1381,7 +1396,9 @@
                 validations_running);
   }
   else
-       GNUNET_break (0);
+  {
+    GNUNET_break (0);
+  }
 
   /* build HELLO to store in PEERINFO */
   ve->copied = GNUNET_NO;
@@ -1390,6 +1407,7 @@
                                GNUNET_NO);
   GNUNET_PEERINFO_add_peer (GST_peerinfo, hello, NULL, NULL);
   GNUNET_free (hello);
+  return GNUNET_OK;
 }
 
 
@@ -1398,8 +1416,9 @@
  * validation.
  *
  * @param hello the HELLO we received
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
 {
   const struct GNUNET_HELLO_Message *hm =
@@ -1409,17 +1428,18 @@
   int friend;
 
   friend = GNUNET_HELLO_is_friend_only (hm);
-  if (((GNUNET_YES != friend) && (GNUNET_NO != friend)) ||
-               (GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) ||
-      (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key)))
+  if ( ( (GNUNET_YES != friend) &&
+         (GNUNET_NO != friend) ) ||
+       (GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) ||
+       (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key)))
   {
     /* malformed HELLO */
-    GNUNET_break (0);
-    return;
+    GNUNET_break_op (0);
+    return GNUNET_SYSERR;
   }
   if (0 ==
       memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity)))
-    return;
+    return GNUNET_OK;
   /* Add peer identity without addresses to peerinfo service */
   h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, friend);
   GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL);
@@ -1433,11 +1453,12 @@
                  GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO,
                                                  &validate_address_iterator,
                                                  &vac));
+  return GNUNET_OK;
 }
 
 
 /**
- * Closure for 'iterate_addresses'
+ * Closure for #iterate_addresses().
  */
 struct IteratorContext
 {
@@ -1447,7 +1468,7 @@
   GST_ValidationAddressCallback cb;
 
   /**
-   * Closure for 'cb'.
+   * Closure for @e cb.
    */
   void *cb_cls;
 
@@ -1457,9 +1478,9 @@
 /**
  * Call the callback in the closure for each validation entry.
  *
- * @param cls the 'struct GST_ValidationIteratorContext'
+ * @param cls the `struct IteratorContext`
  * @param key the peer's identity
- * @param value the 'struct ValidationEntry'
+ * @param value the `struct ValidationEntry`
  * @return #GNUNET_OK (continue to iterate)
  */
 static int

Modified: gnunet/src/transport/gnunet-service-transport_validation.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.h  2013-12-12 
15:51:28 UTC (rev 31312)
+++ gnunet/src/transport/gnunet-service-transport_validation.h  2013-12-12 
16:17:10 UTC (rev 31313)
@@ -89,8 +89,9 @@
  * @param hdr the PING
  * @param sender_address address of the sender, NULL if we did not initiate
  * @param session session we got the PING from
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
                             const struct GNUNET_MessageHeader *hdr,
                             const struct GNUNET_HELLO_Address *sender_address,
@@ -103,8 +104,9 @@
  *
  * @param sender peer sending the PONG
  * @param hdr the PONG
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
                             const struct GNUNET_MessageHeader *hdr);
 
@@ -114,8 +116,9 @@
  * validation.
  *
  * @param hello the HELLO we received
+ * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
-void
+int
 GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
 
 

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2013-12-12 15:51:28 UTC (rev 
31312)
+++ gnunet/src/transport/plugin_transport_tcp.c 2013-12-12 16:17:10 UTC (rev 
31313)
@@ -1608,25 +1608,25 @@
  */
 struct PrettyPrinterContext
 {
-       /**
-        * DLL
-        */
-       struct PrettyPrinterContext *next;
+  /**
+   * DLL
+   */
+  struct PrettyPrinterContext *next;
 
-       /**
-        * DLL
-        */
-       struct PrettyPrinterContext *prev;
+  /**
+   * DLL
+   */
+  struct PrettyPrinterContext *prev;
 
-       /**
-        * Timeout task
-        */
-       GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+  /**
+   * Timeout task
+   */
+  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
 
-       /**
-        * Resolver handle
-        */
-       struct GNUNET_RESOLVER_RequestHandle *resolver_handle;
+  /**
+   * Resolver handle
+   */
+  struct GNUNET_RESOLVER_RequestHandle *resolver_handle;
 
   /**
    * Function to call with the result.

Modified: gnunet/src/transport/test_transport_defaults.conf
===================================================================
--- gnunet/src/transport/test_transport_defaults.conf   2013-12-12 15:51:28 UTC 
(rev 31312)
+++ gnunet/src/transport/test_transport_defaults.conf   2013-12-12 16:17:10 UTC 
(rev 31313)
@@ -5,10 +5,10 @@
 TIMEOUT = 300 s
 
 [arm]
-DEFAULTSERVICES = 
+DEFAULTSERVICES =
 
 [transport]
-PREFIX = 
+PREFIX = valgrind
 
 [core]
 AUTOSTART = NO

Modified: gnunet/src/transport/transport.conf.in
===================================================================
--- gnunet/src/transport/transport.conf.in      2013-12-12 15:51:28 UTC (rev 
31312)
+++ gnunet/src/transport/transport.conf.in      2013-12-12 16:17:10 UTC (rev 
31313)
@@ -3,7 +3,7 @@
 @address@hidden = 2091
 HOSTNAME = localhost
 BINARY = gnunet-service-transport
-#PREFIX = valgrind
+# PREFIX = valgrind
 NEIGHBOUR_LIMIT = 50
 ACCEPT_FROM = 127.0.0.1;
 ACCEPT_FROM6 = ::1;




reply via email to

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