summaryrefslogtreecommitdiff
path: root/trackerlogic.h
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.h')
-rw-r--r--trackerlogic.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/trackerlogic.h b/trackerlogic.h
index 3525421..986c17a 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -43,6 +43,11 @@ typedef time_t ot_time;
43/* From opentracker.c */ 43/* From opentracker.c */
44extern time_t g_now; 44extern time_t g_now;
45#define NOW (g_now/OT_POOLS_TIMEOUT) 45#define NOW (g_now/OT_POOLS_TIMEOUT)
46extern uint32_t g_tracker_id;
47typedef enum { FLAG_TCP, FLAG_UDP, FLAG_MCA } PROTO_FLAG;
48
49/* Try to bind to ip:port pair. May call exit() on failure */
50int64_t ot_try_bind( char ip[4], uint16_t port, PROTO_FLAG proto );
46 51
47typedef struct { 52typedef struct {
48 uint8_t data[8]; 53 uint8_t data[8];
@@ -50,6 +55,7 @@ typedef struct {
50static const uint8_t PEER_FLAG_SEEDING = 0x80; 55static const uint8_t PEER_FLAG_SEEDING = 0x80;
51static const uint8_t PEER_FLAG_COMPLETED = 0x40; 56static const uint8_t PEER_FLAG_COMPLETED = 0x40;
52static const uint8_t PEER_FLAG_STOPPED = 0x20; 57static const uint8_t PEER_FLAG_STOPPED = 0x20;
58static const uint8_t PEER_FLAG_LEECHING = 0x00;
53 59
54#define OT_SETIP( peer, ip ) memmove((peer),(ip),4); 60#define OT_SETIP( peer, ip ) memmove((peer),(ip),4);
55#define OT_SETPORT( peer, port ) memmove(((uint8_t*)peer)+4,(port),2); 61#define OT_SETPORT( peer, port ) memmove(((uint8_t*)peer)+4,(port),2);
@@ -74,7 +80,7 @@ struct ot_peerlist {
74 size_t down_count; 80 size_t down_count;
75 size_t seed_counts[ OT_POOLS_COUNT ]; 81 size_t seed_counts[ OT_POOLS_COUNT ];
76 ot_vector peers[ OT_POOLS_COUNT ]; 82 ot_vector peers[ OT_POOLS_COUNT ];
77#ifdef WANT_TRACKER_SYNC 83#ifdef WANT_SYNC_BATCH
78 ot_vector changeset; 84 ot_vector changeset;
79#endif 85#endif
80}; 86};
@@ -83,18 +89,23 @@ struct ot_peerlist {
83 Exported functions 89 Exported functions
84*/ 90*/
85 91
86#ifdef WANT_TRACKER_SYNC 92#if defined( WANT_SYNC_BATCH ) || defined( WANT_SYNC_LIVE )
87#define WANT_TRACKER_SYNC_PARAM( param ) , param 93#define WANT_SYNC
94#endif
95
96#ifdef WANT_SYNC
97#define WANT_SYNC_PARAM( param ) , param
88#else 98#else
89#define WANT_TRACKER_SYNC_PARAM( param ) 99#define WANT_SYNC_PARAM( param )
90#endif 100#endif
91 101
92int trackerlogic_init( const char * const serverdir ); 102int trackerlogic_init( const char * const serverdir );
93void trackerlogic_deinit( void ); 103void trackerlogic_deinit( void );
104void exerr( char * message );
94 105
95ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_TRACKER_SYNC_PARAM( int from_changeset ) ); 106ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM( int from_changeset ) );
96size_t remove_peer_from_torrent( ot_hash *hash, ot_peer *peer, char *reply, int is_tcp ); 107size_t remove_peer_from_torrent( ot_hash *hash, ot_peer *peer, char *reply, PROTO_FLAG proto );
97size_t return_peers_for_torrent( ot_hash *hash, size_t amount, char *reply, int is_tcp ); 108size_t return_peers_for_torrent( ot_hash *hash, size_t amount, char *reply, PROTO_FLAG proto );
98size_t return_tcp_scrape_for_torrent( ot_hash *hash, int amount, char *reply ); 109size_t return_tcp_scrape_for_torrent( ot_hash *hash, int amount, char *reply );
99size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ); 110size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply );
100 111