1 /* Copyright (c) 2012-2020. 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_
9 #include "bittorrent.h"
10 #include <xbt/dynar.h>
12 * Tracker main function
14 int tracker(int argc, char* argv[]);
16 * Task types exchanged between a node and the tracker
18 typedef enum { TRACKER_TASK_QUERY, TRACKER_TASK_ANSWER } e_tracker_task_type_t;
20 * Tasks exchanged between a tracker and peers.
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
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
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;
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);
41 int is_in_list(const_xbt_dynar_t peers, int id);
42 #endif /* BITTORRENT_TRACKER_H */