1 /* Copyright (c) 2012-2021. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef _DHT_KADEMLIA_ROUTING_TABLE
8 #define _DHT_KADEMLIA_ROUTING_TABLE
10 #include <xbt/dynar.h>
12 /* Routing table bucket */
13 typedef struct s_bucket {
14 xbt_dynar_t nodes; // Nodes in the bucket.
15 unsigned int id; // bucket id
18 typedef s_bucket_t* bucket_t;
19 typedef const s_bucket_t* const_bucket_t;
21 /* Node routing table */
22 typedef struct s_routing_table {
23 unsigned int id; // node id of the client's routing table
24 s_bucket_t* buckets; // Node bucket list - 160 sized.
27 typedef s_routing_table_t* routing_table_t;
28 typedef const s_routing_table_t* const_routing_table_t;
31 unsigned int bucket_find_id(const_bucket_t bucket, unsigned int id);
33 // routing table functions
34 routing_table_t routing_table_init(unsigned int node_id);
35 void routing_table_free(routing_table_t table);
36 void routing_table_print(const_routing_table_t table);
37 bucket_t routing_table_find_bucket(const_routing_table_t table, unsigned int id);
39 #endif /* _DHT_KADEMLIA_ROUTING_TABLE */