source: trunk/libtransmission/transmission.h @ 3197

Last change on this file since 3197 was 3197, checked in by charles, 15 years ago

some experimental code. (1) try to improve throughput to peers. (2) add first draft of new tr_stat fields requested by BentMyWookie? (3) raise the per-torrent peer limit to 100 to match LibTorrent?'s defaults

  • Property svn:keywords set to Date Rev Author Id
File size: 27.6 KB
Line 
1/******************************************************************************
2 * $Id: transmission.h 3197 2007-09-27 03:03:38Z charles $
3 *
4 * Copyright (c) 2005-2007 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#ifndef TR_TRANSMISSION_H
26#define TR_TRANSMISSION_H 1
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include "version.h"
33
34#include <inttypes.h>
35#ifndef PRId64
36# define PRId64 "lld"
37#endif
38#ifndef PRIu64
39# define PRIu64 "llu"
40#endif
41#include <time.h>
42
43#define SHA_DIGEST_LENGTH 20
44#ifdef __BEOS__
45# include <StorageDefs.h>
46# define MAX_PATH_LENGTH  B_FILE_NAME_LENGTH
47#else
48# define MAX_PATH_LENGTH  1024
49#endif
50
51#ifndef INET_ADDRSTRLEN
52#define INET_ADDRSTRLEN 16
53#endif
54
55#if defined(WIN32)
56#define TR_PATH_DELIMITER '\\'
57#define TR_PATH_DELIMITER_STR "\\"
58#else
59#define TR_PATH_DELIMITER '/'
60#define TR_PATH_DELIMITER_STR "/"
61#endif
62
63#define TR_DEFAULT_PORT   9090
64
65enum
66{
67    TR_PEER_FROM_INCOMING  = 0,  /* connections made to the listening port */
68    TR_PEER_FROM_TRACKER   = 1,  /* peers received from a tracker */
69    TR_PEER_FROM_CACHE     = 2,  /* peers read from the peer cache */
70    TR_PEER_FROM_PEX       = 3,  /* peers discovered via PEX */
71    TR_PEER_FROM__MAX
72};
73
74/***********************************************************************
75 * Error codes
76 **********************************************************************/
77/* General errors */
78#define TR_OK                       0x00000000
79#define TR_ERROR                    0x81000000
80#define TR_ERROR_ASSERT             0x82000000
81/* I/O errors */
82#define TR_ERROR_IO_MASK            0x000000FF
83#define TR_ERROR_IO_PARENT          0x80000001
84#define TR_ERROR_IO_PERMISSIONS     0x80000002
85#define TR_ERROR_IO_SPACE           0x80000004
86#define TR_ERROR_IO_FILE_TOO_BIG    0x80000008
87#define TR_ERROR_IO_OPEN_FILES      0x80000010
88#define TR_ERROR_IO_DUP_DOWNLOAD    0x80000020
89#define TR_ERROR_IO_OTHER           0x80000040
90/* Misc */
91#define TR_ERROR_TC_MASK            0x00000F00
92#define TR_ERROR_TC_ERROR           0x80000100
93#define TR_ERROR_TC_WARNING         0x80000200
94
95#define TR_ERROR_ISSET( num, code ) ( (code) == ( (code) & (num) ) )
96
97/***********************************************************************
98 * tr_init
99 ***********************************************************************
100 * Initializes a libtransmission instance. Returns a obscure handle to
101 * be passed to all functions below. The tag argument is a short string
102 * unique to the program invoking tr_init(), it is currently used as
103 * part of saved torrent files' names to prevent one frontend from
104 * deleting a torrent used by another. The following tags are used:
105 *   beos cli daemon gtk macosx
106 **********************************************************************/
107
108typedef struct tr_handle tr_handle;
109
110tr_handle * tr_init( const char * tag );
111
112typedef struct tr_tracker_info tr_tracker_info;
113
114/**
115***
116**/
117
118typedef enum
119{
120    TR_ENCRYPTION_PREFERRED,
121    TR_ENCRYPTION_REQUIRED
122}
123tr_encryption_mode;
124
125tr_encryption_mode tr_getEncryptionMode( tr_handle * handle );
126
127void tr_setEncryptionMode( tr_handle * handle, tr_encryption_mode mode );
128
129/***********************************************************************
130 * tr_setMessageLevel
131 ***********************************************************************
132 * Set the level of messages to be output or queued
133 **********************************************************************/
134#define TR_MSG_ERR 1
135#define TR_MSG_INF 2
136#define TR_MSG_DBG 3
137void tr_setMessageLevel( int );
138int tr_getMessageLevel( void );
139
140/***********************************************************************
141 * tr_setMessageQueuing
142 ***********************************************************************
143 * Enable or disable message queuing
144 **********************************************************************/
145typedef struct tr_msg_list tr_msg_list;
146void tr_setMessageQueuing( int );
147
148/***********************************************************************
149 * tr_getQueuedMessages
150 ***********************************************************************
151 * Return a list of queued messages
152 **********************************************************************/
153tr_msg_list * tr_getQueuedMessages( void );
154void tr_freeMessageList( tr_msg_list * list );
155
156/***********************************************************************
157 * tr_getPrefsDirectory
158 ***********************************************************************
159 * Returns the full path to a directory which can be used to store
160 * preferences. The string belongs to libtransmission, do not free it.
161 **********************************************************************/
162const char * tr_getPrefsDirectory( void );
163
164/***********************************************************************
165 * tr_setBindPort
166 ***********************************************************************
167 * Sets the port to listen for incoming peer connections.
168 * This can be safely called even with active torrents.
169 **********************************************************************/
170void tr_setBindPort( tr_handle *, int );
171
172int tr_getPublicPort( const tr_handle * );
173
174/***********************************************************************
175 * tr_natTraversalEnable
176 * tr_natTraversalDisable
177 ***********************************************************************
178 * Enable or disable NAT traversal using NAT-PMP or UPnP IGD.
179 **********************************************************************/
180void tr_natTraversalEnable( tr_handle *, int enable );
181
182/***********************************************************************
183 * tr_handleStatus
184 ***********************************************************************
185 * Returns some status info for the given handle.
186 **********************************************************************/
187typedef struct tr_handle_status tr_handle_status;
188tr_handle_status * tr_handleStatus( tr_handle * );
189
190
191/***********************************************************************
192 * tr_torrentCount
193 ***********************************************************************
194 * Returns the count of open torrents
195 **********************************************************************/
196int tr_torrentCount( tr_handle * h );
197
198
199/***********************************************************************
200 * tr_torrentIterate
201 ***********************************************************************
202 * Iterates on open torrents
203 **********************************************************************/
204typedef struct tr_torrent tr_torrent;
205typedef void (*tr_callback_t) ( tr_torrent *, void * );
206void tr_torrentIterate( tr_handle *, tr_callback_t, void * );
207
208
209/***********************************************************************
210*** Speed Limits
211**/
212
213enum { TR_UP, TR_DOWN };
214
215typedef enum
216{
217    TR_SPEEDLIMIT_GLOBAL,    /* only follow the overall speed limit */
218    TR_SPEEDLIMIT_SINGLE,    /* only follow the per-torrent limit */
219    TR_SPEEDLIMIT_UNLIMITED  /* no limits at all */
220}
221tr_speedlimit;
222
223void tr_torrentSetSpeedMode( tr_torrent   * tor,
224                             int            up_or_down,
225                             tr_speedlimit  mode );
226
227tr_speedlimit tr_torrentGetSpeedMode( const tr_torrent  * tor,
228                                      int                 up_or_down);
229
230void tr_torrentSetSpeedLimit( tr_torrent   * tor,
231                              int            up_or_down,
232                              int            single_KiB_sec );
233
234int tr_torrentGetSpeedLimit( const tr_torrent  * tor,
235                             int                 up_or_down );
236
237void tr_setUseGlobalSpeedLimit( tr_handle * handle,
238                                int           up_or_down,
239                                int           use_flag );
240
241void tr_setGlobalSpeedLimit( tr_handle * handle,
242                             int           up_or_down,
243                             int           global_KiB_sec );
244
245void tr_getGlobalSpeedLimit( tr_handle * handle,
246                             int           up_or_down,
247                             int         * setme_is_enabled,
248                             int         * setme_KiBsec );
249
250/***********************************************************************
251 * Torrent Priorities
252 **********************************************************************/
253
254enum
255{
256    TR_PRI_LOW    = -1,
257    TR_PRI_NORMAL =  0, /* since NORMAL is 0, memset initializes nicely */
258    TR_PRI_HIGH   =  1
259};
260
261typedef int8_t tr_priority_t;
262
263/* set a batch of files to a particular priority. */
264void tr_torrentSetFilePriorities( tr_torrent        * tor,
265                                  int               * files,
266                                  int                 fileCount,
267                                  tr_priority_t       priority );
268
269
270/* single-file form of tr_torrentPrioritizeFiles.
271 * priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
272void tr_torrentSetFilePriority( tr_torrent *, int file, tr_priority_t priority );
273
274/* returns a malloc()ed array of tor->info.fileCount items,
275 * each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
276   free the array when done. */
277tr_priority_t* tr_torrentGetFilePriorities( const tr_torrent * );
278
279/* single-file form of tr_torrentGetFilePriorities.
280 * returns one of TR_PRI_NORMAL, _HIGH, or _LOW. */
281tr_priority_t tr_torrentGetFilePriority( const tr_torrent *, int file );
282
283/* returns true if the file's `download' flag is set */
284int tr_torrentGetFileDL( const tr_torrent *, int file );
285
286/* set a batch of files to be downloaded or not. */
287void tr_torrentSetFileDLs ( tr_torrent   * tor,
288                            int            * files,
289                            int              fileCount,
290                            int              do_download );
291
292/* single-file form of tr_torrentSetFileDLs */
293void tr_torrentSetFileDL( tr_torrent *, int file, int do_download );
294
295/***********************************************************************
296 * tr_torrentRates
297 ***********************************************************************
298 * Gets the total download and upload rates
299 **********************************************************************/
300void tr_torrentRates( tr_handle *, float *, float * );
301
302/***********************************************************************
303 * tr_close
304 ***********************************************************************
305 * Frees memory allocated by tr_init.
306 **********************************************************************/
307void tr_close( tr_handle * );
308
309
310
311/**
312 *  Load all the torrents in tr_getTorrentsDirectory().
313 *  This can be used at startup to kickstart all the torrents
314 *  from the previous session.
315 */
316tr_torrent ** tr_loadTorrents ( tr_handle  * h,
317                                const char   * destination,
318                                int            flags,
319                                int          * setmeCount );
320
321
322/***********************************************************************
323 * tr_torrentInit
324 ***********************************************************************
325 * Opens and parses torrent file at 'path'. If the file exists and is
326 * a valid torrent file, returns an handle and adds it to the list of
327 * torrents (but doesn't start it). Returns NULL and sets *error
328 * otherwise. If hash is not NULL and the torrent is already loaded
329 * then it's 20-byte hash will be copied in. If the TR_FLAG_SAVE flag
330 * is passed then a copy of the torrent file will be saved.
331 **********************************************************************/
332#define TR_EINVALID     1
333#define TR_EUNSUPPORTED 2
334#define TR_EDUPLICATE   3
335#define TR_EOTHER       666
336tr_torrent * tr_torrentInit( tr_handle  * handle,
337                             const char   * metainfo_filename,
338                             const char   * destination,
339                             int            flags,
340                             int          * setme_error );
341
342typedef struct tr_info tr_info;
343
344/**
345 * Parses the specified metainfo file.
346 *
347 * Returns TR_OK if it parsed and can be added to Transmission.
348 * Returns TR_INVALID if it couldn't be parsed.
349 * Returns TR_EDUPLICATE if it parsed but can't be added.
350 *
351 * "destination" can be NULL if you don't need to know whether
352 * or not the torrent can be added.
353 *
354 " "setme_info" can be NULL if you don't need the information.
355 * If the metainfo can be parsed and setme_info is non-NULL,
356 * it will be filled with the metadata's info.  You'll need to
357 * call tr_metainfoFree( setme_info ) when done with it.
358 */
359int tr_torrentParse( const tr_handle  * handle,
360                     const char       * metainfo_filename,
361                     const char       * destination,
362                     tr_info          * setme_info );
363
364/**
365 * Parses the cached metainfo file that matches the given hash string.
366 * See tr_torrentParse() for a description of the arguments
367 */
368int
369tr_torrentParseHash( const tr_handle  * h,
370                     const char       * hashStr,
371                     const char       * destination,
372                     tr_info          * setme_info );
373
374
375/***********************************************************************
376 * tr_torrentInitData
377 ***********************************************************************
378 * Like tr_torrentInit, except the actual torrent data is passed in
379 * instead of the filename.
380 **********************************************************************/
381tr_torrent * tr_torrentInitData( tr_handle *,
382                                 const uint8_t * data, size_t size,
383                                 const char * destination,
384                                 int flags, int * error );
385
386/***********************************************************************
387 * tr_torrentInitSaved
388 ***********************************************************************
389 * Opens and parses a torrent file as with tr_torrentInit, only taking
390 * the hash string of a saved torrent file instead of a filename. There
391 * are currently no valid flags for this function.
392 **********************************************************************/
393tr_torrent * tr_torrentInitSaved( tr_handle *,
394                                  const char * hashStr,
395                                  const char * destination,
396                                  int flags, int * error );
397
398/***********************************************************************
399 * tr_torrentDisablePex
400 ***********************************************************************
401 * Disable or enable peer exchange for this torrent. Peer exchange is
402 * enabled by default, except for private torrents where pex is
403 * disabled and cannot be enabled.
404 **********************************************************************/
405void tr_torrentDisablePex( tr_torrent *, int disable );
406
407const tr_info * tr_torrentInfo( const tr_torrent * );
408
409#if 0
410/***********************************************************************
411 * tr_torrentScrape
412 ***********************************************************************
413 * Asks the tracker for the count of seeders and leechers. Returns 0
414 * and fills 's' and 'l' if successful. Otherwise returns 1 if the
415 * tracker doesn't support the scrape protocol, is unreachable or
416 * replied with some error. tr_torrentScrape may block up to 20 seconds
417 * before returning.
418 **********************************************************************/
419int tr_torrentScrape( tr_torrent *, int * s, int * l, int * d );
420#endif
421
422void   tr_torrentSetFolder( tr_torrent *, const char * );
423const char * tr_torrentGetFolder( const tr_torrent * );
424
425/***********************************************************************
426 * tr_torrentStart
427 ***********************************************************************
428 * Starts downloading. The download is launched in a seperate thread,
429 * therefore tr_torrentStart returns immediately.
430 **********************************************************************/
431void   tr_torrentStart( tr_torrent * );
432
433/***********************************************************************
434 * tr_torrentStop
435 ***********************************************************************
436 * Stops downloading and notices the tracker that we are leaving. The
437 * thread keeps running while doing so.
438 * The thread will eventually be joined, either:
439 * - by tr_torrentStat when the tracker has been successfully noticed,
440 * - by tr_torrentStat if the tracker could not be noticed within 60s,
441 * - by tr_torrentClose if you choose to remove the torrent without
442 *   waiting any further.
443 **********************************************************************/
444void tr_torrentStop( tr_torrent * );
445
446/***********************************************************************
447 * tr_getComplete, tr_getIncomplete and tr_getPartial
448 ***********************************************************************
449 * The first call after a torrent changed state returns 1. Returns 0
450 * in other cases.
451 **********************************************************************/
452int tr_getIncomplete( tr_torrent * tor );
453int tr_getDone( tr_torrent * tor );
454int tr_getComplete( tr_torrent * tor );
455
456
457/**
458 * MANUAL ANNOUNCE
459 *
460 * Trackers usually set an announce interval of 15 or 30 minutes.
461 * Users can send one-time announce requests that override this
462 * interval by calling tr_manualUpdate().
463 *
464 * The wait interval for tr_manualUpdate() is much smaller.
465 * You can test whether or not a manual update is possible
466 * (for example, to desensitize the button) by calling
467 * tr_torrentCanManualUpdate().
468 */
469
470void tr_manualUpdate( tr_torrent * );
471
472int tr_torrentCanManualUpdate( const tr_torrent * );
473
474/***********************************************************************
475 * tr_torrentStat
476 ***********************************************************************
477 * Returns a pointer to an tr_stat structure with updated information
478 * on the torrent. The structure belongs to libtransmission (do not
479 * free it) and is guaranteed to be unchanged until the next call to
480 * tr_torrentStat.
481 * The interface should call this function every second or so in order
482 * to update itself.
483 **********************************************************************/
484typedef struct tr_stat tr_stat;
485const tr_stat * tr_torrentStat( tr_torrent * );
486
487/***********************************************************************
488 * tr_torrentPeers
489 ***********************************************************************/
490typedef struct tr_peer_stat tr_peer_stat;
491tr_peer_stat * tr_torrentPeers( const tr_torrent *, int * peerCount );
492void tr_torrentPeersFree( tr_peer_stat *, int peerCount );
493
494typedef struct tr_file_stat tr_file_stat;
495tr_file_stat * tr_torrentFiles( const tr_torrent *, int * fileCount );
496void tr_torrentFilesFree( tr_file_stat *, int fileCount );
497
498
499/***********************************************************************
500 * tr_torrentAvailability
501 ***********************************************************************
502 * Use this to draw an advanced progress bar which is 'size' pixels
503 * wide. Fills 'tab' which you must have allocated: each byte is set
504 * to either -1 if we have the piece, otherwise it is set to the number
505 * of connected peers who have the piece.
506 **********************************************************************/
507void tr_torrentAvailability( const tr_torrent *, int8_t * tab, int size );
508
509void tr_torrentAmountFinished( const tr_torrent * tor, float * tab, int size );
510
511/***********************************************************************
512 * tr_torrentRemoveSaved
513 ***********************************************************************
514 * Removes the saved copy of a torrent file for torrents which the
515 * TR_FLAG_SAVE flag is set.
516 **********************************************************************/
517void tr_torrentRemoveSaved( tr_torrent * );
518
519void tr_torrentRecheck( tr_torrent * );
520
521/***********************************************************************
522 * tr_torrentClose
523 ***********************************************************************
524 * Frees memory allocated by tr_torrentInit. If the torrent was running,
525 * it is stopped first.
526 **********************************************************************/
527void tr_torrentClose( tr_torrent * );
528
529/***********************************************************************
530 * tr_info
531 **********************************************************************/
532
533typedef struct tr_file
534{
535    uint64_t length;                /* Length of the file, in bytes */
536    char     name[MAX_PATH_LENGTH]; /* Path to the file */
537    int8_t   priority;              /* TR_PRI_HIGH, _NORMAL, or _LOW */
538    int8_t   dnd;                   /* nonzero if the file shouldn't be downloaded */
539    int      firstPiece;            /* We need pieces [firstPiece... */
540    int      lastPiece;             /* ...lastPiece] to dl this file */
541    uint64_t offset;                /* file begins at the torrent's nth byte */
542}
543tr_file;
544
545typedef struct tr_piece
546{
547    uint8_t  hash[SHA_DIGEST_LENGTH];  /* pieces hash */
548    int8_t   priority;                 /* TR_PRI_HIGH, _NORMAL, or _LOW */
549    int8_t   dnd;                      /* nonzero if the piece shouldn't be downloaded */
550}
551tr_piece;
552   
553struct tr_info
554{
555    /* Path to torrent */
556    char                 torrent[MAX_PATH_LENGTH];
557
558    /* General info */
559    uint8_t              hash[SHA_DIGEST_LENGTH];
560    char                 hashString[2*SHA_DIGEST_LENGTH+1];
561    char                 name[MAX_PATH_LENGTH];
562
563    /* Flags */
564#define TR_FLAG_SAVE    0x01 /* save a copy of the torrent file */
565#define TR_FLAG_PRIVATE 0x02 /* do not share information for this torrent */
566#define TR_FLAG_PAUSED  0x04 /* don't start the torrent when adding it */
567    int                  flags;
568
569    /* Tracker info */
570    struct
571    {
572        tr_tracker_info  * list;
573        int                 count;
574    }                  * trackerList;
575    int                  trackerTiers;
576    char               * primaryAddress;
577
578    /* Torrent info */
579    char                 comment[MAX_PATH_LENGTH];
580    char                 creator[MAX_PATH_LENGTH];
581    int                  dateCreated;
582
583    /* Pieces info */
584    int                  pieceSize;
585    int                  pieceCount;
586    uint64_t             totalSize;
587    tr_piece           * pieces;
588
589    /* Files info */
590    int                  multifile;
591    int                  fileCount;
592    tr_file            * files;
593};
594
595typedef enum
596{
597    TR_STATUS_CHECK_WAIT   = (1<<0), /* Waiting in queue to check files */
598    TR_STATUS_CHECK        = (1<<1), /* Checking files */
599    TR_STATUS_DOWNLOAD     = (1<<2), /* Downloading */
600    TR_STATUS_DONE         = (1<<3), /* not at 100% so can't tell the tracker
601                                        we're a seeder, but due to DND files
602                                        there's nothing we want right now */
603    TR_STATUS_SEED         = (1<<4), /* Seeding */
604    TR_STATUS_STOPPING     = (1<<5), /* Stopping -- closing connections, etc. */
605    TR_STATUS_STOPPED      = (1<<6)  /* Torrent is stopped */
606}
607torrent_status_t;
608
609#define TR_STATUS_ACTIVE \
610    (TR_STATUS_CHECK_WAIT|TR_STATUS_CHECK|TR_STATUS_DOWNLOAD|TR_STATUS_DONE|TR_STATUS_SEED)
611#define TR_STATUS_INACTIVE \
612    (TR_STATUS_STOPPING|TR_STATUS_STOPPED)
613
614typedef enum
615{
616    TR_CP_INCOMPLETE,   /* doesn't have all the desired pieces */
617    TR_CP_DONE,         /* has all the pieces but the DND ones */
618    TR_CP_COMPLETE      /* has every piece */
619}
620cp_status_t;
621
622/***********************************************************************
623 * tr_stat
624 **********************************************************************/
625struct tr_stat
626{
627    torrent_status_t    status;
628    cp_status_t         cpStatus;
629
630    int                 error;
631    char                errorString[128];
632
633    const tr_tracker_info * tracker;
634
635    float               recheckProgress;
636    float               percentComplete;
637    float               percentDone;
638    float               rateDownload;
639    float               rateUpload;
640    int                 eta;
641    int                 peersTotal;
642    int                 peersConnected;
643    int                 peersFrom[TR_PEER_FROM__MAX];
644    int                 peersSendingToUs;
645    int                 peersGettingFromUs;
646    int                 seeders;
647    int                 leechers;
648    int                 completedFromTracker;
649
650    /* Byte count of how much data is left to be downloaded until
651     * we're done -- that is, until we've got all the pieces we wanted. */
652    uint64_t            leftUntilDone;
653
654    /* Byte count of all the corrupt data you've ever downloaded for
655     * this torrent.  If you're on a poisoned torrent, this number can
656     * grow very large. */
657    uint64_t            corruptEver;
658
659    /* Byte count of all data you've ever uploaded for this torrent. */
660    uint64_t            uploadedEver;
661
662    /* Byte count of all the non-corrupt data you've ever downloaded
663     * for this torrent.  If you deleted the files and downloaded a second time,
664     * this will be 2*totalSize.. */
665    uint64_t            downloadedEver;
666
667    /* Byte count of all the checksum-verified data we have for this torrent. */
668    uint64_t            haveValid;
669
670    /* Byte count of all the partial piece data we have for this torrent.
671     * As pieces become complete, this value may decrease as portions of it are
672     * moved to `corrupt' or `haveValid'. */
673    uint64_t            haveUnchecked;
674
675    /* Byte count of all the non-DND piece data that either we already have,
676     * or that a peer we're connected to has. [0...tr_info.totalSize] */
677    uint64_t            nonDndAvailable;
678
679    /* Byte count of all the non-DND piece data */
680    uint64_t            nonDndSize;
681
682    float               swarmspeed;
683
684#define TR_RATIO_NA  -1
685    float               ratio;
686   
687    uint64_t            startDate;
688    uint64_t            activityDate;
689};
690
691struct tr_file_stat
692{
693    uint64_t bytesCompleted;
694    float progress;
695    cp_status_t completionStatus;
696};
697
698struct tr_peer_stat
699{
700    char    addr[INET_ADDRSTRLEN];
701    const char * client;
702   
703    unsigned int isConnected   : 1;
704    unsigned int isEncrypted   : 1;
705    unsigned int isDownloading : 1;
706    unsigned int isUploading   : 1;
707
708    uint8_t  from;
709    uint16_t port;
710   
711    float progress;
712    float downloadFromRate;
713    float uploadToRate;
714};
715
716struct tr_msg_list
717{
718    uint8_t              level;
719    time_t               when;
720    char               * message;
721    struct tr_msg_list * next;
722};
723
724struct tr_tracker_info
725{
726    char * address;
727    int    port;
728    char * announce;
729    char * scrape;
730};
731
732struct tr_handle_status
733{
734#define TR_NAT_TRAVERSAL_MAPPING        1
735#define TR_NAT_TRAVERSAL_MAPPED         2
736#define TR_NAT_TRAVERSAL_NOTFOUND       3
737#define TR_NAT_TRAVERSAL_ERROR          4
738#define TR_NAT_TRAVERSAL_UNMAPPING      5
739#define TR_NAT_TRAVERSAL_DISABLED       6
740#define TR_NAT_TRAVERSAL_IS_DISABLED( st ) \
741  ( TR_NAT_TRAVERSAL_DISABLED == (st) || TR_NAT_TRAVERSAL_UNMAPPING == (st) )
742    int natTraversalStatus;
743    int publicPort;
744};
745
746#ifdef __TRANSMISSION__
747#  include "internal.h"
748#endif
749
750#ifdef __cplusplus
751}
752#endif
753
754#endif
Note: See TracBrowser for help on using the repository browser.