Revert "transmission: update from 2.13 to 2.22"
[tomato.git] / release / src / router / transmission / libtransmission / peer-common.h
blobb2cf2fe9e7698486f6221b98233b28853793c470
1 /*
2 * This file Copyright (C) 2008-2010 Mnemosyne LLC
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.
10 * $Id: peer-common.h 10800 2010-06-19 14:33:10Z charles $
13 #ifndef __TRANSMISSION__
14 #error only libtransmission should #include this header.
15 #endif
17 #ifndef TR_PEER_H
18 #define TR_PEER_H
20 /**
21 * @addtogroup peers Peers
22 * @{
25 /**
26 *** Fields common to webseed and bittorrent peers
27 **/
29 #include "transmission.h"
31 enum
33 /** when we're making requests from another peer,
34 batch them together to send enough requests to
35 meet our bandwidth goals for the next N seconds */
36 REQUEST_BUF_SECS = 10,
38 /** this is the maximum size of a block request.
39 most bittorrent clients will reject requests
40 larger than this size. */
41 MAX_BLOCK_SIZE = ( 1024 * 16 )
45 typedef enum
47 TR_ADDREQ_OK = 0,
48 TR_ADDREQ_FULL,
49 TR_ADDREQ_DUPLICATE,
50 TR_ADDREQ_MISSING,
51 TR_ADDREQ_CLIENT_CHOKED
53 tr_addreq_t;
55 /**
56 *** Peer Publish / Subscribe
57 **/
59 typedef enum
61 TR_PEER_CLIENT_GOT_BLOCK,
62 TR_PEER_CLIENT_GOT_CHOKE,
63 TR_PEER_CLIENT_GOT_DATA,
64 TR_PEER_CLIENT_GOT_ALLOWED_FAST,
65 TR_PEER_CLIENT_GOT_SUGGEST,
66 TR_PEER_CLIENT_GOT_PORT,
67 TR_PEER_CLIENT_GOT_REJ,
68 TR_PEER_PEER_GOT_DATA,
69 TR_PEER_PEER_PROGRESS,
70 TR_PEER_ERROR
72 PeerEventType;
74 typedef struct
76 PeerEventType eventType;
77 uint32_t pieceIndex; /* for GOT_BLOCK, CANCEL, ALLOWED, SUGGEST */
78 uint32_t offset; /* for GOT_BLOCK */
79 uint32_t length; /* for GOT_BLOCK + GOT_DATA */
80 float progress; /* for PEER_PROGRESS */
81 int err; /* errno for GOT_ERROR */
82 tr_bool wasPieceData; /* for GOT_DATA */
83 tr_port port; /* for GOT_PORT */
85 tr_peer_event;
87 struct tr_peer;
89 typedef void tr_peer_callback( struct tr_peer * peer,
90 const tr_peer_event * event,
91 void * client_data );
93 #ifdef WIN32
94 #define EMSGSIZE WSAEMSGSIZE
95 #endif
97 /** @} */
99 #endif