Make chunked transfers use gzip also
[opentracker.git] / ot_livesync.h
blob41bfc2ef0da7c413d6353fa427df9c93b525ec35
1 /* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever.
4 $id$ */
6 #ifndef OT_LIVESYNC_H__
7 #define OT_LIVESYNC_H__
9 #include "io.h"
10 #include "trackerlogic.h"
13 Syncing is done as udp packets in the multicast domain 224.0.42.5 port 9696
15 Each tracker should join the multicast group and send its live sync packets
16 to that group, using a ttl of 1
18 Format of all sync packets is straight forward, packet type determines
19 which kind of packet this is:
21 0x0000 0x04 id of tracker instance
22 0x0004 0x04 packet type
24 ########
25 ######## PEER SYNC PROTOCOL ########
26 ########
28 Each tracker instance accumulates announce requests until its buffer is
29 full or a timeout is reached. Then it broadcasts its live sync packer:
31 packet type SYNC_LIVE4
32 [ 0x0008 0x14 info_hash
33 0x001c 0x04 peer's ipv4 address
34 0x0020 0x02 peer's port
35 0x0024 0x02 peer flags v1 ( SEEDING = 0x80, COMPLETE = 0x40, STOPPED = 0x20 )
38 packet type SYNC_LIVE6
39 [ 0x0008 0x14 info_hash
40 0x001c 0x10 peer's ipv6 address
41 0x002c 0x02 peer's port
42 0x002e 0x02 peer flags v1 ( SEEDING = 0x80, COMPLETE = 0x40, STOPPED = 0x20 )
46 #ifdef WANT_SYNC_LIVE
48 #define LIVESYNC_PORT 9696
50 void livesync_init();
51 void livesync_deinit();
53 /* Join multicast group for listening and create sending socket */
54 void livesync_bind_mcast( char *ip, uint16_t port );
56 /* Inform live sync about whats going on. */
57 void livesync_tell( struct ot_workstruct *ws );
59 /* Tickle the live sync module from time to time, so no events get
60 stuck when there's not enough traffic to fill udp packets fast
61 enough */
62 void livesync_ticker( );
64 /* Handle an incoming live sync packet */
65 void handle_livesync( const int64 sock );
67 #else
69 /* If no syncing is required, save calling code from #ifdef
70 constructions */
71 #define livesync_deinit()
72 #define livesync_init()
73 #define livesync_ticker()
74 #define handle_livesync(a)
76 #endif
78 #endif