aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/mesh.h
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-09-20 17:22:58 +0000
committerBart Polot <bart@net.in.tum.de>2011-09-20 17:22:58 +0000
commit62cf5f2f6da72d38adac69e239400edd501ef9cb (patch)
treed60c7b9e70328628d81ad2176a5cc9f96c441c37 /src/mesh/mesh.h
parent73e047c74d351257f8b6cf0815a56ff650520cc1 (diff)
downloadgnunet-62cf5f2f6da72d38adac69e239400edd501ef9cb.tar.gz
gnunet-62cf5f2f6da72d38adac69e239400edd501ef9cb.zip
Cleaned and fixed refactoring to improve separation, only 3 structs are now shared
Diffstat (limited to 'src/mesh/mesh.h')
-rw-r--r--src/mesh/mesh.h381
1 files changed, 0 insertions, 381 deletions
diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h
index 2a7133a55..e816e5ddc 100644
--- a/src/mesh/mesh.h
+++ b/src/mesh/mesh.h
@@ -246,386 +246,5 @@ enum MeshPeerState
246}; 246};
247 247
248 248
249/******************************************************************************/
250/************************ DATA STRUCTURES ****************************/
251/******************************************************************************/
252
253/**
254 * Information regarding a possible path to reach a single peer
255 */
256struct MeshPeerPath
257{
258
259 /**
260 * Linked list
261 */
262 struct MeshPeerPath *next;
263 struct MeshPeerPath *prev;
264
265 /**
266 * List of all the peers that form the path from origin to target.
267 */
268 GNUNET_PEER_Id *peers;
269
270 /**
271 * Number of peers (hops) in the path
272 */
273 unsigned int length;
274
275};
276
277
278/**
279 * Node of path tree for a tunnel
280 */
281struct MeshTunnelPathNode
282{
283 /**
284 * Tunnel this node belongs to (and therefore tree)
285 */
286 struct MeshTunnel *t;
287
288 /**
289 * Peer this node describes
290 */
291 GNUNET_PEER_Id peer;
292
293 /**
294 * Parent node in the tree
295 */
296 struct MeshTunnelPathNode *parent;
297
298 /**
299 * Array of children
300 */
301 struct MeshTunnelPathNode *children;
302
303 /**
304 * Number of children
305 */
306 unsigned int nchildren;
307
308 /**
309 * Status of the peer in the tunnel
310 */
311 enum MeshPeerState status;
312};
313
314
315/**
316 * Tree to reach all peers in the tunnel
317 */
318struct MeshTunnelPath
319{
320 /**
321 * How often to refresh the path
322 */
323 struct GNUNET_TIME_Relative refresh;
324
325 /**
326 * Tunnel this path belongs to
327 */
328 struct MeshTunnel *t;
329
330 /**
331 * Root node of peer tree
332 */
333 struct MeshTunnelPathNode *root;
334
335 /**
336 * Node that represents our position in the tree (for non local tunnels)
337 */
338 struct MeshTunnelPathNode *me;
339
340 /**
341 * Cache of all peers and the first hop to them.
342 * Indexed by Peer_Identity, contains a pointer to the PeerIdentity
343 * of 1st hop.
344 */
345 struct GNUNET_CONTAINER_MultiHashMap *first_hops;
346
347};
348
349
350/** FWD declaration */
351struct MeshPeerInfo;
352
353/**
354 * Struct containing all info possibly needed to build a package when called
355 * back by core.
356 */
357struct MeshDataDescriptor
358{
359 /** ID of the tunnel this packet travels in */
360 struct MESH_TunnelID *origin;
361
362 /** Ultimate destination of the packet */
363 GNUNET_PEER_Id destination;
364
365 /** Number of identical messages sent to different hops (multicast) */
366 unsigned int copies;
367
368 /** Size of the data */
369 size_t size;
370
371 /** Client that asked for the transmission, if any */
372 struct GNUNET_SERVER_Client *client;
373
374 /** Who was is message being sent to */
375 struct MeshPeerInfo *peer;
376
377 /** Which handler was used to request the transmission */
378 unsigned int handler_n;
379
380 /* Data at the end */
381};
382
383
384/**
385 * Struct containing all information regarding a given peer
386 */
387struct MeshPeerInfo
388{
389 /**
390 * ID of the peer
391 */
392 GNUNET_PEER_Id id;
393
394 /**
395 * Last time we heard from this peer
396 */
397 struct GNUNET_TIME_Absolute last_contact;
398
399 /**
400 * Number of attempts to reconnect so far
401 */
402 int n_reconnect_attempts;
403
404 /**
405 * Paths to reach the peer, ordered by ascending hop count
406 */
407 struct MeshPeerPath *path_head;
408
409 /**
410 * Paths to reach the peer, ordered by ascending hop count
411 */
412 struct MeshPeerPath *path_tail;
413
414 /**
415 * Handle to stop the DHT search for a path to this peer
416 */
417 struct GNUNET_DHT_GetHandle *dhtget;
418
419 /**
420 * Handles to stop queued transmissions for this peer
421 */
422 struct GNUNET_CORE_TransmitHandle *core_transmit[CORE_QUEUE_SIZE];
423
424 /**
425 * Pointer to info stuctures used as cls for queued transmissions
426 */
427 struct MeshDataDescriptor *infos[CORE_QUEUE_SIZE];
428
429 /**
430 * Array of tunnels this peer participates in
431 * (most probably a small amount, therefore not a hashmap)
432 * When the path to the peer changes, notify these tunnels to let them
433 * re-adjust their path trees.
434 */
435 struct MeshTunnel **tunnels;
436
437 /**
438 * Number of tunnels above
439 */
440 unsigned int ntunnels;
441};
442
443
444/**
445 * Data scheduled to transmit (to local client or remote peer)
446 */
447struct MeshQueue
448{
449 /**
450 * Double linked list
451 */
452 struct MeshQueue *next;
453 struct MeshQueue *prev;
454
455 /**
456 * Target of the data (NULL if target is client)
457 */
458 struct MeshPeerInfo *peer;
459
460 /**
461 * Client to send the data to (NULL if target is peer)
462 */
463 struct MeshClient *client;
464
465 /**
466 * Size of the message to transmit
467 */
468 unsigned int size;
469
470 /**
471 * How old is the data?
472 */
473 struct GNUNET_TIME_Absolute timestamp;
474
475 /**
476 * Data itself
477 */
478 struct GNUNET_MessageHeader *data;
479};
480
481/**
482 * Globally unique tunnel identification (owner + number)
483 * DO NOT USE OVER THE NETWORK
484 */
485struct MESH_TunnelID
486{
487 /**
488 * Node that owns the tunnel
489 */
490 GNUNET_PEER_Id oid;
491
492 /**
493 * Tunnel number to differentiate all the tunnels owned by the node oid
494 * ( tid < GNUNET_MESH_LOCAL_TUNNEL_ID_CLI )
495 */
496 MESH_TunnelNumber tid;
497};
498
499
500struct MeshClient; /* FWD declaration */
501
502/**
503 * Struct containing all information regarding a tunnel
504 * For an intermediate node the improtant info used will be:
505 * - id Tunnel unique identification
506 * - paths[0] To know where to send it next
507 * - metainfo: ready, speeds, accounting
508 */
509struct MeshTunnel
510{
511 /**
512 * Tunnel ID
513 */
514 struct MESH_TunnelID id;
515
516 /**
517 * Local tunnel number ( >= GNUNET_MESH_LOCAL_TUNNEL_ID_CLI or 0 )
518 */
519 MESH_TunnelNumber local_tid;
520
521 /**
522 * Last time the tunnel was used
523 */
524 struct GNUNET_TIME_Absolute timestamp;
525
526 /**
527 * Peers in the tunnel, indexed by PeerIdentity -> (MeshPeerInfo)
528 */
529 struct GNUNET_CONTAINER_MultiHashMap *peers;
530
531 /**
532 * Number of peers that are connected and potentially ready to receive data
533 */
534 unsigned int peers_ready;
535
536 /**
537 * Number of peers that have been added to the tunnel
538 */
539 unsigned int peers_total;
540
541 /**
542 * Client owner of the tunnel, if any
543 */
544 struct MeshClient *client;
545
546 /**
547 * Messages ready to transmit
548 */
549 struct MeshQueue *queue_head;
550 struct MeshQueue *queue_tail;
551
552 /**
553 * Tunnel paths
554 */
555 struct MeshTunnelPath *tree;
556
557 /**
558 * Task to keep the used paths alive
559 */
560 GNUNET_SCHEDULER_TaskIdentifier path_refresh_task;
561};
562
563
564/**
565 * Info needed to work with tunnel paths and peers
566 */
567struct MeshPathInfo
568{
569 /**
570 * Tunnel
571 */
572 struct MeshTunnel *t;
573
574 /**
575 * Destination peer
576 */
577 struct MeshPeerInfo *peer;
578
579 /**
580 * Path itself
581 */
582 struct MeshPeerPath *path;
583};
584
585
586/**
587 * Struct containing information about a client of the service
588 */
589struct MeshClient
590{
591 /**
592 * Linked list
593 */
594 struct MeshClient *next;
595 struct MeshClient *prev;
596
597 /**
598 * Tunnels that belong to this client, indexed by local id
599 */
600 struct GNUNET_CONTAINER_MultiHashMap *tunnels;
601
602 /**
603 * Handle to communicate with the client
604 */
605 struct GNUNET_SERVER_Client *handle;
606
607 /**
608 * Applications that this client has claimed to provide
609 */
610 struct GNUNET_CONTAINER_MultiHashMap *apps;
611
612 /**
613 * Messages that this client has declared interest in
614 */
615 struct GNUNET_CONTAINER_MultiHashMap *types;
616
617 /**
618 * Used to search peers offering a service
619 */
620 struct GNUNET_DHT_GetHandle *dht_get_type;
621
622#if MESH_DEBUG
623 /**
624 * ID of the client, for debug messages
625 */
626 unsigned int id;
627#endif
628
629};
630 249
631#endif 250#endif