summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/opentracker.c b/opentracker.c
index 354e837..af336aa 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -24,17 +24,17 @@
24/* Libowfat */ 24/* Libowfat */
25#include "io.h" 25#include "io.h"
26#include "iob.h" 26#include "iob.h"
27#include "ip6.h"
28#include "socket.h" 27#include "socket.h"
29 28
30/* Opentracker */ 29/* Opentracker */
31#include "ot_accesslist.h" 30#include "ot_accesslist.h"
32#include "ot_hex.h" 31#include "ot_hex.h"
33#include "ot_http.h" 32#include "ot_http.h"
33#include "ot_ip.h"
34#include "ot_livesync.h" 34#include "ot_livesync.h"
35#include "ot_mutex.h" 35#include "ot_mutex.h"
36#include "ot_scan.h"
37#include "ot_random.h" 36#include "ot_random.h"
37#include "ot_scan.h"
38#include "ot_stats.h" 38#include "ot_stats.h"
39#include "ot_udp.h" 39#include "ot_udp.h"
40#include "trackerlogic.h" 40#include "trackerlogic.h"
@@ -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,14 +339,14 @@ 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 {
346 char *protos[] = {"TCP", "UDP", "UDP mcast"}; 346 char *protos[] = {"TCP", "UDP", "UDP mcast"};
347 char _debug[512]; 347 char _debug[512];
348 int off = snprintf(_debug, sizeof(_debug), "Binding socket type %s to address [", protos[proto]); 348 int off = snprintf(_debug, sizeof(_debug), "Binding socket type %s to address [", protos[proto]);
349 off += fmt_ip6c(_debug + off, ip); 349 off += ip_format(_debug + off, ip);
350 snprintf(_debug + off, sizeof(_debug) - off, "]:%d...", port); 350 snprintf(_debug + off, sizeof(_debug) - off, "]:%d...", port);
351 fputs(_debug, stderr); 351 fputs(_debug, stderr);
352 } 352 }
@@ -394,14 +394,14 @@ static int scan_ip6_port(const char *src, ot_ip6 ip, uint16_t *port) {
394 ++s; 394 ++s;
395 if (*s == '[') 395 if (*s == '[')
396 ++s, ++bracket; /* for v6 style notation */ 396 ++s, ++bracket; /* for v6 style notation */
397 if (!(off = scan_ip6(s, ip))) 397 if (!(off = ip_scan(s, ip)))
398 return 0; 398 return 0;
399 s += off; 399 s += off;
400 if (bracket && *s == ']') 400 if (bracket && *s == ']')
401 ++s; 401 ++s;
402 if (*s == 0 || isspace(*s)) 402 if (*s == 0 || isspace(*s))
403 return s - src; 403 return s - src;
404 if (!ip6_isv4mapped(ip)) { 404 if (!ip_is_v4mapped(ip)) {
405 if (*s != ':' && *s != '.') 405 if (*s != ':' && *s != '.')
406 return 0; 406 return 0;
407 if (!bracket && *(s) == ':') 407 if (!bracket && *(s) == ':')
@@ -423,7 +423,7 @@ static int scan_ip6_net(const char *src, ot_net *net) {
423 int off; 423 int off;
424 while (isspace(*s)) 424 while (isspace(*s))
425 ++s; 425 ++s;
426 if (!(off = scan_ip6(s, net->address))) 426 if (!(off = ip_scan(s, net->address)))
427 return 0; 427 return 0;
428 s += off; 428 s += off;
429 if (*s != '/') 429 if (*s != '/')
@@ -433,7 +433,7 @@ static int scan_ip6_net(const char *src, ot_net *net) {
433 if (!(off = scan_udec(s, &value, 128))) 433 if (!(off = scan_udec(s, &value, 128)))
434 return 0; 434 return 0;
435 net->bits = (int)value; 435 net->bits = (int)value;
436 if (ip6_isv4mapped(net->address)) 436 if (ip_is_v4mapped(net->address))
437 net->bits += 96; 437 net->bits += 96;
438 if (net->bits > 128) 438 if (net->bits > 128)
439 return 0; 439 return 0;
@@ -761,7 +761,7 @@ int main(int argc, char **argv) {
761 scanon = 0; 761 scanon = 0;
762 break; 762 break;
763 case 'i': 763 case 'i':
764 if (!scan_ip6(optarg, serverip)) { 764 if (!ip_scan(optarg, serverip)) {
765 usage(argv[0]); 765 usage(argv[0]);
766 exit(1); 766 exit(1);
767 } 767 }