Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups
[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 /** Tasks exchanged between a tracker and peers. */
14 typedef struct s_tracker_query {
15   int peer_id;                 // peer id
16   sg_mailbox_t return_mailbox; // mailbox where the tracker should answer
17 } s_tracker_query_t;
18 typedef s_tracker_query_t* tracker_query_t;
19
20 typedef struct s_tracker_answer {
21   int interval;      // how often the peer should contact the tracker (unused for now)
22   xbt_dynar_t peers; // the peer list the peer has asked for.
23 } s_tracker_answer_t;
24 typedef s_tracker_answer_t* tracker_answer_t;
25
26 tracker_query_t tracker_query_new(int peer_id, sg_mailbox_t return_mailbox);
27 tracker_answer_t tracker_answer_new(int interval);
28 void tracker_answer_free(void* data);
29
30 #endif /* BITTORRENT_TRACKER_H */