summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opentracker.c16
-rw-r--r--ot_fullscrape.c2
-rw-r--r--ot_fullscrape.h2
-rw-r--r--ot_http.c16
-rw-r--r--ot_http.h6
-rw-r--r--ot_livesync.c4
-rw-r--r--ot_livesync.h2
-rw-r--r--ot_mutex.c10
-rw-r--r--ot_mutex.h14
-rw-r--r--ot_stats.c2
-rw-r--r--ot_stats.h2
-rw-r--r--ot_sync.c2
-rw-r--r--ot_sync.h4
-rw-r--r--ot_udp.c6
-rw-r--r--ot_udp.h6
-rw-r--r--proxy.c26
16 files changed, 62 insertions, 58 deletions
diff --git a/opentracker.c b/opentracker.c
index 8a39bde..af336aa 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -156,7 +156,7 @@ static ssize_t header_complete(char *request, ssize_t byte_count) {
156 return 0; 156 return 0;
157} 157}
158 158
159static void handle_dead(const int64 sock) { 159static void handle_dead(const int64_t sock) {
160 struct http_data *cookie = io_getcookie(sock); 160 struct http_data *cookie = io_getcookie(sock);
161 if (cookie) { 161 if (cookie) {
162 size_t i; 162 size_t i;
@@ -171,7 +171,7 @@ static void handle_dead(const int64 sock) {
171 io_close(sock); 171 io_close(sock);
172} 172}
173 173
174static void handle_read(const int64 sock, struct ot_workstruct *ws) { 174static void handle_read(const int64_t sock, struct ot_workstruct *ws) {
175 struct http_data *cookie = io_getcookie(sock); 175 struct http_data *cookie = io_getcookie(sock);
176 ssize_t byte_count = io_tryread(sock, ws->inbuf, G_INBUF_SIZE); 176 ssize_t byte_count = io_tryread(sock, ws->inbuf, G_INBUF_SIZE);
177 177
@@ -215,7 +215,7 @@ static void handle_read(const int64 sock, struct ot_workstruct *ws) {
215 } 215 }
216} 216}
217 217
218static void handle_write(const int64 sock) { 218static void handle_write(const int64_t sock) {
219 struct http_data *cookie = io_getcookie(sock); 219 struct http_data *cookie = io_getcookie(sock);
220 size_t i; 220 size_t i;
221 int chunked = 0; 221 int chunked = 0;
@@ -227,7 +227,7 @@ static void handle_write(const int64 sock) {
227 227
228 for (i = 0; i < cookie->batches; ++i) { 228 for (i = 0; i < cookie->batches; ++i) {
229 if (cookie->batch[i].bytesleft) { 229 if (cookie->batch[i].bytesleft) {
230 int64 res = iob_send(sock, cookie->batch + i); 230 int64_t res = iob_send(sock, cookie->batch + i);
231 231
232 if (res == -3) { 232 if (res == -3) {
233 handle_dead(sock); 233 handle_dead(sock);
@@ -250,9 +250,9 @@ static void handle_write(const int64 sock) {
250 handle_dead(sock); 250 handle_dead(sock);
251} 251}
252 252
253static void handle_accept(const int64 serversocket) { 253static void handle_accept(const int64_t serversocket) {
254 struct http_data *cookie; 254 struct http_data *cookie;
255 int64 sock; 255 int64_t sock;
256 ot_ip6 ip; 256 ot_ip6 ip;
257 uint16 port; 257 uint16 port;
258 tai6464 t; 258 tai6464 t;
@@ -305,7 +305,7 @@ static void *server_mainloop(void *args) {
305 random_bytes(ws.rand48_state, sizeof(ws.rand48_state)); 305 random_bytes(ws.rand48_state, sizeof(ws.rand48_state));
306 306
307 for (;;) { 307 for (;;) {
308 int64 sock; 308 int64_t sock;
309 309
310 io_wait(); 310 io_wait();
311 311
@@ -339,7 +339,7 @@ static void *server_mainloop(void *args) {
339} 339}
340 340
341static int64_t ot_try_bind(ot_ip6 ip, uint16_t port, PROTO_FLAG proto) { 341static int64_t ot_try_bind(ot_ip6 ip, uint16_t port, PROTO_FLAG proto) {
342 int64 sock = proto == FLAG_TCP ? socket_tcp6() : socket_udp6(); 342 int64_t sock = proto == FLAG_TCP ? socket_tcp6() : socket_udp6();
343 343
344#ifdef _DEBUG 344#ifdef _DEBUG
345 { 345 {
diff --git a/ot_fullscrape.c b/ot_fullscrape.c
index 3d0e2f1..9dcbe68 100644
--- a/ot_fullscrape.c
+++ b/ot_fullscrape.c
@@ -82,7 +82,7 @@ void fullscrape_deinit(void) {
82 pthread_cancel( thread_id ); 82 pthread_cancel( thread_id );
83} 83}
84 84
85void fullscrape_deliver( int64 sock, ot_tasktype tasktype ) { 85void fullscrape_deliver( int64_t sock, ot_tasktype tasktype ) {
86 mutex_workqueue_pushtask( sock, tasktype ); 86 mutex_workqueue_pushtask( sock, tasktype );
87} 87}
88 88
diff --git a/ot_fullscrape.h b/ot_fullscrape.h
index 843e039..0e7690c 100644
--- a/ot_fullscrape.h
+++ b/ot_fullscrape.h
@@ -12,7 +12,7 @@
12 12
13void fullscrape_init(void); 13void fullscrape_init(void);
14void fullscrape_deinit(void); 14void fullscrape_deinit(void);
15void fullscrape_deliver(int64 sock, ot_tasktype tasktype); 15void fullscrape_deliver(int64_t sock, ot_tasktype tasktype);
16 16
17#else 17#else
18 18
diff --git a/ot_http.c b/ot_http.c
index fca9176..46ca5a9 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -44,7 +44,7 @@ ssize_t g_stats_path_len;
44 44
45enum { SUCCESS_HTTP_HEADER_LENGTH = 80, SUCCESS_HTTP_SIZE_OFF = 17 }; 45enum { SUCCESS_HTTP_HEADER_LENGTH = 80, SUCCESS_HTTP_SIZE_OFF = 17 };
46 46
47static void http_senddata(const int64 sock, struct ot_workstruct *ws) { 47static void http_senddata(const int64_t sock, struct ot_workstruct *ws) {
48 struct http_data *cookie = io_getcookie(sock); 48 struct http_data *cookie = io_getcookie(sock);
49 ssize_t written_size; 49 ssize_t written_size;
50 50
@@ -124,7 +124,7 @@ static void http_senddata(const int64 sock, struct ot_workstruct *ws) {
124#define HTTPERROR_403_IP return http_issue_error(sock, ws, CODE_HTTPERROR_403_IP) 124#define HTTPERROR_403_IP return http_issue_error(sock, ws, CODE_HTTPERROR_403_IP)
125#define HTTPERROR_404 return http_issue_error(sock, ws, CODE_HTTPERROR_404) 125#define HTTPERROR_404 return http_issue_error(sock, ws, CODE_HTTPERROR_404)
126#define HTTPERROR_500 return http_issue_error(sock, ws, CODE_HTTPERROR_500) 126#define HTTPERROR_500 return http_issue_error(sock, ws, CODE_HTTPERROR_500)
127ssize_t http_issue_error(const int64 sock, struct ot_workstruct *ws, int code) { 127ssize_t http_issue_error(const int64_t sock, struct ot_workstruct *ws, int code) {
128 char *error_code[] = {"302 Found", "400 Invalid Request", "400 Invalid Request", "400 Invalid Request", "402 Payment Required", 128 char *error_code[] = {"302 Found", "400 Invalid Request", "400 Invalid Request", "400 Invalid Request", "402 Payment Required",
129 "403 Not Modest", "403 Access Denied", "404 Not Found", "500 Internal Server Error"}; 129 "403 Not Modest", "403 Access Denied", "404 Not Found", "500 Internal Server Error"};
130 char *title = error_code[code]; 130 char *title = error_code[code];
@@ -144,7 +144,7 @@ ssize_t http_issue_error(const int64 sock, struct ot_workstruct *ws, int code) {
144 return ws->reply_size = -2; 144 return ws->reply_size = -2;
145} 145}
146 146
147ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial) { 147ssize_t http_sendiovecdata(const int64_t sock, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial) {
148 struct http_data *cookie = io_getcookie(sock); 148 struct http_data *cookie = io_getcookie(sock);
149 io_batch *current; 149 io_batch *current;
150 char *header; 150 char *header;
@@ -243,7 +243,7 @@ ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, size_t io
243 return 0; 243 return 0;
244} 244}
245 245
246static ssize_t http_handle_stats(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { 246static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, char *read_ptr) {
247 static const ot_keywords keywords_main[] = {{"mode", 1}, {"format", 2}, {"info_hash", 3}, {NULL, -3}}; 247 static const ot_keywords keywords_main[] = {{"mode", 1}, {"format", 2}, {"info_hash", 3}, {NULL, -3}};
248 static const ot_keywords keywords_mode[] = {{"peer", TASK_STATS_PEERS}, 248 static const ot_keywords keywords_mode[] = {{"peer", TASK_STATS_PEERS},
249 {"conn", TASK_STATS_CONNS}, 249 {"conn", TASK_STATS_CONNS},
@@ -368,7 +368,7 @@ typedef struct {
368#endif 368#endif
369 369
370#ifdef WANT_FULLSCRAPE 370#ifdef WANT_FULLSCRAPE
371static ssize_t http_handle_fullscrape(const int64 sock, struct ot_workstruct *ws) { 371static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct *ws) {
372 struct http_data *cookie = io_getcookie(sock); 372 struct http_data *cookie = io_getcookie(sock);
373 int format = 0; 373 int format = 0;
374 tai6464 t; 374 tai6464 t;
@@ -438,7 +438,7 @@ static ssize_t http_handle_fullscrape(const int64 sock, struct ot_workstruct *ws
438} 438}
439#endif 439#endif
440 440
441static ssize_t http_handle_scrape(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { 441static ssize_t http_handle_scrape(const int64_t sock, struct ot_workstruct *ws, char *read_ptr) {
442 static const ot_keywords keywords_scrape[] = {{"info_hash", 1}, {NULL, -3}}; 442 static const ot_keywords keywords_scrape[] = {{"info_hash", 1}, {NULL, -3}};
443 443
444 ot_hash *multiscrape_buf = (ot_hash *)ws->request; 444 ot_hash *multiscrape_buf = (ot_hash *)ws->request;
@@ -517,7 +517,7 @@ static ot_keywords keywords_announce[] = {{"port", 1}, {"left", 2}, {"event",
517#endif 517#endif
518 {"peer_id", 9}, {NULL, -3}}; 518 {"peer_id", 9}, {NULL, -3}};
519static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; 519static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}};
520static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { 520static ssize_t http_handle_announce(const int64_t sock, struct ot_workstruct *ws, char *read_ptr) {
521 size_t numwant; 521 size_t numwant;
522 int tmp, scanon; 522 int tmp, scanon;
523 unsigned short port = 0; 523 unsigned short port = 0;
@@ -695,7 +695,7 @@ static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *
695 return ws->reply_size; 695 return ws->reply_size;
696} 696}
697 697
698ssize_t http_handle_request(const int64 sock, struct ot_workstruct *ws) { 698ssize_t http_handle_request(const int64_t sock, struct ot_workstruct *ws) {
699 ssize_t reply_off, len; 699 ssize_t reply_off, len;
700 char *read_ptr = ws->request, *write_ptr; 700 char *read_ptr = ws->request, *write_ptr;
701 701
diff --git a/ot_http.h b/ot_http.h
index e53accc..004d710 100644
--- a/ot_http.h
+++ b/ot_http.h
@@ -25,9 +25,9 @@ struct http_data {
25 STRUCT_HTTP_FLAG flag; 25 STRUCT_HTTP_FLAG flag;
26}; 26};
27 27
28ssize_t http_handle_request(const int64 s, struct ot_workstruct *ws); 28ssize_t http_handle_request(const int64_t s, struct ot_workstruct *ws);
29ssize_t http_sendiovecdata(const int64 s, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial); 29ssize_t http_sendiovecdata(const int64_t s, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial);
30ssize_t http_issue_error(const int64 s, struct ot_workstruct *ws, int code); 30ssize_t http_issue_error(const int64_t s, struct ot_workstruct *ws, int code);
31 31
32extern char *g_stats_path; 32extern char *g_stats_path;
33extern ssize_t g_stats_path_len; 33extern ssize_t g_stats_path_len;
diff --git a/ot_livesync.c b/ot_livesync.c
index f6bb28b..8b2dee6 100644
--- a/ot_livesync.c
+++ b/ot_livesync.c
@@ -40,10 +40,10 @@ enum { OT_SYNC_PEER4, OT_SYNC_PEER6 };
40static void *livesync_worker(void *args); 40static void *livesync_worker(void *args);
41 41
42/* For outgoing packets */ 42/* For outgoing packets */
43static int64 g_socket_in = -1; 43static int64_t g_socket_in = -1;
44 44
45/* For incoming packets */ 45/* For incoming packets */
46static int64 g_socket_out = -1; 46static int64_t g_socket_out = -1;
47 47
48static pthread_mutex_t g_outbuf_mutex = PTHREAD_MUTEX_INITIALIZER; 48static pthread_mutex_t g_outbuf_mutex = PTHREAD_MUTEX_INITIALIZER;
49typedef struct { 49typedef struct {
diff --git a/ot_livesync.h b/ot_livesync.h
index ed710f0..6eca479 100644
--- a/ot_livesync.h
+++ b/ot_livesync.h
@@ -62,7 +62,7 @@ void livesync_tell(struct ot_workstruct *ws);
62void livesync_ticker(void); 62void livesync_ticker(void);
63 63
64/* Handle an incoming live sync packet */ 64/* Handle an incoming live sync packet */
65void handle_livesync(const int64 sock); 65void handle_livesync(const int64_t sock);
66 66
67#else 67#else
68 68
diff --git a/ot_mutex.c b/ot_mutex.c
index affec6b..2a8cbf5 100644
--- a/ot_mutex.c
+++ b/ot_mutex.c
@@ -62,7 +62,7 @@ size_t mutex_get_torrent_count(void) { return g_torrent_count; }
62struct ot_task { 62struct ot_task {
63 ot_taskid taskid; 63 ot_taskid taskid;
64 ot_tasktype tasktype; 64 ot_tasktype tasktype;
65 int64 sock; 65 int64_t sock;
66 size_t iovec_entries; 66 size_t iovec_entries;
67 struct iovec *iovec; 67 struct iovec *iovec;
68 struct ot_task *next; 68 struct ot_task *next;
@@ -73,7 +73,7 @@ static struct ot_task *tasklist;
73static pthread_mutex_t tasklist_mutex; 73static pthread_mutex_t tasklist_mutex;
74static pthread_cond_t tasklist_being_filled; 74static pthread_cond_t tasklist_being_filled;
75 75
76int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype) { 76int mutex_workqueue_pushtask(int64_t sock, ot_tasktype tasktype) {
77 struct ot_task **tmptask, *task; 77 struct ot_task **tmptask, *task;
78 78
79 task = malloc(sizeof(struct ot_task)); 79 task = malloc(sizeof(struct ot_task));
@@ -102,7 +102,7 @@ int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype) {
102 return 0; 102 return 0;
103} 103}
104 104
105void mutex_workqueue_canceltask(int64 sock) { 105void mutex_workqueue_canceltask(int64_t sock) {
106 struct ot_task **task; 106 struct ot_task **task;
107 107
108 /* Want exclusive access to tasklist */ 108 /* Want exclusive access to tasklist */
@@ -227,9 +227,9 @@ int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec) {
227 return task ? 0 : -1; 227 return task ? 0 : -1;
228} 228}
229 229
230int64 mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovec, int *is_partial) { 230int64_t mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovec, int *is_partial) {
231 struct ot_task **task; 231 struct ot_task **task;
232 int64 sock = -1; 232 int64_t sock = -1;
233 233
234 *is_partial = 0; 234 *is_partial = 0;
235 235
diff --git a/ot_mutex.h b/ot_mutex.h
index ab1cf59..b5af96e 100644
--- a/ot_mutex.h
+++ b/ot_mutex.h
@@ -69,12 +69,12 @@ typedef enum {
69 69
70typedef unsigned long ot_taskid; 70typedef unsigned long ot_taskid;
71 71
72int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype); 72int mutex_workqueue_pushtask(int64_t sock, ot_tasktype tasktype);
73void mutex_workqueue_canceltask(int64 sock); 73void mutex_workqueue_canceltask(int64_t sock);
74void mutex_workqueue_pushsuccess(ot_taskid taskid); 74void mutex_workqueue_pushsuccess(ot_taskid taskid);
75ot_taskid mutex_workqueue_poptask(ot_tasktype *tasktype); 75ot_taskid mutex_workqueue_poptask(ot_tasktype *tasktype);
76int mutex_workqueue_pushresult(ot_taskid taskid, size_t iovec_entries, struct iovec *iovector); 76int mutex_workqueue_pushresult(ot_taskid taskid, size_t iovec_entries, struct iovec *iovector);
77int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec); 77int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec);
78int64 mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovector, int *is_partial); 78int64_t mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovector, int *is_partial);
79 79
80#endif 80#endif
diff --git a/ot_stats.c b/ot_stats.c
index 62c59c9..7945f4e 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -750,7 +750,7 @@ static void *stats_worker(void *args) {
750 return NULL; 750 return NULL;
751} 751}
752 752
753void stats_deliver(int64 sock, int tasktype) { mutex_workqueue_pushtask(sock, tasktype); } 753void stats_deliver(int64_t sock, int tasktype) { mutex_workqueue_pushtask(sock, tasktype); }
754 754
755static pthread_t thread_id; 755static pthread_t thread_id;
756void stats_init(void) { 756void stats_init(void) {
diff --git a/ot_stats.h b/ot_stats.h
index 8ed2b1e..203831c 100644
--- a/ot_stats.h
+++ b/ot_stats.h
@@ -42,7 +42,7 @@ enum {
42}; 42};
43 43
44void stats_issue_event(ot_status_event event, PROTO_FLAG proto, uintptr_t event_data); 44void stats_issue_event(ot_status_event event, PROTO_FLAG proto, uintptr_t event_data);
45void stats_deliver(int64 sock, int tasktype); 45void stats_deliver(int64_t sock, int tasktype);
46void stats_cleanup(void); 46void stats_cleanup(void);
47size_t return_stats_for_tracker(char *reply, int mode, int format); 47size_t return_stats_for_tracker(char *reply, int mode, int format);
48size_t stats_return_tracker_version(char *reply); 48size_t stats_return_tracker_version(char *reply);
diff --git a/ot_sync.c b/ot_sync.c
index fa6bb8b..dc71ddd 100644
--- a/ot_sync.c
+++ b/ot_sync.c
@@ -163,7 +163,7 @@ void sync_deinit( ) {
163 pthread_cancel( thread_id ); 163 pthread_cancel( thread_id );
164} 164}
165 165
166void sync_deliver( int64 socket ) { 166void sync_deliver( int64_t socket ) {
167 mutex_workqueue_pushtask( socket, TASK_SYNC_OUT ); 167 mutex_workqueue_pushtask( socket, TASK_SYNC_OUT );
168} 168}
169 169
diff --git a/ot_sync.h b/ot_sync.h
index 0fe0739..b6964fa 100644
--- a/ot_sync.h
+++ b/ot_sync.h
@@ -6,12 +6,14 @@
6#ifndef OT_SYNC_H__ 6#ifndef OT_SYNC_H__
7#define OT_SYNC_H__ 7#define OT_SYNC_H__
8 8
9#include <stdint.h>
10
9#ifdef WANT_SYNC_BATCH 11#ifdef WANT_SYNC_BATCH
10enum { SYNC_IN, SYNC_OUT }; 12enum { SYNC_IN, SYNC_OUT };
11 13
12void sync_init(); 14void sync_init();
13void sync_deinit(); 15void sync_deinit();
14void sync_deliver(int64 socket); 16void sync_deliver(int64_t socket);
15 17
16int add_changeset_to_tracker(uint8_t *data, size_t len); 18int add_changeset_to_tracker(uint8_t *data, size_t len);
17#else 19#else
diff --git a/ot_udp.c b/ot_udp.c
index d17f3ff..8e056db 100644
--- a/ot_udp.c
+++ b/ot_udp.c
@@ -71,7 +71,7 @@ static void udp_make_connectionid(uint32_t connid[2], const ot_ip6 remoteip, int
71} 71}
72 72
73/* UDP implementation according to http://xbtt.sourceforge.net/udp_tracker_protocol.html */ 73/* UDP implementation according to http://xbtt.sourceforge.net/udp_tracker_protocol.html */
74int handle_udp6(int64 serversocket, struct ot_workstruct *ws) { 74int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) {
75 ot_ip6 remoteip; 75 ot_ip6 remoteip;
76 uint32_t *inpacket = (uint32_t *)ws->inbuf; 76 uint32_t *inpacket = (uint32_t *)ws->inbuf;
77 uint32_t *outpacket = (uint32_t *)ws->outbuf; 77 uint32_t *outpacket = (uint32_t *)ws->outbuf;
@@ -203,7 +203,7 @@ int handle_udp6(int64 serversocket, struct ot_workstruct *ws) {
203} 203}
204 204
205static void *udp_worker(void *args) { 205static void *udp_worker(void *args) {
206 int64 sock = (int64)args; 206 int64_t sock = (int64_t)args;
207 struct ot_workstruct ws; 207 struct ot_workstruct ws;
208 memset(&ws, 0, sizeof(ws)); 208 memset(&ws, 0, sizeof(ws));
209 209
@@ -229,7 +229,7 @@ static void *udp_worker(void *args) {
229 return NULL; 229 return NULL;
230} 230}
231 231
232void udp_init(int64 sock, unsigned int worker_count) { 232void udp_init(int64_t sock, unsigned int worker_count) {
233 pthread_t thread_id; 233 pthread_t thread_id;
234 if (!g_rijndael_round_key[0]) 234 if (!g_rijndael_round_key[0])
235 udp_generate_rijndael_round_key(); 235 udp_generate_rijndael_round_key();
diff --git a/ot_udp.h b/ot_udp.h
index db48696..c670175 100644
--- a/ot_udp.h
+++ b/ot_udp.h
@@ -6,8 +6,10 @@
6#ifndef OT_UDP_H__ 6#ifndef OT_UDP_H__
7#define OT_UDP_H__ 7#define OT_UDP_H__
8 8
9void udp_init(int64 sock, unsigned int worker_count); 9#include <stdint.h>
10
11void udp_init(int64_t sock, unsigned int worker_count);
10void udp_kickoff(void); 12void udp_kickoff(void);
11int handle_udp6(int64 serversocket, struct ot_workstruct *ws); 13int handle_udp6(int64_t serversocket, struct ot_workstruct *ws);
12 14
13#endif 15#endif
diff --git a/proxy.c b/proxy.c
index 784e2a1..c2dc417 100644
--- a/proxy.c
+++ b/proxy.c
@@ -63,11 +63,11 @@ enum { OT_SYNC_PEER4, OT_SYNC_PEER6 };
63enum { FLAG_SERVERSOCKET = 1 }; 63enum { FLAG_SERVERSOCKET = 1 };
64 64
65/* For incoming packets */ 65/* For incoming packets */
66static int64 g_socket_in = -1; 66static int64_t g_socket_in = -1;
67static uint8_t g_inbuffer[LIVESYNC_INCOMING_BUFFSIZE]; 67static uint8_t g_inbuffer[LIVESYNC_INCOMING_BUFFSIZE];
68 68
69/* For outgoing packets */ 69/* For outgoing packets */
70static int64 g_socket_out = -1; 70static int64_t g_socket_out = -1;
71static uint8_t g_peerbuffer_start[LIVESYNC_OUTGOING_BUFFSIZE_PEERS]; 71static uint8_t g_peerbuffer_start[LIVESYNC_OUTGOING_BUFFSIZE_PEERS];
72static uint8_t *g_peerbuffer_pos; 72static uint8_t *g_peerbuffer_pos;
73static uint8_t *g_peerbuffer_highwater = g_peerbuffer_start + LIVESYNC_OUTGOING_BUFFSIZE_PEERS - LIVESYNC_OUTGOING_WATERMARK_PEERS; 73static uint8_t *g_peerbuffer_highwater = g_peerbuffer_start + LIVESYNC_OUTGOING_BUFFSIZE_PEERS - LIVESYNC_OUTGOING_WATERMARK_PEERS;
@@ -249,7 +249,7 @@ typedef struct {
249 uint8_t indata[8192 * 16]; /* Any data not processed yet */ 249 uint8_t indata[8192 * 16]; /* Any data not processed yet */
250 size_t indata_length; /* Length of unprocessed data */ 250 size_t indata_length; /* Length of unprocessed data */
251 uint32_t tracker_id; /* How the other end greeted */ 251 uint32_t tracker_id; /* How the other end greeted */
252 int64 fd; /* A file handle, if connected, <= 0 is disconnected (0 initially, -1 else) */ 252 int64_t fd; /* A file handle, if connected, <= 0 is disconnected (0 initially, -1 else) */
253 io_batch outdata; /* The iobatch containing our sync data */ 253 io_batch outdata; /* The iobatch containing our sync data */
254 254
255 size_t packet_tcount; /* Number of unprocessed torrents in packet we currently receive */ 255 size_t packet_tcount; /* Number of unprocessed torrents in packet we currently receive */
@@ -283,7 +283,7 @@ static void handle_reconnects(void) {
283 size_t i; 283 size_t i;
284 for (i = 0; i < g_connection_count; ++i) 284 for (i = 0; i < g_connection_count; ++i)
285 if (PROXYPEER_NEEDSCONNECT(g_connections[i].state)) { 285 if (PROXYPEER_NEEDSCONNECT(g_connections[i].state)) {
286 int64 newfd = socket_tcp6(); 286 int64_t newfd = socket_tcp6();
287 fprintf(stderr, "(Re)connecting to peer..."); 287 fprintf(stderr, "(Re)connecting to peer...");
288 if (newfd < 0) 288 if (newfd < 0)
289 continue; /* No socket for you */ 289 continue; /* No socket for you */
@@ -308,10 +308,10 @@ static void handle_reconnects(void) {
308} 308}
309 309
310/* Handle incoming connection requests, check against whitelist */ 310/* Handle incoming connection requests, check against whitelist */
311static void handle_accept(int64 serversocket) { 311static void handle_accept(int64_t serversocket) {
312 int64 newfd; 312 int64_t newfd;
313 ot_ip6 ip; 313 ot_ip6 ip;
314 uint16 port; 314 uint16 port;
315 315
316 while ((newfd = socket_accept6(serversocket, ip, &port, NULL)) != -1) { 316 while ((newfd = socket_accept6(serversocket, ip, &port, NULL)) != -1) {
317 317
@@ -351,9 +351,9 @@ static void handle_accept(int64 serversocket) {
351} 351}
352 352
353/* New sync data on the stream */ 353/* New sync data on the stream */
354static void handle_read(int64 peersocket) { 354static void handle_read(int64_t peersocket) {
355 int i; 355 int i;
356 int64 datalen; 356 int64_t datalen;
357 uint32_t tracker_id; 357 uint32_t tracker_id;
358 proxy_peer *peer = io_getcookie(peersocket); 358 proxy_peer *peer = io_getcookie(peersocket);
359 359
@@ -420,7 +420,7 @@ static void handle_read(int64 peersocket) {
420} 420}
421 421
422/* Can write new sync data to the stream */ 422/* Can write new sync data to the stream */
423static void handle_write(int64 peersocket) { 423static void handle_write(int64_t peersocket) {
424 proxy_peer *peer = io_getcookie(peersocket); 424 proxy_peer *peer = io_getcookie(peersocket);
425 425
426 if (!peer) { 426 if (!peer) {
@@ -472,7 +472,7 @@ static void handle_write(int64 peersocket) {
472} 472}
473 473
474static void server_mainloop() { 474static void server_mainloop() {
475 int64 sock; 475 int64_t sock;
476 uint32_t packet_type; 476 uint32_t packet_type;
477 477
478 /* inlined livesync_init() */ 478 /* inlined livesync_init() */
@@ -515,7 +515,7 @@ static void panic(const char *routine) {
515} 515}
516 516
517static int64_t ot_try_bind(ot_ip6 ip, uint16_t port) { 517static int64_t ot_try_bind(ot_ip6 ip, uint16_t port) {
518 int64 sock = socket_tcp6(); 518 int64_t sock = socket_tcp6();
519 519
520 if (socket_bind6_reuse(sock, ip, port, 0) == -1) 520 if (socket_bind6_reuse(sock, ip, port, 0) == -1)
521 panic("socket_bind6_reuse"); 521 panic("socket_bind6_reuse");