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

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

(libT) new API for webseed statistics: tr_torrentGetWebSpeeds()

  • Property svn:keywords set to Date Rev Author Id
File size: 4.5 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 6112 2008-06-10 01:38:12Z charles $
11 */
12
13#ifndef TR_PEER_MGR_H
14#define TR_PEER_MGR_H
15
16#include <inttypes.h> /* uint16_t */
17
18#ifdef WIN32
19#include <winsock2.h> /* struct in_addr */
20#else
21#include <netinet/in.h> /* struct in_addr */
22#endif
23
24struct in_addr;
25struct tr_handle;
26struct tr_peer_stat;
27struct tr_torrent;
28typedef struct tr_peerMgr tr_peerMgr;
29
30enum
31{
32    /* corresponds to ut_pex's added.f flags */
33    ADDED_F_ENCRYPTION_FLAG = 1,
34
35    /* corresponds to ut_pex's added.f flags */
36    ADDED_F_SEED_FLAG = 2,
37};
38
39typedef struct tr_pex
40{
41    struct in_addr in_addr;
42    uint16_t port;
43    uint8_t flags;
44}
45tr_pex;
46
47int tr_pexCompare( const void * a, const void * b );
48
49tr_peerMgr* tr_peerMgrNew( struct tr_handle * );
50
51void tr_peerMgrFree( tr_peerMgr * manager );
52
53int tr_peerMgrPeerIsSeed( const tr_peerMgr      * mgr,
54                          const uint8_t         * torrentHash,
55                          const struct in_addr  * addr );
56
57void tr_peerMgrAddIncoming( tr_peerMgr      * manager,
58                            struct in_addr  * addr,
59                            uint16_t          port,
60                            int               socket );
61
62tr_pex * tr_peerMgrCompactToPex( const void  * compact,
63                                 size_t        compactLen,
64                                 const char  * added_f,
65                                 size_t      * pexCount );
66                             
67void tr_peerMgrAddPex( tr_peerMgr     * manager,
68                       const uint8_t  * torrentHash,
69                       uint8_t          from,
70                       const tr_pex   * pex );
71
72void tr_peerMgrSetBlame( tr_peerMgr     * manager,
73                         const uint8_t  * torrentHash,
74                         int              pieceIndex,
75                         int              success );
76
77int tr_peerMgrGetPeers( tr_peerMgr      * manager,
78                        const uint8_t   * torrentHash,
79                        tr_pex         ** setme_pex );
80
81void tr_peerMgrStartTorrent( tr_peerMgr     * manager,
82                             const uint8_t  * torrentHash );
83
84void tr_peerMgrStopTorrent( tr_peerMgr     * manager,
85                            const uint8_t  * torrentHash );
86
87void tr_peerMgrAddTorrent( tr_peerMgr         * manager,
88                           struct tr_torrent  * tor );
89
90void tr_peerMgrRemoveTorrent( tr_peerMgr     * manager,
91                               const uint8_t  * torrentHash );
92
93void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
94                                    const uint8_t    * torrentHash,
95                                    int8_t           * tab,
96                                    int                tabCount );
97
98struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager,
99                                            const uint8_t    * torrentHash );
100
101int tr_peerMgrHasConnections( const tr_peerMgr * manager,
102                              const uint8_t    * torrentHash );
103
104void tr_peerMgrTorrentStats( const tr_peerMgr * manager,
105                             const uint8_t    * torrentHash,
106                             int              * setmePeersKnown,
107                             int              * setmePeersConnected,
108                             int              * setmeSeedsConnected,
109                             int              * setmePeersSendingToUs,
110                             int              * setmePeersGettingFromUs,
111                             int              * setmePeersFrom ); /* <-- array of TR_PEER_FROM__MAX */
112
113struct tr_peer_stat * tr_peerMgrPeerStats( const tr_peerMgr  * manager,
114                                           const uint8_t     * torrentHash,
115                                           int               * setmeCount );
116
117float* tr_peerMgrWebSpeeds( const tr_peerMgr * manager,
118                            const uint8_t    * torrentHash );
119
120                             
121struct tr_bitfield *
122tr_peerMgrGenerateAllowedSet( const uint32_t         setCount,
123                              const uint32_t         pieceCount,
124                              const uint8_t          infohash[20],
125                              const struct in_addr * ip );
126
127
128
129#endif
Note: See TracBrowser for help on using the repository browser.