diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-24 17:23:32 +0200 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-24 17:23:32 +0200 |
| commit | d61aefe2fc4d8549f459bdfc2749c9f163449ebc (patch) | |
| tree | df7502281c2c073dc0a07a5b8e2ebc238fbda851 | |
| parent | 0f4892b186312ddd5f836121124e21cb99e5682d (diff) | |
Replace libowfat's ip scanner and formatters with own own
| -rw-r--r-- | opentracker.c | 16 | ||||
| -rw-r--r-- | ot_accesslist.c | 6 | ||||
| -rw-r--r-- | ot_http.c | 10 | ||||
| -rw-r--r-- | ot_livesync.c | 10 | ||||
| -rw-r--r-- | ot_stats.c | 13 | ||||
| -rw-r--r-- | ot_udp.c | 4 | ||||
| -rw-r--r-- | proxy.c | 10 | ||||
| -rw-r--r-- | tests/runner.c | 1 | ||||
| -rw-r--r-- | tests/test.h | 1 | ||||
| -rw-r--r-- | trackerlogic.c | 8 |
10 files changed, 40 insertions, 39 deletions
diff --git a/opentracker.c b/opentracker.c index 354e837..8a39bde 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" |
| @@ -346,7 +346,7 @@ static int64_t ot_try_bind(ot_ip6 ip, uint16_t port, PROTO_FLAG proto) { | |||
| 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 | } |
diff --git a/ot_accesslist.c b/ot_accesslist.c index 9163ea9..2465ada 100644 --- a/ot_accesslist.c +++ b/ot_accesslist.c | |||
| @@ -22,11 +22,11 @@ | |||
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | /* Libowfat */ | 24 | /* Libowfat */ |
| 25 | #include "ip6.h" | ||
| 26 | 25 | ||
| 27 | /* Opentracker */ | 26 | /* Opentracker */ |
| 28 | #include "ot_accesslist.h" | 27 | #include "ot_accesslist.h" |
| 29 | #include "ot_hex.h" | 28 | #include "ot_hex.h" |
| 29 | #include "ot_ip.h" | ||
| 30 | #include "ot_vector.h" | 30 | #include "ot_vector.h" |
| 31 | #include "trackerlogic.h" | 31 | #include "trackerlogic.h" |
| 32 | 32 | ||
| @@ -556,10 +556,10 @@ int accesslist_bless_net(ot_net *net, ot_permissions permissions) { | |||
| 556 | { | 556 | { |
| 557 | char _debug[512]; | 557 | char _debug[512]; |
| 558 | int off = snprintf(_debug, sizeof(_debug), "Blessing ip net "); | 558 | int off = snprintf(_debug, sizeof(_debug), "Blessing ip net "); |
| 559 | off += fmt_ip6c(_debug + off, net->address); | 559 | off += ip_format(_debug + off, net->address); |
| 560 | if (net->bits < 128) { | 560 | if (net->bits < 128) { |
| 561 | _debug[off++] = '/'; | 561 | _debug[off++] = '/'; |
| 562 | if (ip6_isv4mapped(net->address)) | 562 | if (ip_is_v4mapped(net->address)) |
| 563 | off += snprintf(_debug + off, sizeof(_debug) - off, "%d", net->bits - 96); | 563 | off += snprintf(_debug + off, sizeof(_debug) - off, "%d", net->bits - 96); |
| 564 | else | 564 | else |
| 565 | off += snprintf(_debug + off, sizeof(_debug) - off, "%d", net->bits); | 565 | off += snprintf(_debug + off, sizeof(_debug) - off, "%d", net->bits); |
| @@ -16,13 +16,13 @@ | |||
| 16 | 16 | ||
| 17 | /* Libowfat */ | 17 | /* Libowfat */ |
| 18 | #include "iob.h" | 18 | #include "iob.h" |
| 19 | #include "ip6.h" | ||
| 20 | 19 | ||
| 21 | /* Opentracker */ | 20 | /* Opentracker */ |
| 22 | #include "ot_accesslist.h" | 21 | #include "ot_accesslist.h" |
| 23 | #include "ot_fullscrape.h" | 22 | #include "ot_fullscrape.h" |
| 24 | #include "ot_http.h" | 23 | #include "ot_http.h" |
| 25 | #include "ot_iovec.h" | 24 | #include "ot_iovec.h" |
| 25 | #include "ot_ip.h" | ||
| 26 | #include "ot_mutex.h" | 26 | #include "ot_mutex.h" |
| 27 | #include "ot_scan.h" | 27 | #include "ot_scan.h" |
| 28 | #include "ot_stats.h" | 28 | #include "ot_stats.h" |
| @@ -525,7 +525,7 @@ static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct * | |||
| 525 | if (accesslist_is_blessed(cookie->ip, OT_PERMISSION_MAY_PROXY)) { | 525 | if (accesslist_is_blessed(cookie->ip, OT_PERMISSION_MAY_PROXY)) { |
| 526 | ot_ip6 proxied_ip; | 526 | ot_ip6 proxied_ip; |
| 527 | char *fwd = http_header(ws->request, ws->header_size, "x-forwarded-for"); | 527 | char *fwd = http_header(ws->request, ws->header_size, "x-forwarded-for"); |
| 528 | if (fwd && scan_ip6(fwd, proxied_ip)) { | 528 | if (fwd && ip_scan(fwd, proxied_ip)) { |
| 529 | OT_SETIP(ws->peer, proxied_ip); | 529 | OT_SETIP(ws->peer, proxied_ip); |
| 530 | } else | 530 | } else |
| 531 | OT_SETIP(ws->peer, cookie->ip); | 531 | OT_SETIP(ws->peer, cookie->ip); |
| @@ -611,7 +611,7 @@ static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct * | |||
| 611 | char *tmp_buf1 = ws->reply, *tmp_buf2 = ws->reply + 16; | 611 | char *tmp_buf1 = ws->reply, *tmp_buf2 = ws->reply + 16; |
| 612 | len = scan_urlencoded_query(&read_ptr, tmp_buf2, SCAN_SEARCHPATH_VALUE); | 612 | len = scan_urlencoded_query(&read_ptr, tmp_buf2, SCAN_SEARCHPATH_VALUE); |
| 613 | tmp_buf2[len] = 0; | 613 | tmp_buf2[len] = 0; |
| 614 | if ((len <= 0) || !scan_ip6(tmp_buf2, tmp_buf1)) | 614 | if ((len <= 0) || !ip_scan(tmp_buf2, tmp_buf1)) |
| 615 | HTTPERROR_400_PARAM; | 615 | HTTPERROR_400_PARAM; |
| 616 | OT_SETIP(&ws->peer, tmp_buf1); | 616 | OT_SETIP(&ws->peer, tmp_buf1); |
| 617 | } break; | 617 | } break; |
| @@ -633,7 +633,7 @@ static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct * | |||
| 633 | loglist_reset(); | 633 | loglist_reset(); |
| 634 | return ws->reply_size = sprintf(ws->reply, "Successfully removed.\n"); | 634 | return ws->reply_size = sprintf(ws->reply, "Successfully removed.\n"); |
| 635 | } | 635 | } |
| 636 | parsed = scan_ip6(tmp_buf, net.address); | 636 | parsed = ip_scan(tmp_buf, net.address); |
| 637 | if (!parsed) | 637 | if (!parsed) |
| 638 | HTTPERROR_400_PARAM; | 638 | HTTPERROR_400_PARAM; |
| 639 | if (tmp_buf[parsed++] != '/') | 639 | if (tmp_buf[parsed++] != '/') |
| @@ -643,7 +643,7 @@ static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct * | |||
| 643 | if (!parsed) | 643 | if (!parsed) |
| 644 | HTTPERROR_400_PARAM; | 644 | HTTPERROR_400_PARAM; |
| 645 | bits = (signed short)value; | 645 | bits = (signed short)value; |
| 646 | if (ip6_isv4mapped(net.address)) | 646 | if (ip_is_v4mapped(net.address)) |
| 647 | bits += 96; | 647 | bits += 96; |
| 648 | } | 648 | } |
| 649 | net.bits = bits; | 649 | net.bits = bits; |
diff --git a/ot_livesync.c b/ot_livesync.c index c4dc6e5..f6bb28b 100644 --- a/ot_livesync.c +++ b/ot_livesync.c | |||
| @@ -13,11 +13,11 @@ | |||
| 13 | #include <unistd.h> | 13 | #include <unistd.h> |
| 14 | 14 | ||
| 15 | /* Libowfat */ | 15 | /* Libowfat */ |
| 16 | #include "ip6.h" | ||
| 17 | #include "socket.h" | 16 | #include "socket.h" |
| 18 | 17 | ||
| 19 | /* Opentracker */ | 18 | /* Opentracker */ |
| 20 | #include "ot_accesslist.h" | 19 | #include "ot_accesslist.h" |
| 20 | #include "ot_ip.h" | ||
| 21 | #include "ot_livesync.h" | 21 | #include "ot_livesync.h" |
| 22 | #include "ot_mutex.h" | 22 | #include "ot_mutex.h" |
| 23 | #include "ot_stats.h" | 23 | #include "ot_stats.h" |
| @@ -92,7 +92,7 @@ void livesync_bind_mcast(ot_ip6 ip, uint16_t port) { | |||
| 92 | char tmpip[4] = {0, 0, 0, 0}; | 92 | char tmpip[4] = {0, 0, 0, 0}; |
| 93 | char *v4ip; | 93 | char *v4ip; |
| 94 | 94 | ||
| 95 | if (!ip6_isv4mapped(ip)) | 95 | if (!ip_is_v4mapped(ip)) |
| 96 | exerr("v6 mcast support not yet available."); | 96 | exerr("v6 mcast support not yet available."); |
| 97 | v4ip = ip + 12; | 97 | v4ip = ip + 12; |
| 98 | 98 | ||
| @@ -140,14 +140,14 @@ static void livesync_handle_peersync(struct ot_workstruct *ws, size_t peer_size) | |||
| 140 | 140 | ||
| 141 | /* Prepare peer record for v4mapped expansion */ | 141 | /* Prepare peer record for v4mapped expansion */ |
| 142 | if (peer_size == OT_PEER_SIZE4) | 142 | if (peer_size == OT_PEER_SIZE4) |
| 143 | memcpy(&ws->peer, V4mappedprefix, sizeof(V4mappedprefix)); | 143 | memcpy(&ws->peer, ip_v4mapped_prefix, sizeof(ip_v4mapped_prefix)); |
| 144 | 144 | ||
| 145 | /* Now basic sanity checks have been done on the live sync packet | 145 | /* Now basic sanity checks have been done on the live sync packet |
| 146 | We might add more testing and logging. */ | 146 | We might add more testing and logging. */ |
| 147 | while ((ssize_t)(off + sizeof(ot_hash) + peer_size) <= ws->request_size) { | 147 | while ((ssize_t)(off + sizeof(ot_hash) + peer_size) <= ws->request_size) { |
| 148 | char *peer_ip = ws->request + off + sizeof(ot_hash); | 148 | char *peer_ip = ws->request + off + sizeof(ot_hash); |
| 149 | if (peer_size == OT_PEER_SIZE4) | 149 | if (peer_size == OT_PEER_SIZE4) |
| 150 | memcpy(&ws->peer[0] + sizeof(V4mappedprefix), peer_ip, peer_size); | 150 | memcpy(&ws->peer[0] + sizeof(ip_v4mapped_prefix), peer_ip, peer_size); |
| 151 | else | 151 | else |
| 152 | memcpy(&ws->peer, peer_ip, peer_size); | 152 | memcpy(&ws->peer, peer_ip, peer_size); |
| 153 | ws->hash = (ot_hash *)(ws->request + off); | 153 | ws->hash = (ot_hash *)(ws->request + off); |
| @@ -215,7 +215,7 @@ static void *livesync_worker(void *args) { | |||
| 215 | ws.inbuf = ws.request = malloc(LIVESYNC_INCOMING_BUFFSIZE); | 215 | ws.inbuf = ws.request = malloc(LIVESYNC_INCOMING_BUFFSIZE); |
| 216 | ws.outbuf = ws.reply = 0; | 216 | ws.outbuf = ws.reply = 0; |
| 217 | 217 | ||
| 218 | memcpy(in_ip, V4mappedprefix, sizeof(V4mappedprefix)); | 218 | memcpy(in_ip, ip_v4mapped_prefix, sizeof(ip_v4mapped_prefix)); |
| 219 | 219 | ||
| 220 | while (1) { | 220 | while (1) { |
| 221 | uint32_t packet_type; | 221 | uint32_t packet_type; |
| @@ -18,13 +18,12 @@ | |||
| 18 | 18 | ||
| 19 | /* Libowfat */ | 19 | /* Libowfat */ |
| 20 | #include "io.h" | 20 | #include "io.h" |
| 21 | #include "ip4.h" | ||
| 22 | #include "ip6.h" | ||
| 23 | 21 | ||
| 24 | /* Opentracker */ | 22 | /* Opentracker */ |
| 25 | #include "ot_accesslist.h" | 23 | #include "ot_accesslist.h" |
| 26 | #include "ot_hex.h" | 24 | #include "ot_hex.h" |
| 27 | #include "ot_iovec.h" | 25 | #include "ot_iovec.h" |
| 26 | #include "ot_ip.h" | ||
| 28 | #include "ot_mutex.h" | 27 | #include "ot_mutex.h" |
| 29 | #include "ot_stats.h" | 28 | #include "ot_stats.h" |
| 30 | #include "trackerlogic.h" | 29 | #include "trackerlogic.h" |
| @@ -206,7 +205,7 @@ static size_t stats_return_busy_networks(char *reply, stats_network_node *tree, | |||
| 206 | if (scores[i - 1]) { | 205 | if (scores[i - 1]) { |
| 207 | r += sprintf(r, "%08zd: ", scores[i - 1]); | 206 | r += sprintf(r, "%08zd: ", scores[i - 1]); |
| 208 | // #ifdef WANT_V6 | 207 | // #ifdef WANT_V6 |
| 209 | r += fmt_ip6c(r, networks[i - 1]); | 208 | r += ip_format(r, networks[i - 1]); |
| 210 | #if 0 | 209 | #if 0 |
| 211 | // XXX | 210 | // XXX |
| 212 | r += fmt_ip4( r, networks[i - 1]); | 211 | r += fmt_ip4( r, networks[i - 1]); |
| @@ -470,7 +469,7 @@ static void stats_return_fulllog(size_t *iovec_entries, struct iovec **iovector, | |||
| 470 | re = r + 32 * OT_STATS_TMPSIZE; | 469 | re = r + 32 * OT_STATS_TMPSIZE; |
| 471 | } | 470 | } |
| 472 | r += sprintf(r, "%08ld: ", loglist->time); | 471 | r += sprintf(r, "%08ld: ", loglist->time); |
| 473 | r += fmt_ip6c(r, loglist->ip); | 472 | r += ip_format(r, loglist->ip); |
| 474 | *r++ = '\n'; | 473 | *r++ = '\n'; |
| 475 | memcpy(r, loglist->data, loglist->size); | 474 | memcpy(r, loglist->data, loglist->size); |
| 476 | r += loglist->size; | 475 | r += loglist->size; |
| @@ -663,7 +662,7 @@ void stats_issue_event(ot_status_event event, PROTO_FLAG proto, uintptr_t event_ | |||
| 663 | *peerid_hex = 0; | 662 | *peerid_hex = 0; |
| 664 | } | 663 | } |
| 665 | 664 | ||
| 666 | ip_readable[fmt_ip6c(ip_readable, (char *)&ws->peer)] = 0; | 665 | ip_readable[ip_format(ip_readable, (char *)&ws->peer)] = 0; |
| 667 | #if 0 | 666 | #if 0 |
| 668 | /* XXX */ | 667 | /* XXX */ |
| 669 | ip_readable[ fmt_ip4( ip_readable, (char*)&ws->peer ) ] = 0; | 668 | ip_readable[ fmt_ip4( ip_readable, (char*)&ws->peer ) ] = 0; |
| @@ -687,7 +686,7 @@ void stats_issue_event(ot_status_event event, PROTO_FLAG proto, uintptr_t event_ | |||
| 687 | ot_ip6 *ip = (ot_ip6 *)event_data; /* ugly hack to transfer ip to stats */ | 686 | ot_ip6 *ip = (ot_ip6 *)event_data; /* ugly hack to transfer ip to stats */ |
| 688 | char _debug[512]; | 687 | char _debug[512]; |
| 689 | int off = snprintf(_debug, sizeof(_debug), "[%08d] scrp: ", (unsigned int)(g_now_seconds - ot_start_time) / 60); | 688 | int off = snprintf(_debug, sizeof(_debug), "[%08d] scrp: ", (unsigned int)(g_now_seconds - ot_start_time) / 60); |
| 690 | off += fmt_ip6c(_debug + off, *ip); | 689 | off += ip_format(_debug + off, *ip); |
| 691 | off += snprintf(_debug + off, sizeof(_debug) - off, " - FULL SCRAPE\n"); | 690 | off += snprintf(_debug + off, sizeof(_debug) - off, " - FULL SCRAPE\n"); |
| 692 | (void)write(2, _debug, off); | 691 | (void)write(2, _debug, off); |
| 693 | ot_full_scrape_request_count++; | 692 | ot_full_scrape_request_count++; |
| @@ -696,7 +695,7 @@ void stats_issue_event(ot_status_event event, PROTO_FLAG proto, uintptr_t event_ | |||
| 696 | ot_ip6 *ip = (ot_ip6 *)event_data; /* ugly hack to transfer ip to stats */ | 695 | ot_ip6 *ip = (ot_ip6 *)event_data; /* ugly hack to transfer ip to stats */ |
| 697 | char _debug[512]; | 696 | char _debug[512]; |
| 698 | int off = snprintf(_debug, sizeof(_debug), "[%08d] scrp: ", (unsigned int)(g_now_seconds - ot_start_time) / 60); | 697 | int off = snprintf(_debug, sizeof(_debug), "[%08d] scrp: ", (unsigned int)(g_now_seconds - ot_start_time) / 60); |
| 699 | off += fmt_ip6c(_debug + off, *ip); | 698 | off += ip_format(_debug + off, *ip); |
| 700 | off += snprintf(_debug + off, sizeof(_debug) - off, " - FULL SCRAPE\n"); | 699 | off += snprintf(_debug + off, sizeof(_debug) - off, " - FULL SCRAPE\n"); |
| 701 | (void)write(2, _debug, off); | 700 | (void)write(2, _debug, off); |
| 702 | ot_full_scrape_request_count++; | 701 | ot_full_scrape_request_count++; |
| @@ -12,10 +12,10 @@ | |||
| 12 | 12 | ||
| 13 | /* Libowfat */ | 13 | /* Libowfat */ |
| 14 | #include "io.h" | 14 | #include "io.h" |
| 15 | #include "ip6.h" | ||
| 16 | #include "socket.h" | 15 | #include "socket.h" |
| 17 | 16 | ||
| 18 | /* Opentracker */ | 17 | /* Opentracker */ |
| 18 | #include "ot_ip.h" | ||
| 19 | #include "ot_random.h" | 19 | #include "ot_random.h" |
| 20 | #include "ot_rijndael.h" | 20 | #include "ot_rijndael.h" |
| 21 | #include "ot_stats.h" | 21 | #include "ot_stats.h" |
| @@ -176,7 +176,7 @@ int handle_udp6(int64 serversocket, struct ot_workstruct *ws) { | |||
| 176 | } else { | 176 | } else { |
| 177 | /* Limit amount of peers to OT_MAX_PEERS_UDP */ | 177 | /* Limit amount of peers to OT_MAX_PEERS_UDP */ |
| 178 | uint32_t numwant = ntohl(inpacket[92 / 4]); | 178 | uint32_t numwant = ntohl(inpacket[92 / 4]); |
| 179 | size_t max_peers = ip6_isv4mapped(remoteip) ? OT_MAX_PEERS_UDP4 : OT_MAX_PEERS_UDP6; | 179 | size_t max_peers = ip_is_v4mapped(remoteip) ? OT_MAX_PEERS_UDP4 : OT_MAX_PEERS_UDP6; |
| 180 | if (numwant > max_peers) | 180 | if (numwant > max_peers) |
| 181 | numwant = max_peers; | 181 | numwant = max_peers; |
| 182 | 182 | ||
| @@ -19,13 +19,13 @@ | |||
| 19 | /* Libowfat */ | 19 | /* Libowfat */ |
| 20 | #include "io.h" | 20 | #include "io.h" |
| 21 | #include "iob.h" | 21 | #include "iob.h" |
| 22 | #include "ip6.h" | ||
| 23 | #include "socket.h" | 22 | #include "socket.h" |
| 24 | 23 | ||
| 25 | /* Opentracker */ | 24 | /* Opentracker */ |
| 25 | #include "ot_ip.h" | ||
| 26 | #include "ot_mutex.h" | 26 | #include "ot_mutex.h" |
| 27 | #include "ot_scan.h" | ||
| 28 | #include "ot_random.h" | 27 | #include "ot_random.h" |
| 28 | #include "ot_scan.h" | ||
| 29 | #include "ot_stats.h" | 29 | #include "ot_stats.h" |
| 30 | #include "ot_vector.h" | 30 | #include "ot_vector.h" |
| 31 | #include "trackerlogic.h" | 31 | #include "trackerlogic.h" |
| @@ -92,7 +92,7 @@ void livesync_bind_mcast(ot_ip6 ip, uint16_t port) { | |||
| 92 | char tmpip[4] = {0, 0, 0, 0}; | 92 | char tmpip[4] = {0, 0, 0, 0}; |
| 93 | char *v4ip; | 93 | char *v4ip; |
| 94 | 94 | ||
| 95 | if (!ip6_isv4mapped(ip)) | 95 | if (!ip_is_v4mapped(ip)) |
| 96 | exerr("v6 mcast support not yet available."); | 96 | exerr("v6 mcast support not yet available."); |
| 97 | v4ip = ip + 12; | 97 | v4ip = ip + 12; |
| 98 | 98 | ||
| @@ -539,14 +539,14 @@ static int scan_ip6_port(const char *src, ot_ip6 ip, uint16_t *port) { | |||
| 539 | ++s; | 539 | ++s; |
| 540 | if (*s == '[') | 540 | if (*s == '[') |
| 541 | ++s, ++bracket; /* for v6 style notation */ | 541 | ++s, ++bracket; /* for v6 style notation */ |
| 542 | if (!(off = scan_ip6(s, ip))) | 542 | if (!(off = ip_scan(s, ip))) |
| 543 | return 0; | 543 | return 0; |
| 544 | s += off; | 544 | s += off; |
| 545 | if (*s == 0 || isspace(*s)) | 545 | if (*s == 0 || isspace(*s)) |
| 546 | return s - src; | 546 | return s - src; |
| 547 | if (*s == ']' && bracket) | 547 | if (*s == ']' && bracket) |
| 548 | ++s; | 548 | ++s; |
| 549 | if (!ip6_isv4mapped(ip)) { | 549 | if (!ip_is_v4mapped(ip)) { |
| 550 | if ((bracket && *(s) != ':') || (*(s) != '.')) | 550 | if ((bracket && *(s) != ':') || (*(s) != '.')) |
| 551 | return 0; | 551 | return 0; |
| 552 | s++; | 552 | s++; |
diff --git a/tests/runner.c b/tests/runner.c index 25456bc..10b6625 100644 --- a/tests/runner.c +++ b/tests/runner.c | |||
| @@ -21,6 +21,7 @@ static const struct module modules[] = {{"scan_urlencoded_query", test_scan_urle | |||
| 21 | {"ot_hex", test_hex}, | 21 | {"ot_hex", test_hex}, |
| 22 | {"ot_scan", test_scan}, | 22 | {"ot_scan", test_scan}, |
| 23 | {"ot_buf", test_buf}, | 23 | {"ot_buf", test_buf}, |
| 24 | {"ot_ip", test_ip}, | ||
| 24 | {"ot_accesslist", test_accesslist}, | 25 | {"ot_accesslist", test_accesslist}, |
| 25 | {NULL, NULL}}; | 26 | {NULL, NULL}}; |
| 26 | 27 | ||
diff --git a/tests/test.h b/tests/test.h index 676ca33..7449b73 100644 --- a/tests/test.h +++ b/tests/test.h | |||
| @@ -84,5 +84,6 @@ void test_hex(void); | |||
| 84 | void test_accesslist(void); | 84 | void test_accesslist(void); |
| 85 | void test_scan(void); | 85 | void test_scan(void); |
| 86 | void test_buf(void); | 86 | void test_buf(void); |
| 87 | void test_ip(void); | ||
| 87 | 88 | ||
| 88 | #endif | 89 | #endif |
diff --git a/trackerlogic.c b/trackerlogic.c index d8a2f9b..f5e3dc0 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
| @@ -13,19 +13,19 @@ | |||
| 13 | /* Libowfat */ | 13 | /* Libowfat */ |
| 14 | #include "io.h" | 14 | #include "io.h" |
| 15 | #include "iob.h" | 15 | #include "iob.h" |
| 16 | #include "ip6.h" | ||
| 17 | 16 | ||
| 18 | /* Opentracker */ | 17 | /* Opentracker */ |
| 19 | #include "ot_accesslist.h" | 18 | #include "ot_accesslist.h" |
| 20 | #include "ot_clean.h" | 19 | #include "ot_clean.h" |
| 21 | #include "ot_fullscrape.h" | 20 | #include "ot_fullscrape.h" |
| 22 | #include "ot_http.h" | 21 | #include "ot_http.h" |
| 22 | #include "ot_ip.h" | ||
| 23 | #include "ot_livesync.h" | 23 | #include "ot_livesync.h" |
| 24 | #include "ot_mutex.h" | 24 | #include "ot_mutex.h" |
| 25 | #include "ot_random.h" | 25 | #include "ot_random.h" |
| 26 | #include "ot_stats.h" | 26 | #include "ot_stats.h" |
| 27 | #include "ot_vector.h" | ||
| 28 | #include "ot_udp.h" | 27 | #include "ot_udp.h" |
| 28 | #include "ot_vector.h" | ||
| 29 | #include "trackerlogic.h" | 29 | #include "trackerlogic.h" |
| 30 | 30 | ||
| 31 | /* Forward declaration */ | 31 | /* Forward declaration */ |
| @@ -511,7 +511,7 @@ void iterate_all_torrents(int (*for_each)(ot_torrent *torrent, uintptr_t data), | |||
| 511 | 511 | ||
| 512 | ot_peer *peer_from_peer6(ot_peer6 *peer, size_t *peer_size) { | 512 | ot_peer *peer_from_peer6(ot_peer6 *peer, size_t *peer_size) { |
| 513 | ot_ip6 *ip = (ot_ip6 *)peer; | 513 | ot_ip6 *ip = (ot_ip6 *)peer; |
| 514 | if (!ip6_isv4mapped(ip)) { | 514 | if (!ip_is_v4mapped(ip)) { |
| 515 | *peer_size = OT_PEER_SIZE6; | 515 | *peer_size = OT_PEER_SIZE6; |
| 516 | return (ot_peer *)peer; | 516 | return (ot_peer *)peer; |
| 517 | } | 517 | } |
| @@ -521,7 +521,7 @@ ot_peer *peer_from_peer6(ot_peer6 *peer, size_t *peer_size) { | |||
| 521 | 521 | ||
| 522 | size_t peer_size_from_peer6(ot_peer6 *peer) { | 522 | size_t peer_size_from_peer6(ot_peer6 *peer) { |
| 523 | ot_ip6 *ip = (ot_ip6 *)peer; | 523 | ot_ip6 *ip = (ot_ip6 *)peer; |
| 524 | if (!ip6_isv4mapped(ip)) | 524 | if (!ip_is_v4mapped(ip)) |
| 525 | return OT_PEER_SIZE6; | 525 | return OT_PEER_SIZE6; |
| 526 | return OT_PEER_SIZE4; | 526 | return OT_PEER_SIZE4; |
| 527 | } | 527 | } |
