source: trunk/libtransmission/peer-mgr-private.h @ 7151

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

(libT) add #ifdefs to ensure that client apps don't #include private libtransmission headers.

  • Property svn:keywords set to Date Rev Author Id
File size: 2.4 KB
Line 
1/*
2 * This file Copyright (C) 2007-2008 Charles Kerr <charles@rebelbase.com>
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-mgr-private.h 7151 2008-11-24 20:17:36Z charles $
11 */
12
13#ifndef __TRANSMISSION__
14#error only libtransmission should #include this header.
15#endif
16
17#ifndef TR_PEER_MGR_PRIVATE_H
18#define TR_PEER_MGR_PRIVATE_H
19
20#include <inttypes.h> /* uint16_t */
21
22#ifdef WIN32
23 #include <winsock2.h> /* struct in_addr */
24#else
25 #include <netinet/in.h> /* struct in_addr */
26#endif
27
28#include "publish.h" /* tr_publisher_tag */
29
30struct tr_bitfield;
31struct tr_peerIo;
32struct tr_peermsgs;
33struct tr_ratecontrol;
34
35enum
36{
37    ENCRYPTION_PREFERENCE_UNKNOWN,
38    ENCRYPTION_PREFERENCE_YES,
39    ENCRYPTION_PREFERENCE_NO
40};
41
42typedef struct tr_peer
43{
44    unsigned int             peerIsChoked       : 1;
45    unsigned int             peerIsInterested   : 1;
46    unsigned int             clientIsChoked     : 1;
47    unsigned int             clientIsInterested : 1;
48    unsigned int             doPurge            : 1;
49
50    /* number of bad pieces they've contributed to */
51    uint8_t                  strikes;
52
53    uint8_t                  encryption_preference;
54    uint16_t                 port;
55    struct in_addr           in_addr;
56    struct tr_peerIo       * io;
57
58    struct tr_bitfield     * blame;
59    struct tr_bitfield     * have;
60
61    /** how complete the peer's copy of the torrent is. [0.0...1.0] */
62    float                    progress;
63
64    /* the client name from the `v' string in LTEP's handshake dictionary */
65    char                   * client;
66
67    time_t                   peerSentPieceDataAt;
68    time_t                   chokeChangedAt;
69    time_t                   pieceDataActivityDate;
70
71    struct tr_peermsgs     * msgs;
72    tr_publisher_tag         msgsTag;
73
74    /* the rate at which pieces are being transferred between client and peer.
75     * protocol overhead is NOT included; this is only the piece data */
76    struct tr_ratecontrol  * pieceSpeed[2];
77
78    /* the rate at which all data is being transferred between client and peer. */
79    struct tr_ratecontrol  * rawSpeed[2];
80}
81tr_peer;
82
83double tr_peerGetPieceSpeed( const tr_peer    * peer,
84                             tr_direction       direction );
85
86#endif
Note: See TracBrowser for help on using the repository browser.