Logo AND Algorithmique Numérique Distribuée

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