From 6d97e999f1e7b4476faf749abbb5e925d09208c6 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 24 Oct 2026 00:15:34 +0200 Subject: Replace endianess helpers and remove unused system and libowfat included * Replace libowfat big endian packers with htonl/ntohl * Turn bucket derivation in ot_mutex.c into its own helper * remove unused includes --- proxy.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'proxy.c') diff --git a/proxy.c b/proxy.c index 5a7698b..cec985e 100644 --- a/proxy.c +++ b/proxy.c @@ -8,8 +8,6 @@ #include #include #include -#include -#include #include #include #include @@ -472,13 +470,15 @@ static void handle_write(int64 peersocket) { } static void server_mainloop() { - int64 sock; + int64 sock; + uint32_t packet_type; /* inlined livesync_init() */ memset(g_peerbuffer_start, 0, sizeof(g_peerbuffer_start)); g_peerbuffer_pos = g_peerbuffer_start; memcpy(g_peerbuffer_pos, &g_tracker_id, sizeof(g_tracker_id)); - uint32_pack_big((char *)g_peerbuffer_pos + sizeof(g_tracker_id), OT_SYNC_PEER); + packet_type = htonl(OT_SYNC_PEER); + memcpy(g_peerbuffer_pos + sizeof(g_tracker_id), &packet_type, sizeof(packet_type)); g_peerbuffer_pos += sizeof(g_tracker_id) + sizeof(uint32_t); g_next_packet_time = time(NULL) + LIVESYNC_MAXDELAY; @@ -870,6 +870,7 @@ static void *livesync_worker(void *args) { while (1) { ot_ip6 in_ip; uint16_t in_port; + uint32_t packet_type; size_t datalen = socket_recv4(g_socket_in, (char *)g_inbuffer, LIVESYNC_INCOMING_BUFFSIZE, 12 + (char *)in_ip, &in_port); /* Expect at least tracker id and packet type */ @@ -879,7 +880,9 @@ static void *livesync_worker(void *args) { /* drop packet coming from ourselves */ continue; } - switch (uint32_read_big((char *)g_inbuffer + sizeof(g_tracker_id))) { + memcpy(&packet_type, g_inbuffer + sizeof(g_tracker_id), sizeof(packet_type)); + + switch (ntohl(packet_type)) { case OT_SYNC_PEER4: livesync_handle_peersync(datalen, OT_PEER_SIZE4); break; @@ -887,7 +890,7 @@ static void *livesync_worker(void *args) { livesync_handle_peersync(datalen, OT_PEER_SIZE6); break; default: - // fprintf( stderr, "Received an unknown live sync packet type %u.\n", uint32_read_big( sizeof( g_tracker_id ) + (char*)g_inbuffer ) ); + // fprintf( stderr, "Received an unknown live sync packet type %u.\n", ntohl( packet_type ) ); break; } } -- cgit v1.3