3 Copyright (c) 2003, Arvid Norberg
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
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.
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.
33 #ifndef TORRENT_PEER_INFO_HPP_INCLUDED
34 #define TORRENT_PEER_INFO_HPP_INCLUDED
36 #include "libtorrent/socket.hpp"
37 #include "libtorrent/peer_id.hpp"
38 #include "libtorrent/size_type.hpp"
39 #include "libtorrent/config.hpp"
40 #include "libtorrent/bitfield.hpp"
44 struct TORRENT_EXPORT peer_info
50 remote_interested
= 0x4,
52 supports_extensions
= 0x10,
53 local_connection
= 0x20,
59 optimistic_unchoke
= 0x800,
62 #ifndef TORRENT_DISABLE_ENCRYPTION
63 , rc4_encrypted
= 0x100000,
64 plaintext_encrypted
= 0x200000
70 enum peer_source_flags
82 // bw_idle: the channel is not used
83 // bw_torrent: the channel is waiting for torrent quota
84 // bw_global: the channel is waiting for global quota
85 // bw_network: the channel is waiting for an async write
86 // for read operation to complete
87 enum bw_state
{ bw_idle
, bw_torrent
, bw_global
, bw_network
};
95 float payload_up_speed
;
96 float payload_down_speed
;
97 size_type total_download
;
98 size_type total_upload
;
104 // time since last request
105 time_duration last_request
;
107 // time since last download or upload
108 time_duration last_active
;
110 // the number of seconds until the current
111 // pending request times out
114 // the size of the send buffer for this peer, in bytes
115 int send_buffer_size
;
116 // the number bytes that's actually used of the send buffer
117 int used_send_buffer
;
119 int receive_buffer_size
;
120 int used_receive_buffer
;
122 // the number of failed hashes for this peer
125 #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
126 // in case the session settings is set
127 // to resolve countries, this is set to
128 // the two character country code this
133 #ifndef TORRENT_DISABLE_GEO_IP
134 // atonomous system this peer belongs to
135 std::string inet_as_name
;
139 size_type load_balancing
;
141 // this is the number of requests
142 // we have sent to this peer
143 // that we haven't got a response
145 int download_queue_length
;
147 // the number of request messages
148 // waiting to be sent inside the send buffer
149 int requests_in_buffer
;
151 // the number of requests that is
152 // tried to be maintained (this is
153 // typically a function of download speed)
154 int target_dl_queue_length
;
156 // this is the number of requests
157 // the peer has sent to us
158 // that we haven't sent yet
159 int upload_queue_length
;
161 // the number of times this IP
162 // has failed to connect
165 // the currently downloading piece
166 // if piece index is -1 all associated
167 // members are just set to 0
168 int downloading_piece_index
;
169 int downloading_block_index
;
170 int downloading_progress
;
171 int downloading_total
;
177 standard_bittorrent
= 0,
182 // approximate peer download rate
185 // number of bytes this peer has in
186 // the disk write queue
187 int pending_disk_bytes
;
189 // numbers used for bandwidth limiting
193 // estimated rtt to peer, in milliseconds
196 // the highest transfer rates seen for this peer
197 int download_rate_peak
;
198 int upload_rate_peak
;
201 struct TORRENT_EXPORT peer_list_entry
210 boost::uint8_t failcount
;
211 boost::uint8_t source
;
215 #endif // TORRENT_PEER_INFO_HPP_INCLUDED