aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_mesh_service.h24
-rw-r--r--src/include/gnunet_protocols.h10
-rw-r--r--src/mesh/gnunet-service-mesh.c71
-rw-r--r--src/mesh/mesh.h1
-rw-r--r--src/mesh/mesh_api.c53
-rw-r--r--src/mesh/mesh_protocol.h9
6 files changed, 166 insertions, 2 deletions
diff --git a/src/include/gnunet_mesh_service.h b/src/include/gnunet_mesh_service.h
index 11bf246b4..e1cd03005 100644
--- a/src/include/gnunet_mesh_service.h
+++ b/src/include/gnunet_mesh_service.h
@@ -226,6 +226,10 @@ typedef void (*GNUNET_MESH_PeerConnectHandler) (void *cls,
226/** 226/**
227 * Announce to ther peer the availability of services described by the regex, 227 * Announce to ther peer the availability of services described by the regex,
228 * in order to be reachable to other peers via connect_by_string. 228 * in order to be reachable to other peers via connect_by_string.
229 *
230 * Note that the first 8 characters are considered to be part of a prefix,
231 * (for instance 'gnunet://'). If you put a variable part in there (*, +. ()),
232 * all matching strings will be stored in the DHT.
229 * 233 *
230 * @param h handle to mesh. 234 * @param h handle to mesh.
231 * @param regex string with the regular expression describing local services. 235 * @param regex string with the regular expression describing local services.
@@ -262,6 +266,26 @@ GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel);
262 266
263 267
264/** 268/**
269 * Request that the tunnel data rate is limited to the speed of the slowest
270 * receiver.
271 *
272 * @param tunnel Tunnel affected.
273 */
274void
275GNUNET_MESH_tunnel_speed_min (struct GNUNET_MESH_Tunnel *tunnel);
276
277
278/**
279 * Request that the tunnel data rate is limited to the speed of the fastest
280 * receiver. This is the default behavior.
281 *
282 * @param tunnel Tunnel affected.
283 */
284void
285GNUNET_MESH_tunnel_speed_max (struct GNUNET_MESH_Tunnel *tunnel);
286
287
288/**
265 * Request that a peer should be added to the tunnel. The connect handler 289 * Request that a peer should be added to the tunnel. The connect handler
266 * will be called when the peer connects 290 * will be called when the peer connects
267 * 291 *
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 9039d0f1b..652630bcc 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -846,6 +846,16 @@ extern "C"
846#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_UNBLACKLIST 281 846#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_UNBLACKLIST 281
847 847
848/** 848/**
849 * Set tunnel speed to slowest peer
850 */
851#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN 282
852
853/**
854 * Set tunnel speed to fastest peer
855 */
856#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX 283
857
858/**
849 * 640kb should be enough for everybody 859 * 640kb should be enough for everybody
850 */ 860 */
851#define GNUNET_MESSAGE_TYPE_MESH_RESERVE_END 288 861#define GNUNET_MESSAGE_TYPE_MESH_RESERVE_END 288
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index cd2308898..496520125 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -336,6 +336,16 @@ struct MeshTunnel
336 unsigned int queue_max; 336 unsigned int queue_max;
337 337
338 /** 338 /**
339 * Is the speed on the tunnel limited to the slowest peer?
340 */
341 int speed_min;
342
343 /**
344 * Is buffering allowed in the tunnel?
345 */
346 int buffering;
347
348 /**
339 * Flag to signal the destruction of the tunnel. 349 * Flag to signal the destruction of the tunnel.
340 * If this is set GNUNET_YES the tunnel will be destroyed 350 * If this is set GNUNET_YES the tunnel will be destroyed
341 * when the queue is empty. 351 * when the queue is empty.
@@ -5039,6 +5049,61 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
5039 5049
5040 5050
5041/** 5051/**
5052 * Handler for requests of seeting tunnel's speed.
5053 *
5054 * @param cls Closure (unused).
5055 * @param client Identification of the client.
5056 * @param message The actual message.
5057 */
5058static void
5059handle_local_tunnel_speed (void *cls, struct GNUNET_SERVER_Client *client,
5060 const struct GNUNET_MessageHeader *message)
5061{
5062 struct GNUNET_MESH_TunnelMessage *tunnel_msg;
5063 struct MeshClient *c;
5064 struct MeshTunnel *t;
5065 MESH_TunnelNumber tid;
5066
5067 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5068 "Got a SPEED request from client!\n");
5069
5070 /* Sanity check for client registration */
5071 if (NULL == (c = client_get (client)))
5072 {
5073 GNUNET_break (0);
5074 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
5075 return;
5076 }
5077
5078 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id);
5079 tunnel_msg = (struct GNUNET_MESH_TunnelMessage *) message;
5080
5081 /* Retrieve tunnel */
5082 tid = ntohl (tunnel_msg->tunnel_id);
5083 t = tunnel_get_by_local_id(c, tid);
5084 if (NULL == t)
5085 {
5086 GNUNET_break (0);
5087 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " tunnel %X not found\n", tid);
5088 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
5089 return;
5090 }
5091
5092 switch (ntohs(message->type))
5093 {
5094 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN:
5095 t->speed_min = GNUNET_YES;
5096 break;
5097 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX:
5098 t->speed_min = GNUNET_NO;
5099 break;
5100 default:
5101 GNUNET_break (0);
5102 }
5103}
5104
5105
5106/**
5042 * Handler for connection requests to new peers 5107 * Handler for connection requests to new peers
5043 * 5108 *
5044 * @param cls closure 5109 * @param cls closure
@@ -5787,6 +5852,12 @@ static struct GNUNET_SERVER_MessageHandler client_handlers[] = {
5787 {&handle_local_tunnel_destroy, NULL, 5852 {&handle_local_tunnel_destroy, NULL,
5788 GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY, 5853 GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY,
5789 sizeof (struct GNUNET_MESH_TunnelMessage)}, 5854 sizeof (struct GNUNET_MESH_TunnelMessage)},
5855 {&handle_local_tunnel_speed, NULL,
5856 GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN,
5857 sizeof (struct GNUNET_MESH_TunnelMessage)},
5858 {&handle_local_tunnel_speed, NULL,
5859 GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX,
5860 sizeof (struct GNUNET_MESH_TunnelMessage)},
5790 {&handle_local_connect_add, NULL, 5861 {&handle_local_connect_add, NULL,
5791 GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD, 5862 GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD,
5792 sizeof (struct GNUNET_MESH_PeerControl)}, 5863 sizeof (struct GNUNET_MESH_PeerControl)},
diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h
index fd9de27d8..f00c5b256 100644
--- a/src/mesh/mesh.h
+++ b/src/mesh/mesh.h
@@ -122,6 +122,7 @@ struct GNUNET_MESH_TunnelMessage
122{ 122{
123 /** 123 /**
124 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY] 124 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY]
125 * GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[MAX|MIN]
125 * 126 *
126 * Size: sizeof(struct GNUNET_MESH_TunnelMessage) 127 * Size: sizeof(struct GNUNET_MESH_TunnelMessage)
127 */ 128 */
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index b12fdc1fe..185b63a66 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -299,6 +299,11 @@ struct GNUNET_MESH_Tunnel
299 */ 299 */
300 unsigned int napps; 300 unsigned int napps;
301 301
302 /**
303 * Is the tunnel throttled to the slowest peer?
304 */
305 int speed_min;
306
302}; 307};
303 308
304 309
@@ -1386,6 +1391,10 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle)
1386/** 1391/**
1387 * Announce to ther peer the availability of services described by the regex, 1392 * Announce to ther peer the availability of services described by the regex,
1388 * in order to be reachable to other peers via connect_by_string. 1393 * in order to be reachable to other peers via connect_by_string.
1394 *
1395 * Note that the first 8 characters are considered to be part of a prefix,
1396 * (for instance 'gnunet://'). If you put a variable part in there (*, +. ()),
1397 * all matching strings will be stored in the DHT.
1389 * 1398 *
1390 * @param h handle to mesh. 1399 * @param h handle to mesh.
1391 * @param regex string with the regular expression describing local services. 1400 * @param regex string with the regular expression describing local services.
@@ -1484,6 +1493,50 @@ GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel)
1484 send_packet (h, &msg.header, NULL); 1493 send_packet (h, &msg.header, NULL);
1485} 1494}
1486 1495
1496/**
1497 * Request that the tunnel data rate is limited to the speed of the slowest
1498 * receiver.
1499 *
1500 * @param tunnel Tunnel affected.
1501 */
1502void
1503GNUNET_MESH_tunnel_speed_min (struct GNUNET_MESH_Tunnel *tunnel)
1504{
1505 struct GNUNET_MESH_TunnelMessage msg;
1506 struct GNUNET_MESH_Handle *h;
1507
1508 h = tunnel->mesh;
1509 tunnel->speed_min = GNUNET_YES;
1510
1511 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN);
1512 msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage));
1513 msg.tunnel_id = htonl (tunnel->tid);
1514
1515 send_packet (h, &msg.header, NULL);
1516}
1517
1518
1519/**
1520 * Request that the tunnel data rate is limited to the speed of the fastest
1521 * receiver. This is the default behavior.
1522 *
1523 * @param tunnel Tunnel affected.
1524 */
1525void
1526GNUNET_MESH_tunnel_speed_max (struct GNUNET_MESH_Tunnel *tunnel)
1527{
1528 struct GNUNET_MESH_TunnelMessage msg;
1529 struct GNUNET_MESH_Handle *h;
1530
1531 h = tunnel->mesh;
1532 tunnel->speed_min = GNUNET_NO;
1533
1534 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX);
1535 msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage));
1536 msg.tunnel_id = htonl (tunnel->tid);
1537
1538 send_packet (h, &msg.header, NULL);
1539}
1487 1540
1488/** 1541/**
1489 * Request that a peer should be added to the tunnel. The existing 1542 * Request that a peer should be added to the tunnel. The existing
diff --git a/src/mesh/mesh_protocol.h b/src/mesh/mesh_protocol.h
index a699d1897..033276e25 100644
--- a/src/mesh/mesh_protocol.h
+++ b/src/mesh/mesh_protocol.h
@@ -273,9 +273,14 @@ struct GNUNET_MESH_SpeedNotify
273 struct GNUNET_PeerIdentity oid; 273 struct GNUNET_PeerIdentity oid;
274 274
275 /** 275 /**
276 * Slowest link down the path (above minimum speed requirement). 276 * Is the speed limited by the slowest peer?.
277 */ 277 */
278 uint32_t speed_min; 278 int16_t speed_min;
279
280 /**
281 * Is the buffering allowed?.
282 */
283 int16_t buffering;
279 284
280}; 285};
281GNUNET_NETWORK_STRUCT_END 286GNUNET_NETWORK_STRUCT_END