1
0
mirror of git://erdgeist.org/opentracker synced 2025-01-26 22:56:26 +00:00
opentracker/ot_livesync.h

79 lines
2.0 KiB
C
Raw Normal View History

/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
2008-10-28 01:27:22 +00:00
$id$ */
#ifndef OT_LIVESYNC_H__
#define OT_LIVESYNC_H__
#include "io.h"
#include "trackerlogic.h"
/*
2008-12-10 14:19:37 +00:00
Syncing is done as udp packets in the multicast domain 224.0.42.5 port 9696
Each tracker should join the multicast group and send its live sync packets
to that group, using a ttl of 1
2008-12-10 14:19:37 +00:00
Format of all sync packets is straight forward, packet type determines
which kind of packet this is:
0x0000 0x04 id of tracker instance
2008-12-10 14:19:37 +00:00
0x0004 0x04 packet type
########
######## PEER SYNC PROTOCOL ########
########
Each tracker instance accumulates announce requests until its buffer is
full or a timeout is reached. Then it broadcasts its live sync packer:
2024-04-05 03:26:42 +02:00
packet type SYNC_LIVE4
2008-12-10 14:19:37 +00:00
[ 0x0008 0x14 info_hash
0x001c 0x04 peer's ipv4 address
0x0020 0x02 peer's port
0x0024 0x02 peer flags v1 ( SEEDING = 0x80, COMPLETE = 0x40, STOPPED = 0x20 )
]*
2008-10-28 01:27:22 +00:00
2024-04-05 03:26:42 +02:00
packet type SYNC_LIVE6
[ 0x0008 0x14 info_hash
0x001c 0x10 peer's ipv6 address
0x002c 0x02 peer's port
0x002e 0x02 peer flags v1 ( SEEDING = 0x80, COMPLETE = 0x40, STOPPED = 0x20 )
]*
2008-12-10 14:19:37 +00:00
*/
#ifdef WANT_SYNC_LIVE
#define LIVESYNC_PORT 9696
void livesync_init();
void livesync_deinit();
/* Join multicast group for listening and create sending socket */
2024-04-15 00:39:02 +02:00
void livesync_bind_mcast(char *ip, uint16_t port);
/* Inform live sync about whats going on. */
2024-04-15 00:39:02 +02:00
void livesync_tell(struct ot_workstruct *ws);
/* Tickle the live sync module from time to time, so no events get
stuck when there's not enough traffic to fill udp packets fast
enough */
2024-04-15 00:39:02 +02:00
void livesync_ticker();
/* Handle an incoming live sync packet */
2024-04-15 00:39:02 +02:00
void handle_livesync(const int64 sock);
#else
2008-10-28 01:27:22 +00:00
/* If no syncing is required, save calling code from #ifdef
constructions */
2008-12-07 03:50:51 +00:00
#define livesync_deinit()
#define livesync_init()
#define livesync_ticker()
#define handle_livesync(a)
#endif
#endif