2007-09-20 16:32:01 +00:00
|
|
|
/*
|
2008-12-16 00:20:44 +00:00
|
|
|
* This file Copyright (C) 2007-2008 Charles Kerr <charles@transmissionbt.com>
|
2007-09-20 16:32:01 +00:00
|
|
|
*
|
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
2008-09-23 19:11:04 +00:00
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
2007-09-20 16:32:01 +00:00
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
2008-11-24 20:17:36 +00:00
|
|
|
#ifndef __TRANSMISSION__
|
|
|
|
#error only libtransmission should #include this header.
|
|
|
|
#endif
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
#ifndef TR_PEER_MGR_H
|
|
|
|
#define TR_PEER_MGR_H
|
|
|
|
|
|
|
|
#include <inttypes.h> /* uint16_t */
|
2008-01-10 18:52:46 +00:00
|
|
|
|
2008-10-23 02:37:21 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <winsock2.h> /* struct in_addr */
|
|
|
|
#endif
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-12-02 03:41:58 +00:00
|
|
|
#include "net.h"
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
struct tr_peer_stat;
|
|
|
|
struct tr_torrent;
|
|
|
|
typedef struct tr_peerMgr tr_peerMgr;
|
|
|
|
|
2008-04-19 15:07:59 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
/* corresponds to ut_pex's added.f flags */
|
|
|
|
ADDED_F_ENCRYPTION_FLAG = 1,
|
|
|
|
|
|
|
|
/* corresponds to ut_pex's added.f flags */
|
|
|
|
ADDED_F_SEED_FLAG = 2,
|
|
|
|
};
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
typedef struct tr_pex
|
|
|
|
{
|
2008-12-02 03:41:58 +00:00
|
|
|
tr_address addr;
|
|
|
|
tr_port port;
|
|
|
|
uint8_t flags;
|
2007-09-20 16:32:01 +00:00
|
|
|
}
|
|
|
|
tr_pex;
|
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
int tr_pexCompare( const void * a, const void * b );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-12-14 11:21:11 +00:00
|
|
|
tr_peerMgr* tr_peerMgrNew( tr_session * );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
void tr_peerMgrFree( tr_peerMgr * manager );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-12-05 22:56:19 +00:00
|
|
|
tr_bool tr_peerMgrPeerIsSeed( const tr_peerMgr * mgr,
|
|
|
|
const uint8_t * torrentHash,
|
|
|
|
const tr_address * addr );
|
2008-04-17 03:48:56 +00:00
|
|
|
|
2008-12-02 03:41:58 +00:00
|
|
|
void tr_peerMgrAddIncoming( tr_peerMgr * manager,
|
|
|
|
tr_address * addr,
|
|
|
|
tr_port port,
|
|
|
|
int socket );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
tr_pex * tr_peerMgrCompactToPex( const void * compact,
|
|
|
|
size_t compactLen,
|
|
|
|
const uint8_t * added_f,
|
|
|
|
size_t added_f_len,
|
|
|
|
size_t * setme_pex_count );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-12-15 00:17:08 +00:00
|
|
|
tr_pex * tr_peerMgrCompact6ToPex( const void * compact,
|
|
|
|
size_t compactLen,
|
|
|
|
const uint8_t * added_f,
|
|
|
|
size_t added_f_len,
|
|
|
|
size_t * pexCount );
|
|
|
|
|
|
|
|
tr_pex * tr_peerMgrArrayToPex( const void * array,
|
|
|
|
size_t arrayLen,
|
|
|
|
size_t * setme_pex_count );
|
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
void tr_peerMgrAddPex( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
|
|
|
uint8_t from,
|
|
|
|
const tr_pex * pex );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
void tr_peerMgrSetBlame( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
|
|
|
tr_piece_index_t pieceIndex,
|
|
|
|
int success );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
int tr_peerMgrGetPeers( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
2008-12-15 00:17:08 +00:00
|
|
|
tr_pex ** setme_pex,
|
|
|
|
uint8_t af);
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
void tr_peerMgrStartTorrent( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
void tr_peerMgrStopTorrent( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
void tr_peerMgrAddTorrent( tr_peerMgr * manager,
|
|
|
|
struct tr_torrent * tor );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
void tr_peerMgrRemoveTorrent( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
|
|
|
int8_t * tab,
|
|
|
|
unsigned int tabCount );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
2007-09-27 03:03:38 +00:00
|
|
|
struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
|
|
|
|
2008-10-20 03:47:48 +00:00
|
|
|
int tr_peerMgrHasConnections( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
|
|
|
|
|
|
|
void tr_peerMgrTorrentStats( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
|
|
|
int * setmePeersKnown,
|
|
|
|
int * setmePeersConnected,
|
|
|
|
int * setmeSeedsConnected,
|
|
|
|
int * setmeWebseedsSendingToUs,
|
|
|
|
int * setmePeersSendingToUs,
|
|
|
|
int * setmePeersGettingFromUs,
|
|
|
|
int * setmePeersFrom ); /* TR_PEER_FROM__MAX */
|
|
|
|
|
|
|
|
struct tr_peer_stat* tr_peerMgrPeerStats( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
|
|
|
int * setmeCount );
|
|
|
|
|
|
|
|
float* tr_peerMgrWebSpeeds( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
|
|
|
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
#endif
|