source: trunk/libtransmission/peer-common.h @ 10694

Last change on this file since 10694 was 10694, checked in by charles, 12 years ago

(trunk libT) define MAX_BLOCK_SIZE once instead of in a handful of places

  • Property svn:keywords set to Date Rev Author Id
File size: 2.0 KB
Line 
1/*
2 * This file Copyright (C) 2008-2010 Mnemosyne LLC
3 *
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.
9 *
10 * $Id: peer-common.h 10694 2010-05-26 15:23:21Z charles $
11 */
12
13#ifndef __TRANSMISSION__
14 #error only libtransmission should #include this header.
15#endif
16
17#ifndef TR_PEER_H
18#define TR_PEER_H
19
20/**
21 * @addtogroup peers Peers
22 * @{
23 */
24
25/**
26*** Fields common to webseed and bittorrent peers
27**/
28
29#include "transmission.h"
30
31enum
32{
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,
37
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 )
42   
43};
44
45typedef enum
46{
47    TR_ADDREQ_OK = 0,
48    TR_ADDREQ_FULL,
49    TR_ADDREQ_DUPLICATE,
50    TR_ADDREQ_MISSING,
51    TR_ADDREQ_CLIENT_CHOKED
52}
53tr_addreq_t;
54
55/**
56***  Peer Publish / Subscribe
57**/
58
59typedef enum
60{
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
71}
72PeerEventType;
73
74typedef struct
75{
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 */
84}
85tr_peer_event;
86
87#ifdef WIN32
88 #define EMSGSIZE WSAEMSGSIZE
89#endif
90
91/** @} */
92
93#endif
Note: See TracBrowser for help on using the repository browser.