gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r30087 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r30087 - gnunet/src/mesh
Date: Thu, 10 Oct 2013 14:39:45 +0200

Author: bartpolot
Date: 2013-10-10 14:39:45 +0200 (Thu, 10 Oct 2013)
New Revision: 30087

Modified:
   gnunet/src/mesh/gnunet-service-mesh_channel.h
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_peer.h
   gnunet/src/mesh/gnunet-service-mesh_tunnel.c
   gnunet/src/mesh/gnunet-service-mesh_tunnel.h
Log:
- connection fixing


Modified: gnunet/src/mesh/gnunet-service-mesh_channel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.h       2013-10-10 12:31:02 UTC 
(rev 30086)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.h       2013-10-10 12:39:45 UTC 
(rev 30087)
@@ -40,6 +40,8 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 
+#include "mesh_protocol_enc.h"
+
 /**
  * Struct containing all information regarding a channel to a remote client.
  */

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-10 12:31:02 UTC 
(rev 30086)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-10 12:39:45 UTC 
(rev 30087)
@@ -384,13 +384,13 @@
   msg.ack = htonl (ack);
   msg.cid = c->id;
 
-  send_prebuilt_message_connection (&msg.header, c, NULL, !fwd);
+  GMC_send_prebuilt_message (&msg.header, c, NULL, !fwd);
 }
 
 
 /**
  * Sends a CONNECTION ACK message in reponse to a received CONNECTION_CREATE
- * directed to us.
+ * or a first CONNECTION_ACK directed to us.
  *
  * @param connection Connection to confirm.
  * @param fwd Is this a fwd ACK? (First is bck (SYNACK), second is fwd (ACK))
@@ -573,6 +573,65 @@
 
 
 /**
+ * Get the previous hop in a connection
+ *
+ * @param c Connection.
+ *
+ * @return Previous peer in the connection.
+ */
+static struct MeshPeer *
+connection_get_prev_hop (struct MeshConnection *c)
+{
+  GNUNET_PEER_Id id;
+
+  if (0 == c->own_pos || c->path->length < 2)
+    id = c->path->peers[0];
+  else
+    id = c->path->peers[c->own_pos - 1];
+
+  return peer_get_short (id);
+}
+
+
+/**
+ * Get the next hop in a connection
+ *
+ * @param c Connection.
+ *
+ * @return Next peer in the connection.
+ */
+static struct MeshPeer *
+connection_get_next_hop (struct MeshConnection *c)
+{
+  GNUNET_PEER_Id id;
+
+  if ((c->path->length - 1) == c->own_pos || c->path->length < 2)
+    id = c->path->peers[c->path->length - 1];
+  else
+    id = c->path->peers[c->own_pos + 1];
+
+  return peer_get_short (id);
+}
+
+
+/**
+ * Get the hop in a connection.
+ *
+ * @param c Connection.
+ * @param fwd Next hop?
+ *
+ * @return Next peer in the connection.
+ */
+static struct MeshPeer *
+connection_get_hop (struct MeshConnection *c, int fwd)
+{
+  if (fwd)
+    return connection_get_next_hop (c);
+  return connection_get_prev_hop (c);
+}
+
+
+/**
  * Get the first transmittable message for a connection.
  *
  * @param c Connection.
@@ -741,70 +800,7 @@
 }
 
 
-
-
 /**
- * Get the previous hop in a connection
- *
- * @param c Connection.
- *
- * @return Previous peer in the connection.
- */
-static struct MeshPeer *
-connection_get_prev_hop (struct MeshConnection *c)
-{
-  GNUNET_PEER_Id id;
-
-  if (0 == c->own_pos || c->path->length < 2)
-    id = c->path->peers[0];
-  else
-    id = c->path->peers[c->own_pos - 1];
-
-  return peer_get_short (id);
-}
-
-
-/**
- * Get the next hop in a connection
- *
- * @param c Connection.
- *
- * @return Next peer in the connection.
- */
-static struct MeshPeer *
-connection_get_next_hop (struct MeshConnection *c)
-{
-  GNUNET_PEER_Id id;
-
-  if ((c->path->length - 1) == c->own_pos || c->path->length < 2)
-    id = c->path->peers[c->path->length - 1];
-  else
-    id = c->path->peers[c->own_pos + 1];
-
-  return peer_get_short (id);
-}
-
-
-/**
- * Get the hop in a connection.
- *
- * @param c Connection.
- * @param fwd Next hop?
- *
- * @return Next peer in the connection.
- */
-static struct MeshPeer *
-connection_get_hop (struct MeshConnection *c, int fwd)
-{
-  if (fwd)
-    return connection_get_next_hop (c);
-  return connection_get_prev_hop (c);
-}
-
-
-
-
-/**
  * Timeout function due to lack of keepalive/traffic from the owner.
  * Destroys connection if called.
  *
@@ -822,7 +818,7 @@
     return;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "Connection %s[%X] FWD timed out. Destroying.\n",
-              peer2s (c->t->peer),
+              GMT_2s (c->t),
               c->id);
 
   if (GMC_is_origin (c, GNUNET_YES)) /* If local, leave. */
