aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-04-08 11:10:07 +0000
committerBart Polot <bart@net.in.tum.de>2011-04-08 11:10:07 +0000
commit6db24d2d442387b5a803c5c3b24ece59f702e667 (patch)
treed95be71efc4cc68cad31624972bdda1fc8e4721e /src/mesh
parent612f0fee557bddd00245a67726aa3c978c07f5c8 (diff)
downloadgnunet-6db24d2d442387b5a803c5c3b24ece59f702e667.tar.gz
gnunet-6db24d2d442387b5a803c5c3b24ece59f702e667.zip
Work in progress (handle_new_client)
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c87
-rw-r--r--src/mesh/mesh.h2
2 files changed, 60 insertions, 29 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index f6be64457..ea9de3211 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -242,10 +242,10 @@ struct PeerInfo
242 /** 242 /**
243 * Is the peer reachable? Is the peer even connected? 243 * Is the peer reachable? Is the peer even connected?
244 */ 244 */
245 enum PeerState state; 245 enum PeerState state;
246 246
247 /** 247 /**
248 * Who to send the data to --- what about multiple (alternate) paths? 248 * Who to send the data to --- FIXME what about multiple (alternate) paths?
249 */ 249 */
250 GNUNET_PEER_Id first_hop; 250 GNUNET_PEER_Id first_hop;
251 251
@@ -263,6 +263,11 @@ typedef uint32_t MESH_PathID;
263struct Path 263struct Path
264{ 264{
265 /** 265 /**
266 * Double linked list
267 */
268 struct Path *next;
269 struct Path *prev;
270 /**
266 * Id of the path, in case it's needed 271 * Id of the path, in case it's needed
267 */ 272 */
268 MESH_PathID id; 273 MESH_PathID id;
@@ -309,11 +314,6 @@ struct MESH_tunnel
309 MESH_TunnelID tid; 314 MESH_TunnelID tid;
310 315
311 /** 316 /**
312 * Whether the tunnel is in a state to transmit data
313 */
314 int ready;
315
316 /**
317 * Minimal speed for this tunnel in kb/s 317 * Minimal speed for this tunnel in kb/s
318 */ 318 */
319 uint32_t speed_min; 319 uint32_t speed_min;
@@ -331,12 +331,24 @@ struct MESH_tunnel
331 /** 331 /**
332 * Peers in the tunnel, for future optimizations 332 * Peers in the tunnel, for future optimizations
333 */ 333 */
334 struct PeerInfo *peers; 334 struct PeerInfo *peers_head;
335 struct PeerInfo *peers_tail;
336
337 /**
338 * Number of peers that are connected and potentially ready to receive data
339 */
340 unsigned int peers_ready;
341
342 /**
343 * Number of peers that have been added to the tunnel
344 */
345 unsigned int peers_total;
335 346
336 /** 347 /**
337 * Paths (used and backup) 348 * Paths (used and backup)
338 */ 349 */
339 struct Path *paths; 350 struct Path *paths_head;
351 struct Path *paths_tail;
340 352
341 /** 353 /**
342 * If this tunnel was created by a local client, what's its handle? 354 * If this tunnel was created by a local client, what's its handle?
@@ -356,8 +368,7 @@ struct MESH_tunnel
356}; 368};
357 369
358/** 370/**
359 * So, I'm an endpoint. Why am I receiveing traffic? 371 * Struct containing information about a client of the service
360 * Who is interested in this? How to communicate with them?
361 */ 372 */
362struct Client 373struct Client
363{ 374{
@@ -368,21 +379,21 @@ struct Client
368 struct Client *prev; 379 struct Client *prev;
369 380
370 /** 381 /**
371 * Tunnels that belong to this client 382 * Tunnels that belong to this client, for convenience on disconnect
372 */ 383 */
373 struct MESH_tunnel *my_tunnels_head; 384 struct MESH_tunnel *tunnels_head;
374 struct MESH_tunnel *my_tunnels_tail; 385 struct MESH_tunnel *tunnels_tail;
375 386
376 /** 387 /**
377 * If this tunnel was created by a local client, what's its handle? 388 * Handle to communicate with the client
378 */ 389 */
379 struct GNUNET_SERVER_Client *handle; 390 struct GNUNET_SERVER_Client *handle;
380 391
381 /** 392 /**
382 * Messages that this client has declared interest in 393 * Messages that this client has declared interest in
383 */ 394 */
384 uint16_t *messages_subscribed; 395 GNUNET_MESH_ApplicationType *messages_subscribed;
385 unsigned int messages_subscribed_counter; 396 unsigned int subscription_counter;
386 397
387}; 398};
388 399
@@ -393,8 +404,8 @@ struct Client
393/** 404/**
394 * All the clients 405 * All the clients
395 */ 406 */
396//static struct Client clients_head; 407static struct Client clients_head;
397//static struct Client clients_tail; 408static struct Client clients_tail;
398 409
399/** 410/**
400 * All the tunnels 411 * All the tunnels
@@ -402,6 +413,11 @@ struct Client
402// static struct MESH_tunnel *tunnel_participation_head; 413// static struct MESH_tunnel *tunnel_participation_head;
403// static struct MESH_tunnel *tunnel_participation_tail; 414// static struct MESH_tunnel *tunnel_participation_tail;
404 415
416/**
417 * All the paths (for future path optimization)
418 */
419// static struct Path *paths_head;
420// static struct Path *paths_tail;
405 421
406/******************************************************************************/ 422/******************************************************************************/
407/******************** MESH NETWORK HANDLERS **************************/ 423/******************** MESH NETWORK HANDLERS **************************/
@@ -524,20 +540,35 @@ handle_local_new_client (void *cls,
524 struct GNUNET_SERVER_Client *client, 540 struct GNUNET_SERVER_Client *client,
525 const struct GNUNET_MessageHeader *message) 541 const struct GNUNET_MessageHeader *message)
526{ 542{
527 struct Client *c; 543 struct Client *c;
544 unsigned int payload_size;
545// struct GNUNET_MESH_Connect *connect_msg;
546//
547// connect_msg = (struct GNUNET_MESH_Connect *) message;
548
549 /* FIXME: check if already exists? NO (optimization) */
550
551 /* FIXME: is this way correct? NO */
552 GNUNET_assert(0 == payload_size % sizeof(GNUNET_MESH_ApplicationType));
553 /* GNUNET_break */
554 /* notify done with syserr */
555 /* return */
556 /* Create new client structure */
557
528 c = GNUNET_malloc(sizeof(struct Client)); 558 c = GNUNET_malloc(sizeof(struct Client));
529 c->handle = client; 559 c->handle = client;
530 //c->messages_subscribed = message->; 560 c->tunnels_head = NULL;
531 561 c->tunnels_tail = NULL;
532 /*client *c; 562 payload_size = message->size - sizeof(GNUNET_MessageHeader);
533 tunnel *t;
534 563
535 t = new; 564 c->messages_subscribed = GNUNET_malloc(payload_size);
536 GNUNET_CONTAINER_DLL_insert (c->my_tunnels_head, 565 memcpy(c->messages_subscribed, &message[1], payload_size);
537 c->my_tunnels_tail, 566 c->subscription_counter = payload_size / sizeof(GNUNET_MESH_ApplicationType);
538 t);*/
539 567
568 /* Insert new client in DLL */
569 GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, c);
540 570
571 /* FIXME: notify done */
541} 572}
542 573
543/** 574/**
diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h
index 551694c27..609d35ec7 100644
--- a/src/mesh/mesh.h
+++ b/src/mesh/mesh.h
@@ -84,7 +84,7 @@ struct GNUNET_MESH_Connect {
84 */ 84 */
85 struct GNUNET_MessageHeader header; 85 struct GNUNET_MessageHeader header;
86 86
87 /* uint16_t messages_subscribed[] */ 87 /* GNUNET_MESH_ApplicationType messages_subscribed[] */
88}; 88};
89 89
90 90