gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r30108 - gnunet/src/mesh
Date: Thu, 10 Oct 2013 17:35:30 +0200

Author: bartpolot
Date: 2013-10-10 17:35:30 +0200 (Thu, 10 Oct 2013)
New Revision: 30108

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_peer.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:
- fix connection.c


Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-10 15:15:25 UTC 
(rev 30107)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-10 15:35:30 UTC 
(rev 30108)
@@ -1023,8 +1023,8 @@
     connection_change_state (c, MESH_CONNECTION_SENT);
 
   /* Remember peers */
-  dest_peer = peer_get (&id[size - 1]);
-  orig_peer = peer_get (&id[0]);
+  dest_peer = GMP_get (&id[size - 1]);
+  orig_peer = GMP_get (&id[0]);
 
   /* Is it a connection to us? */
   if (c->own_pos == size - 1)
@@ -1032,12 +1032,8 @@
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  It's for us!\n");
     GMP_add_path_to_origin (orig_peer, path, GNUNET_YES);
 
-    if (NULL == orig_peer->tunnel)
-    {
-      orig_peer->tunnel = GMT_new ();
-      orig_peer->tunnel->peer = orig_peer;
-    }
-    GMT_add_connection (orig_peer->tunnel, c);
+    GMP_add_tunnel (orig_peer);
+    GMP_add_connection (orig_peer, c);
     if (MESH_TUNNEL3_NEW == GMT_get_state (c->t))
       GMT_change_state (c->t,  MESH_TUNNEL3_WAITING);
 

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-10-10 15:15:25 UTC (rev 
30107)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-10-10 15:35:30 UTC (rev 
30108)
@@ -139,7 +139,7 @@
     /**
      * Tunnel to this peer, if any.
      */
