Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d13b40e6c0f7f5228c0921e4bda8f82272945193
[simgrid.git] / examples / msg / kademlia / routing_table.h
1
2 /* Copyright (c) 2012. The SimGrid Team.
3  * All rights reserved.                                                     */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #ifndef _MSG_KADEMLIA_EXAMPLES_ROUTING_TABLE
9 #define _MSG_KADEMLIA_EXAMPLES_ROUTING_TABLE
10 #include "common.h"
11 #include <xbt/dynar.h>
12 /*
13  * Routing table bucket
14  */
15 typedef struct s_bucket {
16   xbt_dynar_t nodes; //Nodes in the bucket.
17   unsigned int id; //bucket id
18 } s_bucket_t, *bucket_t;
19
20 /*
21  * Node routing table
22  */
23 typedef struct s_routing_table {
24   unsigned int id; //node id of the client's routing table
25   s_bucket_t *buckets; //Node bucket list - 160 sized.
26 } s_routing_table_t, *routing_table_t;
27 // bucket functions
28 unsigned int bucket_find_id(bucket_t bucket, unsigned int id);
29 unsigned int bucket_contains(bucket_t bucket, unsigned int id);
30 // routing table functions
31 routing_table_t routing_table_init(unsigned int node_id);
32 void routing_table_free(routing_table_t table);
33 unsigned int routing_table_contains(routing_table_t table, unsigned int node_id);
34 void routing_table_print(routing_table_t table);
35 bucket_t routing_table_find_bucket(routing_table_t table, unsigned int id);
36  
37
38 #endif /* _MSG_KADEMLIA_EXAMPLES_ROUTING_TABLE */