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

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

commit the next step of tiennou's fastpeers code.

  • Property svn:keywords set to Date Rev Author Id
File size: 3.9 KB
Line 
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 3227 2007-09-28 16:40:21Z 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
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
39int tr_peerMgrIsAcceptingConnections( const tr_peerMgr * manager );
40
41void tr_peerMgrAddIncoming( tr_peerMgr      * manager,
42                            struct in_addr  * addr,
43                            uint16_t          port,
44                            int               socket );
45
46void tr_peerMgrAddPeers( tr_peerMgr     * manager,
47                         const uint8_t  * torrentHash,
48                         int              from,
49                         const uint8_t  * peerCompact,
50                         int              peerCount );
51
52void tr_peerMgrAddPex( tr_peerMgr     * manager,
53                       const uint8_t  * torrentHash,
54                       int              from,
55                       const tr_pex   * pex,
56                       int              pexCount );
57
58void tr_peerMgrSetBlame( tr_peerMgr     * manager,
59                         const uint8_t  * torrentHash,
60                         int              pieceIndex,
61                         int              success );
62
63int tr_peerMgrGetPeers( tr_peerMgr      * manager,
64                        const uint8_t   * torrentHash,
65                        tr_pex         ** setme_pex );
66
67void tr_peerMgrStartTorrent( tr_peerMgr     * manager,
68                             const uint8_t  * torrentHash );
69
70void tr_peerMgrStopTorrent( tr_peerMgr     * manager,
71                            const uint8_t  * torrentHash );
72
73void tr_peerMgrAddTorrent( tr_peerMgr         * manager,
74                           struct tr_torrent  * tor );
75
76void tr_peerMgrRemoveTorrent( tr_peerMgr     * manager,
77                               const uint8_t  * torrentHash );
78
79void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
80                                    const uint8_t    * torrentHash,
81                                    int8_t           * tab,
82                                    int                tabCount );
83
84struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager,
85                                            const uint8_t    * torrentHash );
86
87void tr_peerMgrTorrentStats( const tr_peerMgr * manager,
88                             const uint8_t    * torrentHash,
89                             int              * setmePeersTotal,
90                             int              * setmePeersConnected,
91                             int              * setmePeersSendingToUs,
92                             int              * setmePeersGettingFromUs,
93                             int              * setmePeersFrom ); /* <-- array of TR_PEER_FROM__MAX */
94
95struct tr_peer_stat * tr_peerMgrPeerStats( const tr_peerMgr  * manager,
96                                           const uint8_t     * torrentHash,
97                                           int               * setmeCount );
98
99                             
100struct tr_bitfield *
101tr_peerMgrGenerateAllowedSet( const uint32_t         setCount,
102                              const uint32_t         pieceCount,
103                              const uint8_t          infohash[20],
104                              const struct in_addr * ip );
105
106
107
108#endif
Note: See TracBrowser for help on using the repository browser.