/**
* 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.
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
*/
#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
*/
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.
}
+/**
+ * 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
*
{&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)},
{
/**
* Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY]
+ * GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[MAX|MIN]
*
* Size: sizeof(struct GNUNET_MESH_TunnelMessage)
*/
*/
unsigned int napps;
+ /**
+ * Is the tunnel throttled to the slowest peer?
+ */
+ int speed_min;
+
};
/**
* 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.
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
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