-  struct MeshTunnel2 *tunnel;
+  struct MeshTunnel3 *tunnel;
 
     /**
      * Connections that go through this peer, indexed by tid;
@@ -252,7 +252,7 @@
 
   LOG ("Peer connected\n");
   LOG ("     %s\n", GNUNET_i2s (&my_full_id));
-  pi = peer_get (peer);
+  pi = GMP_get (peer);
   if (myid == pi->id)
   {
     LOG ("     (self)\n");
@@ -461,7 +461,7 @@
 send_core_connection_ack (struct MeshConnection *c, size_t size, void *buf)
 {
   struct GNUNET_MESH_ConnectionACK *msg = buf;
-  struct MeshTunnel2 *t = c->t;
+  struct MeshTunnel3 *t = c->t;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending CONNECTION ACK...\n");
   GNUNET_assert (NULL != t);
@@ -501,7 +501,7 @@
                  void *value)
 {
   struct MeshPeer *p = value;
-  struct MeshTunnel2 *t = p->tunnel;
+  struct MeshTunnel3 *t = p->tunnel;
 
   if (NULL != t)
     GMT_destroy (t);
@@ -647,52 +647,6 @@
 
 
 /**
- * Retrieve the MeshPeer stucture associated with the peer, create one
- * and insert it in the appropriate structures if the peer is not known yet.
- *
- * @param peer Full identity of the peer.
- *
- * @return Existing or newly created peer info.
- */
-static struct MeshPeer *
-peer_get (const struct GNUNET_PeerIdentity *peer_id)
-{
-  struct MeshPeer *peer;
-
-  peer = GNUNET_CONTAINER_multipeermap_get (peers, peer_id);
-  if (NULL == peer)
-  {
-    peer = GNUNET_new (struct MeshPeer);
-    if (GNUNET_CONTAINER_multipeermap_size (peers) > max_peers)
-    {
-      peer_delete_oldest ();
-    }
-        GNUNET_CONTAINER_multipeermap_put (peers, peer_id, peer,
-                                           
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
-        peer->id = GNUNET_PEER_intern (peer_id);
-  }
-    peer->last_contact = GNUNET_TIME_absolute_get();
-
-    return peer;
-}
-
-
-/**
- * Retrieve the MeshPeer stucture associated with the peer, create one
- * and insert it in the appropriate structures if the peer is not known yet.
- *
- * @param peer Short identity of the peer.
- *
- * @return Existing or newly created peer info.
- */
-static struct MeshPeer *
-peer_get_short (const GNUNET_PEER_Id peer)
-{
-  return peer_get (GNUNET_PEER_resolve2 (peer));
-}
-
-
-/**
  * Get a cost of a path for a peer considering existing tunnel connections.
  *
  * @param peer Peer towards which the path is considered.
@@ -818,7 +772,7 @@
   struct MeshConnection *c;
   struct GNUNET_MessageHeader *msg;
   struct MeshPeerQueue *queue;
-  struct MeshTunnel2 *t;
+  struct MeshTunnel3 *t;
   struct MeshChannel *ch;
   const struct GNUNET_PeerIdentity *dst_id;
   size_t data_size;
@@ -1434,8 +1388,52 @@
   GNUNET_PEER_change_rc (myid, -1);
 }
 
+/**
+ * Retrieve the MeshPeer stucture associated with the peer, create one
+ * and insert it in the appropriate structures if the peer is not known yet.
+ *
+ * @param peer Full identity of the peer.
+ *
+ * @return Existing or newly created peer structure.
+ */
+struct MeshPeer *
+GMP_get (const struct GNUNET_PeerIdentity *peer_id)
+{
+  struct MeshPeer *peer;
 
+  peer = GNUNET_CONTAINER_multipeermap_get (peers, peer_id);
+  if (NULL == peer)
+  {
+    peer = GNUNET_new (struct MeshPeer);
+    if (GNUNET_CONTAINER_multipeermap_size (peers) > max_peers)
+    {
+      peer_delete_oldest ();
+    }
+        GNUNET_CONTAINER_multipeermap_put (peers, peer_id, peer,
+                                           
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
+        peer->id = GNUNET_PEER_intern (peer_id);
+  }
+    peer->last_contact = GNUNET_TIME_absolute_get();
+
+    return peer;
+}
+
+
 /**
+ * Retrieve the MeshPeer stucture associated with the peer, create one
+ * and insert it in the appropriate structures if the peer is not known yet.
+ *
+ * @param peer Short identity of the peer.
+ *
+ * @return Existing or newly created peer structure.
+ */
+struct MeshPeer *
+GMP_get_short (const GNUNET_PEER_Id peer)
+{
+  return GMP_get (GNUNET_PEER_resolve2 (peer));
+}
+
+/**
  * 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 CONNECTION towards it.
@@ -1445,7 +1443,7 @@
 void
 GMP_connect (struct MeshPeer *peer)
 {
-  struct MeshTunnel2 *t;
+  struct MeshTunnel3 *t;
   struct MeshPeerPath *p;
   struct MeshConnection *c;
   int rerun_search;
@@ -1520,7 +1518,7 @@
  * @param t Tunnel.
  */
 void
-GMP_set_tunnel (struct MeshPeer *peer, struct MeshTunnel2 *t)
+GMP_set_tunnel (struct MeshPeer *peer, struct MeshTunnel3 *t)
 {
   peer->tunnel = t;
 }
@@ -1553,6 +1551,22 @@
 
 
 /**
+ * Create and initialize a new tunnel towards a peer, in case it has none.
+ *
+ * Does not generate any traffic, just creates the local data structures.
+ *
+ * @param peer Peer towards which to create the tunnel.
+ */
+void
+GMP_add_tunnel (struct MeshPeer *peer)
+{
+  if (NULL != peer->tunnel)
+    return;
+  peer->tunnel = GMT_new (peer);
+}
+
+
+/**
  * Add a connection to a neighboring peer.
  *
  * Store that the peer is the first hop of the connection in one
@@ -1707,7 +1721,7 @@
     struct MeshPeer *aux;
     struct MeshPeerPath *copy;
 
-    aux = peer_get_short (p->peers[i]);
+    aux = GMP_get_short (p->peers[i]);
     copy = path_duplicate (p);
     copy->length = i + 1;
     GMP_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed);

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h  2013-10-10 15:15:25 UTC (rev 
30107)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h  2013-10-10 15:35:30 UTC (rev 
30108)
@@ -77,7 +77,31 @@
 void
 GMP_shutdown (void);
 
+
 /**
+ * Retrieve the MeshPeer stucture associated with the peer, create one
+ * and insert it in the appropriate structures if the peer is not known yet.
+ *
+ * @param peer Full identity of the peer.
+ *
+ * @return Existing or newly created peer structure.
+ */
+struct MeshPeer *
+GMP_get (const struct GNUNET_PeerIdentity *peer_id);
+
+
+/**
+ * Retrieve the MeshPeer stucture associated with the peer, create one
+ * and insert it in the appropriate structures if the peer is not known yet.
+ *
+ * @param peer Short identity of the peer.
+ *
+ * @return Existing or newly created peer structure.
+ */
+struct MeshPeer *
+GMP_get_short (const GNUNET_PEER_Id peer);
+
+/**
  * @brief Queue and pass message to core when possible.
  *
  * @param cls Closure (@c type dependant). It will be used by queue_send to
@@ -128,6 +152,15 @@
 int
 GMP_is_neighbor (const struct MeshPeer *peer);
 
+/**
+ * Create and initialize a new tunnel towards a peer, in case it has none.
+ *
+ * Does not generate any traffic, just creates the local data structures.
+ *
+ * @param peer Peer towards which to create the tunnel.
+ */
+void
+GMP_add_tunnel (struct MeshPeer *peer);
 
 /**
  * Add a connection to a neighboring peer.
@@ -142,7 +175,7 @@
  * @return GNUNET_OK on success.
  */
 int
-GMP_add_connection (struct MeshPeer *peer, struct MeshConnection *c);
+GMP_add_connection (struct MeshPeer *peer, const struct MeshConnection *c);
 
 /**
  * Add the path to the peer and update the path used to reach it in case this

Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-10-10 15:15:25 UTC 
(rev 30107)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-10-10 15:35:30 UTC 
(rev 30108)
@@ -573,14 +573,17 @@
 
 /**
  * Create a tunnel.
+ *
+ * @param destination Peer this tunnel is towards.
  */
 struct MeshTunnel3 *
-GMT_new (void)
+GMT_new (struct MeshPeer *destination)
 {
   struct MeshTunnel3 *t;
 
   t = GNUNET_new (struct MeshTunnel3);
   t->next_chid = 0;
+  t->peer = destination;
 //   if (GNUNET_OK !=
 //       GNUNET_CONTAINER_multihashmap_put (tunnels, tid, t,
 //                                          
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))

Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.h        2013-10-10 15:15:25 UTC 
(rev 30107)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.h        2013-10-10 15:35:30 UTC 
(rev 30108)
@@ -102,6 +102,14 @@
 GMT_shutdown (void);
 
 /**
+ * Create a tunnel.
+ *
+ * @param destination Peer this tunnel is towards.
+ */
+struct MeshTunnel3 *
+GMT_new (struct MeshPeer *destination);
+
+/**
  * Tunnel is empty: destroy it.
  *
  * Notifies all connections about the destruction.




reply via email to

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