2008-06-07 21:26:41 +00:00
|
|
|
/*
|
2009-12-05 02:19:24 +00:00
|
|
|
* This file Copyright (C) 2008-2009 Mnemosyne LLC
|
2008-06-07 21:26:41 +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.
|
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__
|
|
|
|
#error only libtransmission should #include this header.
|
|
|
|
#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"
|
|
|
|
|
2009-11-08 23:20:00 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
/** when we're making requests from another peer,
|
|
|
|
batch them together to send enough requests to
|
|
|
|
meet our bandwidth goals for the next N seconds */
|
2009-12-16 18:20:01 +00:00
|
|
|
REQUEST_BUF_SECS = 10
|
2009-11-08 23:20:00 +00:00
|
|
|
};
|
|
|
|
|
2008-08-22 16:13:52 +00:00
|
|
|
typedef enum
|
2008-06-07 21:26:41 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
TR_ADDREQ_OK = 0,
|
2008-06-07 21:26:41 +00:00
|
|
|
TR_ADDREQ_FULL,
|
|
|
|
TR_ADDREQ_DUPLICATE,
|
|
|
|
TR_ADDREQ_MISSING,
|
|
|
|
TR_ADDREQ_CLIENT_CHOKED
|
2008-08-22 17:59:31 +00:00
|
|
|
}
|
|
|
|
tr_addreq_t;
|
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,
|
2008-06-07 21:26:41 +00:00
|
|
|
TR_PEER_PEER_GOT_DATA,
|
|
|
|
TR_PEER_PEER_PROGRESS,
|
|
|
|
TR_PEER_ERROR,
|
2009-11-08 23:20:00 +00:00
|
|
|
TR_PEER_UPLOAD_ONLY
|
2008-06-07 21:26:41 +00:00
|
|
|
}
|
|
|
|
PeerEventType;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
PeerEventType eventType;
|
2008-12-02 17:10:54 +00:00
|
|
|
uint32_t pieceIndex; /* for GOT_BLOCK, CANCEL, ALLOWED, SUGGEST */
|
2008-11-17 04:00:57 +00:00
|
|
|
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 */
|
2008-12-22 00:52:44 +00:00
|
|
|
tr_bool wasPieceData; /* for GOT_DATA */
|
2008-12-02 19:46:51 +00:00
|
|
|
tr_bool uploadOnly; /* for UPLOAD_ONLY */
|
2009-10-29 16:10:03 +00:00
|
|
|
tr_port port; /* for GOT_PORT */
|
2008-06-07 21:26:41 +00:00
|
|
|
}
|
|
|
|
tr_peer_event;
|
|
|
|
|
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
|