gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r30110 - gnunet/src/mesh
Date: Thu, 10 Oct 2013 17:47:14 +0200

Author: bartpolot
Date: 2013-10-10 17:47:14 +0200 (Thu, 10 Oct 2013)
New Revision: 30110

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_connection.h
   gnunet/src/mesh/gnunet-service-mesh_peer.c
   gnunet/src/mesh/gnunet-service-mesh_peer.h
   gnunet/src/mesh/gnunet-service-mesh_tunnel.h
Log:
- expose appropriate functions in API


Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-10 15:37:02 UTC 
(rev 30109)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-10 15:47:14 UTC 
(rev 30110)
@@ -480,35 +480,6 @@
 
 
 /**
- * Sends a CREATE CONNECTION message for a path to a peer.
- * Changes the connection and tunnel states if necessary.
- *
- * @param connection Connection to create.
- */
-static void
-send_connection_create (struct MeshConnection *connection)
-{
-enum MeshTunnel3State state;
-  size_t size;
-
-  size = sizeof (struct GNUNET_MESH_ConnectionCreate);
-  size += connection->path->length * sizeof (struct GNUNET_PeerIdentity);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Send connection create\n");
-  GMP_queue_add (NULL,
-                 GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE,
-                 size,
-                 connection,
-                 NULL,
-                 GNUNET_YES, &message_sent, (void *) size);
-  state = GMT_get_state (connection->t);
-  if (MESH_TUNNEL3_SEARCHING == state || MESH_TUNNEL3_NEW == state)
-    GMT_change_state (connection->t, MESH_TUNNEL3_WAITING);
-  if (MESH_CONNECTION_NEW == connection->state)
-    connection_change_state (connection, MESH_CONNECTION_SENT);
-}
-
-
-/**
  * Send keepalive packets for a connection.
  *
  * @param c Connection to keep alive..
@@ -2037,6 +2008,35 @@
 
 
 /**
+ * Sends a CREATE CONNECTION message for a path to a peer.
+ * Changes the connection and tunnel states if necessary.
+ *
+ * @param connection Connection to create.
+ */
+void
+GMC_send_create (struct MeshConnection *connection)
+{
+enum MeshTunnel3State state;
+  size_t size;
+
+  size = sizeof (struct GNUNET_MESH_ConnectionCreate);
+  size += connection->path->length * sizeof (struct GNUNET_PeerIdentity);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Send connection create\n");
+  GMP_queue_add (NULL,
+                 GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE,
+                 size,
+                 connection,
+                 NULL,
+                 GNUNET_YES, &message_sent, (void *) size);
+  state = GMT_get_state (connection->t);
+  if (MESH_TUNNEL3_SEARCHING == state || MESH_TUNNEL3_NEW == state)
+    GMT_change_state (connection->t, MESH_TUNNEL3_WAITING);
+  if (MESH_CONNECTION_NEW == connection->state)
+    GMC_change_state (connection, MESH_CONNECTION_SENT);
+}
+
+
+/**
  * Send a message to all peers in this connection that the connection
  * is no longer valid.
  *

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.h    2013-10-10 15:37:02 UTC 
(rev 30109)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.h    2013-10-10 15:47:14 UTC 
(rev 30110)
@@ -397,6 +397,15 @@
                            int fwd);
 
 /**
+ * Sends a CREATE CONNECTION message for a path to a peer.
+ * Changes the connection and tunnel states if necessary.
+ *
+ * @param connection Connection to create.
+ */
+void
+GMC_send_create (struct MeshConnection *connection);
+
+/**
  * Send a message to all peers in this connection that the connection
  * is no longer valid.
  *

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-10-10 15:37:02 UTC (rev 
30109)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-10-10 15:47:14 UTC (rev 
30110)
@@ -732,7 +732,7 @@
  * @param path
  */
 static void
-search_handler (void *cls, struct MeshPeerPath *path)
+search_handler (void *cls, const struct MeshPeerPath *path)
 {
   struct MeshPeer *peer = cls;
   unsigned int connection_count;
@@ -1299,7 +1299,7 @@
     return; /* Already unlocked */
   }
 
-  q = connection_get_first_message (c);
+  q = connection_get_first_message (peer, c);
   if (NULL == q)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  queue empty!\n");
@@ -1433,12 +1433,13 @@
   return GMP_get (GNUNET_PEER_resolve2 (peer));
 }
 
+
 /**
- * Try to establish a new connection to this peer in the given tunnel.
+ * Try to establish a new connection to this peer (in its 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.
  *
- * @param peer PeerInfo of the peer.
+ * @param peer Peer to connect to.
  */
 void
 GMP_connect (struct MeshPeer *peer)
@@ -1462,7 +1463,7 @@
     if (NULL != p)
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG, "  %u hops\n", p->length);
-      c = tunnel_use_path (t, p);
+      c = GMT_use_path (t, p);
       if (NULL == c)
       {
         /* This case can happen when the path includes a first hop that is
@@ -1482,7 +1483,7 @@
       }
       else
       {
-        send_connection_create (c);
+        GMC_send_create (c);
         return;
       }
     }
@@ -1505,7 +1506,7 @@
     LOG (GNUNET_ERROR_TYPE_DEBUG,
                 "  Starting DHT GET for peer %s\n", peer2s (peer));
     peer->search_h = GMD_search (id, &search_handler, peer);
-    if (MESH_TUNNEL3_NEW == t->state)
+    if (MESH_TUNNEL3_NEW == GMT_get_state (t))
       GMT_change_state (t, MESH_TUNNEL3_SEARCHING);
   }
 }
@@ -1580,7 +1581,7 @@
  */
 int
 GMP_add_connection (struct MeshPeer *peer,
-                    const struct MeshConnection *c)
+                    struct MeshConnection *c)
 {
   if (NULL == peer->connections)
   {

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h  2013-10-10 15:37:02 UTC (rev 
30109)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h  2013-10-10 15:47:14 UTC (rev 
30110)
@@ -102,6 +102,16 @@
 GMP_get_short (const GNUNET_PEER_Id peer);
 
 /**
+ * Try to establish a new connection to this peer (in its 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.
+ *
+ * @param peer Peer to connect to.
+ */
+void
+GMP_connect (struct MeshPeer *peer);
+
+/**
  * @brief Queue and pass message to core when possible.
  *
  * @param cls Closure (@c type dependant). It will be used by queue_send to
@@ -175,7 +185,7 @@
  * @return GNUNET_OK on success.
  */
 int
-GMP_add_connection (struct MeshPeer *peer, const struct MeshConnection *c);
+GMP_add_connection (struct MeshPeer *peer, 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.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.h        2013-10-10 15:37:02 UTC 
(rev 30109)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.h        2013-10-10 15:47:14 UTC 
(rev 30110)
@@ -222,6 +222,19 @@
 GMT_send_queued_data (struct MeshTunnel3 *t, int fwd);
 
 /**
+ * @brief Use the given path for the tunnel.
+ * Update the next and prev hops (and RCs).
+ * (Re)start the path refresh in case the tunnel is locally owned.
+ *
+ * @param t Tunnel to update.
+ * @param p Path to use.
+ *
+ * @return Connection created.
+ */
+struct MeshConnection *
+GMT_use_path (struct MeshTunnel3 *t, struct MeshPeerPath *p);
+
+/**
  * Count established (ready) connections of a tunnel.
  *
  * @param t Tunnel on which to count.




reply via email to

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