@@ -851,8 +847,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "Connection %s[%X] FWD timed out. Destroying.\n",
-              peer2s (c->t->peer),
-              c->id);
+              GMT_2s (c->t), c->id);
 
   if (GMC_is_origin (c, GNUNET_NO)) /* If local, leave. */
     return;
@@ -1058,12 +1053,6 @@
   c = connection_get (cid);
   if (NULL == c)
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "  Creating connection\n");
-    c = connection_new (cid);
-    if (NULL == c)
-      return GNUNET_OK;
-    connection_reset_timeout (c, GNUNET_YES);
-
     /* Create path */
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  Creating path...\n");
     path = path_new (size);
@@ -1086,8 +1075,11 @@
     }
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  Own position: %u\n", own_pos);
     path_add_to_peers (path, GNUNET_NO);
-    c->path = path_duplicate (path);
-    c->own_pos = own_pos;
+        LOG (GNUNET_ERROR_TYPE_DEBUG, "  Creating connection\n");
+    c = GMC_new (cid, NULL, path_duplicate (path), own_pos);
+    if (NULL == c)
+      return GNUNET_OK;
+    connection_reset_timeout (c, GNUNET_YES);
   }
   else
   {
@@ -1128,7 +1120,7 @@
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  Retransmitting.\n");
     peer_add_path (dest_peer, path_duplicate (path), GNUNET_NO);
     peer_add_path_to_origin (orig_peer, path, GNUNET_NO);
-    send_prebuilt_message_connection (message, c, NULL, GNUNET_YES);
+    GMC_send_prebuilt_message (message, c, NULL, GNUNET_YES);
   }
   return GNUNET_OK;
 }
@@ -1204,18 +1196,13 @@
   }
 
   /* Message for us as creator? */
-  if (connection_is_origin (c, GNUNET_YES))
+  if (GMC_is_origin (c, GNUNET_YES))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  Connection (SYN)ACK for us!\n");
     connection_change_state (c, MESH_CONNECTION_READY);
-    if (MESH_TUNNEL_READY != c->t->state)
-      tunnel_change_state (c->t, MESH_TUNNEL_READY);
+    GMT_change_state (c->t, MESH_TUNNEL_READY);
     send_connection_ack (c, GNUNET_YES);
-    tunnel_send_queued_data (c->t, GNUNET_YES);
-    if (3 <= tunnel_count_connections (c->t) && NULL != c->t->peer->dhtget)
-    {
-      GMP_stop_search (c->t->peer);
-    }
+    GMT_send_queued_data (c->t, GNUNET_YES);
     return GNUNET_OK;
   }
 

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h  2013-10-10 12:31:02 UTC (rev 
30086)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h  2013-10-10 12:39:45 UTC (rev 
30087)
@@ -139,7 +139,7 @@
 GMP_start_search (struct MeshPeer *peer);
 
 void
-GMP_start_search (struct MeshPeer *peer);
+GMP_stop_search (struct MeshPeer *peer);
 
 /**
  * Get the Full ID of a peer.

Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-10-10 12:31:02 UTC 
(rev 30086)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-10-10 12:39:45 UTC 
(rev 30087)
@@ -65,7 +65,7 @@
     /**
      * State of the tunnel.
      */
-  enum MeshTunnelState state;
+  enum MeshTunnel3State state;
 
   /**
    * Local peer ephemeral private key
@@ -196,7 +196,7 @@
  * @return String representation.
  */
 static const char *
-GMT_state2s (enum MeshTunnelState s)
+GMT_state2s (enum MeshTunnel3State s)
 {
   static char buf[128];
 
@@ -619,7 +619,7 @@
  * @param state New state.
  */
 void
-GMT_change_state (struct MeshTunnel3* t, enum MeshTunnelState state)
+GMT_change_state (struct MeshTunnel3* t, enum MeshTunnel3State state)
 {
   if (NULL == t)
     return;
@@ -632,6 +632,10 @@
               GMP_2s (t->peer),
               GMT_state2s (state));
   t->state = state;
+  if (MESH_TUNNEL_READY == state && 3 <= GMT_count_connections (t))
+  {
+    GMP_stop_search (t->peer);
+  }
 }
 
 
@@ -996,7 +1000,7 @@
  *
  * @return Tunnel's state.
  */
-enum MeshTunnelState
+enum MeshTunnel3State
 GMT_get_state (struct MeshTunnel3 *t)
 {
   return t->state;

Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.h        2013-10-10 12:31:02 UTC 
(rev 30086)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.h        2013-10-10 12:39:45 UTC 
(rev 30087)
@@ -43,7 +43,7 @@
 /**
  * All the states a tunnel can be in.
  */
-enum MeshTunnelState
+enum MeshTunnel3State
 {
     /**
      * Uninitialized status, should never appear in operation.
@@ -142,7 +142,7 @@
  * @param state New state.
  */
 void
-GMT_change_state (struct MeshTunnel3* t, enum MeshTunnelState state);
+GMT_change_state (struct MeshTunnel3* t, enum MeshTunnel3State state);
 
 /**
  * Add a connection to a tunnel.
@@ -242,7 +242,7 @@
  *
  * @return Tunnel's state.
  */
-enum MeshTunnelState
+enum MeshTunnel3State
 GMT_get_state (struct MeshTunnel3 *t);
 
 /**




reply via email to

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