2007-09-20 16:32:01 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2007 Charles Kerr <charles@rebelbase.com>
|
|
|
|
*
|
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TR_PEER_MGR_H
|
|
|
|
#define TR_PEER_MGR_H
|
|
|
|
|
|
|
|
#include <inttypes.h> /* uint16_t */
|
2007-10-25 13:59:46 +00:00
|
|
|
#include <netinet/in.h> /* struct in_addr */
|
2007-09-20 16:32:01 +00:00
|
|
|
|
|
|
|
struct in_addr;
|
|
|
|
struct tr_handle;
|
|
|
|
struct tr_peer_stat;
|
|
|
|
struct tr_torrent;
|
|
|
|
typedef struct tr_peerMgr tr_peerMgr;
|
|
|
|
|
|
|
|
typedef struct tr_pex
|
|
|
|
{
|
|
|
|
struct in_addr in_addr;
|
|
|
|
uint16_t port;
|
|
|
|
uint8_t flags;
|
|
|
|
}
|
|
|
|
tr_pex;
|
|
|
|
|
|
|
|
int tr_pexCompare( const void * a, const void * b );
|
|
|
|
|
|
|
|
tr_peerMgr* tr_peerMgrNew( struct tr_handle * );
|
|
|
|
|
|
|
|
void tr_peerMgrFree( tr_peerMgr * manager );
|
|
|
|
|
|
|
|
void tr_peerMgrAddIncoming( tr_peerMgr * manager,
|
|
|
|
struct in_addr * addr,
|
2007-09-25 23:10:34 +00:00
|
|
|
uint16_t port,
|
2007-09-20 16:32:01 +00:00
|
|
|
int socket );
|
|
|
|
|
|
|
|
void tr_peerMgrAddPeers( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
2007-10-16 00:55:17 +00:00
|
|
|
uint8_t from,
|
2007-09-20 16:32:01 +00:00
|
|
|
const uint8_t * peerCompact,
|
|
|
|
int peerCount );
|
|
|
|
|
|
|
|
void tr_peerMgrAddPex( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
2007-10-16 00:55:17 +00:00
|
|
|
uint8_t from,
|
2007-09-20 16:32:01 +00:00
|
|
|
const tr_pex * pex,
|
|
|
|
int pexCount );
|
|
|
|
|
|
|
|
void tr_peerMgrSetBlame( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
|
|
|
int pieceIndex,
|
|
|
|
int success );
|
|
|
|
|
|
|
|
int tr_peerMgrGetPeers( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
|
|
|
tr_pex ** setme_pex );
|
|
|
|
|
|
|
|
void tr_peerMgrStartTorrent( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
|
|
|
|
|
|
|
void tr_peerMgrStopTorrent( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
|
|
|
|
|
|
|
void tr_peerMgrAddTorrent( tr_peerMgr * manager,
|
|
|
|
struct tr_torrent * tor );
|
|
|
|
|
|
|
|
void tr_peerMgrRemoveTorrent( tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
|
|
|
|
|
|
|
void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
|
|
|
int8_t * tab,
|
|
|
|
int tabCount );
|
|
|
|
|
2007-09-27 03:03:38 +00:00
|
|
|
struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
|
|
|
|
2007-10-21 15:47:26 +00:00
|
|
|
int tr_peerMgrHasConnections( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash );
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
void tr_peerMgrTorrentStats( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
2007-10-01 15:51:54 +00:00
|
|
|
int * setmePeersKnown,
|
2007-09-20 16:32:01 +00:00
|
|
|
int * setmePeersConnected,
|
|
|
|
int * setmePeersSendingToUs,
|
|
|
|
int * setmePeersGettingFromUs,
|
|
|
|
int * setmePeersFrom ); /* <-- array of TR_PEER_FROM__MAX */
|
|
|
|
|
|
|
|
struct tr_peer_stat * tr_peerMgrPeerStats( const tr_peerMgr * manager,
|
|
|
|
const uint8_t * torrentHash,
|
|
|
|
int * setmeCount );
|
|
|
|
|
2007-09-28 16:40:21 +00:00
|
|
|
|
|
|
|
struct tr_bitfield *
|
|
|
|
tr_peerMgrGenerateAllowedSet( const uint32_t setCount,
|
|
|
|
const uint32_t pieceCount,
|
|
|
|
const uint8_t infohash[20],
|
|
|
|
const struct in_addr * ip );
|
2007-09-20 16:32:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|