summaryrefslogtreecommitdiff
path: root/src/ot_livesync.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ot_livesync.c')
-rw-r--r--src/ot_livesync.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ot_livesync.c b/src/ot_livesync.c
index 11b75d2..85577f7 100644
--- a/src/ot_livesync.c
+++ b/src/ot_livesync.c
@@ -22,8 +22,10 @@
22 22
23#ifdef WANT_SYNC_LIVE 23#ifdef WANT_SYNC_LIVE
24 24
25ot_ip6 groupip_1 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 224, 0, 23, 5}; 25/* The multicast group, legacy opentrackers joined by default 224.0.23.5, so it
26static uint16_t g_port = LIVESYNC_PORT; 26 stays the default */
27static ot_ip6 g_group = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 224, 0, 23, 5};
28static uint16_t g_port = LIVESYNC_PORT;
27 29
28#define LIVESYNC_INCOMING_BUFFSIZE (256 * 256) 30#define LIVESYNC_INCOMING_BUFFSIZE (256 * 256)
29 31
@@ -96,6 +98,14 @@ void livesync_deinit(void) {
96 close(g_socket_out); 98 close(g_socket_out);
97} 99}
98 100
101int livesync_set_group(const ot_ip6 group) {
102 /* v4 multicast is 224.0.0.0/4, and the socket layer has nothing else */
103 if (!ip_is_v4mapped(group) || (group[12] & 0xf0) != 0xe0)
104 return -1;
105 memcpy(g_group, group, sizeof(ot_ip6));
106 return 0;
107}
108
99void livesync_bind_mcast(ot_ip6 ip, uint16_t port) { 109void livesync_bind_mcast(ot_ip6 ip, uint16_t port) {
100 if (!ip_is_v4mapped(ip)) 110 if (!ip_is_v4mapped(ip))
101 exerr("v6 mcast support not yet available."); 111 exerr("v6 mcast support not yet available.");
@@ -105,7 +115,7 @@ void livesync_bind_mcast(ot_ip6 ip, uint16_t port) {
105 115
106 g_port = port; 116 g_port = port;
107 117
108 if ((g_socket_in = socket_mcast_join(groupip_1, ip, port)) == -1) 118 if ((g_socket_in = socket_mcast_join(g_group, ip, port)) == -1)
109 exerr("Error: Cant bind live sync incoming socket."); 119 exerr("Error: Cant bind live sync incoming socket.");
110 120
111 if ((g_socket_out = socket_mcast_bind(ip, port, 0)) == -1) 121 if ((g_socket_out = socket_mcast_bind(ip, port, 0)) == -1)
@@ -125,7 +135,7 @@ static void livesync_issue_peersync(sync_buffer *buf) {
125 has modified the protected element */ 135 has modified the protected element */
126 pthread_mutex_unlock(&g_outbuf_mutex); 136 pthread_mutex_unlock(&g_outbuf_mutex);
127 137
128 socket_mcast_send(g_socket_out, mycopy, fill, groupip_1, g_port); 138 socket_mcast_send(g_socket_out, mycopy, fill, g_group, g_port);
129} 139}
130 140
131static void livesync_handle_peersync(struct ot_workstruct *ws, size_t peer_size) { 141static void livesync_handle_peersync(struct ot_workstruct *ws, size_t peer_size) {