Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f285236e3f3104c15e46b1281c918fd8e03f744d
[simgrid.git] / examples / c / app-bittorrent / tracker.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 BITTORRENT_TRACKER_H
8 #define BITTORRENT_TRACKER_H
9 #include "app-bittorrent.h"
10 #include <xbt/dynar.h>
11
12 void tracker(int argc, char* argv[]);
13 /**
14  * Task types exchanged between a node and the tracker
15  */
16 typedef enum { TRACKER_TASK_QUERY, TRACKER_TASK_ANSWER } e_tracker_task_type_t;
17 /**
18  * Tasks exchanged between a tracker and peers.
19  */
20 typedef struct s_tracker_query {
21   int peer_id;                 // peer id
22   sg_mailbox_t return_mailbox; // mailbox where the tracker should answer
23 } s_tracker_query_t;
24 typedef s_tracker_query_t* tracker_query_t;
25
26 typedef struct s_tracker_answer {
27   int interval;      // how often the peer should contact the tracker (unused for now)
28   xbt_dynar_t peers; // the peer list the peer has asked for.
29 } s_tracker_answer_t;
30 typedef s_tracker_answer_t* tracker_answer_t;
31
32 tracker_query_t tracker_query_new(int peer_id, sg_mailbox_t return_mailbox);
33 tracker_answer_t tracker_answer_new(int interval);
34 void tracker_answer_free(void* data);
35
36 #endif /* BITTORRENT_TRACKER_H */