source: trunk/libtransmission/announcer-common.h @ 14241

Last change on this file since 14241 was 14241, checked in by jordan, 7 years ago

Copyedit the license's revised text: (1) remove unnecessary repitition use of the word 'license' from the top of the header and source files (2) add the standard 'we hope it's useful, but no warranty' clause to COPYING (3) make explicit that linking OpenSSL is allowed (see https://people.gnome.org/~markmc/openssl-and-the-gpl.html for background) (4) sync the Qt and GTK+ clients' license popups with COPYING's revised text

  • Property svn:keywords set to Date Rev Author Id
File size: 6.3 KB
Line 
1/*
2 * This file Copyright (C) 2010-2014 Mnemosyne LLC
3 *
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
6 *
7 * $Id: announcer-common.h 14241 2014-01-21 03:10:30Z jordan $
8 */
9
10#ifndef __LIBTRANSMISSION_ANNOUNCER_MODULE___
11 #error only the libtransmission announcer module should #include this header.
12#endif
13
14#ifndef _TR_ANNOUNCER_COMMON_H_
15#define _TR_ANNOUNCER_COMMON_H_
16
17#include "transmission.h" /* SHA_DIGEST_LENGTH */
18#include "session.h" /* PEER_ID_LEN */
19
20/***
21****  SCRAPE
22***/
23
24enum
25{
26  /* pick a number small enough for common tracker software:
27   *  - ocelot has no upper bound
28   *  - opentracker has an upper bound of 64
29   *  - udp protocol has an upper bound of 74
30   *  - xbtt has no upper bound */
31  TR_MULTISCRAPE_MAX = 64
32};
33
34typedef struct
35{
36  /* the scrape URL */
37  char * url;
38
39  /* the name to use when deep logging is enabled */
40  char log_name[128];
41
42  /* info hashes of the torrents to scrape */
43  uint8_t info_hash[TR_MULTISCRAPE_MAX][SHA_DIGEST_LENGTH];
44
45  /* how many hashes to use in the info_hash field */
46  int info_hash_count;
47}
48tr_scrape_request;
49
50struct tr_scrape_response_row
51{
52  /* the torrent's info_hash */
53  uint8_t info_hash[SHA_DIGEST_LENGTH];
54
55  /* how many peers are seeding this torrent */
56  int seeders;
57
58  /* how many peers are downloading this torrent */
59  int leechers;
60
61  /* how many times this torrent has been downloaded */
62  int downloads;
63
64  /* the number of active downloaders in the swarm.
65   * this is a BEP 21 extension that some trackers won't support.
66   * http://www.bittorrent.org/beps/bep_0021.html#tracker-scrapes  */
67  int downloaders;
68};
69
70typedef struct
71{
72  /* whether or not we managed to connect to the tracker */
73  bool did_connect;
74
75  /* whether or not the scrape timed out */
76  bool did_timeout;
77
78  /* how many info hashes are in the 'rows' field */
79  int row_count;
80
81  /* the individual torrents' scrape results */
82  struct tr_scrape_response_row rows[TR_MULTISCRAPE_MAX];
83
84  /* the raw scrape url */
85  char * url;
86
87  /* human-readable error string on failure, or NULL */
88  char * errmsg;
89
90  /* minimum interval (in seconds) allowed between scrapes.
91   * this is an unofficial extension that some trackers won't support. */
92  int min_request_interval;
93}
94tr_scrape_response;
95
96typedef void (*tr_scrape_response_func) (const tr_scrape_response  * response,
97                                         void                      * user_data);
98
99void tr_tracker_http_scrape (tr_session               * session,
100                             const tr_scrape_request  * req,
101                             tr_scrape_response_func    response_func,
102                             void                     * user_data);
103
104void tr_tracker_udp_scrape (tr_session               * session,
105                            const tr_scrape_request  * req,
106                            tr_scrape_response_func    response_func,
107                            void                     * user_data);
108
109/***
110****  ANNOUNCE
111***/
112
113typedef enum
114{
115  TR_ANNOUNCE_EVENT_NONE,
116  TR_ANNOUNCE_EVENT_COMPLETED,
117  TR_ANNOUNCE_EVENT_STARTED,
118  TR_ANNOUNCE_EVENT_STOPPED
119}
120tr_announce_event;
121
122const char * tr_announce_event_get_string (tr_announce_event);
123
124typedef struct
125{
126  tr_announce_event event;
127  bool partial_seed;
128
129  /* the port we listen for incoming peers on */
130  int port;
131
132  /* per-session key */
133  int key;
134
135  /* the number of peers we'd like to get back in the response */
136  int numwant;
137
138  /* the number of bytes we uploaded since the last 'started' event */
139  uint64_t up;
140
141  /* the number of good bytes we downloaded since the last 'started' event */
142  uint64_t down;
143
144  /* the number of bad bytes we downloaded since the last 'started' event */
145  uint64_t corrupt;
146
147  /* the total size of the torrent minus the number of bytes completed */
148  uint64_t leftUntilComplete;
149
150  /* the tracker's announce URL */
151  char * url;
152
153  /* key generated by and returned from an http tracker.
154   * see tr_announce_response.tracker_id_str */
155  char * tracker_id_str;
156
157  /* the torrent's peer id.
158   * this changes when a torrent is stopped -> restarted. */
159  char peer_id[PEER_ID_LEN];
160
161  /* the torrent's info_hash */
162  uint8_t info_hash[SHA_DIGEST_LENGTH];
163
164  /* the name to use when deep logging is enabled */
165  char log_name[128];
166}
167tr_announce_request;
168
169struct tr_pex;
170
171typedef struct
172{
173  /* the torrent's info hash */
174  uint8_t info_hash[SHA_DIGEST_LENGTH];
175
176  /* whether or not we managed to connect to the tracker */
177  bool did_connect;
178
179  /* whether or not the scrape timed out */
180  bool did_timeout;
181
182  /* preferred interval between announces.
183   * transmission treats this as the interval for periodic announces */
184  int interval;
185
186  /* minimum interval between announces. (optional)
187   * transmission treats this as the min interval for manual announces */
188  int min_interval;
189
190  /* how many peers are seeding this torrent */
191  int seeders;
192
193  /* how many peers are downloading this torrent */
194  int leechers;
195
196  /* how many times this torrent has been downloaded */
197  int downloads;
198
199  /* number of items in the 'pex' field */
200  size_t pex_count;
201
202  /* IPv4 peers that we acquired from the tracker */
203  struct tr_pex * pex;
204
205  /* number of items in the 'pex6' field */
206  size_t pex6_count;
207
208  /* IPv6 peers that we acquired from the tracker */
209  struct tr_pex * pex6;
210
211  /* human-readable error string on failure, or NULL */
212  char * errmsg;
213
214  /* human-readable warning string or NULL */
215  char * warning;
216
217  /* key generated by and returned from an http tracker.
218   * if this is provided, subsequent http announces must include this. */
219  char * tracker_id_str;
220}
221tr_announce_response;
222
223typedef void (*tr_announce_response_func) (const tr_announce_response * response,
224                                           void                       * userdata);
225
226void tr_tracker_http_announce (tr_session                 * session,
227                               const tr_announce_request  * req,
228                               tr_announce_response_func    response_func,
229                               void                       * user_data);
230
231void tr_tracker_udp_announce (tr_session                 * session,
232                              const tr_announce_request  * req,
233                              tr_announce_response_func    response_func,
234                              void                       * user_data);
235
236void tr_tracker_udp_start_shutdown (tr_session * session);
237
238#endif /* _TR_ANNOUNCER_COMMON_H_ */
Note: See TracBrowser for help on using the repository browser.