gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r27121 - gnunet/src/mesh
Date: Tue, 14 May 2013 13:49:52 +0200

Author: bartpolot
Date: 2013-05-14 13:49:52 +0200 (Tue, 14 May 2013)
New Revision: 27121

Modified:
   gnunet/src/mesh/gnunet-service-mesh-new.c
   gnunet/src/mesh/mesh2.h
Log:
- Added status flag for tunnels


Modified: gnunet/src/mesh/gnunet-service-mesh-new.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh-new.c   2013-05-14 11:31:32 UTC (rev 
27120)
+++ gnunet/src/mesh/gnunet-service-mesh-new.c   2013-05-14 11:49:52 UTC (rev 
27121)
@@ -307,6 +307,11 @@
   struct MESH_TunnelID id;
 
     /**
+     * State of the tunnel.
+     */
+  MeshTunnelState state;
+
+    /**
      * Local tunnel number ( >= GNUNET_MESH_LOCAL_TUNNEL_ID_CLI or 0 )
      */
   MESH_TunnelNumber local_tid;
@@ -1198,29 +1203,21 @@
  * Sends a CREATE PATH message for a path to a peer, properly registrating
  * all used resources.
  *
- * @param peer PeerInfo of the final peer for whom this path is being created.
- * @param p Path itself.
  * @param t Tunnel for which the path is created.
  */
 static void
-send_create_path (struct MeshPeerInfo *peer, struct MeshPeerPath *p,
-                  struct MeshTunnel *t)
+send_create_path (struct MeshTunnel *t)
 {
   struct MeshPeerInfo *neighbor;
 
-  if (NULL == p)
-  {
-    GNUNET_break (0);
-    return;
-  }
-
   neighbor = peer_get_short (t->next_hop);
   queue_add (t,
              GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE,
              sizeof (struct GNUNET_MESH_ManipulatePath) +
-                (p->length * sizeof (struct GNUNET_PeerIdentity)),
+                (t->path->length * sizeof (struct GNUNET_PeerIdentity)),
              neighbor,
              t);
+  t->state = MESH_TUNNEL_WAITING;
 }
 
 
@@ -1251,7 +1248,7 @@
 
 
 /**
- * Try to establish a new connection to this peer in the fiven tunnel.
+ * Try to establish a new connection to this peer in the given tunnel.
  * If the peer doesn't have any path to it yet, try to get one.
  * If the peer already has some path, send a CREATE PATH towards it.
  *
@@ -1267,7 +1264,7 @@
   {
     p = peer_get_best_path (peer, t);
     tunnel_use_path (t, p);
-    send_create_path (peer, p, t);
+    send_create_path (t);
   }
   else if (NULL == peer->dhtget)
   {
@@ -1285,6 +1282,7 @@
                                          NULL,       /* xquery */
                                          0,     /* xquery bits */
                                          &dht_get_id_handler, peer);
+    t->state = MESH_TUNNEL_SEARCHING;
   }
   /* Otherwise, there is no path but the DHT get is already started. */
 }
@@ -2955,6 +2953,7 @@
       return GNUNET_OK;
     }
   }
+  t->state = MESH_TUNNEL_WAITING;
   dest_peer_info =
       GNUNET_CONTAINER_multihashmap_get (peers, &pi[size - 1].hashPubKey);
   if (NULL == dest_peer_info)
@@ -3029,7 +3028,7 @@
     peer_info_add_path (dest_peer_info, path2, GNUNET_NO);
     path2 = path_duplicate (path);
     peer_info_add_path_to_origin (orig_peer_info, path2, GNUNET_NO);
-    send_create_path (dest_peer_info, path, t);
+    send_create_path (t);
   }
   return GNUNET_OK;
 }
@@ -3593,6 +3592,7 @@
   {
     GNUNET_break (0);
   }
+  t->state = MESH_TUNNEL_READY;
 
   /* Message for us? */
   if (0 == memcmp (&msg->oid, &my_full_id, sizeof (struct 
GNUNET_PeerIdentity)))
@@ -3781,8 +3781,6 @@
  * @param type type of the result
  * @param size number of bytes in data
  * @param data pointer to the result data
- *
- * TODO: re-issue the request after certain time? cancel after X results?
  */
 static void
 dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
@@ -3808,7 +3806,8 @@
   path_destroy (p);
   for (i = 0; i < peer->ntunnels; i++)
   {
-    peer_connect (peer, peer->tunnels[i]); // FIXME add if
+    if (peer->tunnels[i]->state == MESH_TUNNEL_SEARCHING)
+      peer_connect (peer, peer->tunnels[i]);
   }
 
   return;
@@ -3907,7 +3906,7 @@
 
   /* Create new client structure */
   c = GNUNET_malloc (sizeof (struct MeshClient));
-  c->id = next_client_id++; // overflow not important: just for debug
+  c->id = next_client_id++; /* overflow not important: just for debug */
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "  CLIENT NEW %u\n", c->id);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "  client has %u types\n", ntypes);
   c->handle = client;

Modified: gnunet/src/mesh/mesh2.h
===================================================================
--- gnunet/src/mesh/mesh2.h     2013-05-14 11:31:32 UTC (rev 27120)
+++ gnunet/src/mesh/mesh2.h     2013-05-14 11:49:52 UTC (rev 27121)
@@ -241,44 +241,34 @@
 
/******************************************************************************/
 
 /**
- * All the states a peer participating in a tunnel can be in.
+ * All the states a tunnel can be in.
  */
-enum MeshPeerState
+enum MeshTunnelState
 {
     /**
      * Uninitialized status, should never appear in operation.
      */
-  MESH_PEER_INVALID,
+  MESH_TUNNEL_NEW,
 
     /**
-     * Peer is the root and owner of the tree
-     */
-  MESH_PEER_ROOT,
-
-    /**
-     * Peer only retransmits traffic, is not a final destination
-     */
-  MESH_PEER_RELAY,
-
-    /**
      * Path to the peer not known yet
      */
-  MESH_PEER_SEARCHING,
+  MESH_TUNNEL_SEARCHING,
 
     /**
      * Request sent, not yet answered.
      */
-  MESH_PEER_WAITING,
+  MESH_TUNNEL_WAITING,
 
     /**
      * Peer connected and ready to accept data
      */
-  MESH_PEER_READY,
+  MESH_TUNNEL_READY,
 
     /**
      * Peer connected previosly but not responding
      */
-  MESH_PEER_RECONNECTING
+  MESH_TUNNEL_RECONNECTING
 };
 
 




reply via email to

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