gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22803 - gnunet/src/mesh
Date: Fri, 20 Jul 2012 18:18:18 +0200

Author: bartpolot
Date: 2012-07-20 18:18:18 +0200 (Fri, 20 Jul 2012)
New Revision: 22803

Modified:
   gnunet/src/mesh/mesh_api.c
Log:
- new API calls

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2012-07-20 15:25:39 UTC (rev 22802)
+++ gnunet/src/mesh/mesh_api.c  2012-07-20 16:18:18 UTC (rev 22803)
@@ -303,6 +303,11 @@
      * Is the tunnel throttled to the slowest peer?
      */
   int speed_min;
+  
+    /**
+     * Is the tunnel allowed to buffer?
+     */
+  int buffering;
 
 };
 
@@ -718,14 +723,13 @@
     pmsg.tunnel_id = htonl (t->tid);
 
     /* Reconnect all peers */
-    for (i = 0; i < t->npeers; i++)
+    /* If the tunnel was "by type", dont connect individual peers */
+    for (i = 0; i < t->npeers && 0 == t->napps; i++)
     {
       GNUNET_PEER_resolve (t->peers[i]->id, &pmsg.peer);
       if (NULL != t->disconnect_handler && t->peers[i]->connected)
         t->disconnect_handler (t->cls, &pmsg.peer);
-      /* If the tunnel was "by type", dont connect individual peers */
-      if (0 == t->napps)
-        send_packet (t->mesh, &pmsg.header, t);
+      send_packet (t->mesh, &pmsg.header, t);
     }
     /* Reconnect all types, if any  */
     for (i = 0; i < t->napps; i++)
@@ -738,6 +742,10 @@
       msg.type = htonl (t->apps[i]);
       send_packet (t->mesh, &msg.header, t);
     }
+    if (GNUNET_NO == t->buffering)
+      GNUNET_MESH_tunnel_buffer (t, GNUNET_NO);
+    if (GNUNET_YES == t->speed_min)
+      GNUNET_MESH_tunnel_speed_min (t);
   }
   return GNUNET_YES;
 }
@@ -1539,6 +1547,32 @@
 }
 
 /**
+ * Turn on/off the buffering status of the tunnel.
+ * 
+ * @param tunnel Tunnel affected.
+ * @param buffer GNUNET_YES to turn buffering on (default),
+ *               GNUNET_NO otherwise.
+ */
+void
+GNUNET_MESH_tunnel_buffer (struct GNUNET_MESH_Tunnel *tunnel, int buffer)
+{
+  struct GNUNET_MESH_TunnelMessage msg;
+  struct GNUNET_MESH_Handle *h;
+
+  h = tunnel->mesh;
+  tunnel->buffering = buffer;
+
+  if (GNUNET_YES == buffer)
+    msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_BUFFER);
+  else
+    msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOBUFFER);
+  msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage));
+  msg.tunnel_id = htonl (tunnel->tid);
+
+  send_packet (h, &msg.header, NULL);
+}
+
+/**
  * Request that a peer should be added to the tunnel.  The existing
  * connect handler will be called ONCE with either success or failure.
  * This function should NOT be called again with the same peer before the
@@ -1651,6 +1685,8 @@
 /**
  * Request that the mesh should try to connect to a peer matching the
  * description given in the service string.
+ * 
+ * FIXME: allow multiple? how to deal with reconnect?
  *
  * @param tunnel handle to existing tunnel
  * @param description string describing the destination node requirements




reply via email to

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