forked from wereHamster/transmission
/
announcer.h
136 lines (98 loc) · 3.36 KB
/
announcer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* This file Copyright (C) Mnemosyne LLC
*
* This file is licensed by the GPL version 2. Works owned by the
* Transmission project are granted a special exemption to clause 2(b)
* so that the bulk of its code can remain under the MIT license.
* This exemption does not extend to derived works not owned by
* the Transmission project.
*
* $Id: announcer.h 12237 2011-03-26 10:22:25Z jordan $
*/
#ifndef __TRANSMISSION__
#error only libtransmission should #include this header.
#endif
#ifndef _TR_ANNOUNCER_H_
#define _TR_ANNOUNCER_H_
#include <event2/event.h> /* evtimer */
#include "transmission.h"
#include "ptrarray.h"
/**
* "global" (per-tr_session) fields
*/
typedef struct tr_announcer
{
tr_ptrArray stops; /* tr_announce_request */
tr_session * session;
struct event * upkeepTimer;
int slotsAvailable;
int key;
time_t tauUpkeepAt;
}
tr_announcer;
struct tr_torrent_tiers;
/**
* *** Tracker Publish / Subscribe
* **/
typedef enum
{
TR_TRACKER_WARNING,
TR_TRACKER_ERROR,
TR_TRACKER_ERROR_CLEAR,
TR_TRACKER_PEERS
}
TrackerEventType;
struct tr_pex;
/** @brief Notification object to tell listeners about announce or scrape occurences */
typedef struct
{
/* what type of event this is */
TrackerEventType messageType;
/* for TR_TRACKER_WARNING and TR_TRACKER_ERROR */
const char * text;
const char * tracker;
/* for TR_TRACKER_PEERS */
const struct tr_pex * pex;
size_t pexCount;
/* [0...100] for probability a peer is a seed. calculated by the leecher/seeder ratio */
int8_t seedProbability;
}
tr_tracker_event;
typedef void tr_tracker_callback ( tr_torrent * tor,
const tr_tracker_event * event,
void * client_data );
/**
*** Session ctor/dtor
**/
void tr_announcerInit( tr_session * );
void tr_announcerClose( tr_session * );
/**
*** For torrent customers
**/
struct tr_torrent_tiers * tr_announcerAddTorrent( tr_torrent * torrent,
tr_tracker_callback * cb,
void * cbdata );
bool tr_announcerHasBacklog( const tr_announcer * );
void tr_announcerResetTorrent( tr_announcer*, tr_torrent* );
void tr_announcerRemoveTorrent( tr_announcer * ,
tr_torrent * );
void tr_announcerChangeMyPort( tr_torrent * );
bool tr_announcerCanManualAnnounce( const tr_torrent * );
void tr_announcerManualAnnounce( tr_torrent * );
void tr_announcerTorrentStarted( tr_torrent * );
void tr_announcerTorrentStopped( tr_torrent * );
void tr_announcerTorrentCompleted( tr_torrent * );
enum { TR_ANN_UP, TR_ANN_DOWN, TR_ANN_CORRUPT };
void tr_announcerAddBytes( tr_torrent *, int up_down_or_corrupt, uint32_t byteCount );
time_t tr_announcerNextManualAnnounce( const tr_torrent * );
tr_tracker_stat * tr_announcerStats( const tr_torrent * torrent,
int * setmeTrackerCount );
void tr_announcerStatsFree( tr_tracker_stat * trackers,
int trackerCount );
/***
****
***/
void tr_tracker_udp_upkeep( tr_session * session );
void tr_tracker_udp_close( tr_session * session );
bool tr_tracker_udp_is_idle( const tr_session * session );
#endif /* _TR_ANNOUNCER_H_ */