1 | /* |
---|
2 | * This file Copyright (C) 2007-2008 Charles Kerr <charles@transmissionbt.com> |
---|
3 | * |
---|
4 | * This file is licensed by the GPL version 2. Works owned by the |
---|
5 | * Transmission project are granted a special exemption to clause 2(b) |
---|
6 | * so that the bulk of its code can remain under the MIT license. |
---|
7 | * This exemption does not extend to derived works not owned by |
---|
8 | * the Transmission project. |
---|
9 | * |
---|
10 | * $Id: peer-mgr-private.h 7580 2009-01-02 19:56:06Z charles $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef __TRANSMISSION__ |
---|
14 | #error only libtransmission should #include this header. |
---|
15 | #endif |
---|
16 | |
---|
17 | #ifndef TR_PEER_MGR_PRIVATE_H |
---|
18 | #define TR_PEER_MGR_PRIVATE_H |
---|
19 | |
---|
20 | #include <inttypes.h> /* uint16_t */ |
---|
21 | |
---|
22 | #ifdef WIN32 |
---|
23 | #include <winsock2.h> /* struct in_addr */ |
---|
24 | #endif |
---|
25 | |
---|
26 | #include "publish.h" /* tr_publisher_tag */ |
---|
27 | |
---|
28 | struct tr_bandwidth; |
---|
29 | struct tr_bitfield; |
---|
30 | struct tr_peerIo; |
---|
31 | struct tr_peermsgs; |
---|
32 | |
---|
33 | enum |
---|
34 | { |
---|
35 | ENCRYPTION_PREFERENCE_UNKNOWN, |
---|
36 | ENCRYPTION_PREFERENCE_YES, |
---|
37 | ENCRYPTION_PREFERENCE_NO |
---|
38 | }; |
---|
39 | |
---|
40 | /** |
---|
41 | * State information about a connected peer. |
---|
42 | * |
---|
43 | * @see struct peer_atom |
---|
44 | * @see tr_peermsgs |
---|
45 | */ |
---|
46 | typedef struct tr_peer |
---|
47 | { |
---|
48 | tr_bool peerIsChoked; |
---|
49 | tr_bool peerIsInterested; |
---|
50 | tr_bool clientIsChoked; |
---|
51 | tr_bool clientIsInterested; |
---|
52 | tr_bool doPurge; |
---|
53 | |
---|
54 | /* number of bad pieces they've contributed to */ |
---|
55 | uint8_t strikes; |
---|
56 | |
---|
57 | uint8_t encryption_preference; |
---|
58 | tr_port port; |
---|
59 | tr_address addr; |
---|
60 | struct tr_peerIo * io; |
---|
61 | |
---|
62 | struct tr_bitfield * blame; |
---|
63 | struct tr_bitfield * have; |
---|
64 | |
---|
65 | /** how complete the peer's copy of the torrent is. [0.0...1.0] */ |
---|
66 | float progress; |
---|
67 | |
---|
68 | /* the client name from the `v' string in LTEP's handshake dictionary */ |
---|
69 | char * client; |
---|
70 | |
---|
71 | time_t chokeChangedAt; |
---|
72 | |
---|
73 | struct tr_peermsgs * msgs; |
---|
74 | tr_publisher_tag msgsTag; |
---|
75 | } |
---|
76 | tr_peer; |
---|
77 | |
---|
78 | double tr_peerGetPieceSpeed( const tr_peer * peer, |
---|
79 | tr_direction direction ); |
---|
80 | |
---|
81 | #endif |
---|