Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correct a bug in kademlia
[simgrid.git] / examples / msg / kademlia / task.h
1 /* Copyright (c) 2012. 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 #ifndef _MSG_KADEMLIA_EXAMPLES_TASK
7 #define _MSG_KADEMLIA_EXAMPLES_TASK
8 #include "common.h"
9 #include "node.h"
10 #include "msg/msg.h"
11 /**
12   * Types of tasks exchanged
13   */
14 typedef enum {
15   TASK_FIND_NODE,
16   TASK_FIND_NODE_ANSWER,
17   TASK_FIND_VALUE,
18   TASK_FIND_VALUE_ANSWER,
19   TASK_PING,
20   TASK_PING_ANSWER,
21   TASK_LEAVING
22 } e_task_type_t;
23 /**
24   * Data attached with the tasks
25   */
26 typedef struct s_task_data {
27   e_task_type_t type;
28   unsigned int sender_id;       //Id of the guy who sent the task
29   unsigned int destination_id;  //Id we are trying to find, if needed.
30   answer_t answer;              //Answer to the request made, if needed.
31   char *answer_to;              // mailbox to send the answer to (if not an answer).
32   const char *issuer_host_name; // used for logging
33 } s_task_data_t, *task_data_t;
34
35 //Task handling functions
36 msg_task_t task_new_find_node(unsigned int sender_id,
37                               unsigned int destination_id, char *mailbox,
38                               const char *hostname);
39
40 msg_task_t task_new_find_node_answer(unsigned int sender_id,
41                                      unsigned int destination_id,
42                                      answer_t answer, char *mailbox,
43                                      const char *hostname);
44
45 msg_task_t task_new_ping(unsigned int sender_id, char *mailbox,
46                          const char *hostname);
47 msg_task_t task_new_ping_answer(unsigned int sender_id, char *mailbox,
48                                 const char *hostname);
49 void task_free(msg_task_t task);
50 void task_free_v(void *task);
51 #endif                          /* _MSG_KADEMLIA_EXAMPLES_TASK */