~ubuntu-branches/ubuntu/intrepid/miro/intrepid

« back to all changes in this revision

Viewing changes to portable/libtorrent/include/libtorrent/peer_info.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-02-09 13:37:10 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080209133710-9rs90q6gckvp1b6i
Tags: 1.1.2-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
Copyright (c) 2003, Arvid Norberg
 
4
All rights reserved.
 
5
 
 
6
Redistribution and use in source and binary forms, with or without
 
7
modification, are permitted provided that the following conditions
 
8
are met:
 
9
 
 
10
    * Redistributions of source code must retain the above copyright
 
11
      notice, this list of conditions and the following disclaimer.
 
12
    * Redistributions in binary form must reproduce the above copyright
 
13
      notice, this list of conditions and the following disclaimer in
 
14
      the documentation and/or other materials provided with the distribution.
 
15
    * Neither the name of the author nor the names of its
 
16
      contributors may be used to endorse or promote products derived
 
17
      from this software without specific prior written permission.
 
18
 
 
19
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
20
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
21
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
22
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
23
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
24
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
25
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
26
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
27
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
28
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
29
POSSIBILITY OF SUCH DAMAGE.
 
30
 
 
31
*/
 
32
 
 
33
#ifndef TORRENT_PEER_INFO_HPP_INCLUDED
 
34
#define TORRENT_PEER_INFO_HPP_INCLUDED
 
35
 
 
36
#include <vector>
 
37
 
 
38
#include "libtorrent/socket.hpp"
 
39
#include "libtorrent/peer_id.hpp"
 
40
#include "libtorrent/size_type.hpp"
 
41
#include "libtorrent/config.hpp"
 
42
 
 
43
namespace libtorrent
 
44
{
 
45
        struct TORRENT_EXPORT peer_info
 
46
        {
 
47
                enum
 
48
                {
 
49
                        interesting = 0x1,
 
50
                        choked = 0x2,
 
51
                        remote_interested = 0x4,
 
52
                        remote_choked = 0x8,
 
53
                        supports_extensions = 0x10,
 
54
                        local_connection = 0x20,
 
55
                        handshake = 0x40,
 
56
                        connecting = 0x80,
 
57
                        queued = 0x100,
 
58
                        on_parole = 0x200,
 
59
                        seed = 0x400,
 
60
                        optimistic_unchoke = 0x800
 
61
#ifndef TORRENT_DISABLE_ENCRYPTION
 
62
                        , rc4_encrypted = 0x100000,
 
63
                        plaintext_encrypted = 0x200000
 
64
#endif
 
65
                };
 
66
 
 
67
                unsigned int flags;
 
68
 
 
69
                enum peer_source_flags
 
70
                {
 
71
                        tracker = 0x1,
 
72
                        dht = 0x2,
 
73
                        pex = 0x4,
 
74
                        lsd = 0x8,
 
75
                        resume_data = 0x10,
 
76
                        incoming = 0x20
 
77
                };
 
78
 
 
79
                int source;
 
80
 
 
81
                tcp::endpoint ip;
 
82
                float up_speed;
 
83
                float down_speed;
 
84
                float payload_up_speed;
 
85
                float payload_down_speed;
 
86
                size_type total_download;
 
87
                size_type total_upload;
 
88
                peer_id pid;
 
89
                std::vector<bool> pieces;
 
90
                int upload_limit;
 
91
                int download_limit;
 
92
 
 
93
                // time since last request
 
94
                time_duration last_request;
 
95
 
 
96
                // time since last download or upload
 
97
                time_duration last_active;
 
98
 
 
99
                // the size of the send buffer for this peer
 
100
                int send_buffer_size;
 
101
 
 
102
                // the number of failed hashes for this peer
 
103
                int num_hashfails;
 
104
 
 
105
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
 
106
                // in case the session settings is set
 
107
                // to resolve countries, this is set to
 
108
                // the two character country code this
 
109
                // peer resides in.
 
110
                char country[2];
 
111
#endif
 
112
 
 
113
                size_type load_balancing;
 
114
 
 
115
                // this is the number of requests
 
116
                // we have sent to this peer
 
117
                // that we haven't got a response
 
118
                // for yet
 
119
                int download_queue_length;
 
120
 
 
121
                // the number of requests that is
 
122
                // tried to be maintained (this is
 
123
                // typically a function of download speed)
 
124
                int target_dl_queue_length;
 
125
 
 
126
                // this is the number of requests
 
127
                // the peer has sent to us
 
128
                // that we haven't sent yet
 
129
                int upload_queue_length;
 
130
 
 
131
                // the number of times this IP
 
132
                // has failed to connect
 
133
                int failcount;
 
134
 
 
135
                // the currently downloading piece
 
136
                // if piece index is -1 all associated
 
137
                // members are just set to 0
 
138
                int downloading_piece_index;
 
139
                int downloading_block_index;
 
140
                int downloading_progress;
 
141
                int downloading_total;
 
142
                
 
143
                std::string client;
 
144
                
 
145
                enum
 
146
                {
 
147
                        standard_bittorrent = 0,
 
148
                        web_seed = 1
 
149
                };
 
150
                int connection_type;
 
151
                
 
152
                // approximate peer download rate
 
153
                int remote_dl_rate;
 
154
 
 
155
                // number of bytes this peer has in
 
156
                // the disk write queue
 
157
                int pending_disk_bytes;
 
158
        };
 
159
 
 
160
}
 
161
 
 
162
#endif // TORRENT_PEER_INFO_HPP_INCLUDED