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

Last change on this file since 12002 was 12002, checked in by jordan, 11 years ago

(trunk libT) remove dead code in peer-common.h: the tr_addreq_t enum

  • Property svn:keywords set to Date Rev Author Id
File size: 2.4 KB
Line 
1/*
2 * This file Copyright (C) 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 12002 2011-02-21 01:15:13Z jordan $
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
31struct tr_bitfield;
32
33enum
34{
35    /** when we're making requests from another peer,
36        batch them together to send enough requests to
37        meet our bandwidth goals for the next N seconds */
38    REQUEST_BUF_SECS = 10,
39
40    /** this is the maximum size of a block request.
41        most bittorrent clients will reject requests
42        larger than this size. */
43    MAX_BLOCK_SIZE = ( 1024 * 16 )
44};
45
46/**
47***  Peer Publish / Subscribe
48**/
49
50typedef enum
51{
52    TR_PEER_CLIENT_GOT_BLOCK,
53    TR_PEER_CLIENT_GOT_CHOKE,
54    TR_PEER_CLIENT_GOT_DATA,
55    TR_PEER_CLIENT_GOT_ALLOWED_FAST,
56    TR_PEER_CLIENT_GOT_SUGGEST,
57    TR_PEER_CLIENT_GOT_PORT,
58    TR_PEER_CLIENT_GOT_REJ,
59    TR_PEER_CLIENT_GOT_BITFIELD,
60    TR_PEER_CLIENT_GOT_HAVE,
61    TR_PEER_CLIENT_GOT_HAVE_ALL,
62    TR_PEER_CLIENT_GOT_HAVE_NONE,
63    TR_PEER_PEER_GOT_DATA,
64    TR_PEER_PEER_PROGRESS,
65    TR_PEER_ERROR
66}
67PeerEventType;
68
69typedef struct
70{
71    PeerEventType         eventType;
72
73    uint32_t              pieceIndex;   /* for GOT_BLOCK, GOT_HAVE, CANCEL, ALLOWED, SUGGEST */
74    struct tr_bitfield  * bitfield;     /* for GOT_BITFIELD */
75    uint32_t              offset;       /* for GOT_BLOCK */
76    uint32_t              length;       /* for GOT_BLOCK + GOT_DATA */
77    float                 progress;     /* for PEER_PROGRESS */
78    int                   err;          /* errno for GOT_ERROR */
79    tr_bool               wasPieceData; /* for GOT_DATA */
80    tr_port               port;         /* for GOT_PORT */
81}
82tr_peer_event;
83
84extern const tr_peer_event TR_PEER_EVENT_INIT;
85
86struct tr_peer;
87
88typedef void tr_peer_callback( struct tr_peer       * peer,
89                               const tr_peer_event  * event,
90                               void                 * client_data );
91
92#ifdef WIN32
93 #define EMSGSIZE WSAEMSGSIZE
94#endif
95
96/** @} */
97
98#endif
Note: See TracBrowser for help on using the repository browser.