source: trunk/libtransmission/transmission.h @ 3864

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

reintroduce the "SWIFT" algorithm

  • Property svn:keywords set to Date Rev Author Id
File size: 27.2 KB
Line 
1/******************************************************************************
2 * $Id: transmission.h 3864 2007-11-18 01:00:49Z 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_PERMISSIONS     0x80000002
84#define TR_ERROR_IO_SPACE           0x80000004
85#define TR_ERROR_IO_FILE_TOO_BIG    0x80000008
86#define TR_ERROR_IO_OPEN_FILES      0x80000010
87#define TR_ERROR_IO_DUP_DOWNLOAD    0x80000020
88#define TR_ERROR_IO_OTHER           0x80000040
89/* Misc */
90#define TR_ERROR_TC_MASK            0x00000F00
91#define TR_ERROR_TC_ERROR           0x80000100
92#define TR_ERROR_TC_WARNING         0x80000200
93
94#define TR_ERROR_ISSET( num, code ) ( (code) == ( (code) & (num) ) )
95
96/***********************************************************************
97 * tr_init
98 ***********************************************************************
99 * Initializes a libtransmission instance. Returns a obscure handle to
100 * be passed to all functions below. The tag argument is a short string
101 * unique to the program invoking tr_init(), it is currently used as
102 * part of saved torrent files' names to prevent one frontend from
103 * deleting a torrent used by another. The following tags are used:
104 *   beos cli daemon gtk macosx
105 **********************************************************************/
106
107typedef struct tr_handle tr_handle;
108
109tr_handle * tr_init( const char * tag );
110
111typedef struct tr_tracker_info tr_tracker_info;
112
113/**
114***
115**/
116
117typedef enum
118{
119    TR_PLAINTEXT_PREFERRED,
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.
264 * priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
265void tr_torrentSetFilePriorities( tr_torrent        * tor,
266                                  int               * files,
267                                  int                 fileCount,
268                                  tr_priority_t       priority );
269
270/* returns a malloc()ed array of tor->info.fileCount items,
271 * each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
272   free the array when done. */
273tr_priority_t* tr_torrentGetFilePriorities( const tr_torrent * );
274
275/* single-file form of tr_torrentGetFilePriorities.
276 * returns one of TR_PRI_NORMAL, _HIGH, or _LOW. */
277tr_priority_t tr_torrentGetFilePriority( const tr_torrent *, int file );
278
279/* returns true if the file's `download' flag is set */
280int tr_torrentGetFileDL( const tr_torrent *, int file );
281
282/* set a batch of files to be downloaded or not. */
283void tr_torrentSetFileDLs ( tr_torrent   * tor,
284                            int          * files,
285                            int            fileCount,
286                            int            do_download );
287
288/***********************************************************************
289 * tr_torrentRates
290 ***********************************************************************
291 * Gets the total download and upload rates
292 **********************************************************************/
293void tr_torrentRates( tr_handle *, float *, float * );
294
295/***********************************************************************
296 * tr_close
297 ***********************************************************************
298 * Frees memory allocated by tr_init.
299 **********************************************************************/
300void tr_close( tr_handle * );
301
302
303
304/**
305 *  Load all the torrents in tr_getTorrentsDirectory().
306 *  This can be used at startup to kickstart all the torrents
307 *  from the previous session.
308 */
309tr_torrent ** tr_loadTorrents ( tr_handle  * h,
310                                const char   * fallback_destination,
311                                int            isPaused,
312                                int          * setmeCount );
313
314
315/***********************************************************************
316 * tr_torrentInit
317 ***********************************************************************
318 * Opens and parses torrent file at 'path'. If the file exists and is
319 * a valid torrent file, returns an handle and adds it to the list of
320 * torrents (but doesn't start it). Returns NULL and sets *error
321 * otherwise. If hash is not NULL and the torrent is already loaded
322 * then it's 20-byte hash will be copied in. If the TR_FLAG_SAVE flag
323 * is passed then a copy of the torrent file will be saved.
324 **********************************************************************/
325#define TR_EINVALID     1
326#define TR_EUNSUPPORTED 2
327#define TR_EDUPLICATE   3
328#define TR_EOTHER       666
329tr_torrent * tr_torrentInit( tr_handle    * handle,
330                             const char   * metainfo_filename,
331                             const char   * destination,
332                             int            isPaused,
333                             int          * setme_error );
334
335/* This is a stupid hack to fix #415.  Probably I should fold all
336 * these torrent constructors into a single function that takes
337 * a function object to hold all these esoteric arguments. */
338tr_torrent * tr_torrentLoad( tr_handle    * handle,
339                             const char   * metainfo_filename,
340                             const char   * fallback_destination,
341                             int            isPaused,
342                             int          * setme_error );
343
344typedef struct tr_info tr_info;
345
346/**
347 * Parses the specified metainfo file.
348 *
349 * Returns TR_OK if it parsed and can be added to Transmission.
350 * Returns TR_INVALID if it couldn't be parsed.
351 * Returns TR_EDUPLICATE if it parsed but can't be added.
352 *
353 * "destination" can be NULL if you don't need to know whether
354 * or not the torrent can be added.
355 *
356 " "setme_info" can be NULL if you don't need the information.
357 * If the metainfo can be parsed and setme_info is non-NULL,
358 * it will be filled with the metadata's info.  You'll need to
359 * call tr_metainfoFree( setme_info ) when done with it.
360 */
361int tr_torrentParse( const tr_handle  * handle,
362                     const char       * metainfo_filename,
363                     const char       * destination,
364                     tr_info          * setme_info );
365
366/**
367 * Parses the cached metainfo file that matches the given hash string.
368 * See tr_torrentParse() for a description of the arguments
369 */
370int
371tr_torrentParseHash( const tr_handle  * h,
372                     const char       * hashStr,
373                     const char       * destination,
374                     tr_info          * setme_info );
375
376
377/***********************************************************************
378 * tr_torrentInitData
379 ***********************************************************************
380 * Like tr_torrentInit, except the actual torrent data is passed in
381 * instead of the filename.
382 **********************************************************************/
383tr_torrent * tr_torrentInitData( tr_handle *,
384                                 const uint8_t * data, size_t size,
385                                 const char * destination,
386                                 int isPaused,
387                                 int * error );
388
389/***********************************************************************
390 * tr_torrentInitSaved
391 ***********************************************************************
392 * Opens and parses a torrent file as with tr_torrentInit, only taking
393 * the hash string of a saved torrent file instead of a filename. There
394 * are currently no valid flags for this function.
395 **********************************************************************/
396tr_torrent * tr_torrentInitSaved( tr_handle *,
397                                  const char * hashStr,
398                                  const char * destination,
399                                  int isPaused,
400                                  int * error );
401
402/***********************************************************************
403 * tr_torrentDisablePex
404 ***********************************************************************
405 * Disable or enable peer exchange for this torrent. Peer exchange is
406 * enabled by default, except for private torrents where pex is
407 * disabled and cannot be enabled.
408 **********************************************************************/
409void tr_torrentDisablePex( tr_torrent *, int disable );
410int tr_torrentIsPexEnabled( const tr_torrent * );
411
412const tr_info * tr_torrentInfo( const tr_torrent * );
413
414void   tr_torrentSetFolder( tr_torrent *, const char * );
415const char * tr_torrentGetFolder( const tr_torrent * );
416
417/***********************************************************************
418 * tr_torrentStart
419 ***********************************************************************
420 * Starts downloading. The download is launched in a seperate thread,
421 * therefore tr_torrentStart returns immediately.
422 **********************************************************************/
423void   tr_torrentStart( tr_torrent * );
424
425/***********************************************************************
426 * tr_torrentStop
427 ***********************************************************************
428 * Stops downloading and notices the tracker that we are leaving. The
429 * thread keeps running while doing so.
430 * The thread will eventually be joined, either:
431 * - by tr_torrentStat when the tracker has been successfully noticed,
432 * - by tr_torrentStat if the tracker could not be noticed within 60s,
433 * - by tr_torrentClose if you choose to remove the torrent without
434 *   waiting any further.
435 **********************************************************************/
436void tr_torrentStop( tr_torrent * );
437
438
439/**
440***  Register to be notified whenever a torrent's state changes.
441**/
442
443typedef enum
444{
445    TR_CP_INCOMPLETE,   /* doesn't have all the desired pieces */
446    TR_CP_DONE,         /* has all the pieces but the DND ones */
447    TR_CP_COMPLETE      /* has every piece */
448}
449cp_status_t;
450
451typedef void (tr_torrent_status_func)(tr_torrent   * torrent,
452                                      cp_status_t    status,
453                                      void         * user_data );
454
455void tr_torrentSetStatusCallback( tr_torrent             * torrent,
456                                  tr_torrent_status_func   func,
457                                  void                   * user_data );
458
459void tr_torrentClearStatusCallback( tr_torrent * torrent );
460
461/**
462 * MANUAL ANNOUNCE
463 *
464 * Trackers usually set an announce interval of 15 or 30 minutes.
465 * Users can send one-time announce requests that override this
466 * interval by calling tr_manualUpdate().
467 *
468 * The wait interval for tr_manualUpdate() is much smaller.
469 * You can test whether or not a manual update is possible
470 * (for example, to desensitize the button) by calling
471 * tr_torrentCanManualUpdate().
472 */
473
474void tr_manualUpdate( tr_torrent * );
475
476int tr_torrentCanManualUpdate( const tr_torrent * );
477
478/***********************************************************************
479 * tr_torrentStat
480 ***********************************************************************
481 * Returns a pointer to an tr_stat structure with updated information
482 * on the torrent. The structure belongs to libtransmission (do not
483 * free it) and is guaranteed to be unchanged until the next call to
484 * tr_torrentStat.
485 * The interface should call this function every second or so in order
486 * to update itself.
487 **********************************************************************/
488typedef struct tr_stat tr_stat;
489const tr_stat * tr_torrentStat( tr_torrent * );
490
491/***********************************************************************
492 * tr_torrentPeers
493 ***********************************************************************/
494typedef struct tr_peer_stat tr_peer_stat;
495tr_peer_stat * tr_torrentPeers( const tr_torrent *, int * peerCount );
496void tr_torrentPeersFree( tr_peer_stat *, int peerCount );
497
498typedef struct tr_file_stat tr_file_stat;
499tr_file_stat * tr_torrentFiles( const tr_torrent *, int * fileCount );
500void tr_torrentFilesFree( tr_file_stat *, int fileCount );
501
502
503/***********************************************************************
504 * tr_torrentAvailability
505 ***********************************************************************
506 * Use this to draw an advanced progress bar which is 'size' pixels
507 * wide. Fills 'tab' which you must have allocated: each byte is set
508 * to either -1 if we have the piece, otherwise it is set to the number
509 * of connected peers who have the piece.
510 **********************************************************************/
511void tr_torrentAvailability( const tr_torrent *, int8_t * tab, int size );
512
513void tr_torrentAmountFinished( const tr_torrent * tor, float * tab, int size );
514
515/***********************************************************************
516 * tr_torrentRemoveSaved
517 ***********************************************************************
518 * Removes the saved copy of a torrent file for torrents which the
519 * TR_FLAG_SAVE flag is set.
520 **********************************************************************/
521void tr_torrentRemoveSaved( tr_torrent * );
522
523void tr_torrentRecheck( tr_torrent * );
524
525/***********************************************************************
526 * tr_torrentClose
527 ***********************************************************************
528 * Frees memory allocated by tr_torrentInit. If the torrent was running,
529 * it is stopped first.
530 **********************************************************************/
531void tr_torrentClose( tr_torrent * );
532
533/***********************************************************************
534 * tr_info
535 **********************************************************************/
536
537typedef struct tr_file
538{
539    uint64_t length;                /* Length of the file, in bytes */
540    char     name[MAX_PATH_LENGTH]; /* Path to the file */
541    int8_t   priority;              /* TR_PRI_HIGH, _NORMAL, or _LOW */
542    int8_t   dnd;                   /* nonzero if the file shouldn't be downloaded */
543    int      firstPiece;            /* We need pieces [firstPiece... */
544    int      lastPiece;             /* ...lastPiece] to dl this file */
545    uint64_t offset;                /* file begins at the torrent's nth byte */
546}
547tr_file;
548
549typedef struct tr_piece
550{
551    uint8_t  hash[SHA_DIGEST_LENGTH];  /* pieces hash */
552    int8_t   priority;                 /* TR_PRI_HIGH, _NORMAL, or _LOW */
553    int8_t   dnd;                      /* nonzero if the piece shouldn't be downloaded */
554}
555tr_piece;
556   
557struct tr_info
558{
559    /* Path to torrent */
560    char                 torrent[MAX_PATH_LENGTH];
561
562    /* General info */
563    uint8_t              hash[SHA_DIGEST_LENGTH];
564    char                 hashString[2*SHA_DIGEST_LENGTH+1];
565    char                 name[MAX_PATH_LENGTH];
566
567    /* Flags */
568    unsigned int isPrivate : 1;
569    unsigned int isMultifile : 1;
570
571    /* Tracker info */
572    struct
573    {
574        tr_tracker_info  * list;
575        int                 count;
576    }                  * trackerList;
577    int                  trackerTiers;
578    char               * primaryAddress;
579
580    /* Torrent info */
581    char                 comment[MAX_PATH_LENGTH];
582    char                 creator[MAX_PATH_LENGTH];
583    int                  dateCreated;
584
585    /* Pieces info */
586    int                  pieceSize;
587    int                  pieceCount;
588    uint64_t             totalSize;
589    tr_piece           * pieces;
590
591    /* Files info */
592    int                  fileCount;
593    tr_file            * files;
594};
595
596typedef enum
597{
598    TR_STATUS_CHECK_WAIT   = (1<<0), /* Waiting in queue to check files */
599    TR_STATUS_CHECK        = (1<<1), /* Checking files */
600    TR_STATUS_DOWNLOAD     = (1<<2), /* Downloading */
601    TR_STATUS_DONE         = (1<<3), /* not at 100% so can't tell the tracker
602                                        we're a seeder, but due to DND files
603                                        there's nothing we want right now */
604    TR_STATUS_SEED         = (1<<4), /* Seeding */
605    TR_STATUS_STOPPED      = (1<<5)  /* Torrent is stopped */
606}
607tr_torrent_status;
608
609#define TR_STATUS_IS_ACTIVE(s) ((s) != TR_STATUS_STOPPED)
610
611/***********************************************************************
612 * tr_stat
613 **********************************************************************/
614struct tr_stat
615{
616    tr_torrent_status   status;
617
618    int                 error;
619    char                errorString[128];
620
621    const tr_tracker_info * tracker;
622
623    float               recheckProgress;
624    float               percentComplete;
625    float               percentDone;
626    float               rateDownload;
627    float               rateUpload;
628    int                 eta;
629    int                 peersKnown;
630    int                 peersConnected;
631    int                 peersFrom[TR_PEER_FROM__MAX];
632    int                 peersSendingToUs;
633    int                 peersGettingFromUs;
634    int                 seeders;
635    int                 leechers;
636    int                 completedFromTracker;
637
638    /* Byte count of how much data is left to be downloaded until
639     * we're done -- that is, until we've got all the pieces we wanted. */
640    uint64_t            leftUntilDone;
641
642    /* Byte count of all the corrupt data you've ever downloaded for
643     * this torrent.  If you're on a poisoned torrent, this number can
644     * grow very large. */
645    uint64_t            corruptEver;
646
647    /* Byte count of all data you've ever uploaded for this torrent. */
648    uint64_t            uploadedEver;
649
650    /* Byte count of all the non-corrupt data you've ever downloaded
651     * for this torrent.  If you deleted the files and downloaded a second time,
652     * this will be 2*totalSize.. */
653    uint64_t            downloadedEver;
654
655    /* Byte count of all the checksum-verified data we have for this torrent. */
656    uint64_t            haveValid;
657
658    /* Byte count of all the partial piece data we have for this torrent.
659     * As pieces become complete, this value may decrease as portions of it are
660     * moved to `corrupt' or `haveValid'. */
661    uint64_t            haveUnchecked;
662
663    /* Byte count of all the non-DND piece data that either we already have,
664     * or that a peer we're connected to has. [0...desiredSize] */
665    uint64_t            desiredAvailable;
666
667    /* Byte count of all the piece data we want, whether we currently
668     * have it nor not. [0...tr_info.totalSize] */
669    uint64_t            desiredSize;
670
671    float               swarmspeed;
672
673#define TR_RATIO_NA  -1
674    float               ratio;
675   
676    uint64_t            startDate;
677    uint64_t            activityDate;
678};
679
680struct tr_file_stat
681{
682    uint64_t bytesCompleted;
683    float progress;
684};
685
686typedef enum
687{
688    TR_PEER_STATUS_HANDSHAKE,
689    TR_PEER_STATUS_PEER_IS_CHOKED,
690    TR_PEER_STATUS_CLIENT_IS_CHOKED,
691    TR_PEER_STATUS_CLIENT_IS_INTERESTED,
692    TR_PEER_STATUS_READY,
693    TR_PEER_STATUS_REQUEST_SENT,
694    TR_PEER_STATUS_ACTIVE,
695    TR_PEER_STATUS_ACTIVE_AND_CHOKED
696}
697tr_peer_status;
698
699struct tr_peer_stat
700{
701    char addr[INET_ADDRSTRLEN];
702    char client[80];
703   
704    unsigned int isEncrypted   : 1;
705    unsigned int isDownloading : 1;
706    unsigned int isUploading   : 1;
707
708    tr_peer_status status;
709
710    uint8_t  from;
711    uint16_t port;
712   
713    float progress;
714    float downloadFromRate;
715    float uploadToRate;
716};
717
718struct tr_msg_list
719{
720    uint8_t              level;
721    time_t               when;
722    char               * message;
723    struct tr_msg_list * next;
724};
725
726struct tr_tracker_info
727{
728    char * address;
729    int    port;
730    char * announce;
731    char * scrape;
732};
733
734struct tr_handle_status
735{
736#define TR_NAT_TRAVERSAL_MAPPING        1
737#define TR_NAT_TRAVERSAL_MAPPED         2
738#define TR_NAT_TRAVERSAL_NOTFOUND       3
739#define TR_NAT_TRAVERSAL_ERROR          4
740#define TR_NAT_TRAVERSAL_UNMAPPING      5
741#define TR_NAT_TRAVERSAL_DISABLED       6
742#define TR_NAT_TRAVERSAL_IS_DISABLED( st ) \
743  ( TR_NAT_TRAVERSAL_DISABLED == (st) || TR_NAT_TRAVERSAL_UNMAPPING == (st) )
744    int natTraversalStatus;
745    int publicPort;
746};
747
748#ifdef __TRANSMISSION__
749#  include "internal.h"
750#endif
751
752#ifdef __cplusplus
753}
754#endif
755
756#endif
Note: See TracBrowser for help on using the repository browser.