gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r22792 - in gnunet/src: include mesh


From: gnunet
Subject: [GNUnet-SVN] r22792 - in gnunet/src: include mesh
Date: Fri, 20 Jul 2012 14:49:07 +0200

Author: bartpolot
Date: 2012-07-20 14:49:06 +0200 (Fri, 20 Jul 2012)
New Revision: 22792

Modified:
   gnunet/src/include/gnunet_mesh_service.h
   gnunet/src/include/gnunet_protocols.h
   gnunet/src/mesh/gnunet-service-mesh.c
   gnunet/src/mesh/mesh.h
   gnunet/src/mesh/mesh_api.c
   gnunet/src/mesh/mesh_protocol.h
Log:
- partial change, broken build system on laptop

Modified: gnunet/src/include/gnunet_mesh_service.h
===================================================================
--- gnunet/src/include/gnunet_mesh_service.h    2012-07-20 12:43:27 UTC (rev 
22791)
+++ gnunet/src/include/gnunet_mesh_service.h    2012-07-20 12:49:06 UTC (rev 
22792)
@@ -226,6 +226,10 @@
 /**
  * Announce to ther peer the availability of services described by the regex,
  * in order to be reachable to other peers via connect_by_string.
+ * 
+ * Note that the first 8 characters are considered to be part of a prefix,
+ * (for instance 'gnunet://'). If you put a variable part in there (*, +. ()),
+ * all matching strings will be stored in the DHT.
  *
  * @param h handle to mesh.
  * @param regex string with the regular expression describing local services.
@@ -262,6 +266,26 @@
 
 
 /**
+ * Request that the tunnel data rate is limited to the speed of the slowest
+ * receiver.
+ * 
+ * @param tunnel Tunnel affected.
+ */
+void
+GNUNET_MESH_tunnel_speed_min (struct GNUNET_MESH_Tunnel *tunnel);
+
+
+/**
+ * Request that the tunnel data rate is limited to the speed of the fastest
+ * receiver. This is the default behavior.
+ * 
+ * @param tunnel Tunnel affected.
+ */
+void
+GNUNET_MESH_tunnel_speed_max (struct GNUNET_MESH_Tunnel *tunnel);
+
+
+/**
  * Request that a peer should be added to the tunnel.  The connect handler
  * will be called when the peer connects
  *

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2012-07-20 12:43:27 UTC (rev 
22791)
+++ gnunet/src/include/gnunet_protocols.h       2012-07-20 12:49:06 UTC (rev 
22792)
@@ -846,6 +846,16 @@
 #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_UNBLACKLIST 281
 
 /**
+ * Set tunnel speed to slowest peer
+ */
+#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN    282
+
+/**
+ * Set tunnel speed to fastest peer
+ */
+#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX   283
+
+/**
  * 640kb should be enough for everybody
  */
 #define GNUNET_MESSAGE_TYPE_MESH_RESERVE_END            288

Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2012-07-20 12:43:27 UTC (rev 
22791)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2012-07-20 12:49:06 UTC (rev 
22792)
@@ -336,6 +336,16 @@
   unsigned int queue_max;
 
     /**
+     * Is the speed on the tunnel limited to the slowest peer?
+     */
+  int speed_min;
+
+    /**
+     * Is buffering allowed in the tunnel?
+     */
+  int buffering;
+
+  /**
      * Flag to signal the destruction of the tunnel.
      * If this is set GNUNET_YES the tunnel will be destroyed
      * when the queue is empty.
@@ -5039,6 +5049,61 @@
 
 
 /**
+ * Handler for requests of seeting tunnel's speed.
+ *
+ * @param cls Closure (unused).
+ * @param client Identification of the client.
+ * @param message The actual message.
+ */
+static void
+handle_local_tunnel_speed (void *cls, struct GNUNET_SERVER_Client *client,
+                           const struct GNUNET_MessageHeader *message)
+{
+  struct GNUNET_MESH_TunnelMessage *tunnel_msg;
+  struct MeshClient *c;
+  struct MeshTunnel *t;
+  MESH_TunnelNumber tid;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Got a SPEED request from client!\n");
+
+  /* Sanity check for client registration */
+  if (NULL == (c = client_get (client)))
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "  by client %u\n", c->id);
+  tunnel_msg = (struct GNUNET_MESH_TunnelMessage *) message;
+
+  /* Retrieve tunnel */
+  tid = ntohl (tunnel_msg->tunnel_id);
+  t = tunnel_get_by_local_id(c, tid);
+  if (NULL == t)
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "  tunnel %X not found\n", tid);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+
+  switch (ntohs(message->type))
+  {
+      case GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN:
+          t->speed_min = GNUNET_YES;
+          break;
+      case GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX:
+          t->speed_min = GNUNET_NO;
+          break;
+      default:
+          GNUNET_break (0);
+  }
+}
+
+
+/**
  * Handler for connection requests to new peers
  *
  * @param cls closure
@@ -5787,6 +5852,12 @@
   {&handle_local_tunnel_destroy, NULL,
    GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY,
    sizeof (struct GNUNET_MESH_TunnelMessage)},
+  {&handle_local_tunnel_speed, NULL,
+   GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN,
+   sizeof (struct GNUNET_MESH_TunnelMessage)},
+  {&handle_local_tunnel_speed, NULL,
+   GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX,
+   sizeof (struct GNUNET_MESH_TunnelMessage)},
   {&handle_local_connect_add, NULL,
    GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD,
    sizeof (struct GNUNET_MESH_PeerControl)},

Modified: gnunet/src/mesh/mesh.h
===================================================================
--- gnunet/src/mesh/mesh.h      2012-07-20 12:43:27 UTC (rev 22791)
+++ gnunet/src/mesh/mesh.h      2012-07-20 12:49:06 UTC (rev 22792)
@@ -122,6 +122,7 @@
 {
     /**
      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY]
+     *       GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[MAX|MIN]
      *
      * Size: sizeof(struct GNUNET_MESH_TunnelMessage)
      */

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2012-07-20 12:43:27 UTC (rev 22791)
+++ gnunet/src/mesh/mesh_api.c  2012-07-20 12:49:06 UTC (rev 22792)
@@ -299,6 +299,11 @@
      */
   unsigned int napps;
 
