Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of github.com:simgrid/simgrid into s_type_cleanup
[simgrid.git] / teshsuite / msg / app-bittorrent / tracker.h
1 /* Copyright (c) 2012-2014. 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 "bittorrent.h"
10 #include <xbt/dynar.h>
11 /**
12  * Tracker main function
13  */
14 int tracker(int argc, char* argv[]);
15 /**
16  * Task types exchanged between a node and the tracker
17  */
18 typedef enum { TRACKER_TASK_QUERY, TRACKER_TASK_ANSWER } e_tracker_task_type_t;
19 /**
20  * Tasks exchanged between a tracker and peers.
21  */
22 typedef struct s_tracker_task_data {
23   e_tracker_task_type_t type;   // type of the task
24   const char* mailbox;          // mailbox where the tracker should answer
25   const char* issuer_host_name; // hostname, for debug purposes
26   // Query data
27   int peer_id;    // peer id
28   int uploaded;   // how much the peer has already uploaded
29   int downloaded; // how much the peer has downloaded
30   int left;       // how much the peer has left
31   // Answer data
32   int interval;      // how often the peer should contact the tracker (unused for now)
33   xbt_dynar_t peers; // the peer list the peer has asked for.
34 } s_tracker_task_data_t;
35 typedef s_tracker_task_data_t* tracker_task_data_t;
36
37 tracker_task_data_t tracker_task_data_new(const char* issuer_host_name, const char* mailbox, int peer_id, int uploaded,
38                                           int downloaded, int left);
39 void tracker_task_data_free(tracker_task_data_t task);
40
41 int is_in_list(xbt_dynar_t peers, int id);
42 #endif /* BITTORRENT_TRACKER_H */