2008-06-07 21:26:41 +00:00
|
|
|
/*
|
2011-01-19 13:48:47 +00:00
|
|
|
* This file Copyright (C) Mnemosyne LLC
|
2008-06-07 21:26:41 +00:00
|
|
|
*
|
2010-12-27 19:18:17 +00:00
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
2008-06-07 21:26:41 +00:00
|
|
|
* 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.
|
2008-06-07 21:26:41 +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__
|
2010-05-26 15:23:21 +00:00
|
|
|
#error only libtransmission should #include this header.
|
2008-11-24 20:17:36 +00:00
|
|
|
#endif
|
2008-06-07 21:26:41 +00:00
|
|
|
|
|
|
|
#ifndef TR_PEER_H
|
|
|
|
#define TR_PEER_H
|
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/**
|
|
|
|
* @addtogroup peers Peers
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2008-06-07 21:26:41 +00:00
|
|
|
/**
|
|
|
|
*** Fields common to webseed and bittorrent peers
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "transmission.h"
|
|
|
|
|
2011-02-17 05:14:53 +00:00
|
|
|
struct tr_bitfield;
|
|
|
|
|
2009-11-08 23:20:00 +00:00
|
|
|
enum
|
|
|
|
{
|
2010-01-05 23:47:50 +00:00
|
|
|
/** when we're making requests from another peer,
|
2009-11-08 23:20:00 +00:00
|
|
|
batch them together to send enough requests to
|
|
|
|
meet our bandwidth goals for the next N seconds */
|
2010-05-26 15:23:21 +00:00
|
|
|
REQUEST_BUF_SECS = 10,
|
|
|
|
|
|
|
|
/** this is the maximum size of a block request.
|
|
|
|
most bittorrent clients will reject requests
|
|
|
|
larger than this size. */
|
|
|
|
MAX_BLOCK_SIZE = ( 1024 * 16 )
|
2009-11-08 23:20:00 +00:00
|
|
|
};
|
|
|
|
|
2008-06-07 21:26:41 +00:00
|
|
|
/**
|
|
|
|
*** Peer Publish / Subscribe
|
|
|
|
**/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_PEER_CLIENT_GOT_BLOCK,
|
2009-11-08 23:20:00 +00:00
|
|
|
TR_PEER_CLIENT_GOT_CHOKE,
|
2008-06-07 21:26:41 +00:00
|
|
|
TR_PEER_CLIENT_GOT_DATA,
|
2008-12-02 17:10:54 +00:00
|
|
|
TR_PEER_CLIENT_GOT_ALLOWED_FAST,
|
|
|
|
TR_PEER_CLIENT_GOT_SUGGEST,
|
2009-10-29 16:10:03 +00:00
|
|
|
TR_PEER_CLIENT_GOT_PORT,
|
2009-11-08 23:20:00 +00:00
|
|
|
TR_PEER_CLIENT_GOT_REJ,
|
2011-02-17 05:14:53 +00:00
|
|
|
TR_PEER_CLIENT_GOT_BITFIELD,
|
|
|
|
TR_PEER_CLIENT_GOT_HAVE,
|
|
|
|
TR_PEER_CLIENT_GOT_HAVE_ALL,
|
|
|
|
TR_PEER_CLIENT_GOT_HAVE_NONE,
|
2008-06-07 21:26:41 +00:00
|
|
|
TR_PEER_PEER_GOT_DATA,
|
|
|
|
TR_PEER_PEER_PROGRESS,
|
2010-04-20 21:54:03 +00:00
|
|
|
TR_PEER_ERROR
|
2008-06-07 21:26:41 +00:00
|
|
|
}
|
|
|
|
PeerEventType;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2011-02-17 05:14:53 +00:00
|
|
|
PeerEventType eventType;
|
|
|
|
|
|
|
|
uint32_t pieceIndex; /* for GOT_BLOCK, GOT_HAVE, CANCEL, ALLOWED, SUGGEST */
|
|
|
|
struct tr_bitfield * bitfield; /* for GOT_BITFIELD */
|
|
|
|
uint32_t offset; /* for GOT_BLOCK */
|
|
|
|
uint32_t length; /* for GOT_BLOCK + GOT_DATA */
|
|
|
|
float progress; /* for PEER_PROGRESS */
|
|
|
|
int err; /* errno for GOT_ERROR */
|
|
|
|
tr_bool wasPieceData; /* for GOT_DATA */
|
|
|
|
tr_port port; /* for GOT_PORT */
|
2008-06-07 21:26:41 +00:00
|
|
|
}
|
|
|
|
tr_peer_event;
|
|
|
|
|
2011-02-17 05:14:53 +00:00
|
|
|
extern const tr_peer_event TR_PEER_EVENT_INIT;
|
|
|
|
|
2010-06-19 14:33:10 +00:00
|
|
|
struct tr_peer;
|
|
|
|
|
2011-01-06 01:00:21 +00:00
|
|
|
typedef void tr_peer_callback( struct tr_peer * peer,
|
|
|
|
const tr_peer_event * event,
|
|
|
|
void * client_data );
|
2010-06-19 14:33:10 +00:00
|
|
|
|
2008-10-10 00:38:37 +00:00
|
|
|
#ifdef WIN32
|
2009-08-12 14:40:32 +00:00
|
|
|
#define EMSGSIZE WSAEMSGSIZE
|
2008-10-10 00:38:37 +00:00
|
|
|
#endif
|
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/** @} */
|
|
|
|
|
2008-06-07 21:26:41 +00:00
|
|
|
#endif
|