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 3265 2007-10-02 00:05:40Z charles $ |
---|
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 | void tr_peerMgrAddIncoming( tr_peerMgr * manager, |
---|
40 | struct in_addr * addr, |
---|
41 | uint16_t port, |
---|
42 | int socket ); |
---|
43 | |
---|
44 | void tr_peerMgrAddPeers( tr_peerMgr * manager, |
---|
45 | const uint8_t * torrentHash, |
---|
46 | int from, |
---|
47 | const uint8_t * peerCompact, |
---|
48 | int peerCount ); |
---|
49 | |
---|
50 | void tr_peerMgrAddPex( tr_peerMgr * manager, |
---|
51 | const uint8_t * torrentHash, |
---|
52 | int from, |
---|
53 | const tr_pex * pex, |
---|
54 | int pexCount ); |
---|
55 | |
---|
56 | void tr_peerMgrSetBlame( tr_peerMgr * manager, |
---|
57 | const uint8_t * torrentHash, |
---|
58 | int pieceIndex, |
---|
59 | int success ); |
---|
60 | |
---|
61 | int tr_peerMgrGetPeers( tr_peerMgr * manager, |
---|
62 | const uint8_t * torrentHash, |
---|
63 | tr_pex ** setme_pex ); |
---|
64 | |
---|
65 | void tr_peerMgrStartTorrent( tr_peerMgr * manager, |
---|
66 | const uint8_t * torrentHash ); |
---|
67 | |
---|
68 | void tr_peerMgrStopTorrent( tr_peerMgr * manager, |
---|
69 | const uint8_t * torrentHash ); |
---|
70 | |
---|
71 | void tr_peerMgrAddTorrent( tr_peerMgr * manager, |
---|
72 | struct tr_torrent * tor ); |
---|
73 | |
---|
74 | void tr_peerMgrRemoveTorrent( tr_peerMgr * manager, |
---|
75 | const uint8_t * torrentHash ); |
---|
76 | |
---|
77 | void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager, |
---|
78 | const uint8_t * torrentHash, |
---|
79 | int8_t * tab, |
---|
80 | int tabCount ); |
---|
81 | |
---|
82 | struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager, |
---|
83 | const uint8_t * torrentHash ); |
---|
84 | |
---|
85 | void tr_peerMgrTorrentStats( const tr_peerMgr * manager, |
---|
86 | const uint8_t * torrentHash, |
---|
87 | int * setmePeersKnown, |
---|
88 | int * setmePeersConnected, |
---|
89 | int * setmePeersSendingToUs, |
---|
90 | int * setmePeersGettingFromUs, |
---|
91 | int * setmePeersFrom ); /* <-- array of TR_PEER_FROM__MAX */ |
---|
92 | |
---|
93 | struct tr_peer_stat * tr_peerMgrPeerStats( const tr_peerMgr * manager, |
---|
94 | const uint8_t * torrentHash, |
---|
95 | int * setmeCount ); |
---|
96 | |
---|
97 | |
---|
98 | struct tr_bitfield * |
---|
99 | tr_peerMgrGenerateAllowedSet( const uint32_t setCount, |
---|
100 | const uint32_t pieceCount, |
---|
101 | const uint8_t infohash[20], |
---|
102 | const struct in_addr * ip ); |
---|
103 | |
---|
104 | |
---|
105 | |
---|
106 | #endif |
---|