transmission 2.83
[tomato.git] / release / src-rt-6.x.4708 / router / transmission / libtransmission / announcer.h
blobfb777c33bbf400a9345233cccb6faadc11422922
1 /*
2 * This file Copyright (C) 2010-2014 Mnemosyne LLC
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
7 * $Id: announcer.h 14241 2014-01-21 03:10:30Z jordan $
8 */
10 #ifndef __TRANSMISSION__
11 #error only libtransmission should #include this header.
12 #endif
14 #ifndef _TR_ANNOUNCER_H_
15 #define _TR_ANNOUNCER_H_
17 #include "transmission.h"
19 struct tr_announcer;
20 struct tr_torrent_tiers;
22 /**
23 * *** Tracker Publish / Subscribe
24 * **/
26 typedef enum
28 TR_TRACKER_WARNING,
29 TR_TRACKER_ERROR,
30 TR_TRACKER_ERROR_CLEAR,
31 TR_TRACKER_PEERS
33 TrackerEventType;
35 struct tr_pex;
37 /** @brief Notification object to tell listeners about announce or scrape occurences */
38 typedef struct
40 /* what type of event this is */
41 TrackerEventType messageType;
43 /* for TR_TRACKER_WARNING and TR_TRACKER_ERROR */
44 const char * text;
45 const char * tracker;
47 /* for TR_TRACKER_PEERS */
48 const struct tr_pex * pex;
49 size_t pexCount;
51 /* [0...100] for probability a peer is a seed. calculated by the leecher/seeder ratio */
52 int8_t seedProbability;
54 tr_tracker_event;
56 typedef void (*tr_tracker_callback) (tr_torrent * tor,
57 const tr_tracker_event * event,
58 void * client_data);
60 /**
61 *** Session ctor/dtor
62 **/
64 void tr_announcerInit (tr_session *);
66 void tr_announcerClose (tr_session *);
68 /**
69 *** For torrent customers
70 **/
72 struct tr_torrent_tiers * tr_announcerAddTorrent (tr_torrent * torrent,
73 tr_tracker_callback cb,
74 void * cbdata);
76 bool tr_announcerHasBacklog (const struct tr_announcer *);
78 void tr_announcerResetTorrent (struct tr_announcer*, tr_torrent*);
80 void tr_announcerRemoveTorrent (struct tr_announcer * ,
81 tr_torrent *);
83 void tr_announcerChangeMyPort (tr_torrent *);
85 bool tr_announcerCanManualAnnounce (const tr_torrent *);
87 void tr_announcerManualAnnounce (tr_torrent *);
89 void tr_announcerTorrentStarted (tr_torrent *);
90 void tr_announcerTorrentStopped (tr_torrent *);
91 void tr_announcerTorrentCompleted (tr_torrent *);
93 enum { TR_ANN_UP, TR_ANN_DOWN, TR_ANN_CORRUPT };
94 void tr_announcerAddBytes (tr_torrent *, int up_down_or_corrupt, uint32_t byteCount);
96 time_t tr_announcerNextManualAnnounce (const tr_torrent *);
98 tr_tracker_stat * tr_announcerStats (const tr_torrent * torrent,
99 int * setmeTrackerCount);
101 void tr_announcerStatsFree (tr_tracker_stat * trackers,
102 int trackerCount);
104 /***
105 ****
106 ***/
108 void tr_tracker_udp_upkeep (tr_session * session);
110 void tr_tracker_udp_close (tr_session * session);
112 bool tr_tracker_udp_is_idle (const tr_session * session);
116 #endif /* _TR_ANNOUNCER_H_ */