Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9e617ef13f638ad27effe8fefa75a32f8d1553ec
[simgrid.git] / examples / c / dht-kademlia / answer.h
1 /* Copyright (c) 2012-2020. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #ifndef _KADEMLIA_EXAMPLES_ANSWER_H_
8 #define _KADEMLIA_EXAMPLES_ANSWER_H_
9 #include "routing_table.h"
10 #include <xbt/dynar.h>
11
12 /* Node query answer. contains the elements closest to the id given. */
13 typedef struct s_node_answer {
14   unsigned int destination_id;
15   xbt_dynar_t nodes; // Dynar of node_contact_t
16   unsigned int size;
17 } s_answer_t;
18
19 typedef s_answer_t* answer_t;
20 typedef const s_answer_t* const_answer_t;
21
22 answer_t answer_init(unsigned int destination_id);
23 void answer_free(answer_t answer);
24 void answer_print(const_answer_t answer);
25 unsigned int answer_merge(answer_t destination, const_answer_t source);
26 void answer_sort(const_answer_t answer);
27 void answer_trim(answer_t answer);
28 void answer_add_bucket(const_bucket_t bucket, answer_t answer);
29 unsigned int answer_contains(const_answer_t answer, unsigned int id);
30 unsigned int answer_destination_found(const_answer_t answer);
31
32 #endif /* _KADEMLIA_EXAMPLES_ANSWER_H_ */