Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Doc] Added description for the boost context factory
[simgrid.git] / examples / msg / bittorrent / connection.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_CONNECTION_H_
8 #define BITTORRENT_CONNECTION_H_
9 /**
10  * Contains the connection data of a peer.
11  */
12 typedef struct s_connection {
13   int id;                       //Peer id
14   char *bitfield;               //Fields
15   char *mailbox;
16   int messages_count;
17   double peer_speed;
18   double last_unchoke;
19   int current_piece;
20   int am_interested:1;          //Indicates if we are interested in something the peer has
21   int interested:1;             //Indicates if the peer is interested in one of our pieces
22   int choked_upload:1;          //Indicates if the peer is choked for the current peer
23   int choked_download:1;        //Indicates if the peer has choked the current peer
24 } s_connection_t, *connection_t;
25 /**
26  * Build a new connection object from the peer id.
27  * @param id id of the peer
28  */
29 connection_t connection_new(int id);
30 /**
31  * Add a new value to the peer speed average
32  * @param connection connection data
33  * @param speed speed to add to the speed average
34  */
35 void connection_add_speed_value(connection_t connection, double speed);
36 /**
37  * Frees a connection object
38  */
39 void connection_free(void *data);
40 #endif                          /* BITTORRENT_CONNECTION_H_ */