diff options
Diffstat (limited to 'src/ot_livesync.c')
| -rw-r--r-- | src/ot_livesync.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/ot_livesync.c b/src/ot_livesync.c index 9770bbc..85577f7 100644 --- a/src/ot_livesync.c +++ b/src/ot_livesync.c | |||
| @@ -22,7 +22,10 @@ | |||
| 22 | 22 | ||
| 23 | #ifdef WANT_SYNC_LIVE | 23 | #ifdef WANT_SYNC_LIVE |
| 24 | 24 | ||
| 25 | ot_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 |
| 26 | stays the default */ | ||
| 27 | static ot_ip6 g_group = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 224, 0, 23, 5}; | ||
| 28 | static uint16_t g_port = LIVESYNC_PORT; | ||
| 26 | 29 | ||
| 27 | #define LIVESYNC_INCOMING_BUFFSIZE (256 * 256) | 30 | #define LIVESYNC_INCOMING_BUFFSIZE (256 * 256) |
| 28 | 31 | ||
| @@ -95,6 +98,14 @@ void livesync_deinit(void) { | |||
| 95 | close(g_socket_out); | 98 | close(g_socket_out); |
| 96 | } | 99 | } |
| 97 | 100 | ||
| 101 | int 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 | |||
| 98 | void livesync_bind_mcast(ot_ip6 ip, uint16_t port) { | 109 | void livesync_bind_mcast(ot_ip6 ip, uint16_t port) { |
| 99 | if (!ip_is_v4mapped(ip)) | 110 | if (!ip_is_v4mapped(ip)) |
| 100 | exerr("v6 mcast support not yet available."); | 111 | exerr("v6 mcast support not yet available."); |
| @@ -102,7 +113,9 @@ void livesync_bind_mcast(ot_ip6 ip, uint16_t port) { | |||
| 102 | if (g_socket_in != -1) | 113 | if (g_socket_in != -1) |
| 103 | exerr("Error: Livesync listen ip specified twice."); | 114 | exerr("Error: Livesync listen ip specified twice."); |
| 104 | 115 | ||
| 105 | if ((g_socket_in = socket_mcast_join(groupip_1, ip, port)) == -1) | 116 | g_port = port; |
| 117 | |||
| 118 | if ((g_socket_in = socket_mcast_join(g_group, ip, port)) == -1) | ||
| 106 | exerr("Error: Cant bind live sync incoming socket."); | 119 | exerr("Error: Cant bind live sync incoming socket."); |
| 107 | 120 | ||
| 108 | if ((g_socket_out = socket_mcast_bind(ip, port, 0)) == -1) | 121 | if ((g_socket_out = socket_mcast_bind(ip, port, 0)) == -1) |
| @@ -122,7 +135,7 @@ static void livesync_issue_peersync(sync_buffer *buf) { | |||
| 122 | has modified the protected element */ | 135 | has modified the protected element */ |
| 123 | pthread_mutex_unlock(&g_outbuf_mutex); | 136 | pthread_mutex_unlock(&g_outbuf_mutex); |
| 124 | 137 | ||
| 125 | socket_mcast_send(g_socket_out, mycopy, fill, groupip_1, LIVESYNC_PORT); | 138 | socket_mcast_send(g_socket_out, mycopy, fill, g_group, g_port); |
| 126 | } | 139 | } |
| 127 | 140 | ||
| 128 | static void livesync_handle_peersync(struct ot_workstruct *ws, size_t peer_size) { | 141 | static void livesync_handle_peersync(struct ot_workstruct *ws, size_t peer_size) { |
