source: trunk/libtransmission/peer-mgr.h @ 4404

Last change on this file since 4404 was 4404, checked in by charles, 15 years ago

set copyright info to 2008

  • Property svn:keywords set to Date Rev Author Id
File size: 3.9 KB
Line 
1/*
2 * This file Copyright (C) 2007-2008 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 4404 2008-01-01 17:20:20Z charles $
11 */
12
13#ifndef TR_PEER_MGR_H
14#define TR_PEER_MGR_H
15
16#include <inttypes.h> /* uint16_t */
17#include <netinet/in.h> /* struct in_addr */
18
19struct in_addr;
20struct tr_handle;
21struct tr_peer_stat;
22struct tr_torrent;
23typedef struct tr_peerMgr tr_peerMgr;
24
25typedef struct tr_pex
26{
27    struct in_addr in_addr;
28    uint16_t port;
29    uint8_t flags;
30}
31tr_pex;
32
33int tr_pexCompare( const void * a, const void * b );
34
35tr_peerMgr* tr_peerMgrNew( struct tr_handle * );
36
37void tr_peerMgrFree( tr_peerMgr * manager );
38
39void tr_peerMgrAddIncoming( tr_peerMgr      * manager,
40                            struct in_addr  * addr,
41                            uint16_t          port,
42                            int               socket );
43
44void tr_peerMgrAddPeers( tr_peerMgr     * manager,
45                         const uint8_t  * torrentHash,
46                         uint8_t          from,
47                         const uint8_t  * peerCompact,
48                         int              peerCount );
49
50void tr_peerMgrAddPex( tr_peerMgr     * manager,
51                       const uint8_t  * torrentHash,
52                       uint8_t          from,
53                       const tr_pex   * pex,
54                       int              pexCount );
55
56void tr_peerMgrSetBlame( tr_peerMgr     * manager,
57                         const uint8_t  * torrentHash,
58                         int              pieceIndex,
59                         int              success );
60
61int tr_peerMgrGetPeers( tr_peerMgr      * manager,
62                        const uint8_t   * torrentHash,
63                        tr_pex         ** setme_pex );
64
65void tr_peerMgrStartTorrent( tr_peerMgr     * manager,
66                             const uint8_t  * torrentHash );
67
68void tr_peerMgrStopTorrent( tr_peerMgr     * manager,
69                            const uint8_t  * torrentHash );
70
71void tr_peerMgrAddTorrent( tr_peerMgr         * manager,
72                           struct tr_torrent  * tor );
73
74void tr_peerMgrRemoveTorrent( tr_peerMgr     * manager,
75                               const uint8_t  * torrentHash );
76
77void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
78                                    const uint8_t    * torrentHash,
79                                    int8_t           * tab,
80                                    int                tabCount );
81
82struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager,
83                                            const uint8_t    * torrentHash );
84
85int tr_peerMgrHasConnections( const tr_peerMgr * manager,
86                              const uint8_t    * torrentHash );
87
88void tr_peerMgrTorrentStats( const tr_peerMgr * manager,
89                             const uint8_t    * torrentHash,
90                             int              * setmePeersKnown,
91                             int              * setmePeersConnected,
92                             int              * setmePeersSendingToUs,
93                             int              * setmePeersGettingFromUs,
94                             int              * setmePeersFrom ); /* <-- array of TR_PEER_FROM__MAX */
95
96struct tr_peer_stat * tr_peerMgrPeerStats( const tr_peerMgr  * manager,
97                                           const uint8_t     * torrentHash,
98                                           int               * setmeCount );
99
100                             
101struct tr_bitfield *
102tr_peerMgrGenerateAllowedSet( const uint32_t         setCount,
103                              const uint32_t         pieceCount,
104                              const uint8_t          infohash[20],
105                              const struct in_addr * ip );
106
107
108
109#endif
Note: See TracBrowser for help on using the repository browser.