+    /**
+     * Is the tunnel throttled to the slowest peer?
+     */
+  int speed_min;
+
 };
 
 
@@ -1386,6 +1391,10 @@
 /**
  * Announce to ther peer the availability of services described by the regex,
  * in order to be reachable to other peers via connect_by_string.
+ * 
+ * Note that the first 8 characters are considered to be part of a prefix,
+ * (for instance 'gnunet://'). If you put a variable part in there (*, +. ()),
+ * all matching strings will be stored in the DHT.
  *
  * @param h handle to mesh.
  * @param regex string with the regular expression describing local services.
@@ -1484,8 +1493,52 @@
   send_packet (h, &msg.header, NULL);
 }
 
+/**
+ * Request that the tunnel data rate is limited to the speed of the slowest
+ * receiver.
+ *
+ * @param tunnel Tunnel affected.
+ */
+void
+GNUNET_MESH_tunnel_speed_min (struct GNUNET_MESH_Tunnel *tunnel)
+{
+  struct GNUNET_MESH_TunnelMessage msg;
+  struct GNUNET_MESH_Handle *h;
 
+  h = tunnel->mesh;
+  tunnel->speed_min = GNUNET_YES;
+
+  msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN);
+  msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage));
+  msg.tunnel_id = htonl (tunnel->tid);
+
+  send_packet (h, &msg.header, NULL);
+}
+
+
 /**
+ * Request that the tunnel data rate is limited to the speed of the fastest
+ * receiver. This is the default behavior.
+ *
+ * @param tunnel Tunnel affected.
+ */
+void
+GNUNET_MESH_tunnel_speed_max (struct GNUNET_MESH_Tunnel *tunnel)
+{
+  struct GNUNET_MESH_TunnelMessage msg;
+  struct GNUNET_MESH_Handle *h;
+
+  h = tunnel->mesh;
+  tunnel->speed_min = GNUNET_NO;
+
+  msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX);
+  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

Modified: gnunet/src/mesh/mesh_protocol.h
===================================================================
--- gnunet/src/mesh/mesh_protocol.h     2012-07-20 12:43:27 UTC (rev 22791)
+++ gnunet/src/mesh/mesh_protocol.h     2012-07-20 12:49:06 UTC (rev 22792)
@@ -273,10 +273,15 @@
   struct GNUNET_PeerIdentity oid;
 
     /**
-     * Slowest link down the path (above minimum speed requirement).
+     * Is the speed limited by the slowest peer?.
      */
-  uint32_t speed_min;
+  int16_t speed_min;
 
+    /**
+     * Is the buffering allowed?.
+     */
+  int16_t buffering;
+
 };
 GNUNET_NETWORK_STRUCT_END
 




reply via email to

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