- partial change, broken build system on laptop
authorBart Polot <bart@net.in.tum.de>
Fri, 20 Jul 2012 12:49:06 +0000 (12:49 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 20 Jul 2012 12:49:06 +0000 (12:49 +0000)
src/include/gnunet_mesh_service.h
src/include/gnunet_protocols.h
src/mesh/gnunet-service-mesh.c
src/mesh/mesh.h
src/mesh/mesh_api.c
src/mesh/mesh_protocol.h

index 11bf246b4296e7f2c12adbcea6dd19c1245ce92d..e1cd030052ab4bdbb53352932ff288c96c7dbfd9 100644 (file)
@@ -226,6 +226,10 @@ typedef void (*GNUNET_MESH_PeerConnectHandler) (void *cls,
 /**
  * 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.
@@ -261,6 +265,26 @@ void
 GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel);
 
 
+/**
+ * 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
index 9039d0f1b13b989ac95b86608bbeb2471e47084f..652630bcc1beed2a4b63a1c7db288095fd92b2fe 100644 (file)
@@ -845,6 +845,16 @@ extern "C"
  */
 #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
  */
index cd2308898156ecbb433a0dcd46e265b52412c3e9..4965201255a9969a1f50721c089954709ea4f7e7 100644 (file)
@@ -336,6 +336,16 @@ struct MeshTunnel
   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.
@@ -5038,6 +5048,61 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
 }
 
 
+/**
+ * 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
  *
@@ -5787,6 +5852,12 @@ static struct GNUNET_SERVER_MessageHandler client_handlers[] = {
   {&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)},
index fd9de27d8aef1b7e111d256d0eedee2c739466ff..f00c5b256a40314bcdeacfa6f039bf825c47e830 100644 (file)
@@ -122,6 +122,7 @@ struct GNUNET_MESH_TunnelMessage
 {
     /**
      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY]
+     *       GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[MAX|MIN]
      *
      * Size: sizeof(struct GNUNET_MESH_TunnelMessage)
      */
index b12fdc1fe812f83791aca1b6f79c37c24d378017..185b63a661dc1615dfa7cc0d41e546e3083d711b 100644 (file)
@@ -299,6 +299,11 @@ struct GNUNET_MESH_Tunnel
      */
   unsigned int napps;
 
+    /**
+     * Is the tunnel throttled to the slowest peer?
+     */
+  int speed_min;
+
 };
 
 
@@ -1386,6 +1391,10 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle)
 /**
  * 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,6 +1493,50 @@ GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel)
   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
index a699d1897d0705d15a5737c021d9909fc84a967e..033276e253ab8ca0931500bd1602471f4fbc6935 100644 (file)
@@ -273,9 +273,14 @@ struct GNUNET_MESH_SpeedNotify
   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