1 /* Copyright (c) 2012. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #ifndef BITTORRENT_TRACKER_H_
8 #define BITTORRENT_TRACKER_H_
10 #include "bittorrent.h"
12 * Tracker main function
14 int tracker(int argc, char *argv[]);
16 * Task types exchanged between a node and the tracker
21 } e_tracker_task_type_t;
23 * Tasks exchanged between a tracker and peers.
25 typedef struct s_tracker_task_data {
26 e_tracker_task_type_t type; //type of the task
27 const char *mailbox; //mailbox where the tracker should answer
28 const char *issuer_host_name; //hostname, for debug purposes
30 int peer_id; //peer id
31 int uploaded; //how much the peer has already uploaded
32 int downloaded; //how much the peer has downloaded
33 int left; //how much the peer has left
35 int interval; //how often the peer should contact the tracker (unused for now)
36 xbt_dynar_t peers; //the peer list the peer has asked for.
37 } s_tracker_task_data_t, *tracker_task_data_t;
39 tracker_task_data_t tracker_task_data_new(const char *issuer_host_name,
40 const char *mailbox, int peer_id,
41 int uploaded, int downloaded,
43 void tracker_task_data_free(tracker_task_data_t task);
45 int is_in_list(xbt_dynar_t peers, int id);
46 #endif /* BITTORRENT_TRACKER_H */