1 | /* |
---|
2 | * This file Copyright (C) 2007 Charles Kerr <charles@rebelbase.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.h 3105 2007-09-20 16:32:01Z livings124 $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef TR_PEER_MGR_H |
---|
14 | #define TR_PEER_MGR_H |
---|
15 | |
---|
16 | #include <inttypes.h> /* uint16_t */ |
---|
17 | #include <arpa/inet.h> /* struct in_addr */ |
---|
18 | |
---|
19 | struct in_addr; |
---|
20 | struct tr_handle; |
---|
21 | struct tr_peer_stat; |
---|
22 | struct tr_torrent; |
---|
23 | typedef struct tr_peerMgr tr_peerMgr; |
---|
24 | |
---|
25 | typedef struct tr_pex |
---|
26 | { |
---|
27 | struct in_addr in_addr; |
---|
28 | uint16_t port; |
---|
29 | uint8_t flags; |
---|
30 | } |
---|
31 | tr_pex; |
---|
32 | |
---|
33 | int tr_pexCompare( const void * a, const void * b ); |
---|
34 | |
---|
35 | tr_peerMgr* tr_peerMgrNew( struct tr_handle * ); |
---|
36 | |
---|
37 | void tr_peerMgrFree( tr_peerMgr * manager ); |
---|
38 | |
---|
39 | int tr_peerMgrIsAcceptingConnections( const tr_peerMgr * manager ); |
---|
40 | |
---|
41 | void tr_peerMgrAddIncoming( tr_peerMgr * manager, |
---|
42 | struct in_addr * addr, |
---|
43 | int socket ); |
---|
44 | |
---|
45 | void tr_peerMgrAddPeers( tr_peerMgr * manager, |
---|
46 | const uint8_t * torrentHash, |
---|
47 | int from, |
---|
48 | const uint8_t * peerCompact, |
---|
49 | int peerCount ); |
---|
50 | |
---|
51 | void tr_peerMgrAddPex( tr_peerMgr * manager, |
---|
52 | const uint8_t * torrentHash, |
---|
53 | int from, |
---|
54 | const tr_pex * pex, |
---|
55 | int pexCount ); |
---|
56 | |
---|
57 | void tr_peerMgrSetBlame( tr_peerMgr * manager, |
---|
58 | const uint8_t * torrentHash, |
---|
59 | int pieceIndex, |
---|
60 | int success ); |
---|
61 | |
---|
62 | int tr_peerMgrGetPeers( tr_peerMgr * manager, |
---|
63 | const uint8_t * torrentHash, |
---|
64 | tr_pex ** setme_pex ); |
---|
65 | |
---|
66 | void tr_peerMgrStartTorrent( tr_peerMgr * manager, |
---|
67 | const uint8_t * torrentHash ); |
---|
68 | |
---|
69 | void tr_peerMgrStopTorrent( tr_peerMgr * manager, |
---|
70 | const uint8_t * torrentHash ); |
---|
71 | |
---|
72 | void tr_peerMgrAddTorrent( tr_peerMgr * manager, |
---|
73 | struct tr_torrent * tor ); |
---|
74 | |
---|
75 | void tr_peerMgrRemoveTorrent( tr_peerMgr * manager, |
---|
76 | const uint8_t * torrentHash ); |
---|
77 | |
---|
78 | void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager, |
---|
79 | const uint8_t * torrentHash, |
---|
80 | int8_t * tab, |
---|
81 | int tabCount ); |
---|
82 | |
---|
83 | void tr_peerMgrTorrentStats( const tr_peerMgr * manager, |
---|
84 | const uint8_t * torrentHash, |
---|
85 | int * setmePeersTotal, |
---|
86 | int * setmePeersConnected, |
---|
87 | int * setmePeersSendingToUs, |
---|
88 | int * setmePeersGettingFromUs, |
---|
89 | int * setmePeersFrom ); /* <-- array of TR_PEER_FROM__MAX */ |
---|
90 | |
---|
91 | struct tr_peer_stat * tr_peerMgrPeerStats( const tr_peerMgr * manager, |
---|
92 | const uint8_t * torrentHash, |
---|
93 | int * setmeCount ); |
---|
94 | |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | |
---|
99 | #endif |
---|