diff options
Diffstat (limited to 'proxy.c')
| -rw-r--r-- | proxy.c | 26 |
1 files changed, 13 insertions, 13 deletions
| @@ -63,11 +63,11 @@ enum { OT_SYNC_PEER4, OT_SYNC_PEER6 }; | |||
| 63 | enum { FLAG_SERVERSOCKET = 1 }; | 63 | enum { FLAG_SERVERSOCKET = 1 }; |
| 64 | 64 | ||
| 65 | /* For incoming packets */ | 65 | /* For incoming packets */ |
| 66 | static int64 g_socket_in = -1; | 66 | static int64_t g_socket_in = -1; |
| 67 | static uint8_t g_inbuffer[LIVESYNC_INCOMING_BUFFSIZE]; | 67 | static uint8_t g_inbuffer[LIVESYNC_INCOMING_BUFFSIZE]; |
| 68 | 68 | ||
| 69 | /* For outgoing packets */ | 69 | /* For outgoing packets */ |
| 70 | static int64 g_socket_out = -1; | 70 | static int64_t g_socket_out = -1; |
| 71 | static uint8_t g_peerbuffer_start[LIVESYNC_OUTGOING_BUFFSIZE_PEERS]; | 71 | static uint8_t g_peerbuffer_start[LIVESYNC_OUTGOING_BUFFSIZE_PEERS]; |
| 72 | static uint8_t *g_peerbuffer_pos; | 72 | static uint8_t *g_peerbuffer_pos; |
| 73 | static uint8_t *g_peerbuffer_highwater = g_peerbuffer_start + LIVESYNC_OUTGOING_BUFFSIZE_PEERS - LIVESYNC_OUTGOING_WATERMARK_PEERS; | 73 | static 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 */ |
| 311 | static void handle_accept(int64 serversocket) { | 311 | static 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 */ |
| 354 | static void handle_read(int64 peersocket) { | 354 | static 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 */ |
| 423 | static void handle_write(int64 peersocket) { | 423 | static 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 | ||
| 474 | static void server_mainloop() { | 474 | static 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 | ||
| 517 | static int64_t ot_try_bind(ot_ip6 ip, uint16_t port) { | 517 | static 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"); |
