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 --- ot_livesync.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'ot_livesync.c') diff --git a/ot_livesync.c b/ot_livesync.c index efba4d7..b876ef8 100644 --- a/ot_livesync.c +++ b/ot_livesync.c @@ -4,15 +4,14 @@ $id$ */ /* System */ +#include #include #include #include #include -#include #include /* Libowfat */ -#include "byte.h" #include "ip6.h" #include "ndelay.h" #include "socket.h" @@ -58,6 +57,8 @@ static sync_buffer g_v4_buf; static pthread_t thread_id; void livesync_init(void) { + uint32_t packet_type6 = htonl(OT_SYNC_PEER6); + uint32_t packet_type4 = htonl(OT_SYNC_PEER4); if (g_socket_in == -1) exerr("No socket address for live sync specified."); @@ -66,8 +67,8 @@ void livesync_init(void) { memcpy(g_v6_buf.data, &g_tracker_id, sizeof(g_tracker_id)); memcpy(g_v4_buf.data, &g_tracker_id, sizeof(g_tracker_id)); - uint32_pack_big((char *)g_v6_buf.data + sizeof(g_tracker_id), OT_SYNC_PEER6); - uint32_pack_big((char *)g_v4_buf.data + sizeof(g_tracker_id), OT_SYNC_PEER4); + memcpy(g_v6_buf.data + sizeof(g_tracker_id), &packet_type6, sizeof(packet_type6)); + memcpy(g_v4_buf.data + sizeof(g_tracker_id), &packet_type4, sizeof(packet_type4)); g_v6_buf.fill = sizeof(g_tracker_id) + sizeof(uint32_t); g_v4_buf.fill = sizeof(g_tracker_id) + sizeof(uint32_t); @@ -216,6 +217,8 @@ static void *livesync_worker(void *args) { memcpy(in_ip, V4mappedprefix, sizeof(V4mappedprefix)); while (1) { + uint32_t packet_type; + ws.request_size = socket_recv4(g_socket_in, (char *)ws.inbuf, LIVESYNC_INCOMING_BUFFSIZE, 12 + (char *)in_ip, &in_port); /* Expect at least tracker id and packet type */ @@ -228,7 +231,9 @@ static void *livesync_worker(void *args) { continue; } - switch (uint32_read_big(sizeof(g_tracker_id) + (char *)ws.inbuf)) { + memcpy(&packet_type, ws.inbuf + sizeof(g_tracker_id), sizeof(packet_type)); + + switch (ntohl(packet_type)) { case OT_SYNC_PEER6: livesync_handle_peersync(&ws, OT_PEER_SIZE6); break; -- cgit v1.3