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

Last change on this file since 7224 was 7224, checked in by charles, 14 years ago

(libT) janitorial: use the tr_port type whenever we have a `port' as a function argument or as a field in a struct.

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